Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Factor shrink loggers #172

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
@@ -1,168 +1,4 @@
random seed: 1234
2724675603984413065
0
1362337801992206532
0
681168900996103266
0
340584450498051633
0
170292225249025816
0
85146112624512908
0
42573056312256454
0
21286528156128227
0
10643264078064113
0
5321632039032056
0
2660816019516028
0
1330408009758014
0
665204004879007
0
332602002439503
0
166301001219751
0
83150500609875
0
41575250304937
0
20787625152468
0
10393812576234
0
5196906288117
0
2598453144058
0
1299226572029
0
649613286014
0
324806643007
0
162403321503
0
81201660751
0
40600830375
0
20300415187
0
10150207593
0
5075103796
0
2537551898
0
1268775949
0
634387974
0
317193987
0
158596993
0
79298496
0
39649248
0
19824624
0
9912312
0
4956156
0
2478078
0
1239039
0
619519
0
309759
0
154879
0
77439
0
38719
0
19359
0
9679
0
4839
0
2419
0
1209
0
604
0
302
0
151
0
75
0
37
0
18
0
9
0
4
0
2
0
1
0
[7; 1; 42; 1; 8; 5; 3; 9; 5; 38; 3; 3; 0; 1; 98; 1; 4; 13; 9; 2; 6; 9; 47; 6; 5; 8; 8; 6; 0; 9; 7; 2; 8; 6; 62; 6; 4; 31; 19; 1; 41; 60; 6; 5; 8; 1; 1; 4; 7; 7; 0; 5; 5; 71; 14; 26; 47; 5; 1; 6; 34; 9; 4; 2; 37; 3; 8; 4; 31; 6; 2; 1; 0; 7; 5; 1; 0; 15; 6; 1; 8; 13; 0; 6; 2; 4; 2; 6; 6; 1; 4; 1; 9; 79; 0; 87; 6; 8; 8; 62; 1; 4; 62; 6; 31; 1; 5; 6;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79; 7; 86; 52; 39; 19; 0; 4; 7; 7; 7; 0; 4; 8; 8; 0; 5; 13; 1; 5; 0; 7; 12; 64; 34; 1; 1; 85; 8; 2; 9; 76; 0; 2; 5; 76; 69; 8; 8; 0; 1; 2; 2; 4; 60; 29; 5; 9; 4; 0; 8; 3; 3; 5; 1; 35; 8; 2; 7; 23; 61; 56; 8; 1; 1; 78; 7; 5; 0; 30; 9; 3; 7; 28; 57; 98; 3; 52; 3; 82; 7; 5; 5; 6; 8; 1; 6; 8; 9; 8; 16; 0]
[]
[1; 9; 8; 28; 47; 8; 5; 6; 8; 9; 2; 5; 8; 30; 6; 8; 84; 0; 6; 7; 76; 7; 9; 1; 0; 5; 76; 95; 2; 2; 1; 45; 7; 8; 8; 1; 6; 37; 5; 6; 73; 8; 0; 85; 8; 0; 4; 5; 2; 0; 26; 59; 0; 5; 13; 4; 7; 3; 6; 8; 1; 3]
[]
[5; 0; 0; 4; 10; 2; 4; 9; 5; 73; 6; 1; 5; 5; 3; 10; 5; 31; 1; 4; 3; 8; 9; 13; 41; 20; 96; 5; 1; 2; 8]
[]
[9; 8; 73; 5; 8; 2; 1; 8; 2; 6; 4; 18; 5; 76; 3]
[]
[0; 6; 2; 8; 8; 1; 4]
[]
[5; 2; 3]
[3; 2; 7; 3; 3]
[]
[5; 3]
[5; 3; 2]
[9; 87; 7; 0]
[0; 2; 7; 3; 3]
[0; 0; 7; 3; 3]
[0; 0; 0; 3; 3]
[0; 0; 0; 0; 3]
[0; 0; 0; 0; 0]

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

Expand Down Expand Up @@ -282,7 +118,7 @@ Test nat < 5001 failed (7 shrink steps):

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

Test char is never produces 'abcdef' failed (1 shrink steps):
Test char is never 'abcdef' failed (1 shrink steps):

'a'

Expand Down
10 changes: 4 additions & 6 deletions test/core/QCheck2_expect_test.ml
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ module Shrink = struct

let ints_are_0 =
Test.make ~name:"ints are 0" ~count:1000 ~print:Print.int
Gen.int (fun i -> Printf.printf "%i\n" i; i = 0)
Gen.int (fun i -> i = 0)

(* test from issue #59 *)
let ints_smaller_209609 =
Expand All @@ -177,7 +177,7 @@ module Shrink = struct
Gen.nat (fun n -> n < 5001)

let char_is_never_abcdef =
Test.make ~name:"char is never produces 'abcdef'" ~count:1000 ~print:Print.char
Test.make ~name:"char is never 'abcdef'" ~count:1000 ~print:Print.char
Gen.char (fun c -> not (List.mem c ['a';'b';'c';'d';'e';'f']))

let strings_are_empty =
Expand All @@ -195,11 +195,9 @@ module Shrink = struct
(fun s -> String.to_seq s |> Seq.fold_left (fun acc c -> acc && c <> '\255') true)

(* tests from issue #64 *)
let print_list xs = print_endline Print.(list int xs)

let lists_are_empty_issue_64 =
Test.make ~name:"lists are empty" ~print:Print.(list int)
Gen.(list small_int) (fun xs -> print_list xs; xs = [])
Gen.(list small_int) (fun xs -> xs = [])

let list_shorter_10 =
Test.make ~name:"lists shorter than 10" ~print:Print.(list int)
Expand Down Expand Up @@ -230,7 +228,7 @@ module Shrink = struct
Test.make ~name:"lists have unique elems" ~print:Print.(list int)
Gen.(list small_int)
(fun xs -> let ys = List.sort_uniq Int.compare xs in
print_list xs; List.length xs = List.length ys)
List.length xs = List.length ys)

let tree_contains_only_42 =
Test.make ~name:"tree contains only 42" ~print:IntTree.print_tree
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,103 +1,4 @@
random seed: 1234
2724675603984413065
1362337801992206533
681168900996103267
340584450498051634
170292225249025817
85146112624512909
42573056312256455
21286528156128228
10643264078064114
5321632039032057
2660816019516029
1330408009758015
665204004879008
332602002439504
166301001219752
83150500609876
41575250304938
20787625152469
10393812576235
5196906288118
2598453144059
1299226572030
649613286015
324806643008
162403321504
81201660752
40600830376
20300415188
10150207594
5075103797
2537551899
1268775950
634387975
317193988
158596994
79298497
39649249
19824625
9912313
4956157
2478079
1239040
619520
309760
154880
77440
38720
19360
9680
4840
2420
1210
605
303
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7; 4]
[7; 6]
[7; 6]

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

Expand Down Expand Up @@ -217,7 +118,7 @@ Test nat < 5001 failed (6 shrink steps):

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

Test char is never produces 'abcdef' failed (0 shrink steps):
Test char is never 'abcdef' failed (0 shrink steps):

'd'

Expand Down
9 changes: 4 additions & 5 deletions test/core/QCheck_expect_test.ml
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ module Shrink = struct

let ints_are_0 =
Test.make ~name:"ints are 0" ~count:1000
int (fun i -> Printf.printf "%i\n" i; i = 0)
int (fun i -> i = 0)

(* test from issue #59 *)
let ints_smaller_209609 =
Expand All @@ -173,7 +173,7 @@ module Shrink = struct
(make ~print:Print.int ~shrink:Shrink.int Gen.nat) (fun n -> n < 5001)

let char_is_never_abcdef =
Test.make ~name:"char is never produces 'abcdef'" ~count:1000
Test.make ~name:"char is never 'abcdef'" ~count:1000
char (fun c -> not (List.mem c ['a';'b';'c';'d';'e';'f']))

let strings_are_empty =
Expand All @@ -190,11 +190,10 @@ module Shrink = struct
string
(fun s -> String.to_seq s |> Seq.fold_left (fun acc c -> acc && c <> '\255') true)

let print_list xs = print_endline Print.(list int xs)
(* test from issue #64 *)
let lists_are_empty_issue_64 =
Test.make ~name:"lists are empty"
(list small_int) (fun xs -> print_list xs; xs = [])
(list small_int) (fun xs -> xs = [])

let list_shorter_10 =
Test.make ~name:"lists shorter than 10"
Expand Down Expand Up @@ -225,7 +224,7 @@ module Shrink = struct
Test.make ~name:"lists have unique elems"
(list small_int)
(fun xs -> let ys = List.sort_uniq Int.compare xs in
print_list xs; List.length xs = List.length ys)
List.length xs = List.length ys)
end

(* tests function generator and shrinker *)
Expand Down
Loading