Skip to content

Commit 27f4f8d

Browse files
committed
add test case for is_rec_constr_decl record case
1 parent c2d7652 commit 27f4f8d

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

test/ppx_deriving_qcheck/deriver/qcheck/test_textual.ml

+25
Original file line numberDiff line numberDiff line change
@@ -875,6 +875,27 @@ let test_faulty_is_rec_typ_in_variant () =
875875
in
876876
check_eq ~expected ~actual "deriving rec type in a type constructor inside variant"
877877

878+
let test_faulty_is_rec_constr_decl () =
879+
let expected =
880+
[
881+
[%stri let rec gen_sized n =
882+
match n with
883+
| 0 -> QCheck.Gen.pure Foo
884+
| _ ->
885+
QCheck.Gen.frequency
886+
[(1, (QCheck.Gen.pure Foo));
887+
(1,
888+
(QCheck.Gen.map (fun gen0 -> Bar { baz = gen0 })
889+
(gen_sized (n / 2))))]];
890+
[%stri let gen = QCheck.Gen.sized gen_sized];
891+
[%stri let arb_sized n = QCheck.make @@ (gen_sized n)];
892+
[%stri let arb = QCheck.make @@ gen];
893+
]
894+
in
895+
let actual = f @@ extract [%stri type t = Foo | Bar of { baz : t }]
896+
in
897+
check_eq ~expected ~actual "deriving rec type in a type constructor inside record"
898+
878899
let () =
879900
Alcotest.(
880901
run
@@ -925,5 +946,9 @@ let () =
925946
"deriving rec type in a type constructor inside variant"
926947
`Quick
927948
test_faulty_is_rec_typ_in_variant;
949+
test_case
950+
"deriving rec type in a type constructor inside record"
951+
`Quick
952+
test_faulty_is_rec_constr_decl;
928953
] );
929954
])

0 commit comments

Comments
 (0)