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

parseFunctor: Fail for trailing junk

This means that "Xfoo" won't parse, but "X" will. Previously, non-parsable
suffixes had been ignored.
parent 3a01062a
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -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
+1 −1
Original line number Diff line number Diff line
@@ -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

+14 −0
Original line number Diff line number Diff line
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