Add multiple tests
This commit is contained in:
parent
ae73de8f64
commit
3d29e88f2a
1 changed files with 16 additions and 1 deletions
|
@ -3,6 +3,7 @@ open TypeInference
|
|||
let tests_typeof =
|
||||
let x = Identifier.fresh () in
|
||||
let y = Identifier.fresh () in
|
||||
let z = Identifier.fresh () in
|
||||
[ (* IntConst *)
|
||||
"0", Term.IntConst 0, Some Type.Int
|
||||
; (* int -> int -> int = <fun> *)
|
||||
|
@ -10,7 +11,7 @@ let tests_typeof =
|
|||
, Term.(Fun (x, Fun (y, Binop (Var x, Plus, Var y))))
|
||||
, Some Type.(Arrow (Int, Arrow (Int, Int))) )
|
||||
; (* Not typed variable *)
|
||||
"x", Term.(Var "x"), Some (Type.Var "x")
|
||||
"x", Term.(Var "x"), None
|
||||
; (* Binary operation *)
|
||||
"1 + 2", Term.(Binop (IntConst 1, Plus, IntConst 2)), Some Type.Int
|
||||
; (* Pair *)
|
||||
|
@ -27,6 +28,20 @@ let tests_typeof =
|
|||
( "(fun x -> x + 1) (1, 2)"
|
||||
, Term.(App (Fun (x, Binop (Var x, Plus, IntConst 1)), Pair (IntConst 1, IntConst 2)))
|
||||
, None )
|
||||
; (* int -> int -> int = <fun> *)
|
||||
( "fun x -> fun y -> x * y"
|
||||
, Term.(Fun (x, Fun (y, Binop (Var x, Times, Var y))))
|
||||
, Some Type.(Arrow (Int, Arrow (Int, Int))) )
|
||||
; (* int -> int -> int = <fun> *)
|
||||
( "fun x -> fun y -> x - y"
|
||||
, Term.(Fun (x, Fun (y, Binop (Var x, Minus, Var y))))
|
||||
, Some Type.(Arrow (Int, Arrow (Int, Int))) )
|
||||
; (* int -> int -> int = <fun> *)
|
||||
( "fun x -> fun y -> y / x"
|
||||
, Term.(Fun (x, Fun (y, Binop (Var y, Div, Var x))))
|
||||
, Some Type.(Arrow (Int, Arrow (Int, Int))) )
|
||||
; (* Use of a non declared variable *)
|
||||
"fun x -> fun y -> y / z", Term.(Fun (x, Fun (y, Binop (Var y, Div, Var z)))), None
|
||||
]
|
||||
;;
|
||||
|
||||
|
|
Reference in a new issue