File: test_api.cppo.ml

package info (click to toggle)
ppx-deriving 6.1.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 532 kB
  • sloc: ml: 3,983; makefile: 26; sh: 15
file content (26 lines) | stat: -rw-r--r-- 718 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
open OUnit2

let string_of_tyvar tyvar =
  tyvar.Location.txt

let test_free_vars ctxt =
  let loc = !Ast_helper.default_loc in
  let free_vars = Ppx_deriving.free_vars_in_core_type in
  let (!!) li = List.map string_of_tyvar li in
  let printer li =
    List.map (Printf.sprintf "%S") li |> String.concat ", " in
  assert_equal ~printer
    !!(free_vars [%type: int]) [];
  assert_equal ~printer
    !!(free_vars [%type: 'a option]) ["a"];
  assert_equal ~printer
    !!(free_vars [%type: ('a, 'b) result]) ["a"; "b"];
  assert_equal ~printer
    !!(free_vars [%type: ('a, 'b * 'a) result]) ["a"; "b"];
  ()

let suite = "Test API" >::: [
    "test_free_vars" >:: test_free_vars;
  ]

let () = run_test_tt_main suite