1
0
Fork 0
This repository has been archived on 2024-05-03. You can view files and clone it, but cannot push or open issues or pull requests.
unification-pfa/test/test_projet_pfa_23_24.ml

33 lines
817 B
OCaml
Raw Normal View History

2024-03-11 09:31:56 +01:00
open TypeInference
2024-03-11 15:18:02 +01:00
let tests_typeof =
(* TODO: add more tests *)
2024-03-11 09:31:56 +01:00
let x = Identifier.fresh () in
let y = Identifier.fresh () in
2024-03-11 15:18:02 +01:00
[ "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))) )
]
;;
2024-03-11 14:25:40 +01:00
2024-03-11 09:31:56 +01:00
let typeModule = (module Type : Alcotest.TESTABLE with type t = Type.t)
let check_typeof term_text term expected_type =
let open Alcotest in
2024-03-11 15:18:02 +01:00
test_case term_text `Quick (fun () ->
check (option typeModule) "Same type" expected_type (Inference.typeof term))
;;
2024-03-11 09:31:56 +01:00
let () =
let open Alcotest in
2024-03-11 15:18:02 +01:00
run
"Inference"
[ ( "typeof"
, List.map
(fun (term_text, term, expected_type) ->
check_typeof term_text term expected_type)
tests_typeof )
2024-03-11 09:31:56 +01:00
]
2024-03-11 15:18:02 +01:00
;;