Add test for the EmptyBlock parser error

This commit is contained in:
Ben Fradet 2019-04-21 21:50:08 +02:00
parent cdcdf92374
commit 4d18134a30

View File

@ -55,7 +55,7 @@ module Unison.Test.FileParser where
test :: Test ()
test = scope "fileparser" . tests $
[test1, emptyWatchTest, signatureNeedsAccompanyingBodyTest]
[test1, emptyWatchTest, signatureNeedsAccompanyingBodyTest, emptyBlockTest]
expectFileParseFailure :: String -> (P.Error Symbol -> Test ()) -> Test ()
expectFileParseFailure s expectation = scope s $ do
@ -87,6 +87,15 @@ module Unison.Test.FileParser where
P.SignatureNeedsAccompanyingBody _ -> ok
_ -> crash "Error wasn't SignatureNeedsAccompanyingBody"
emptyBlockTest :: Test ()
emptyBlockTest = scope "emptyBlockTest" $
expectFileParseFailure (unlines ["f a =", "", "> 1 + 1"]) expectation
where
expectation :: Var e => P.Error e -> Test ()
expectation e = case e of
P.EmptyBlock _ -> ok
_ -> crash "Error wasn't EmptyBlock"
builtins :: Names
builtins = Names.fromTerms
[ ("Pair" , Referent.Con (R.Builtin "Pair") 0)