about summary refs log tree commit diff
path: root/test/TypecheckTest.hs
blob: b08574a465ca73edbdd4921ca4e5b0d61d1a060b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
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