diff options
author | Paweł Dybiec <pawel.to.malpa@gmail.com> | 2020-01-08 20:22:14 +0100 |
---|---|---|
committer | Paweł Dybiec <pawel.to.malpa@gmail.com> | 2020-01-08 20:22:14 +0100 |
commit | ea41a7529715987941257a0330c1eb1ae08cc12c (patch) | |
tree | 825c5a1507d253dac04ef43c136449b117f931f0 /test |
Initial commit
Initial version of project. What is done:
* Syntax of expressions,commands,programs and types
* Crude typechecking
* Some typechecking tests
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 |