Skip to content

Commit

Permalink
add back some variant tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jchavarri committed Nov 26, 2024
1 parent 2899658 commit 0a3e9c9
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ppx/test/example.ml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ let of_json_cases = [
C ({|["P2", 42, "hello"]|}, poly2_of_json, poly2_to_json, (`P2 (42, "hello") : poly2));
C ({|["Fix",["Fix",["Fix",["A"]]]]|}, recur_of_json, recur_to_json, (Fix (Fix (Fix A))));
C ({|["Fix",["Fix",["Fix",["A"]]]]|}, polyrecur_of_json, polyrecur_to_json, (`Fix (`Fix (`Fix `A))));
C ({|["A"]|}, evar_of_json, evar_to_json, (A : evar));
C ({|["b_aliased"]|}, evar_of_json, evar_to_json, (B : evar)); (* variant B repr as "b_aliased" in JSON *)
C ({|["b"]|}, epoly_of_json, epoly_to_json, (`b : epoly));
C ({|["A_aliased"]|}, epoly_of_json, epoly_to_json, (`a : epoly)); (* polyvariant `a aliased to "A_aliased"*)
C ({|{"my_name":"N","my_age":1}|}, record_aliased_of_json, record_aliased_to_json, {name="N"; age=1});
C ({|{"my_name":"N"}|}, record_aliased_of_json, record_aliased_to_json, {name="N"; age=100});
C ({|{}|}, record_opt_of_json, record_opt_to_json, {k=None});
Expand Down
8 changes: 8 additions & 0 deletions ppx/test/ppx_deriving_json_js.e2e.t
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,14 @@
JSON REPRINT: ["Fix",["Fix",["Fix",["A"]]]]
JSON DATA: ["Fix",["Fix",["Fix",["A"]]]]
JSON REPRINT: ["Fix",["Fix",["Fix",["A"]]]]
JSON DATA: ["A"]
JSON REPRINT: ["A"]
JSON DATA: ["b_aliased"]
JSON REPRINT: ["b_aliased"]
JSON DATA: ["b"]
JSON REPRINT: ["b"]
JSON DATA: ["A_aliased"]
JSON REPRINT: ["A_aliased"]
JSON DATA: {"my_name":"N","my_age":1}
JSON REPRINT: {"my_name":"N","my_age":1}
JSON DATA: {"my_name":"N"}
Expand Down
8 changes: 8 additions & 0 deletions ppx/test/ppx_deriving_json_native.e2e.t
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,14 @@
JSON REPRINT: ["Fix",["Fix",["Fix",["A"]]]]
JSON DATA: ["Fix",["Fix",["Fix",["A"]]]]
JSON REPRINT: ["Fix",["Fix",["Fix",["A"]]]]
JSON DATA: ["A"]
JSON REPRINT: ["A"]
JSON DATA: ["b_aliased"]
JSON REPRINT: ["b_aliased"]
JSON DATA: ["b"]
JSON REPRINT: ["b"]
JSON DATA: ["A_aliased"]
JSON REPRINT: ["A_aliased"]
JSON DATA: {"my_name":"N","my_age":1}
JSON REPRINT: {"my_name":"N","my_age":1}
JSON DATA: {"my_name":"N"}
Expand Down

0 comments on commit 0a3e9c9

Please sign in to comment.