open OUnit (* open Types *) let parse_typ s = let st = Stream.of_string s in let astpat = Parser.pat st in let nodepat = Typer.typ Builtin.env astpat in Types.descr nodepat ;; let cup = Types.Tallying.CS.S.cup let cap = Types.Tallying.CS.cap let singleton = Types.Tallying.CS.singleton let norm_tests = [ "Int \\ (`$A | `$B)", singleton (false,`Var "A",parse_typ "Int \\ `$B"); "(`$A -> Int) \\ (`$B -> `$B)", cup (singleton (true,`Var "B",parse_typ "Empty")) (cap (singleton (false , `Var "B",parse_typ "`$A")) (singleton (false , `Var "B",parse_typ "Int")) ); "`$B", singleton (true,`Var "B",parse_typ "Empty"); "`$B \\ `$A", singleton (false , `Var "B",parse_typ "`$A"); "Int \\ `$B", singleton (false , `Var "B",parse_typ "Int"); "(Int & Bool -> Int) \\ (`$A -> `$B)" ] let test_norm = "test tallying norm" >::: List.map (fun (t,expected) -> (Printf.sprintf " %s " t) >:: (fun _ -> let ll = Types.Tallying.norm (parse_typ t) in assert_equal ll expected ) ) norm_tests ;; let all = "all tests" >::: [ test_norm; ] let main () = OUnit.run_test_tt_main all ;; main ()