diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/Spec.hs | 6 | ||||
-rw-r--r-- | test/TypecheckTest.hs | 14 |
2 files changed, 20 insertions, 0 deletions
diff --git a/test/Spec.hs b/test/Spec.hs new file mode 100644 index 0000000..4e3f0c1 --- /dev/null +++ b/test/Spec.hs @@ -0,0 +1,6 @@ +import Test.Hspec +import TypecheckTest +main :: IO () +main = hspec $ do + typecheckTest + diff --git a/test/TypecheckTest.hs b/test/TypecheckTest.hs new file mode 100644 index 0000000..b08574a --- /dev/null +++ b/test/TypecheckTest.hs @@ -0,0 +1,14 @@ +module TypecheckTest + where +import Typecheck +import Syntax +import Test.Hspec +typecheckTest :: Spec +typecheckTest = describe "inferExpr" $ do + it "can infer variables" $ do + inferExpr (Var "a") [("a", TInt)] `shouldBe` Just TInt + inferExpr (Var "a") [("a", TRecord [("b",TInt)])] `shouldBe` (Just $ TRecord [("b",TInt)]) + inferExpr (Var "a") [("a", TVariant [("b",TInt)])] `shouldBe` (Just $ TVariant[("b",TInt)]) + inferExpr (Var "a") [("a", TPtr TInt)] `shouldBe` ( Just $ TPtr TInt ) + it "shouldn't infer undefined variables" $ do + inferExpr (Var "a") [] `shouldBe` Nothing |