Skip to content

Commit

Permalink
better list test
Browse files Browse the repository at this point in the history
  • Loading branch information
benbellick committed Dec 19, 2024
1 parent d17cd1e commit 09e0768
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions test/test_identity.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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] *)
Expand Down

0 comments on commit 09e0768

Please sign in to comment.