From 09e0768ac49dfda36da378ab1d83d4059baf92c4 Mon Sep 17 00:00:00 2001 From: Ben Bellick Date: Thu, 19 Dec 2024 12:36:51 -0600 Subject: [PATCH] better list test --- test/test_identity.ml | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/test/test_identity.ml b/test/test_identity.ml index 32dce8c..d5df1e7 100644 --- a/test/test_identity.ml +++ b/test/test_identity.ml @@ -59,11 +59,27 @@ module Expression = struct end end -(* type my_list = Null | L of my_list [@@deriving decoders, encoders] *) +module MyList = struct + type t = Null | L of t [@@deriving decoders, encoders] -(* let my_list_id = make_id my_list_encoder my_list_decoder *) -(* let%test "my_list:1" = check my_list_id Null *) -(* let%test "my_list:2" = check my_list_id (L (L (L (L Null)))) *) + module OnJson = struct + open OnJson + + let id = make_id t_encoder t_decoder + let check = check id + let%test "my_list:json:1" = check {|{"Null":null}|} + let%test "my_list:value:2" = check {|{"L":{"L":{"L":{"Null":null}}}}|} + end + + module OnValue = struct + open OnValue + + let id = make_id t_encoder t_decoder + let check = check id + let%test "my_list:value:1" = check Null + let%test "my_list:value:2" = check (L (L (L (L Null)))) + end +end (* type a_rec = { b : b_rec option } *) (* and b_rec = { a : a_rec option } [@@deriving decoders, encoders] *)