Commit 0d400313 authored by Hans-Peter Deifel's avatar Hans-Peter Deifel 🐢

parseFunctor: Fail for trailing junk

This means that "Xfoo" won't parse, but "X" will. Previously, non-parsable
suffixes had been ignored.
parent 3a01062a
......@@ -150,6 +150,7 @@ test-suite spec
, Copar.FunctorExpression.PrettySpec
, Copar.FunctorExpression.SortsSpec
, Copar.Coalgebra.ParserSpec
, Copar.ParserSpec
, Copar.Parser.LexerSpec
, Copar.Algorithm.InitializeSpec
, Copar.Algorithm.SplitSpec
......
......@@ -113,7 +113,7 @@ parseFunctor name input =
in bimap
errorBundlePretty
id
(parse (functorExpressionParser identity functorParsers) name input)
(parse (functorExpressionParser identity functorParsers <* eof) name input)
where
functorParsers = map (map functorExprParser) registeredFunctors
......
module Copar.ParserSpec (spec) where
import Test.Hspec
import Data.Either
import Copar.Parser
spec :: Spec
spec = do
parseFunctorSpec
parseFunctorSpec :: Spec
parseFunctorSpec = describe "parseFunctor" $ do
it "it fails for trailing junk" $
parseFunctor "" "Xfoo" `shouldSatisfy` isLeft
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment