diff --git a/test/test_projet_pfa_23_24.ml b/test/test_projet_pfa_23_24.ml index ac27b50..5e3f434 100644 --- a/test/test_projet_pfa_23_24.ml +++ b/test/test_projet_pfa_23_24.ml @@ -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 = *) @@ -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 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 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 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 ] ;;