Skip to content

Commit 7125521

Browse files
authored
Merge pull request #332 from Pat-Lafon/main
Continue on fail when max_fail is gt 0
2 parents 1201198 + 4f9c1d5 commit 7125521

12 files changed

+166
-10
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## NEXT RELEASE
44

5-
- ...
5+
- Restore `Test.make`'s `max_fail` parameter which was accidentally broken in 0.18
66

77
## 0.24
88

src/core/QCheck2.ml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -884,7 +884,7 @@ module Gen = struct
884884
make_primitive
885885
~gen:(fun st -> gen st |> Tree.root)
886886
~shrink
887-
887+
888888
let no_shrink (gen: 'a t) : 'a t = set_shrink (fun _ -> Seq.empty) gen
889889

890890
let (let+) = (>|=)
@@ -1868,6 +1868,7 @@ module Test = struct
18681868
state.step state.test.name state.test input Failure;
18691869
state.cur_max_fail <- state.cur_max_fail - 1;
18701870
R.fail state.res ~steps ~msg_l input;
1871+
if state.cur_max_fail > 0 then CR_continue else
18711872
CR_yield state.res
18721873

18731874
(* [check_state state] applies [state.test] repeatedly ([iter] times)

test/core/QCheck2_expect_test.expected.ocaml4.32

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,24 @@ Test should_fail_sort_id failed (5 shrink steps):
107107

108108
[1; 0]
109109

110+
--- Failure --------------------------------------------------------------------
111+
112+
Test max_fail failed (3 shrink steps):
113+
114+
[0; 1]
115+
116+
--- Failure --------------------------------------------------------------------
117+
118+
Test max_fail failed (8 shrink steps):
119+
120+
[0; 1]
121+
122+
--- Failure --------------------------------------------------------------------
123+
124+
Test max_fail failed (8 shrink steps):
125+
126+
[0; 1]
127+
110128
=== Error ======================================================================
111129

112130
Test should_error_raise_exn errored on (1 shrink steps):
@@ -1664,7 +1682,7 @@ stats dist:
16641682
6.. 10: 0
16651683
================================================================================
16661684
1 warning(s)
1667-
failure (74 tests failed, 3 tests errored, ran 166 tests)
1685+
failure (75 tests failed, 3 tests errored, ran 167 tests)
16681686
random seed: 153870556
16691687

16701688
+++ Stats for int_dist_empty_bucket ++++++++++++++++++++++++++++++++++++++++++++++++++++++++

test/core/QCheck2_expect_test.expected.ocaml4.64

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,24 @@ Test should_fail_sort_id failed (5 shrink steps):
169169

170170
[1; 0]
171171

172+
--- Failure --------------------------------------------------------------------
173+
174+
Test max_fail failed (3 shrink steps):
175+
176+
[0; 1]
177+
178+
--- Failure --------------------------------------------------------------------
179+
180+
Test max_fail failed (8 shrink steps):
181+
182+
[0; 1]
183+
184+
--- Failure --------------------------------------------------------------------
185+
186+
Test max_fail failed (8 shrink steps):
187+
188+
[0; 1]
189+
172190
=== Error ======================================================================
173191

174192
Test should_error_raise_exn errored on (1 shrink steps):
@@ -1726,7 +1744,7 @@ stats dist:
17261744
6.. 10: 0
17271745
================================================================================
17281746
1 warning(s)
1729-
failure (74 tests failed, 3 tests errored, ran 166 tests)
1747+
failure (75 tests failed, 3 tests errored, ran 167 tests)
17301748
random seed: 153870556
17311749

17321750
+++ Stats for int_dist_empty_bucket ++++++++++++++++++++++++++++++++++++++++++++++++++++++++

test/core/QCheck2_expect_test.expected.ocaml5.32

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,24 @@ Test should_fail_sort_id failed (8 shrink steps):
9090

9191
[1; 0]
9292

93+
--- Failure --------------------------------------------------------------------
94+
95+
Test max_fail failed (4 shrink steps):
96+
97+
[0; 1]
98+
99+
--- Failure --------------------------------------------------------------------
100+
101+
Test max_fail failed (8 shrink steps):
102+
103+
[0; 1]
104+
105+
--- Failure --------------------------------------------------------------------
106+
107+
Test max_fail failed (2 shrink steps):
108+
109+
[0; 1]
110+
93111
=== Error ======================================================================
94112

95113
Test should_error_raise_exn errored on (1 shrink steps):
@@ -1648,7 +1666,7 @@ stats dist:
16481666
-3.. 0: ####################################################### 1631
16491667
================================================================================
16501668
1 warning(s)
1651-
failure (74 tests failed, 3 tests errored, ran 166 tests)
1669+
failure (75 tests failed, 3 tests errored, ran 167 tests)
16521670
random seed: 153870556
16531671

16541672
+++ Stats for int_dist_empty_bucket ++++++++++++++++++++++++++++++++++++++++++++++++++++++++

test/core/QCheck2_expect_test.expected.ocaml5.64

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,24 @@ Test should_fail_sort_id failed (8 shrink steps):
152152

153153
[1; 0]
154154

155+
--- Failure --------------------------------------------------------------------
156+
157+
Test max_fail failed (4 shrink steps):
158+
159+
[0; 1]
160+
161+
--- Failure --------------------------------------------------------------------
162+
163+
Test max_fail failed (8 shrink steps):
164+
165+
[0; 1]
166+
167+
--- Failure --------------------------------------------------------------------
168+
169+
Test max_fail failed (2 shrink steps):
170+
171+
[0; 1]
172+
155173
=== Error ======================================================================
156174

157175
Test should_error_raise_exn errored on (1 shrink steps):
@@ -1710,7 +1728,7 @@ stats dist:
17101728
-3.. 0: ####################################################### 1631
17111729
================================================================================
17121730
1 warning(s)
1713-
failure (74 tests failed, 3 tests errored, ran 166 tests)
1731+
failure (75 tests failed, 3 tests errored, ran 167 tests)
17141732
random seed: 153870556
17151733

17161734
+++ Stats for int_dist_empty_bucket ++++++++++++++++++++++++++++++++++++++++++++++++++++++++

test/core/QCheck2_tests.ml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ module Overall = struct
5151
Test.make ~name:"should_fail_sort_id" ~count:10 ~print:Print.(list int)
5252
Gen.(small_list small_int) (fun l -> l = List.sort compare l)
5353

54+
let max_fail =
55+
Test.make ~name:"max_fail" ~count:1000 ~max_fail:3 ~print:Print.(list int)
56+
Gen.(list small_nat) (fun l -> l = List.rev l)
57+
5458
exception Error
5559

5660
let error =
@@ -142,6 +146,7 @@ module Overall = struct
142146
let tests = [
143147
passing;
144148
failing;
149+
max_fail;
145150
error;
146151
collect;
147152
stats;

test/core/QCheck_expect_test.expected.ocaml4.32

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,24 @@ Test should_fail_sort_id failed (13 shrink steps):
8383

8484
[1; 0]
8585

86+
--- Failure --------------------------------------------------------------------
87+
88+
Test max_fail failed (16 shrink steps):
89+
90+
[0; 1]
91+
92+
--- Failure --------------------------------------------------------------------
93+
94+
Test max_fail failed (19 shrink steps):
95+
96+
[0; 1]
97+
98+
--- Failure --------------------------------------------------------------------
99+
100+
Test max_fail failed (11 shrink steps):
101+
102+
[1; 0]
103+
86104
=== Error ======================================================================
87105

88106
Test should_error_raise_exn errored on (31 shrink steps):
@@ -1641,7 +1659,7 @@ stats dist:
16411659
6.. 10: 0
16421660
================================================================================
16431661
1 warning(s)
1644-
failure (74 tests failed, 3 tests errored, ran 174 tests)
1662+
failure (75 tests failed, 3 tests errored, ran 175 tests)
16451663
random seed: 153870556
16461664

16471665
+++ Stats for int_dist_empty_bucket ++++++++++++++++++++++++++++++++++++++++++++++++++++++++

test/core/QCheck_expect_test.expected.ocaml4.64

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,24 @@ Test should_fail_sort_id failed (13 shrink steps):
115115

116116
[1; 0]
117117

118+
--- Failure --------------------------------------------------------------------
119+
120+
Test max_fail failed (16 shrink steps):
121+
122+
[0; 1]
123+
124+
--- Failure --------------------------------------------------------------------
125+
126+
Test max_fail failed (19 shrink steps):
127+
128+
[0; 1]
129+
130+
--- Failure --------------------------------------------------------------------
131+
132+
Test max_fail failed (11 shrink steps):
133+
134+
[1; 0]
135+
118136
=== Error ======================================================================
119137

120138
Test should_error_raise_exn errored on (63 shrink steps):
@@ -1673,7 +1691,7 @@ stats dist:
16731691
6.. 10: 0
16741692
================================================================================
16751693
1 warning(s)
1676-
failure (74 tests failed, 3 tests errored, ran 174 tests)
1694+
failure (75 tests failed, 3 tests errored, ran 175 tests)
16771695
random seed: 153870556
16781696

16791697
+++ Stats for int_dist_empty_bucket ++++++++++++++++++++++++++++++++++++++++++++++++++++++++

test/core/QCheck_expect_test.expected.ocaml5.32

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,24 @@ Test should_fail_sort_id failed (10 shrink steps):
9393

9494
[1; 0]
9595

96+
--- Failure --------------------------------------------------------------------
97+
98+
Test max_fail failed (20 shrink steps):
99+
100+
[0; 1]
101+
102+
--- Failure --------------------------------------------------------------------
103+
104+
Test max_fail failed (14 shrink steps):
105+
106+
[0; 1]
107+
108+
--- Failure --------------------------------------------------------------------
109+
110+
Test max_fail failed (16 shrink steps):
111+
112+
[1; 0]
113+
96114
=== Error ======================================================================
97115

98116
Test should_error_raise_exn errored on (30 shrink steps):
@@ -1652,7 +1670,7 @@ stats dist:
16521670
-3.. 0: ####################################################### 1631
16531671
================================================================================
16541672
1 warning(s)
1655-
failure (74 tests failed, 3 tests errored, ran 174 tests)
1673+
failure (75 tests failed, 3 tests errored, ran 175 tests)
16561674
random seed: 153870556
16571675

16581676
+++ Stats for int_dist_empty_bucket ++++++++++++++++++++++++++++++++++++++++++++++++++++++++

0 commit comments

Comments
 (0)