open TypeInference let tests_typeof = (* TODO: add more tests *) let x = Identifier.fresh () in let y = Identifier.fresh () in [ "0", Term.IntConst 0, Some Type.Int ; ( "fun x -> fun y -> x+y" , Term.(Fun (x, Fun (y, Binop (Var x, Plus, Var y)))) , Some Type.(Arrow (Int, Arrow (Int, Int))) ) ] ;; let typeModule = (module Type : Alcotest.TESTABLE with type t = Type.t) let check_typeof term_text term expected_type = let open Alcotest in test_case term_text `Quick (fun () -> check (option typeModule) "Same type" expected_type (Inference.typeof term)) ;; let () = let open Alcotest in run "Inference" [ ( "typeof" , List.map (fun (term_text, term, expected_type) -> check_typeof term_text term expected_type) tests_typeof ) ] ;;