diff --git a/CHANGELOG.md b/CHANGELOG.md index 6a28959b..b66a1cd0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## NEXT RELEASE +- Adjust the `QCheck2.Gen.list` shrinker to produce minimal counterexamples at size 3 too - Replace the `QCheck2` OCaml 4 `Random.State.split` hack with a faster one - Improve the `QCheck2.Gen.list` shrinker heuristic and utilize the improved shrinker in other `QCheck2` `{list,array,bytes,string,function}*` shrinkers diff --git a/src/core/QCheck2.ml b/src/core/QCheck2.ml index 7b3bda9b..b9e07c38 100644 --- a/src/core/QCheck2.ml +++ b/src/core/QCheck2.ml @@ -267,30 +267,38 @@ module Tree = struct | (0, _) | (_, []) -> pure [] | (n, (tree :: trees)) -> liftA2 List.cons tree (applicative_take (pred n) trees) + (** [drop_one l []] returns all versions of [l] with one element removed, for example + [drop_one [1;2;3] [] = [ [2;3]; [1;3]; [1;2] ]] *) + let rec drop_one (l : 'a list) (rev_prefix : 'a list) : 'a list list = match l with + | [] -> [] + | x::xs -> (List.rev rev_prefix @ xs) :: drop_one xs (x::rev_prefix) + let rec build_list_shrink_tree (l : 'a t list) : 'a list t Seq.t = match l with | [] -> Seq.empty - | [_] -> - fun () -> Seq.cons (Tree ([], Seq.empty)) (* [x] leaves only empty list to try *) - (children (sequence_list l)) () (* otherwise, reduce element(s) *) | _::_ -> fun () -> let len = List.length l in - let xs,ys = list_split l ((1 + len) / 2) [] in - let xs_roots = List.map root xs in - let ys_roots = List.map root ys in - (* Try reducing a list [1;2;3;4] in halves: [1;2] and [3;4] *) - Seq.cons (Tree (xs_roots, build_list_shrink_tree xs)) - (Seq.cons (Tree (ys_roots, build_list_shrink_tree ys)) - (fun () -> - (if len >= 4 - then (* Try dropping an element from either half: [2;3;4] and [1;2;4] *) - let rest = List.tl l in - let rest_roots = List.map root rest in - (Seq.cons (Tree (rest_roots, build_list_shrink_tree rest)) - (Seq.cons (Tree (xs_roots@(List.tl ys_roots), build_list_shrink_tree (xs@(List.tl ys)))) - (children (sequence_list l)))) (* at bottom: reduce elements *) - else - children (sequence_list l)) ())) () + if len < 4 then + let candidates = drop_one l [] in + List.fold_right (* try dropping each element in turn, starting with the list head *) + (fun cand acc -> Seq.cons (Tree (List.map root cand, build_list_shrink_tree cand)) acc) + candidates + (fun () -> children (sequence_list l) ()) () (* otherwise, reduce element(s) *) + else + let xs,ys = list_split l ((1 + len) / 2) [] in + let xs_roots = List.map root xs in + let ys_roots = List.map root ys in + (* Try reducing a list [1;2;3;4] in halves: [1;2] and [3;4] *) + Seq.cons (Tree (xs_roots, build_list_shrink_tree xs)) + (Seq.cons (Tree (ys_roots, build_list_shrink_tree ys)) + (fun () -> + (* Try dropping an element from either half: [2;3;4] and [1;2;4] *) + let rest = List.tl l in + let rest_roots = List.map root rest in + (Seq.cons (Tree (rest_roots, build_list_shrink_tree rest)) + (Seq.cons (Tree (xs_roots@(List.tl ys_roots), build_list_shrink_tree (xs@(List.tl ys)))) + (fun () -> children (sequence_list l) ()))) (* at bottom: reduce elements *) + () )) () end module Gen = struct diff --git a/test/core/QCheck2_expect_test.expected.ocaml4.32 b/test/core/QCheck2_expect_test.expected.ocaml4.32 index 80ab3d81..d27af061 100644 --- a/test/core/QCheck2_expect_test.expected.ocaml4.32 +++ b/test/core/QCheck2_expect_test.expected.ocaml4.32 @@ -73,8 +73,9 @@ random seed: 1234 [0; 13; 4; 6; 14; 6; 47; 3] [0; 13; 4; 6] [0; 13] -[0] +[13] [] +[0] [0; 13; 4; 6; 14; 6; 47; 3; 4; 3; 6; 6; 9; 4; 3; 65; 2; 4; 55; 2; 4; 87; 9; 5; 35; 73; 9; 9; 2; 74; 5; 9; 10; 93; 2; 7; 1; 4; 6; 91; 8; 8; 2; 9; 47; 6; 26; 3; 60; 1; 0; 5; 26; 4; 28; 6; 0; 5; 88; 3; 7] [0; 13; 4; 6; 14; 6; 47; 3; 4; 3; 6; 6; 9; 4; 3; 65; 2; 4; 55; 2; 4; 87; 9; 5; 35; 73; 9; 9; 2; 74; 5] [0; 13; 4; 6; 14; 6; 47; 3; 4; 3; 6; 6; 9; 4; 3; 65] @@ -89,14 +90,16 @@ random seed: 1234 [6; 47; 3] [6; 14; 6; 47; 3] [6; 14; 6] -[6; 14] +[14; 6] +[6; 6] +[6] [6] -[0; 14; 6] -[3; 14; 6] -[5; 14; 6] -[6; 0; 6] -[0; 0; 6] -[0; 0; 0] +[0; 6] +[3; 6] +[5; 6] +[6; 0] +[6; 3] +[6; 5] --- Failure -------------------------------------------------------------------- @@ -308,15 +311,15 @@ Test bytes never has a \000 char failed (13 shrink steps): --- Failure -------------------------------------------------------------------- -Test bytes never has a \255 char failed (5 shrink steps): +Test bytes never has a \255 char failed (6 shrink steps): "\255" --- Failure -------------------------------------------------------------------- -Test bytes have unique chars failed (16 shrink steps): +Test bytes have unique chars failed (13 shrink steps): -"aaa" +"**" --- Failure -------------------------------------------------------------------- @@ -332,15 +335,15 @@ Test string never has a \000 char failed (13 shrink steps): --- Failure -------------------------------------------------------------------- -Test string never has a \255 char failed (5 shrink steps): +Test string never has a \255 char failed (6 shrink steps): "\255" --- Failure -------------------------------------------------------------------- -Test strings have unique chars failed (16 shrink steps): +Test strings have unique chars failed (13 shrink steps): -"aaa" +"**" --- Failure -------------------------------------------------------------------- @@ -386,13 +389,13 @@ Test pairs sum to less than 128 failed (26 shrink steps): --- Failure -------------------------------------------------------------------- -Test pairs lists rev concat failed (34 shrink steps): +Test pairs lists rev concat failed (30 shrink steps): ([0], [1]) --- Failure -------------------------------------------------------------------- -Test pairs lists no overlap failed (12 shrink steps): +Test pairs lists no overlap failed (13 shrink steps): ([0], [0]) @@ -506,7 +509,7 @@ Test bind list_size constant failed (12 shrink steps): --- Failure -------------------------------------------------------------------- -Test lists are empty failed (6 shrink steps): +Test lists are empty failed (7 shrink steps): [0] @@ -530,9 +533,9 @@ Test lists shorter than 4332 failed (4022 shrink steps): --- Failure -------------------------------------------------------------------- -Test lists have unique elems failed (10 shrink steps): +Test lists have unique elems failed (8 shrink steps): -[0; 0; 0] +[6; 6] --- Failure -------------------------------------------------------------------- @@ -572,31 +575,31 @@ Test sum list = 0 failed (0 shrink steps): --- Failure -------------------------------------------------------------------- -Test fail_pred_map_commute_int failed (53 shrink steps): +Test fail_pred_map_commute_int failed (55 shrink steps): ([0], {0 -> 5; _ -> 0}, {5 -> true; _ -> false}) --- Failure -------------------------------------------------------------------- -Test fail_pred_map_commute_int32 failed (54 shrink steps): +Test fail_pred_map_commute_int32 failed (57 shrink steps): ([0l], {0l -> -15l; _ -> 0l}, {-15l -> true; _ -> false}) --- Failure -------------------------------------------------------------------- -Test fail_pred_map_commute_int64 failed (105 shrink steps): +Test fail_pred_map_commute_int64 failed (107 shrink steps): ([0L], {0L -> -71L; _ -> 0L}, {-71L -> true; _ -> false}) --- Failure -------------------------------------------------------------------- -Test fail_pred_strings failed (0 shrink steps): +Test fail_pred_strings failed (1 shrink steps): -{"some random string" -> true; "some other string" -> false; _ -> false} +{"some random string" -> true; _ -> false} --- Failure -------------------------------------------------------------------- -Test fold_left fold_right failed (17 shrink steps): +Test fold_left fold_right failed (20 shrink steps): (0, [1], {(0, 1) -> 1; _ -> 0}) @@ -609,9 +612,9 @@ l=[1], fold_left=0, fold_right=1 --- Failure -------------------------------------------------------------------- -Test fold_left fold_right uncurried failed (14 shrink steps): +Test fold_left fold_right uncurried failed (17 shrink steps): -({(9, 6) -> 0; (1, 5) -> 0; (4, 8) -> 1; (9, 8) -> 0; _ -> 0}, 8, [4]) +({(9, 6) -> 0; (1, 5) -> 0; (4, 8) -> 0; (9, 8) -> 1; _ -> 0}, 8, [9]) --- Failure -------------------------------------------------------------------- diff --git a/test/core/QCheck2_expect_test.expected.ocaml4.64 b/test/core/QCheck2_expect_test.expected.ocaml4.64 index bcbf02ef..cc4a28e8 100644 --- a/test/core/QCheck2_expect_test.expected.ocaml4.64 +++ b/test/core/QCheck2_expect_test.expected.ocaml4.64 @@ -135,8 +135,9 @@ random seed: 1234 [0; 13; 4; 6; 14; 6; 47; 3] [0; 13; 4; 6] [0; 13] -[0] +[13] [] +[0] [0; 13; 4; 6; 14; 6; 47; 3; 4; 3; 6; 6; 9; 4; 3; 65; 2; 4; 55; 2; 4; 87; 9; 5; 35; 73; 9; 9; 2; 74; 5; 9; 10; 93; 2; 7; 1; 4; 6; 91; 8; 8; 2; 9; 47; 6; 26; 3; 60; 1; 0; 5; 26; 4; 28; 6; 0; 5; 88; 3; 7] [0; 13; 4; 6; 14; 6; 47; 3; 4; 3; 6; 6; 9; 4; 3; 65; 2; 4; 55; 2; 4; 87; 9; 5; 35; 73; 9; 9; 2; 74; 5] [0; 13; 4; 6; 14; 6; 47; 3; 4; 3; 6; 6; 9; 4; 3; 65] @@ -151,14 +152,16 @@ random seed: 1234 [6; 47; 3] [6; 14; 6; 47; 3] [6; 14; 6] -[6; 14] +[14; 6] +[6; 6] +[6] [6] -[0; 14; 6] -[3; 14; 6] -[5; 14; 6] -[6; 0; 6] -[0; 0; 6] -[0; 0; 0] +[0; 6] +[3; 6] +[5; 6] +[6; 0] +[6; 3] +[6; 5] --- Failure -------------------------------------------------------------------- @@ -370,15 +373,15 @@ Test bytes never has a \000 char failed (13 shrink steps): --- Failure -------------------------------------------------------------------- -Test bytes never has a \255 char failed (5 shrink steps): +Test bytes never has a \255 char failed (6 shrink steps): "\255" --- Failure -------------------------------------------------------------------- -Test bytes have unique chars failed (16 shrink steps): +Test bytes have unique chars failed (13 shrink steps): -"aaa" +"**" --- Failure -------------------------------------------------------------------- @@ -394,15 +397,15 @@ Test string never has a \000 char failed (13 shrink steps): --- Failure -------------------------------------------------------------------- -Test string never has a \255 char failed (5 shrink steps): +Test string never has a \255 char failed (6 shrink steps): "\255" --- Failure -------------------------------------------------------------------- -Test strings have unique chars failed (16 shrink steps): +Test strings have unique chars failed (13 shrink steps): -"aaa" +"**" --- Failure -------------------------------------------------------------------- @@ -454,7 +457,7 @@ Test pairs lists rev concat failed (66 shrink steps): --- Failure -------------------------------------------------------------------- -Test pairs lists no overlap failed (12 shrink steps): +Test pairs lists no overlap failed (13 shrink steps): ([0], [0]) @@ -568,7 +571,7 @@ Test bind list_size constant failed (12 shrink steps): --- Failure -------------------------------------------------------------------- -Test lists are empty failed (6 shrink steps): +Test lists are empty failed (7 shrink steps): [0] @@ -592,9 +595,9 @@ Test lists shorter than 4332 failed (4022 shrink steps): --- Failure -------------------------------------------------------------------- -Test lists have unique elems failed (10 shrink steps): +Test lists have unique elems failed (8 shrink steps): -[0; 0; 0] +[6; 6] --- Failure -------------------------------------------------------------------- @@ -634,31 +637,31 @@ Test sum list = 0 failed (0 shrink steps): --- Failure -------------------------------------------------------------------- -Test fail_pred_map_commute_int failed (105 shrink steps): +Test fail_pred_map_commute_int failed (107 shrink steps): ([0], {0 -> 29; _ -> 0}, {29 -> true; _ -> false}) --- Failure -------------------------------------------------------------------- -Test fail_pred_map_commute_int32 failed (54 shrink steps): +Test fail_pred_map_commute_int32 failed (57 shrink steps): ([0l], {0l -> -15l; _ -> 0l}, {-15l -> true; _ -> false}) --- Failure -------------------------------------------------------------------- -Test fail_pred_map_commute_int64 failed (105 shrink steps): +Test fail_pred_map_commute_int64 failed (107 shrink steps): ([0L], {0L -> -71L; _ -> 0L}, {-71L -> true; _ -> false}) --- Failure -------------------------------------------------------------------- -Test fail_pred_strings failed (0 shrink steps): +Test fail_pred_strings failed (1 shrink steps): -{"some random string" -> true; "some other string" -> false; _ -> false} +{"some random string" -> true; _ -> false} --- Failure -------------------------------------------------------------------- -Test fold_left fold_right failed (17 shrink steps): +Test fold_left fold_right failed (20 shrink steps): (0, [1], {(0, 1) -> 1; _ -> 0}) @@ -671,9 +674,9 @@ l=[1], fold_left=0, fold_right=1 --- Failure -------------------------------------------------------------------- -Test fold_left fold_right uncurried failed (14 shrink steps): +Test fold_left fold_right uncurried failed (17 shrink steps): -({(9, 6) -> 0; (1, 5) -> 0; (4, 8) -> 1; (9, 8) -> 0; _ -> 0}, 8, [4]) +({(9, 6) -> 0; (1, 5) -> 0; (4, 8) -> 0; (9, 8) -> 1; _ -> 0}, 8, [9]) --- Failure -------------------------------------------------------------------- diff --git a/test/core/QCheck2_expect_test.expected.ocaml5.32 b/test/core/QCheck2_expect_test.expected.ocaml5.32 index f14668fe..2207d60c 100644 --- a/test/core/QCheck2_expect_test.expected.ocaml5.32 +++ b/test/core/QCheck2_expect_test.expected.ocaml5.32 @@ -70,17 +70,19 @@ random seed: 1234 [0; 1; 80; 0; 9; 2; 3] [0; 1; 80; 0] [0; 1] -[0] +[1] [] +[0] [0; 1; 80; 0; 9; 2; 3] [0; 1; 80; 0] [0; 1] [80; 0] [1; 80; 0] [0; 1; 0] -[0; 1] +[1; 0] +[0; 0] +[0] [0] -[0; 0; 0] --- Failure -------------------------------------------------------------------- @@ -298,9 +300,9 @@ Test bytes never has a \255 char failed (5 shrink steps): --- Failure -------------------------------------------------------------------- -Test bytes have unique chars failed (29 shrink steps): +Test bytes have unique chars failed (27 shrink steps): -"aaa" +"\253\253" --- Failure -------------------------------------------------------------------- @@ -322,9 +324,9 @@ Test string never has a \255 char failed (5 shrink steps): --- Failure -------------------------------------------------------------------- -Test strings have unique chars failed (29 shrink steps): +Test strings have unique chars failed (27 shrink steps): -"aaa" +"\253\253" --- Failure -------------------------------------------------------------------- @@ -376,7 +378,7 @@ Test pairs lists rev concat failed (47 shrink steps): --- Failure -------------------------------------------------------------------- -Test pairs lists no overlap failed (17 shrink steps): +Test pairs lists no overlap failed (18 shrink steps): ([0], [0]) @@ -490,7 +492,7 @@ Test bind list_size constant failed (12 shrink steps): --- Failure -------------------------------------------------------------------- -Test lists are empty failed (3 shrink steps): +Test lists are empty failed (4 shrink steps): [0] @@ -516,7 +518,7 @@ Test lists shorter than 4332 failed (4005 shrink steps): Test lists have unique elems failed (3 shrink steps): -[0; 0; 0] +[0; 0] --- Failure -------------------------------------------------------------------- @@ -556,31 +558,31 @@ Test sum list = 0 failed (0 shrink steps): --- Failure -------------------------------------------------------------------- -Test fail_pred_map_commute_int failed (53 shrink steps): +Test fail_pred_map_commute_int failed (54 shrink steps): ([0], {0 -> 74; _ -> 0}, {74 -> true; _ -> false}) --- Failure -------------------------------------------------------------------- -Test fail_pred_map_commute_int32 failed (52 shrink steps): +Test fail_pred_map_commute_int32 failed (53 shrink steps): ([0l], {0l -> 99l; _ -> 0l}, {99l -> true; _ -> false}) --- Failure -------------------------------------------------------------------- -Test fail_pred_map_commute_int64 failed (108 shrink steps): +Test fail_pred_map_commute_int64 failed (109 shrink steps): ([0L], {0L -> 1L; _ -> 0L}, {1L -> true; _ -> false}) --- Failure -------------------------------------------------------------------- -Test fail_pred_strings failed (0 shrink steps): +Test fail_pred_strings failed (1 shrink steps): -{"some random string" -> true; "some other string" -> false; _ -> false} +{"some random string" -> true; _ -> false} --- Failure -------------------------------------------------------------------- -Test fold_left fold_right failed (18 shrink steps): +Test fold_left fold_right failed (24 shrink steps): (0, [1], {(0, 1) -> 1; _ -> 0}) @@ -593,13 +595,13 @@ l=[1], fold_left=0, fold_right=1 --- Failure -------------------------------------------------------------------- -Test fold_left fold_right uncurried failed (114 shrink steps): +Test fold_left fold_right uncurried failed (115 shrink steps): ({(6, 0) -> 1; _ -> 0}, 0, [6]) --- Failure -------------------------------------------------------------------- -Test fold_left fold_right uncurried fun last failed (21 shrink steps): +Test fold_left fold_right uncurried fun last failed (19 shrink steps): (0, [1], {(0, 1) -> 1; _ -> 0}) @@ -607,7 +609,7 @@ Test fold_left fold_right uncurried fun last failed (21 shrink steps): Test fold_left test, fun first failed (50 shrink steps): -({("", 5) -> "a"; _ -> ""}, "", [0; 0; 5], [0]) +({("", 5) -> "a"; _ -> ""}, "", [0; 5], [0]) --- Failure -------------------------------------------------------------------- diff --git a/test/core/QCheck2_expect_test.expected.ocaml5.64 b/test/core/QCheck2_expect_test.expected.ocaml5.64 index 33fb14d8..9205829a 100644 --- a/test/core/QCheck2_expect_test.expected.ocaml5.64 +++ b/test/core/QCheck2_expect_test.expected.ocaml5.64 @@ -132,17 +132,19 @@ random seed: 1234 [0; 1; 80; 0; 9; 2; 3] [0; 1; 80; 0] [0; 1] -[0] +[1] [] +[0] [0; 1; 80; 0; 9; 2; 3] [0; 1; 80; 0] [0; 1] [80; 0] [1; 80; 0] [0; 1; 0] -[0; 1] +[1; 0] +[0; 0] +[0] [0] -[0; 0; 0] --- Failure -------------------------------------------------------------------- @@ -360,9 +362,9 @@ Test bytes never has a \255 char failed (5 shrink steps): --- Failure -------------------------------------------------------------------- -Test bytes have unique chars failed (29 shrink steps): +Test bytes have unique chars failed (27 shrink steps): -"aaa" +"\253\253" --- Failure -------------------------------------------------------------------- @@ -384,9 +386,9 @@ Test string never has a \255 char failed (5 shrink steps): --- Failure -------------------------------------------------------------------- -Test strings have unique chars failed (29 shrink steps): +Test strings have unique chars failed (27 shrink steps): -"aaa" +"\253\253" --- Failure -------------------------------------------------------------------- @@ -438,7 +440,7 @@ Test pairs lists rev concat failed (79 shrink steps): --- Failure -------------------------------------------------------------------- -Test pairs lists no overlap failed (17 shrink steps): +Test pairs lists no overlap failed (18 shrink steps): ([0], [0]) @@ -552,7 +554,7 @@ Test bind list_size constant failed (12 shrink steps): --- Failure -------------------------------------------------------------------- -Test lists are empty failed (3 shrink steps): +Test lists are empty failed (4 shrink steps): [0] @@ -578,7 +580,7 @@ Test lists shorter than 4332 failed (4005 shrink steps): Test lists have unique elems failed (3 shrink steps): -[0; 0; 0] +[0; 0] --- Failure -------------------------------------------------------------------- @@ -618,31 +620,31 @@ Test sum list = 0 failed (0 shrink steps): --- Failure -------------------------------------------------------------------- -Test fail_pred_map_commute_int failed (108 shrink steps): +Test fail_pred_map_commute_int failed (109 shrink steps): ([0], {0 -> 1; _ -> 0}, {1 -> true; _ -> false}) --- Failure -------------------------------------------------------------------- -Test fail_pred_map_commute_int32 failed (52 shrink steps): +Test fail_pred_map_commute_int32 failed (53 shrink steps): ([0l], {0l -> 99l; _ -> 0l}, {99l -> true; _ -> false}) --- Failure -------------------------------------------------------------------- -Test fail_pred_map_commute_int64 failed (108 shrink steps): +Test fail_pred_map_commute_int64 failed (109 shrink steps): ([0L], {0L -> 1L; _ -> 0L}, {1L -> true; _ -> false}) --- Failure -------------------------------------------------------------------- -Test fail_pred_strings failed (0 shrink steps): +Test fail_pred_strings failed (1 shrink steps): -{"some random string" -> true; "some other string" -> false; _ -> false} +{"some random string" -> true; _ -> false} --- Failure -------------------------------------------------------------------- -Test fold_left fold_right failed (18 shrink steps): +Test fold_left fold_right failed (24 shrink steps): (0, [1], {(0, 1) -> 1; _ -> 0}) @@ -655,13 +657,13 @@ l=[1], fold_left=0, fold_right=1 --- Failure -------------------------------------------------------------------- -Test fold_left fold_right uncurried failed (114 shrink steps): +Test fold_left fold_right uncurried failed (115 shrink steps): ({(6, 0) -> 1; _ -> 0}, 0, [6]) --- Failure -------------------------------------------------------------------- -Test fold_left fold_right uncurried fun last failed (21 shrink steps): +Test fold_left fold_right uncurried fun last failed (19 shrink steps): (0, [1], {(0, 1) -> 1; _ -> 0}) @@ -669,7 +671,7 @@ Test fold_left fold_right uncurried fun last failed (21 shrink steps): Test fold_left test, fun first failed (50 shrink steps): -({("", 5) -> "a"; _ -> ""}, "", [0; 0; 5], [0]) +({("", 5) -> "a"; _ -> ""}, "", [0; 5], [0]) --- Failure -------------------------------------------------------------------- diff --git a/test/core/QCheck2_unit_tests.ml b/test/core/QCheck2_unit_tests.ml index 1278284e..9d89f474 100644 --- a/test/core/QCheck2_unit_tests.ml +++ b/test/core/QCheck2_unit_tests.ml @@ -216,7 +216,7 @@ module Shrink = struct Alcotest.(check' (list (list int))) ~msg:"[0; 5; 3; 7] on repeated success" ~actual:(Gen.(generate_tree ~rand:(rand_init 3345) (list (int_bound 10))) |> repeated_success) - ~expected:[ [0; 5; 3; 7]; [0; 5]; [0]; []; ]) + ~expected:[ [0; 5; 3; 7]; [0; 5]; [5]; []; ]) else (Alcotest.(check' (list (list int))) ~msg:"[1; 10; 10; 7; 3] on repeated failure" @@ -230,7 +230,7 @@ module Shrink = struct Alcotest.(check' (list (list int))) ~msg:"[1; 10; 10; 7; 3] on repeated success" ~actual:(Gen.(generate_tree ~rand:(rand_init 3347) (list (int_bound 10))) |> repeated_success) - ~expected:[ [1; 10; 10; 7; 3]; [1; 10; 10]; [1; 10]; [1]; []; ]) + ~expected:[ [1; 10; 10; 7; 3]; [1; 10; 10]; [10; 10]; [10]; []; ]) let test_small_list_int () = if ocaml_major_version < 5 @@ -245,7 +245,7 @@ module Shrink = struct Alcotest.(check' (list (list int))) ~msg:"[0; 5; 3; 7] on repeated success" ~actual:(Gen.(generate_tree ~rand:(rand_init 3345) (small_list (int_bound 10))) |> repeated_success) - ~expected:[ [0; 5; 3; 7]; [0; 5]; [0]; []; ]) + ~expected:[ [0; 5; 3; 7]; [0; 5]; [5]; []; ]) else (Alcotest.(check' (list (list int))) ~msg:"[1; 10; 10; 7; 3] on repeated failure" @@ -259,7 +259,7 @@ module Shrink = struct Alcotest.(check' (list (list int))) ~msg:"[1; 10; 10; 7; 3] on repeated success" ~actual:(Gen.(generate_tree ~rand:(rand_init 3347) (small_list (int_bound 10))) |> repeated_success) - ~expected:[ [1; 10; 10; 7; 3]; [1; 10; 10]; [1; 10]; [1]; []; ]) + ~expected:[ [1; 10; 10; 7; 3]; [1; 10; 10]; [10; 10]; [10]; []; ]) let test_array_size_int () = if ocaml_major_version < 5 @@ -304,7 +304,7 @@ module Shrink = struct Alcotest.(check' (list (array int))) ~msg:"[|0; 5; 3; 7|] on repeated success" ~actual:(Gen.(generate_tree ~rand:(rand_init 3345) (array (int_bound 10))) |> repeated_success) - ~expected:[ [|0; 5; 3; 7|]; [|0; 5|]; [|0|]; [||]; ]) + ~expected:[ [|0; 5; 3; 7|]; [|0; 5|]; [|5|]; [||]; ]) else (Alcotest.(check' (list (array int))) ~msg:"[|1; 10; 10; 7; 3|] on repeated failure" @@ -318,7 +318,7 @@ module Shrink = struct Alcotest.(check' (list (array int))) ~msg:"[|1; 10; 10; 7; 3|] on repeated success" ~actual:(Gen.(generate_tree ~rand:(rand_init 3347) (array (int_bound 10))) |> repeated_success) - ~expected:[ [|1; 10; 10; 7; 3|]; [|1; 10; 10|]; [|1; 10|]; [|1|]; [||]; ]) + ~expected:[ [|1; 10; 10; 7; 3|]; [|1; 10; 10|]; [|10; 10|]; [|10|]; [||]; ]) let test_small_array_int () = if ocaml_major_version < 5 @@ -333,7 +333,7 @@ module Shrink = struct Alcotest.(check' (list (array int))) ~msg:"[|0; 5; 3; 7|] on repeated success" ~actual:(Gen.(generate_tree ~rand:(rand_init 3345) (small_array (int_bound 10))) |> repeated_success) - ~expected:[ [|0; 5; 3; 7|]; [|0; 5|]; [|0|]; [||]; ]) + ~expected:[ [|0; 5; 3; 7|]; [|0; 5|]; [|5|]; [||]; ]) else (Alcotest.(check' (list (array int))) ~msg:"[|1; 10; 10; 7; 3|] on repeated failure" @@ -347,7 +347,7 @@ module Shrink = struct Alcotest.(check' (list (array int))) ~msg:"[|1; 10; 10; 7; 3|] on repeated success" ~actual:(Gen.(generate_tree ~rand:(rand_init 3347) (small_array (int_bound 10))) |> repeated_success) - ~expected:[ [|1; 10; 10; 7; 3|]; [|1; 10; 10|]; [|1; 10|]; [|1|]; [||]; ]) + ~expected:[ [|1; 10; 10; 7; 3|]; [|1; 10; 10|]; [|10; 10|]; [|10|]; [||]; ]) let test_bytes_size () = if ocaml_major_version < 5 @@ -400,7 +400,7 @@ module Shrink = struct Alcotest.(check' (list bytes)) ~msg:"\"9\007\127\250\" on repeated success" ~actual:(Gen.(generate_tree ~rand:(rand_init 3345) bytes) |> repeated_success) - ~expected:(List.map Bytes.of_string [ "9\007\127\250"; "9\007"; "9"; ""; ])) + ~expected:(List.map Bytes.of_string [ "9\007\127\250"; "9\007"; "\007"; ""; ])) else (Alcotest.(check' (list bytes)) ~msg:"\"\253NS\173\" on repeated failure" @@ -414,7 +414,7 @@ module Shrink = struct Alcotest.(check' (list bytes)) ~msg:"\"\253NS\173\" on repeated success" ~actual:(Gen.(generate_tree ~rand:(rand_init 3349) bytes) |> repeated_success) - ~expected:(List.map Bytes.of_string [ "\253NS\173"; "\253N"; "\253"; ""; ])) + ~expected:(List.map Bytes.of_string [ "\253NS\173"; "\253N"; "N"; ""; ])) let test_bytes_small () = if ocaml_major_version < 5 @@ -431,7 +431,7 @@ module Shrink = struct Alcotest.(check' (list bytes)) ~msg:"\"9\007\127\250\" on repeated success" ~actual:(Gen.(generate_tree ~rand:(rand_init 3345) bytes_small) |> repeated_success) - ~expected:(List.map Bytes.of_string [ "9\007\127\250"; "9\007"; "9"; ""; ])) + ~expected:(List.map Bytes.of_string [ "9\007\127\250"; "9\007"; "\007"; ""; ])) else (Alcotest.(check' (list bytes)) ~msg:"\"\253NS\173\" on repeated failure" @@ -445,7 +445,7 @@ module Shrink = struct Alcotest.(check' (list bytes)) ~msg:"\"\253NS\173\" on repeated success" ~actual:(Gen.(generate_tree ~rand:(rand_init 3349) bytes_small) |> repeated_success) - ~expected:(List.map Bytes.of_string [ "\253NS\173"; "\253N"; "\253"; ""; ])) + ~expected:(List.map Bytes.of_string [ "\253NS\173"; "\253N"; "N"; ""; ])) let test_string_size () = if ocaml_major_version < 5 @@ -495,7 +495,7 @@ module Shrink = struct Alcotest.(check' (list string)) ~msg:"\"9\007\127\250\" on repeated success" ~actual:(Gen.(generate_tree ~rand:(rand_init 3345) string) |> repeated_success) - ~expected:[ "9\007\127\250"; "9\007"; "9"; ""; ]) + ~expected:[ "9\007\127\250"; "9\007"; "\007"; ""; ]) else (Alcotest.(check' (list string)) ~msg:"\"\253NS\173\" on repeated failure" @@ -508,7 +508,7 @@ module Shrink = struct Alcotest.(check' (list string)) ~msg:"\"\253NS\173\" on repeated success" ~actual:(Gen.(generate_tree ~rand:(rand_init 3349) string) |> repeated_success) - ~expected:[ "\253NS\173"; "\253N"; "\253"; ""; ]) + ~expected:[ "\253NS\173"; "\253N"; "N"; ""; ]) let test_string_small () = if ocaml_major_version < 5 @@ -524,7 +524,7 @@ module Shrink = struct Alcotest.(check' (list string)) ~msg:"\"u\238\154I\" on repeated success" ~actual:(Gen.(generate_tree ~rand:(rand_init 3345) string_small) |> repeated_success) - ~expected:[ "9\007\127\250"; "9\007"; "9"; ""; ]) + ~expected:[ "9\007\127\250"; "9\007"; "\007"; ""; ]) else (Alcotest.(check' (list string)) ~msg:"\"\253NS\173\" on repeated failure" @@ -537,7 +537,7 @@ module Shrink = struct Alcotest.(check' (list string)) ~msg:"\"\253NS\173\" on repeated success" ~actual:(Gen.(generate_tree ~rand:(rand_init 3349) string_small) |> repeated_success) - ~expected:[ "\253NS\173"; "\253N"; "\253"; ""; ]) + ~expected:[ "\253NS\173"; "\253N"; "N"; ""; ]) let tests = ("Shrink", Alcotest.[ test_case "int_towards" `Quick test_int_towards;