Skip to content

Commit

Permalink
add test case for is_rec_constr_decl record case
Browse files Browse the repository at this point in the history
  • Loading branch information
jmid committed May 2, 2023
1 parent 78e8baf commit 08db794
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions test/ppx_deriving_qcheck/deriver/qcheck/test_textual.ml
Original file line number Diff line number Diff line change
Expand Up @@ -875,6 +875,27 @@ let test_faulty_is_rec_typ_in_variant () =
in
check_eq ~expected ~actual "deriving rec type in a type constructor inside variant"

let test_faulty_is_rec_constr_decl () =
let expected =
[
[%stri let rec gen_sized n =
match n with
| 0 -> QCheck.Gen.pure Foo
| _ ->
QCheck.Gen.frequency
[(1, (QCheck.Gen.pure Foo));
(1,
(QCheck.Gen.map (fun gen0 -> Bar { baz = gen0 })
(gen_sized (n / 2))))]];
[%stri let gen = QCheck.Gen.sized gen_sized];
[%stri let arb_sized n = QCheck.make @@ (gen_sized n)];
[%stri let arb = QCheck.make @@ gen];
]
in
let actual = f @@ extract [%stri type t = Foo | Bar of { baz : t }]
in
check_eq ~expected ~actual "deriving rec type in a type constructor inside record"

let () =
Alcotest.(
run
Expand Down Expand Up @@ -925,5 +946,9 @@ let () =
"deriving rec type in a type constructor inside variant"
`Quick
test_faulty_is_rec_typ_in_variant;
test_case
"deriving rec type in a type constructor inside record"
`Quick
test_faulty_is_rec_constr_decl;
] );
])

0 comments on commit 08db794

Please sign in to comment.