@@ -860,6 +860,41 @@ let test_unused_variable () =
860
860
in
861
861
check_eq ~expected ~actual "deriving variant with unused fuel parameter"
862
862
863
+ (* Regression test: https://github.com/c-cube/qcheck/issues/269 *)
864
+ let test_faulty_is_rec_typ_in_variant () =
865
+ let expected =
866
+ [
867
+ [% stri let rec gen_sized n =
868
+ QCheck.Gen .map (fun gen0 -> Foo gen0 ) (QCheck.Gen .list (gen_sized (n / 2 )))];
869
+ [% stri let gen = QCheck.Gen .sized gen_sized ];
870
+ [% stri let arb_sized n = QCheck .make @@ (gen_sized n )];
871
+ [% stri let arb = QCheck .make @@ gen ];
872
+ ]
873
+ in
874
+ let actual = f @@ extract [% stri type t = Foo of t list ]
875
+ in
876
+ check_eq ~expected ~actual "deriving rec type in a type constructor inside variant"
877
+
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"
863
898
864
899
let () =
865
900
Alcotest. (
@@ -907,5 +942,13 @@ let () =
907
942
"deriving variant with unused fuel parameter"
908
943
`Quick
909
944
test_unused_variable ;
945
+ test_case
946
+ "deriving rec type in a type constructor inside variant"
947
+ `Quick
948
+ 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 ;
910
953
] );
911
954
])
0 commit comments