💕 Adding assignment 2
This commit is contained in:
26
a2/a2-handout/src/APL/Check_Tests.hs
Normal file
26
a2/a2-handout/src/APL/Check_Tests.hs
Normal file
@ -0,0 +1,26 @@
|
||||
module APL.Check_Tests (tests) where
|
||||
|
||||
import APL.AST (Exp (..))
|
||||
import APL.Check (checkExp)
|
||||
import Test.Tasty (TestTree, testGroup)
|
||||
import Test.Tasty.HUnit (assertFailure, testCase, (@?=))
|
||||
|
||||
-- Assert that the provided expression should pass the type checker.
|
||||
testPos :: Exp -> TestTree
|
||||
testPos e =
|
||||
testCase (show e) $
|
||||
checkExp e @?= Nothing
|
||||
|
||||
-- Assert that the provided expression should fail the type checker.
|
||||
testNeg :: Exp -> TestTree
|
||||
testNeg e =
|
||||
testCase (show e) $
|
||||
case checkExp e of
|
||||
Nothing -> assertFailure "expected error"
|
||||
Just _ -> pure ()
|
||||
|
||||
tests :: TestTree
|
||||
tests =
|
||||
testGroup
|
||||
"Checking"
|
||||
[]
|
Reference in New Issue
Block a user