Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## NEXT RELEASE

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

## 0.24

Expand Down
3 changes: 2 additions & 1 deletion src/core/QCheck2.ml
Original file line number Diff line number Diff line change
Expand Up @@ -884,7 +884,7 @@ module Gen = struct
make_primitive
~gen:(fun st -> gen st |> Tree.root)
~shrink

let no_shrink (gen: 'a t) : 'a t = set_shrink (fun _ -> Seq.empty) gen

let (let+) = (>|=)
Expand Down Expand Up @@ -1868,6 +1868,7 @@ module Test = struct
state.step state.test.name state.test input Failure;
state.cur_max_fail <- state.cur_max_fail - 1;
R.fail state.res ~steps ~msg_l input;
if state.cur_max_fail > 0 then CR_continue else
CR_yield state.res

(* [check_state state] applies [state.test] repeatedly ([iter] times)
Expand Down
20 changes: 19 additions & 1 deletion test/core/QCheck2_expect_test.expected.ocaml4.32
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,24 @@ Test should_fail_sort_id failed (5 shrink steps):

[1; 0]

--- Failure --------------------------------------------------------------------

Test max_fail failed (3 shrink steps):

[0; 1]

--- Failure --------------------------------------------------------------------

Test max_fail failed (8 shrink steps):

[0; 1]

--- Failure --------------------------------------------------------------------

Test max_fail failed (8 shrink steps):

[0; 1]

=== Error ======================================================================

Test should_error_raise_exn errored on (1 shrink steps):
Expand Down Expand Up @@ -1664,7 +1682,7 @@ stats dist:
6.. 10: 0
================================================================================
1 warning(s)
failure (74 tests failed, 3 tests errored, ran 166 tests)
failure (75 tests failed, 3 tests errored, ran 167 tests)
random seed: 153870556

+++ Stats for int_dist_empty_bucket ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Expand Down
20 changes: 19 additions & 1 deletion test/core/QCheck2_expect_test.expected.ocaml4.64
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,24 @@ Test should_fail_sort_id failed (5 shrink steps):

[1; 0]

--- Failure --------------------------------------------------------------------

Test max_fail failed (3 shrink steps):

[0; 1]

--- Failure --------------------------------------------------------------------

Test max_fail failed (8 shrink steps):

[0; 1]

--- Failure --------------------------------------------------------------------

Test max_fail failed (8 shrink steps):

[0; 1]

=== Error ======================================================================

Test should_error_raise_exn errored on (1 shrink steps):
Expand Down Expand Up @@ -1726,7 +1744,7 @@ stats dist:
6.. 10: 0
================================================================================
1 warning(s)
failure (74 tests failed, 3 tests errored, ran 166 tests)
failure (75 tests failed, 3 tests errored, ran 167 tests)
random seed: 153870556

+++ Stats for int_dist_empty_bucket ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Expand Down
20 changes: 19 additions & 1 deletion test/core/QCheck2_expect_test.expected.ocaml5.32
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,24 @@ Test should_fail_sort_id failed (8 shrink steps):

[1; 0]

--- Failure --------------------------------------------------------------------

Test max_fail failed (4 shrink steps):

[0; 1]

--- Failure --------------------------------------------------------------------

Test max_fail failed (8 shrink steps):

[0; 1]

--- Failure --------------------------------------------------------------------

Test max_fail failed (2 shrink steps):

[0; 1]

=== Error ======================================================================

Test should_error_raise_exn errored on (1 shrink steps):
Expand Down Expand Up @@ -1648,7 +1666,7 @@ stats dist:
-3.. 0: ####################################################### 1631
================================================================================
1 warning(s)
failure (74 tests failed, 3 tests errored, ran 166 tests)
failure (75 tests failed, 3 tests errored, ran 167 tests)
random seed: 153870556

+++ Stats for int_dist_empty_bucket ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Expand Down
20 changes: 19 additions & 1 deletion test/core/QCheck2_expect_test.expected.ocaml5.64
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,24 @@ Test should_fail_sort_id failed (8 shrink steps):

[1; 0]

--- Failure --------------------------------------------------------------------

Test max_fail failed (4 shrink steps):

[0; 1]

--- Failure --------------------------------------------------------------------

Test max_fail failed (8 shrink steps):

[0; 1]

--- Failure --------------------------------------------------------------------

Test max_fail failed (2 shrink steps):

[0; 1]

=== Error ======================================================================

Test should_error_raise_exn errored on (1 shrink steps):
Expand Down Expand Up @@ -1710,7 +1728,7 @@ stats dist:
-3.. 0: ####################################################### 1631
================================================================================
1 warning(s)
failure (74 tests failed, 3 tests errored, ran 166 tests)
failure (75 tests failed, 3 tests errored, ran 167 tests)
random seed: 153870556

+++ Stats for int_dist_empty_bucket ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Expand Down
5 changes: 5 additions & 0 deletions test/core/QCheck2_tests.ml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ module Overall = struct
Test.make ~name:"should_fail_sort_id" ~count:10 ~print:Print.(list int)
Gen.(small_list small_int) (fun l -> l = List.sort compare l)

let max_fail =
Test.make ~name:"max_fail" ~count:1000 ~max_fail:3 ~print:Print.(list int)
Gen.(list small_nat) (fun l -> l = List.rev l)

exception Error

let error =
Expand Down Expand Up @@ -142,6 +146,7 @@ module Overall = struct
let tests = [
passing;
failing;
max_fail;
error;
collect;
stats;
Expand Down
20 changes: 19 additions & 1 deletion test/core/QCheck_expect_test.expected.ocaml4.32
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,24 @@ Test should_fail_sort_id failed (13 shrink steps):

[1; 0]

--- Failure --------------------------------------------------------------------

Test max_fail failed (16 shrink steps):

[0; 1]

--- Failure --------------------------------------------------------------------

Test max_fail failed (19 shrink steps):

[0; 1]

--- Failure --------------------------------------------------------------------

Test max_fail failed (11 shrink steps):

[1; 0]

=== Error ======================================================================

Test should_error_raise_exn errored on (31 shrink steps):
Expand Down Expand Up @@ -1641,7 +1659,7 @@ stats dist:
6.. 10: 0
================================================================================
1 warning(s)
failure (74 tests failed, 3 tests errored, ran 174 tests)
failure (75 tests failed, 3 tests errored, ran 175 tests)
random seed: 153870556

+++ Stats for int_dist_empty_bucket ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Expand Down
20 changes: 19 additions & 1 deletion test/core/QCheck_expect_test.expected.ocaml4.64
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,24 @@ Test should_fail_sort_id failed (13 shrink steps):

[1; 0]

--- Failure --------------------------------------------------------------------

Test max_fail failed (16 shrink steps):

[0; 1]

--- Failure --------------------------------------------------------------------

Test max_fail failed (19 shrink steps):

[0; 1]

--- Failure --------------------------------------------------------------------

Test max_fail failed (11 shrink steps):

[1; 0]

=== Error ======================================================================

Test should_error_raise_exn errored on (63 shrink steps):
Expand Down Expand Up @@ -1673,7 +1691,7 @@ stats dist:
6.. 10: 0
================================================================================
1 warning(s)
failure (74 tests failed, 3 tests errored, ran 174 tests)
failure (75 tests failed, 3 tests errored, ran 175 tests)
random seed: 153870556

+++ Stats for int_dist_empty_bucket ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Expand Down
20 changes: 19 additions & 1 deletion test/core/QCheck_expect_test.expected.ocaml5.32
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,24 @@ Test should_fail_sort_id failed (10 shrink steps):

[1; 0]

--- Failure --------------------------------------------------------------------

Test max_fail failed (20 shrink steps):

[0; 1]

--- Failure --------------------------------------------------------------------

Test max_fail failed (14 shrink steps):

[0; 1]

--- Failure --------------------------------------------------------------------

Test max_fail failed (16 shrink steps):

[1; 0]

=== Error ======================================================================

Test should_error_raise_exn errored on (30 shrink steps):
Expand Down Expand Up @@ -1652,7 +1670,7 @@ stats dist:
-3.. 0: ####################################################### 1631
================================================================================
1 warning(s)
failure (74 tests failed, 3 tests errored, ran 174 tests)
failure (75 tests failed, 3 tests errored, ran 175 tests)
random seed: 153870556

+++ Stats for int_dist_empty_bucket ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Expand Down
20 changes: 19 additions & 1 deletion test/core/QCheck_expect_test.expected.ocaml5.64
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,24 @@ Test should_fail_sort_id failed (10 shrink steps):

[1; 0]

--- Failure --------------------------------------------------------------------

Test max_fail failed (20 shrink steps):

[0; 1]

--- Failure --------------------------------------------------------------------

Test max_fail failed (14 shrink steps):

[0; 1]

--- Failure --------------------------------------------------------------------

Test max_fail failed (16 shrink steps):

[1; 0]

=== Error ======================================================================

Test should_error_raise_exn errored on (62 shrink steps):
Expand Down Expand Up @@ -1684,7 +1702,7 @@ stats dist:
-3.. 0: ####################################################### 1631
================================================================================
1 warning(s)
failure (74 tests failed, 3 tests errored, ran 174 tests)
failure (75 tests failed, 3 tests errored, ran 175 tests)
random seed: 153870556

+++ Stats for int_dist_empty_bucket ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Expand Down
6 changes: 6 additions & 0 deletions test/core/QCheck_tests.ml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ module Overall = struct
Test.make ~name:"should_fail_sort_id" ~count:10
(small_list small_int) (fun l -> l = List.sort compare l)

let max_fail =
Test.make ~name:"max_fail" ~count:1000 ~max_fail:3
(list small_nat)
(fun l -> l = List.rev l)

exception Error

let error =
Expand Down Expand Up @@ -152,6 +157,7 @@ module Overall = struct
let tests = [
passing;
failing;
max_fail;
error;
collect;
stats;
Expand Down