packages feed

htoml-megaparsec-1.1.0.3: test/Text/TomlSpec.hs

{-# LANGUAGE OverloadedStrings #-}

module Text.TomlSpec (hspecTests) where

import           Data.List.NonEmpty
import qualified Data.Set           as Set
import           Test.Hspec
import           Text.Megaparsec
import           Text.Toml

hspecTests :: Spec
hspecTests =
  describe "parser" $
  it "should not parse re-assignment of key" $ do
  let actual = parseTomlDoc "noSrc" "q={k=42, k=43}\nd=str"
  actual `shouldBe` Left (FancyError (SourcePos "noSrc" (mkPos 1) (mkPos 15) :| []) (Set.fromList [ErrorFail "Cannot redefine key k"]))