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 to_string pp t = Format.fprintf Format.str_formatter "%a@." pp t; Format.flush_str_formatter () ;; let print_tests = [ "Int"; "Empty"; "(Int,Int)"; "Int -> Int"; "Bool -> Bool"; "Int -> 'A"; "[] -> []"; "Int -> 'A"; "('A -> Bool)"; "('B -> 'B)"; "(Int -> Bool)"; "(Int -> Int) | (Bool -> Bool)"; "(Int -> Int) | (Bool -> Bool)"; "([0--*] & `true)"; "('A | Int) & ((Any \\ 'A) | Bool)"; "('A | ('B , 'C))"; "(Int , Int)"; "('A -> 'B) -> [ 'A ] -> [ 'B ]"; "((Int -> Bool) | (('A \\ Int) -> ('B \\ Int))) -> 'Gamma"; "(('A , Int) & ('B , Bool))"; "(Int , (*Int & Bool*) Empty)"; "(('A , Int) | ('B , Bool))"; "(Int , (Int | Bool))"; "((Int | Bool) -> Int)"; "((Int | Bool) -> Int)"; "(Int -> Int) | (Bool -> Bool)"; "((Int,Int) , (Int | Bool))"; "('A,Int) | (('B,Int),Bool)"; "(('A , Int) | ('B , Bool))"; "(Int , (Int | Bool))"; "(('A , Int) & ('B , Bool))"; "(Int , (Int & Bool))"; "('A -> 'B) -> ['A ] -> ['B ]"; "((Int -> Bool) & (('A \\ Int) -> ('A \\ Int)))"; "((Int -> Int) & (Bool -> Bool)) -> 'T"; ] let test_print = "test print module" >::: List.map (fun s -> (Printf.sprintf " Printing %s " s) >:: (fun _ -> let t = parse_typ s in Format.printf "String : %s\n" s; Format.printf "Print : %a\n\n" Types.Print.pp_value t; (* Format.printf "Dump : %a\n\n" Types.dump t; *) assert_equal true true ) ) print_tests ;; let suite = "tests" >::: [ test_print; ] let main () = OUnit.run_test_tt_main suite ;; main ()