diff options
author | Stephane Glondu <steph@glondu.net> | 2020-07-25 14:08:15 +0200 |
---|---|---|
committer | Stephane Glondu <steph@glondu.net> | 2020-07-25 14:08:15 +0200 |
commit | 7de507169d624bae7b8080ecff1892bc00efae66 (patch) | |
tree | e840dae068f1b24b957dbe6f74825372f3e1845c /src_test | |
parent | d8ec95e219762a402fea7edd51d80b462c3e839a (diff) |
New upstream version 4.4.1
Diffstat (limited to 'src_test')
-rw-r--r-- | src_test/api/dune | 9 | ||||
-rw-r--r-- | src_test/api/test_api.cppo.ml | 30 | ||||
-rw-r--r-- | src_test/show/test_deriving_show.cppo.ml | 4 |
3 files changed, 43 insertions, 0 deletions
diff --git a/src_test/api/dune b/src_test/api/dune new file mode 100644 index 0000000..b5e850c --- /dev/null +++ b/src_test/api/dune @@ -0,0 +1,9 @@ +(rule + (deps test_api.cppo.ml) + (targets test_api.ml) + (action (run %{bin:cppo} -V OCAML:%{ocaml_version} %{deps} -o %{targets}))) + +(test + (name test_api) + (libraries oUnit compiler-libs.common ppx_deriving.api) + (preprocess (action (run ppxfind -legacy ppx_tools.metaquot --as-pp %{input-file})))) diff --git a/src_test/api/test_api.cppo.ml b/src_test/api/test_api.cppo.ml new file mode 100644 index 0000000..8bdde64 --- /dev/null +++ b/src_test/api/test_api.cppo.ml @@ -0,0 +1,30 @@ +open Parsetree +open OUnit2 + +let string_of_tyvar tyvar = +#if OCAML_VERSION >= (4, 05, 0) + tyvar.Location.txt +#else + tyvar +#endif + +let test_free_vars ctxt = + 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 diff --git a/src_test/show/test_deriving_show.cppo.ml b/src_test/show/test_deriving_show.cppo.ml index 093ce0f..04043d7 100644 --- a/src_test/show/test_deriving_show.cppo.ml +++ b/src_test/show/test_deriving_show.cppo.ml @@ -85,6 +85,7 @@ let test_record ctxt = assert_equal ~printer "{ Test_deriving_show.f1 = 1; f2 = \"foo\"; f3 = <opaque> }" (show_re { f1 = 1; f2 = "foo"; f3 = 1.0 }) +#if OCAML_VERSION >= (4, 03, 0) type variant = Foo of { f1 : int; f2 : string; @@ -94,6 +95,7 @@ let test_variant_record ctxt = assert_equal ~printer "Test_deriving_show.Foo {f1 = 1; f2 = \"foo\"; f3 = <opaque>}" (show_variant (Foo { f1 = 1; f2 = "foo"; f3 = 1.0 })) +#endif module M : sig @@ -257,7 +259,9 @@ let suite = "Test deriving(show)" >::: [ "test_poly" >:: test_poly; "test_poly_inherit" >:: test_poly_inherit; "test_record" >:: test_record; +#if OCAML_VERSION >= (4, 03, 0) "test_variant_record" >:: test_variant_record; +#endif "test_abstr" >:: test_abstr; "test_custom" >:: test_custom; "test_parametric" >:: test_parametric; |