Skip to content

Commit 4a5b754

Browse files
authored
Merge pull request #280 from jmid/revert-shrinker-fix
Regression: Revert shrinker fix
2 parents a138b2b + 0133ea2 commit 4a5b754

7 files changed

+15
-5
lines changed

CHANGELOG.md

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

33
## NEXT RELEASE
44

5-
- ...
5+
- Roll back the `Shrink.list_spine` fix, as it was utilizing polymorphic
6+
equality that can raise an exception on function comparison.
67

78
## 0.21
89

src/core/QCheck.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -760,7 +760,7 @@ module Shrink = struct
760760
match l with
761761
| [] -> ()
762762
| [_] -> yield []
763-
| [x;y] -> yield []; yield [x]; if x <> y then yield [y]
763+
| [x;y] -> yield []; yield [x]; yield [y]
764764
| _::_ ->
765765
let len = List.length l in
766766
let xs,ys = split l ((1 + len) / 2) [] in

test/core/QCheck_expect_test.expected.ocaml4.32

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ random seed: 1234
7474
[1; 1]
7575
[]
7676
[1]
77+
[1]
7778
[0; 1]
7879
[1; 0]
7980

test/core/QCheck_expect_test.expected.ocaml4.64

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ random seed: 1234
106106
[1; 1]
107107
[]
108108
[1]
109+
[1]
109110
[0; 1]
110111
[1; 0]
111112

test/core/QCheck_expect_test.expected.ocaml5.32

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ random seed: 1234
8484
[2; 2]
8585
[]
8686
[2]
87+
[2]
8788
[1; 2]
8889
[2; 1]
8990

test/core/QCheck_expect_test.expected.ocaml5.64

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ random seed: 1234
116116
[2; 2]
117117
[]
118118
[2]
119+
[2]
119120
[1; 2]
120121
[2; 1]
121122

test/core/QCheck_unit_tests.ml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ module Shrink = struct
8585
List.iter (alco_check Alcotest.string (trace_false Shrink.string) "on repeated failure")
8686
[ ("string \"\"", "", []);
8787
("string \"a\"", "a", [""]);
88-
("string \"aa\"", "aa", [""; "a"]);
89-
("string \"aaaa\"", "aaaa", ["aa"; "aa"; "aaa"]);
88+
("string \"aa\"", "aa", [""; "a"; "a"]);
89+
("string \"aaaa\"", "aaaa", ["aa"; "aa"; "aaa"; "aaa"]);
9090
("string \"abcd\"", "abcd", ["ab"; "cd"; "acd"; "bcd"; "aacd"; "abbd"; "abcc"]);
9191
("string \"E'*\"", "E'*", ["E'"; "*"; "E*"; "'*"; "S'*"; "L'*"; "H'*"; "F'*"; "ED*";
9292
"E5*"; "E.*"; "E**"; "E(*"; "E'E"; "E'7"; "E'0"; "E'-"; "E'+"]);
@@ -101,7 +101,7 @@ module Shrink = struct
101101
"vi5x92mgG"; "vi5x92sgG"; "vi5x92vgG"; "vi5x92wgG";
102102
"vi5x92xdG"; "vi5x92xfG";
103103
"vi5x92xgT"; "vi5x92xgM"; "vi5x92xgJ"; "vi5x92xgH"]);
104-
("string \"~~~~\"", "~~~~", ["~~"; "~~"; "~~~"; "p~~~"; "w~~~"; "{~~~"; "}~~~"; "~p~~";
104+
("string \"~~~~\"", "~~~~", ["~~"; "~~"; "~~~"; "~~~"; "p~~~"; "w~~~"; "{~~~"; "}~~~"; "~p~~";
105105
"~w~~"; "~{~~"; "~}~~"; "~~p~"; "~~w~"; "~~{~"; "~~}~";
106106
"~~~p"; "~~~w"; "~~~{"; "~~~}"]); ];
107107
List.iter (alco_check Alcotest.string (trace_true Shrink.string) "on repeated success")
@@ -113,6 +113,10 @@ module Shrink = struct
113113
("string \"E'*\"", "E'*", ["E'"; ""]);
114114
("string \"vi5x92xgG\"", "vi5x92xgG", ["vi5x9"; "vi5"; "vi"; ""]); ]
115115

116+
let test_list_spine_compare () =
117+
let run_test () = QCheck.Shrink.list_spine [pred;succ] ignore in
118+
Alcotest.(check unit) "doesn't compare elements" () @@ run_test ()
119+
116120
let tests = ("Shrink", Alcotest.[
117121
test_case "int" `Quick test_int;
118122
test_case "int32" `Quick test_int32;
@@ -121,6 +125,7 @@ module Shrink = struct
121125
test_case "char_numeral" `Quick test_char_numeral;
122126
test_case "char_printable" `Quick test_char_printable;
123127
test_case "string" `Quick test_string;
128+
test_case "list_spine" `Quick test_list_spine_compare;
124129
])
125130
end
126131

0 commit comments

Comments
 (0)