From ff6a3779ca39dc9781e0f51deeb2143ed18b33df Mon Sep 17 00:00:00 2001 From: Simon Cruanes Date: Mon, 9 Aug 2021 12:45:31 -0400 Subject: [PATCH 01/49] test: add package on main test --- test/core/dune | 1 + 1 file changed, 1 insertion(+) diff --git a/test/core/dune b/test/core/dune index 75871057..40e59e0c 100644 --- a/test/core/dune +++ b/test/core/dune @@ -1,3 +1,4 @@ (test (name test) + (package qcheck-core) (libraries qcheck-core alcotest)) From f163a46981379560096acc10078e3f5b6a2b0b93 Mon Sep 17 00:00:00 2001 From: Jan Midtgaard Date: Tue, 10 Aug 2021 16:08:51 +0200 Subject: [PATCH 02/49] fix overflow --- src/core/QCheck2.ml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/core/QCheck2.ml b/src/core/QCheck2.ml index a3dea662..2e648125 100644 --- a/src/core/QCheck2.ml +++ b/src/core/QCheck2.ml @@ -1700,7 +1700,10 @@ module Test = struct int_of_float (ceil (Int64.to_float sample_width /. float_of_int stat_max_lines)) else max_idx-min_idx, 1 in - let hist_size = if min_idx + bucket_size * hist_size <= max_idx then 1+hist_size else hist_size in + let hist_size = + if Int64.(add (of_int min_idx) (mul (of_int bucket_size) (of_int hist_size))) <= Int64.of_int max_idx + then 1+hist_size + else hist_size in (* accumulate bucket counts *) let max_val = ref 0 in (* max value after grouping by buckets *) let bucket_count = Array.init hist_size (fun _ -> 0) in From 5ca4219b7eaaaa3466ace5681b322e369e40a80c Mon Sep 17 00:00:00 2001 From: Jan Midtgaard Date: Tue, 10 Aug 2021 16:12:47 +0200 Subject: [PATCH 03/49] avoid repeated conversion --- src/core/QCheck2.ml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/core/QCheck2.ml b/src/core/QCheck2.ml index 2e648125..3996f44a 100644 --- a/src/core/QCheck2.ml +++ b/src/core/QCheck2.ml @@ -1693,15 +1693,16 @@ module Test = struct median := i)); (* group by buckets, if there are too many entries: *) (* first compute histogram and bucket size *) + let min_idx64, max_idx64 = Int64.(of_int min_idx, of_int max_idx) in let hist_size, bucket_size = - let sample_width = Int64.(sub (of_int max_idx) (of_int min_idx)) in + let sample_width = Int64.sub max_idx64 min_idx64 in if sample_width > Int64.of_int stat_max_lines then stat_max_lines, int_of_float (ceil (Int64.to_float sample_width /. float_of_int stat_max_lines)) else max_idx-min_idx, 1 in let hist_size = - if Int64.(add (of_int min_idx) (mul (of_int bucket_size) (of_int hist_size))) <= Int64.of_int max_idx + if Int64.(add min_idx64 (mul (of_int bucket_size) (of_int hist_size))) <= max_idx64 then 1+hist_size else hist_size in (* accumulate bucket counts *) @@ -1709,7 +1710,7 @@ module Test = struct let bucket_count = Array.init hist_size (fun _ -> 0) in Hashtbl.iter (fun j count -> - let bucket = Int64.(to_int (div (sub (of_int j) (of_int min_idx)) (of_int bucket_size))) in + let bucket = Int64.(to_int (div (sub (of_int j) min_idx64) (of_int bucket_size))) in let new_count = bucket_count.(bucket) + count in bucket_count.(bucket) <- new_count; max_val := max !max_val new_count) tbl; From 5d055dd3bcba2aac81ca63e4195885db21461112 Mon Sep 17 00:00:00 2001 From: Jan Midtgaard Date: Tue, 10 Aug 2021 16:24:18 +0200 Subject: [PATCH 04/49] clean-up rep.code --- src/core/QCheck2.ml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/core/QCheck2.ml b/src/core/QCheck2.ml index 3996f44a..e7936d4b 100644 --- a/src/core/QCheck2.ml +++ b/src/core/QCheck2.ml @@ -1721,9 +1721,8 @@ module Test = struct " num: %d, avg: %.2f, stddev: %.2f, median %d, min %d, max %d\n" !num !avg stddev !median min_idx max_idx; let indwidth = - max (String.length (Printf.sprintf "%d" min_idx)) - (max (String.length (Printf.sprintf "%d" max_idx)) - (String.length (Printf.sprintf "%d" (min_idx + bucket_size * hist_size)))) in + let str_width i = String.length (Printf.sprintf "%d" i) in + List.map str_width [min_idx; max_idx; min_idx + bucket_size * hist_size] |> List.fold_left max min_int in let labwidth = if bucket_size=1 then indwidth else 2+2*indwidth in for i = 0 to hist_size - 1 do let i' = min_idx + i * bucket_size in From ea6a2f671b8453684827a5099ca8f4338aa8c722 Mon Sep 17 00:00:00 2001 From: Jan Midtgaard Date: Wed, 11 Aug 2021 17:41:39 +0200 Subject: [PATCH 05/49] initial version --- test/core/QCheck2_expect_test.ml | 192 +++++++++++++ test/core/QCheck_expect_test.ml | 183 +++++++++++++ test/core/dune | 46 +++- test/core/qcheck2_output.txt.expected | 373 ++++++++++++++++++++++++++ test/core/qcheck_output.txt.expected | 373 ++++++++++++++++++++++++++ 5 files changed, 1164 insertions(+), 3 deletions(-) create mode 100644 test/core/QCheck2_expect_test.ml create mode 100644 test/core/QCheck_expect_test.ml create mode 100644 test/core/qcheck2_output.txt.expected create mode 100644 test/core/qcheck_output.txt.expected diff --git a/test/core/QCheck2_expect_test.ml b/test/core/QCheck2_expect_test.ml new file mode 100644 index 00000000..7f471fda --- /dev/null +++ b/test/core/QCheck2_expect_test.ml @@ -0,0 +1,192 @@ +(** QCheck2 tests **) + +let passing = + QCheck2.Test.make ~count:100 ~long_factor:100 ~print:QCheck2.Print.(list int) + ~name:"list_rev_is_involutive" + QCheck2.Gen.(list small_int) + (fun l -> List.rev (List.rev l) = l);; + +let failing = + QCheck2.Test.make ~count:10 + ~name:"should_fail_sort_id" ~print:QCheck2.Print.(list int) + QCheck2.Gen.(small_list small_int) + (fun l -> l = List.sort compare l);; + +exception Error + +let error = + QCheck2.Test.make ~count:10 + ~name:"should_error_raise_exn" ~print:QCheck2.Print.int + QCheck2.Gen.int + (fun _ -> raise Error) + +let collect = + QCheck2.Test.make ~count:100 ~long_factor:100 + ~name:"collect_results" ~print:QCheck2.Print.int + ~collect:string_of_int (QCheck2.Gen.int_bound 4) + (fun _ -> true) + +let stats = + QCheck2.Test.make ~count:100 ~long_factor:100 + ~name:"with_stats" ~print:QCheck2.Print.int + ~stats:[ + "mod4", (fun i->i mod 4); + "num", (fun i->i); + ] + (QCheck2.Gen.int_bound 120) + (fun _ -> true) + +let fun1 = + let open QCheck2 in + Test.make ~count:100 ~long_factor:100 + ~name:"FAIL_pred_map_commute" ~print:Print.(triple (list int) Fn.print Fn.print) + Gen.(triple + (small_list small_int) + (fun1 ~print:Print.int Observable.int int) + (fun1 ~print:Print.bool Observable.int bool)) + (fun (l,QCheck2.Fun (_,f), QCheck2.Fun (_,p)) -> + List.filter p (List.map f l) = List.map f (List.filter p l)) + +let fun2 = + let open QCheck2 in + Test.make ~count:100 + ~name:"FAIL_fun2_pred_strings" ~print:Fn.print + (fun1 Observable.string ~print:Print.bool Gen.bool) + (fun (Fun (_,p)) -> + not (p "some random string") || p "some other string") + +let int_gen = QCheck2.Gen.small_nat (* int *) + +(* Another example (false) property *) +let prop_foldleft_foldright = + let open QCheck2 in + Test.make ~name:"fold_left fold_right" ~count:1000 ~long_factor:20 + ~print:Print.(triple int (list int) Fn.print) + Gen.(triple + int_gen + (list int_gen) + (fun2 ~print:Print.int Observable.int Observable.int int_gen)) + (fun (z,xs,f) -> + let l1 = List.fold_right (Fn.apply f) xs z in + let l2 = List.fold_left (Fn.apply f) z xs in + if l1=l2 then true + else QCheck.Test.fail_reportf "l=%s, fold_left=%s, fold_right=%s@." + (QCheck.Print.(list int) xs) + (QCheck.Print.int l1) + (QCheck.Print.int l2) + ) + +(* Another example (false) property *) +let prop_foldleft_foldright_uncurry = + let open QCheck2 in + Test.make ~name:"fold_left fold_right uncurried" ~count:1000 ~long_factor:20 + ~print:Print.(triple Fn.print int (list int)) + Gen.(triple + (fun1 ~print:Print.int Observable.(pair int int) int_gen) + int_gen + (list int_gen)) + (fun (f,z,xs) -> + List.fold_right (fun x y -> Fn.apply f (x,y)) xs z = + List.fold_left (fun x y -> Fn.apply f (x,y)) z xs) + +let long_shrink = + let open QCheck2 in + let listgen = Gen.(list_size (int_range 1000 10000) int) in + Test.make ~name:"long_shrink" ~print:Print.(pair (list int) (list int)) + (Gen.pair listgen listgen) + (fun (xs,ys) -> List.rev (xs@ys) = (List.rev xs)@(List.rev ys)) + +(* test shrinking on integers *) +let shrink_int = + let open QCheck2 in + Test.make ~count:1000 ~name:"mod3_should_fail" ~print:Print.int + Gen.int (fun i -> i mod 3 <> 0) + +let bad_assume_warn = + let open QCheck2 in + Test.make ~count:2_000 + ~name:"WARN_unlikely_precond" ~print:Print.int + Gen.int + (fun x -> + QCheck.assume (x mod 100 = 1); + true) + +let bad_assume_fail = + let open QCheck2 in + Test.make ~count:2_000 ~if_assumptions_fail:(`Fatal, 0.1) + ~name:"FAIL_unlikely_precond" ~print:Print.int + Gen.int + (fun x -> + QCheck.assume (x mod 100 = 1); + true) + +let find_ex = + let open QCheck2 in + Test.make ~name:"find_example" ~print:Print.int + Gen.(2--50) + (fun n -> + let st = Random.State.make [| 0 |] in + let f m = n < m && m < 2 * n in + try + let m = find_example_gen ~rand:st ~count:100_000 ~f Gen.(0 -- 1000) in + f m + with No_example_found _ -> false) + +let find_ex_uncaught_issue_99 : _ list = + let open QCheck2 in + let t1 = + let rs = (find_example ~count:10 ~f:(fun _ -> false) Gen.int) in + Test.make ~name:"FAIL_#99_1" rs (fun _ -> true) in + let t2 = + Test.make ~name:"should_succeed_#99_2" ~count:10 Gen.int + (fun i -> i <= max_int) in + [t1;t2] + +let stats_negs = + QCheck2.(Test.make ~count:5_000 ~name:"stats_neg" + ~stats:[("dist",fun x -> x)] Gen.small_signed_int) + (fun _ -> true) + +let stats_tests = + let open QCheck2 in + let dist = ("dist",fun x -> x) in + [ + Test.make ~name:"stat_display_test_1" ~count:1000 ~stats:[dist] Gen.small_signed_int (fun _ -> true); + Test.make ~name:"stat_display_test_2" ~count:1000 ~stats:[dist] Gen.small_nat (fun _ -> true); + Test.make ~name:"stat_display_test_3" ~count:1000 ~stats:[dist] (Gen.int_range (-43643) 435434) (fun _ -> true); + Test.make ~name:"stat_display_test_4" ~count:1000 ~stats:[dist] (Gen.int_range (-40000) 40000) (fun _ -> true); + Test.make ~name:"stat_display_test_5" ~count:1000 ~stats:[dist] (Gen.int_range (-4) 4) (fun _ -> true); + Test.make ~name:"stat_display_test_6" ~count:1000 ~stats:[dist] (Gen.int_range (-4) 17) (fun _ -> true); + Test.make ~name:"stat_display_test_7" ~count:100000 ~stats:[dist] Gen.int (fun _ -> true); + Test.make ~name:"stat_display_test_8" ~count:1000 ~stats:[dist] (Gen.oneofl[min_int;-1;0;1;max_int]) (fun _ -> true); + ] + +let stat_display_test9 = + let open QCheck2 in + Test.make ~name:"stat_display_test9" ~count:1_000 + ~stats:[("dist",fun x -> x)] Gen.(oneof [small_int_corners ();int]) (fun _ -> true) + +(* Calling runners *) + +let () = QCheck_base_runner.set_seed 1234 +let _ = + QCheck_base_runner.run_tests ~colors:false ([ + passing; + failing; + error; + collect; + stats; + fun1; + fun2; + prop_foldleft_foldright; + prop_foldleft_foldright_uncurry; + long_shrink; + shrink_int; + bad_assume_warn; + bad_assume_fail; + ] @ find_ex :: find_ex_uncaught_issue_99 + @ stats_negs :: stats_tests) + +let () = QCheck_base_runner.set_seed 153870556 +let _ = QCheck_base_runner.run_tests ~colors:false [stat_display_test9] + diff --git a/test/core/QCheck_expect_test.ml b/test/core/QCheck_expect_test.ml new file mode 100644 index 00000000..ca0fd0f9 --- /dev/null +++ b/test/core/QCheck_expect_test.ml @@ -0,0 +1,183 @@ +(** QCheck(1) tests **) + +let passing = + QCheck.Test.make ~count:100 ~long_factor:100 + ~name:"list_rev_is_involutive" + QCheck.(list small_int) + (fun l -> List.rev (List.rev l) = l) + +let failing = + QCheck.Test.make ~count:10 + ~name:"should_fail_sort_id" + QCheck.(small_list small_int) + (fun l -> l = List.sort compare l) + +exception Error + +let error = + QCheck.Test.make ~count:10 + ~name:"should_error_raise_exn" + QCheck.int + (fun _ -> raise Error) + +let collect = + QCheck.Test.make ~count:100 ~long_factor:100 + ~name:"collect_results" + QCheck.(make ~collect:string_of_int (Gen.int_bound 4)) + (fun _ -> true) + +let stats = + QCheck.Test.make ~count:100 ~long_factor:100 + ~name:"with_stats" + QCheck.(make (Gen.int_bound 120) + ~stats:[ + "mod4", (fun i->i mod 4); + "num", (fun i->i); + ] + ) + (fun _ -> true) + +let fun1 = + QCheck.Test.make ~count:100 ~long_factor:100 + ~name:"FAIL_pred_map_commute" + QCheck.(triple + (small_list small_int) + (fun1 Observable.int int) + (fun1 Observable.int bool)) + (fun (l,QCheck.Fun (_,f), QCheck.Fun (_,p)) -> + List.filter p (List.map f l) = List.map f (List.filter p l)) + +let fun2 = + QCheck.Test.make ~count:100 + ~name:"FAIL_fun2_pred_strings" + QCheck.(fun1 Observable.string bool) + (fun (QCheck.Fun (_,p)) -> + not (p "some random string") || p "some other string") + +let int_gen = QCheck.small_nat (* int *) + +(* Another example (false) property *) +let prop_foldleft_foldright = + let open QCheck in + Test.make ~name:"fold_left fold_right" ~count:1000 ~long_factor:20 + (triple + int_gen + (list int_gen) + (fun2 Observable.int Observable.int int_gen)) + (fun (z,xs,f) -> + let l1 = List.fold_right (Fn.apply f) xs z in + let l2 = List.fold_left (Fn.apply f) z xs in + if l1=l2 then true + else QCheck.Test.fail_reportf "l=%s, fold_left=%s, fold_right=%s@." + (QCheck.Print.(list int) xs) + (QCheck.Print.int l1) + (QCheck.Print.int l2) + ) + +(* Another example (false) property *) +let prop_foldleft_foldright_uncurry = + let open QCheck in + Test.make ~name:"fold_left fold_right uncurried" ~count:1000 ~long_factor:20 + (triple + (fun1 Observable.(pair int int) int_gen) + int_gen + (list int_gen)) + (fun (f,z,xs) -> + List.fold_right (fun x y -> Fn.apply f (x,y)) xs z = + List.fold_left (fun x y -> Fn.apply f (x,y)) z xs) + +let long_shrink = + let open QCheck in + let listgen = list_of_size (Gen.int_range 1000 10000) int in + Test.make ~name:"long_shrink" (pair listgen listgen) + (fun (xs,ys) -> List.rev (xs@ys) = (List.rev xs)@(List.rev ys)) + +(* test shrinking on integers *) +let shrink_int = + QCheck.Test.make ~count:1000 ~name:"mod3_should_fail" + QCheck.int (fun i -> i mod 3 <> 0) + +let bad_assume_warn = + QCheck.Test.make ~count:2_000 + ~name:"WARN_unlikely_precond" + QCheck.int + (fun x -> + QCheck.assume (x mod 100 = 1); + true) + +let bad_assume_fail = + QCheck.Test.make ~count:2_000 ~if_assumptions_fail:(`Fatal, 0.1) + ~name:"FAIL_unlikely_precond" + QCheck.int + (fun x -> + QCheck.assume (x mod 100 = 1); + true) + +let find_ex = + let open QCheck in + Test.make ~name:"find_example" (2--50) + (fun n -> + let st = Random.State.make [| 0 |] in + let f m = n < m && m < 2 * n in + try + let m = find_example_gen ~rand:st ~count:100_000 ~f Gen.(0 -- 1000) in + f m + with No_example_found _ -> false) + +let find_ex_uncaught_issue_99 : _ list = + let open QCheck in + let t1 = + let rs = make (find_example ~count:10 ~f:(fun _ -> false) Gen.int) in + Test.make ~name:"FAIL_#99_1" rs (fun _ -> true) in + let t2 = + Test.make ~name:"should_succeed_#99_2" ~count:10 int + (fun i -> i <= max_int) in + [t1;t2] + +let stats_negs = + QCheck.(Test.make ~count:5_000 ~name:"stats_neg" + (add_stat ("dist",fun x -> x) small_signed_int)) + (fun _ -> true) + +let stats_tests = + let open QCheck in + let dist = ("dist",fun x -> x) in + [ + Test.make ~name:"stat_display_test_1" ~count:1000 (add_stat dist small_signed_int) (fun _ -> true); + Test.make ~name:"stat_display_test_2" ~count:1000 (add_stat dist small_nat) (fun _ -> true); + Test.make ~name:"stat_display_test_3" ~count:1000 (add_stat dist (int_range (-43643) 435434)) (fun _ -> true); + Test.make ~name:"stat_display_test_4" ~count:1000 (add_stat dist (int_range (-40000) 40000)) (fun _ -> true); + Test.make ~name:"stat_display_test_5" ~count:1000 (add_stat dist (int_range (-4) 4)) (fun _ -> true); + Test.make ~name:"stat_display_test_6" ~count:1000 (add_stat dist (int_range (-4) 17)) (fun _ -> true); + Test.make ~name:"stat_display_test_7" ~count:100000 (add_stat dist int) (fun _ -> true); + Test.make ~name:"stat_display_test_8" ~count:1000 (add_stat dist (oneofl[min_int;-1;0;1;max_int])) (fun _ -> true); + ] + +let stat_display_test9 = + let open QCheck in + Test.make ~name:"stat_display_test9" ~count:1_000 + (add_stat ("dist",fun x -> x) (oneof [small_int_corners ();int])) (fun _ -> true) + +(* Calling runners *) + +let () = QCheck_base_runner.set_seed 1234 +let i = + QCheck_base_runner.run_tests ~colors:false ([ + passing; + failing; + error; + collect; + stats; + fun1; + fun2; + prop_foldleft_foldright; + prop_foldleft_foldright_uncurry; + long_shrink; + shrink_int; + bad_assume_warn; + bad_assume_fail; + ] @ find_ex :: find_ex_uncaught_issue_99 + @ stats_negs :: stats_tests) + +let () = QCheck_base_runner.set_seed 153870556 +let _ = QCheck_base_runner.run_tests ~colors:false [stat_display_test9] diff --git a/test/core/dune b/test/core/dune index 40e59e0c..4f4ee0e6 100644 --- a/test/core/dune +++ b/test/core/dune @@ -1,4 +1,44 @@ + (test - (name test) - (package qcheck-core) - (libraries qcheck-core alcotest)) + (name test) + (modules test) + (libraries qcheck-core alcotest)) + +(executables + (names QCheck_expect_test QCheck2_expect_test) + (modules QCheck_expect_test QCheck2_expect_test) + (libraries qcheck-core qcheck-core.runner)) + +;; rules for QCheck_expect_test +(rule + (targets qcheck_output.txt) + (deps ./QCheck_expect_test.exe) + (package qcheck-core) + (enabled_if (= %{os_type} "Unix")) + (action + (with-stdout-to + %{targets} + (run ./QCheck_expect_test.exe --no-colors)))) + +(rule + (alias runtest) + (package qcheck-core) + (enabled_if (= %{os_type} "Unix")) + (action (diff qcheck_output.txt.expected qcheck_output.txt))) + +;; rules for QCheck2_expect_test +(rule + (targets qcheck2_output.txt) + (deps ./QCheck2_expect_test.exe) + (package qcheck-core) + (enabled_if (= %{os_type} "Unix")) + (action + (with-stdout-to + %{targets} + (run ./QCheck2_expect_test.exe --no-colors)))) + +(rule + (alias runtest) + (package qcheck-core) + (enabled_if (= %{os_type} "Unix")) + (action (diff qcheck2_output.txt.expected qcheck2_output.txt))) diff --git a/test/core/qcheck2_output.txt.expected b/test/core/qcheck2_output.txt.expected new file mode 100644 index 00000000..eeb19832 --- /dev/null +++ b/test/core/qcheck2_output.txt.expected @@ -0,0 +1,373 @@ +random seed: 1234 + +--- Failure -------------------------------------------------------------------- + +Test should_fail_sort_id failed (9 shrink steps): + +[1; 0] + +=== Error ====================================================================== + +Test should_error_raise_exn errored on (1 shrink steps): + +0 + +exception Dune__exe__QCheck2_expect_test.Error + + ++++ Collect ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +Collect results for test collect_results: + +4: 20 cases +3: 25 cases +2: 17 cases +1: 18 cases +0: 20 cases + ++++ Stats for with_stats ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats mod4: + num: 100, avg: 1.68, stddev: 1.09, median 2, min 0, max 3 + 0: ############################## 17 + 1: ################################################### 29 + 2: ######################################## 23 + 3: ####################################################### 31 + +stats num: + num: 100, avg: 66.84, stddev: 31.94, median 65, min 2, max 120 + 2.. 7: ################## 3 + 8.. 13: ################## 3 + 14.. 19: 0 + 20.. 25: ########################################## 7 + 26.. 31: ######################## 4 + 32.. 37: ######################## 4 + 38.. 43: ################## 3 + 44.. 49: ################################################ 8 + 50.. 55: #################################### 6 + 56.. 61: #################################### 6 + 62.. 67: ####################################################### 9 + 68.. 73: ########################################## 7 + 74.. 79: ######################## 4 + 80.. 85: ################## 3 + 86.. 91: ############ 2 + 92.. 97: ########################################## 7 + 98..103: #################################### 6 + 104..109: #################################### 6 + 110..115: ####################################################### 9 + 116..121: ################## 3 + +--- Failure -------------------------------------------------------------------- + +Test FAIL_pred_map_commute failed (16 shrink steps): + +([2], {_ -> 0}, {1 -> false; 2 -> true; _ -> false}) + +--- Failure -------------------------------------------------------------------- + +Test FAIL_fun2_pred_strings failed (1 shrink steps): + +{"some random string" -> true; _ -> false} + +--- Failure -------------------------------------------------------------------- + +Test fold_left fold_right failed (22 shrink steps): + +(0, [1], {(1, 0) -> 1; (8, 0) -> 0; (8, 8) -> 0; (8, 93) -> 0; (7, 7) -> 0; (24, 5) -> 0; (7, 0) -> 0; (0, 2) -> 0; (2, 4) -> 0; (9, 8) -> 0; (4, 9) -> 0; (1, 24) -> 0; (9, 5) -> 0; (80, 9) -> 0; (24, 0) -> 0; (1, 8) -> 0; (5, 7) -> 0; (0, 7) -> 0; (7, 8) -> 0; (0, 24) -> 0; _ -> 0}) + ++++ Messages ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +Messages for test fold_left fold_right: + +l=[1], fold_left=1, fold_right=0 + + +--- Failure -------------------------------------------------------------------- + +Test fold_left fold_right uncurried failed (325 shrink steps): + +({(23, 62) -> 0; (9, 42) -> 0; (8, 61) -> 0; (8, 5) -> 0; (30, 5) -> 0; (9, 6) -> 0; (76, 6) -> 0; (19, 31) -> 0; (7, 62) -> 0; (0, 7) -> 1; (7, 1) -> 0; (78, 4) -> 0; (8, 2) -> 0; (78, 0) -> 0; (3, 47) -> 0; (4, 8) -> 0; (98, 9) -> 0; (1, 38) -> 0; (0, 26) -> 0; (1, 7) -> 0; (86, 3) -> 0; (9, 37) -> 0; (8, 1) -> 0; (79, 9) -> 0; (3, 5) -> 0; (56, 8) -> 0; (2, 5) -> 0; (8, 8) -> 0; (56, 67) -> 0; (5, 60) -> 0; (2, 31) -> 0; (61, 6) -> 0; (12, 5) -> 0; (76, 2) -> 0; (78, 8) -> 0; (1, 1) -> 0; (8, 9) -> 0; (7, 8) -> 0; (2, 9) -> 0; (29, 7) -> 0; (5, 8) -> 0; (28, 6) -> 0; (1, 4) -> 0; (9, 79) -> 0; (0, 1) -> 0; (1, 41) -> 0; (82, 98) -> 0; (6, 79) -> 0; (7, 6) -> 0; (4, 3) -> 0; (8, 12) -> 0; (5, 1) -> 0; (39, 1) -> 0; (3, 6) -> 0; (1, 2) -> 0; (76, 31) -> 0; (4, 1) -> 0; (6, 5) -> 0; (0, 8) -> 0; (8, 7) -> 0; (2, 6) -> 0; (52, 5) -> 0; (8, 47) -> 0; (5, 3) -> 0; (7, 9) -> 0; (13, 13) -> 0; (0, 87) -> 0; (82, 0) -> 0; (34, 8) -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-------------------------------------------------------------------- + +Test mod3_should_fail failed (1 shrink steps): + +0 + +!!! Warning !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +Warning for test WARN_unlikely_precond: + +WARNING: only 0.7% tests (of 2000) passed precondition for "WARN_unlikely_precond" + +NOTE: it is likely that the precondition is too strong, or that the generator is buggy. + +--- Failure -------------------------------------------------------------------- + +Test FAIL_unlikely_precond failed: + +ERROR: only 0.7% tests (of 2000) passed precondition for "FAIL_unlikely_precond" + +NOTE: it is likely that the precondition is too strong, or that the generator is buggy. + + +--- Failure -------------------------------------------------------------------- + +Test FAIL_#99_1 failed: + +ERROR: uncaught exception in generator for test FAIL_#99_1 after 100 steps: +Exception: QCheck2.No_example_found("") +Backtrace: + ++++ Stats for stats_neg ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats dist: + num: 5000, avg: 0.17, stddev: 29.68, median 0, min -99, max 99 + -99..-90: # 65 + -89..-80: # 63 + -79..-70: # 64 + -69..-60: # 58 + -59..-50: # 67 + -49..-40: # 72 + -39..-30: # 61 + -29..-20: # 61 + -19..-10: # 67 + -9.. 0: ####################################################### 2076 + 1.. 10: ############################################## 1764 + 11.. 20: # 66 + 21.. 30: # 64 + 31.. 40: # 64 + 41.. 50: # 67 + 51.. 60: # 60 + 61.. 70: # 75 + 71.. 80: # 60 + 81.. 90: # 60 + 91..100: # 66 + ++++ Stats for stat_display_test_1 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats dist: + num: 1000, avg: 0.90, stddev: 28.23, median 0, min -99, max 99 + -99..-90: # 12 + -89..-80: # 11 + -79..-70: # 9 + -69..-60: 6 + -59..-50: # 11 + -49..-40: # 13 + -39..-30: # 9 + -29..-20: # 13 + -19..-10: 8 + -9.. 0: ####################################################### 453 + 1.. 10: ######################################### 340 + 11.. 20: # 15 + 21.. 30: # 11 + 31.. 40: # 12 + 41.. 50: # 13 + 51.. 60: # 13 + 61.. 70: # 16 + 71.. 80: # 9 + 81.. 90: # 16 + 91..100: # 10 + ++++ Stats for stat_display_test_2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats dist: + num: 1000, avg: 15.11, stddev: 23.27, median 6, min 0, max 99 + 0.. 4: #################################################### 377 + 5.. 9: ####################################################### 392 + 10.. 14: ## 20 + 15.. 19: ## 15 + 20.. 24: # 11 + 25.. 29: ## 17 + 30.. 34: ## 19 + 35.. 39: ## 17 + 40.. 44: # 10 + 45.. 49: # 9 + 50.. 54: # 8 + 55.. 59: # 9 + 60.. 64: ## 15 + 65.. 69: # 10 + 70.. 74: # 13 + 75.. 79: ## 19 + 80.. 84: # 11 + 85.. 89: # 13 + 90.. 94: 5 + 95.. 99: # 10 + ++++ Stats for stat_display_test_3 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats dist: + num: 1000, avg: 195335.64, stddev: 136803.99, median 195583, min -43624, max 435210 + -43624..-19683: ############################################ 52 + -19682.. 4259: ######################################## 47 + 4260.. 28201: ############################## 36 + 28202.. 52143: ############################################ 52 + 52144.. 76085: ########################################## 50 + 76086..100027: ####################################################### 64 + 100028..123969: ############################################### 55 + 123970..147911: ######################################## 47 + 147912..171853: ############################################## 54 + 171854..195795: #################################### 43 + 195796..219737: ############################################## 54 + 219738..243679: ########################################### 51 + 243680..267621: ################################################ 57 + 267622..291563: ########################################## 49 + 291564..315505: #################################### 42 + 315506..339447: ###################################### 45 + 339448..363389: ################################################ 57 + 363390..387331: ###################################### 45 + 387332..411273: ########################################## 49 + 411274..435215: ########################################### 51 + ++++ Stats for stat_display_test_4 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats dist: + num: 1000, avg: -173.78, stddev: 23042.92, median 180, min -39859, max 39942 + -39859..-35869: ############################################# 56 + -35868..-31878: ################################### 43 + -31877..-27887: ################################################# 60 + -27886..-23896: ##################################### 46 + -23895..-19905: ######################################## 49 + -19904..-15914: #################################### 45 + -15913..-11923: ############################################ 54 + -11922.. -7932: ############################################### 58 + -7931.. -3941: ######################################### 51 + -3940.. 50: ############################ 35 + 51.. 4041: ####################################### 48 + 4042.. 8032: ########################################## 52 + 8033.. 12023: ######################################### 51 + 12024.. 16014: ########################################### 53 + 16015.. 20005: ############################################ 54 + 20006.. 23996: ################################## 42 + 23997.. 27987: ####################################################### 67 + 27988.. 31978: ################################ 40 + 31979.. 35969: ######################################### 51 + 35970.. 39960: #################################### 45 + ++++ Stats for stat_display_test_5 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats dist: + num: 1000, avg: 0.02, stddev: 2.55, median 0, min -4, max 4 + -4: ############################################ 99 + -3: ##################################################### 118 + -2: ################################################## 111 + -1: ################################################## 113 + 0: ################################################## 113 + 1: ##################################################### 118 + 2: ############################################# 102 + 3: ####################################################### 122 + 4: ############################################## 104 + ++++ Stats for stat_display_test_6 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats dist: + num: 1000, avg: 6.67, stddev: 6.39, median 7, min -4, max 17 + -4..-3: ############################################# 90 + -2..-1: ############################################# 91 + 0.. 1: ########################################## 84 + 2.. 3: ############################################## 92 + 4.. 5: ########################################### 87 + 6.. 7: ########################################### 86 + 8.. 9: ############################################ 89 + 10..11: ########################################### 87 + 12..13: ####################################################### 110 + 14..15: ############################################# 91 + 16..17: ############################################## 93 + 18..19: 0 + 20..21: 0 + 22..23: 0 + 24..25: 0 + 26..27: 0 + 28..29: 0 + 30..31: 0 + 32..33: 0 + 34..35: 0 + ++++ Stats for stat_display_test_7 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats dist: + num: 100000, avg: 6126662802445055.00, stddev: 2661484817981980672.00, median 158655556399988, min -4611578348806740501, max 4611677827646819817 + -4611578348806740501..-4150415539984062486: #################################################### 4926 + -4150415539984062485..-3689252731161384470: #################################################### 4949 + -3689252731161384469..-3228089922338706454: ##################################################### 4957 + -3228089922338706453..-2766927113516028438: ##################################################### 4993 + -2766927113516028437..-2305764304693350422: ###################################################### 5043 + -2305764304693350421..-1844601495870672406: ##################################################### 5040 + -1844601495870672405..-1383438687047994390: ##################################################### 4974 + -1383438687047994389.. -922275878225316374: ##################################################### 5031 + -922275878225316373.. -461113069402638358: ####################################################### 5136 + -461113069402638357.. 49739420039658: ##################################################### 4950 + 49739420039659.. 461212548242717674: ###################################################### 5076 + 461212548242717675.. 922375357065395690: #################################################### 4933 + 922375357065395691.. 1383538165888073706: ##################################################### 4970 + 1383538165888073707.. 1844700974710751722: #################################################### 4922 + 1844700974710751723.. 2305863783533429738: ###################################################### 5087 + 2305863783533429739.. 2767026592356107754: #################################################### 4913 + 2767026592356107755.. 3228189401178785770: ##################################################### 4960 + 3228189401178785771.. 3689352210001463786: ##################################################### 5029 + 3689352210001463787.. 4150515018824141802: ###################################################### 5048 + 4150515018824141803.. 4611677827646819818: ###################################################### 5063 + ++++ Stats for stat_display_test_8 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats dist: + num: 1000, avg: 4611686018427388.00, stddev: 2905870896563567616.00, median 0, min -4611686018427387904, max 4611686018427387903 + -4611686018427387904..-4150517416584649089: ################## 208 + -4150517416584649088..-3689348814741910273: 0 + -3689348814741910272..-3228180212899171457: 0 + -3228180212899171456..-2767011611056432641: 0 + -2767011611056432640..-2305843009213693825: 0 + -2305843009213693824..-1844674407370955009: 0 + -1844674407370955008..-1383505805528216193: 0 + -1383505805528216192.. -922337203685477377: 0 + -922337203685477376.. -461168601842738561: 0 + -461168601842738560.. 255: ####################################################### 603 + 256.. 461168601842739071: 0 + 461168601842739072.. 922337203685477887: 0 + 922337203685477888.. 1383505805528216703: 0 + 1383505805528216704.. 1844674407370955519: 0 + 1844674407370955520.. 2305843009213694335: 0 + 2305843009213694336.. 2767011611056433151: 0 + 2767011611056433152.. 3228180212899171967: 0 + 3228180212899171968.. 3689348814741910783: 0 + 3689348814741910784.. 4150517416584649599: 0 + 4150517416584649600.. 4611686018427387903: ################# 189 + -4611686018427387392..-4150517416584648577: 0 +================================================================================ +1 warning(s) +failure (9 tests failed, 1 tests errored, ran 25 tests) +random seed: 153870556 + ++++ Stats for stat_display_test9 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats dist: + num: 1000, avg: -10119269408092442.00, stddev: 1871251663919905536.00, median 9, min -4576142151952919207, max 4611686018427387903 + -4576142151952919207..-4116750743433903848: ## 25 + -4116750743433903847..-3657359334914888488: ## 23 + -3657359334914888487..-3197967926395873128: ### 30 + -3197967926395873127..-2738576517876857768: ## 24 + -2738576517876857767..-2279185109357842408: ## 28 + -2279185109357842407..-1819793700838827048: ## 21 + -1819793700838827047..-1360402292319811688: # 19 + -1360402292319811687.. -901010883800796328: ## 27 + -901010883800796327.. -441619475281780968: ## 27 + -441619475281780967.. 17771933237234392: ####################################################### 540 + 17771933237234393.. 477163341756249752: ## 21 + 477163341756249753.. 936554750275265112: # 19 + 936554750275265113.. 1395946158794280472: ## 24 + 1395946158794280473.. 1855337567313295832: ## 27 + 1855337567313295833.. 2314728975832311192: ## 21 + 2314728975832311193.. 2774120384351326552: ## 23 + 2774120384351326553.. 3233511792870341912: ### 36 + 3233511792870341913.. 3692903201389357272: # 17 + 3692903201389357273.. 4152294609908372632: ## 21 + 4152294609908372633.. 4611686018427387903: ## 27 + -4611686018427387815..-4152294609908372456: 0 +================================================================================ +success (ran 1 tests) diff --git a/test/core/qcheck_output.txt.expected b/test/core/qcheck_output.txt.expected new file mode 100644 index 00000000..96cc4f67 --- /dev/null +++ b/test/core/qcheck_output.txt.expected @@ -0,0 +1,373 @@ +random seed: 1234 + +--- Failure -------------------------------------------------------------------- + +Test should_fail_sort_id failed (18 shrink steps): + +[1; 0] + +=== Error ====================================================================== + +Test should_error_raise_exn errored on (63 shrink steps): + +0 + +exception Dune__exe__QCheck_expect_test.Error + + ++++ Collect ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +Collect results for test collect_results: + +4: 20 cases +3: 25 cases +2: 17 cases +1: 18 cases +0: 20 cases + ++++ Stats for with_stats ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats mod4: + num: 100, avg: 1.68, stddev: 1.09, median 2, min 0, max 3 + 0: ############################## 17 + 1: ################################################### 29 + 2: ######################################## 23 + 3: ####################################################### 31 + +stats num: + num: 100, avg: 66.84, stddev: 31.94, median 65, min 2, max 120 + 2.. 7: ################## 3 + 8.. 13: ################## 3 + 14.. 19: 0 + 20.. 25: ########################################## 7 + 26.. 31: ######################## 4 + 32.. 37: ######################## 4 + 38.. 43: ################## 3 + 44.. 49: ################################################ 8 + 50.. 55: #################################### 6 + 56.. 61: #################################### 6 + 62.. 67: ####################################################### 9 + 68.. 73: ########################################## 7 + 74.. 79: ######################## 4 + 80.. 85: ################## 3 + 86.. 91: ############ 2 + 92.. 97: ########################################## 7 + 98..103: #################################### 6 + 104..109: #################################### 6 + 110..115: ####################################################### 9 + 116..121: ################## 3 + +--- Failure -------------------------------------------------------------------- + +Test FAIL_pred_map_commute failed (127 shrink steps): + +([3], {_ -> 0}, {3 -> false; _ -> true}) + +--- Failure -------------------------------------------------------------------- + +Test FAIL_fun2_pred_strings failed (1 shrink steps): + +{some random string -> true; _ -> false} + +--- Failure -------------------------------------------------------------------- + +Test fold_left fold_right failed (25 shrink steps): + +(0, [1], {(1, 0) -> 1; _ -> 0}) + ++++ Messages ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +Messages for test fold_left fold_right: + +l=[1], fold_left=1, fold_right=0 + + +--- Failure -------------------------------------------------------------------- + +Test fold_left fold_right uncurried failed (111 shrink steps): + +({(5, 7) -> 0; _ -> 7}, 0, [5; 0]) + +--- Failure -------------------------------------------------------------------- + +Test long_shrink failed (149 shrink steps): + +([0], [-1]) + +--- Failure -------------------------------------------------------------------- + +Test mod3_should_fail failed (84 shrink steps): + +-21 + +!!! Warning !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +Warning for test WARN_unlikely_precond: + +WARNING: only 0.5% tests (of 2000) passed precondition for "WARN_unlikely_precond" + +NOTE: it is likely that the precondition is too strong, or that the generator is buggy. + +--- Failure -------------------------------------------------------------------- + +Test FAIL_unlikely_precond failed: + +ERROR: only 0.5% tests (of 2000) passed precondition for "FAIL_unlikely_precond" + +NOTE: it is likely that the precondition is too strong, or that the generator is buggy. + + +--- Failure -------------------------------------------------------------------- + +Test FAIL_#99_1 failed: + +ERROR: uncaught exception in generator for test FAIL_#99_1 after 100 steps: +Exception: QCheck.No_example_found("") +Backtrace: + ++++ Stats for stats_neg ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats dist: + num: 5000, avg: 0.17, stddev: 29.68, median 0, min -99, max 99 + -99..-90: # 65 + -89..-80: # 63 + -79..-70: # 64 + -69..-60: # 58 + -59..-50: # 67 + -49..-40: # 72 + -39..-30: # 61 + -29..-20: # 61 + -19..-10: # 67 + -9.. 0: ####################################################### 2076 + 1.. 10: ############################################## 1764 + 11.. 20: # 66 + 21.. 30: # 64 + 31.. 40: # 64 + 41.. 50: # 67 + 51.. 60: # 60 + 61.. 70: # 75 + 71.. 80: # 60 + 81.. 90: # 60 + 91..100: # 66 + ++++ Stats for stat_display_test_1 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats dist: + num: 1000, avg: 0.90, stddev: 28.23, median 0, min -99, max 99 + -99..-90: # 12 + -89..-80: # 11 + -79..-70: # 9 + -69..-60: 6 + -59..-50: # 11 + -49..-40: # 13 + -39..-30: # 9 + -29..-20: # 13 + -19..-10: 8 + -9.. 0: ####################################################### 453 + 1.. 10: ######################################### 340 + 11.. 20: # 15 + 21.. 30: # 11 + 31.. 40: # 12 + 41.. 50: # 13 + 51.. 60: # 13 + 61.. 70: # 16 + 71.. 80: # 9 + 81.. 90: # 16 + 91..100: # 10 + ++++ Stats for stat_display_test_2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats dist: + num: 1000, avg: 15.11, stddev: 23.27, median 6, min 0, max 99 + 0.. 4: #################################################### 377 + 5.. 9: ####################################################### 392 + 10.. 14: ## 20 + 15.. 19: ## 15 + 20.. 24: # 11 + 25.. 29: ## 17 + 30.. 34: ## 19 + 35.. 39: ## 17 + 40.. 44: # 10 + 45.. 49: # 9 + 50.. 54: # 8 + 55.. 59: # 9 + 60.. 64: ## 15 + 65.. 69: # 10 + 70.. 74: # 13 + 75.. 79: ## 19 + 80.. 84: # 11 + 85.. 89: # 13 + 90.. 94: 5 + 95.. 99: # 10 + ++++ Stats for stat_display_test_3 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats dist: + num: 1000, avg: 195335.64, stddev: 136803.99, median 195583, min -43624, max 435210 + -43624..-19683: ############################################ 52 + -19682.. 4259: ######################################## 47 + 4260.. 28201: ############################## 36 + 28202.. 52143: ############################################ 52 + 52144.. 76085: ########################################## 50 + 76086..100027: ####################################################### 64 + 100028..123969: ############################################### 55 + 123970..147911: ######################################## 47 + 147912..171853: ############################################## 54 + 171854..195795: #################################### 43 + 195796..219737: ############################################## 54 + 219738..243679: ########################################### 51 + 243680..267621: ################################################ 57 + 267622..291563: ########################################## 49 + 291564..315505: #################################### 42 + 315506..339447: ###################################### 45 + 339448..363389: ################################################ 57 + 363390..387331: ###################################### 45 + 387332..411273: ########################################## 49 + 411274..435215: ########################################### 51 + ++++ Stats for stat_display_test_4 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats dist: + num: 1000, avg: -173.78, stddev: 23042.92, median 180, min -39859, max 39942 + -39859..-35869: ############################################# 56 + -35868..-31878: ################################### 43 + -31877..-27887: ################################################# 60 + -27886..-23896: ##################################### 46 + -23895..-19905: ######################################## 49 + -19904..-15914: #################################### 45 + -15913..-11923: ############################################ 54 + -11922.. -7932: ############################################### 58 + -7931.. -3941: ######################################### 51 + -3940.. 50: ############################ 35 + 51.. 4041: ####################################### 48 + 4042.. 8032: ########################################## 52 + 8033.. 12023: ######################################### 51 + 12024.. 16014: ########################################### 53 + 16015.. 20005: ############################################ 54 + 20006.. 23996: ################################## 42 + 23997.. 27987: ####################################################### 67 + 27988.. 31978: ################################ 40 + 31979.. 35969: ######################################### 51 + 35970.. 39960: #################################### 45 + ++++ Stats for stat_display_test_5 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats dist: + num: 1000, avg: 0.02, stddev: 2.55, median 0, min -4, max 4 + -4: ############################################ 99 + -3: ##################################################### 118 + -2: ################################################## 111 + -1: ################################################## 113 + 0: ################################################## 113 + 1: ##################################################### 118 + 2: ############################################# 102 + 3: ####################################################### 122 + 4: ############################################## 104 + ++++ Stats for stat_display_test_6 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats dist: + num: 1000, avg: 6.67, stddev: 6.39, median 7, min -4, max 17 + -4..-3: ############################################# 90 + -2..-1: ############################################# 91 + 0.. 1: ########################################## 84 + 2.. 3: ############################################## 92 + 4.. 5: ########################################### 87 + 6.. 7: ########################################### 86 + 8.. 9: ############################################ 89 + 10..11: ########################################### 87 + 12..13: ####################################################### 110 + 14..15: ############################################# 91 + 16..17: ############################################## 93 + 18..19: 0 + 20..21: 0 + 22..23: 0 + 24..25: 0 + 26..27: 0 + 28..29: 0 + 30..31: 0 + 32..33: 0 + 34..35: 0 + ++++ Stats for stat_display_test_7 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats dist: + num: 100000, avg: 2541076923587387.50, stddev: 2660730801206827008.00, median 158655268318060, min -4611522359435274428, max 4611540922436307689 + -4611522359435274428..-4150369195341695293: ##################################################### 4976 + -4150369195341695292..-3689216031248116157: ##################################################### 4963 + -3689216031248116156..-3228062867154537021: ###################################################### 5038 + -3228062867154537020..-2766909703060957885: ##################################################### 4979 + -2766909703060957884..-2305756538967378749: ##################################################### 5001 + -2305756538967378748..-1844603374873799613: ##################################################### 4982 + -1844603374873799612..-1383450210780220477: ##################################################### 5025 + -1383450210780220476.. -922297046686641341: #################################################### 4901 + -922297046686641340.. -461143882593062205: ####################################################### 5126 + -461143882593062204.. 9281500516931: ##################################################### 5008 + 9281500516932.. 461162445594096067: ###################################################### 5041 + 461162445594096068.. 922315609687675203: ##################################################### 5001 + 922315609687675204.. 1383468773781254339: ##################################################### 4986 + 1383468773781254340.. 1844621937874833475: ##################################################### 4949 + 1844621937874833476.. 2305775101968412611: ##################################################### 5025 + 2305775101968412612.. 2766928266061991747: ##################################################### 5022 + 2766928266061991748.. 3228081430155570883: ##################################################### 4958 + 3228081430155570884.. 3689234594249150019: ##################################################### 4998 + 3689234594249150020.. 4150387758342729155: ##################################################### 4982 + 4150387758342729156.. 4611540922436308291: ###################################################### 5039 + ++++ Stats for stat_display_test_8 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats dist: + num: 1000, avg: 4611686018427388.00, stddev: 2905870896563567616.00, median 0, min -4611686018427387904, max 4611686018427387903 + -4611686018427387904..-4150517416584649089: ################## 208 + -4150517416584649088..-3689348814741910273: 0 + -3689348814741910272..-3228180212899171457: 0 + -3228180212899171456..-2767011611056432641: 0 + -2767011611056432640..-2305843009213693825: 0 + -2305843009213693824..-1844674407370955009: 0 + -1844674407370955008..-1383505805528216193: 0 + -1383505805528216192.. -922337203685477377: 0 + -922337203685477376.. -461168601842738561: 0 + -461168601842738560.. 255: ####################################################### 603 + 256.. 461168601842739071: 0 + 461168601842739072.. 922337203685477887: 0 + 922337203685477888.. 1383505805528216703: 0 + 1383505805528216704.. 1844674407370955519: 0 + 1844674407370955520.. 2305843009213694335: 0 + 2305843009213694336.. 2767011611056433151: 0 + 2767011611056433152.. 3228180212899171967: 0 + 3228180212899171968.. 3689348814741910783: 0 + 3689348814741910784.. 4150517416584649599: 0 + 4150517416584649600.. 4611686018427387903: ################# 189 + -4611686018427387392..-4150517416584648577: 0 +================================================================================ +1 warning(s) +failure (9 tests failed, 1 tests errored, ran 25 tests) +random seed: 153870556 + ++++ Stats for stat_display_test9 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats dist: + num: 1000, avg: -55083208105414400.00, stddev: 1847115855773139200.00, median 9, min -4590718933436425025, max 4611686018427387903 + -4590718933436425025..-4130598685843234370: ## 26 + -4130598685843234369..-3670478438250043714: # 13 + -3670478438250043713..-3210358190656853058: ### 37 + -3210358190656853057..-2750237943063662402: ### 30 + -2750237943063662401..-2290117695470471746: ## 27 + -2290117695470471745..-1829997447877281090: ## 24 + -1829997447877281089..-1369877200284090434: ## 27 + -1369877200284090433.. -909756952690899778: ## 27 + -909756952690899777.. -449636705097709122: ## 21 + -449636705097709121.. 10483542495481534: ####################################################### 531 + 10483542495481535.. 470603790088672190: ## 21 + 470603790088672191.. 930724037681862846: ## 27 + 930724037681862847.. 1390844285275053502: ## 24 + 1390844285275053503.. 1850964532868244158: ## 25 + 1850964532868244159.. 2311084780461434814: ## 28 + 2311084780461434815.. 2771205028054625470: ## 23 + 2771205028054625471.. 3231325275647816126: ## 23 + 3231325275647816127.. 3691445523241006782: ## 25 + 3691445523241006783.. 4151565770834197438: # 17 + 4151565770834197439.. 4611686018427387903: ## 24 + -4611686018427387713..-4151565770834197058: 0 +================================================================================ +success (ran 1 tests) From b046799d52d9d7a7c7e35ac12ba1698d78457201 Mon Sep 17 00:00:00 2001 From: Jan Midtgaard Date: Wed, 11 Aug 2021 17:48:27 +0200 Subject: [PATCH 06/49] add fun prop illustrating fun-last advantage --- test/core/QCheck2_expect_test.ml | 14 ++++++++++++++ test/core/QCheck_expect_test.ml | 13 +++++++++++++ test/core/qcheck2_output.txt.expected | 8 +++++++- test/core/qcheck_output.txt.expected | 8 +++++++- 4 files changed, 41 insertions(+), 2 deletions(-) diff --git a/test/core/QCheck2_expect_test.ml b/test/core/QCheck2_expect_test.ml index 7f471fda..df29a53b 100644 --- a/test/core/QCheck2_expect_test.ml +++ b/test/core/QCheck2_expect_test.ml @@ -89,6 +89,19 @@ let prop_foldleft_foldright_uncurry = List.fold_right (fun x y -> Fn.apply f (x,y)) xs z = List.fold_left (fun x y -> Fn.apply f (x,y)) z xs) +(* Same as the above (false) property, but generating+shrinking functions last *) +let prop_foldleft_foldright_uncurry_funlast = + let open QCheck2 in + Test.make ~name:"fold_left fold_right uncurried fun last" ~count:1000 ~long_factor:20 + ~print:Print.(triple int (list int) Fn.print) + Gen.(triple + int_gen + (list int_gen) + (fun1 ~print:Print.int Observable.(pair int int) int_gen)) + (fun (z,xs,f) -> + List.fold_right (fun x y -> Fn.apply f (x,y)) xs z = + List.fold_left (fun x y -> Fn.apply f (x,y)) z xs) + let long_shrink = let open QCheck2 in let listgen = Gen.(list_size (int_range 1000 10000) int) in @@ -180,6 +193,7 @@ let _ = fun2; prop_foldleft_foldright; prop_foldleft_foldright_uncurry; + prop_foldleft_foldright_uncurry_funlast; long_shrink; shrink_int; bad_assume_warn; diff --git a/test/core/QCheck_expect_test.ml b/test/core/QCheck_expect_test.ml index ca0fd0f9..74f6e4e5 100644 --- a/test/core/QCheck_expect_test.ml +++ b/test/core/QCheck_expect_test.ml @@ -86,6 +86,18 @@ let prop_foldleft_foldright_uncurry = List.fold_right (fun x y -> Fn.apply f (x,y)) xs z = List.fold_left (fun x y -> Fn.apply f (x,y)) z xs) +(* Same as the above (false) property, but generating+shrinking functions last *) +let prop_foldleft_foldright_uncurry_funlast = + let open QCheck in + Test.make ~name:"fold_left fold_right uncurried fun last" ~count:1000 ~long_factor:20 + (triple + int_gen + (list int_gen) + (fun1 Observable.(pair int int) int_gen)) + (fun (z,xs,f) -> + List.fold_right (fun x y -> Fn.apply f (x,y)) xs z = + List.fold_left (fun x y -> Fn.apply f (x,y)) z xs) + let long_shrink = let open QCheck in let listgen = list_of_size (Gen.int_range 1000 10000) int in @@ -172,6 +184,7 @@ let i = fun2; prop_foldleft_foldright; prop_foldleft_foldright_uncurry; + prop_foldleft_foldright_uncurry_funlast; long_shrink; shrink_int; bad_assume_warn; diff --git a/test/core/qcheck2_output.txt.expected b/test/core/qcheck2_output.txt.expected index eeb19832..502164af 100644 --- a/test/core/qcheck2_output.txt.expected +++ b/test/core/qcheck2_output.txt.expected @@ -90,6 +90,12 @@ Test fold_left fold_right uncurried failed (325 shrink steps): --- Failure -------------------------------------------------------------------- +Test fold_left fold_right uncurried fun last failed (25 shrink steps): + +(0, [1], {(0, 2) -> 0; (8, 80) -> 0; (93, 9) -> 0; (7, 24) -> 0; (8, 0) -> 0; (9, 7) -> 0; (0, 24) -> 0; (0, 7) -> 0; (7, 1) -> 0; (8, 9) -> 0; (24, 0) -> 0; (5, 8) -> 0; (1, 0) -> 1; (4, 8) -> 0; (7, 0) -> 0; (5, 7) -> 0; (8, 4) -> 0; (24, 5) -> 0; (0, 1) -> 0; (2, 8) -> 0; (9, 1) -> 0; (8, 8) -> 0; _ -> 0}) + +--- Failure -------------------------------------------------------------------- + Test long_shrink failed (3040 shrink steps): ([0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0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0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 1]) @@ -341,7 +347,7 @@ stats dist: -4611686018427387392..-4150517416584648577: 0 ================================================================================ 1 warning(s) -failure (9 tests failed, 1 tests errored, ran 25 tests) +failure (10 tests failed, 1 tests errored, ran 26 tests) random seed: 153870556 +++ Stats for stat_display_test9 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ diff --git a/test/core/qcheck_output.txt.expected b/test/core/qcheck_output.txt.expected index 96cc4f67..f21ad597 100644 --- a/test/core/qcheck_output.txt.expected +++ b/test/core/qcheck_output.txt.expected @@ -90,6 +90,12 @@ Test fold_left fold_right uncurried failed (111 shrink steps): --- Failure -------------------------------------------------------------------- +Test fold_left fold_right uncurried fun last failed (26 shrink steps): + +(0, [1], {(0, 1) -> 1; _ -> 0}) + +--- Failure -------------------------------------------------------------------- + Test long_shrink failed (149 shrink steps): ([0], [-1]) @@ -341,7 +347,7 @@ stats dist: -4611686018427387392..-4150517416584648577: 0 ================================================================================ 1 warning(s) -failure (9 tests failed, 1 tests errored, ran 25 tests) +failure (10 tests failed, 1 tests errored, ran 26 tests) random seed: 153870556 +++ Stats for stat_display_test9 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ From 15368f3e54ab11fee1412e14813af5d75eb3f14e Mon Sep 17 00:00:00 2001 From: Jan Midtgaard Date: Wed, 11 Aug 2021 18:11:55 +0200 Subject: [PATCH 07/49] collect tests thematically in sub-modules --- test/core/QCheck2_expect_test.ml | 403 +++++++++++++------------- test/core/QCheck_expect_test.ml | 387 +++++++++++++------------ test/core/qcheck2_output.txt.expected | 36 +-- test/core/qcheck_output.txt.expected | 36 +-- 4 files changed, 446 insertions(+), 416 deletions(-) diff --git a/test/core/QCheck2_expect_test.ml b/test/core/QCheck2_expect_test.ml index df29a53b..da412988 100644 --- a/test/core/QCheck2_expect_test.ml +++ b/test/core/QCheck2_expect_test.ml @@ -1,206 +1,221 @@ (** QCheck2 tests **) -let passing = - QCheck2.Test.make ~count:100 ~long_factor:100 ~print:QCheck2.Print.(list int) - ~name:"list_rev_is_involutive" - QCheck2.Gen.(list small_int) - (fun l -> List.rev (List.rev l) = l);; - -let failing = - QCheck2.Test.make ~count:10 - ~name:"should_fail_sort_id" ~print:QCheck2.Print.(list int) - QCheck2.Gen.(small_list small_int) - (fun l -> l = List.sort compare l);; - -exception Error - -let error = - QCheck2.Test.make ~count:10 - ~name:"should_error_raise_exn" ~print:QCheck2.Print.int - QCheck2.Gen.int - (fun _ -> raise Error) - -let collect = - QCheck2.Test.make ~count:100 ~long_factor:100 - ~name:"collect_results" ~print:QCheck2.Print.int - ~collect:string_of_int (QCheck2.Gen.int_bound 4) - (fun _ -> true) - -let stats = - QCheck2.Test.make ~count:100 ~long_factor:100 - ~name:"with_stats" ~print:QCheck2.Print.int - ~stats:[ - "mod4", (fun i->i mod 4); - "num", (fun i->i); +(* tests of overall functionality *) +module Overall = struct + let passing = + QCheck2.Test.make ~count:100 ~long_factor:100 ~print:QCheck2.Print.(list int) + ~name:"list_rev_is_involutive" + QCheck2.Gen.(list small_int) + (fun l -> List.rev (List.rev l) = l);; + + let failing = + QCheck2.Test.make ~count:10 + ~name:"should_fail_sort_id" ~print:QCheck2.Print.(list int) + QCheck2.Gen.(small_list small_int) + (fun l -> l = List.sort compare l);; + + exception Error + + let error = + QCheck2.Test.make ~count:10 + ~name:"should_error_raise_exn" ~print:QCheck2.Print.int + QCheck2.Gen.int + (fun _ -> raise Error) + + let collect = + QCheck2.Test.make ~count:100 ~long_factor:100 + ~name:"collect_results" ~print:QCheck2.Print.int + ~collect:string_of_int (QCheck2.Gen.int_bound 4) + (fun _ -> true) + + let stats = + QCheck2.Test.make ~count:100 ~long_factor:100 + ~name:"with_stats" ~print:QCheck2.Print.int + ~stats:[ + "mod4", (fun i->i mod 4); + "num", (fun i->i); + ] + (QCheck2.Gen.int_bound 120) + (fun _ -> true) + + let bad_assume_warn = + let open QCheck2 in + Test.make ~count:2_000 + ~name:"WARN_unlikely_precond" ~print:Print.int + Gen.int + (fun x -> + QCheck.assume (x mod 100 = 1); + true) + + let bad_assume_fail = + let open QCheck2 in + Test.make ~count:2_000 ~if_assumptions_fail:(`Fatal, 0.1) + ~name:"FAIL_unlikely_precond" ~print:Print.int + Gen.int + (fun x -> + QCheck.assume (x mod 100 = 1); + true) +end + +(* tests function generator and shrinker *) +module Function = struct + let fun1 = + let open QCheck2 in + Test.make ~count:100 ~long_factor:100 + ~name:"FAIL_pred_map_commute" ~print:Print.(triple (list int) Fn.print Fn.print) + Gen.(triple + (small_list small_int) + (fun1 ~print:Print.int Observable.int int) + (fun1 ~print:Print.bool Observable.int bool)) + (fun (l,QCheck2.Fun (_,f), QCheck2.Fun (_,p)) -> + List.filter p (List.map f l) = List.map f (List.filter p l)) + + let fun2 = + let open QCheck2 in + Test.make ~count:100 + ~name:"FAIL_fun2_pred_strings" ~print:Fn.print + (fun1 Observable.string ~print:Print.bool Gen.bool) + (fun (Fun (_,p)) -> + not (p "some random string") || p "some other string") + + let int_gen = QCheck2.Gen.small_nat (* int *) + + (* Another example (false) property *) + let prop_foldleft_foldright = + let open QCheck2 in + Test.make ~name:"fold_left fold_right" ~count:1000 ~long_factor:20 + ~print:Print.(triple int (list int) Fn.print) + Gen.(triple + int_gen + (list int_gen) + (fun2 ~print:Print.int Observable.int Observable.int int_gen)) + (fun (z,xs,f) -> + let l1 = List.fold_right (Fn.apply f) xs z in + let l2 = List.fold_left (Fn.apply f) z xs in + if l1=l2 then true + else QCheck.Test.fail_reportf "l=%s, fold_left=%s, fold_right=%s@." + (QCheck.Print.(list int) xs) + (QCheck.Print.int l1) + (QCheck.Print.int l2) + ) + + (* Another example (false) property *) + let prop_foldleft_foldright_uncurry = + let open QCheck2 in + Test.make ~name:"fold_left fold_right uncurried" ~count:1000 ~long_factor:20 + ~print:Print.(triple Fn.print int (list int)) + Gen.(triple + (fun1 ~print:Print.int Observable.(pair int int) int_gen) + int_gen + (list int_gen)) + (fun (f,z,xs) -> + List.fold_right (fun x y -> Fn.apply f (x,y)) xs z = + List.fold_left (fun x y -> Fn.apply f (x,y)) z xs) + + (* Same as the above (false) property, but generating+shrinking functions last *) + let prop_foldleft_foldright_uncurry_funlast = + let open QCheck2 in + Test.make ~name:"fold_left fold_right uncurried fun last" ~count:1000 ~long_factor:20 + ~print:Print.(triple int (list int) Fn.print) + Gen.(triple + int_gen + (list int_gen) + (fun1 ~print:Print.int Observable.(pair int int) int_gen)) + (fun (z,xs,f) -> + List.fold_right (fun x y -> Fn.apply f (x,y)) xs z = + List.fold_left (fun x y -> Fn.apply f (x,y)) z xs) +end + +(* tests of shrinking behaviour *) +module Shrink = struct + let long_shrink = + let open QCheck2 in + let listgen = Gen.(list_size (int_range 1000 10000) int) in + Test.make ~name:"long_shrink" ~print:Print.(pair (list int) (list int)) + (Gen.pair listgen listgen) + (fun (xs,ys) -> List.rev (xs@ys) = (List.rev xs)@(List.rev ys)) + + (* test shrinking on integers *) + let shrink_int = + let open QCheck2 in + Test.make ~count:1000 ~name:"mod3_should_fail" ~print:Print.int + Gen.int (fun i -> i mod 3 <> 0) +end + +(* tests of (inner) find_example(_gen) behaviour *) +module FindExample = struct + let find_ex = + let open QCheck2 in + Test.make ~name:"find_example" ~print:Print.int + Gen.(2--50) + (fun n -> + let st = Random.State.make [| 0 |] in + let f m = n < m && m < 2 * n in + try + let m = find_example_gen ~rand:st ~count:100_000 ~f Gen.(0 -- 1000) in + f m + with No_example_found _ -> false) + + let find_ex_uncaught_issue_99 : _ list = + let open QCheck2 in + let t1 = + let rs = (find_example ~count:10 ~f:(fun _ -> false) Gen.int) in + Test.make ~name:"FAIL_#99_1" rs (fun _ -> true) in + let t2 = + Test.make ~name:"should_succeed_#99_2" ~count:10 Gen.int + (fun i -> i <= max_int) in + [t1;t2] +end + +(* tests of statistics and histogram display *) +module Stats = struct + let stats_negs = + QCheck2.(Test.make ~count:5_000 ~name:"stats_neg" + ~stats:[("dist",fun x -> x)] Gen.small_signed_int) + (fun _ -> true) + + let stats_tests = + let open QCheck2 in + let dist = ("dist",fun x -> x) in + [ + Test.make ~name:"stat_display_test_1" ~count:1000 ~stats:[dist] Gen.small_signed_int (fun _ -> true); + Test.make ~name:"stat_display_test_2" ~count:1000 ~stats:[dist] Gen.small_nat (fun _ -> true); + Test.make ~name:"stat_display_test_3" ~count:1000 ~stats:[dist] (Gen.int_range (-43643) 435434) (fun _ -> true); + Test.make ~name:"stat_display_test_4" ~count:1000 ~stats:[dist] (Gen.int_range (-40000) 40000) (fun _ -> true); + Test.make ~name:"stat_display_test_5" ~count:1000 ~stats:[dist] (Gen.int_range (-4) 4) (fun _ -> true); + Test.make ~name:"stat_display_test_6" ~count:1000 ~stats:[dist] (Gen.int_range (-4) 17) (fun _ -> true); + Test.make ~name:"stat_display_test_7" ~count:100000 ~stats:[dist] Gen.int (fun _ -> true); + Test.make ~name:"stat_display_test_8" ~count:1000 ~stats:[dist] (Gen.oneofl[min_int;-1;0;1;max_int]) (fun _ -> true); ] - (QCheck2.Gen.int_bound 120) - (fun _ -> true) - -let fun1 = - let open QCheck2 in - Test.make ~count:100 ~long_factor:100 - ~name:"FAIL_pred_map_commute" ~print:Print.(triple (list int) Fn.print Fn.print) - Gen.(triple - (small_list small_int) - (fun1 ~print:Print.int Observable.int int) - (fun1 ~print:Print.bool Observable.int bool)) - (fun (l,QCheck2.Fun (_,f), QCheck2.Fun (_,p)) -> - List.filter p (List.map f l) = List.map f (List.filter p l)) - -let fun2 = - let open QCheck2 in - Test.make ~count:100 - ~name:"FAIL_fun2_pred_strings" ~print:Fn.print - (fun1 Observable.string ~print:Print.bool Gen.bool) - (fun (Fun (_,p)) -> - not (p "some random string") || p "some other string") - -let int_gen = QCheck2.Gen.small_nat (* int *) - -(* Another example (false) property *) -let prop_foldleft_foldright = - let open QCheck2 in - Test.make ~name:"fold_left fold_right" ~count:1000 ~long_factor:20 - ~print:Print.(triple int (list int) Fn.print) - Gen.(triple - int_gen - (list int_gen) - (fun2 ~print:Print.int Observable.int Observable.int int_gen)) - (fun (z,xs,f) -> - let l1 = List.fold_right (Fn.apply f) xs z in - let l2 = List.fold_left (Fn.apply f) z xs in - if l1=l2 then true - else QCheck.Test.fail_reportf "l=%s, fold_left=%s, fold_right=%s@." - (QCheck.Print.(list int) xs) - (QCheck.Print.int l1) - (QCheck.Print.int l2) - ) - -(* Another example (false) property *) -let prop_foldleft_foldright_uncurry = - let open QCheck2 in - Test.make ~name:"fold_left fold_right uncurried" ~count:1000 ~long_factor:20 - ~print:Print.(triple Fn.print int (list int)) - Gen.(triple - (fun1 ~print:Print.int Observable.(pair int int) int_gen) - int_gen - (list int_gen)) - (fun (f,z,xs) -> - List.fold_right (fun x y -> Fn.apply f (x,y)) xs z = - List.fold_left (fun x y -> Fn.apply f (x,y)) z xs) - -(* Same as the above (false) property, but generating+shrinking functions last *) -let prop_foldleft_foldright_uncurry_funlast = - let open QCheck2 in - Test.make ~name:"fold_left fold_right uncurried fun last" ~count:1000 ~long_factor:20 - ~print:Print.(triple int (list int) Fn.print) - Gen.(triple - int_gen - (list int_gen) - (fun1 ~print:Print.int Observable.(pair int int) int_gen)) - (fun (z,xs,f) -> - List.fold_right (fun x y -> Fn.apply f (x,y)) xs z = - List.fold_left (fun x y -> Fn.apply f (x,y)) z xs) - -let long_shrink = - let open QCheck2 in - let listgen = Gen.(list_size (int_range 1000 10000) int) in - Test.make ~name:"long_shrink" ~print:Print.(pair (list int) (list int)) - (Gen.pair listgen listgen) - (fun (xs,ys) -> List.rev (xs@ys) = (List.rev xs)@(List.rev ys)) - -(* test shrinking on integers *) -let shrink_int = - let open QCheck2 in - Test.make ~count:1000 ~name:"mod3_should_fail" ~print:Print.int - Gen.int (fun i -> i mod 3 <> 0) - -let bad_assume_warn = - let open QCheck2 in - Test.make ~count:2_000 - ~name:"WARN_unlikely_precond" ~print:Print.int - Gen.int - (fun x -> - QCheck.assume (x mod 100 = 1); - true) - -let bad_assume_fail = - let open QCheck2 in - Test.make ~count:2_000 ~if_assumptions_fail:(`Fatal, 0.1) - ~name:"FAIL_unlikely_precond" ~print:Print.int - Gen.int - (fun x -> - QCheck.assume (x mod 100 = 1); - true) - -let find_ex = - let open QCheck2 in - Test.make ~name:"find_example" ~print:Print.int - Gen.(2--50) - (fun n -> - let st = Random.State.make [| 0 |] in - let f m = n < m && m < 2 * n in - try - let m = find_example_gen ~rand:st ~count:100_000 ~f Gen.(0 -- 1000) in - f m - with No_example_found _ -> false) - -let find_ex_uncaught_issue_99 : _ list = - let open QCheck2 in - let t1 = - let rs = (find_example ~count:10 ~f:(fun _ -> false) Gen.int) in - Test.make ~name:"FAIL_#99_1" rs (fun _ -> true) in - let t2 = - Test.make ~name:"should_succeed_#99_2" ~count:10 Gen.int - (fun i -> i <= max_int) in - [t1;t2] - -let stats_negs = - QCheck2.(Test.make ~count:5_000 ~name:"stats_neg" - ~stats:[("dist",fun x -> x)] Gen.small_signed_int) - (fun _ -> true) - -let stats_tests = - let open QCheck2 in - let dist = ("dist",fun x -> x) in - [ - Test.make ~name:"stat_display_test_1" ~count:1000 ~stats:[dist] Gen.small_signed_int (fun _ -> true); - Test.make ~name:"stat_display_test_2" ~count:1000 ~stats:[dist] Gen.small_nat (fun _ -> true); - Test.make ~name:"stat_display_test_3" ~count:1000 ~stats:[dist] (Gen.int_range (-43643) 435434) (fun _ -> true); - Test.make ~name:"stat_display_test_4" ~count:1000 ~stats:[dist] (Gen.int_range (-40000) 40000) (fun _ -> true); - Test.make ~name:"stat_display_test_5" ~count:1000 ~stats:[dist] (Gen.int_range (-4) 4) (fun _ -> true); - Test.make ~name:"stat_display_test_6" ~count:1000 ~stats:[dist] (Gen.int_range (-4) 17) (fun _ -> true); - Test.make ~name:"stat_display_test_7" ~count:100000 ~stats:[dist] Gen.int (fun _ -> true); - Test.make ~name:"stat_display_test_8" ~count:1000 ~stats:[dist] (Gen.oneofl[min_int;-1;0;1;max_int]) (fun _ -> true); - ] - -let stat_display_test9 = - let open QCheck2 in - Test.make ~name:"stat_display_test9" ~count:1_000 - ~stats:[("dist",fun x -> x)] Gen.(oneof [small_int_corners ();int]) (fun _ -> true) + + let stat_display_test9 = + let open QCheck2 in + Test.make ~name:"stat_display_test9" ~count:1_000 + ~stats:[("dist",fun x -> x)] Gen.(oneof [small_int_corners ();int]) (fun _ -> true) +end (* Calling runners *) let () = QCheck_base_runner.set_seed 1234 let _ = QCheck_base_runner.run_tests ~colors:false ([ - passing; - failing; - error; - collect; - stats; - fun1; - fun2; - prop_foldleft_foldright; - prop_foldleft_foldright_uncurry; - prop_foldleft_foldright_uncurry_funlast; - long_shrink; - shrink_int; - bad_assume_warn; - bad_assume_fail; - ] @ find_ex :: find_ex_uncaught_issue_99 - @ stats_negs :: stats_tests) + Overall.passing; + Overall.failing; + Overall.error; + Overall.collect; + Overall.stats; + Overall.bad_assume_warn; + Overall.bad_assume_fail; + Function.fun1; + Function.fun2; + Function.prop_foldleft_foldright; + Function.prop_foldleft_foldright_uncurry; + Function.prop_foldleft_foldright_uncurry_funlast; + Shrink.long_shrink; + Shrink.shrink_int; + ] @ FindExample.find_ex :: FindExample.find_ex_uncaught_issue_99 + @ Stats.stats_negs :: Stats.stats_tests) let () = QCheck_base_runner.set_seed 153870556 -let _ = QCheck_base_runner.run_tests ~colors:false [stat_display_test9] +let _ = QCheck_base_runner.run_tests ~colors:false [Stats.stat_display_test9] diff --git a/test/core/QCheck_expect_test.ml b/test/core/QCheck_expect_test.ml index 74f6e4e5..c75a93ca 100644 --- a/test/core/QCheck_expect_test.ml +++ b/test/core/QCheck_expect_test.ml @@ -1,196 +1,211 @@ (** QCheck(1) tests **) -let passing = - QCheck.Test.make ~count:100 ~long_factor:100 - ~name:"list_rev_is_involutive" - QCheck.(list small_int) - (fun l -> List.rev (List.rev l) = l) - -let failing = - QCheck.Test.make ~count:10 - ~name:"should_fail_sort_id" - QCheck.(small_list small_int) - (fun l -> l = List.sort compare l) - -exception Error - -let error = - QCheck.Test.make ~count:10 - ~name:"should_error_raise_exn" - QCheck.int - (fun _ -> raise Error) - -let collect = - QCheck.Test.make ~count:100 ~long_factor:100 - ~name:"collect_results" - QCheck.(make ~collect:string_of_int (Gen.int_bound 4)) - (fun _ -> true) - -let stats = - QCheck.Test.make ~count:100 ~long_factor:100 - ~name:"with_stats" - QCheck.(make (Gen.int_bound 120) - ~stats:[ - "mod4", (fun i->i mod 4); - "num", (fun i->i); - ] - ) - (fun _ -> true) - -let fun1 = - QCheck.Test.make ~count:100 ~long_factor:100 - ~name:"FAIL_pred_map_commute" - QCheck.(triple - (small_list small_int) - (fun1 Observable.int int) - (fun1 Observable.int bool)) - (fun (l,QCheck.Fun (_,f), QCheck.Fun (_,p)) -> - List.filter p (List.map f l) = List.map f (List.filter p l)) - -let fun2 = - QCheck.Test.make ~count:100 - ~name:"FAIL_fun2_pred_strings" - QCheck.(fun1 Observable.string bool) - (fun (QCheck.Fun (_,p)) -> - not (p "some random string") || p "some other string") - -let int_gen = QCheck.small_nat (* int *) - -(* Another example (false) property *) -let prop_foldleft_foldright = - let open QCheck in - Test.make ~name:"fold_left fold_right" ~count:1000 ~long_factor:20 - (triple - int_gen - (list int_gen) - (fun2 Observable.int Observable.int int_gen)) - (fun (z,xs,f) -> - let l1 = List.fold_right (Fn.apply f) xs z in - let l2 = List.fold_left (Fn.apply f) z xs in - if l1=l2 then true - else QCheck.Test.fail_reportf "l=%s, fold_left=%s, fold_right=%s@." - (QCheck.Print.(list int) xs) - (QCheck.Print.int l1) - (QCheck.Print.int l2) - ) - -(* Another example (false) property *) -let prop_foldleft_foldright_uncurry = - let open QCheck in - Test.make ~name:"fold_left fold_right uncurried" ~count:1000 ~long_factor:20 - (triple - (fun1 Observable.(pair int int) int_gen) - int_gen - (list int_gen)) - (fun (f,z,xs) -> - List.fold_right (fun x y -> Fn.apply f (x,y)) xs z = - List.fold_left (fun x y -> Fn.apply f (x,y)) z xs) - -(* Same as the above (false) property, but generating+shrinking functions last *) -let prop_foldleft_foldright_uncurry_funlast = - let open QCheck in - Test.make ~name:"fold_left fold_right uncurried fun last" ~count:1000 ~long_factor:20 - (triple - int_gen - (list int_gen) - (fun1 Observable.(pair int int) int_gen)) - (fun (z,xs,f) -> - List.fold_right (fun x y -> Fn.apply f (x,y)) xs z = - List.fold_left (fun x y -> Fn.apply f (x,y)) z xs) - -let long_shrink = - let open QCheck in - let listgen = list_of_size (Gen.int_range 1000 10000) int in - Test.make ~name:"long_shrink" (pair listgen listgen) - (fun (xs,ys) -> List.rev (xs@ys) = (List.rev xs)@(List.rev ys)) - -(* test shrinking on integers *) -let shrink_int = - QCheck.Test.make ~count:1000 ~name:"mod3_should_fail" - QCheck.int (fun i -> i mod 3 <> 0) - -let bad_assume_warn = - QCheck.Test.make ~count:2_000 - ~name:"WARN_unlikely_precond" - QCheck.int - (fun x -> - QCheck.assume (x mod 100 = 1); - true) - -let bad_assume_fail = - QCheck.Test.make ~count:2_000 ~if_assumptions_fail:(`Fatal, 0.1) - ~name:"FAIL_unlikely_precond" - QCheck.int - (fun x -> - QCheck.assume (x mod 100 = 1); - true) - -let find_ex = - let open QCheck in - Test.make ~name:"find_example" (2--50) - (fun n -> - let st = Random.State.make [| 0 |] in - let f m = n < m && m < 2 * n in - try - let m = find_example_gen ~rand:st ~count:100_000 ~f Gen.(0 -- 1000) in - f m - with No_example_found _ -> false) - -let find_ex_uncaught_issue_99 : _ list = - let open QCheck in - let t1 = - let rs = make (find_example ~count:10 ~f:(fun _ -> false) Gen.int) in - Test.make ~name:"FAIL_#99_1" rs (fun _ -> true) in - let t2 = - Test.make ~name:"should_succeed_#99_2" ~count:10 int - (fun i -> i <= max_int) in - [t1;t2] - -let stats_negs = - QCheck.(Test.make ~count:5_000 ~name:"stats_neg" - (add_stat ("dist",fun x -> x) small_signed_int)) - (fun _ -> true) - -let stats_tests = - let open QCheck in - let dist = ("dist",fun x -> x) in - [ - Test.make ~name:"stat_display_test_1" ~count:1000 (add_stat dist small_signed_int) (fun _ -> true); - Test.make ~name:"stat_display_test_2" ~count:1000 (add_stat dist small_nat) (fun _ -> true); - Test.make ~name:"stat_display_test_3" ~count:1000 (add_stat dist (int_range (-43643) 435434)) (fun _ -> true); - Test.make ~name:"stat_display_test_4" ~count:1000 (add_stat dist (int_range (-40000) 40000)) (fun _ -> true); - Test.make ~name:"stat_display_test_5" ~count:1000 (add_stat dist (int_range (-4) 4)) (fun _ -> true); - Test.make ~name:"stat_display_test_6" ~count:1000 (add_stat dist (int_range (-4) 17)) (fun _ -> true); - Test.make ~name:"stat_display_test_7" ~count:100000 (add_stat dist int) (fun _ -> true); - Test.make ~name:"stat_display_test_8" ~count:1000 (add_stat dist (oneofl[min_int;-1;0;1;max_int])) (fun _ -> true); - ] - -let stat_display_test9 = - let open QCheck in - Test.make ~name:"stat_display_test9" ~count:1_000 - (add_stat ("dist",fun x -> x) (oneof [small_int_corners ();int])) (fun _ -> true) +(* tests of overall functionality *) +module Overall = struct + let passing = + QCheck.Test.make ~count:100 ~long_factor:100 + ~name:"list_rev_is_involutive" + QCheck.(list small_int) + (fun l -> List.rev (List.rev l) = l) + + let failing = + QCheck.Test.make ~count:10 + ~name:"should_fail_sort_id" + QCheck.(small_list small_int) + (fun l -> l = List.sort compare l) + + exception Error + + let error = + QCheck.Test.make ~count:10 + ~name:"should_error_raise_exn" + QCheck.int + (fun _ -> raise Error) + + let collect = + QCheck.Test.make ~count:100 ~long_factor:100 + ~name:"collect_results" + QCheck.(make ~collect:string_of_int (Gen.int_bound 4)) + (fun _ -> true) + + let stats = + QCheck.Test.make ~count:100 ~long_factor:100 + ~name:"with_stats" + QCheck.(make (Gen.int_bound 120) + ~stats:[ + "mod4", (fun i->i mod 4); + "num", (fun i->i); + ] + ) + (fun _ -> true) + + let bad_assume_warn = + QCheck.Test.make ~count:2_000 + ~name:"WARN_unlikely_precond" + QCheck.int + (fun x -> + QCheck.assume (x mod 100 = 1); + true) + + let bad_assume_fail = + QCheck.Test.make ~count:2_000 ~if_assumptions_fail:(`Fatal, 0.1) + ~name:"FAIL_unlikely_precond" + QCheck.int + (fun x -> + QCheck.assume (x mod 100 = 1); + true) +end + +(* tests function generator and shrinker *) +module Function = struct + let fun1 = + QCheck.Test.make ~count:100 ~long_factor:100 + ~name:"FAIL_pred_map_commute" + QCheck.(triple + (small_list small_int) + (fun1 Observable.int int) + (fun1 Observable.int bool)) + (fun (l,QCheck.Fun (_,f), QCheck.Fun (_,p)) -> + List.filter p (List.map f l) = List.map f (List.filter p l)) + + let fun2 = + QCheck.Test.make ~count:100 + ~name:"FAIL_fun2_pred_strings" + QCheck.(fun1 Observable.string bool) + (fun (QCheck.Fun (_,p)) -> + not (p "some random string") || p "some other string") + + let int_gen = QCheck.small_nat (* int *) + + (* Another example (false) property *) + let prop_foldleft_foldright = + let open QCheck in + Test.make ~name:"fold_left fold_right" ~count:1000 ~long_factor:20 + (triple + int_gen + (list int_gen) + (fun2 Observable.int Observable.int int_gen)) + (fun (z,xs,f) -> + let l1 = List.fold_right (Fn.apply f) xs z in + let l2 = List.fold_left (Fn.apply f) z xs in + if l1=l2 then true + else QCheck.Test.fail_reportf "l=%s, fold_left=%s, fold_right=%s@." + (QCheck.Print.(list int) xs) + (QCheck.Print.int l1) + (QCheck.Print.int l2) + ) + + (* Another example (false) property *) + let prop_foldleft_foldright_uncurry = + let open QCheck in + Test.make ~name:"fold_left fold_right uncurried" ~count:1000 ~long_factor:20 + (triple + (fun1 Observable.(pair int int) int_gen) + int_gen + (list int_gen)) + (fun (f,z,xs) -> + List.fold_right (fun x y -> Fn.apply f (x,y)) xs z = + List.fold_left (fun x y -> Fn.apply f (x,y)) z xs) + + (* Same as the above (false) property, but generating+shrinking functions last *) + let prop_foldleft_foldright_uncurry_funlast = + let open QCheck in + Test.make ~name:"fold_left fold_right uncurried fun last" ~count:1000 ~long_factor:20 + (triple + int_gen + (list int_gen) + (fun1 Observable.(pair int int) int_gen)) + (fun (z,xs,f) -> + List.fold_right (fun x y -> Fn.apply f (x,y)) xs z = + List.fold_left (fun x y -> Fn.apply f (x,y)) z xs) +end + +(* tests of shrinking behaviour *) +module Shrink = struct + let long_shrink = + let open QCheck in + let listgen = list_of_size (Gen.int_range 1000 10000) int in + Test.make ~name:"long_shrink" (pair listgen listgen) + (fun (xs,ys) -> List.rev (xs@ys) = (List.rev xs)@(List.rev ys)) + + (* test shrinking on integers *) + let shrink_int = + QCheck.Test.make ~count:1000 ~name:"mod3_should_fail" + QCheck.int (fun i -> i mod 3 <> 0) +end + +(* tests of (inner) find_example(_gen) behaviour *) +module FindExample = struct + let find_ex = + let open QCheck in + Test.make ~name:"find_example" (2--50) + (fun n -> + let st = Random.State.make [| 0 |] in + let f m = n < m && m < 2 * n in + try + let m = find_example_gen ~rand:st ~count:100_000 ~f Gen.(0 -- 1000) in + f m + with No_example_found _ -> false) + + let find_ex_uncaught_issue_99 : _ list = + let open QCheck in + let t1 = + let rs = make (find_example ~count:10 ~f:(fun _ -> false) Gen.int) in + Test.make ~name:"FAIL_#99_1" rs (fun _ -> true) in + let t2 = + Test.make ~name:"should_succeed_#99_2" ~count:10 int + (fun i -> i <= max_int) in + [t1;t2] +end + +(* tests of statistics and histogram display *) +module Stats = struct + let stats_negs = + QCheck.(Test.make ~count:5_000 ~name:"stats_neg" + (add_stat ("dist",fun x -> x) small_signed_int)) + (fun _ -> true) + + let stats_tests = + let open QCheck in + let dist = ("dist",fun x -> x) in + [ + Test.make ~name:"stat_display_test_1" ~count:1000 (add_stat dist small_signed_int) (fun _ -> true); + Test.make ~name:"stat_display_test_2" ~count:1000 (add_stat dist small_nat) (fun _ -> true); + Test.make ~name:"stat_display_test_3" ~count:1000 (add_stat dist (int_range (-43643) 435434)) (fun _ -> true); + Test.make ~name:"stat_display_test_4" ~count:1000 (add_stat dist (int_range (-40000) 40000)) (fun _ -> true); + Test.make ~name:"stat_display_test_5" ~count:1000 (add_stat dist (int_range (-4) 4)) (fun _ -> true); + Test.make ~name:"stat_display_test_6" ~count:1000 (add_stat dist (int_range (-4) 17)) (fun _ -> true); + Test.make ~name:"stat_display_test_7" ~count:100000 (add_stat dist int) (fun _ -> true); + Test.make ~name:"stat_display_test_8" ~count:1000 (add_stat dist (oneofl[min_int;-1;0;1;max_int])) (fun _ -> true); + ] + + let stat_display_test9 = + let open QCheck in + Test.make ~name:"stat_display_test9" ~count:1_000 + (add_stat ("dist",fun x -> x) (oneof [small_int_corners ();int])) (fun _ -> true) +end (* Calling runners *) let () = QCheck_base_runner.set_seed 1234 let i = QCheck_base_runner.run_tests ~colors:false ([ - passing; - failing; - error; - collect; - stats; - fun1; - fun2; - prop_foldleft_foldright; - prop_foldleft_foldright_uncurry; - prop_foldleft_foldright_uncurry_funlast; - long_shrink; - shrink_int; - bad_assume_warn; - bad_assume_fail; - ] @ find_ex :: find_ex_uncaught_issue_99 - @ stats_negs :: stats_tests) + Overall.passing; + Overall.failing; + Overall.error; + Overall.collect; + Overall.stats; + Overall.bad_assume_warn; + Overall.bad_assume_fail; + Function.fun1; + Function.fun2; + Function.prop_foldleft_foldright; + Function.prop_foldleft_foldright_uncurry; + Function.prop_foldleft_foldright_uncurry_funlast; + Shrink.long_shrink; + Shrink.shrink_int; + ] @ FindExample.find_ex :: FindExample.find_ex_uncaught_issue_99 + @ Stats.stats_negs :: Stats.stats_tests) let () = QCheck_base_runner.set_seed 153870556 -let _ = QCheck_base_runner.run_tests ~colors:false [stat_display_test9] +let _ = QCheck_base_runner.run_tests ~colors:false [Stats.stat_display_test9] diff --git a/test/core/qcheck2_output.txt.expected b/test/core/qcheck2_output.txt.expected index 502164af..a80943f1 100644 --- a/test/core/qcheck2_output.txt.expected +++ b/test/core/qcheck2_output.txt.expected @@ -12,7 +12,7 @@ Test should_error_raise_exn errored on (1 shrink steps): 0 -exception Dune__exe__QCheck2_expect_test.Error +exception Dune__exe__QCheck2_expect_test.Overall.Error +++ Collect ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ @@ -57,6 +57,23 @@ stats num: 110..115: ####################################################### 9 116..121: ################## 3 +!!! Warning !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +Warning for test WARN_unlikely_precond: + +WARNING: only 0.7% tests (of 2000) passed precondition for "WARN_unlikely_precond" + +NOTE: it is likely that the precondition is too strong, or that the generator is buggy. + +--- Failure -------------------------------------------------------------------- + +Test FAIL_unlikely_precond failed: + +ERROR: only 0.7% tests (of 2000) passed precondition for "FAIL_unlikely_precond" + +NOTE: it is likely that the precondition is too strong, or that the generator is buggy. + + --- Failure -------------------------------------------------------------------- Test FAIL_pred_map_commute failed (16 shrink steps): @@ -106,23 +123,6 @@ Test mod3_should_fail failed (1 shrink steps): 0 -!!! Warning !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -Warning for test WARN_unlikely_precond: - -WARNING: only 0.7% tests (of 2000) passed precondition for "WARN_unlikely_precond" - -NOTE: it is likely that the precondition is too strong, or that the generator is buggy. - ---- Failure -------------------------------------------------------------------- - -Test FAIL_unlikely_precond failed: - -ERROR: only 0.7% tests (of 2000) passed precondition for "FAIL_unlikely_precond" - -NOTE: it is likely that the precondition is too strong, or that the generator is buggy. - - --- Failure -------------------------------------------------------------------- Test FAIL_#99_1 failed: diff --git a/test/core/qcheck_output.txt.expected b/test/core/qcheck_output.txt.expected index f21ad597..bce1f16d 100644 --- a/test/core/qcheck_output.txt.expected +++ b/test/core/qcheck_output.txt.expected @@ -12,7 +12,7 @@ Test should_error_raise_exn errored on (63 shrink steps): 0 -exception Dune__exe__QCheck_expect_test.Error +exception Dune__exe__QCheck_expect_test.Overall.Error +++ Collect ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ @@ -57,6 +57,23 @@ stats num: 110..115: ####################################################### 9 116..121: ################## 3 +!!! Warning !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +Warning for test WARN_unlikely_precond: + +WARNING: only 0.5% tests (of 2000) passed precondition for "WARN_unlikely_precond" + +NOTE: it is likely that the precondition is too strong, or that the generator is buggy. + +--- Failure -------------------------------------------------------------------- + +Test FAIL_unlikely_precond failed: + +ERROR: only 0.5% tests (of 2000) passed precondition for "FAIL_unlikely_precond" + +NOTE: it is likely that the precondition is too strong, or that the generator is buggy. + + --- Failure -------------------------------------------------------------------- Test FAIL_pred_map_commute failed (127 shrink steps): @@ -106,23 +123,6 @@ Test mod3_should_fail failed (84 shrink steps): -21 -!!! Warning !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -Warning for test WARN_unlikely_precond: - -WARNING: only 0.5% tests (of 2000) passed precondition for "WARN_unlikely_precond" - -NOTE: it is likely that the precondition is too strong, or that the generator is buggy. - ---- Failure -------------------------------------------------------------------- - -Test FAIL_unlikely_precond failed: - -ERROR: only 0.5% tests (of 2000) passed precondition for "FAIL_unlikely_precond" - -NOTE: it is likely that the precondition is too strong, or that the generator is buggy. - - --- Failure -------------------------------------------------------------------- Test FAIL_#99_1 failed: From f3085df63bd3c8f7fe39a4ba0ea8bd03e50a9287 Mon Sep 17 00:00:00 2001 From: Jan Midtgaard Date: Wed, 11 Aug 2021 19:02:44 +0200 Subject: [PATCH 08/49] add tests from issue #59 --- test/core/QCheck2_expect_test.ml | 20 ++++++++++++++++++++ test/core/QCheck_expect_test.ml | 20 ++++++++++++++++++++ test/core/qcheck2_output.txt.expected | 8 +++++++- test/core/qcheck_output.txt.expected | 8 +++++++- 4 files changed, 54 insertions(+), 2 deletions(-) diff --git a/test/core/QCheck2_expect_test.ml b/test/core/QCheck2_expect_test.ml index da412988..516e05f5 100644 --- a/test/core/QCheck2_expect_test.ml +++ b/test/core/QCheck2_expect_test.ml @@ -128,6 +128,24 @@ end (* tests of shrinking behaviour *) module Shrink = struct + let rec fac n = match n with + | 0 -> 1 + | n -> n * fac (n - 1) + + (* example from issue #59 *) + let test_fac_issue59 = + let open QCheck2 in + Test.make ~name:"test fac issue59" + (Gen.make_primitive ~gen:(fun st -> Gen.generate1 ~rand:st (Gen.small_int_corners ())) ~shrink:(fun _ -> Seq.empty)) + (fun n -> try (fac n) mod n = 0 + with + (*| Stack_overflow -> false*) + | Division_by_zero -> (n=0)) + + let big_bound_issue59 = + QCheck2.Test.make ~name:"big bound issue59" ~print:QCheck2.Print.int + (QCheck2.Gen.small_int_corners()) (fun i -> i < 209609) + let long_shrink = let open QCheck2 in let listgen = Gen.(list_size (int_range 1000 10000) int) in @@ -211,6 +229,8 @@ let _ = Function.prop_foldleft_foldright; Function.prop_foldleft_foldright_uncurry; Function.prop_foldleft_foldright_uncurry_funlast; + (*Shrink.test_fac_issue59;*) + Shrink.big_bound_issue59; Shrink.long_shrink; Shrink.shrink_int; ] @ FindExample.find_ex :: FindExample.find_ex_uncaught_issue_99 diff --git a/test/core/QCheck_expect_test.ml b/test/core/QCheck_expect_test.ml index c75a93ca..b7337e27 100644 --- a/test/core/QCheck_expect_test.ml +++ b/test/core/QCheck_expect_test.ml @@ -122,6 +122,24 @@ end (* tests of shrinking behaviour *) module Shrink = struct + let rec fac n = match n with + | 0 -> 1 + | n -> n * fac (n - 1) + + (* example from issue #59 *) + let test_fac_issue59 = + let open QCheck in + Test.make ~name:"test fac issue59" + (set_shrink Shrink.nil (small_int_corners ())) + (fun n -> try (fac n) mod n = 0 + with + (*| Stack_overflow -> false*) + | Division_by_zero -> (n=0)) + + let big_bound_issue59 = + QCheck.Test.make ~name:"big bound issue59" + (QCheck.small_int_corners()) (fun i -> i < 209609) + let long_shrink = let open QCheck in let listgen = list_of_size (Gen.int_range 1000 10000) int in @@ -202,6 +220,8 @@ let i = Function.prop_foldleft_foldright; Function.prop_foldleft_foldright_uncurry; Function.prop_foldleft_foldright_uncurry_funlast; + (*Shrink.test_fac_issue59;*) + Shrink.big_bound_issue59; Shrink.long_shrink; Shrink.shrink_int; ] @ FindExample.find_ex :: FindExample.find_ex_uncaught_issue_99 diff --git a/test/core/qcheck2_output.txt.expected b/test/core/qcheck2_output.txt.expected index a80943f1..7705ca0e 100644 --- a/test/core/qcheck2_output.txt.expected +++ b/test/core/qcheck2_output.txt.expected @@ -113,6 +113,12 @@ Test fold_left fold_right uncurried fun last failed (25 shrink steps): --- Failure -------------------------------------------------------------------- +Test big bound issue59 failed (0 shrink steps): + +4611686018427387903 + +--- Failure -------------------------------------------------------------------- + Test long_shrink failed (3040 shrink steps): ([0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0;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; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 1]) @@ -347,7 +353,7 @@ stats dist: -4611686018427387392..-4150517416584648577: 0 ================================================================================ 1 warning(s) -failure (10 tests failed, 1 tests errored, ran 26 tests) +failure (11 tests failed, 1 tests errored, ran 27 tests) random seed: 153870556 +++ Stats for stat_display_test9 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ diff --git a/test/core/qcheck_output.txt.expected b/test/core/qcheck_output.txt.expected index bce1f16d..2d54be04 100644 --- a/test/core/qcheck_output.txt.expected +++ b/test/core/qcheck_output.txt.expected @@ -113,6 +113,12 @@ Test fold_left fold_right uncurried fun last failed (26 shrink steps): --- Failure -------------------------------------------------------------------- +Test big bound issue59 failed (52 shrink steps): + +209609 + +--- Failure -------------------------------------------------------------------- + Test long_shrink failed (149 shrink steps): ([0], [-1]) @@ -347,7 +353,7 @@ stats dist: -4611686018427387392..-4150517416584648577: 0 ================================================================================ 1 warning(s) -failure (10 tests failed, 1 tests errored, ran 26 tests) +failure (11 tests failed, 1 tests errored, ran 27 tests) random seed: 153870556 +++ Stats for stat_display_test9 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ From 9eb04eb3643ae6958e163d4f15480a9aa00daad8 Mon Sep 17 00:00:00 2001 From: Jan Midtgaard Date: Thu, 12 Aug 2021 08:56:18 +0200 Subject: [PATCH 09/49] add test (and char dist) from issue #23 --- test/core/QCheck2_expect_test.ml | 16 ++++++++++++- test/core/QCheck_expect_test.ml | 15 +++++++++++- test/core/qcheck2_output.txt.expected | 33 ++++++++++++++++++++++++++- test/core/qcheck_output.txt.expected | 33 ++++++++++++++++++++++++++- 4 files changed, 93 insertions(+), 4 deletions(-) diff --git a/test/core/QCheck2_expect_test.ml b/test/core/QCheck2_expect_test.ml index 516e05f5..4f42331c 100644 --- a/test/core/QCheck2_expect_test.ml +++ b/test/core/QCheck2_expect_test.ml @@ -57,6 +57,14 @@ module Overall = struct true) end +(* test various generators *) +module Generator = struct + (* example from issue #23 *) + let char_dist_issue_23 = + let open QCheck2 in + Test.make ~name:"char never produces '\\255'" ~count:1_000_000 ~print:Print.char Gen.char (fun c -> c <> '\255') +end + (* tests function generator and shrinker *) module Function = struct let fun1 = @@ -187,6 +195,11 @@ end (* tests of statistics and histogram display *) module Stats = struct + let char_dist = + QCheck2.(Test.make ~count:500_000 ~name:"char code dist" + ~stats:[("char code", Char.code)] Gen.char) + (fun _ -> true) + let stats_negs = QCheck2.(Test.make ~count:5_000 ~name:"stats_neg" ~stats:[("dist",fun x -> x)] Gen.small_signed_int) @@ -224,6 +237,7 @@ let _ = Overall.stats; Overall.bad_assume_warn; Overall.bad_assume_fail; + Generator.char_dist_issue_23; Function.fun1; Function.fun2; Function.prop_foldleft_foldright; @@ -234,7 +248,7 @@ let _ = Shrink.long_shrink; Shrink.shrink_int; ] @ FindExample.find_ex :: FindExample.find_ex_uncaught_issue_99 - @ Stats.stats_negs :: Stats.stats_tests) + @ [Stats.char_dist; Stats.stats_negs] @ Stats.stats_tests) let () = QCheck_base_runner.set_seed 153870556 let _ = QCheck_base_runner.run_tests ~colors:false [Stats.stat_display_test9] diff --git a/test/core/QCheck_expect_test.ml b/test/core/QCheck_expect_test.ml index b7337e27..70c27ac7 100644 --- a/test/core/QCheck_expect_test.ml +++ b/test/core/QCheck_expect_test.ml @@ -56,6 +56,13 @@ module Overall = struct true) end +(* test various generators *) +module Generator = struct + (* example from issue #23 *) + let char_dist_issue_23 = + QCheck.Test.make ~name:"char never produces '\\255'" ~count:1_000_000 QCheck.char (fun c -> c <> '\255') +end + (* tests function generator and shrinker *) module Function = struct let fun1 = @@ -178,6 +185,11 @@ end (* tests of statistics and histogram display *) module Stats = struct + let char_dist = + QCheck.(Test.make ~count:500_000 ~name:"char code dist" + (add_stat ("char code", Char.code) char)) + (fun _ -> true) + let stats_negs = QCheck.(Test.make ~count:5_000 ~name:"stats_neg" (add_stat ("dist",fun x -> x) small_signed_int)) @@ -215,6 +227,7 @@ let i = Overall.stats; Overall.bad_assume_warn; Overall.bad_assume_fail; + Generator.char_dist_issue_23; Function.fun1; Function.fun2; Function.prop_foldleft_foldright; @@ -225,7 +238,7 @@ let i = Shrink.long_shrink; Shrink.shrink_int; ] @ FindExample.find_ex :: FindExample.find_ex_uncaught_issue_99 - @ Stats.stats_negs :: Stats.stats_tests) + @ [Stats.char_dist; Stats.stats_negs] @ Stats.stats_tests) let () = QCheck_base_runner.set_seed 153870556 let _ = QCheck_base_runner.run_tests ~colors:false [Stats.stat_display_test9] diff --git a/test/core/qcheck2_output.txt.expected b/test/core/qcheck2_output.txt.expected index 7705ca0e..a27bd75a 100644 --- a/test/core/qcheck2_output.txt.expected +++ b/test/core/qcheck2_output.txt.expected @@ -74,6 +74,12 @@ ERROR: only 0.7% tests (of 2000) passed precondition for "FAIL_unlikely_precond" NOTE: it is likely that the precondition is too strong, or that the generator is buggy. +--- Failure -------------------------------------------------------------------- + +Test char never produces '\255' failed (0 shrink steps): + +'\255' + --- Failure -------------------------------------------------------------------- Test FAIL_pred_map_commute failed (16 shrink steps): @@ -137,6 +143,31 @@ ERROR: uncaught exception in generator for test FAIL_#99_1 after 100 steps: Exception: QCheck2.No_example_found("") Backtrace: ++++ Stats for char code dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats char code: + num: 500000, avg: 127.42, stddev: 73.92, median 127, min 0, max 255 + 0.. 12: ###################################################### 25509 + 13.. 25: ###################################################### 25398 + 26.. 38: ###################################################### 25293 + 39.. 51: ###################################################### 25448 + 52.. 64: ###################################################### 25392 + 65.. 77: ####################################################### 25660 + 78.. 90: ###################################################### 25462 + 91..103: ###################################################### 25331 + 104..116: ##################################################### 25129 + 117..129: ###################################################### 25351 + 130..142: ###################################################### 25492 + 143..155: ###################################################### 25370 + 156..168: ###################################################### 25658 + 169..181: ###################################################### 25400 + 182..194: ##################################################### 25167 + 195..207: ###################################################### 25338 + 208..220: ##################################################### 25181 + 221..233: ##################################################### 25145 + 234..246: ###################################################### 25567 + 247..259: ##################################### 17709 + +++ Stats for stats_neg ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: @@ -353,7 +384,7 @@ stats dist: -4611686018427387392..-4150517416584648577: 0 ================================================================================ 1 warning(s) -failure (11 tests failed, 1 tests errored, ran 27 tests) +failure (12 tests failed, 1 tests errored, ran 29 tests) random seed: 153870556 +++ Stats for stat_display_test9 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ diff --git a/test/core/qcheck_output.txt.expected b/test/core/qcheck_output.txt.expected index 2d54be04..ab889376 100644 --- a/test/core/qcheck_output.txt.expected +++ b/test/core/qcheck_output.txt.expected @@ -74,6 +74,12 @@ ERROR: only 0.5% tests (of 2000) passed precondition for "FAIL_unlikely_precond" NOTE: it is likely that the precondition is too strong, or that the generator is buggy. +--- Failure -------------------------------------------------------------------- + +Test char never produces '\255' failed (0 shrink steps): + +'\255' + --- Failure -------------------------------------------------------------------- Test FAIL_pred_map_commute failed (127 shrink steps): @@ -137,6 +143,31 @@ ERROR: uncaught exception in generator for test FAIL_#99_1 after 100 steps: Exception: QCheck.No_example_found("") Backtrace: ++++ Stats for char code dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats char code: + num: 500000, avg: 127.42, stddev: 73.92, median 127, min 0, max 255 + 0.. 12: ###################################################### 25509 + 13.. 25: ###################################################### 25398 + 26.. 38: ###################################################### 25293 + 39.. 51: ###################################################### 25448 + 52.. 64: ###################################################### 25392 + 65.. 77: ####################################################### 25660 + 78.. 90: ###################################################### 25462 + 91..103: ###################################################### 25331 + 104..116: ##################################################### 25129 + 117..129: ###################################################### 25351 + 130..142: ###################################################### 25492 + 143..155: ###################################################### 25370 + 156..168: ###################################################### 25658 + 169..181: ###################################################### 25400 + 182..194: ##################################################### 25167 + 195..207: ###################################################### 25338 + 208..220: ##################################################### 25181 + 221..233: ##################################################### 25145 + 234..246: ###################################################### 25567 + 247..259: ##################################### 17709 + +++ Stats for stats_neg ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: @@ -353,7 +384,7 @@ stats dist: -4611686018427387392..-4150517416584648577: 0 ================================================================================ 1 warning(s) -failure (11 tests failed, 1 tests errored, ran 27 tests) +failure (12 tests failed, 1 tests errored, ran 29 tests) random seed: 153870556 +++ Stats for stat_display_test9 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ From 0cd4f578c6df1fa10759e9a11d615ce1a8ae88e5 Mon Sep 17 00:00:00 2001 From: Jan Midtgaard Date: Thu, 12 Aug 2021 09:02:13 +0200 Subject: [PATCH 10/49] rename to *int_*stat tests --- test/core/QCheck2_expect_test.ml | 30 +++++++++++++-------------- test/core/QCheck_expect_test.ml | 30 +++++++++++++-------------- test/core/qcheck2_output.txt.expected | 20 +++++++++--------- test/core/qcheck_output.txt.expected | 20 +++++++++--------- 4 files changed, 50 insertions(+), 50 deletions(-) diff --git a/test/core/QCheck2_expect_test.ml b/test/core/QCheck2_expect_test.ml index 4f42331c..c978156a 100644 --- a/test/core/QCheck2_expect_test.ml +++ b/test/core/QCheck2_expect_test.ml @@ -200,28 +200,28 @@ module Stats = struct ~stats:[("char code", Char.code)] Gen.char) (fun _ -> true) - let stats_negs = - QCheck2.(Test.make ~count:5_000 ~name:"stats_neg" + let int_stats_neg = + QCheck2.(Test.make ~count:5_000 ~name:"int_stats_neg" ~stats:[("dist",fun x -> x)] Gen.small_signed_int) (fun _ -> true) - let stats_tests = + let int_stats_tests = let open QCheck2 in let dist = ("dist",fun x -> x) in [ - Test.make ~name:"stat_display_test_1" ~count:1000 ~stats:[dist] Gen.small_signed_int (fun _ -> true); - Test.make ~name:"stat_display_test_2" ~count:1000 ~stats:[dist] Gen.small_nat (fun _ -> true); - Test.make ~name:"stat_display_test_3" ~count:1000 ~stats:[dist] (Gen.int_range (-43643) 435434) (fun _ -> true); - Test.make ~name:"stat_display_test_4" ~count:1000 ~stats:[dist] (Gen.int_range (-40000) 40000) (fun _ -> true); - Test.make ~name:"stat_display_test_5" ~count:1000 ~stats:[dist] (Gen.int_range (-4) 4) (fun _ -> true); - Test.make ~name:"stat_display_test_6" ~count:1000 ~stats:[dist] (Gen.int_range (-4) 17) (fun _ -> true); - Test.make ~name:"stat_display_test_7" ~count:100000 ~stats:[dist] Gen.int (fun _ -> true); - Test.make ~name:"stat_display_test_8" ~count:1000 ~stats:[dist] (Gen.oneofl[min_int;-1;0;1;max_int]) (fun _ -> true); + Test.make ~name:"int_stat_display_test_1" ~count:1000 ~stats:[dist] Gen.small_signed_int (fun _ -> true); + Test.make ~name:"int_stat_display_test_2" ~count:1000 ~stats:[dist] Gen.small_nat (fun _ -> true); + Test.make ~name:"int_stat_display_test_3" ~count:1000 ~stats:[dist] (Gen.int_range (-43643) 435434) (fun _ -> true); + Test.make ~name:"int_stat_display_test_4" ~count:1000 ~stats:[dist] (Gen.int_range (-40000) 40000) (fun _ -> true); + Test.make ~name:"int_stat_display_test_5" ~count:1000 ~stats:[dist] (Gen.int_range (-4) 4) (fun _ -> true); + Test.make ~name:"int_stat_display_test_6" ~count:1000 ~stats:[dist] (Gen.int_range (-4) 17) (fun _ -> true); + Test.make ~name:"int_stat_display_test_7" ~count:100000 ~stats:[dist] Gen.int (fun _ -> true); + Test.make ~name:"int_stat_display_test_8" ~count:1000 ~stats:[dist] (Gen.oneofl[min_int;-1;0;1;max_int]) (fun _ -> true); ] - let stat_display_test9 = + let int_stat_display_test9 = let open QCheck2 in - Test.make ~name:"stat_display_test9" ~count:1_000 + Test.make ~name:"int_stat_display_test9" ~count:1_000 ~stats:[("dist",fun x -> x)] Gen.(oneof [small_int_corners ();int]) (fun _ -> true) end @@ -248,8 +248,8 @@ let _ = Shrink.long_shrink; Shrink.shrink_int; ] @ FindExample.find_ex :: FindExample.find_ex_uncaught_issue_99 - @ [Stats.char_dist; Stats.stats_negs] @ Stats.stats_tests) + @ [Stats.char_dist; Stats.int_stats_neg] @ Stats.int_stats_tests) let () = QCheck_base_runner.set_seed 153870556 -let _ = QCheck_base_runner.run_tests ~colors:false [Stats.stat_display_test9] +let _ = QCheck_base_runner.run_tests ~colors:false [Stats.int_stat_display_test9] diff --git a/test/core/QCheck_expect_test.ml b/test/core/QCheck_expect_test.ml index 70c27ac7..4438c543 100644 --- a/test/core/QCheck_expect_test.ml +++ b/test/core/QCheck_expect_test.ml @@ -190,28 +190,28 @@ module Stats = struct (add_stat ("char code", Char.code) char)) (fun _ -> true) - let stats_negs = - QCheck.(Test.make ~count:5_000 ~name:"stats_neg" + let int_stats_neg = + QCheck.(Test.make ~count:5_000 ~name:"int_stats_neg" (add_stat ("dist",fun x -> x) small_signed_int)) (fun _ -> true) - let stats_tests = + let int_stats_tests = let open QCheck in let dist = ("dist",fun x -> x) in [ - Test.make ~name:"stat_display_test_1" ~count:1000 (add_stat dist small_signed_int) (fun _ -> true); - Test.make ~name:"stat_display_test_2" ~count:1000 (add_stat dist small_nat) (fun _ -> true); - Test.make ~name:"stat_display_test_3" ~count:1000 (add_stat dist (int_range (-43643) 435434)) (fun _ -> true); - Test.make ~name:"stat_display_test_4" ~count:1000 (add_stat dist (int_range (-40000) 40000)) (fun _ -> true); - Test.make ~name:"stat_display_test_5" ~count:1000 (add_stat dist (int_range (-4) 4)) (fun _ -> true); - Test.make ~name:"stat_display_test_6" ~count:1000 (add_stat dist (int_range (-4) 17)) (fun _ -> true); - Test.make ~name:"stat_display_test_7" ~count:100000 (add_stat dist int) (fun _ -> true); - Test.make ~name:"stat_display_test_8" ~count:1000 (add_stat dist (oneofl[min_int;-1;0;1;max_int])) (fun _ -> true); + Test.make ~name:"int_stat_display_test_1" ~count:1000 (add_stat dist small_signed_int) (fun _ -> true); + Test.make ~name:"int_stat_display_test_2" ~count:1000 (add_stat dist small_nat) (fun _ -> true); + Test.make ~name:"int_stat_display_test_3" ~count:1000 (add_stat dist (int_range (-43643) 435434)) (fun _ -> true); + Test.make ~name:"int_stat_display_test_4" ~count:1000 (add_stat dist (int_range (-40000) 40000)) (fun _ -> true); + Test.make ~name:"int_stat_display_test_5" ~count:1000 (add_stat dist (int_range (-4) 4)) (fun _ -> true); + Test.make ~name:"int_stat_display_test_6" ~count:1000 (add_stat dist (int_range (-4) 17)) (fun _ -> true); + Test.make ~name:"int_stat_display_test_7" ~count:100000 (add_stat dist int) (fun _ -> true); + Test.make ~name:"int_stat_display_test_8" ~count:1000 (add_stat dist (oneofl[min_int;-1;0;1;max_int])) (fun _ -> true); ] - let stat_display_test9 = + let int_stat_display_test9 = let open QCheck in - Test.make ~name:"stat_display_test9" ~count:1_000 + Test.make ~name:"int_stat_display_test9" ~count:1_000 (add_stat ("dist",fun x -> x) (oneof [small_int_corners ();int])) (fun _ -> true) end @@ -238,7 +238,7 @@ let i = Shrink.long_shrink; Shrink.shrink_int; ] @ FindExample.find_ex :: FindExample.find_ex_uncaught_issue_99 - @ [Stats.char_dist; Stats.stats_negs] @ Stats.stats_tests) + @ [Stats.char_dist; Stats.int_stats_neg] @ Stats.int_stats_tests) let () = QCheck_base_runner.set_seed 153870556 -let _ = QCheck_base_runner.run_tests ~colors:false [Stats.stat_display_test9] +let _ = QCheck_base_runner.run_tests ~colors:false [Stats.int_stat_display_test9] diff --git a/test/core/qcheck2_output.txt.expected b/test/core/qcheck2_output.txt.expected index a27bd75a..83bad7c6 100644 --- a/test/core/qcheck2_output.txt.expected +++ b/test/core/qcheck2_output.txt.expected @@ -168,7 +168,7 @@ stats char code: 234..246: ###################################################### 25567 247..259: ##################################### 17709 -+++ Stats for stats_neg ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++ Stats for int_stats_neg ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 5000, avg: 0.17, stddev: 29.68, median 0, min -99, max 99 @@ -193,7 +193,7 @@ stats dist: 81.. 90: # 60 91..100: # 66 -+++ Stats for stat_display_test_1 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++ Stats for int_stat_display_test_1 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 0.90, stddev: 28.23, median 0, min -99, max 99 @@ -218,7 +218,7 @@ stats dist: 81.. 90: # 16 91..100: # 10 -+++ Stats for stat_display_test_2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++ Stats for int_stat_display_test_2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 15.11, stddev: 23.27, median 6, min 0, max 99 @@ -243,7 +243,7 @@ stats dist: 90.. 94: 5 95.. 99: # 10 -+++ Stats for stat_display_test_3 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++ Stats for int_stat_display_test_3 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 195335.64, stddev: 136803.99, median 195583, min -43624, max 435210 @@ -268,7 +268,7 @@ stats dist: 387332..411273: ########################################## 49 411274..435215: ########################################### 51 -+++ Stats for stat_display_test_4 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++ Stats for int_stat_display_test_4 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: -173.78, stddev: 23042.92, median 180, min -39859, max 39942 @@ -293,7 +293,7 @@ stats dist: 31979.. 35969: ######################################### 51 35970.. 39960: #################################### 45 -+++ Stats for stat_display_test_5 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++ Stats for int_stat_display_test_5 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 0.02, stddev: 2.55, median 0, min -4, max 4 @@ -307,7 +307,7 @@ stats dist: 3: ####################################################### 122 4: ############################################## 104 -+++ Stats for stat_display_test_6 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++ Stats for int_stat_display_test_6 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 6.67, stddev: 6.39, median 7, min -4, max 17 @@ -332,7 +332,7 @@ stats dist: 32..33: 0 34..35: 0 -+++ Stats for stat_display_test_7 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++ Stats for int_stat_display_test_7 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 100000, avg: 6126662802445055.00, stddev: 2661484817981980672.00, median 158655556399988, min -4611578348806740501, max 4611677827646819817 @@ -357,7 +357,7 @@ stats dist: 3689352210001463787.. 4150515018824141802: ###################################################### 5048 4150515018824141803.. 4611677827646819818: ###################################################### 5063 -+++ Stats for stat_display_test_8 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++ Stats for int_stat_display_test_8 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 4611686018427388.00, stddev: 2905870896563567616.00, median 0, min -4611686018427387904, max 4611686018427387903 @@ -387,7 +387,7 @@ stats dist: failure (12 tests failed, 1 tests errored, ran 29 tests) random seed: 153870556 -+++ Stats for stat_display_test9 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++ Stats for int_stat_display_test9 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: -10119269408092442.00, stddev: 1871251663919905536.00, median 9, min -4576142151952919207, max 4611686018427387903 diff --git a/test/core/qcheck_output.txt.expected b/test/core/qcheck_output.txt.expected index ab889376..07c7e0d9 100644 --- a/test/core/qcheck_output.txt.expected +++ b/test/core/qcheck_output.txt.expected @@ -168,7 +168,7 @@ stats char code: 234..246: ###################################################### 25567 247..259: ##################################### 17709 -+++ Stats for stats_neg ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++ Stats for int_stats_neg ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 5000, avg: 0.17, stddev: 29.68, median 0, min -99, max 99 @@ -193,7 +193,7 @@ stats dist: 81.. 90: # 60 91..100: # 66 -+++ Stats for stat_display_test_1 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++ Stats for int_stat_display_test_1 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 0.90, stddev: 28.23, median 0, min -99, max 99 @@ -218,7 +218,7 @@ stats dist: 81.. 90: # 16 91..100: # 10 -+++ Stats for stat_display_test_2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++ Stats for int_stat_display_test_2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 15.11, stddev: 23.27, median 6, min 0, max 99 @@ -243,7 +243,7 @@ stats dist: 90.. 94: 5 95.. 99: # 10 -+++ Stats for stat_display_test_3 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++ Stats for int_stat_display_test_3 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 195335.64, stddev: 136803.99, median 195583, min -43624, max 435210 @@ -268,7 +268,7 @@ stats dist: 387332..411273: ########################################## 49 411274..435215: ########################################### 51 -+++ Stats for stat_display_test_4 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++ Stats for int_stat_display_test_4 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: -173.78, stddev: 23042.92, median 180, min -39859, max 39942 @@ -293,7 +293,7 @@ stats dist: 31979.. 35969: ######################################### 51 35970.. 39960: #################################### 45 -+++ Stats for stat_display_test_5 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++ Stats for int_stat_display_test_5 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 0.02, stddev: 2.55, median 0, min -4, max 4 @@ -307,7 +307,7 @@ stats dist: 3: ####################################################### 122 4: ############################################## 104 -+++ Stats for stat_display_test_6 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++ Stats for int_stat_display_test_6 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 6.67, stddev: 6.39, median 7, min -4, max 17 @@ -332,7 +332,7 @@ stats dist: 32..33: 0 34..35: 0 -+++ Stats for stat_display_test_7 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++ Stats for int_stat_display_test_7 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 100000, avg: 2541076923587387.50, stddev: 2660730801206827008.00, median 158655268318060, min -4611522359435274428, max 4611540922436307689 @@ -357,7 +357,7 @@ stats dist: 3689234594249150020.. 4150387758342729155: ##################################################### 4982 4150387758342729156.. 4611540922436308291: ###################################################### 5039 -+++ Stats for stat_display_test_8 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++ Stats for int_stat_display_test_8 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 4611686018427388.00, stddev: 2905870896563567616.00, median 0, min -4611686018427387904, max 4611686018427387903 @@ -387,7 +387,7 @@ stats dist: failure (12 tests failed, 1 tests errored, ran 29 tests) random seed: 153870556 -+++ Stats for stat_display_test9 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++ Stats for int_stat_display_test9 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: -55083208105414400.00, stddev: 1847115855773139200.00, median 9, min -4590718933436425025, max 4611686018427387903 From 141d8ac24a49e2c917f13d3fffbd569eeb915eed Mon Sep 17 00:00:00 2001 From: Jan Midtgaard Date: Thu, 12 Aug 2021 09:17:21 +0200 Subject: [PATCH 11/49] comment tests with issue/PR --- test/core/QCheck2_expect_test.ml | 2 ++ test/core/QCheck_expect_test.ml | 2 ++ 2 files changed, 4 insertions(+) diff --git a/test/core/QCheck2_expect_test.ml b/test/core/QCheck2_expect_test.ml index c978156a..8c7a97c4 100644 --- a/test/core/QCheck2_expect_test.ml +++ b/test/core/QCheck2_expect_test.ml @@ -200,11 +200,13 @@ module Stats = struct ~stats:[("char code", Char.code)] Gen.char) (fun _ -> true) + (* test from issue #40 *) let int_stats_neg = QCheck2.(Test.make ~count:5_000 ~name:"int_stats_neg" ~stats:[("dist",fun x -> x)] Gen.small_signed_int) (fun _ -> true) + (* distribution tests from PR #45 *) let int_stats_tests = let open QCheck2 in let dist = ("dist",fun x -> x) in diff --git a/test/core/QCheck_expect_test.ml b/test/core/QCheck_expect_test.ml index 4438c543..398c8b9c 100644 --- a/test/core/QCheck_expect_test.ml +++ b/test/core/QCheck_expect_test.ml @@ -190,11 +190,13 @@ module Stats = struct (add_stat ("char code", Char.code) char)) (fun _ -> true) + (* test from issue #40 *) let int_stats_neg = QCheck.(Test.make ~count:5_000 ~name:"int_stats_neg" (add_stat ("dist",fun x -> x) small_signed_int)) (fun _ -> true) + (* distribution tests from PR #45 *) let int_stats_tests = let open QCheck in let dist = ("dist",fun x -> x) in From a7fe5466f1d1e7ae9896740fac4cbb5af6231f05 Mon Sep 17 00:00:00 2001 From: Jan Midtgaard Date: Thu, 12 Aug 2021 09:25:33 +0200 Subject: [PATCH 12/49] add bool dist test --- test/core/QCheck2_expect_test.ml | 9 ++++++--- test/core/QCheck_expect_test.ml | 12 +++++++----- test/core/qcheck2_output.txt.expected | 9 ++++++++- test/core/qcheck_output.txt.expected | 9 ++++++++- 4 files changed, 29 insertions(+), 10 deletions(-) diff --git a/test/core/QCheck2_expect_test.ml b/test/core/QCheck2_expect_test.ml index 8c7a97c4..190f0f16 100644 --- a/test/core/QCheck2_expect_test.ml +++ b/test/core/QCheck2_expect_test.ml @@ -195,10 +195,13 @@ end (* tests of statistics and histogram display *) module Stats = struct + let bool_dist = + QCheck2.(Test.make ~count:500_000 ~name:"bool dist" + ~collect:Bool.to_string Gen.bool) (fun _ -> true) + let char_dist = QCheck2.(Test.make ~count:500_000 ~name:"char code dist" - ~stats:[("char code", Char.code)] Gen.char) - (fun _ -> true) + ~stats:[("char code", Char.code)] Gen.char) (fun _ -> true) (* test from issue #40 *) let int_stats_neg = @@ -250,7 +253,7 @@ let _ = Shrink.long_shrink; Shrink.shrink_int; ] @ FindExample.find_ex :: FindExample.find_ex_uncaught_issue_99 - @ [Stats.char_dist; Stats.int_stats_neg] @ Stats.int_stats_tests) + @ [Stats.bool_dist; Stats.char_dist; Stats.int_stats_neg] @ Stats.int_stats_tests) let () = QCheck_base_runner.set_seed 153870556 let _ = QCheck_base_runner.run_tests ~colors:false [Stats.int_stat_display_test9] diff --git a/test/core/QCheck_expect_test.ml b/test/core/QCheck_expect_test.ml index 398c8b9c..46563916 100644 --- a/test/core/QCheck_expect_test.ml +++ b/test/core/QCheck_expect_test.ml @@ -185,16 +185,18 @@ end (* tests of statistics and histogram display *) module Stats = struct + let bool_dist = + QCheck.(Test.make ~count:500_000 ~name:"bool dist" + (set_collect Bool.to_string bool)) (fun _ -> true) + let char_dist = QCheck.(Test.make ~count:500_000 ~name:"char code dist" - (add_stat ("char code", Char.code) char)) - (fun _ -> true) + (add_stat ("char code", Char.code) char)) (fun _ -> true) (* test from issue #40 *) let int_stats_neg = QCheck.(Test.make ~count:5_000 ~name:"int_stats_neg" - (add_stat ("dist",fun x -> x) small_signed_int)) - (fun _ -> true) + (add_stat ("dist",fun x -> x) small_signed_int)) (fun _ -> true) (* distribution tests from PR #45 *) let int_stats_tests = @@ -240,7 +242,7 @@ let i = Shrink.long_shrink; Shrink.shrink_int; ] @ FindExample.find_ex :: FindExample.find_ex_uncaught_issue_99 - @ [Stats.char_dist; Stats.int_stats_neg] @ Stats.int_stats_tests) + @ [Stats.bool_dist; Stats.char_dist; Stats.int_stats_neg] @ Stats.int_stats_tests) let () = QCheck_base_runner.set_seed 153870556 let _ = QCheck_base_runner.run_tests ~colors:false [Stats.int_stat_display_test9] diff --git a/test/core/qcheck2_output.txt.expected b/test/core/qcheck2_output.txt.expected index 83bad7c6..ef02359f 100644 --- a/test/core/qcheck2_output.txt.expected +++ b/test/core/qcheck2_output.txt.expected @@ -143,6 +143,13 @@ ERROR: uncaught exception in generator for test FAIL_#99_1 after 100 steps: Exception: QCheck2.No_example_found("") Backtrace: ++++ Collect ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +Collect results for test bool dist: + +true: 250134 cases +false: 249866 cases + +++ Stats for char code dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats char code: @@ -384,7 +391,7 @@ stats dist: -4611686018427387392..-4150517416584648577: 0 ================================================================================ 1 warning(s) -failure (12 tests failed, 1 tests errored, ran 29 tests) +failure (12 tests failed, 1 tests errored, ran 30 tests) random seed: 153870556 +++ Stats for int_stat_display_test9 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ diff --git a/test/core/qcheck_output.txt.expected b/test/core/qcheck_output.txt.expected index 07c7e0d9..2daaccd3 100644 --- a/test/core/qcheck_output.txt.expected +++ b/test/core/qcheck_output.txt.expected @@ -143,6 +143,13 @@ ERROR: uncaught exception in generator for test FAIL_#99_1 after 100 steps: Exception: QCheck.No_example_found("") Backtrace: ++++ Collect ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +Collect results for test bool dist: + +true: 250134 cases +false: 249866 cases + +++ Stats for char code dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats char code: @@ -384,7 +391,7 @@ stats dist: -4611686018427387392..-4150517416584648577: 0 ================================================================================ 1 warning(s) -failure (12 tests failed, 1 tests errored, ran 29 tests) +failure (12 tests failed, 1 tests errored, ran 30 tests) random seed: 153870556 +++ Stats for int_stat_display_test9 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ From 9e223d110d7e54ee1d8f58a140c00bf589b06afc Mon Sep 17 00:00:00 2001 From: Jan Midtgaard Date: Thu, 12 Aug 2021 09:37:03 +0200 Subject: [PATCH 13/49] add list dist test --- test/core/QCheck2_expect_test.ml | 11 ++++++++++- test/core/QCheck_expect_test.ml | 11 ++++++++++- test/core/qcheck2_output.txt.expected | 27 ++++++++++++++++++++++++++- test/core/qcheck_output.txt.expected | 27 ++++++++++++++++++++++++++- 4 files changed, 72 insertions(+), 4 deletions(-) diff --git a/test/core/QCheck2_expect_test.ml b/test/core/QCheck2_expect_test.ml index 190f0f16..2c7fa448 100644 --- a/test/core/QCheck2_expect_test.ml +++ b/test/core/QCheck2_expect_test.ml @@ -203,6 +203,11 @@ module Stats = struct QCheck2.(Test.make ~count:500_000 ~name:"char code dist" ~stats:[("char code", Char.code)] Gen.char) (fun _ -> true) + (* test from issue #30 *) + let list_size_dist = + QCheck2.(Test.make ~count:5_000 ~name:"list size dist" + ~stats:[("len",List.length)] Gen.(list int)) (fun _ -> true) + (* test from issue #40 *) let int_stats_neg = QCheck2.(Test.make ~count:5_000 ~name:"int_stats_neg" @@ -253,7 +258,11 @@ let _ = Shrink.long_shrink; Shrink.shrink_int; ] @ FindExample.find_ex :: FindExample.find_ex_uncaught_issue_99 - @ [Stats.bool_dist; Stats.char_dist; Stats.int_stats_neg] @ Stats.int_stats_tests) + @ [Stats.bool_dist; + Stats.char_dist; + Stats.list_size_dist; + Stats.int_stats_neg] + @ Stats.int_stats_tests) let () = QCheck_base_runner.set_seed 153870556 let _ = QCheck_base_runner.run_tests ~colors:false [Stats.int_stat_display_test9] diff --git a/test/core/QCheck_expect_test.ml b/test/core/QCheck_expect_test.ml index 46563916..9f5f9ee9 100644 --- a/test/core/QCheck_expect_test.ml +++ b/test/core/QCheck_expect_test.ml @@ -193,6 +193,11 @@ module Stats = struct QCheck.(Test.make ~count:500_000 ~name:"char code dist" (add_stat ("char code", Char.code) char)) (fun _ -> true) + (* test from issue #30 *) + let list_size_dist = + QCheck.(Test.make ~count:5_000 ~name:"list size dist" + (add_stat ("len",List.length) (list int))) (fun _ -> true) + (* test from issue #40 *) let int_stats_neg = QCheck.(Test.make ~count:5_000 ~name:"int_stats_neg" @@ -242,7 +247,11 @@ let i = Shrink.long_shrink; Shrink.shrink_int; ] @ FindExample.find_ex :: FindExample.find_ex_uncaught_issue_99 - @ [Stats.bool_dist; Stats.char_dist; Stats.int_stats_neg] @ Stats.int_stats_tests) + @ [Stats.bool_dist; + Stats.char_dist; + Stats.list_size_dist; + Stats.int_stats_neg] + @ Stats.int_stats_tests) let () = QCheck_base_runner.set_seed 153870556 let _ = QCheck_base_runner.run_tests ~colors:false [Stats.int_stat_display_test9] diff --git a/test/core/qcheck2_output.txt.expected b/test/core/qcheck2_output.txt.expected index ef02359f..9cba6d91 100644 --- a/test/core/qcheck2_output.txt.expected +++ b/test/core/qcheck2_output.txt.expected @@ -175,6 +175,31 @@ stats char code: 234..246: ###################################################### 25567 247..259: ##################################### 17709 ++++ Stats for list size dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats len: + num: 5000, avg: 400.16, stddev: 1371.90, median 9, min 0, max 9987 + 0.. 499: ####################################################### 4246 + 500.. 999: ###### 502 + 1000.. 1499: 13 + 1500.. 1999: 10 + 2000.. 2499: 14 + 2500.. 2999: 14 + 3000.. 3499: 20 + 3500.. 3999: 7 + 4000.. 4499: 13 + 4500.. 4999: 16 + 5000.. 5499: 12 + 5500.. 5999: 15 + 6000.. 6499: 15 + 6500.. 6999: 13 + 7000.. 7499: 16 + 7500.. 7999: 12 + 8000.. 8499: 11 + 8500.. 8999: 16 + 9000.. 9499: 15 + 9500.. 9999: 20 + +++ Stats for int_stats_neg ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: @@ -391,7 +416,7 @@ stats dist: -4611686018427387392..-4150517416584648577: 0 ================================================================================ 1 warning(s) -failure (12 tests failed, 1 tests errored, ran 30 tests) +failure (12 tests failed, 1 tests errored, ran 31 tests) random seed: 153870556 +++ Stats for int_stat_display_test9 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ diff --git a/test/core/qcheck_output.txt.expected b/test/core/qcheck_output.txt.expected index 2daaccd3..4fab766a 100644 --- a/test/core/qcheck_output.txt.expected +++ b/test/core/qcheck_output.txt.expected @@ -175,6 +175,31 @@ stats char code: 234..246: ###################################################### 25567 247..259: ##################################### 17709 ++++ Stats for list size dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats len: + num: 5000, avg: 400.16, stddev: 1371.90, median 9, min 0, max 9987 + 0.. 499: ####################################################### 4246 + 500.. 999: ###### 502 + 1000.. 1499: 13 + 1500.. 1999: 10 + 2000.. 2499: 14 + 2500.. 2999: 14 + 3000.. 3499: 20 + 3500.. 3999: 7 + 4000.. 4499: 13 + 4500.. 4999: 16 + 5000.. 5499: 12 + 5500.. 5999: 15 + 6000.. 6499: 15 + 6500.. 6999: 13 + 7000.. 7499: 16 + 7500.. 7999: 12 + 8000.. 8499: 11 + 8500.. 8999: 16 + 9000.. 9499: 15 + 9500.. 9999: 20 + +++ Stats for int_stats_neg ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: @@ -391,7 +416,7 @@ stats dist: -4611686018427387392..-4150517416584648577: 0 ================================================================================ 1 warning(s) -failure (12 tests failed, 1 tests errored, ran 30 tests) +failure (12 tests failed, 1 tests errored, ran 31 tests) random seed: 153870556 +++ Stats for int_stat_display_test9 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ From 594b6ae7ef22421072f982564f7fbb94d2f8f3b8 Mon Sep 17 00:00:00 2001 From: Jan Midtgaard Date: Thu, 12 Aug 2021 09:50:10 +0200 Subject: [PATCH 14/49] add small_list+list_(of_)size test --- test/core/QCheck2_expect_test.ml | 16 +++++++++-- test/core/QCheck_expect_test.ml | 16 +++++++++-- test/core/qcheck2_output.txt.expected | 40 +++++++++++++++++++++++++-- test/core/qcheck_output.txt.expected | 40 +++++++++++++++++++++++++-- 4 files changed, 102 insertions(+), 10 deletions(-) diff --git a/test/core/QCheck2_expect_test.ml b/test/core/QCheck2_expect_test.ml index 2c7fa448..21ecd363 100644 --- a/test/core/QCheck2_expect_test.ml +++ b/test/core/QCheck2_expect_test.ml @@ -204,10 +204,18 @@ module Stats = struct ~stats:[("char code", Char.code)] Gen.char) (fun _ -> true) (* test from issue #30 *) - let list_size_dist = - QCheck2.(Test.make ~count:5_000 ~name:"list size dist" + let list_len_dist = + QCheck2.(Test.make ~count:5_000 ~name:"list len dist" ~stats:[("len",List.length)] Gen.(list int)) (fun _ -> true) + let small_list_len_dist = + QCheck2.(Test.make ~count:5_000 ~name:"small_list len dist" + ~stats:[("len",List.length)] Gen.(small_list int)) (fun _ -> true) + + let list_size_len_dist = + QCheck2.(Test.make ~count:5_000 ~name:"list_size len dist" + ~stats:[("len",List.length)] Gen.(list_size (int_range 5 10) int)) (fun _ -> true) + (* test from issue #40 *) let int_stats_neg = QCheck2.(Test.make ~count:5_000 ~name:"int_stats_neg" @@ -260,7 +268,9 @@ let _ = ] @ FindExample.find_ex :: FindExample.find_ex_uncaught_issue_99 @ [Stats.bool_dist; Stats.char_dist; - Stats.list_size_dist; + Stats.list_len_dist; + Stats.small_list_len_dist; + Stats.list_size_len_dist; Stats.int_stats_neg] @ Stats.int_stats_tests) diff --git a/test/core/QCheck_expect_test.ml b/test/core/QCheck_expect_test.ml index 9f5f9ee9..305066e4 100644 --- a/test/core/QCheck_expect_test.ml +++ b/test/core/QCheck_expect_test.ml @@ -194,10 +194,18 @@ module Stats = struct (add_stat ("char code", Char.code) char)) (fun _ -> true) (* test from issue #30 *) - let list_size_dist = - QCheck.(Test.make ~count:5_000 ~name:"list size dist" + let list_len_dist = + QCheck.(Test.make ~count:5_000 ~name:"list len dist" (add_stat ("len",List.length) (list int))) (fun _ -> true) + let small_list_len_dist = + QCheck.(Test.make ~count:5_000 ~name:"small_list len dist" + (add_stat ("len",List.length) (small_list int))) (fun _ -> true) + + let list_of_size_len_dist = + QCheck.(Test.make ~count:5_000 ~name:"list_of_size len dist" + (add_stat ("len",List.length) (list_of_size (Gen.int_range 5 10) int))) (fun _ -> true) + (* test from issue #40 *) let int_stats_neg = QCheck.(Test.make ~count:5_000 ~name:"int_stats_neg" @@ -249,7 +257,9 @@ let i = ] @ FindExample.find_ex :: FindExample.find_ex_uncaught_issue_99 @ [Stats.bool_dist; Stats.char_dist; - Stats.list_size_dist; + Stats.list_len_dist; + Stats.small_list_len_dist; + Stats.list_of_size_len_dist; Stats.int_stats_neg] @ Stats.int_stats_tests) diff --git a/test/core/qcheck2_output.txt.expected b/test/core/qcheck2_output.txt.expected index 9cba6d91..60556ce9 100644 --- a/test/core/qcheck2_output.txt.expected +++ b/test/core/qcheck2_output.txt.expected @@ -175,7 +175,7 @@ stats char code: 234..246: ###################################################### 25567 247..259: ##################################### 17709 -+++ Stats for list size dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++ Stats for list len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 400.16, stddev: 1371.90, median 9, min 0, max 9987 @@ -200,6 +200,42 @@ stats len: 9000.. 9499: 15 9500.. 9999: 20 ++++ Stats for small_list len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats len: + num: 5000, avg: 16.14, stddev: 24.86, median 6, min 0, max 99 + 0.. 4: ###################################################### 1923 + 5.. 9: ####################################################### 1936 + 10.. 14: # 61 + 15.. 19: # 59 + 20.. 24: # 62 + 25.. 29: # 70 + 30.. 34: # 61 + 35.. 39: # 64 + 40.. 44: # 64 + 45.. 49: # 56 + 50.. 54: # 65 + 55.. 59: # 55 + 60.. 64: # 60 + 65.. 69: # 62 + 70.. 74: # 57 + 75.. 79: # 69 + 80.. 84: ## 73 + 85.. 89: # 67 + 90.. 94: # 62 + 95.. 99: ## 74 + ++++ Stats for list_size len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats len: + num: 5000, avg: 7.49, stddev: 1.71, median 8, min 5, max 10 + 5: ####################################################### 867 + 6: ################################################### 813 + 7: ################################################### 815 + 8: #################################################### 833 + 9: ###################################################### 857 + 10: ################################################### 815 + +++ Stats for int_stats_neg ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: @@ -416,7 +452,7 @@ stats dist: -4611686018427387392..-4150517416584648577: 0 ================================================================================ 1 warning(s) -failure (12 tests failed, 1 tests errored, ran 31 tests) +failure (12 tests failed, 1 tests errored, ran 33 tests) random seed: 153870556 +++ Stats for int_stat_display_test9 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ diff --git a/test/core/qcheck_output.txt.expected b/test/core/qcheck_output.txt.expected index 4fab766a..8044674b 100644 --- a/test/core/qcheck_output.txt.expected +++ b/test/core/qcheck_output.txt.expected @@ -175,7 +175,7 @@ stats char code: 234..246: ###################################################### 25567 247..259: ##################################### 17709 -+++ Stats for list size dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++ Stats for list len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 400.16, stddev: 1371.90, median 9, min 0, max 9987 @@ -200,6 +200,42 @@ stats len: 9000.. 9499: 15 9500.. 9999: 20 ++++ Stats for small_list len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats len: + num: 5000, avg: 16.14, stddev: 24.86, median 6, min 0, max 99 + 0.. 4: ###################################################### 1923 + 5.. 9: ####################################################### 1936 + 10.. 14: # 61 + 15.. 19: # 59 + 20.. 24: # 62 + 25.. 29: # 70 + 30.. 34: # 61 + 35.. 39: # 64 + 40.. 44: # 64 + 45.. 49: # 56 + 50.. 54: # 65 + 55.. 59: # 55 + 60.. 64: # 60 + 65.. 69: # 62 + 70.. 74: # 57 + 75.. 79: # 69 + 80.. 84: ## 73 + 85.. 89: # 67 + 90.. 94: # 62 + 95.. 99: ## 74 + ++++ Stats for list_of_size len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats len: + num: 5000, avg: 7.49, stddev: 1.71, median 8, min 5, max 10 + 5: ####################################################### 867 + 6: ################################################### 813 + 7: ################################################### 815 + 8: #################################################### 833 + 9: ###################################################### 857 + 10: ################################################### 815 + +++ Stats for int_stats_neg ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: @@ -416,7 +452,7 @@ stats dist: -4611686018427387392..-4150517416584648577: 0 ================================================================================ 1 warning(s) -failure (12 tests failed, 1 tests errored, ran 31 tests) +failure (12 tests failed, 1 tests errored, ran 33 tests) random seed: 153870556 +++ Stats for int_stat_display_test9 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ From 1b594e9da970779d5ff020e074fbe3f0b7ea65cd Mon Sep 17 00:00:00 2001 From: Jan Midtgaard Date: Thu, 12 Aug 2021 10:07:00 +0200 Subject: [PATCH 15/49] collect list dist tests --- test/core/QCheck2_expect_test.ml | 28 +++++++++++----------------- test/core/QCheck_expect_test.ml | 28 +++++++++++----------------- 2 files changed, 22 insertions(+), 34 deletions(-) diff --git a/test/core/QCheck2_expect_test.ml b/test/core/QCheck2_expect_test.ml index 21ecd363..cb941704 100644 --- a/test/core/QCheck2_expect_test.ml +++ b/test/core/QCheck2_expect_test.ml @@ -203,19 +203,15 @@ module Stats = struct QCheck2.(Test.make ~count:500_000 ~name:"char code dist" ~stats:[("char code", Char.code)] Gen.char) (fun _ -> true) - (* test from issue #30 *) - let list_len_dist = - QCheck2.(Test.make ~count:5_000 ~name:"list len dist" - ~stats:[("len",List.length)] Gen.(list int)) (fun _ -> true) - - let small_list_len_dist = - QCheck2.(Test.make ~count:5_000 ~name:"small_list len dist" - ~stats:[("len",List.length)] Gen.(small_list int)) (fun _ -> true) + let list_len_tests = + let open QCheck2 in + let len = ("len",List.length) in + [ (* test from issue #30 *) + Test.make ~count:5_000 ~name:"list len dist" ~stats:[len] Gen.(list int) (fun _ -> true); + Test.make ~count:5_000 ~name:"small_list len dist" ~stats:[len] Gen.(small_list int) (fun _ -> true); + Test.make ~count:5_000 ~name:"list_size len dist" ~stats:[len] Gen.(list_size (int_range 5 10) int) (fun _ -> true); + ] - let list_size_len_dist = - QCheck2.(Test.make ~count:5_000 ~name:"list_size len dist" - ~stats:[("len",List.length)] Gen.(list_size (int_range 5 10) int)) (fun _ -> true) - (* test from issue #40 *) let int_stats_neg = QCheck2.(Test.make ~count:5_000 ~name:"int_stats_neg" @@ -267,11 +263,9 @@ let _ = Shrink.shrink_int; ] @ FindExample.find_ex :: FindExample.find_ex_uncaught_issue_99 @ [Stats.bool_dist; - Stats.char_dist; - Stats.list_len_dist; - Stats.small_list_len_dist; - Stats.list_size_len_dist; - Stats.int_stats_neg] + Stats.char_dist] + @ Stats.list_len_tests + @ [Stats.int_stats_neg] @ Stats.int_stats_tests) let () = QCheck_base_runner.set_seed 153870556 diff --git a/test/core/QCheck_expect_test.ml b/test/core/QCheck_expect_test.ml index 305066e4..35e41b4e 100644 --- a/test/core/QCheck_expect_test.ml +++ b/test/core/QCheck_expect_test.ml @@ -193,18 +193,14 @@ module Stats = struct QCheck.(Test.make ~count:500_000 ~name:"char code dist" (add_stat ("char code", Char.code) char)) (fun _ -> true) - (* test from issue #30 *) - let list_len_dist = - QCheck.(Test.make ~count:5_000 ~name:"list len dist" - (add_stat ("len",List.length) (list int))) (fun _ -> true) - - let small_list_len_dist = - QCheck.(Test.make ~count:5_000 ~name:"small_list len dist" - (add_stat ("len",List.length) (small_list int))) (fun _ -> true) - - let list_of_size_len_dist = - QCheck.(Test.make ~count:5_000 ~name:"list_of_size len dist" - (add_stat ("len",List.length) (list_of_size (Gen.int_range 5 10) int))) (fun _ -> true) + let list_len_tests = + let open QCheck in + let len = ("len",List.length) in + [ (* test from issue #30 *) + Test.make ~count:5_000 ~name:"list len dist" (add_stat len (list int)) (fun _ -> true); + Test.make ~count:5_000 ~name:"small_list len dist" (add_stat len (small_list int)) (fun _ -> true); + Test.make ~count:5_000 ~name:"list_of_size len dist" (add_stat len (list_of_size (Gen.int_range 5 10) int)) (fun _ -> true); + ] (* test from issue #40 *) let int_stats_neg = @@ -256,11 +252,9 @@ let i = Shrink.shrink_int; ] @ FindExample.find_ex :: FindExample.find_ex_uncaught_issue_99 @ [Stats.bool_dist; - Stats.char_dist; - Stats.list_len_dist; - Stats.small_list_len_dist; - Stats.list_of_size_len_dist; - Stats.int_stats_neg] + Stats.char_dist] + @ Stats.list_len_tests + @ [Stats.int_stats_neg] @ Stats.int_stats_tests) let () = QCheck_base_runner.set_seed 153870556 From 77d745c8ab96b84bfc420237b768cb385f2ad811 Mon Sep 17 00:00:00 2001 From: Jan Midtgaard Date: Thu, 12 Aug 2021 12:15:33 +0200 Subject: [PATCH 16/49] add array and repeat tests --- test/core/QCheck2_expect_test.ml | 32 ++++++++++-- test/core/QCheck_expect_test.ml | 26 ++++++++++ test/core/qcheck2_output.txt.expected | 75 ++++++++++++++++++++++++++- test/core/qcheck_output.txt.expected | 75 ++++++++++++++++++++++++++- 4 files changed, 202 insertions(+), 6 deletions(-) diff --git a/test/core/QCheck2_expect_test.ml b/test/core/QCheck2_expect_test.ml index cb941704..4719a79e 100644 --- a/test/core/QCheck2_expect_test.ml +++ b/test/core/QCheck2_expect_test.ml @@ -63,6 +63,16 @@ module Generator = struct let char_dist_issue_23 = let open QCheck2 in Test.make ~name:"char never produces '\\255'" ~count:1_000_000 ~print:Print.char Gen.char (fun c -> c <> '\255') + + let list_repeat_test = + let open QCheck2 in + Test.make ~name:"list_repeat has constant length" ~count:1000 ~print:Print.(pair int (list unit)) + Gen.(small_nat >>= fun i -> list_repeat i unit >>= fun l -> return (i,l)) (fun (i,l) -> List.length l = i) + + let array_repeat_test = + let open QCheck2 in + Test.make ~name:"array_repeat has constant length" ~count:1000 ~print:Print.(pair int (array unit)) + Gen.(small_nat >>= fun i -> array_repeat i unit >>= fun l -> return (i,l)) (fun (i,l) -> Array.length l = i) end (* tests function generator and shrinker *) @@ -198,7 +208,7 @@ module Stats = struct let bool_dist = QCheck2.(Test.make ~count:500_000 ~name:"bool dist" ~collect:Bool.to_string Gen.bool) (fun _ -> true) - + let char_dist = QCheck2.(Test.make ~count:500_000 ~name:"char code dist" ~stats:[("char code", Char.code)] Gen.char) (fun _ -> true) @@ -207,9 +217,20 @@ module Stats = struct let open QCheck2 in let len = ("len",List.length) in [ (* test from issue #30 *) - Test.make ~count:5_000 ~name:"list len dist" ~stats:[len] Gen.(list int) (fun _ -> true); - Test.make ~count:5_000 ~name:"small_list len dist" ~stats:[len] Gen.(small_list int) (fun _ -> true); - Test.make ~count:5_000 ~name:"list_size len dist" ~stats:[len] Gen.(list_size (int_range 5 10) int) (fun _ -> true); + Test.make ~count:5_000 ~name:"list len dist" ~stats:[len] Gen.(list int) (fun _ -> true); + Test.make ~count:5_000 ~name:"small_list len dist" ~stats:[len] Gen.(small_list int) (fun _ -> true); + Test.make ~count:5_000 ~name:"list_size len dist" ~stats:[len] Gen.(list_size (int_range 5 10) int) (fun _ -> true); + Test.make ~count:5_000 ~name:"list_repeat len dist" ~stats:[len] Gen.(list_repeat 42 int) (fun _ -> true); + ] + + let array_len_tests = + let open QCheck2 in + let len = ("len",Array.length) in + [ + Test.make ~count:5_000 ~name:"array len dist" ~stats:[len] Gen.(array int) (fun _ -> true); + Test.make ~count:5_000 ~name:"small_array len dist" ~stats:[len] Gen.(small_array int) (fun _ -> true); + Test.make ~count:5_000 ~name:"array_size len dist" ~stats:[len] Gen.(array_size (int_range 5 10) int) (fun _ -> true); + Test.make ~count:5_000 ~name:"array_repeat len dist" ~stats:[len] Gen.(array_repeat 42 int) (fun _ -> true); ] (* test from issue #40 *) @@ -252,6 +273,8 @@ let _ = Overall.bad_assume_warn; Overall.bad_assume_fail; Generator.char_dist_issue_23; + Generator.list_repeat_test; + Generator.array_repeat_test; Function.fun1; Function.fun2; Function.prop_foldleft_foldright; @@ -265,6 +288,7 @@ let _ = @ [Stats.bool_dist; Stats.char_dist] @ Stats.list_len_tests + @ Stats.array_len_tests @ [Stats.int_stats_neg] @ Stats.int_stats_tests) diff --git a/test/core/QCheck_expect_test.ml b/test/core/QCheck_expect_test.ml index 35e41b4e..80c0c071 100644 --- a/test/core/QCheck_expect_test.ml +++ b/test/core/QCheck_expect_test.ml @@ -61,6 +61,18 @@ module Generator = struct (* example from issue #23 *) let char_dist_issue_23 = QCheck.Test.make ~name:"char never produces '\\255'" ~count:1_000_000 QCheck.char (fun c -> c <> '\255') + + let list_repeat_test = + let open QCheck in + let gen = Gen.(small_nat >>= fun i -> list_repeat i unit >>= fun l -> return (i,l)) in + Test.make ~name:"list_repeat has constant length" ~count:1000 + (make ~print:Print.(pair int (list unit)) gen) (fun (i,l) -> List.length l = i) + + let array_repeat_test = + let open QCheck in + let gen = Gen.(small_nat >>= fun i -> array_repeat i unit >>= fun l -> return (i,l)) in + Test.make ~name:"array_repeat has constant length" ~count:1000 + (make ~print:Print.(pair int (array unit)) gen) (fun (i,l) -> Array.length l = i) end (* tests function generator and shrinker *) @@ -200,6 +212,17 @@ module Stats = struct Test.make ~count:5_000 ~name:"list len dist" (add_stat len (list int)) (fun _ -> true); Test.make ~count:5_000 ~name:"small_list len dist" (add_stat len (small_list int)) (fun _ -> true); Test.make ~count:5_000 ~name:"list_of_size len dist" (add_stat len (list_of_size (Gen.int_range 5 10) int)) (fun _ -> true); + Test.make ~count:5_000 ~name:"list_repeat len dist" (add_stat len (make Gen.(list_repeat 42 int))) (fun _ -> true); + ] + + let array_len_tests = + let open QCheck in + let len = ("len",Array.length) in + [ + Test.make ~count:5_000 ~name:"array len dist" (add_stat len (array int)) (fun _ -> true); + Test.make ~count:5_000 ~name:"small_array len dist" (add_stat len (make Gen.(small_array int))) (fun _ -> true); + Test.make ~count:5_000 ~name:"array_of_size len dist" (add_stat len (array_of_size (Gen.int_range 5 10) int)) (fun _ -> true); + Test.make ~count:5_000 ~name:"array_repeat len dist" (add_stat len (make Gen.(array_repeat 42 int))) (fun _ -> true); ] (* test from issue #40 *) @@ -241,6 +264,8 @@ let i = Overall.bad_assume_warn; Overall.bad_assume_fail; Generator.char_dist_issue_23; + Generator.list_repeat_test; + Generator.array_repeat_test; Function.fun1; Function.fun2; Function.prop_foldleft_foldright; @@ -254,6 +279,7 @@ let i = @ [Stats.bool_dist; Stats.char_dist] @ Stats.list_len_tests + @ Stats.array_len_tests @ [Stats.int_stats_neg] @ Stats.int_stats_tests) diff --git a/test/core/qcheck2_output.txt.expected b/test/core/qcheck2_output.txt.expected index 60556ce9..99f37897 100644 --- a/test/core/qcheck2_output.txt.expected +++ b/test/core/qcheck2_output.txt.expected @@ -236,6 +236,79 @@ stats len: 9: ###################################################### 857 10: ################################################### 815 ++++ Stats for list_repeat len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats len: + num: 5000, avg: 42.00, stddev: 0.00, median 42, min 42, max 42 + 42: ####################################################### 5000 + ++++ Stats for array len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats len: + num: 5000, avg: 400.16, stddev: 1371.90, median 9, min 0, max 9987 + 0.. 499: ####################################################### 4246 + 500.. 999: ###### 502 + 1000.. 1499: 13 + 1500.. 1999: 10 + 2000.. 2499: 14 + 2500.. 2999: 14 + 3000.. 3499: 20 + 3500.. 3999: 7 + 4000.. 4499: 13 + 4500.. 4999: 16 + 5000.. 5499: 12 + 5500.. 5999: 15 + 6000.. 6499: 15 + 6500.. 6999: 13 + 7000.. 7499: 16 + 7500.. 7999: 12 + 8000.. 8499: 11 + 8500.. 8999: 16 + 9000.. 9499: 15 + 9500.. 9999: 20 + ++++ Stats for small_array len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats len: + num: 5000, avg: 16.14, stddev: 24.86, median 6, min 0, max 99 + 0.. 4: ###################################################### 1923 + 5.. 9: ####################################################### 1936 + 10.. 14: # 61 + 15.. 19: # 59 + 20.. 24: # 62 + 25.. 29: # 70 + 30.. 34: # 61 + 35.. 39: # 64 + 40.. 44: # 64 + 45.. 49: # 56 + 50.. 54: # 65 + 55.. 59: # 55 + 60.. 64: # 60 + 65.. 69: # 62 + 70.. 74: # 57 + 75.. 79: # 69 + 80.. 84: ## 73 + 85.. 89: # 67 + 90.. 94: # 62 + 95.. 99: ## 74 + ++++ Stats for array_size len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats len: + num: 5000, avg: 7.49, stddev: 1.71, median 8, min 5, max 10 + 5: ####################################################### 867 + 6: ################################################### 813 + 7: ################################################### 815 + 8: #################################################### 833 + 9: ###################################################### 857 + 10: ################################################### 815 + ++++ Stats for array_repeat len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats len: + num: 5000, avg: 42.00, stddev: 0.00, median 42, min 42, max 42 + 42: ####################################################### 5000 + +++ Stats for int_stats_neg ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: @@ -452,7 +525,7 @@ stats dist: -4611686018427387392..-4150517416584648577: 0 ================================================================================ 1 warning(s) -failure (12 tests failed, 1 tests errored, ran 33 tests) +failure (12 tests failed, 1 tests errored, ran 40 tests) random seed: 153870556 +++ Stats for int_stat_display_test9 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ diff --git a/test/core/qcheck_output.txt.expected b/test/core/qcheck_output.txt.expected index 8044674b..69389b6d 100644 --- a/test/core/qcheck_output.txt.expected +++ b/test/core/qcheck_output.txt.expected @@ -236,6 +236,79 @@ stats len: 9: ###################################################### 857 10: ################################################### 815 ++++ Stats for list_repeat len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats len: + num: 5000, avg: 42.00, stddev: 0.00, median 42, min 42, max 42 + 42: ####################################################### 5000 + ++++ Stats for array len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats len: + num: 5000, avg: 400.16, stddev: 1371.90, median 9, min 0, max 9987 + 0.. 499: ####################################################### 4246 + 500.. 999: ###### 502 + 1000.. 1499: 13 + 1500.. 1999: 10 + 2000.. 2499: 14 + 2500.. 2999: 14 + 3000.. 3499: 20 + 3500.. 3999: 7 + 4000.. 4499: 13 + 4500.. 4999: 16 + 5000.. 5499: 12 + 5500.. 5999: 15 + 6000.. 6499: 15 + 6500.. 6999: 13 + 7000.. 7499: 16 + 7500.. 7999: 12 + 8000.. 8499: 11 + 8500.. 8999: 16 + 9000.. 9499: 15 + 9500.. 9999: 20 + ++++ Stats for small_array len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats len: + num: 5000, avg: 16.14, stddev: 24.86, median 6, min 0, max 99 + 0.. 4: ###################################################### 1923 + 5.. 9: ####################################################### 1936 + 10.. 14: # 61 + 15.. 19: # 59 + 20.. 24: # 62 + 25.. 29: # 70 + 30.. 34: # 61 + 35.. 39: # 64 + 40.. 44: # 64 + 45.. 49: # 56 + 50.. 54: # 65 + 55.. 59: # 55 + 60.. 64: # 60 + 65.. 69: # 62 + 70.. 74: # 57 + 75.. 79: # 69 + 80.. 84: ## 73 + 85.. 89: # 67 + 90.. 94: # 62 + 95.. 99: ## 74 + ++++ Stats for array_of_size len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats len: + num: 5000, avg: 7.49, stddev: 1.71, median 8, min 5, max 10 + 5: ####################################################### 867 + 6: ################################################### 813 + 7: ################################################### 815 + 8: #################################################### 833 + 9: ###################################################### 857 + 10: ################################################### 815 + ++++ Stats for array_repeat len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats len: + num: 5000, avg: 42.00, stddev: 0.00, median 42, min 42, max 42 + 42: ####################################################### 5000 + +++ Stats for int_stats_neg ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: @@ -452,7 +525,7 @@ stats dist: -4611686018427387392..-4150517416584648577: 0 ================================================================================ 1 warning(s) -failure (12 tests failed, 1 tests errored, ran 33 tests) +failure (12 tests failed, 1 tests errored, ran 40 tests) random seed: 153870556 +++ Stats for int_stat_display_test9 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ From 541552409e4e6641a64b56a806aec698ac6584f1 Mon Sep 17 00:00:00 2001 From: Jan Midtgaard Date: Thu, 12 Aug 2021 14:14:18 +0200 Subject: [PATCH 17/49] rename int dist tests to make it easier to add more --- test/core/QCheck2_expect_test.ml | 37 ++++++++++++--------------- test/core/QCheck_expect_test.ml | 37 ++++++++++++--------------- test/core/qcheck2_output.txt.expected | 18 ++++++------- test/core/qcheck_output.txt.expected | 18 ++++++------- 4 files changed, 50 insertions(+), 60 deletions(-) diff --git a/test/core/QCheck2_expect_test.ml b/test/core/QCheck2_expect_test.ml index 4719a79e..a0efef2c 100644 --- a/test/core/QCheck2_expect_test.ml +++ b/test/core/QCheck2_expect_test.ml @@ -233,30 +233,26 @@ module Stats = struct Test.make ~count:5_000 ~name:"array_repeat len dist" ~stats:[len] Gen.(array_repeat 42 int) (fun _ -> true); ] - (* test from issue #40 *) - let int_stats_neg = - QCheck2.(Test.make ~count:5_000 ~name:"int_stats_neg" - ~stats:[("dist",fun x -> x)] Gen.small_signed_int) - (fun _ -> true) - - (* distribution tests from PR #45 *) - let int_stats_tests = + let int_dist_tests = let open QCheck2 in let dist = ("dist",fun x -> x) in [ - Test.make ~name:"int_stat_display_test_1" ~count:1000 ~stats:[dist] Gen.small_signed_int (fun _ -> true); - Test.make ~name:"int_stat_display_test_2" ~count:1000 ~stats:[dist] Gen.small_nat (fun _ -> true); - Test.make ~name:"int_stat_display_test_3" ~count:1000 ~stats:[dist] (Gen.int_range (-43643) 435434) (fun _ -> true); - Test.make ~name:"int_stat_display_test_4" ~count:1000 ~stats:[dist] (Gen.int_range (-40000) 40000) (fun _ -> true); - Test.make ~name:"int_stat_display_test_5" ~count:1000 ~stats:[dist] (Gen.int_range (-4) 4) (fun _ -> true); - Test.make ~name:"int_stat_display_test_6" ~count:1000 ~stats:[dist] (Gen.int_range (-4) 17) (fun _ -> true); - Test.make ~name:"int_stat_display_test_7" ~count:100000 ~stats:[dist] Gen.int (fun _ -> true); - Test.make ~name:"int_stat_display_test_8" ~count:1000 ~stats:[dist] (Gen.oneofl[min_int;-1;0;1;max_int]) (fun _ -> true); + (* test from issue #40 *) + Test.make ~name:"int_stats_neg" ~count:5000 ~stats:[dist] Gen.small_signed_int (fun _ -> true); + (* distribution tests from PR #45 *) + Test.make ~name:"small_signed_int dist" ~count:1000 ~stats:[dist] Gen.small_signed_int (fun _ -> true); + Test.make ~name:"small_nat dist" ~count:1000 ~stats:[dist] Gen.small_nat (fun _ -> true); + Test.make ~name:"int_range (-43643) 435434 dist" ~count:1000 ~stats:[dist] (Gen.int_range (-43643) 435434) (fun _ -> true); + Test.make ~name:"int_range (-40000) 40000 dist" ~count:1000 ~stats:[dist] (Gen.int_range (-40000) 40000) (fun _ -> true); + Test.make ~name:"int_range (-4) 4 dist" ~count:1000 ~stats:[dist] (Gen.int_range (-4) 4) (fun _ -> true); + Test.make ~name:"int_range (-4) 17 dist" ~count:1000 ~stats:[dist] (Gen.int_range (-4) 17) (fun _ -> true); + Test.make ~name:"int dist" ~count:100000 ~stats:[dist] Gen.int (fun _ -> true); + Test.make ~name:"oneof int dist" ~count:1000 ~stats:[dist] (Gen.oneofl[min_int;-1;0;1;max_int]) (fun _ -> true); ] - let int_stat_display_test9 = + let int_dist_empty_bucket = let open QCheck2 in - Test.make ~name:"int_stat_display_test9" ~count:1_000 + Test.make ~name:"int_dist_empty_bucket" ~count:1_000 ~stats:[("dist",fun x -> x)] Gen.(oneof [small_int_corners ();int]) (fun _ -> true) end @@ -289,9 +285,8 @@ let _ = Stats.char_dist] @ Stats.list_len_tests @ Stats.array_len_tests - @ [Stats.int_stats_neg] - @ Stats.int_stats_tests) + @ Stats.int_dist_tests) let () = QCheck_base_runner.set_seed 153870556 -let _ = QCheck_base_runner.run_tests ~colors:false [Stats.int_stat_display_test9] +let _ = QCheck_base_runner.run_tests ~colors:false [Stats.int_dist_empty_bucket] diff --git a/test/core/QCheck_expect_test.ml b/test/core/QCheck_expect_test.ml index 80c0c071..80323556 100644 --- a/test/core/QCheck_expect_test.ml +++ b/test/core/QCheck_expect_test.ml @@ -225,29 +225,25 @@ module Stats = struct Test.make ~count:5_000 ~name:"array_repeat len dist" (add_stat len (make Gen.(array_repeat 42 int))) (fun _ -> true); ] - (* test from issue #40 *) - let int_stats_neg = - QCheck.(Test.make ~count:5_000 ~name:"int_stats_neg" - (add_stat ("dist",fun x -> x) small_signed_int)) (fun _ -> true) - - (* distribution tests from PR #45 *) - let int_stats_tests = + let int_dist_tests = let open QCheck in let dist = ("dist",fun x -> x) in - [ - Test.make ~name:"int_stat_display_test_1" ~count:1000 (add_stat dist small_signed_int) (fun _ -> true); - Test.make ~name:"int_stat_display_test_2" ~count:1000 (add_stat dist small_nat) (fun _ -> true); - Test.make ~name:"int_stat_display_test_3" ~count:1000 (add_stat dist (int_range (-43643) 435434)) (fun _ -> true); - Test.make ~name:"int_stat_display_test_4" ~count:1000 (add_stat dist (int_range (-40000) 40000)) (fun _ -> true); - Test.make ~name:"int_stat_display_test_5" ~count:1000 (add_stat dist (int_range (-4) 4)) (fun _ -> true); - Test.make ~name:"int_stat_display_test_6" ~count:1000 (add_stat dist (int_range (-4) 17)) (fun _ -> true); - Test.make ~name:"int_stat_display_test_7" ~count:100000 (add_stat dist int) (fun _ -> true); - Test.make ~name:"int_stat_display_test_8" ~count:1000 (add_stat dist (oneofl[min_int;-1;0;1;max_int])) (fun _ -> true); + [ (* test from issue #40 *) + Test.make ~name:"int_stats_neg" ~count:5000 (add_stat dist small_signed_int) (fun _ -> true); + (* distribution tests from PR #45 *) + Test.make ~name:"small_signed_int dist" ~count:1000 (add_stat dist small_signed_int) (fun _ -> true); + Test.make ~name:"small_nat dist" ~count:1000 (add_stat dist small_nat) (fun _ -> true); + Test.make ~name:"int_range (-43643) 435434 dist" ~count:1000 (add_stat dist (int_range (-43643) 435434)) (fun _ -> true); + Test.make ~name:"int_range (-40000) 40000 dist" ~count:1000 (add_stat dist (int_range (-40000) 40000)) (fun _ -> true); + Test.make ~name:"int_range (-4) 4 dist" ~count:1000 (add_stat dist (int_range (-4) 4)) (fun _ -> true); + Test.make ~name:"int_range (-4) 17 dist" ~count:1000 (add_stat dist (int_range (-4) 17)) (fun _ -> true); + Test.make ~name:"int dist" ~count:100000 (add_stat dist int) (fun _ -> true); + Test.make ~name:"oneof int dist" ~count:1000 (add_stat dist (oneofl[min_int;-1;0;1;max_int])) (fun _ -> true); ] - let int_stat_display_test9 = + let int_dist_empty_bucket = let open QCheck in - Test.make ~name:"int_stat_display_test9" ~count:1_000 + Test.make ~name:"int_dist_empty_bucket" ~count:1_000 (add_stat ("dist",fun x -> x) (oneof [small_int_corners ();int])) (fun _ -> true) end @@ -280,8 +276,7 @@ let i = Stats.char_dist] @ Stats.list_len_tests @ Stats.array_len_tests - @ [Stats.int_stats_neg] - @ Stats.int_stats_tests) + @ Stats.int_dist_tests) let () = QCheck_base_runner.set_seed 153870556 -let _ = QCheck_base_runner.run_tests ~colors:false [Stats.int_stat_display_test9] +let _ = QCheck_base_runner.run_tests ~colors:false [Stats.int_dist_empty_bucket] diff --git a/test/core/qcheck2_output.txt.expected b/test/core/qcheck2_output.txt.expected index 99f37897..2a9836d6 100644 --- a/test/core/qcheck2_output.txt.expected +++ b/test/core/qcheck2_output.txt.expected @@ -334,7 +334,7 @@ stats dist: 81.. 90: # 60 91..100: # 66 -+++ Stats for int_stat_display_test_1 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++ Stats for small_signed_int dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 0.90, stddev: 28.23, median 0, min -99, max 99 @@ -359,7 +359,7 @@ stats dist: 81.. 90: # 16 91..100: # 10 -+++ Stats for int_stat_display_test_2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++ Stats for small_nat dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 15.11, stddev: 23.27, median 6, min 0, max 99 @@ -384,7 +384,7 @@ stats dist: 90.. 94: 5 95.. 99: # 10 -+++ Stats for int_stat_display_test_3 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++ Stats for int_range (-43643) 435434 dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 195335.64, stddev: 136803.99, median 195583, min -43624, max 435210 @@ -409,7 +409,7 @@ stats dist: 387332..411273: ########################################## 49 411274..435215: ########################################### 51 -+++ Stats for int_stat_display_test_4 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++ Stats for int_range (-40000) 40000 dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: -173.78, stddev: 23042.92, median 180, min -39859, max 39942 @@ -434,7 +434,7 @@ stats dist: 31979.. 35969: ######################################### 51 35970.. 39960: #################################### 45 -+++ Stats for int_stat_display_test_5 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++ Stats for int_range (-4) 4 dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 0.02, stddev: 2.55, median 0, min -4, max 4 @@ -448,7 +448,7 @@ stats dist: 3: ####################################################### 122 4: ############################################## 104 -+++ Stats for int_stat_display_test_6 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++ Stats for int_range (-4) 17 dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 6.67, stddev: 6.39, median 7, min -4, max 17 @@ -473,7 +473,7 @@ stats dist: 32..33: 0 34..35: 0 -+++ Stats for int_stat_display_test_7 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++ Stats for int dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 100000, avg: 6126662802445055.00, stddev: 2661484817981980672.00, median 158655556399988, min -4611578348806740501, max 4611677827646819817 @@ -498,7 +498,7 @@ stats dist: 3689352210001463787.. 4150515018824141802: ###################################################### 5048 4150515018824141803.. 4611677827646819818: ###################################################### 5063 -+++ Stats for int_stat_display_test_8 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++ Stats for oneof int dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 4611686018427388.00, stddev: 2905870896563567616.00, median 0, min -4611686018427387904, max 4611686018427387903 @@ -528,7 +528,7 @@ stats dist: failure (12 tests failed, 1 tests errored, ran 40 tests) random seed: 153870556 -+++ Stats for int_stat_display_test9 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++ Stats for int_dist_empty_bucket ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: -10119269408092442.00, stddev: 1871251663919905536.00, median 9, min -4576142151952919207, max 4611686018427387903 diff --git a/test/core/qcheck_output.txt.expected b/test/core/qcheck_output.txt.expected index 69389b6d..725031c2 100644 --- a/test/core/qcheck_output.txt.expected +++ b/test/core/qcheck_output.txt.expected @@ -334,7 +334,7 @@ stats dist: 81.. 90: # 60 91..100: # 66 -+++ Stats for int_stat_display_test_1 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++ Stats for small_signed_int dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 0.90, stddev: 28.23, median 0, min -99, max 99 @@ -359,7 +359,7 @@ stats dist: 81.. 90: # 16 91..100: # 10 -+++ Stats for int_stat_display_test_2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++ Stats for small_nat dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 15.11, stddev: 23.27, median 6, min 0, max 99 @@ -384,7 +384,7 @@ stats dist: 90.. 94: 5 95.. 99: # 10 -+++ Stats for int_stat_display_test_3 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++ Stats for int_range (-43643) 435434 dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 195335.64, stddev: 136803.99, median 195583, min -43624, max 435210 @@ -409,7 +409,7 @@ stats dist: 387332..411273: ########################################## 49 411274..435215: ########################################### 51 -+++ Stats for int_stat_display_test_4 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++ Stats for int_range (-40000) 40000 dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: -173.78, stddev: 23042.92, median 180, min -39859, max 39942 @@ -434,7 +434,7 @@ stats dist: 31979.. 35969: ######################################### 51 35970.. 39960: #################################### 45 -+++ Stats for int_stat_display_test_5 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++ Stats for int_range (-4) 4 dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 0.02, stddev: 2.55, median 0, min -4, max 4 @@ -448,7 +448,7 @@ stats dist: 3: ####################################################### 122 4: ############################################## 104 -+++ Stats for int_stat_display_test_6 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++ Stats for int_range (-4) 17 dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 6.67, stddev: 6.39, median 7, min -4, max 17 @@ -473,7 +473,7 @@ stats dist: 32..33: 0 34..35: 0 -+++ Stats for int_stat_display_test_7 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++ Stats for int dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 100000, avg: 2541076923587387.50, stddev: 2660730801206827008.00, median 158655268318060, min -4611522359435274428, max 4611540922436307689 @@ -498,7 +498,7 @@ stats dist: 3689234594249150020.. 4150387758342729155: ##################################################### 4982 4150387758342729156.. 4611540922436308291: ###################################################### 5039 -+++ Stats for int_stat_display_test_8 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++ Stats for oneof int dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 4611686018427388.00, stddev: 2905870896563567616.00, median 0, min -4611686018427387904, max 4611686018427387903 @@ -528,7 +528,7 @@ stats dist: failure (12 tests failed, 1 tests errored, ran 40 tests) random seed: 153870556 -+++ Stats for int_stat_display_test9 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++ Stats for int_dist_empty_bucket ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: -55083208105414400.00, stddev: 1847115855773139200.00, median 9, min -4590718933436425025, max 4611686018427387903 From 9334a060b0e221ae50bc976eb9a510b131b30807 Mon Sep 17 00:00:00 2001 From: Jan Midtgaard Date: Thu, 12 Aug 2021 15:07:24 +0200 Subject: [PATCH 18/49] clean-up: avoid repeated 'let open QCheck', take ~name first, rename --- test/core/QCheck2_expect_test.ml | 171 ++++++++++++-------------- test/core/QCheck_expect_test.ml | 167 ++++++++++++------------- test/core/qcheck2_output.txt.expected | 4 +- test/core/qcheck_output.txt.expected | 4 +- 4 files changed, 159 insertions(+), 187 deletions(-) diff --git a/test/core/QCheck2_expect_test.ml b/test/core/QCheck2_expect_test.ml index a0efef2c..8e2a91b9 100644 --- a/test/core/QCheck2_expect_test.ml +++ b/test/core/QCheck2_expect_test.ml @@ -2,55 +2,46 @@ (* tests of overall functionality *) module Overall = struct + open QCheck2 + let passing = - QCheck2.Test.make ~count:100 ~long_factor:100 ~print:QCheck2.Print.(list int) - ~name:"list_rev_is_involutive" - QCheck2.Gen.(list small_int) - (fun l -> List.rev (List.rev l) = l);; + Test.make ~name:"list_rev_is_involutive" ~count:100 ~long_factor:100 + ~print:Print.(list int) + Gen.(list small_int) (fun l -> List.rev (List.rev l) = l) let failing = - QCheck2.Test.make ~count:10 - ~name:"should_fail_sort_id" ~print:QCheck2.Print.(list int) - QCheck2.Gen.(small_list small_int) - (fun l -> l = List.sort compare l);; + 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) exception Error let error = - QCheck2.Test.make ~count:10 - ~name:"should_error_raise_exn" ~print:QCheck2.Print.int - QCheck2.Gen.int - (fun _ -> raise Error) + Test.make ~name:"should_error_raise_exn" ~count:10 ~print:Print.int + Gen.int (fun _ -> raise Error) let collect = - QCheck2.Test.make ~count:100 ~long_factor:100 - ~name:"collect_results" ~print:QCheck2.Print.int - ~collect:string_of_int (QCheck2.Gen.int_bound 4) - (fun _ -> true) + Test.make ~name:"collect_results" ~count:100 ~long_factor:100 + ~print:Print.int ~collect:string_of_int + (Gen.int_bound 4) (fun _ -> true) let stats = - QCheck2.Test.make ~count:100 ~long_factor:100 - ~name:"with_stats" ~print:QCheck2.Print.int + Test.make ~name:"with_stats" ~count:100 ~long_factor:100 ~print:Print.int ~stats:[ "mod4", (fun i->i mod 4); "num", (fun i->i); ] - (QCheck2.Gen.int_bound 120) - (fun _ -> true) + (Gen.int_bound 120) (fun _ -> true) let bad_assume_warn = - let open QCheck2 in - Test.make ~count:2_000 - ~name:"WARN_unlikely_precond" ~print:Print.int + Test.make ~name:"WARN_unlikely_precond" ~count:2_000 ~print:Print.int Gen.int (fun x -> QCheck.assume (x mod 100 = 1); true) let bad_assume_fail = - let open QCheck2 in - Test.make ~count:2_000 ~if_assumptions_fail:(`Fatal, 0.1) - ~name:"FAIL_unlikely_precond" ~print:Print.int + Test.make ~name:"FAIL_unlikely_precond" ~count:2_000 + ~if_assumptions_fail:(`Fatal, 0.1) ~print:Print.int Gen.int (fun x -> QCheck.assume (x mod 100 = 1); @@ -59,48 +50,50 @@ end (* test various generators *) module Generator = struct + open QCheck2 + (* example from issue #23 *) let char_dist_issue_23 = - let open QCheck2 in - Test.make ~name:"char never produces '\\255'" ~count:1_000_000 ~print:Print.char Gen.char (fun c -> c <> '\255') + Test.make ~name:"char never produces '\\255'" ~count:1_000_000 + ~print:Print.char + Gen.char (fun c -> c <> '\255') let list_repeat_test = - let open QCheck2 in - Test.make ~name:"list_repeat has constant length" ~count:1000 ~print:Print.(pair int (list unit)) - Gen.(small_nat >>= fun i -> list_repeat i unit >>= fun l -> return (i,l)) (fun (i,l) -> List.length l = i) + Test.make ~name:"list_repeat has constant length" ~count:1000 + ~print:Print.(pair int (list unit)) + Gen.(small_nat >>= fun i -> list_repeat i unit >>= fun l -> return (i,l)) + (fun (i,l) -> List.length l = i) let array_repeat_test = - let open QCheck2 in - Test.make ~name:"array_repeat has constant length" ~count:1000 ~print:Print.(pair int (array unit)) - Gen.(small_nat >>= fun i -> array_repeat i unit >>= fun l -> return (i,l)) (fun (i,l) -> Array.length l = i) + Test.make ~name:"array_repeat has constant length" ~count:1000 + ~print:Print.(pair int (array unit)) + Gen.(small_nat >>= fun i -> array_repeat i unit >>= fun l -> return (i,l)) + (fun (i,l) -> Array.length l = i) end (* tests function generator and shrinker *) module Function = struct - let fun1 = - let open QCheck2 in - Test.make ~count:100 ~long_factor:100 - ~name:"FAIL_pred_map_commute" ~print:Print.(triple (list int) Fn.print Fn.print) + open QCheck2 + + let fail_pred_map_commute = + Test.make ~name:"fail_pred_map_commute" ~count:100 ~long_factor:100 + ~print:Print.(triple (list int) Fn.print Fn.print) Gen.(triple (small_list small_int) (fun1 ~print:Print.int Observable.int int) (fun1 ~print:Print.bool Observable.int bool)) - (fun (l,QCheck2.Fun (_,f), QCheck2.Fun (_,p)) -> + (fun (l,Fun (_,f),Fun (_,p)) -> List.filter p (List.map f l) = List.map f (List.filter p l)) - let fun2 = - let open QCheck2 in - Test.make ~count:100 - ~name:"FAIL_fun2_pred_strings" ~print:Fn.print + let fail_pred_strings = + Test.make ~name:"fail_pred_strings" ~count:100 ~print:Fn.print (fun1 Observable.string ~print:Print.bool Gen.bool) - (fun (Fun (_,p)) -> - not (p "some random string") || p "some other string") + (fun (Fun (_,p)) -> not (p "some random string") || p "some other string") - let int_gen = QCheck2.Gen.small_nat (* int *) + let int_gen = Gen.small_nat (* int *) (* Another example (false) property *) let prop_foldleft_foldright = - let open QCheck2 in Test.make ~name:"fold_left fold_right" ~count:1000 ~long_factor:20 ~print:Print.(triple int (list int) Fn.print) Gen.(triple @@ -111,15 +104,14 @@ module Function = struct let l1 = List.fold_right (Fn.apply f) xs z in let l2 = List.fold_left (Fn.apply f) z xs in if l1=l2 then true - else QCheck.Test.fail_reportf "l=%s, fold_left=%s, fold_right=%s@." - (QCheck.Print.(list int) xs) - (QCheck.Print.int l1) - (QCheck.Print.int l2) + else Test.fail_reportf "l=%s, fold_left=%s, fold_right=%s@." + (Print.(list int) xs) + (Print.int l1) + (Print.int l2) ) (* Another example (false) property *) let prop_foldleft_foldright_uncurry = - let open QCheck2 in Test.make ~name:"fold_left fold_right uncurried" ~count:1000 ~long_factor:20 ~print:Print.(triple Fn.print int (list int)) Gen.(triple @@ -132,7 +124,6 @@ module Function = struct (* Same as the above (false) property, but generating+shrinking functions last *) let prop_foldleft_foldright_uncurry_funlast = - let open QCheck2 in Test.make ~name:"fold_left fold_right uncurried fun last" ~count:1000 ~long_factor:20 ~print:Print.(triple int (list int) Fn.print) Gen.(triple @@ -146,13 +137,14 @@ end (* tests of shrinking behaviour *) module Shrink = struct + open QCheck2 + let rec fac n = match n with | 0 -> 1 | n -> n * fac (n - 1) (* example from issue #59 *) let test_fac_issue59 = - let open QCheck2 in Test.make ~name:"test fac issue59" (Gen.make_primitive ~gen:(fun st -> Gen.generate1 ~rand:st (Gen.small_int_corners ())) ~shrink:(fun _ -> Seq.empty)) (fun n -> try (fac n) mod n = 0 @@ -161,11 +153,10 @@ module Shrink = struct | Division_by_zero -> (n=0)) let big_bound_issue59 = - QCheck2.Test.make ~name:"big bound issue59" ~print:QCheck2.Print.int - (QCheck2.Gen.small_int_corners()) (fun i -> i < 209609) + Test.make ~name:"big bound issue59" ~print:Print.int + (Gen.small_int_corners()) (fun i -> i < 209609) let long_shrink = - let open QCheck2 in let listgen = Gen.(list_size (int_range 1000 10000) int) in Test.make ~name:"long_shrink" ~print:Print.(pair (list int) (list int)) (Gen.pair listgen listgen) @@ -173,15 +164,15 @@ module Shrink = struct (* test shrinking on integers *) let shrink_int = - let open QCheck2 in - Test.make ~count:1000 ~name:"mod3_should_fail" ~print:Print.int + Test.make ~name:"mod3_should_fail" ~count:1000 ~print:Print.int Gen.int (fun i -> i mod 3 <> 0) end (* tests of (inner) find_example(_gen) behaviour *) module FindExample = struct + open QCheck2 + let find_ex = - let open QCheck2 in Test.make ~name:"find_example" ~print:Print.int Gen.(2--50) (fun n -> @@ -192,49 +183,44 @@ module FindExample = struct f m with No_example_found _ -> false) - let find_ex_uncaught_issue_99 : _ list = - let open QCheck2 in - let t1 = - let rs = (find_example ~count:10 ~f:(fun _ -> false) Gen.int) in - Test.make ~name:"FAIL_#99_1" rs (fun _ -> true) in - let t2 = - Test.make ~name:"should_succeed_#99_2" ~count:10 Gen.int - (fun i -> i <= max_int) in - [t1;t2] + let find_ex_uncaught_issue_99_1_fail = + let rs = (find_example ~count:10 ~f:(fun _ -> false) Gen.int) in + Test.make ~name:"FAIL_#99_1" rs (fun _ -> true) + + let find_ex_uncaught_issue_99_2_succeed = + Test.make ~name:"should_succeed_#99_2" ~count:10 + Gen.int (fun i -> i <= max_int) end (* tests of statistics and histogram display *) module Stats = struct + open QCheck2 + let bool_dist = - QCheck2.(Test.make ~count:500_000 ~name:"bool dist" - ~collect:Bool.to_string Gen.bool) (fun _ -> true) + Test.make ~name:"bool dist" ~count:500_000 ~collect:Bool.to_string Gen.bool (fun _ -> true) let char_dist = - QCheck2.(Test.make ~count:500_000 ~name:"char code dist" - ~stats:[("char code", Char.code)] Gen.char) (fun _ -> true) + Test.make ~name:"char code dist" ~count:500_000 ~stats:[("char code", Char.code)] Gen.char (fun _ -> true) let list_len_tests = - let open QCheck2 in let len = ("len",List.length) in [ (* test from issue #30 *) - Test.make ~count:5_000 ~name:"list len dist" ~stats:[len] Gen.(list int) (fun _ -> true); - Test.make ~count:5_000 ~name:"small_list len dist" ~stats:[len] Gen.(small_list int) (fun _ -> true); - Test.make ~count:5_000 ~name:"list_size len dist" ~stats:[len] Gen.(list_size (int_range 5 10) int) (fun _ -> true); - Test.make ~count:5_000 ~name:"list_repeat len dist" ~stats:[len] Gen.(list_repeat 42 int) (fun _ -> true); + Test.make ~name:"list len dist" ~count:5_000 ~stats:[len] Gen.(list int) (fun _ -> true); + Test.make ~name:"small_list len dist" ~count:5_000 ~stats:[len] Gen.(small_list int) (fun _ -> true); + Test.make ~name:"list_size len dist" ~count:5_000 ~stats:[len] Gen.(list_size (int_range 5 10) int) (fun _ -> true); + Test.make ~name:"list_repeat len dist" ~count:5_000 ~stats:[len] Gen.(list_repeat 42 int) (fun _ -> true); ] let array_len_tests = - let open QCheck2 in let len = ("len",Array.length) in [ - Test.make ~count:5_000 ~name:"array len dist" ~stats:[len] Gen.(array int) (fun _ -> true); - Test.make ~count:5_000 ~name:"small_array len dist" ~stats:[len] Gen.(small_array int) (fun _ -> true); - Test.make ~count:5_000 ~name:"array_size len dist" ~stats:[len] Gen.(array_size (int_range 5 10) int) (fun _ -> true); - Test.make ~count:5_000 ~name:"array_repeat len dist" ~stats:[len] Gen.(array_repeat 42 int) (fun _ -> true); + Test.make ~name:"array len dist" ~count:5_000 ~stats:[len] Gen.(array int) (fun _ -> true); + Test.make ~name:"small_array len dist" ~count:5_000 ~stats:[len] Gen.(small_array int) (fun _ -> true); + Test.make ~name:"array_size len dist" ~count:5_000 ~stats:[len] Gen.(array_size (int_range 5 10) int) (fun _ -> true); + Test.make ~name:"array_repeat len dist" ~count:5_000 ~stats:[len] Gen.(array_repeat 42 int) (fun _ -> true); ] let int_dist_tests = - let open QCheck2 in let dist = ("dist",fun x -> x) in [ (* test from issue #40 *) @@ -251,9 +237,8 @@ module Stats = struct ] let int_dist_empty_bucket = - let open QCheck2 in - Test.make ~name:"int_dist_empty_bucket" ~count:1_000 - ~stats:[("dist",fun x -> x)] Gen.(oneof [small_int_corners ();int]) (fun _ -> true) + Test.make ~name:"int_dist_empty_bucket" ~count:1_000 ~stats:[("dist",fun x -> x)] + Gen.(oneof [small_int_corners ();int]) (fun _ -> true) end (* Calling runners *) @@ -271,8 +256,8 @@ let _ = Generator.char_dist_issue_23; Generator.list_repeat_test; Generator.array_repeat_test; - Function.fun1; - Function.fun2; + Function.fail_pred_map_commute; + Function.fail_pred_strings; Function.prop_foldleft_foldright; Function.prop_foldleft_foldright_uncurry; Function.prop_foldleft_foldright_uncurry_funlast; @@ -280,9 +265,11 @@ let _ = Shrink.big_bound_issue59; Shrink.long_shrink; Shrink.shrink_int; - ] @ FindExample.find_ex :: FindExample.find_ex_uncaught_issue_99 - @ [Stats.bool_dist; - Stats.char_dist] + FindExample.find_ex; + FindExample.find_ex_uncaught_issue_99_1_fail; + FindExample.find_ex_uncaught_issue_99_2_succeed; + Stats.bool_dist; + Stats.char_dist] @ Stats.list_len_tests @ Stats.array_len_tests @ Stats.int_dist_tests) diff --git a/test/core/QCheck_expect_test.ml b/test/core/QCheck_expect_test.ml index 80323556..d07b0030 100644 --- a/test/core/QCheck_expect_test.ml +++ b/test/core/QCheck_expect_test.ml @@ -2,55 +2,47 @@ (* tests of overall functionality *) module Overall = struct + open QCheck + let passing = - QCheck.Test.make ~count:100 ~long_factor:100 - ~name:"list_rev_is_involutive" - QCheck.(list small_int) - (fun l -> List.rev (List.rev l) = l) + Test.make ~name:"list_rev_is_involutive" ~count:100 ~long_factor:100 + (list small_int) (fun l -> List.rev (List.rev l) = l) let failing = - QCheck.Test.make ~count:10 - ~name:"should_fail_sort_id" - QCheck.(small_list small_int) - (fun l -> l = List.sort compare l) + Test.make ~name:"should_fail_sort_id" ~count:10 + (small_list small_int) (fun l -> l = List.sort compare l) exception Error let error = - QCheck.Test.make ~count:10 - ~name:"should_error_raise_exn" - QCheck.int - (fun _ -> raise Error) + Test.make ~name:"should_error_raise_exn" ~count:10 + int (fun _ -> raise Error) let collect = - QCheck.Test.make ~count:100 ~long_factor:100 - ~name:"collect_results" - QCheck.(make ~collect:string_of_int (Gen.int_bound 4)) + Test.make ~name:"collect_results" ~count:100 ~long_factor:100 + (make ~collect:string_of_int (Gen.int_bound 4)) (fun _ -> true) let stats = - QCheck.Test.make ~count:100 ~long_factor:100 - ~name:"with_stats" - QCheck.(make (Gen.int_bound 120) - ~stats:[ - "mod4", (fun i->i mod 4); - "num", (fun i->i); - ] - ) + Test.make ~name:"with_stats" ~count:100 ~long_factor:100 + (make (Gen.int_bound 120) + ~stats:[ + "mod4", (fun i->i mod 4); + "num", (fun i->i); + ]) (fun _ -> true) let bad_assume_warn = - QCheck.Test.make ~count:2_000 - ~name:"WARN_unlikely_precond" - QCheck.int + Test.make ~name:"WARN_unlikely_precond" ~count:2_000 + int (fun x -> QCheck.assume (x mod 100 = 1); true) let bad_assume_fail = - QCheck.Test.make ~count:2_000 ~if_assumptions_fail:(`Fatal, 0.1) - ~name:"FAIL_unlikely_precond" - QCheck.int + Test.make ~name:"FAIL_unlikely_precond" ~count:2_000 + ~if_assumptions_fail:(`Fatal, 0.1) + int (fun x -> QCheck.assume (x mod 100 = 1); true) @@ -58,18 +50,18 @@ end (* test various generators *) module Generator = struct + open QCheck + (* example from issue #23 *) let char_dist_issue_23 = - QCheck.Test.make ~name:"char never produces '\\255'" ~count:1_000_000 QCheck.char (fun c -> c <> '\255') + Test.make ~name:"char never produces '\\255'" ~count:1_000_000 char (fun c -> c <> '\255') let list_repeat_test = - let open QCheck in let gen = Gen.(small_nat >>= fun i -> list_repeat i unit >>= fun l -> return (i,l)) in Test.make ~name:"list_repeat has constant length" ~count:1000 (make ~print:Print.(pair int (list unit)) gen) (fun (i,l) -> List.length l = i) let array_repeat_test = - let open QCheck in let gen = Gen.(small_nat >>= fun i -> array_repeat i unit >>= fun l -> return (i,l)) in Test.make ~name:"array_repeat has constant length" ~count:1000 (make ~print:Print.(pair int (array unit)) gen) (fun (i,l) -> Array.length l = i) @@ -77,28 +69,26 @@ end (* tests function generator and shrinker *) module Function = struct - let fun1 = - QCheck.Test.make ~count:100 ~long_factor:100 - ~name:"FAIL_pred_map_commute" - QCheck.(triple - (small_list small_int) - (fun1 Observable.int int) - (fun1 Observable.int bool)) - (fun (l,QCheck.Fun (_,f), QCheck.Fun (_,p)) -> + open QCheck + + let fail_pred_map_commute = + Test.make ~name:"fail_pred_map_commute" ~count:100 ~long_factor:100 + (triple + (small_list small_int) + (fun1 Observable.int int) + (fun1 Observable.int bool)) + (fun (l,Fun (_,f),Fun (_,p)) -> List.filter p (List.map f l) = List.map f (List.filter p l)) - let fun2 = - QCheck.Test.make ~count:100 - ~name:"FAIL_fun2_pred_strings" - QCheck.(fun1 Observable.string bool) - (fun (QCheck.Fun (_,p)) -> - not (p "some random string") || p "some other string") + let fail_pred_strings = + Test.make ~name:"fail_pred_strings" ~count:100 + (fun1 Observable.string bool) + (fun (Fun (_,p)) -> not (p "some random string") || p "some other string") - let int_gen = QCheck.small_nat (* int *) + let int_gen = small_nat (* int *) (* Another example (false) property *) let prop_foldleft_foldright = - let open QCheck in Test.make ~name:"fold_left fold_right" ~count:1000 ~long_factor:20 (triple int_gen @@ -108,15 +98,14 @@ module Function = struct let l1 = List.fold_right (Fn.apply f) xs z in let l2 = List.fold_left (Fn.apply f) z xs in if l1=l2 then true - else QCheck.Test.fail_reportf "l=%s, fold_left=%s, fold_right=%s@." - (QCheck.Print.(list int) xs) - (QCheck.Print.int l1) - (QCheck.Print.int l2) + else Test.fail_reportf "l=%s, fold_left=%s, fold_right=%s@." + (Print.(list int) xs) + (Print.int l1) + (Print.int l2) ) (* Another example (false) property *) let prop_foldleft_foldright_uncurry = - let open QCheck in Test.make ~name:"fold_left fold_right uncurried" ~count:1000 ~long_factor:20 (triple (fun1 Observable.(pair int int) int_gen) @@ -128,7 +117,6 @@ module Function = struct (* Same as the above (false) property, but generating+shrinking functions last *) let prop_foldleft_foldright_uncurry_funlast = - let open QCheck in Test.make ~name:"fold_left fold_right uncurried fun last" ~count:1000 ~long_factor:20 (triple int_gen @@ -141,13 +129,14 @@ end (* tests of shrinking behaviour *) module Shrink = struct + open QCheck + let rec fac n = match n with | 0 -> 1 | n -> n * fac (n - 1) (* example from issue #59 *) let test_fac_issue59 = - let open QCheck in Test.make ~name:"test fac issue59" (set_shrink Shrink.nil (small_int_corners ())) (fun n -> try (fac n) mod n = 0 @@ -156,25 +145,25 @@ module Shrink = struct | Division_by_zero -> (n=0)) let big_bound_issue59 = - QCheck.Test.make ~name:"big bound issue59" - (QCheck.small_int_corners()) (fun i -> i < 209609) + Test.make ~name:"big bound issue59" + (small_int_corners()) (fun i -> i < 209609) let long_shrink = - let open QCheck in let listgen = list_of_size (Gen.int_range 1000 10000) int in Test.make ~name:"long_shrink" (pair listgen listgen) (fun (xs,ys) -> List.rev (xs@ys) = (List.rev xs)@(List.rev ys)) (* test shrinking on integers *) let shrink_int = - QCheck.Test.make ~count:1000 ~name:"mod3_should_fail" - QCheck.int (fun i -> i mod 3 <> 0) + Test.make ~name:"mod3_should_fail" ~count:1000 + int (fun i -> i mod 3 <> 0) end (* tests of (inner) find_example(_gen) behaviour *) module FindExample = struct + open QCheck + let find_ex = - let open QCheck in Test.make ~name:"find_example" (2--50) (fun n -> let st = Random.State.make [| 0 |] in @@ -184,49 +173,44 @@ module FindExample = struct f m with No_example_found _ -> false) - let find_ex_uncaught_issue_99 : _ list = - let open QCheck in - let t1 = - let rs = make (find_example ~count:10 ~f:(fun _ -> false) Gen.int) in - Test.make ~name:"FAIL_#99_1" rs (fun _ -> true) in - let t2 = - Test.make ~name:"should_succeed_#99_2" ~count:10 int - (fun i -> i <= max_int) in - [t1;t2] + let find_ex_uncaught_issue_99_1_fail = + let rs = make (find_example ~count:10 ~f:(fun _ -> false) Gen.int) in + Test.make ~name:"FAIL_#99_1" rs (fun _ -> true) + + let find_ex_uncaught_issue_99_2_succeed = + Test.make ~name:"should_succeed_#99_2" ~count:10 + int (fun i -> i <= max_int) end (* tests of statistics and histogram display *) module Stats = struct + open QCheck + let bool_dist = - QCheck.(Test.make ~count:500_000 ~name:"bool dist" - (set_collect Bool.to_string bool)) (fun _ -> true) + Test.make ~name:"bool dist" ~count:500_000 (set_collect Bool.to_string bool) (fun _ -> true) let char_dist = - QCheck.(Test.make ~count:500_000 ~name:"char code dist" - (add_stat ("char code", Char.code) char)) (fun _ -> true) + Test.make ~name:"char code dist" ~count:500_000 (add_stat ("char code", Char.code) char) (fun _ -> true) let list_len_tests = - let open QCheck in let len = ("len",List.length) in [ (* test from issue #30 *) - Test.make ~count:5_000 ~name:"list len dist" (add_stat len (list int)) (fun _ -> true); - Test.make ~count:5_000 ~name:"small_list len dist" (add_stat len (small_list int)) (fun _ -> true); - Test.make ~count:5_000 ~name:"list_of_size len dist" (add_stat len (list_of_size (Gen.int_range 5 10) int)) (fun _ -> true); - Test.make ~count:5_000 ~name:"list_repeat len dist" (add_stat len (make Gen.(list_repeat 42 int))) (fun _ -> true); + Test.make ~name:"list len dist" ~count:5_000 (add_stat len (list int)) (fun _ -> true); + Test.make ~name:"small_list len dist" ~count:5_000 (add_stat len (small_list int)) (fun _ -> true); + Test.make ~name:"list_of_size len dist" ~count:5_000 (add_stat len (list_of_size (Gen.int_range 5 10) int)) (fun _ -> true); + Test.make ~name:"list_repeat len dist" ~count:5_000 (add_stat len (make Gen.(list_repeat 42 int))) (fun _ -> true); ] let array_len_tests = - let open QCheck in let len = ("len",Array.length) in [ - Test.make ~count:5_000 ~name:"array len dist" (add_stat len (array int)) (fun _ -> true); - Test.make ~count:5_000 ~name:"small_array len dist" (add_stat len (make Gen.(small_array int))) (fun _ -> true); - Test.make ~count:5_000 ~name:"array_of_size len dist" (add_stat len (array_of_size (Gen.int_range 5 10) int)) (fun _ -> true); - Test.make ~count:5_000 ~name:"array_repeat len dist" (add_stat len (make Gen.(array_repeat 42 int))) (fun _ -> true); + Test.make ~name:"array len dist" ~count:5_000 (add_stat len (array int)) (fun _ -> true); + Test.make ~name:"small_array len dist" ~count:5_000 (add_stat len (make Gen.(small_array int))) (fun _ -> true); + Test.make ~name:"array_of_size len dist" ~count:5_000 (add_stat len (array_of_size (Gen.int_range 5 10) int)) (fun _ -> true); + Test.make ~name:"array_repeat len dist" ~count:5_000 (add_stat len (make Gen.(array_repeat 42 int))) (fun _ -> true); ] let int_dist_tests = - let open QCheck in let dist = ("dist",fun x -> x) in [ (* test from issue #40 *) Test.make ~name:"int_stats_neg" ~count:5000 (add_stat dist small_signed_int) (fun _ -> true); @@ -242,7 +226,6 @@ module Stats = struct ] let int_dist_empty_bucket = - let open QCheck in Test.make ~name:"int_dist_empty_bucket" ~count:1_000 (add_stat ("dist",fun x -> x) (oneof [small_int_corners ();int])) (fun _ -> true) end @@ -262,8 +245,8 @@ let i = Generator.char_dist_issue_23; Generator.list_repeat_test; Generator.array_repeat_test; - Function.fun1; - Function.fun2; + Function.fail_pred_map_commute; + Function.fail_pred_strings; Function.prop_foldleft_foldright; Function.prop_foldleft_foldright_uncurry; Function.prop_foldleft_foldright_uncurry_funlast; @@ -271,9 +254,11 @@ let i = Shrink.big_bound_issue59; Shrink.long_shrink; Shrink.shrink_int; - ] @ FindExample.find_ex :: FindExample.find_ex_uncaught_issue_99 - @ [Stats.bool_dist; - Stats.char_dist] + FindExample.find_ex; + FindExample.find_ex_uncaught_issue_99_1_fail; + FindExample.find_ex_uncaught_issue_99_2_succeed; + Stats.bool_dist; + Stats.char_dist] @ Stats.list_len_tests @ Stats.array_len_tests @ Stats.int_dist_tests) diff --git a/test/core/qcheck2_output.txt.expected b/test/core/qcheck2_output.txt.expected index 2a9836d6..0cd6c9d1 100644 --- a/test/core/qcheck2_output.txt.expected +++ b/test/core/qcheck2_output.txt.expected @@ -82,13 +82,13 @@ Test char never produces '\255' failed (0 shrink steps): --- Failure -------------------------------------------------------------------- -Test FAIL_pred_map_commute failed (16 shrink steps): +Test fail_pred_map_commute failed (16 shrink steps): ([2], {_ -> 0}, {1 -> false; 2 -> true; _ -> false}) --- Failure -------------------------------------------------------------------- -Test FAIL_fun2_pred_strings failed (1 shrink steps): +Test fail_pred_strings failed (1 shrink steps): {"some random string" -> true; _ -> false} diff --git a/test/core/qcheck_output.txt.expected b/test/core/qcheck_output.txt.expected index 725031c2..70a9ec09 100644 --- a/test/core/qcheck_output.txt.expected +++ b/test/core/qcheck_output.txt.expected @@ -82,13 +82,13 @@ Test char never produces '\255' failed (0 shrink steps): --- Failure -------------------------------------------------------------------- -Test FAIL_pred_map_commute failed (127 shrink steps): +Test fail_pred_map_commute failed (127 shrink steps): ([3], {_ -> 0}, {3 -> false; _ -> true}) --- Failure -------------------------------------------------------------------- -Test FAIL_fun2_pred_strings failed (1 shrink steps): +Test fail_pred_strings failed (1 shrink steps): {some random string -> true; _ -> false} From fa0ac0500acd6fd58bfa46a64e03e5ab2220bbd9 Mon Sep 17 00:00:00 2001 From: Jan Midtgaard Date: Thu, 12 Aug 2021 15:46:50 +0200 Subject: [PATCH 19/49] add string dist tests --- test/core/QCheck2_expect_test.ml | 11 +++ test/core/QCheck_expect_test.ml | 11 +++ test/core/qcheck2_output.txt.expected | 113 +++++++++++++++++++++++++- test/core/qcheck_output.txt.expected | 113 +++++++++++++++++++++++++- 4 files changed, 246 insertions(+), 2 deletions(-) diff --git a/test/core/QCheck2_expect_test.ml b/test/core/QCheck2_expect_test.ml index 8e2a91b9..d27852d0 100644 --- a/test/core/QCheck2_expect_test.ml +++ b/test/core/QCheck2_expect_test.ml @@ -202,6 +202,16 @@ module Stats = struct let char_dist = Test.make ~name:"char code dist" ~count:500_000 ~stats:[("char code", Char.code)] Gen.char (fun _ -> true) + let string_len_tests = + let len = ("len",String.length) in + [ + Test.make ~name:"string_size len dist" ~count:5_000 ~stats:[len] Gen.(string_size (int_range 5 10)) (fun _ -> true); + Test.make ~name:"string len dist" ~count:5_000 ~stats:[len] Gen.string (fun _ -> true); + Test.make ~name:"string_of len dist" ~count:5_000 ~stats:[len] Gen.(string_of (return 'a')) (fun _ -> true); + Test.make ~name:"string_readable len dist" ~count:5_000 ~stats:[len] Gen.string_readable (fun _ -> true); + Test.make ~name:"small_string len dist" ~count:5_000 ~stats:[len] Gen.(small_string ~gen:char)(*ugh*)(fun _ -> true); + ] + let list_len_tests = let len = ("len",List.length) in [ (* test from issue #30 *) @@ -270,6 +280,7 @@ let _ = FindExample.find_ex_uncaught_issue_99_2_succeed; Stats.bool_dist; Stats.char_dist] + @ Stats.string_len_tests @ Stats.list_len_tests @ Stats.array_len_tests @ Stats.int_dist_tests) diff --git a/test/core/QCheck_expect_test.ml b/test/core/QCheck_expect_test.ml index d07b0030..a0855826 100644 --- a/test/core/QCheck_expect_test.ml +++ b/test/core/QCheck_expect_test.ml @@ -192,6 +192,16 @@ module Stats = struct let char_dist = Test.make ~name:"char code dist" ~count:500_000 (add_stat ("char code", Char.code) char) (fun _ -> true) + let string_len_tests = + let len = ("len",String.length) in + [ + Test.make ~name:"string_size len dist" ~count:5_000 (add_stat len (string_of_size (Gen.int_range 5 10))) (fun _ -> true); + Test.make ~name:"string len dist" ~count:5_000 (add_stat len string) (fun _ -> true); + Test.make ~name:"string_of len dist" ~count:5_000 (add_stat len (string_gen (Gen.return 'a'))) (fun _ -> true); + Test.make ~name:"printable_string len dist" ~count:5_000 (add_stat len printable_string) (fun _ -> true); + Test.make ~name:"small_string len dist" ~count:5_000 (add_stat len small_string) (fun _ -> true); + ] + let list_len_tests = let len = ("len",List.length) in [ (* test from issue #30 *) @@ -259,6 +269,7 @@ let i = FindExample.find_ex_uncaught_issue_99_2_succeed; Stats.bool_dist; Stats.char_dist] + @ Stats.string_len_tests @ Stats.list_len_tests @ Stats.array_len_tests @ Stats.int_dist_tests) diff --git a/test/core/qcheck2_output.txt.expected b/test/core/qcheck2_output.txt.expected index 0cd6c9d1..b843092f 100644 --- a/test/core/qcheck2_output.txt.expected +++ b/test/core/qcheck2_output.txt.expected @@ -175,6 +175,117 @@ stats char code: 234..246: ###################################################### 25567 247..259: ##################################### 17709 ++++ Stats for string_size len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats len: + num: 5000, avg: 7.49, stddev: 1.70, median 7, min 5, max 10 + 5: ##################################################### 837 + 6: ##################################################### 826 + 7: ###################################################### 843 + 8: ####################################################### 855 + 9: #################################################### 813 + 10: ##################################################### 826 + ++++ Stats for string len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats len: + num: 5000, avg: 384.53, stddev: 1330.61, median 9, min 0, max 9969 + 0.. 498: ####################################################### 4246 + 499.. 997: ###### 518 + 998..1496: 21 + 1497..1995: 10 + 1996..2494: 11 + 2495..2993: 10 + 2994..3492: 13 + 3493..3991: 13 + 3992..4490: 5 + 4491..4989: 10 + 4990..5488: 19 + 5489..5987: 9 + 5988..6486: 10 + 6487..6985: 12 + 6986..7484: 17 + 7485..7983: 16 + 7984..8482: 16 + 8483..8981: 16 + 8982..9480: 16 + 9481..9979: 12 + ++++ Stats for string_of len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats len: + num: 5000, avg: 363.14, stddev: 1245.80, median 9, min 0, max 9986 + 0.. 499: ####################################################### 4270 + 500.. 999: ###### 493 + 1000.. 1499: 16 + 1500.. 1999: 11 + 2000.. 2499: 15 + 2500.. 2999: 17 + 3000.. 3499: 11 + 3500.. 3999: 19 + 4000.. 4499: 14 + 4500.. 4999: 10 + 5000.. 5499: 16 + 5500.. 5999: 11 + 6000.. 6499: 15 + 6500.. 6999: 13 + 7000.. 7499: 12 + 7500.. 7999: 16 + 8000.. 8499: 11 + 8500.. 8999: 4 + 9000.. 9499: 13 + 9500.. 9999: 13 + ++++ Stats for string_readable len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats len: + num: 5000, avg: 384.53, stddev: 1330.61, median 9, min 0, max 9969 + 0.. 498: ####################################################### 4246 + 499.. 997: ###### 518 + 998..1496: 21 + 1497..1995: 10 + 1996..2494: 11 + 2495..2993: 10 + 2994..3492: 13 + 3493..3991: 13 + 3992..4490: 5 + 4491..4989: 10 + 4990..5488: 19 + 5489..5987: 9 + 5988..6486: 10 + 6487..6985: 12 + 6986..7484: 17 + 7485..7983: 16 + 7984..8482: 16 + 8483..8981: 16 + 8982..9480: 16 + 9481..9979: 12 + ++++ Stats for small_string len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats len: + num: 5000, avg: 15.57, stddev: 24.36, median 6, min 0, max 99 + 0.. 4: #################################################### 1925 + 5.. 9: ####################################################### 2005 + 10.. 14: # 52 + 15.. 19: # 50 + 20.. 24: # 55 + 25.. 29: # 56 + 30.. 34: # 55 + 35.. 39: # 49 + 40.. 44: # 65 + 45.. 49: # 65 + 50.. 54: # 55 + 55.. 59: # 68 + 60.. 64: # 61 + 65.. 69: # 65 + 70.. 74: # 57 + 75.. 79: # 66 + 80.. 84: # 65 + 85.. 89: # 64 + 90.. 94: # 60 + 95.. 99: # 62 + +++ Stats for list len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: @@ -525,7 +636,7 @@ stats dist: -4611686018427387392..-4150517416584648577: 0 ================================================================================ 1 warning(s) -failure (12 tests failed, 1 tests errored, ran 40 tests) +failure (12 tests failed, 1 tests errored, ran 45 tests) random seed: 153870556 +++ Stats for int_dist_empty_bucket ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ diff --git a/test/core/qcheck_output.txt.expected b/test/core/qcheck_output.txt.expected index 70a9ec09..5b054aaa 100644 --- a/test/core/qcheck_output.txt.expected +++ b/test/core/qcheck_output.txt.expected @@ -175,6 +175,117 @@ stats char code: 234..246: ###################################################### 25567 247..259: ##################################### 17709 ++++ Stats for string_size len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats len: + num: 5000, avg: 7.49, stddev: 1.70, median 7, min 5, max 10 + 5: ##################################################### 837 + 6: ##################################################### 826 + 7: ###################################################### 843 + 8: ####################################################### 855 + 9: #################################################### 813 + 10: ##################################################### 826 + ++++ Stats for string len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats len: + num: 5000, avg: 384.53, stddev: 1330.61, median 9, min 0, max 9969 + 0.. 498: ####################################################### 4246 + 499.. 997: ###### 518 + 998..1496: 21 + 1497..1995: 10 + 1996..2494: 11 + 2495..2993: 10 + 2994..3492: 13 + 3493..3991: 13 + 3992..4490: 5 + 4491..4989: 10 + 4990..5488: 19 + 5489..5987: 9 + 5988..6486: 10 + 6487..6985: 12 + 6986..7484: 17 + 7485..7983: 16 + 7984..8482: 16 + 8483..8981: 16 + 8982..9480: 16 + 9481..9979: 12 + ++++ Stats for string_of len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats len: + num: 5000, avg: 363.14, stddev: 1245.80, median 9, min 0, max 9986 + 0.. 499: ####################################################### 4270 + 500.. 999: ###### 493 + 1000.. 1499: 16 + 1500.. 1999: 11 + 2000.. 2499: 15 + 2500.. 2999: 17 + 3000.. 3499: 11 + 3500.. 3999: 19 + 4000.. 4499: 14 + 4500.. 4999: 10 + 5000.. 5499: 16 + 5500.. 5999: 11 + 6000.. 6499: 15 + 6500.. 6999: 13 + 7000.. 7499: 12 + 7500.. 7999: 16 + 8000.. 8499: 11 + 8500.. 8999: 4 + 9000.. 9499: 13 + 9500.. 9999: 13 + ++++ Stats for printable_string len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats len: + num: 5000, avg: 384.53, stddev: 1330.61, median 9, min 0, max 9969 + 0.. 498: ####################################################### 4246 + 499.. 997: ###### 518 + 998..1496: 21 + 1497..1995: 10 + 1996..2494: 11 + 2495..2993: 10 + 2994..3492: 13 + 3493..3991: 13 + 3992..4490: 5 + 4491..4989: 10 + 4990..5488: 19 + 5489..5987: 9 + 5988..6486: 10 + 6487..6985: 12 + 6986..7484: 17 + 7485..7983: 16 + 7984..8482: 16 + 8483..8981: 16 + 8982..9480: 16 + 9481..9979: 12 + ++++ Stats for small_string len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats len: + num: 5000, avg: 15.57, stddev: 24.36, median 6, min 0, max 99 + 0.. 4: #################################################### 1925 + 5.. 9: ####################################################### 2005 + 10.. 14: # 52 + 15.. 19: # 50 + 20.. 24: # 55 + 25.. 29: # 56 + 30.. 34: # 55 + 35.. 39: # 49 + 40.. 44: # 65 + 45.. 49: # 65 + 50.. 54: # 55 + 55.. 59: # 68 + 60.. 64: # 61 + 65.. 69: # 65 + 70.. 74: # 57 + 75.. 79: # 66 + 80.. 84: # 65 + 85.. 89: # 64 + 90.. 94: # 60 + 95.. 99: # 62 + +++ Stats for list len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: @@ -525,7 +636,7 @@ stats dist: -4611686018427387392..-4150517416584648577: 0 ================================================================================ 1 warning(s) -failure (12 tests failed, 1 tests errored, ran 40 tests) +failure (12 tests failed, 1 tests errored, ran 45 tests) random seed: 153870556 +++ Stats for int_dist_empty_bucket ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ From 51075bff3a2bde88e4984a207ec79ce64038840f Mon Sep 17 00:00:00 2001 From: Jan Midtgaard Date: Thu, 12 Aug 2021 16:09:47 +0200 Subject: [PATCH 20/49] add false string tests --- test/core/QCheck2_expect_test.ml | 22 ++++++++++++++++++++++ test/core/QCheck_expect_test.ml | 22 ++++++++++++++++++++++ test/core/qcheck2_output.txt.expected | 14 +++++++++++++- test/core/qcheck_output.txt.expected | 14 +++++++++++++- 4 files changed, 70 insertions(+), 2 deletions(-) diff --git a/test/core/QCheck2_expect_test.ml b/test/core/QCheck2_expect_test.ml index d27852d0..2bcbd102 100644 --- a/test/core/QCheck2_expect_test.ml +++ b/test/core/QCheck2_expect_test.ml @@ -58,6 +58,25 @@ module Generator = struct ~print:Print.char Gen.char (fun c -> c <> '\255') + let string_test = + Test.make ~name:"string has right length and content" ~count:1000 ~print:Print.string + Gen.string + (fun s -> + let len = String.length s in + 0 <= len && len < 10000 + && String.to_seq s |> + Seq.fold_left (fun acc c -> acc && '\000' <= c && c <= '\255') true) + + let string_never_has_000_char = + Test.make ~name:"string never has a \\000 char" ~count:1000 ~print:Print.string + Gen.string + (fun s -> String.to_seq s |> Seq.fold_left (fun acc c -> acc && c <> '\000') true) + + let string_never_has_255_char = + Test.make ~name:"string never has a \\255 char" ~count:1000 ~print:Print.string + Gen.string + (fun s -> String.to_seq s |> Seq.fold_left (fun acc c -> acc && c <> '\255') true) + let list_repeat_test = Test.make ~name:"list_repeat has constant length" ~count:1000 ~print:Print.(pair int (list unit)) @@ -264,6 +283,9 @@ let _ = Overall.bad_assume_warn; Overall.bad_assume_fail; Generator.char_dist_issue_23; + Generator.string_test; + Generator.string_never_has_000_char; + Generator.string_never_has_255_char; Generator.list_repeat_test; Generator.array_repeat_test; Function.fail_pred_map_commute; diff --git a/test/core/QCheck_expect_test.ml b/test/core/QCheck_expect_test.ml index a0855826..de7f68d6 100644 --- a/test/core/QCheck_expect_test.ml +++ b/test/core/QCheck_expect_test.ml @@ -56,6 +56,25 @@ module Generator = struct let char_dist_issue_23 = Test.make ~name:"char never produces '\\255'" ~count:1_000_000 char (fun c -> c <> '\255') + let string_test = + Test.make ~name:"string has right length and content" ~count:1000 + string + (fun s -> + let len = String.length s in + 0 <= len && len < 10000 + && String.to_seq s |> + Seq.fold_left (fun acc c -> acc && '\000' <= c && c <= '\255') true) + + let string_never_has_000_char = + Test.make ~name:"string never has a \\000 char" ~count:1000 + string + (fun s -> String.to_seq s |> Seq.fold_left (fun acc c -> acc && c <> '\000') true) + + let string_never_has_255_char = + Test.make ~name:"string never has a \\255 char" ~count:1000 + string + (fun s -> String.to_seq s |> Seq.fold_left (fun acc c -> acc && c <> '\255') true) + let list_repeat_test = let gen = Gen.(small_nat >>= fun i -> list_repeat i unit >>= fun l -> return (i,l)) in Test.make ~name:"list_repeat has constant length" ~count:1000 @@ -253,6 +272,9 @@ let i = Overall.bad_assume_warn; Overall.bad_assume_fail; Generator.char_dist_issue_23; + Generator.string_test; + Generator.string_never_has_000_char; + Generator.string_never_has_255_char; Generator.list_repeat_test; Generator.array_repeat_test; Function.fail_pred_map_commute; diff --git a/test/core/qcheck2_output.txt.expected b/test/core/qcheck2_output.txt.expected index b843092f..33cbc537 100644 --- a/test/core/qcheck2_output.txt.expected +++ b/test/core/qcheck2_output.txt.expected @@ -82,6 +82,18 @@ Test char never produces '\255' failed (0 shrink steps): --- Failure -------------------------------------------------------------------- +Test string never has a \000 char failed (22 shrink steps): + +"aaaaaa\000aaaaaaaaaaaaaaaa" + +--- Failure -------------------------------------------------------------------- + +Test string never has a \255 char failed (59 shrink steps): + +"aaaaaaaaaaaaaaaaaaaaaaaaaa\255aaaaaaaaaaaaaaaaaaaaaaaa" + +--- Failure -------------------------------------------------------------------- + Test fail_pred_map_commute failed (16 shrink steps): ([2], {_ -> 0}, {1 -> false; 2 -> true; _ -> false}) @@ -636,7 +648,7 @@ stats dist: -4611686018427387392..-4150517416584648577: 0 ================================================================================ 1 warning(s) -failure (12 tests failed, 1 tests errored, ran 45 tests) +failure (14 tests failed, 1 tests errored, ran 48 tests) random seed: 153870556 +++ Stats for int_dist_empty_bucket ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ diff --git a/test/core/qcheck_output.txt.expected b/test/core/qcheck_output.txt.expected index 5b054aaa..344536ce 100644 --- a/test/core/qcheck_output.txt.expected +++ b/test/core/qcheck_output.txt.expected @@ -82,6 +82,18 @@ Test char never produces '\255' failed (0 shrink steps): --- Failure -------------------------------------------------------------------- +Test string never has a \000 char failed (25 shrink steps): + +"\000" + +--- Failure -------------------------------------------------------------------- + +Test string never has a \255 char failed (249 shrink steps): + +"\255" + +--- Failure -------------------------------------------------------------------- + Test fail_pred_map_commute failed (127 shrink steps): ([3], {_ -> 0}, {3 -> false; _ -> true}) @@ -636,7 +648,7 @@ stats dist: -4611686018427387392..-4150517416584648577: 0 ================================================================================ 1 warning(s) -failure (12 tests failed, 1 tests errored, ran 45 tests) +failure (14 tests failed, 1 tests errored, ran 48 tests) random seed: 153870556 +++ Stats for int_dist_empty_bucket ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ From c206713edf8027d06b35053a71a9f41ede4fe65f Mon Sep 17 00:00:00 2001 From: Jan Midtgaard Date: Fri, 13 Aug 2021 12:45:25 +0200 Subject: [PATCH 21/49] restructure tests into positive (Generator) / negative (Shrink) --- test/core/QCheck2_expect_test.ml | 100 +++++++++++++------------- test/core/QCheck_expect_test.ml | 98 ++++++++++++------------- test/core/qcheck2_output.txt.expected | 36 +++++----- test/core/qcheck_output.txt.expected | 36 +++++----- 4 files changed, 135 insertions(+), 135 deletions(-) diff --git a/test/core/QCheck2_expect_test.ml b/test/core/QCheck2_expect_test.ml index 2bcbd102..415290d6 100644 --- a/test/core/QCheck2_expect_test.ml +++ b/test/core/QCheck2_expect_test.ml @@ -48,7 +48,7 @@ module Overall = struct true) end -(* test various generators *) +(* positive tests of the various generators *) module Generator = struct open QCheck2 @@ -67,16 +67,6 @@ module Generator = struct && String.to_seq s |> Seq.fold_left (fun acc c -> acc && '\000' <= c && c <= '\255') true) - let string_never_has_000_char = - Test.make ~name:"string never has a \\000 char" ~count:1000 ~print:Print.string - Gen.string - (fun s -> String.to_seq s |> Seq.fold_left (fun acc c -> acc && c <> '\000') true) - - let string_never_has_255_char = - Test.make ~name:"string never has a \\255 char" ~count:1000 ~print:Print.string - Gen.string - (fun s -> String.to_seq s |> Seq.fold_left (fun acc c -> acc && c <> '\255') true) - let list_repeat_test = Test.make ~name:"list_repeat has constant length" ~count:1000 ~print:Print.(pair int (list unit)) @@ -90,6 +80,49 @@ module Generator = struct (fun (i,l) -> Array.length l = i) end +(* negative tests that exercise shrinking behaviour *) +module Shrink = struct + open QCheck2 + + let rec fac n = match n with + | 0 -> 1 + | n -> n * fac (n - 1) + + (* example from issue #59 *) + let test_fac_issue59 = + Test.make ~name:"test fac issue59" + (Gen.make_primitive ~gen:(fun st -> Gen.generate1 ~rand:st (Gen.small_int_corners ())) ~shrink:(fun _ -> Seq.empty)) + (fun n -> try (fac n) mod n = 0 + with + (*| Stack_overflow -> false*) + | Division_by_zero -> (n=0)) + + let big_bound_issue59 = + Test.make ~name:"big bound issue59" ~print:Print.int + (Gen.small_int_corners()) (fun i -> i < 209609) + + let long_shrink = + let listgen = Gen.(list_size (int_range 1000 10000) int) in + Test.make ~name:"long_shrink" ~print:Print.(pair (list int) (list int)) + (Gen.pair listgen listgen) + (fun (xs,ys) -> List.rev (xs@ys) = (List.rev xs)@(List.rev ys)) + + (* test shrinking on integers *) + let shrink_int = + Test.make ~name:"mod3_should_fail" ~count:1000 ~print:Print.int + Gen.int (fun i -> i mod 3 <> 0) + + let string_never_has_000_char = + Test.make ~name:"string never has a \\000 char" ~count:1000 ~print:Print.string + Gen.string + (fun s -> String.to_seq s |> Seq.fold_left (fun acc c -> acc && c <> '\000') true) + + let string_never_has_255_char = + Test.make ~name:"string never has a \\255 char" ~count:1000 ~print:Print.string + Gen.string + (fun s -> String.to_seq s |> Seq.fold_left (fun acc c -> acc && c <> '\255') true) +end + (* tests function generator and shrinker *) module Function = struct open QCheck2 @@ -154,39 +187,6 @@ module Function = struct List.fold_left (fun x y -> Fn.apply f (x,y)) z xs) end -(* tests of shrinking behaviour *) -module Shrink = struct - open QCheck2 - - let rec fac n = match n with - | 0 -> 1 - | n -> n * fac (n - 1) - - (* example from issue #59 *) - let test_fac_issue59 = - Test.make ~name:"test fac issue59" - (Gen.make_primitive ~gen:(fun st -> Gen.generate1 ~rand:st (Gen.small_int_corners ())) ~shrink:(fun _ -> Seq.empty)) - (fun n -> try (fac n) mod n = 0 - with - (*| Stack_overflow -> false*) - | Division_by_zero -> (n=0)) - - let big_bound_issue59 = - Test.make ~name:"big bound issue59" ~print:Print.int - (Gen.small_int_corners()) (fun i -> i < 209609) - - let long_shrink = - let listgen = Gen.(list_size (int_range 1000 10000) int) in - Test.make ~name:"long_shrink" ~print:Print.(pair (list int) (list int)) - (Gen.pair listgen listgen) - (fun (xs,ys) -> List.rev (xs@ys) = (List.rev xs)@(List.rev ys)) - - (* test shrinking on integers *) - let shrink_int = - Test.make ~name:"mod3_should_fail" ~count:1000 ~print:Print.int - Gen.int (fun i -> i mod 3 <> 0) -end - (* tests of (inner) find_example(_gen) behaviour *) module FindExample = struct open QCheck2 @@ -284,19 +284,19 @@ let _ = Overall.bad_assume_fail; Generator.char_dist_issue_23; Generator.string_test; - Generator.string_never_has_000_char; - Generator.string_never_has_255_char; Generator.list_repeat_test; Generator.array_repeat_test; + (*Shrink.test_fac_issue59;*) + Shrink.big_bound_issue59; + Shrink.long_shrink; + Shrink.shrink_int; + Shrink.string_never_has_000_char; + Shrink.string_never_has_255_char; Function.fail_pred_map_commute; Function.fail_pred_strings; Function.prop_foldleft_foldright; Function.prop_foldleft_foldright_uncurry; Function.prop_foldleft_foldright_uncurry_funlast; - (*Shrink.test_fac_issue59;*) - Shrink.big_bound_issue59; - Shrink.long_shrink; - Shrink.shrink_int; FindExample.find_ex; FindExample.find_ex_uncaught_issue_99_1_fail; FindExample.find_ex_uncaught_issue_99_2_succeed; diff --git a/test/core/QCheck_expect_test.ml b/test/core/QCheck_expect_test.ml index de7f68d6..5f204eac 100644 --- a/test/core/QCheck_expect_test.ml +++ b/test/core/QCheck_expect_test.ml @@ -48,7 +48,7 @@ module Overall = struct true) end -(* test various generators *) +(* positive tests of the various generators *) module Generator = struct open QCheck @@ -65,16 +65,6 @@ module Generator = struct && String.to_seq s |> Seq.fold_left (fun acc c -> acc && '\000' <= c && c <= '\255') true) - let string_never_has_000_char = - Test.make ~name:"string never has a \\000 char" ~count:1000 - string - (fun s -> String.to_seq s |> Seq.fold_left (fun acc c -> acc && c <> '\000') true) - - let string_never_has_255_char = - Test.make ~name:"string never has a \\255 char" ~count:1000 - string - (fun s -> String.to_seq s |> Seq.fold_left (fun acc c -> acc && c <> '\255') true) - let list_repeat_test = let gen = Gen.(small_nat >>= fun i -> list_repeat i unit >>= fun l -> return (i,l)) in Test.make ~name:"list_repeat has constant length" ~count:1000 @@ -86,6 +76,48 @@ module Generator = struct (make ~print:Print.(pair int (array unit)) gen) (fun (i,l) -> Array.length l = i) end +(* negative tests that exercise shrinking behaviour *) +module Shrink = struct + open QCheck + + let rec fac n = match n with + | 0 -> 1 + | n -> n * fac (n - 1) + + (* example from issue #59 *) + let test_fac_issue59 = + Test.make ~name:"test fac issue59" + (set_shrink Shrink.nil (small_int_corners ())) + (fun n -> try (fac n) mod n = 0 + with + (*| Stack_overflow -> false*) + | Division_by_zero -> (n=0)) + + let big_bound_issue59 = + Test.make ~name:"big bound issue59" + (small_int_corners()) (fun i -> i < 209609) + + let long_shrink = + let listgen = list_of_size (Gen.int_range 1000 10000) int in + Test.make ~name:"long_shrink" (pair listgen listgen) + (fun (xs,ys) -> List.rev (xs@ys) = (List.rev xs)@(List.rev ys)) + + (* test shrinking on integers *) + let shrink_int = + Test.make ~name:"mod3_should_fail" ~count:1000 + int (fun i -> i mod 3 <> 0) + + let string_never_has_000_char = + Test.make ~name:"string never has a \\000 char" ~count:1000 + string + (fun s -> String.to_seq s |> Seq.fold_left (fun acc c -> acc && c <> '\000') true) + + let string_never_has_255_char = + Test.make ~name:"string never has a \\255 char" ~count:1000 + string + (fun s -> String.to_seq s |> Seq.fold_left (fun acc c -> acc && c <> '\255') true) +end + (* tests function generator and shrinker *) module Function = struct open QCheck @@ -146,38 +178,6 @@ module Function = struct List.fold_left (fun x y -> Fn.apply f (x,y)) z xs) end -(* tests of shrinking behaviour *) -module Shrink = struct - open QCheck - - let rec fac n = match n with - | 0 -> 1 - | n -> n * fac (n - 1) - - (* example from issue #59 *) - let test_fac_issue59 = - Test.make ~name:"test fac issue59" - (set_shrink Shrink.nil (small_int_corners ())) - (fun n -> try (fac n) mod n = 0 - with - (*| Stack_overflow -> false*) - | Division_by_zero -> (n=0)) - - let big_bound_issue59 = - Test.make ~name:"big bound issue59" - (small_int_corners()) (fun i -> i < 209609) - - let long_shrink = - let listgen = list_of_size (Gen.int_range 1000 10000) int in - Test.make ~name:"long_shrink" (pair listgen listgen) - (fun (xs,ys) -> List.rev (xs@ys) = (List.rev xs)@(List.rev ys)) - - (* test shrinking on integers *) - let shrink_int = - Test.make ~name:"mod3_should_fail" ~count:1000 - int (fun i -> i mod 3 <> 0) -end - (* tests of (inner) find_example(_gen) behaviour *) module FindExample = struct open QCheck @@ -273,19 +273,19 @@ let i = Overall.bad_assume_fail; Generator.char_dist_issue_23; Generator.string_test; - Generator.string_never_has_000_char; - Generator.string_never_has_255_char; Generator.list_repeat_test; Generator.array_repeat_test; + (*Shrink.test_fac_issue59;*) + Shrink.big_bound_issue59; + Shrink.long_shrink; + Shrink.shrink_int; + Shrink.string_never_has_000_char; + Shrink.string_never_has_255_char; Function.fail_pred_map_commute; Function.fail_pred_strings; Function.prop_foldleft_foldright; Function.prop_foldleft_foldright_uncurry; Function.prop_foldleft_foldright_uncurry_funlast; - (*Shrink.test_fac_issue59;*) - Shrink.big_bound_issue59; - Shrink.long_shrink; - Shrink.shrink_int; FindExample.find_ex; FindExample.find_ex_uncaught_issue_99_1_fail; FindExample.find_ex_uncaught_issue_99_2_succeed; diff --git a/test/core/qcheck2_output.txt.expected b/test/core/qcheck2_output.txt.expected index 33cbc537..c0a2422d 100644 --- a/test/core/qcheck2_output.txt.expected +++ b/test/core/qcheck2_output.txt.expected @@ -82,6 +82,24 @@ Test char never produces '\255' failed (0 shrink steps): --- Failure -------------------------------------------------------------------- +Test big bound issue59 failed (0 shrink steps): + +4611686018427387903 + +--- Failure -------------------------------------------------------------------- + +Test long_shrink failed (3040 shrink steps): + +([0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 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 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 1]) + +--- Failure -------------------------------------------------------------------- + +Test mod3_should_fail failed (1 shrink steps): + +0 + +--- Failure -------------------------------------------------------------------- + Test string never has a \000 char failed (22 shrink steps): "aaaaaa\000aaaaaaaaaaaaaaaa" @@ -131,24 +149,6 @@ Test fold_left fold_right uncurried fun last failed (25 shrink steps): --- Failure -------------------------------------------------------------------- -Test big bound issue59 failed (0 shrink steps): - -4611686018427387903 - ---- Failure -------------------------------------------------------------------- - -Test long_shrink failed (3040 shrink steps): - -([0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 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 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 1]) - ---- Failure -------------------------------------------------------------------- - -Test mod3_should_fail failed (1 shrink steps): - -0 - ---- Failure -------------------------------------------------------------------- - Test FAIL_#99_1 failed: ERROR: uncaught exception in generator for test FAIL_#99_1 after 100 steps: diff --git a/test/core/qcheck_output.txt.expected b/test/core/qcheck_output.txt.expected index 344536ce..a427e47b 100644 --- a/test/core/qcheck_output.txt.expected +++ b/test/core/qcheck_output.txt.expected @@ -82,6 +82,24 @@ Test char never produces '\255' failed (0 shrink steps): --- Failure -------------------------------------------------------------------- +Test big bound issue59 failed (52 shrink steps): + +209609 + +--- Failure -------------------------------------------------------------------- + +Test long_shrink failed (149 shrink steps): + +([0], [-1]) + +--- Failure -------------------------------------------------------------------- + +Test mod3_should_fail failed (84 shrink steps): + +-21 + +--- Failure -------------------------------------------------------------------- + Test string never has a \000 char failed (25 shrink steps): "\000" @@ -131,24 +149,6 @@ Test fold_left fold_right uncurried fun last failed (26 shrink steps): --- Failure -------------------------------------------------------------------- -Test big bound issue59 failed (52 shrink steps): - -209609 - ---- Failure -------------------------------------------------------------------- - -Test long_shrink failed (149 shrink steps): - -([0], [-1]) - ---- Failure -------------------------------------------------------------------- - -Test mod3_should_fail failed (84 shrink steps): - --21 - ---- Failure -------------------------------------------------------------------- - Test FAIL_#99_1 failed: ERROR: uncaught exception in generator for test FAIL_#99_1 after 100 steps: From fed8815db278724c0961bacfc9134bb289bbdc9d Mon Sep 17 00:00:00 2001 From: Jan Midtgaard Date: Fri, 13 Aug 2021 13:25:29 +0200 Subject: [PATCH 22/49] add pos and neg char tests --- test/core/QCheck2_expect_test.ml | 11 ++++++++++- test/core/QCheck_expect_test.ml | 13 +++++++++++-- test/core/qcheck2_output.txt.expected | 8 +++++++- test/core/qcheck_output.txt.expected | 8 +++++++- 4 files changed, 35 insertions(+), 5 deletions(-) diff --git a/test/core/QCheck2_expect_test.ml b/test/core/QCheck2_expect_test.ml index 415290d6..e42825cd 100644 --- a/test/core/QCheck2_expect_test.ml +++ b/test/core/QCheck2_expect_test.ml @@ -58,6 +58,10 @@ module Generator = struct ~print:Print.char Gen.char (fun c -> c <> '\255') + let char_test = + Test.make ~name:"char has right range'" ~count:1000 ~print:Print.char + Gen.char (fun c -> '\000' <= c && c <= '\255') + let string_test = Test.make ~name:"string has right length and content" ~count:1000 ~print:Print.string Gen.string @@ -107,11 +111,14 @@ module Shrink = struct (Gen.pair listgen listgen) (fun (xs,ys) -> List.rev (xs@ys) = (List.rev xs)@(List.rev ys)) - (* test shrinking on integers *) let shrink_int = Test.make ~name:"mod3_should_fail" ~count:1000 ~print:Print.int Gen.int (fun i -> i mod 3 <> 0) + let char_is_never_abcdef = + Test.make ~name:"char is never produces 'abcdef'" ~count:1000 ~print:Print.char + Gen.char (fun c -> not (List.mem c ['a';'b';'c';'d';'e';'f'])) + let string_never_has_000_char = Test.make ~name:"string never has a \\000 char" ~count:1000 ~print:Print.string Gen.string @@ -283,6 +290,7 @@ let _ = Overall.bad_assume_warn; Overall.bad_assume_fail; Generator.char_dist_issue_23; + Generator.char_test; Generator.string_test; Generator.list_repeat_test; Generator.array_repeat_test; @@ -290,6 +298,7 @@ let _ = Shrink.big_bound_issue59; Shrink.long_shrink; Shrink.shrink_int; + Shrink.char_is_never_abcdef; Shrink.string_never_has_000_char; Shrink.string_never_has_255_char; Function.fail_pred_map_commute; diff --git a/test/core/QCheck_expect_test.ml b/test/core/QCheck_expect_test.ml index 5f204eac..c164759b 100644 --- a/test/core/QCheck_expect_test.ml +++ b/test/core/QCheck_expect_test.ml @@ -56,6 +56,10 @@ module Generator = struct let char_dist_issue_23 = Test.make ~name:"char never produces '\\255'" ~count:1_000_000 char (fun c -> c <> '\255') + let char_test = + Test.make ~name:"char has right range'" ~count:1000 + char (fun c -> '\000' <= c && c <= '\255') + let string_test = Test.make ~name:"string has right length and content" ~count:1000 string @@ -102,11 +106,14 @@ module Shrink = struct Test.make ~name:"long_shrink" (pair listgen listgen) (fun (xs,ys) -> List.rev (xs@ys) = (List.rev xs)@(List.rev ys)) - (* test shrinking on integers *) let shrink_int = Test.make ~name:"mod3_should_fail" ~count:1000 int (fun i -> i mod 3 <> 0) + let char_is_never_abcdef = + Test.make ~name:"char is never produces 'abcdef'" ~count:1000 + char (fun c -> not (List.mem c ['a';'b';'c';'d';'e';'f'])) + let string_never_has_000_char = Test.make ~name:"string never has a \\000 char" ~count:1000 string @@ -262,7 +269,7 @@ end (* Calling runners *) let () = QCheck_base_runner.set_seed 1234 -let i = +let _ = QCheck_base_runner.run_tests ~colors:false ([ Overall.passing; Overall.failing; @@ -272,6 +279,7 @@ let i = Overall.bad_assume_warn; Overall.bad_assume_fail; Generator.char_dist_issue_23; + Generator.char_test; Generator.string_test; Generator.list_repeat_test; Generator.array_repeat_test; @@ -279,6 +287,7 @@ let i = Shrink.big_bound_issue59; Shrink.long_shrink; Shrink.shrink_int; + Shrink.char_is_never_abcdef; Shrink.string_never_has_000_char; Shrink.string_never_has_255_char; Function.fail_pred_map_commute; diff --git a/test/core/qcheck2_output.txt.expected b/test/core/qcheck2_output.txt.expected index c0a2422d..e07e1ef9 100644 --- a/test/core/qcheck2_output.txt.expected +++ b/test/core/qcheck2_output.txt.expected @@ -100,6 +100,12 @@ Test mod3_should_fail failed (1 shrink steps): --- Failure -------------------------------------------------------------------- +Test char is never produces 'abcdef' failed (1 shrink steps): + +'a' + +--- Failure -------------------------------------------------------------------- + Test string never has a \000 char failed (22 shrink steps): "aaaaaa\000aaaaaaaaaaaaaaaa" @@ -648,7 +654,7 @@ stats dist: -4611686018427387392..-4150517416584648577: 0 ================================================================================ 1 warning(s) -failure (14 tests failed, 1 tests errored, ran 48 tests) +failure (15 tests failed, 1 tests errored, ran 50 tests) random seed: 153870556 +++ Stats for int_dist_empty_bucket ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ diff --git a/test/core/qcheck_output.txt.expected b/test/core/qcheck_output.txt.expected index a427e47b..4d0158fa 100644 --- a/test/core/qcheck_output.txt.expected +++ b/test/core/qcheck_output.txt.expected @@ -100,6 +100,12 @@ Test mod3_should_fail failed (84 shrink steps): --- Failure -------------------------------------------------------------------- +Test char is never produces 'abcdef' failed (0 shrink steps): + +'d' + +--- Failure -------------------------------------------------------------------- + Test string never has a \000 char failed (25 shrink steps): "\000" @@ -648,7 +654,7 @@ stats dist: -4611686018427387392..-4150517416584648577: 0 ================================================================================ 1 warning(s) -failure (14 tests failed, 1 tests errored, ran 48 tests) +failure (15 tests failed, 1 tests errored, ran 50 tests) random seed: 153870556 +++ Stats for int_dist_empty_bucket ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ From 762e36583a7681dee0612af911053b2af4ca5dc5 Mon Sep 17 00:00:00 2001 From: Jan Midtgaard Date: Fri, 13 Aug 2021 17:39:19 +0200 Subject: [PATCH 23/49] add list tests (and a fun test) from issue #64 --- test/core/QCheck2_expect_test.ml | 57 +++++++++++++++++++++++++ test/core/QCheck_expect_test.ml | 56 ++++++++++++++++++++++++ test/core/qcheck2_output.txt.expected | 61 ++++++++++++++++++++++++++- test/core/qcheck_output.txt.expected | 55 +++++++++++++++++++++++- 4 files changed, 227 insertions(+), 2 deletions(-) diff --git a/test/core/QCheck2_expect_test.ml b/test/core/QCheck2_expect_test.ml index e42825cd..f04a7f03 100644 --- a/test/core/QCheck2_expect_test.ml +++ b/test/core/QCheck2_expect_test.ml @@ -71,6 +71,11 @@ module Generator = struct && String.to_seq s |> Seq.fold_left (fun acc c -> acc && '\000' <= c && c <= '\255') true) + let list_test = + Test.make ~name:"list has right length" ~count:1000 + ~print:Print.(list unit) + Gen.(list unit) (fun l -> let len = List.length l in 0 <= len && len < 10_000) + let list_repeat_test = Test.make ~name:"list_repeat has constant length" ~count:1000 ~print:Print.(pair int (list unit)) @@ -128,6 +133,38 @@ module Shrink = struct Test.make ~name:"string never has a \\255 char" ~count:1000 ~print:Print.string Gen.string (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 = []) + + let list_shorter_10 = + Test.make ~name:"lists shorter than 10" ~print:Print.(list int) + Gen.(list small_int) (fun xs -> (*print_list xs;*) List.length xs < 10) + + let length_printer xs = + Printf.sprintf "[...] list length: %i" (List.length xs) + + let size_gen = Gen.(oneof [small_nat; int_bound 750_000]) + + let list_shorter_432 = + Test.make ~name:"lists shorter than 432" ~print:length_printer + Gen.(list_size size_gen small_int) (*Gen.(list small_int)*) + (fun xs -> (*print_list xs;*) List.length xs < 432) + + let list_shorter_4332 = + Test.make ~name:"lists shorter than 4332" ~print:length_printer + Gen.(list_size size_gen small_int) (*Gen.(list small_int)*) + (fun xs -> (*print_list xs;*) List.length xs < 4332) + + let list_equal_dupl = + Test.make ~name:"lists equal to duplication" ~print:length_printer + Gen.(list_size size_gen small_int) (*Gen.(list small_int)*) + (fun xs -> try xs = xs @ xs + with Stack_overflow -> false) end (* tests function generator and shrinker *) @@ -192,6 +229,19 @@ module Function = struct (fun (z,xs,f) -> List.fold_right (fun x y -> Fn.apply f (x,y)) xs z = List.fold_left (fun x y -> Fn.apply f (x,y)) z xs) + + (* test from issue #64 *) + let fold_left_test = + Test.make ~name:"fold_left test, fun first" ~print:Print.(quad Fn.print string (list int) (list int)) + Gen.(quad (* string -> int -> string *) + (fun2 ~print:Print.string Observable.string Observable.int (small_string ~gen:char)) + (small_string ~gen:char) + (list small_int) + (list small_int)) + (fun (f,acc,is,js) -> + let f = Fn.apply f in + List.fold_left f acc (is @ js) + = List.fold_left f (List.fold_left f acc is) is) (*Typo*) end (* tests of (inner) find_example(_gen) behaviour *) @@ -292,6 +342,7 @@ let _ = Generator.char_dist_issue_23; Generator.char_test; Generator.string_test; + Generator.list_test; Generator.list_repeat_test; Generator.array_repeat_test; (*Shrink.test_fac_issue59;*) @@ -301,11 +352,17 @@ let _ = Shrink.char_is_never_abcdef; Shrink.string_never_has_000_char; Shrink.string_never_has_255_char; + Shrink.lists_are_empty_issue_64; + Shrink.list_shorter_10; + Shrink.list_shorter_432; + Shrink.list_shorter_4332; + Shrink.list_equal_dupl; Function.fail_pred_map_commute; Function.fail_pred_strings; Function.prop_foldleft_foldright; Function.prop_foldleft_foldright_uncurry; Function.prop_foldleft_foldright_uncurry_funlast; + Function.fold_left_test; FindExample.find_ex; FindExample.find_ex_uncaught_issue_99_1_fail; FindExample.find_ex_uncaught_issue_99_2_succeed; diff --git a/test/core/QCheck_expect_test.ml b/test/core/QCheck_expect_test.ml index c164759b..be19c004 100644 --- a/test/core/QCheck_expect_test.ml +++ b/test/core/QCheck_expect_test.ml @@ -69,6 +69,10 @@ module Generator = struct && String.to_seq s |> Seq.fold_left (fun acc c -> acc && '\000' <= c && c <= '\255') true) + let list_test = + Test.make ~name:"list has right length" ~count:1000 + (list unit) (fun l -> let len = List.length l in 0 <= len && len < 10_000) + let list_repeat_test = let gen = Gen.(small_nat >>= fun i -> list_repeat i unit >>= fun l -> return (i,l)) in Test.make ~name:"list_repeat has constant length" ~count:1000 @@ -123,6 +127,38 @@ module Shrink = struct Test.make ~name:"string never has a \\255 char" ~count:1000 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 = []) + + let list_shorter_10 = + Test.make ~name:"lists shorter than 10" + (list small_int) (fun xs -> (*print_list xs;*) List.length xs < 10) + + let length_printer xs = + Printf.sprintf "[...] list length: %i" (List.length xs) + + let size_gen = Gen.(oneof [small_nat; int_bound 750_000]) + + let list_shorter_432 = + Test.make ~name:"lists shorter than 432" + (set_print length_printer (list_of_size size_gen small_int)) (*(list small_int)*) + (fun xs -> (*print_list xs;*) List.length xs < 432) + + let list_shorter_4332 = + Test.make ~name:"lists shorter than 4332" + (set_shrink Shrink.list_spine (set_print length_printer (list_of_size size_gen small_int))) + (fun xs -> (*print_list xs;*) List.length xs < 4332) + + let list_equal_dupl = + Test.make ~name:"lists equal to duplication" + (set_print length_printer (list_of_size size_gen small_int)) + (*(set_print length_printer (list small_int))*) + (fun xs -> try xs = xs @ xs + with Stack_overflow -> false) end (* tests function generator and shrinker *) @@ -183,6 +219,19 @@ module Function = struct (fun (z,xs,f) -> List.fold_right (fun x y -> Fn.apply f (x,y)) xs z = List.fold_left (fun x y -> Fn.apply f (x,y)) z xs) + + (* test from issue #64 *) + let fold_left_test = + Test.make ~name:"false fold, fun first" + (quad (* string -> int -> string *) + (fun2 Observable.string Observable.int small_string) + small_string + (list small_int) + (list small_int)) + (fun (f,acc,is,js) -> + let f = Fn.apply f in + List.fold_left f acc (is @ js) + = List.fold_left f (List.fold_left f acc is) is) (*Typo*) end (* tests of (inner) find_example(_gen) behaviour *) @@ -281,6 +330,7 @@ let _ = Generator.char_dist_issue_23; Generator.char_test; Generator.string_test; + Generator.list_test; Generator.list_repeat_test; Generator.array_repeat_test; (*Shrink.test_fac_issue59;*) @@ -290,11 +340,17 @@ let _ = Shrink.char_is_never_abcdef; Shrink.string_never_has_000_char; Shrink.string_never_has_255_char; + Shrink.lists_are_empty_issue_64; + Shrink.list_shorter_10; + Shrink.list_shorter_432; + Shrink.list_shorter_4332; + Shrink.list_equal_dupl; Function.fail_pred_map_commute; Function.fail_pred_strings; Function.prop_foldleft_foldright; Function.prop_foldleft_foldright_uncurry; Function.prop_foldleft_foldright_uncurry_funlast; + Function.fold_left_test; FindExample.find_ex; FindExample.find_ex_uncaught_issue_99_1_fail; FindExample.find_ex_uncaught_issue_99_2_succeed; diff --git a/test/core/qcheck2_output.txt.expected b/test/core/qcheck2_output.txt.expected index e07e1ef9..32c01bf6 100644 --- a/test/core/qcheck2_output.txt.expected +++ b/test/core/qcheck2_output.txt.expected @@ -1,4 +1,21 @@ random seed: 1234 +[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; 5; 9; 3; 3; 1; 79; 4; 3; 2; 67; 5; 7; 12; 70; 8; 8; 6; 1; 3; 14; 15; 1; 61; 4; 1; 4; 1; 7; 4; 4; 4; 2; 8; 8; 7; 5; 4; 27; 0; 9; 80; 25; 1; 8; 1; 3; 7; 4; 3; 5; 5; 6; 5; 5; 31; 7; 0; 3; 3; 6; 71; 76; 28; 60; 6; 2; 6; 3; 0; 4; 1; 0; 5; 7; 0; 28; 86; 4; 7; 51; 36; 0; 5; 0; 1; 4; 3; 6; 0; 1; 1; 8; 18; 4; 2; 8; 8; 1; 4; 7; 1; 0; 93; 5; 3; 0; 80; 1; 7; 7; 8; 8; 5; 7; 8; 9; 24; 4; 25; 8; 8; 5; 4; 90; 4; 6; 8; 4; 4; 0; 60; 8; 9; 7; 44; 5; 1; 2; 9; 74; 7; 7] +[] +[9; 61; 8; 4; 69; 2; 0; 72; 4; 41; 3; 8; 75; 83; 7; 7; 3; 9; 5; 8; 4; 1; 0; 2; 1; 4; 7; 6; 2; 1; 4; 86; 3; 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] +[] +[0] --- Failure -------------------------------------------------------------------- @@ -118,6 +135,42 @@ Test string never has a \255 char failed (59 shrink steps): --- Failure -------------------------------------------------------------------- +Test lists are empty failed (8 shrink steps): + +[0] + +--- Failure -------------------------------------------------------------------- + +Test lists shorter than 10 failed (16 shrink steps): + +[0; 0; 0; 0; 0; 0; 0; 0; 0; 0] + +--- Failure -------------------------------------------------------------------- + +Test lists shorter than 432 failed: + +ERROR: uncaught exception in generator for test lists shorter than 432 after 100 steps: +Exception: Stack overflow +Backtrace: + +--- Failure -------------------------------------------------------------------- + +Test lists shorter than 4332 failed: + +ERROR: uncaught exception in generator for test lists shorter than 4332 after 100 steps: +Exception: Stack overflow +Backtrace: + +--- Failure -------------------------------------------------------------------- + +Test lists equal to duplication failed: + +ERROR: uncaught exception in generator for test lists equal to duplication after 100 steps: +Exception: Stack overflow +Backtrace: + +--- Failure -------------------------------------------------------------------- + Test fail_pred_map_commute failed (16 shrink steps): ([2], {_ -> 0}, {1 -> false; 2 -> true; _ -> false}) @@ -155,6 +208,12 @@ Test fold_left fold_right uncurried fun last failed (25 shrink steps): --- Failure -------------------------------------------------------------------- +Test fold_left test, fun first failed (15 shrink steps): + +({_ -> ""}, "a", [], [0]) + +--- Failure -------------------------------------------------------------------- + Test FAIL_#99_1 failed: ERROR: uncaught exception in generator for test FAIL_#99_1 after 100 steps: @@ -654,7 +713,7 @@ stats dist: -4611686018427387392..-4150517416584648577: 0 ================================================================================ 1 warning(s) -failure (15 tests failed, 1 tests errored, ran 50 tests) +failure (21 tests failed, 1 tests errored, ran 57 tests) random seed: 153870556 +++ Stats for int_dist_empty_bucket ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ diff --git a/test/core/qcheck_output.txt.expected b/test/core/qcheck_output.txt.expected index 4d0158fa..54715747 100644 --- a/test/core/qcheck_output.txt.expected +++ b/test/core/qcheck_output.txt.expected @@ -1,4 +1,21 @@ random seed: 1234 +[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; 5; 9; 3; 3; 1; 79; 4; 3; 2; 67; 5; 7; 12; 70; 8; 8; 6; 1; 3; 14; 15; 1; 61; 4; 1; 4; 1; 7; 4; 4; 4; 2; 8; 8; 7; 5; 4; 27; 0; 9; 80; 25; 1; 8; 1; 3; 7; 4; 3; 5;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] +[2] +[] +[1] +[] +[0] +[] --- Failure -------------------------------------------------------------------- @@ -118,6 +135,36 @@ Test string never has a \255 char failed (249 shrink steps): --- Failure -------------------------------------------------------------------- +Test lists are empty failed (11 shrink steps): + +[0] + +--- Failure -------------------------------------------------------------------- + +Test lists shorter than 10 failed (50 shrink steps): + +[0; 0; 0; 0; 0; 0; 0; 0; 0; 0] + +--- Failure -------------------------------------------------------------------- + +Test lists shorter than 432 failed (1696 shrink steps): + +[...] list length: 432 + +--- Failure -------------------------------------------------------------------- + +Test lists shorter than 4332 failed (13 shrink steps): + +[...] list length: 4332 + +--- Failure -------------------------------------------------------------------- + +Test lists equal to duplication failed (20 shrink steps): + +[...] list length: 1 + +--- Failure -------------------------------------------------------------------- + Test fail_pred_map_commute failed (127 shrink steps): ([3], {_ -> 0}, {3 -> false; _ -> true}) @@ -155,6 +202,12 @@ Test fold_left fold_right uncurried fun last failed (26 shrink steps): --- Failure -------------------------------------------------------------------- +Test false fold, fun first failed (40 shrink steps): + +({_ -> ""}, "z", [], [0]) + +--- Failure -------------------------------------------------------------------- + Test FAIL_#99_1 failed: ERROR: uncaught exception in generator for test FAIL_#99_1 after 100 steps: @@ -654,7 +707,7 @@ stats dist: -4611686018427387392..-4150517416584648577: 0 ================================================================================ 1 warning(s) -failure (15 tests failed, 1 tests errored, ran 50 tests) +failure (21 tests failed, 1 tests errored, ran 57 tests) random seed: 153870556 +++ Stats for int_dist_empty_bucket ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ From 2ebfec618cd5dbb69c0574f001b5c2e9c3195f7f Mon Sep 17 00:00:00 2001 From: Jan Midtgaard Date: Fri, 13 Aug 2021 19:16:56 +0200 Subject: [PATCH 24/49] add more int shrinker tests (with a comparable trace) --- test/core/QCheck2_expect_test.ml | 17 +++- test/core/QCheck_expect_test.ml | 17 +++- test/core/qcheck2_output.txt.expected | 138 +++++++++++++++++++++++++- test/core/qcheck_output.txt.expected | 80 ++++++++++++++- 4 files changed, 242 insertions(+), 10 deletions(-) diff --git a/test/core/QCheck2_expect_test.ml b/test/core/QCheck2_expect_test.ml index f04a7f03..080b0659 100644 --- a/test/core/QCheck2_expect_test.ml +++ b/test/core/QCheck2_expect_test.ml @@ -116,10 +116,19 @@ module Shrink = struct (Gen.pair listgen listgen) (fun (xs,ys) -> List.rev (xs@ys) = (List.rev xs)@(List.rev ys)) - let shrink_int = - Test.make ~name:"mod3_should_fail" ~count:1000 ~print:Print.int + let ints_arent_0_mod_3 = + Test.make ~name:"ints arent 0 mod 3" ~count:1000 ~print:Print.int Gen.int (fun i -> i mod 3 <> 0) + 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) + + (* test from issue #59 *) + let ints_smaller_209609 = + Test.make ~name:"ints < 209609" ~print:Print.int + (Gen.small_int_corners()) (fun i -> i < 209609) + let char_is_never_abcdef = Test.make ~name:"char is never produces 'abcdef'" ~count:1000 ~print:Print.char Gen.char (fun c -> not (List.mem c ['a';'b';'c';'d';'e';'f'])) @@ -348,7 +357,9 @@ let _ = (*Shrink.test_fac_issue59;*) Shrink.big_bound_issue59; Shrink.long_shrink; - Shrink.shrink_int; + Shrink.ints_arent_0_mod_3; + Shrink.ints_are_0; + Shrink.ints_smaller_209609; Shrink.char_is_never_abcdef; Shrink.string_never_has_000_char; Shrink.string_never_has_255_char; diff --git a/test/core/QCheck_expect_test.ml b/test/core/QCheck_expect_test.ml index be19c004..29f1b926 100644 --- a/test/core/QCheck_expect_test.ml +++ b/test/core/QCheck_expect_test.ml @@ -110,10 +110,19 @@ module Shrink = struct Test.make ~name:"long_shrink" (pair listgen listgen) (fun (xs,ys) -> List.rev (xs@ys) = (List.rev xs)@(List.rev ys)) - let shrink_int = - Test.make ~name:"mod3_should_fail" ~count:1000 + let ints_arent_0_mod_3 = + Test.make ~name:"ints arent 0 mod 3" ~count:1000 int (fun i -> i mod 3 <> 0) + let ints_are_0 = + Test.make ~name:"ints are 0" ~count:1000 + int (fun i -> Printf.printf "%i\n" i; i = 0) + + (* test from issue #59 *) + let ints_smaller_209609 = + Test.make ~name:"ints < 209609" + (small_int_corners()) (fun i -> i < 209609) + let char_is_never_abcdef = Test.make ~name:"char is never produces 'abcdef'" ~count:1000 char (fun c -> not (List.mem c ['a';'b';'c';'d';'e';'f'])) @@ -336,7 +345,9 @@ let _ = (*Shrink.test_fac_issue59;*) Shrink.big_bound_issue59; Shrink.long_shrink; - Shrink.shrink_int; + Shrink.ints_arent_0_mod_3; + Shrink.ints_are_0; + Shrink.ints_smaller_209609; Shrink.char_is_never_abcdef; Shrink.string_never_has_000_char; Shrink.string_never_has_255_char; diff --git a/test/core/qcheck2_output.txt.expected b/test/core/qcheck2_output.txt.expected index 32c01bf6..e38efaa4 100644 --- a/test/core/qcheck2_output.txt.expected +++ b/test/core/qcheck2_output.txt.expected @@ -1,4 +1,126 @@ random seed: 1234 +1571754099758104554 +0 +785877049879052277 +0 +392938524939526138 +0 +196469262469763069 +0 +98234631234881534 +0 +49117315617440767 +0 +24558657808720383 +0 +12279328904360191 +0 +6139664452180095 +0 +3069832226090047 +0 +1534916113045023 +0 +767458056522511 +0 +383729028261255 +0 +191864514130627 +0 +95932257065313 +0 +47966128532656 +0 +23983064266328 +0 +11991532133164 +0 +5995766066582 +0 +2997883033291 +0 +1498941516645 +0 +749470758322 +0 +374735379161 +0 +187367689580 +0 +93683844790 +0 +46841922395 +0 +23420961197 +0 +11710480598 +0 +5855240299 +0 +2927620149 +0 +1463810074 +0 +731905037 +0 +365952518 +0 +182976259 +0 +91488129 +0 +45744064 +0 +22872032 +0 +11436016 +0 +5718008 +0 +2859004 +0 +1429502 +0 +714751 +0 +357375 +0 +178687 +0 +89343 +0 +44671 +0 +22335 +0 +11167 +0 +5583 +0 +2791 +0 +1395 +0 +697 +0 +348 +0 +174 +0 +87 +0 +43 +0 +21 +0 +10 +0 +5 +0 +2 +0 +1 +0 [7; 1; 42; 1; 8; 5; 3; 9; 5; 38; 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 0; 30; 9; 3; 7; 28; 57; 98; 3; 52; 3; 82; 7; 5; 5; 6; 8; 1; 6; 8; 9; 8; 16; 0] @@ -111,12 +233,24 @@ Test long_shrink failed (3040 shrink steps): --- Failure -------------------------------------------------------------------- -Test mod3_should_fail failed (1 shrink steps): +Test ints arent 0 mod 3 failed (1 shrink steps): 0 --- Failure -------------------------------------------------------------------- +Test ints are 0 failed (60 shrink steps): + +1 + +--- Failure -------------------------------------------------------------------- + +Test ints < 209609 failed (0 shrink steps): + +4611686018427387903 + +--- Failure -------------------------------------------------------------------- + Test char is never produces 'abcdef' failed (1 shrink steps): 'a' @@ -713,7 +847,7 @@ stats dist: -4611686018427387392..-4150517416584648577: 0 ================================================================================ 1 warning(s) -failure (21 tests failed, 1 tests errored, ran 57 tests) +failure (23 tests failed, 1 tests errored, ran 59 tests) random seed: 153870556 +++ Stats for int_dist_empty_bucket ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ diff --git a/test/core/qcheck_output.txt.expected b/test/core/qcheck_output.txt.expected index 54715747..f915746e 100644 --- a/test/core/qcheck_output.txt.expected +++ b/test/core/qcheck_output.txt.expected @@ -1,4 +1,68 @@ 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 +152 +76 +38 +19 +10 +5 +3 +2 +1 +0 [7; 1; 42; 1; 8; 5; 3; 9; 5; 38; 3; 3; 0; 1; 98; 1; 4; 13; 9; 2; 6;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0; 60; 8; 9; 7; 44; 5; 1; 2; 9; 74; 7; 7] [36; 0; 5; 0; 1; 4; 3; 6; 0; 1; 1; 8; 18; 4; 2; 8; 8; 1; 4; 7; 1; 0; 93; 5; 3; 0; 80; 1; 7; 7; 8; 8; 5; 7; 8; 9; 24; 4; 25; 8; 8; 5; 4; 90; 4; 6; 8; 4; 4; 0; 60; 8; 9; 7; 44; 5; 1; 2; 9; 74; 7; 7] @@ -111,12 +175,24 @@ Test long_shrink failed (149 shrink steps): --- Failure -------------------------------------------------------------------- -Test mod3_should_fail failed (84 shrink steps): +Test ints arent 0 mod 3 failed (84 shrink steps): -21 --- Failure -------------------------------------------------------------------- +Test ints are 0 failed (62 shrink steps): + +1 + +--- Failure -------------------------------------------------------------------- + +Test ints < 209609 failed (52 shrink steps): + +209609 + +--- Failure -------------------------------------------------------------------- + Test char is never produces 'abcdef' failed (0 shrink steps): 'd' @@ -707,7 +783,7 @@ stats dist: -4611686018427387392..-4150517416584648577: 0 ================================================================================ 1 warning(s) -failure (21 tests failed, 1 tests errored, ran 57 tests) +failure (23 tests failed, 1 tests errored, ran 59 tests) random seed: 153870556 +++ Stats for int_dist_empty_bucket ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ From 3f3261d58b5dff2874ca70ce6c4006eb82a74be8 Mon Sep 17 00:00:00 2001 From: Kate Date: Sun, 15 Aug 2021 18:48:34 +0100 Subject: [PATCH 25/49] Fix the tests and remove out of place (optional) --- example/alcotest/dune | 2 +- example/dune | 2 +- example/ounit/dune | 4 ++-- src/dune | 1 - src/ounit/dune | 1 - 5 files changed, 4 insertions(+), 6 deletions(-) diff --git a/example/alcotest/dune b/example/alcotest/dune index ca82186c..aebb720f 100644 --- a/example/alcotest/dune +++ b/example/alcotest/dune @@ -6,7 +6,6 @@ (rule (targets output.txt) (deps ./QCheck_alcotest_test.exe) - (package qcheck-alcotest) (enabled_if (= %{os_type} "Unix")) (action (with-accepted-exit-codes @@ -19,5 +18,6 @@ (rule (alias runtest) + (package qcheck-alcotest) (enabled_if (= %{os_type} "Unix")) (action (diff output.txt.expected output.txt))) diff --git a/example/dune b/example/dune index 345449cc..fe4b2715 100644 --- a/example/dune +++ b/example/dune @@ -6,7 +6,6 @@ (rule (targets output.txt) (deps ./QCheck_runner_test.exe) - (package qcheck-core) (enabled_if (= %{os_type} "Unix")) (action (with-accepted-exit-codes @@ -18,4 +17,5 @@ (rule (alias runtest) (enabled_if (= %{os_type} "Unix")) + (package qcheck) (action (diff output.txt.expected output.txt))) diff --git a/example/ounit/dune b/example/ounit/dune index 0162c96a..86554a74 100644 --- a/example/ounit/dune +++ b/example/ounit/dune @@ -1,12 +1,11 @@ (executables (names QCheck_ounit_test QCheck_test) - (libraries qcheck ounit2 qcheck-ounit)) + (libraries ounit2 qcheck-ounit)) (rule (targets output.txt) (deps ./QCheck_ounit_test.exe) - (package qcheck-ounit) (enabled_if (= %{os_type} "Unix")) (action (with-accepted-exit-codes @@ -17,5 +16,6 @@ (rule (alias runtest) + (package qcheck-ounit) (enabled_if (= %{os_type} "Unix")) (action (diff output.txt.expected output.txt))) diff --git a/src/dune b/src/dune index 59f9f1d6..7f18afde 100644 --- a/src/dune +++ b/src/dune @@ -3,7 +3,6 @@ (name qcheck) (public_name qcheck) (wrapped false) - (optional) (modules QCheck_runner) (synopsis "compatibility library for qcheck") (libraries qcheck-core qcheck-core.runner qcheck-ounit)) diff --git a/src/ounit/dune b/src/ounit/dune index cb45b69a..2fadb7a4 100644 --- a/src/ounit/dune +++ b/src/ounit/dune @@ -2,7 +2,6 @@ (library (name qcheck_ounit) (public_name qcheck-ounit) - (optional) (wrapped false) (libraries unix bytes qcheck-core qcheck-core.runner ounit2) (flags :standard -w +a-4-42-44-48-50-58-32-60@8 -safe-string) From 13ea8d66e0d80ce38a2c670992c48ce7da14f395 Mon Sep 17 00:00:00 2001 From: Jan Midtgaard Date: Wed, 11 Aug 2021 17:41:39 +0200 Subject: [PATCH 26/49] initial version --- test/core/QCheck2_expect_test.ml | 192 +++++++++++++ test/core/QCheck_expect_test.ml | 183 +++++++++++++ test/core/dune | 46 +++- test/core/qcheck2_output.txt.expected | 373 ++++++++++++++++++++++++++ test/core/qcheck_output.txt.expected | 373 ++++++++++++++++++++++++++ 5 files changed, 1164 insertions(+), 3 deletions(-) create mode 100644 test/core/QCheck2_expect_test.ml create mode 100644 test/core/QCheck_expect_test.ml create mode 100644 test/core/qcheck2_output.txt.expected create mode 100644 test/core/qcheck_output.txt.expected diff --git a/test/core/QCheck2_expect_test.ml b/test/core/QCheck2_expect_test.ml new file mode 100644 index 00000000..7f471fda --- /dev/null +++ b/test/core/QCheck2_expect_test.ml @@ -0,0 +1,192 @@ +(** QCheck2 tests **) + +let passing = + QCheck2.Test.make ~count:100 ~long_factor:100 ~print:QCheck2.Print.(list int) + ~name:"list_rev_is_involutive" + QCheck2.Gen.(list small_int) + (fun l -> List.rev (List.rev l) = l);; + +let failing = + QCheck2.Test.make ~count:10 + ~name:"should_fail_sort_id" ~print:QCheck2.Print.(list int) + QCheck2.Gen.(small_list small_int) + (fun l -> l = List.sort compare l);; + +exception Error + +let error = + QCheck2.Test.make ~count:10 + ~name:"should_error_raise_exn" ~print:QCheck2.Print.int + QCheck2.Gen.int + (fun _ -> raise Error) + +let collect = + QCheck2.Test.make ~count:100 ~long_factor:100 + ~name:"collect_results" ~print:QCheck2.Print.int + ~collect:string_of_int (QCheck2.Gen.int_bound 4) + (fun _ -> true) + +let stats = + QCheck2.Test.make ~count:100 ~long_factor:100 + ~name:"with_stats" ~print:QCheck2.Print.int + ~stats:[ + "mod4", (fun i->i mod 4); + "num", (fun i->i); + ] + (QCheck2.Gen.int_bound 120) + (fun _ -> true) + +let fun1 = + let open QCheck2 in + Test.make ~count:100 ~long_factor:100 + ~name:"FAIL_pred_map_commute" ~print:Print.(triple (list int) Fn.print Fn.print) + Gen.(triple + (small_list small_int) + (fun1 ~print:Print.int Observable.int int) + (fun1 ~print:Print.bool Observable.int bool)) + (fun (l,QCheck2.Fun (_,f), QCheck2.Fun (_,p)) -> + List.filter p (List.map f l) = List.map f (List.filter p l)) + +let fun2 = + let open QCheck2 in + Test.make ~count:100 + ~name:"FAIL_fun2_pred_strings" ~print:Fn.print + (fun1 Observable.string ~print:Print.bool Gen.bool) + (fun (Fun (_,p)) -> + not (p "some random string") || p "some other string") + +let int_gen = QCheck2.Gen.small_nat (* int *) + +(* Another example (false) property *) +let prop_foldleft_foldright = + let open QCheck2 in + Test.make ~name:"fold_left fold_right" ~count:1000 ~long_factor:20 + ~print:Print.(triple int (list int) Fn.print) + Gen.(triple + int_gen + (list int_gen) + (fun2 ~print:Print.int Observable.int Observable.int int_gen)) + (fun (z,xs,f) -> + let l1 = List.fold_right (Fn.apply f) xs z in + let l2 = List.fold_left (Fn.apply f) z xs in + if l1=l2 then true + else QCheck.Test.fail_reportf "l=%s, fold_left=%s, fold_right=%s@." + (QCheck.Print.(list int) xs) + (QCheck.Print.int l1) + (QCheck.Print.int l2) + ) + +(* Another example (false) property *) +let prop_foldleft_foldright_uncurry = + let open QCheck2 in + Test.make ~name:"fold_left fold_right uncurried" ~count:1000 ~long_factor:20 + ~print:Print.(triple Fn.print int (list int)) + Gen.(triple + (fun1 ~print:Print.int Observable.(pair int int) int_gen) + int_gen + (list int_gen)) + (fun (f,z,xs) -> + List.fold_right (fun x y -> Fn.apply f (x,y)) xs z = + List.fold_left (fun x y -> Fn.apply f (x,y)) z xs) + +let long_shrink = + let open QCheck2 in + let listgen = Gen.(list_size (int_range 1000 10000) int) in + Test.make ~name:"long_shrink" ~print:Print.(pair (list int) (list int)) + (Gen.pair listgen listgen) + (fun (xs,ys) -> List.rev (xs@ys) = (List.rev xs)@(List.rev ys)) + +(* test shrinking on integers *) +let shrink_int = + let open QCheck2 in + Test.make ~count:1000 ~name:"mod3_should_fail" ~print:Print.int + Gen.int (fun i -> i mod 3 <> 0) + +let bad_assume_warn = + let open QCheck2 in + Test.make ~count:2_000 + ~name:"WARN_unlikely_precond" ~print:Print.int + Gen.int + (fun x -> + QCheck.assume (x mod 100 = 1); + true) + +let bad_assume_fail = + let open QCheck2 in + Test.make ~count:2_000 ~if_assumptions_fail:(`Fatal, 0.1) + ~name:"FAIL_unlikely_precond" ~print:Print.int + Gen.int + (fun x -> + QCheck.assume (x mod 100 = 1); + true) + +let find_ex = + let open QCheck2 in + Test.make ~name:"find_example" ~print:Print.int + Gen.(2--50) + (fun n -> + let st = Random.State.make [| 0 |] in + let f m = n < m && m < 2 * n in + try + let m = find_example_gen ~rand:st ~count:100_000 ~f Gen.(0 -- 1000) in + f m + with No_example_found _ -> false) + +let find_ex_uncaught_issue_99 : _ list = + let open QCheck2 in + let t1 = + let rs = (find_example ~count:10 ~f:(fun _ -> false) Gen.int) in + Test.make ~name:"FAIL_#99_1" rs (fun _ -> true) in + let t2 = + Test.make ~name:"should_succeed_#99_2" ~count:10 Gen.int + (fun i -> i <= max_int) in + [t1;t2] + +let stats_negs = + QCheck2.(Test.make ~count:5_000 ~name:"stats_neg" + ~stats:[("dist",fun x -> x)] Gen.small_signed_int) + (fun _ -> true) + +let stats_tests = + let open QCheck2 in + let dist = ("dist",fun x -> x) in + [ + Test.make ~name:"stat_display_test_1" ~count:1000 ~stats:[dist] Gen.small_signed_int (fun _ -> true); + Test.make ~name:"stat_display_test_2" ~count:1000 ~stats:[dist] Gen.small_nat (fun _ -> true); + Test.make ~name:"stat_display_test_3" ~count:1000 ~stats:[dist] (Gen.int_range (-43643) 435434) (fun _ -> true); + Test.make ~name:"stat_display_test_4" ~count:1000 ~stats:[dist] (Gen.int_range (-40000) 40000) (fun _ -> true); + Test.make ~name:"stat_display_test_5" ~count:1000 ~stats:[dist] (Gen.int_range (-4) 4) (fun _ -> true); + Test.make ~name:"stat_display_test_6" ~count:1000 ~stats:[dist] (Gen.int_range (-4) 17) (fun _ -> true); + Test.make ~name:"stat_display_test_7" ~count:100000 ~stats:[dist] Gen.int (fun _ -> true); + Test.make ~name:"stat_display_test_8" ~count:1000 ~stats:[dist] (Gen.oneofl[min_int;-1;0;1;max_int]) (fun _ -> true); + ] + +let stat_display_test9 = + let open QCheck2 in + Test.make ~name:"stat_display_test9" ~count:1_000 + ~stats:[("dist",fun x -> x)] Gen.(oneof [small_int_corners ();int]) (fun _ -> true) + +(* Calling runners *) + +let () = QCheck_base_runner.set_seed 1234 +let _ = + QCheck_base_runner.run_tests ~colors:false ([ + passing; + failing; + error; + collect; + stats; + fun1; + fun2; + prop_foldleft_foldright; + prop_foldleft_foldright_uncurry; + long_shrink; + shrink_int; + bad_assume_warn; + bad_assume_fail; + ] @ find_ex :: find_ex_uncaught_issue_99 + @ stats_negs :: stats_tests) + +let () = QCheck_base_runner.set_seed 153870556 +let _ = QCheck_base_runner.run_tests ~colors:false [stat_display_test9] + diff --git a/test/core/QCheck_expect_test.ml b/test/core/QCheck_expect_test.ml new file mode 100644 index 00000000..ca0fd0f9 --- /dev/null +++ b/test/core/QCheck_expect_test.ml @@ -0,0 +1,183 @@ +(** QCheck(1) tests **) + +let passing = + QCheck.Test.make ~count:100 ~long_factor:100 + ~name:"list_rev_is_involutive" + QCheck.(list small_int) + (fun l -> List.rev (List.rev l) = l) + +let failing = + QCheck.Test.make ~count:10 + ~name:"should_fail_sort_id" + QCheck.(small_list small_int) + (fun l -> l = List.sort compare l) + +exception Error + +let error = + QCheck.Test.make ~count:10 + ~name:"should_error_raise_exn" + QCheck.int + (fun _ -> raise Error) + +let collect = + QCheck.Test.make ~count:100 ~long_factor:100 + ~name:"collect_results" + QCheck.(make ~collect:string_of_int (Gen.int_bound 4)) + (fun _ -> true) + +let stats = + QCheck.Test.make ~count:100 ~long_factor:100 + ~name:"with_stats" + QCheck.(make (Gen.int_bound 120) + ~stats:[ + "mod4", (fun i->i mod 4); + "num", (fun i->i); + ] + ) + (fun _ -> true) + +let fun1 = + QCheck.Test.make ~count:100 ~long_factor:100 + ~name:"FAIL_pred_map_commute" + QCheck.(triple + (small_list small_int) + (fun1 Observable.int int) + (fun1 Observable.int bool)) + (fun (l,QCheck.Fun (_,f), QCheck.Fun (_,p)) -> + List.filter p (List.map f l) = List.map f (List.filter p l)) + +let fun2 = + QCheck.Test.make ~count:100 + ~name:"FAIL_fun2_pred_strings" + QCheck.(fun1 Observable.string bool) + (fun (QCheck.Fun (_,p)) -> + not (p "some random string") || p "some other string") + +let int_gen = QCheck.small_nat (* int *) + +(* Another example (false) property *) +let prop_foldleft_foldright = + let open QCheck in + Test.make ~name:"fold_left fold_right" ~count:1000 ~long_factor:20 + (triple + int_gen + (list int_gen) + (fun2 Observable.int Observable.int int_gen)) + (fun (z,xs,f) -> + let l1 = List.fold_right (Fn.apply f) xs z in + let l2 = List.fold_left (Fn.apply f) z xs in + if l1=l2 then true + else QCheck.Test.fail_reportf "l=%s, fold_left=%s, fold_right=%s@." + (QCheck.Print.(list int) xs) + (QCheck.Print.int l1) + (QCheck.Print.int l2) + ) + +(* Another example (false) property *) +let prop_foldleft_foldright_uncurry = + let open QCheck in + Test.make ~name:"fold_left fold_right uncurried" ~count:1000 ~long_factor:20 + (triple + (fun1 Observable.(pair int int) int_gen) + int_gen + (list int_gen)) + (fun (f,z,xs) -> + List.fold_right (fun x y -> Fn.apply f (x,y)) xs z = + List.fold_left (fun x y -> Fn.apply f (x,y)) z xs) + +let long_shrink = + let open QCheck in + let listgen = list_of_size (Gen.int_range 1000 10000) int in + Test.make ~name:"long_shrink" (pair listgen listgen) + (fun (xs,ys) -> List.rev (xs@ys) = (List.rev xs)@(List.rev ys)) + +(* test shrinking on integers *) +let shrink_int = + QCheck.Test.make ~count:1000 ~name:"mod3_should_fail" + QCheck.int (fun i -> i mod 3 <> 0) + +let bad_assume_warn = + QCheck.Test.make ~count:2_000 + ~name:"WARN_unlikely_precond" + QCheck.int + (fun x -> + QCheck.assume (x mod 100 = 1); + true) + +let bad_assume_fail = + QCheck.Test.make ~count:2_000 ~if_assumptions_fail:(`Fatal, 0.1) + ~name:"FAIL_unlikely_precond" + QCheck.int + (fun x -> + QCheck.assume (x mod 100 = 1); + true) + +let find_ex = + let open QCheck in + Test.make ~name:"find_example" (2--50) + (fun n -> + let st = Random.State.make [| 0 |] in + let f m = n < m && m < 2 * n in + try + let m = find_example_gen ~rand:st ~count:100_000 ~f Gen.(0 -- 1000) in + f m + with No_example_found _ -> false) + +let find_ex_uncaught_issue_99 : _ list = + let open QCheck in + let t1 = + let rs = make (find_example ~count:10 ~f:(fun _ -> false) Gen.int) in + Test.make ~name:"FAIL_#99_1" rs (fun _ -> true) in + let t2 = + Test.make ~name:"should_succeed_#99_2" ~count:10 int + (fun i -> i <= max_int) in + [t1;t2] + +let stats_negs = + QCheck.(Test.make ~count:5_000 ~name:"stats_neg" + (add_stat ("dist",fun x -> x) small_signed_int)) + (fun _ -> true) + +let stats_tests = + let open QCheck in + let dist = ("dist",fun x -> x) in + [ + Test.make ~name:"stat_display_test_1" ~count:1000 (add_stat dist small_signed_int) (fun _ -> true); + Test.make ~name:"stat_display_test_2" ~count:1000 (add_stat dist small_nat) (fun _ -> true); + Test.make ~name:"stat_display_test_3" ~count:1000 (add_stat dist (int_range (-43643) 435434)) (fun _ -> true); + Test.make ~name:"stat_display_test_4" ~count:1000 (add_stat dist (int_range (-40000) 40000)) (fun _ -> true); + Test.make ~name:"stat_display_test_5" ~count:1000 (add_stat dist (int_range (-4) 4)) (fun _ -> true); + Test.make ~name:"stat_display_test_6" ~count:1000 (add_stat dist (int_range (-4) 17)) (fun _ -> true); + Test.make ~name:"stat_display_test_7" ~count:100000 (add_stat dist int) (fun _ -> true); + Test.make ~name:"stat_display_test_8" ~count:1000 (add_stat dist (oneofl[min_int;-1;0;1;max_int])) (fun _ -> true); + ] + +let stat_display_test9 = + let open QCheck in + Test.make ~name:"stat_display_test9" ~count:1_000 + (add_stat ("dist",fun x -> x) (oneof [small_int_corners ();int])) (fun _ -> true) + +(* Calling runners *) + +let () = QCheck_base_runner.set_seed 1234 +let i = + QCheck_base_runner.run_tests ~colors:false ([ + passing; + failing; + error; + collect; + stats; + fun1; + fun2; + prop_foldleft_foldright; + prop_foldleft_foldright_uncurry; + long_shrink; + shrink_int; + bad_assume_warn; + bad_assume_fail; + ] @ find_ex :: find_ex_uncaught_issue_99 + @ stats_negs :: stats_tests) + +let () = QCheck_base_runner.set_seed 153870556 +let _ = QCheck_base_runner.run_tests ~colors:false [stat_display_test9] diff --git a/test/core/dune b/test/core/dune index 40e59e0c..4f4ee0e6 100644 --- a/test/core/dune +++ b/test/core/dune @@ -1,4 +1,44 @@ + (test - (name test) - (package qcheck-core) - (libraries qcheck-core alcotest)) + (name test) + (modules test) + (libraries qcheck-core alcotest)) + +(executables + (names QCheck_expect_test QCheck2_expect_test) + (modules QCheck_expect_test QCheck2_expect_test) + (libraries qcheck-core qcheck-core.runner)) + +;; rules for QCheck_expect_test +(rule + (targets qcheck_output.txt) + (deps ./QCheck_expect_test.exe) + (package qcheck-core) + (enabled_if (= %{os_type} "Unix")) + (action + (with-stdout-to + %{targets} + (run ./QCheck_expect_test.exe --no-colors)))) + +(rule + (alias runtest) + (package qcheck-core) + (enabled_if (= %{os_type} "Unix")) + (action (diff qcheck_output.txt.expected qcheck_output.txt))) + +;; rules for QCheck2_expect_test +(rule + (targets qcheck2_output.txt) + (deps ./QCheck2_expect_test.exe) + (package qcheck-core) + (enabled_if (= %{os_type} "Unix")) + (action + (with-stdout-to + %{targets} + (run ./QCheck2_expect_test.exe --no-colors)))) + +(rule + (alias runtest) + (package qcheck-core) + (enabled_if (= %{os_type} "Unix")) + (action (diff qcheck2_output.txt.expected qcheck2_output.txt))) diff --git a/test/core/qcheck2_output.txt.expected b/test/core/qcheck2_output.txt.expected new file mode 100644 index 00000000..eeb19832 --- /dev/null +++ b/test/core/qcheck2_output.txt.expected @@ -0,0 +1,373 @@ +random seed: 1234 + +--- Failure -------------------------------------------------------------------- + +Test should_fail_sort_id failed (9 shrink steps): + +[1; 0] + +=== Error ====================================================================== + +Test should_error_raise_exn errored on (1 shrink steps): + +0 + +exception Dune__exe__QCheck2_expect_test.Error + + ++++ Collect ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +Collect results for test collect_results: + +4: 20 cases +3: 25 cases +2: 17 cases +1: 18 cases +0: 20 cases + ++++ Stats for with_stats ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats mod4: + num: 100, avg: 1.68, stddev: 1.09, median 2, min 0, max 3 + 0: ############################## 17 + 1: ################################################### 29 + 2: ######################################## 23 + 3: ####################################################### 31 + +stats num: + num: 100, avg: 66.84, stddev: 31.94, median 65, min 2, max 120 + 2.. 7: ################## 3 + 8.. 13: ################## 3 + 14.. 19: 0 + 20.. 25: ########################################## 7 + 26.. 31: ######################## 4 + 32.. 37: ######################## 4 + 38.. 43: ################## 3 + 44.. 49: ################################################ 8 + 50.. 55: #################################### 6 + 56.. 61: #################################### 6 + 62.. 67: ####################################################### 9 + 68.. 73: ########################################## 7 + 74.. 79: ######################## 4 + 80.. 85: ################## 3 + 86.. 91: ############ 2 + 92.. 97: ########################################## 7 + 98..103: #################################### 6 + 104..109: #################################### 6 + 110..115: ####################################################### 9 + 116..121: ################## 3 + +--- Failure -------------------------------------------------------------------- + +Test FAIL_pred_map_commute failed (16 shrink steps): + +([2], {_ -> 0}, {1 -> false; 2 -> true; _ -> false}) + +--- Failure -------------------------------------------------------------------- + +Test FAIL_fun2_pred_strings failed (1 shrink steps): + +{"some random string" -> true; _ -> false} + +--- Failure -------------------------------------------------------------------- + +Test fold_left fold_right failed (22 shrink steps): + +(0, [1], {(1, 0) -> 1; (8, 0) -> 0; (8, 8) -> 0; (8, 93) -> 0; (7, 7) -> 0; (24, 5) -> 0; (7, 0) -> 0; (0, 2) -> 0; (2, 4) -> 0; (9, 8) -> 0; (4, 9) -> 0; (1, 24) -> 0; (9, 5) -> 0; (80, 9) -> 0; (24, 0) -> 0; (1, 8) -> 0; (5, 7) -> 0; (0, 7) -> 0; (7, 8) -> 0; (0, 24) -> 0; _ -> 0}) + ++++ Messages ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +Messages for test fold_left fold_right: + +l=[1], fold_left=1, fold_right=0 + + +--- Failure -------------------------------------------------------------------- + +Test fold_left fold_right uncurried failed (325 shrink steps): + +({(23, 62) -> 0; (9, 42) -> 0; (8, 61) -> 0; (8, 5) -> 0; (30, 5) -> 0; (9, 6) -> 0; (76, 6) -> 0; (19, 31) -> 0; (7, 62) -> 0; (0, 7) -> 1; (7, 1) -> 0; (78, 4) -> 0; (8, 2) -> 0; (78, 0) -> 0; (3, 47) -> 0; (4, 8) -> 0; (98, 9) -> 0; (1, 38) -> 0; (0, 26) -> 0; (1, 7) -> 0; (86, 3) -> 0; (9, 37) -> 0; (8, 1) -> 0; (79, 9) -> 0; (3, 5) -> 0; (56, 8) -> 0; (2, 5) -> 0; (8, 8) -> 0; (56, 67) -> 0; (5, 60) -> 0; (2, 31) -> 0; (61, 6) -> 0; (12, 5) -> 0; (76, 2) -> 0; (78, 8) -> 0; (1, 1) -> 0; (8, 9) -> 0; (7, 8) -> 0; (2, 9) -> 0; (29, 7) -> 0; (5, 8) -> 0; (28, 6) -> 0; (1, 4) -> 0; (9, 79) -> 0; (0, 1) -> 0; (1, 41) -> 0; (82, 98) -> 0; (6, 79) -> 0; (7, 6) -> 0; (4, 3) -> 0; (8, 12) -> 0; (5, 1) -> 0; (39, 1) -> 0; (3, 6) -> 0; (1, 2) -> 0; (76, 31) -> 0; (4, 1) -> 0; (6, 5) -> 0; (0, 8) -> 0; (8, 7) -> 0; (2, 6) -> 0; (52, 5) -> 0; (8, 47) -> 0; (5, 3) -> 0; (7, 9) -> 0; (13, 13) -> 0; (0, 87) -> 0; (82, 0) -> 0; (34, 8) -> 0; (1, 14) -> 0; (2, 71) -> 0; (52, 4) -> 0; (1, 3) -> 0; (85, 6) -> 0; (8, 19) -> 0; (3, 13) -> 0; (69, 1) -> 0; (5, 62) -> 0; (0, 15) -> 0; (34, 0) -> 0; (9, 4) -> 0; (0, 6) -> 0; (1, 8) -> 0; (86, 6) -> 0; (4, 5) -> 0; (3, 1) -> 0; (57, 2) -> 0; (3, 3) -> 0; (4, 0) -> 0; (30, 6) -> 0; (5, 34) -> 0; (0, 4) -> 0; (2, 3) -> 0; (5, 6) -> 0; (5, 7) -> 0; (5, 0) -> 0; (4, 4) -> 0; (7, 5) -> 0; (78, 2) -> 0; (9, 8) -> 0; (7, 70) -> 0; (35, 1) -> 0; (64, 7) -> 0; (60, 0) -> 0; (1, 9) -> 0; _ -> 0}, 0, [0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 7]) + +--- Failure -------------------------------------------------------------------- + +Test long_shrink failed (3040 shrink steps): + +([0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 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 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 1]) + +--- Failure -------------------------------------------------------------------- + +Test mod3_should_fail failed (1 shrink steps): + +0 + +!!! Warning !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +Warning for test WARN_unlikely_precond: + +WARNING: only 0.7% tests (of 2000) passed precondition for "WARN_unlikely_precond" + +NOTE: it is likely that the precondition is too strong, or that the generator is buggy. + +--- Failure -------------------------------------------------------------------- + +Test FAIL_unlikely_precond failed: + +ERROR: only 0.7% tests (of 2000) passed precondition for "FAIL_unlikely_precond" + +NOTE: it is likely that the precondition is too strong, or that the generator is buggy. + + +--- Failure -------------------------------------------------------------------- + +Test FAIL_#99_1 failed: + +ERROR: uncaught exception in generator for test FAIL_#99_1 after 100 steps: +Exception: QCheck2.No_example_found("") +Backtrace: + ++++ Stats for stats_neg ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats dist: + num: 5000, avg: 0.17, stddev: 29.68, median 0, min -99, max 99 + -99..-90: # 65 + -89..-80: # 63 + -79..-70: # 64 + -69..-60: # 58 + -59..-50: # 67 + -49..-40: # 72 + -39..-30: # 61 + -29..-20: # 61 + -19..-10: # 67 + -9.. 0: ####################################################### 2076 + 1.. 10: ############################################## 1764 + 11.. 20: # 66 + 21.. 30: # 64 + 31.. 40: # 64 + 41.. 50: # 67 + 51.. 60: # 60 + 61.. 70: # 75 + 71.. 80: # 60 + 81.. 90: # 60 + 91..100: # 66 + ++++ Stats for stat_display_test_1 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats dist: + num: 1000, avg: 0.90, stddev: 28.23, median 0, min -99, max 99 + -99..-90: # 12 + -89..-80: # 11 + -79..-70: # 9 + -69..-60: 6 + -59..-50: # 11 + -49..-40: # 13 + -39..-30: # 9 + -29..-20: # 13 + -19..-10: 8 + -9.. 0: ####################################################### 453 + 1.. 10: ######################################### 340 + 11.. 20: # 15 + 21.. 30: # 11 + 31.. 40: # 12 + 41.. 50: # 13 + 51.. 60: # 13 + 61.. 70: # 16 + 71.. 80: # 9 + 81.. 90: # 16 + 91..100: # 10 + ++++ Stats for stat_display_test_2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats dist: + num: 1000, avg: 15.11, stddev: 23.27, median 6, min 0, max 99 + 0.. 4: #################################################### 377 + 5.. 9: ####################################################### 392 + 10.. 14: ## 20 + 15.. 19: ## 15 + 20.. 24: # 11 + 25.. 29: ## 17 + 30.. 34: ## 19 + 35.. 39: ## 17 + 40.. 44: # 10 + 45.. 49: # 9 + 50.. 54: # 8 + 55.. 59: # 9 + 60.. 64: ## 15 + 65.. 69: # 10 + 70.. 74: # 13 + 75.. 79: ## 19 + 80.. 84: # 11 + 85.. 89: # 13 + 90.. 94: 5 + 95.. 99: # 10 + ++++ Stats for stat_display_test_3 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats dist: + num: 1000, avg: 195335.64, stddev: 136803.99, median 195583, min -43624, max 435210 + -43624..-19683: ############################################ 52 + -19682.. 4259: ######################################## 47 + 4260.. 28201: ############################## 36 + 28202.. 52143: ############################################ 52 + 52144.. 76085: ########################################## 50 + 76086..100027: ####################################################### 64 + 100028..123969: ############################################### 55 + 123970..147911: ######################################## 47 + 147912..171853: ############################################## 54 + 171854..195795: #################################### 43 + 195796..219737: ############################################## 54 + 219738..243679: ########################################### 51 + 243680..267621: ################################################ 57 + 267622..291563: ########################################## 49 + 291564..315505: #################################### 42 + 315506..339447: ###################################### 45 + 339448..363389: ################################################ 57 + 363390..387331: ###################################### 45 + 387332..411273: ########################################## 49 + 411274..435215: ########################################### 51 + ++++ Stats for stat_display_test_4 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats dist: + num: 1000, avg: -173.78, stddev: 23042.92, median 180, min -39859, max 39942 + -39859..-35869: ############################################# 56 + -35868..-31878: ################################### 43 + -31877..-27887: ################################################# 60 + -27886..-23896: ##################################### 46 + -23895..-19905: ######################################## 49 + -19904..-15914: #################################### 45 + -15913..-11923: ############################################ 54 + -11922.. -7932: ############################################### 58 + -7931.. -3941: ######################################### 51 + -3940.. 50: ############################ 35 + 51.. 4041: ####################################### 48 + 4042.. 8032: ########################################## 52 + 8033.. 12023: ######################################### 51 + 12024.. 16014: ########################################### 53 + 16015.. 20005: ############################################ 54 + 20006.. 23996: ################################## 42 + 23997.. 27987: ####################################################### 67 + 27988.. 31978: ################################ 40 + 31979.. 35969: ######################################### 51 + 35970.. 39960: #################################### 45 + ++++ Stats for stat_display_test_5 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats dist: + num: 1000, avg: 0.02, stddev: 2.55, median 0, min -4, max 4 + -4: ############################################ 99 + -3: ##################################################### 118 + -2: ################################################## 111 + -1: ################################################## 113 + 0: ################################################## 113 + 1: ##################################################### 118 + 2: ############################################# 102 + 3: ####################################################### 122 + 4: ############################################## 104 + ++++ Stats for stat_display_test_6 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats dist: + num: 1000, avg: 6.67, stddev: 6.39, median 7, min -4, max 17 + -4..-3: ############################################# 90 + -2..-1: ############################################# 91 + 0.. 1: ########################################## 84 + 2.. 3: ############################################## 92 + 4.. 5: ########################################### 87 + 6.. 7: ########################################### 86 + 8.. 9: ############################################ 89 + 10..11: ########################################### 87 + 12..13: ####################################################### 110 + 14..15: ############################################# 91 + 16..17: ############################################## 93 + 18..19: 0 + 20..21: 0 + 22..23: 0 + 24..25: 0 + 26..27: 0 + 28..29: 0 + 30..31: 0 + 32..33: 0 + 34..35: 0 + ++++ Stats for stat_display_test_7 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats dist: + num: 100000, avg: 6126662802445055.00, stddev: 2661484817981980672.00, median 158655556399988, min -4611578348806740501, max 4611677827646819817 + -4611578348806740501..-4150415539984062486: #################################################### 4926 + -4150415539984062485..-3689252731161384470: #################################################### 4949 + -3689252731161384469..-3228089922338706454: ##################################################### 4957 + -3228089922338706453..-2766927113516028438: ##################################################### 4993 + -2766927113516028437..-2305764304693350422: ###################################################### 5043 + -2305764304693350421..-1844601495870672406: ##################################################### 5040 + -1844601495870672405..-1383438687047994390: ##################################################### 4974 + -1383438687047994389.. -922275878225316374: ##################################################### 5031 + -922275878225316373.. -461113069402638358: ####################################################### 5136 + -461113069402638357.. 49739420039658: ##################################################### 4950 + 49739420039659.. 461212548242717674: ###################################################### 5076 + 461212548242717675.. 922375357065395690: #################################################### 4933 + 922375357065395691.. 1383538165888073706: ##################################################### 4970 + 1383538165888073707.. 1844700974710751722: #################################################### 4922 + 1844700974710751723.. 2305863783533429738: ###################################################### 5087 + 2305863783533429739.. 2767026592356107754: #################################################### 4913 + 2767026592356107755.. 3228189401178785770: ##################################################### 4960 + 3228189401178785771.. 3689352210001463786: ##################################################### 5029 + 3689352210001463787.. 4150515018824141802: ###################################################### 5048 + 4150515018824141803.. 4611677827646819818: ###################################################### 5063 + ++++ Stats for stat_display_test_8 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats dist: + num: 1000, avg: 4611686018427388.00, stddev: 2905870896563567616.00, median 0, min -4611686018427387904, max 4611686018427387903 + -4611686018427387904..-4150517416584649089: ################## 208 + -4150517416584649088..-3689348814741910273: 0 + -3689348814741910272..-3228180212899171457: 0 + -3228180212899171456..-2767011611056432641: 0 + -2767011611056432640..-2305843009213693825: 0 + -2305843009213693824..-1844674407370955009: 0 + -1844674407370955008..-1383505805528216193: 0 + -1383505805528216192.. -922337203685477377: 0 + -922337203685477376.. -461168601842738561: 0 + -461168601842738560.. 255: ####################################################### 603 + 256.. 461168601842739071: 0 + 461168601842739072.. 922337203685477887: 0 + 922337203685477888.. 1383505805528216703: 0 + 1383505805528216704.. 1844674407370955519: 0 + 1844674407370955520.. 2305843009213694335: 0 + 2305843009213694336.. 2767011611056433151: 0 + 2767011611056433152.. 3228180212899171967: 0 + 3228180212899171968.. 3689348814741910783: 0 + 3689348814741910784.. 4150517416584649599: 0 + 4150517416584649600.. 4611686018427387903: ################# 189 + -4611686018427387392..-4150517416584648577: 0 +================================================================================ +1 warning(s) +failure (9 tests failed, 1 tests errored, ran 25 tests) +random seed: 153870556 + ++++ Stats for stat_display_test9 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats dist: + num: 1000, avg: -10119269408092442.00, stddev: 1871251663919905536.00, median 9, min -4576142151952919207, max 4611686018427387903 + -4576142151952919207..-4116750743433903848: ## 25 + -4116750743433903847..-3657359334914888488: ## 23 + -3657359334914888487..-3197967926395873128: ### 30 + -3197967926395873127..-2738576517876857768: ## 24 + -2738576517876857767..-2279185109357842408: ## 28 + -2279185109357842407..-1819793700838827048: ## 21 + -1819793700838827047..-1360402292319811688: # 19 + -1360402292319811687.. -901010883800796328: ## 27 + -901010883800796327.. -441619475281780968: ## 27 + -441619475281780967.. 17771933237234392: ####################################################### 540 + 17771933237234393.. 477163341756249752: ## 21 + 477163341756249753.. 936554750275265112: # 19 + 936554750275265113.. 1395946158794280472: ## 24 + 1395946158794280473.. 1855337567313295832: ## 27 + 1855337567313295833.. 2314728975832311192: ## 21 + 2314728975832311193.. 2774120384351326552: ## 23 + 2774120384351326553.. 3233511792870341912: ### 36 + 3233511792870341913.. 3692903201389357272: # 17 + 3692903201389357273.. 4152294609908372632: ## 21 + 4152294609908372633.. 4611686018427387903: ## 27 + -4611686018427387815..-4152294609908372456: 0 +================================================================================ +success (ran 1 tests) diff --git a/test/core/qcheck_output.txt.expected b/test/core/qcheck_output.txt.expected new file mode 100644 index 00000000..96cc4f67 --- /dev/null +++ b/test/core/qcheck_output.txt.expected @@ -0,0 +1,373 @@ +random seed: 1234 + +--- Failure -------------------------------------------------------------------- + +Test should_fail_sort_id failed (18 shrink steps): + +[1; 0] + +=== Error ====================================================================== + +Test should_error_raise_exn errored on (63 shrink steps): + +0 + +exception Dune__exe__QCheck_expect_test.Error + + ++++ Collect ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +Collect results for test collect_results: + +4: 20 cases +3: 25 cases +2: 17 cases +1: 18 cases +0: 20 cases + ++++ Stats for with_stats ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats mod4: + num: 100, avg: 1.68, stddev: 1.09, median 2, min 0, max 3 + 0: ############################## 17 + 1: ################################################### 29 + 2: ######################################## 23 + 3: ####################################################### 31 + +stats num: + num: 100, avg: 66.84, stddev: 31.94, median 65, min 2, max 120 + 2.. 7: ################## 3 + 8.. 13: ################## 3 + 14.. 19: 0 + 20.. 25: ########################################## 7 + 26.. 31: ######################## 4 + 32.. 37: ######################## 4 + 38.. 43: ################## 3 + 44.. 49: ################################################ 8 + 50.. 55: #################################### 6 + 56.. 61: #################################### 6 + 62.. 67: ####################################################### 9 + 68.. 73: ########################################## 7 + 74.. 79: ######################## 4 + 80.. 85: ################## 3 + 86.. 91: ############ 2 + 92.. 97: ########################################## 7 + 98..103: #################################### 6 + 104..109: #################################### 6 + 110..115: ####################################################### 9 + 116..121: ################## 3 + +--- Failure -------------------------------------------------------------------- + +Test FAIL_pred_map_commute failed (127 shrink steps): + +([3], {_ -> 0}, {3 -> false; _ -> true}) + +--- Failure -------------------------------------------------------------------- + +Test FAIL_fun2_pred_strings failed (1 shrink steps): + +{some random string -> true; _ -> false} + +--- Failure -------------------------------------------------------------------- + +Test fold_left fold_right failed (25 shrink steps): + +(0, [1], {(1, 0) -> 1; _ -> 0}) + ++++ Messages ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +Messages for test fold_left fold_right: + +l=[1], fold_left=1, fold_right=0 + + +--- Failure -------------------------------------------------------------------- + +Test fold_left fold_right uncurried failed (111 shrink steps): + +({(5, 7) -> 0; _ -> 7}, 0, [5; 0]) + +--- Failure -------------------------------------------------------------------- + +Test long_shrink failed (149 shrink steps): + +([0], [-1]) + +--- Failure -------------------------------------------------------------------- + +Test mod3_should_fail failed (84 shrink steps): + +-21 + +!!! Warning !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +Warning for test WARN_unlikely_precond: + +WARNING: only 0.5% tests (of 2000) passed precondition for "WARN_unlikely_precond" + +NOTE: it is likely that the precondition is too strong, or that the generator is buggy. + +--- Failure -------------------------------------------------------------------- + +Test FAIL_unlikely_precond failed: + +ERROR: only 0.5% tests (of 2000) passed precondition for "FAIL_unlikely_precond" + +NOTE: it is likely that the precondition is too strong, or that the generator is buggy. + + +--- Failure -------------------------------------------------------------------- + +Test FAIL_#99_1 failed: + +ERROR: uncaught exception in generator for test FAIL_#99_1 after 100 steps: +Exception: QCheck.No_example_found("") +Backtrace: + ++++ Stats for stats_neg ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats dist: + num: 5000, avg: 0.17, stddev: 29.68, median 0, min -99, max 99 + -99..-90: # 65 + -89..-80: # 63 + -79..-70: # 64 + -69..-60: # 58 + -59..-50: # 67 + -49..-40: # 72 + -39..-30: # 61 + -29..-20: # 61 + -19..-10: # 67 + -9.. 0: ####################################################### 2076 + 1.. 10: ############################################## 1764 + 11.. 20: # 66 + 21.. 30: # 64 + 31.. 40: # 64 + 41.. 50: # 67 + 51.. 60: # 60 + 61.. 70: # 75 + 71.. 80: # 60 + 81.. 90: # 60 + 91..100: # 66 + ++++ Stats for stat_display_test_1 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats dist: + num: 1000, avg: 0.90, stddev: 28.23, median 0, min -99, max 99 + -99..-90: # 12 + -89..-80: # 11 + -79..-70: # 9 + -69..-60: 6 + -59..-50: # 11 + -49..-40: # 13 + -39..-30: # 9 + -29..-20: # 13 + -19..-10: 8 + -9.. 0: ####################################################### 453 + 1.. 10: ######################################### 340 + 11.. 20: # 15 + 21.. 30: # 11 + 31.. 40: # 12 + 41.. 50: # 13 + 51.. 60: # 13 + 61.. 70: # 16 + 71.. 80: # 9 + 81.. 90: # 16 + 91..100: # 10 + ++++ Stats for stat_display_test_2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats dist: + num: 1000, avg: 15.11, stddev: 23.27, median 6, min 0, max 99 + 0.. 4: #################################################### 377 + 5.. 9: ####################################################### 392 + 10.. 14: ## 20 + 15.. 19: ## 15 + 20.. 24: # 11 + 25.. 29: ## 17 + 30.. 34: ## 19 + 35.. 39: ## 17 + 40.. 44: # 10 + 45.. 49: # 9 + 50.. 54: # 8 + 55.. 59: # 9 + 60.. 64: ## 15 + 65.. 69: # 10 + 70.. 74: # 13 + 75.. 79: ## 19 + 80.. 84: # 11 + 85.. 89: # 13 + 90.. 94: 5 + 95.. 99: # 10 + ++++ Stats for stat_display_test_3 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats dist: + num: 1000, avg: 195335.64, stddev: 136803.99, median 195583, min -43624, max 435210 + -43624..-19683: ############################################ 52 + -19682.. 4259: ######################################## 47 + 4260.. 28201: ############################## 36 + 28202.. 52143: ############################################ 52 + 52144.. 76085: ########################################## 50 + 76086..100027: ####################################################### 64 + 100028..123969: ############################################### 55 + 123970..147911: ######################################## 47 + 147912..171853: ############################################## 54 + 171854..195795: #################################### 43 + 195796..219737: ############################################## 54 + 219738..243679: ########################################### 51 + 243680..267621: ################################################ 57 + 267622..291563: ########################################## 49 + 291564..315505: #################################### 42 + 315506..339447: ###################################### 45 + 339448..363389: ################################################ 57 + 363390..387331: ###################################### 45 + 387332..411273: ########################################## 49 + 411274..435215: ########################################### 51 + ++++ Stats for stat_display_test_4 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats dist: + num: 1000, avg: -173.78, stddev: 23042.92, median 180, min -39859, max 39942 + -39859..-35869: ############################################# 56 + -35868..-31878: ################################### 43 + -31877..-27887: ################################################# 60 + -27886..-23896: ##################################### 46 + -23895..-19905: ######################################## 49 + -19904..-15914: #################################### 45 + -15913..-11923: ############################################ 54 + -11922.. -7932: ############################################### 58 + -7931.. -3941: ######################################### 51 + -3940.. 50: ############################ 35 + 51.. 4041: ####################################### 48 + 4042.. 8032: ########################################## 52 + 8033.. 12023: ######################################### 51 + 12024.. 16014: ########################################### 53 + 16015.. 20005: ############################################ 54 + 20006.. 23996: ################################## 42 + 23997.. 27987: ####################################################### 67 + 27988.. 31978: ################################ 40 + 31979.. 35969: ######################################### 51 + 35970.. 39960: #################################### 45 + ++++ Stats for stat_display_test_5 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats dist: + num: 1000, avg: 0.02, stddev: 2.55, median 0, min -4, max 4 + -4: ############################################ 99 + -3: ##################################################### 118 + -2: ################################################## 111 + -1: ################################################## 113 + 0: ################################################## 113 + 1: ##################################################### 118 + 2: ############################################# 102 + 3: ####################################################### 122 + 4: ############################################## 104 + ++++ Stats for stat_display_test_6 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats dist: + num: 1000, avg: 6.67, stddev: 6.39, median 7, min -4, max 17 + -4..-3: ############################################# 90 + -2..-1: ############################################# 91 + 0.. 1: ########################################## 84 + 2.. 3: ############################################## 92 + 4.. 5: ########################################### 87 + 6.. 7: ########################################### 86 + 8.. 9: ############################################ 89 + 10..11: ########################################### 87 + 12..13: ####################################################### 110 + 14..15: ############################################# 91 + 16..17: ############################################## 93 + 18..19: 0 + 20..21: 0 + 22..23: 0 + 24..25: 0 + 26..27: 0 + 28..29: 0 + 30..31: 0 + 32..33: 0 + 34..35: 0 + ++++ Stats for stat_display_test_7 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats dist: + num: 100000, avg: 2541076923587387.50, stddev: 2660730801206827008.00, median 158655268318060, min -4611522359435274428, max 4611540922436307689 + -4611522359435274428..-4150369195341695293: ##################################################### 4976 + -4150369195341695292..-3689216031248116157: ##################################################### 4963 + -3689216031248116156..-3228062867154537021: ###################################################### 5038 + -3228062867154537020..-2766909703060957885: ##################################################### 4979 + -2766909703060957884..-2305756538967378749: ##################################################### 5001 + -2305756538967378748..-1844603374873799613: ##################################################### 4982 + -1844603374873799612..-1383450210780220477: ##################################################### 5025 + -1383450210780220476.. -922297046686641341: #################################################### 4901 + -922297046686641340.. -461143882593062205: ####################################################### 5126 + -461143882593062204.. 9281500516931: ##################################################### 5008 + 9281500516932.. 461162445594096067: ###################################################### 5041 + 461162445594096068.. 922315609687675203: ##################################################### 5001 + 922315609687675204.. 1383468773781254339: ##################################################### 4986 + 1383468773781254340.. 1844621937874833475: ##################################################### 4949 + 1844621937874833476.. 2305775101968412611: ##################################################### 5025 + 2305775101968412612.. 2766928266061991747: ##################################################### 5022 + 2766928266061991748.. 3228081430155570883: ##################################################### 4958 + 3228081430155570884.. 3689234594249150019: ##################################################### 4998 + 3689234594249150020.. 4150387758342729155: ##################################################### 4982 + 4150387758342729156.. 4611540922436308291: ###################################################### 5039 + ++++ Stats for stat_display_test_8 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats dist: + num: 1000, avg: 4611686018427388.00, stddev: 2905870896563567616.00, median 0, min -4611686018427387904, max 4611686018427387903 + -4611686018427387904..-4150517416584649089: ################## 208 + -4150517416584649088..-3689348814741910273: 0 + -3689348814741910272..-3228180212899171457: 0 + -3228180212899171456..-2767011611056432641: 0 + -2767011611056432640..-2305843009213693825: 0 + -2305843009213693824..-1844674407370955009: 0 + -1844674407370955008..-1383505805528216193: 0 + -1383505805528216192.. -922337203685477377: 0 + -922337203685477376.. -461168601842738561: 0 + -461168601842738560.. 255: ####################################################### 603 + 256.. 461168601842739071: 0 + 461168601842739072.. 922337203685477887: 0 + 922337203685477888.. 1383505805528216703: 0 + 1383505805528216704.. 1844674407370955519: 0 + 1844674407370955520.. 2305843009213694335: 0 + 2305843009213694336.. 2767011611056433151: 0 + 2767011611056433152.. 3228180212899171967: 0 + 3228180212899171968.. 3689348814741910783: 0 + 3689348814741910784.. 4150517416584649599: 0 + 4150517416584649600.. 4611686018427387903: ################# 189 + -4611686018427387392..-4150517416584648577: 0 +================================================================================ +1 warning(s) +failure (9 tests failed, 1 tests errored, ran 25 tests) +random seed: 153870556 + ++++ Stats for stat_display_test9 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats dist: + num: 1000, avg: -55083208105414400.00, stddev: 1847115855773139200.00, median 9, min -4590718933436425025, max 4611686018427387903 + -4590718933436425025..-4130598685843234370: ## 26 + -4130598685843234369..-3670478438250043714: # 13 + -3670478438250043713..-3210358190656853058: ### 37 + -3210358190656853057..-2750237943063662402: ### 30 + -2750237943063662401..-2290117695470471746: ## 27 + -2290117695470471745..-1829997447877281090: ## 24 + -1829997447877281089..-1369877200284090434: ## 27 + -1369877200284090433.. -909756952690899778: ## 27 + -909756952690899777.. -449636705097709122: ## 21 + -449636705097709121.. 10483542495481534: ####################################################### 531 + 10483542495481535.. 470603790088672190: ## 21 + 470603790088672191.. 930724037681862846: ## 27 + 930724037681862847.. 1390844285275053502: ## 24 + 1390844285275053503.. 1850964532868244158: ## 25 + 1850964532868244159.. 2311084780461434814: ## 28 + 2311084780461434815.. 2771205028054625470: ## 23 + 2771205028054625471.. 3231325275647816126: ## 23 + 3231325275647816127.. 3691445523241006782: ## 25 + 3691445523241006783.. 4151565770834197438: # 17 + 4151565770834197439.. 4611686018427387903: ## 24 + -4611686018427387713..-4151565770834197058: 0 +================================================================================ +success (ran 1 tests) From f02ea4b8df99f2d08a1aa4a15f9680109e920589 Mon Sep 17 00:00:00 2001 From: Jan Midtgaard Date: Wed, 11 Aug 2021 17:48:27 +0200 Subject: [PATCH 27/49] add fun prop illustrating fun-last advantage --- test/core/QCheck2_expect_test.ml | 14 ++++++++++++++ test/core/QCheck_expect_test.ml | 13 +++++++++++++ test/core/qcheck2_output.txt.expected | 8 +++++++- test/core/qcheck_output.txt.expected | 8 +++++++- 4 files changed, 41 insertions(+), 2 deletions(-) diff --git a/test/core/QCheck2_expect_test.ml b/test/core/QCheck2_expect_test.ml index 7f471fda..df29a53b 100644 --- a/test/core/QCheck2_expect_test.ml +++ b/test/core/QCheck2_expect_test.ml @@ -89,6 +89,19 @@ let prop_foldleft_foldright_uncurry = List.fold_right (fun x y -> Fn.apply f (x,y)) xs z = List.fold_left (fun x y -> Fn.apply f (x,y)) z xs) +(* Same as the above (false) property, but generating+shrinking functions last *) +let prop_foldleft_foldright_uncurry_funlast = + let open QCheck2 in + Test.make ~name:"fold_left fold_right uncurried fun last" ~count:1000 ~long_factor:20 + ~print:Print.(triple int (list int) Fn.print) + Gen.(triple + int_gen + (list int_gen) + (fun1 ~print:Print.int Observable.(pair int int) int_gen)) + (fun (z,xs,f) -> + List.fold_right (fun x y -> Fn.apply f (x,y)) xs z = + List.fold_left (fun x y -> Fn.apply f (x,y)) z xs) + let long_shrink = let open QCheck2 in let listgen = Gen.(list_size (int_range 1000 10000) int) in @@ -180,6 +193,7 @@ let _ = fun2; prop_foldleft_foldright; prop_foldleft_foldright_uncurry; + prop_foldleft_foldright_uncurry_funlast; long_shrink; shrink_int; bad_assume_warn; diff --git a/test/core/QCheck_expect_test.ml b/test/core/QCheck_expect_test.ml index ca0fd0f9..74f6e4e5 100644 --- a/test/core/QCheck_expect_test.ml +++ b/test/core/QCheck_expect_test.ml @@ -86,6 +86,18 @@ let prop_foldleft_foldright_uncurry = List.fold_right (fun x y -> Fn.apply f (x,y)) xs z = List.fold_left (fun x y -> Fn.apply f (x,y)) z xs) +(* Same as the above (false) property, but generating+shrinking functions last *) +let prop_foldleft_foldright_uncurry_funlast = + let open QCheck in + Test.make ~name:"fold_left fold_right uncurried fun last" ~count:1000 ~long_factor:20 + (triple + int_gen + (list int_gen) + (fun1 Observable.(pair int int) int_gen)) + (fun (z,xs,f) -> + List.fold_right (fun x y -> Fn.apply f (x,y)) xs z = + List.fold_left (fun x y -> Fn.apply f (x,y)) z xs) + let long_shrink = let open QCheck in let listgen = list_of_size (Gen.int_range 1000 10000) int in @@ -172,6 +184,7 @@ let i = fun2; prop_foldleft_foldright; prop_foldleft_foldright_uncurry; + prop_foldleft_foldright_uncurry_funlast; long_shrink; shrink_int; bad_assume_warn; diff --git a/test/core/qcheck2_output.txt.expected b/test/core/qcheck2_output.txt.expected index eeb19832..502164af 100644 --- a/test/core/qcheck2_output.txt.expected +++ b/test/core/qcheck2_output.txt.expected @@ -90,6 +90,12 @@ Test fold_left fold_right uncurried failed (325 shrink steps): --- Failure -------------------------------------------------------------------- +Test fold_left fold_right uncurried fun last failed (25 shrink steps): + +(0, [1], {(0, 2) -> 0; (8, 80) -> 0; (93, 9) -> 0; (7, 24) -> 0; (8, 0) -> 0; (9, 7) -> 0; (0, 24) -> 0; (0, 7) -> 0; (7, 1) -> 0; (8, 9) -> 0; (24, 0) -> 0; (5, 8) -> 0; (1, 0) -> 1; (4, 8) -> 0; (7, 0) -> 0; (5, 7) -> 0; (8, 4) -> 0; (24, 5) -> 0; (0, 1) -> 0; (2, 8) -> 0; (9, 1) -> 0; (8, 8) -> 0; _ -> 0}) + +--- Failure -------------------------------------------------------------------- + Test long_shrink failed (3040 shrink steps): ([0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0;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; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 1]) @@ -341,7 +347,7 @@ stats dist: -4611686018427387392..-4150517416584648577: 0 ================================================================================ 1 warning(s) -failure (9 tests failed, 1 tests errored, ran 25 tests) +failure (10 tests failed, 1 tests errored, ran 26 tests) random seed: 153870556 +++ Stats for stat_display_test9 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ diff --git a/test/core/qcheck_output.txt.expected b/test/core/qcheck_output.txt.expected index 96cc4f67..f21ad597 100644 --- a/test/core/qcheck_output.txt.expected +++ b/test/core/qcheck_output.txt.expected @@ -90,6 +90,12 @@ Test fold_left fold_right uncurried failed (111 shrink steps): --- Failure -------------------------------------------------------------------- +Test fold_left fold_right uncurried fun last failed (26 shrink steps): + +(0, [1], {(0, 1) -> 1; _ -> 0}) + +--- Failure -------------------------------------------------------------------- + Test long_shrink failed (149 shrink steps): ([0], [-1]) @@ -341,7 +347,7 @@ stats dist: -4611686018427387392..-4150517416584648577: 0 ================================================================================ 1 warning(s) -failure (9 tests failed, 1 tests errored, ran 25 tests) +failure (10 tests failed, 1 tests errored, ran 26 tests) random seed: 153870556 +++ Stats for stat_display_test9 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ From f53a36737956818c7efe5a88d117d97ac5a5277d Mon Sep 17 00:00:00 2001 From: Jan Midtgaard Date: Wed, 11 Aug 2021 18:11:55 +0200 Subject: [PATCH 28/49] collect tests thematically in sub-modules --- test/core/QCheck2_expect_test.ml | 403 +++++++++++++------------- test/core/QCheck_expect_test.ml | 387 +++++++++++++------------ test/core/qcheck2_output.txt.expected | 36 +-- test/core/qcheck_output.txt.expected | 36 +-- 4 files changed, 446 insertions(+), 416 deletions(-) diff --git a/test/core/QCheck2_expect_test.ml b/test/core/QCheck2_expect_test.ml index df29a53b..da412988 100644 --- a/test/core/QCheck2_expect_test.ml +++ b/test/core/QCheck2_expect_test.ml @@ -1,206 +1,221 @@ (** QCheck2 tests **) -let passing = - QCheck2.Test.make ~count:100 ~long_factor:100 ~print:QCheck2.Print.(list int) - ~name:"list_rev_is_involutive" - QCheck2.Gen.(list small_int) - (fun l -> List.rev (List.rev l) = l);; - -let failing = - QCheck2.Test.make ~count:10 - ~name:"should_fail_sort_id" ~print:QCheck2.Print.(list int) - QCheck2.Gen.(small_list small_int) - (fun l -> l = List.sort compare l);; - -exception Error - -let error = - QCheck2.Test.make ~count:10 - ~name:"should_error_raise_exn" ~print:QCheck2.Print.int - QCheck2.Gen.int - (fun _ -> raise Error) - -let collect = - QCheck2.Test.make ~count:100 ~long_factor:100 - ~name:"collect_results" ~print:QCheck2.Print.int - ~collect:string_of_int (QCheck2.Gen.int_bound 4) - (fun _ -> true) - -let stats = - QCheck2.Test.make ~count:100 ~long_factor:100 - ~name:"with_stats" ~print:QCheck2.Print.int - ~stats:[ - "mod4", (fun i->i mod 4); - "num", (fun i->i); +(* tests of overall functionality *) +module Overall = struct + let passing = + QCheck2.Test.make ~count:100 ~long_factor:100 ~print:QCheck2.Print.(list int) + ~name:"list_rev_is_involutive" + QCheck2.Gen.(list small_int) + (fun l -> List.rev (List.rev l) = l);; + + let failing = + QCheck2.Test.make ~count:10 + ~name:"should_fail_sort_id" ~print:QCheck2.Print.(list int) + QCheck2.Gen.(small_list small_int) + (fun l -> l = List.sort compare l);; + + exception Error + + let error = + QCheck2.Test.make ~count:10 + ~name:"should_error_raise_exn" ~print:QCheck2.Print.int + QCheck2.Gen.int + (fun _ -> raise Error) + + let collect = + QCheck2.Test.make ~count:100 ~long_factor:100 + ~name:"collect_results" ~print:QCheck2.Print.int + ~collect:string_of_int (QCheck2.Gen.int_bound 4) + (fun _ -> true) + + let stats = + QCheck2.Test.make ~count:100 ~long_factor:100 + ~name:"with_stats" ~print:QCheck2.Print.int + ~stats:[ + "mod4", (fun i->i mod 4); + "num", (fun i->i); + ] + (QCheck2.Gen.int_bound 120) + (fun _ -> true) + + let bad_assume_warn = + let open QCheck2 in + Test.make ~count:2_000 + ~name:"WARN_unlikely_precond" ~print:Print.int + Gen.int + (fun x -> + QCheck.assume (x mod 100 = 1); + true) + + let bad_assume_fail = + let open QCheck2 in + Test.make ~count:2_000 ~if_assumptions_fail:(`Fatal, 0.1) + ~name:"FAIL_unlikely_precond" ~print:Print.int + Gen.int + (fun x -> + QCheck.assume (x mod 100 = 1); + true) +end + +(* tests function generator and shrinker *) +module Function = struct + let fun1 = + let open QCheck2 in + Test.make ~count:100 ~long_factor:100 + ~name:"FAIL_pred_map_commute" ~print:Print.(triple (list int) Fn.print Fn.print) + Gen.(triple + (small_list small_int) + (fun1 ~print:Print.int Observable.int int) + (fun1 ~print:Print.bool Observable.int bool)) + (fun (l,QCheck2.Fun (_,f), QCheck2.Fun (_,p)) -> + List.filter p (List.map f l) = List.map f (List.filter p l)) + + let fun2 = + let open QCheck2 in + Test.make ~count:100 + ~name:"FAIL_fun2_pred_strings" ~print:Fn.print + (fun1 Observable.string ~print:Print.bool Gen.bool) + (fun (Fun (_,p)) -> + not (p "some random string") || p "some other string") + + let int_gen = QCheck2.Gen.small_nat (* int *) + + (* Another example (false) property *) + let prop_foldleft_foldright = + let open QCheck2 in + Test.make ~name:"fold_left fold_right" ~count:1000 ~long_factor:20 + ~print:Print.(triple int (list int) Fn.print) + Gen.(triple + int_gen + (list int_gen) + (fun2 ~print:Print.int Observable.int Observable.int int_gen)) + (fun (z,xs,f) -> + let l1 = List.fold_right (Fn.apply f) xs z in + let l2 = List.fold_left (Fn.apply f) z xs in + if l1=l2 then true + else QCheck.Test.fail_reportf "l=%s, fold_left=%s, fold_right=%s@." + (QCheck.Print.(list int) xs) + (QCheck.Print.int l1) + (QCheck.Print.int l2) + ) + + (* Another example (false) property *) + let prop_foldleft_foldright_uncurry = + let open QCheck2 in + Test.make ~name:"fold_left fold_right uncurried" ~count:1000 ~long_factor:20 + ~print:Print.(triple Fn.print int (list int)) + Gen.(triple + (fun1 ~print:Print.int Observable.(pair int int) int_gen) + int_gen + (list int_gen)) + (fun (f,z,xs) -> + List.fold_right (fun x y -> Fn.apply f (x,y)) xs z = + List.fold_left (fun x y -> Fn.apply f (x,y)) z xs) + + (* Same as the above (false) property, but generating+shrinking functions last *) + let prop_foldleft_foldright_uncurry_funlast = + let open QCheck2 in + Test.make ~name:"fold_left fold_right uncurried fun last" ~count:1000 ~long_factor:20 + ~print:Print.(triple int (list int) Fn.print) + Gen.(triple + int_gen + (list int_gen) + (fun1 ~print:Print.int Observable.(pair int int) int_gen)) + (fun (z,xs,f) -> + List.fold_right (fun x y -> Fn.apply f (x,y)) xs z = + List.fold_left (fun x y -> Fn.apply f (x,y)) z xs) +end + +(* tests of shrinking behaviour *) +module Shrink = struct + let long_shrink = + let open QCheck2 in + let listgen = Gen.(list_size (int_range 1000 10000) int) in + Test.make ~name:"long_shrink" ~print:Print.(pair (list int) (list int)) + (Gen.pair listgen listgen) + (fun (xs,ys) -> List.rev (xs@ys) = (List.rev xs)@(List.rev ys)) + + (* test shrinking on integers *) + let shrink_int = + let open QCheck2 in + Test.make ~count:1000 ~name:"mod3_should_fail" ~print:Print.int + Gen.int (fun i -> i mod 3 <> 0) +end + +(* tests of (inner) find_example(_gen) behaviour *) +module FindExample = struct + let find_ex = + let open QCheck2 in + Test.make ~name:"find_example" ~print:Print.int + Gen.(2--50) + (fun n -> + let st = Random.State.make [| 0 |] in + let f m = n < m && m < 2 * n in + try + let m = find_example_gen ~rand:st ~count:100_000 ~f Gen.(0 -- 1000) in + f m + with No_example_found _ -> false) + + let find_ex_uncaught_issue_99 : _ list = + let open QCheck2 in + let t1 = + let rs = (find_example ~count:10 ~f:(fun _ -> false) Gen.int) in + Test.make ~name:"FAIL_#99_1" rs (fun _ -> true) in + let t2 = + Test.make ~name:"should_succeed_#99_2" ~count:10 Gen.int + (fun i -> i <= max_int) in + [t1;t2] +end + +(* tests of statistics and histogram display *) +module Stats = struct + let stats_negs = + QCheck2.(Test.make ~count:5_000 ~name:"stats_neg" + ~stats:[("dist",fun x -> x)] Gen.small_signed_int) + (fun _ -> true) + + let stats_tests = + let open QCheck2 in + let dist = ("dist",fun x -> x) in + [ + Test.make ~name:"stat_display_test_1" ~count:1000 ~stats:[dist] Gen.small_signed_int (fun _ -> true); + Test.make ~name:"stat_display_test_2" ~count:1000 ~stats:[dist] Gen.small_nat (fun _ -> true); + Test.make ~name:"stat_display_test_3" ~count:1000 ~stats:[dist] (Gen.int_range (-43643) 435434) (fun _ -> true); + Test.make ~name:"stat_display_test_4" ~count:1000 ~stats:[dist] (Gen.int_range (-40000) 40000) (fun _ -> true); + Test.make ~name:"stat_display_test_5" ~count:1000 ~stats:[dist] (Gen.int_range (-4) 4) (fun _ -> true); + Test.make ~name:"stat_display_test_6" ~count:1000 ~stats:[dist] (Gen.int_range (-4) 17) (fun _ -> true); + Test.make ~name:"stat_display_test_7" ~count:100000 ~stats:[dist] Gen.int (fun _ -> true); + Test.make ~name:"stat_display_test_8" ~count:1000 ~stats:[dist] (Gen.oneofl[min_int;-1;0;1;max_int]) (fun _ -> true); ] - (QCheck2.Gen.int_bound 120) - (fun _ -> true) - -let fun1 = - let open QCheck2 in - Test.make ~count:100 ~long_factor:100 - ~name:"FAIL_pred_map_commute" ~print:Print.(triple (list int) Fn.print Fn.print) - Gen.(triple - (small_list small_int) - (fun1 ~print:Print.int Observable.int int) - (fun1 ~print:Print.bool Observable.int bool)) - (fun (l,QCheck2.Fun (_,f), QCheck2.Fun (_,p)) -> - List.filter p (List.map f l) = List.map f (List.filter p l)) - -let fun2 = - let open QCheck2 in - Test.make ~count:100 - ~name:"FAIL_fun2_pred_strings" ~print:Fn.print - (fun1 Observable.string ~print:Print.bool Gen.bool) - (fun (Fun (_,p)) -> - not (p "some random string") || p "some other string") - -let int_gen = QCheck2.Gen.small_nat (* int *) - -(* Another example (false) property *) -let prop_foldleft_foldright = - let open QCheck2 in - Test.make ~name:"fold_left fold_right" ~count:1000 ~long_factor:20 - ~print:Print.(triple int (list int) Fn.print) - Gen.(triple - int_gen - (list int_gen) - (fun2 ~print:Print.int Observable.int Observable.int int_gen)) - (fun (z,xs,f) -> - let l1 = List.fold_right (Fn.apply f) xs z in - let l2 = List.fold_left (Fn.apply f) z xs in - if l1=l2 then true - else QCheck.Test.fail_reportf "l=%s, fold_left=%s, fold_right=%s@." - (QCheck.Print.(list int) xs) - (QCheck.Print.int l1) - (QCheck.Print.int l2) - ) - -(* Another example (false) property *) -let prop_foldleft_foldright_uncurry = - let open QCheck2 in - Test.make ~name:"fold_left fold_right uncurried" ~count:1000 ~long_factor:20 - ~print:Print.(triple Fn.print int (list int)) - Gen.(triple - (fun1 ~print:Print.int Observable.(pair int int) int_gen) - int_gen - (list int_gen)) - (fun (f,z,xs) -> - List.fold_right (fun x y -> Fn.apply f (x,y)) xs z = - List.fold_left (fun x y -> Fn.apply f (x,y)) z xs) - -(* Same as the above (false) property, but generating+shrinking functions last *) -let prop_foldleft_foldright_uncurry_funlast = - let open QCheck2 in - Test.make ~name:"fold_left fold_right uncurried fun last" ~count:1000 ~long_factor:20 - ~print:Print.(triple int (list int) Fn.print) - Gen.(triple - int_gen - (list int_gen) - (fun1 ~print:Print.int Observable.(pair int int) int_gen)) - (fun (z,xs,f) -> - List.fold_right (fun x y -> Fn.apply f (x,y)) xs z = - List.fold_left (fun x y -> Fn.apply f (x,y)) z xs) - -let long_shrink = - let open QCheck2 in - let listgen = Gen.(list_size (int_range 1000 10000) int) in - Test.make ~name:"long_shrink" ~print:Print.(pair (list int) (list int)) - (Gen.pair listgen listgen) - (fun (xs,ys) -> List.rev (xs@ys) = (List.rev xs)@(List.rev ys)) - -(* test shrinking on integers *) -let shrink_int = - let open QCheck2 in - Test.make ~count:1000 ~name:"mod3_should_fail" ~print:Print.int - Gen.int (fun i -> i mod 3 <> 0) - -let bad_assume_warn = - let open QCheck2 in - Test.make ~count:2_000 - ~name:"WARN_unlikely_precond" ~print:Print.int - Gen.int - (fun x -> - QCheck.assume (x mod 100 = 1); - true) - -let bad_assume_fail = - let open QCheck2 in - Test.make ~count:2_000 ~if_assumptions_fail:(`Fatal, 0.1) - ~name:"FAIL_unlikely_precond" ~print:Print.int - Gen.int - (fun x -> - QCheck.assume (x mod 100 = 1); - true) - -let find_ex = - let open QCheck2 in - Test.make ~name:"find_example" ~print:Print.int - Gen.(2--50) - (fun n -> - let st = Random.State.make [| 0 |] in - let f m = n < m && m < 2 * n in - try - let m = find_example_gen ~rand:st ~count:100_000 ~f Gen.(0 -- 1000) in - f m - with No_example_found _ -> false) - -let find_ex_uncaught_issue_99 : _ list = - let open QCheck2 in - let t1 = - let rs = (find_example ~count:10 ~f:(fun _ -> false) Gen.int) in - Test.make ~name:"FAIL_#99_1" rs (fun _ -> true) in - let t2 = - Test.make ~name:"should_succeed_#99_2" ~count:10 Gen.int - (fun i -> i <= max_int) in - [t1;t2] - -let stats_negs = - QCheck2.(Test.make ~count:5_000 ~name:"stats_neg" - ~stats:[("dist",fun x -> x)] Gen.small_signed_int) - (fun _ -> true) - -let stats_tests = - let open QCheck2 in - let dist = ("dist",fun x -> x) in - [ - Test.make ~name:"stat_display_test_1" ~count:1000 ~stats:[dist] Gen.small_signed_int (fun _ -> true); - Test.make ~name:"stat_display_test_2" ~count:1000 ~stats:[dist] Gen.small_nat (fun _ -> true); - Test.make ~name:"stat_display_test_3" ~count:1000 ~stats:[dist] (Gen.int_range (-43643) 435434) (fun _ -> true); - Test.make ~name:"stat_display_test_4" ~count:1000 ~stats:[dist] (Gen.int_range (-40000) 40000) (fun _ -> true); - Test.make ~name:"stat_display_test_5" ~count:1000 ~stats:[dist] (Gen.int_range (-4) 4) (fun _ -> true); - Test.make ~name:"stat_display_test_6" ~count:1000 ~stats:[dist] (Gen.int_range (-4) 17) (fun _ -> true); - Test.make ~name:"stat_display_test_7" ~count:100000 ~stats:[dist] Gen.int (fun _ -> true); - Test.make ~name:"stat_display_test_8" ~count:1000 ~stats:[dist] (Gen.oneofl[min_int;-1;0;1;max_int]) (fun _ -> true); - ] - -let stat_display_test9 = - let open QCheck2 in - Test.make ~name:"stat_display_test9" ~count:1_000 - ~stats:[("dist",fun x -> x)] Gen.(oneof [small_int_corners ();int]) (fun _ -> true) + + let stat_display_test9 = + let open QCheck2 in + Test.make ~name:"stat_display_test9" ~count:1_000 + ~stats:[("dist",fun x -> x)] Gen.(oneof [small_int_corners ();int]) (fun _ -> true) +end (* Calling runners *) let () = QCheck_base_runner.set_seed 1234 let _ = QCheck_base_runner.run_tests ~colors:false ([ - passing; - failing; - error; - collect; - stats; - fun1; - fun2; - prop_foldleft_foldright; - prop_foldleft_foldright_uncurry; - prop_foldleft_foldright_uncurry_funlast; - long_shrink; - shrink_int; - bad_assume_warn; - bad_assume_fail; - ] @ find_ex :: find_ex_uncaught_issue_99 - @ stats_negs :: stats_tests) + Overall.passing; + Overall.failing; + Overall.error; + Overall.collect; + Overall.stats; + Overall.bad_assume_warn; + Overall.bad_assume_fail; + Function.fun1; + Function.fun2; + Function.prop_foldleft_foldright; + Function.prop_foldleft_foldright_uncurry; + Function.prop_foldleft_foldright_uncurry_funlast; + Shrink.long_shrink; + Shrink.shrink_int; + ] @ FindExample.find_ex :: FindExample.find_ex_uncaught_issue_99 + @ Stats.stats_negs :: Stats.stats_tests) let () = QCheck_base_runner.set_seed 153870556 -let _ = QCheck_base_runner.run_tests ~colors:false [stat_display_test9] +let _ = QCheck_base_runner.run_tests ~colors:false [Stats.stat_display_test9] diff --git a/test/core/QCheck_expect_test.ml b/test/core/QCheck_expect_test.ml index 74f6e4e5..c75a93ca 100644 --- a/test/core/QCheck_expect_test.ml +++ b/test/core/QCheck_expect_test.ml @@ -1,196 +1,211 @@ (** QCheck(1) tests **) -let passing = - QCheck.Test.make ~count:100 ~long_factor:100 - ~name:"list_rev_is_involutive" - QCheck.(list small_int) - (fun l -> List.rev (List.rev l) = l) - -let failing = - QCheck.Test.make ~count:10 - ~name:"should_fail_sort_id" - QCheck.(small_list small_int) - (fun l -> l = List.sort compare l) - -exception Error - -let error = - QCheck.Test.make ~count:10 - ~name:"should_error_raise_exn" - QCheck.int - (fun _ -> raise Error) - -let collect = - QCheck.Test.make ~count:100 ~long_factor:100 - ~name:"collect_results" - QCheck.(make ~collect:string_of_int (Gen.int_bound 4)) - (fun _ -> true) - -let stats = - QCheck.Test.make ~count:100 ~long_factor:100 - ~name:"with_stats" - QCheck.(make (Gen.int_bound 120) - ~stats:[ - "mod4", (fun i->i mod 4); - "num", (fun i->i); - ] - ) - (fun _ -> true) - -let fun1 = - QCheck.Test.make ~count:100 ~long_factor:100 - ~name:"FAIL_pred_map_commute" - QCheck.(triple - (small_list small_int) - (fun1 Observable.int int) - (fun1 Observable.int bool)) - (fun (l,QCheck.Fun (_,f), QCheck.Fun (_,p)) -> - List.filter p (List.map f l) = List.map f (List.filter p l)) - -let fun2 = - QCheck.Test.make ~count:100 - ~name:"FAIL_fun2_pred_strings" - QCheck.(fun1 Observable.string bool) - (fun (QCheck.Fun (_,p)) -> - not (p "some random string") || p "some other string") - -let int_gen = QCheck.small_nat (* int *) - -(* Another example (false) property *) -let prop_foldleft_foldright = - let open QCheck in - Test.make ~name:"fold_left fold_right" ~count:1000 ~long_factor:20 - (triple - int_gen - (list int_gen) - (fun2 Observable.int Observable.int int_gen)) - (fun (z,xs,f) -> - let l1 = List.fold_right (Fn.apply f) xs z in - let l2 = List.fold_left (Fn.apply f) z xs in - if l1=l2 then true - else QCheck.Test.fail_reportf "l=%s, fold_left=%s, fold_right=%s@." - (QCheck.Print.(list int) xs) - (QCheck.Print.int l1) - (QCheck.Print.int l2) - ) - -(* Another example (false) property *) -let prop_foldleft_foldright_uncurry = - let open QCheck in - Test.make ~name:"fold_left fold_right uncurried" ~count:1000 ~long_factor:20 - (triple - (fun1 Observable.(pair int int) int_gen) - int_gen - (list int_gen)) - (fun (f,z,xs) -> - List.fold_right (fun x y -> Fn.apply f (x,y)) xs z = - List.fold_left (fun x y -> Fn.apply f (x,y)) z xs) - -(* Same as the above (false) property, but generating+shrinking functions last *) -let prop_foldleft_foldright_uncurry_funlast = - let open QCheck in - Test.make ~name:"fold_left fold_right uncurried fun last" ~count:1000 ~long_factor:20 - (triple - int_gen - (list int_gen) - (fun1 Observable.(pair int int) int_gen)) - (fun (z,xs,f) -> - List.fold_right (fun x y -> Fn.apply f (x,y)) xs z = - List.fold_left (fun x y -> Fn.apply f (x,y)) z xs) - -let long_shrink = - let open QCheck in - let listgen = list_of_size (Gen.int_range 1000 10000) int in - Test.make ~name:"long_shrink" (pair listgen listgen) - (fun (xs,ys) -> List.rev (xs@ys) = (List.rev xs)@(List.rev ys)) - -(* test shrinking on integers *) -let shrink_int = - QCheck.Test.make ~count:1000 ~name:"mod3_should_fail" - QCheck.int (fun i -> i mod 3 <> 0) - -let bad_assume_warn = - QCheck.Test.make ~count:2_000 - ~name:"WARN_unlikely_precond" - QCheck.int - (fun x -> - QCheck.assume (x mod 100 = 1); - true) - -let bad_assume_fail = - QCheck.Test.make ~count:2_000 ~if_assumptions_fail:(`Fatal, 0.1) - ~name:"FAIL_unlikely_precond" - QCheck.int - (fun x -> - QCheck.assume (x mod 100 = 1); - true) - -let find_ex = - let open QCheck in - Test.make ~name:"find_example" (2--50) - (fun n -> - let st = Random.State.make [| 0 |] in - let f m = n < m && m < 2 * n in - try - let m = find_example_gen ~rand:st ~count:100_000 ~f Gen.(0 -- 1000) in - f m - with No_example_found _ -> false) - -let find_ex_uncaught_issue_99 : _ list = - let open QCheck in - let t1 = - let rs = make (find_example ~count:10 ~f:(fun _ -> false) Gen.int) in - Test.make ~name:"FAIL_#99_1" rs (fun _ -> true) in - let t2 = - Test.make ~name:"should_succeed_#99_2" ~count:10 int - (fun i -> i <= max_int) in - [t1;t2] - -let stats_negs = - QCheck.(Test.make ~count:5_000 ~name:"stats_neg" - (add_stat ("dist",fun x -> x) small_signed_int)) - (fun _ -> true) - -let stats_tests = - let open QCheck in - let dist = ("dist",fun x -> x) in - [ - Test.make ~name:"stat_display_test_1" ~count:1000 (add_stat dist small_signed_int) (fun _ -> true); - Test.make ~name:"stat_display_test_2" ~count:1000 (add_stat dist small_nat) (fun _ -> true); - Test.make ~name:"stat_display_test_3" ~count:1000 (add_stat dist (int_range (-43643) 435434)) (fun _ -> true); - Test.make ~name:"stat_display_test_4" ~count:1000 (add_stat dist (int_range (-40000) 40000)) (fun _ -> true); - Test.make ~name:"stat_display_test_5" ~count:1000 (add_stat dist (int_range (-4) 4)) (fun _ -> true); - Test.make ~name:"stat_display_test_6" ~count:1000 (add_stat dist (int_range (-4) 17)) (fun _ -> true); - Test.make ~name:"stat_display_test_7" ~count:100000 (add_stat dist int) (fun _ -> true); - Test.make ~name:"stat_display_test_8" ~count:1000 (add_stat dist (oneofl[min_int;-1;0;1;max_int])) (fun _ -> true); - ] - -let stat_display_test9 = - let open QCheck in - Test.make ~name:"stat_display_test9" ~count:1_000 - (add_stat ("dist",fun x -> x) (oneof [small_int_corners ();int])) (fun _ -> true) +(* tests of overall functionality *) +module Overall = struct + let passing = + QCheck.Test.make ~count:100 ~long_factor:100 + ~name:"list_rev_is_involutive" + QCheck.(list small_int) + (fun l -> List.rev (List.rev l) = l) + + let failing = + QCheck.Test.make ~count:10 + ~name:"should_fail_sort_id" + QCheck.(small_list small_int) + (fun l -> l = List.sort compare l) + + exception Error + + let error = + QCheck.Test.make ~count:10 + ~name:"should_error_raise_exn" + QCheck.int + (fun _ -> raise Error) + + let collect = + QCheck.Test.make ~count:100 ~long_factor:100 + ~name:"collect_results" + QCheck.(make ~collect:string_of_int (Gen.int_bound 4)) + (fun _ -> true) + + let stats = + QCheck.Test.make ~count:100 ~long_factor:100 + ~name:"with_stats" + QCheck.(make (Gen.int_bound 120) + ~stats:[ + "mod4", (fun i->i mod 4); + "num", (fun i->i); + ] + ) + (fun _ -> true) + + let bad_assume_warn = + QCheck.Test.make ~count:2_000 + ~name:"WARN_unlikely_precond" + QCheck.int + (fun x -> + QCheck.assume (x mod 100 = 1); + true) + + let bad_assume_fail = + QCheck.Test.make ~count:2_000 ~if_assumptions_fail:(`Fatal, 0.1) + ~name:"FAIL_unlikely_precond" + QCheck.int + (fun x -> + QCheck.assume (x mod 100 = 1); + true) +end + +(* tests function generator and shrinker *) +module Function = struct + let fun1 = + QCheck.Test.make ~count:100 ~long_factor:100 + ~name:"FAIL_pred_map_commute" + QCheck.(triple + (small_list small_int) + (fun1 Observable.int int) + (fun1 Observable.int bool)) + (fun (l,QCheck.Fun (_,f), QCheck.Fun (_,p)) -> + List.filter p (List.map f l) = List.map f (List.filter p l)) + + let fun2 = + QCheck.Test.make ~count:100 + ~name:"FAIL_fun2_pred_strings" + QCheck.(fun1 Observable.string bool) + (fun (QCheck.Fun (_,p)) -> + not (p "some random string") || p "some other string") + + let int_gen = QCheck.small_nat (* int *) + + (* Another example (false) property *) + let prop_foldleft_foldright = + let open QCheck in + Test.make ~name:"fold_left fold_right" ~count:1000 ~long_factor:20 + (triple + int_gen + (list int_gen) + (fun2 Observable.int Observable.int int_gen)) + (fun (z,xs,f) -> + let l1 = List.fold_right (Fn.apply f) xs z in + let l2 = List.fold_left (Fn.apply f) z xs in + if l1=l2 then true + else QCheck.Test.fail_reportf "l=%s, fold_left=%s, fold_right=%s@." + (QCheck.Print.(list int) xs) + (QCheck.Print.int l1) + (QCheck.Print.int l2) + ) + + (* Another example (false) property *) + let prop_foldleft_foldright_uncurry = + let open QCheck in + Test.make ~name:"fold_left fold_right uncurried" ~count:1000 ~long_factor:20 + (triple + (fun1 Observable.(pair int int) int_gen) + int_gen + (list int_gen)) + (fun (f,z,xs) -> + List.fold_right (fun x y -> Fn.apply f (x,y)) xs z = + List.fold_left (fun x y -> Fn.apply f (x,y)) z xs) + + (* Same as the above (false) property, but generating+shrinking functions last *) + let prop_foldleft_foldright_uncurry_funlast = + let open QCheck in + Test.make ~name:"fold_left fold_right uncurried fun last" ~count:1000 ~long_factor:20 + (triple + int_gen + (list int_gen) + (fun1 Observable.(pair int int) int_gen)) + (fun (z,xs,f) -> + List.fold_right (fun x y -> Fn.apply f (x,y)) xs z = + List.fold_left (fun x y -> Fn.apply f (x,y)) z xs) +end + +(* tests of shrinking behaviour *) +module Shrink = struct + let long_shrink = + let open QCheck in + let listgen = list_of_size (Gen.int_range 1000 10000) int in + Test.make ~name:"long_shrink" (pair listgen listgen) + (fun (xs,ys) -> List.rev (xs@ys) = (List.rev xs)@(List.rev ys)) + + (* test shrinking on integers *) + let shrink_int = + QCheck.Test.make ~count:1000 ~name:"mod3_should_fail" + QCheck.int (fun i -> i mod 3 <> 0) +end + +(* tests of (inner) find_example(_gen) behaviour *) +module FindExample = struct + let find_ex = + let open QCheck in + Test.make ~name:"find_example" (2--50) + (fun n -> + let st = Random.State.make [| 0 |] in + let f m = n < m && m < 2 * n in + try + let m = find_example_gen ~rand:st ~count:100_000 ~f Gen.(0 -- 1000) in + f m + with No_example_found _ -> false) + + let find_ex_uncaught_issue_99 : _ list = + let open QCheck in + let t1 = + let rs = make (find_example ~count:10 ~f:(fun _ -> false) Gen.int) in + Test.make ~name:"FAIL_#99_1" rs (fun _ -> true) in + let t2 = + Test.make ~name:"should_succeed_#99_2" ~count:10 int + (fun i -> i <= max_int) in + [t1;t2] +end + +(* tests of statistics and histogram display *) +module Stats = struct + let stats_negs = + QCheck.(Test.make ~count:5_000 ~name:"stats_neg" + (add_stat ("dist",fun x -> x) small_signed_int)) + (fun _ -> true) + + let stats_tests = + let open QCheck in + let dist = ("dist",fun x -> x) in + [ + Test.make ~name:"stat_display_test_1" ~count:1000 (add_stat dist small_signed_int) (fun _ -> true); + Test.make ~name:"stat_display_test_2" ~count:1000 (add_stat dist small_nat) (fun _ -> true); + Test.make ~name:"stat_display_test_3" ~count:1000 (add_stat dist (int_range (-43643) 435434)) (fun _ -> true); + Test.make ~name:"stat_display_test_4" ~count:1000 (add_stat dist (int_range (-40000) 40000)) (fun _ -> true); + Test.make ~name:"stat_display_test_5" ~count:1000 (add_stat dist (int_range (-4) 4)) (fun _ -> true); + Test.make ~name:"stat_display_test_6" ~count:1000 (add_stat dist (int_range (-4) 17)) (fun _ -> true); + Test.make ~name:"stat_display_test_7" ~count:100000 (add_stat dist int) (fun _ -> true); + Test.make ~name:"stat_display_test_8" ~count:1000 (add_stat dist (oneofl[min_int;-1;0;1;max_int])) (fun _ -> true); + ] + + let stat_display_test9 = + let open QCheck in + Test.make ~name:"stat_display_test9" ~count:1_000 + (add_stat ("dist",fun x -> x) (oneof [small_int_corners ();int])) (fun _ -> true) +end (* Calling runners *) let () = QCheck_base_runner.set_seed 1234 let i = QCheck_base_runner.run_tests ~colors:false ([ - passing; - failing; - error; - collect; - stats; - fun1; - fun2; - prop_foldleft_foldright; - prop_foldleft_foldright_uncurry; - prop_foldleft_foldright_uncurry_funlast; - long_shrink; - shrink_int; - bad_assume_warn; - bad_assume_fail; - ] @ find_ex :: find_ex_uncaught_issue_99 - @ stats_negs :: stats_tests) + Overall.passing; + Overall.failing; + Overall.error; + Overall.collect; + Overall.stats; + Overall.bad_assume_warn; + Overall.bad_assume_fail; + Function.fun1; + Function.fun2; + Function.prop_foldleft_foldright; + Function.prop_foldleft_foldright_uncurry; + Function.prop_foldleft_foldright_uncurry_funlast; + Shrink.long_shrink; + Shrink.shrink_int; + ] @ FindExample.find_ex :: FindExample.find_ex_uncaught_issue_99 + @ Stats.stats_negs :: Stats.stats_tests) let () = QCheck_base_runner.set_seed 153870556 -let _ = QCheck_base_runner.run_tests ~colors:false [stat_display_test9] +let _ = QCheck_base_runner.run_tests ~colors:false [Stats.stat_display_test9] diff --git a/test/core/qcheck2_output.txt.expected b/test/core/qcheck2_output.txt.expected index 502164af..a80943f1 100644 --- a/test/core/qcheck2_output.txt.expected +++ b/test/core/qcheck2_output.txt.expected @@ -12,7 +12,7 @@ Test should_error_raise_exn errored on (1 shrink steps): 0 -exception Dune__exe__QCheck2_expect_test.Error +exception Dune__exe__QCheck2_expect_test.Overall.Error +++ Collect ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ @@ -57,6 +57,23 @@ stats num: 110..115: ####################################################### 9 116..121: ################## 3 +!!! Warning !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +Warning for test WARN_unlikely_precond: + +WARNING: only 0.7% tests (of 2000) passed precondition for "WARN_unlikely_precond" + +NOTE: it is likely that the precondition is too strong, or that the generator is buggy. + +--- Failure -------------------------------------------------------------------- + +Test FAIL_unlikely_precond failed: + +ERROR: only 0.7% tests (of 2000) passed precondition for "FAIL_unlikely_precond" + +NOTE: it is likely that the precondition is too strong, or that the generator is buggy. + + --- Failure -------------------------------------------------------------------- Test FAIL_pred_map_commute failed (16 shrink steps): @@ -106,23 +123,6 @@ Test mod3_should_fail failed (1 shrink steps): 0 -!!! Warning !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -Warning for test WARN_unlikely_precond: - -WARNING: only 0.7% tests (of 2000) passed precondition for "WARN_unlikely_precond" - -NOTE: it is likely that the precondition is too strong, or that the generator is buggy. - ---- Failure -------------------------------------------------------------------- - -Test FAIL_unlikely_precond failed: - -ERROR: only 0.7% tests (of 2000) passed precondition for "FAIL_unlikely_precond" - -NOTE: it is likely that the precondition is too strong, or that the generator is buggy. - - --- Failure -------------------------------------------------------------------- Test FAIL_#99_1 failed: diff --git a/test/core/qcheck_output.txt.expected b/test/core/qcheck_output.txt.expected index f21ad597..bce1f16d 100644 --- a/test/core/qcheck_output.txt.expected +++ b/test/core/qcheck_output.txt.expected @@ -12,7 +12,7 @@ Test should_error_raise_exn errored on (63 shrink steps): 0 -exception Dune__exe__QCheck_expect_test.Error +exception Dune__exe__QCheck_expect_test.Overall.Error +++ Collect ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ @@ -57,6 +57,23 @@ stats num: 110..115: ####################################################### 9 116..121: ################## 3 +!!! Warning !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +Warning for test WARN_unlikely_precond: + +WARNING: only 0.5% tests (of 2000) passed precondition for "WARN_unlikely_precond" + +NOTE: it is likely that the precondition is too strong, or that the generator is buggy. + +--- Failure -------------------------------------------------------------------- + +Test FAIL_unlikely_precond failed: + +ERROR: only 0.5% tests (of 2000) passed precondition for "FAIL_unlikely_precond" + +NOTE: it is likely that the precondition is too strong, or that the generator is buggy. + + --- Failure -------------------------------------------------------------------- Test FAIL_pred_map_commute failed (127 shrink steps): @@ -106,23 +123,6 @@ Test mod3_should_fail failed (84 shrink steps): -21 -!!! Warning !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -Warning for test WARN_unlikely_precond: - -WARNING: only 0.5% tests (of 2000) passed precondition for "WARN_unlikely_precond" - -NOTE: it is likely that the precondition is too strong, or that the generator is buggy. - ---- Failure -------------------------------------------------------------------- - -Test FAIL_unlikely_precond failed: - -ERROR: only 0.5% tests (of 2000) passed precondition for "FAIL_unlikely_precond" - -NOTE: it is likely that the precondition is too strong, or that the generator is buggy. - - --- Failure -------------------------------------------------------------------- Test FAIL_#99_1 failed: From dc774325d176afbfe324bb76365a99cdd27368bd Mon Sep 17 00:00:00 2001 From: Jan Midtgaard Date: Wed, 11 Aug 2021 19:02:44 +0200 Subject: [PATCH 29/49] add tests from issue #59 --- test/core/QCheck2_expect_test.ml | 20 ++++++++++++++++++++ test/core/QCheck_expect_test.ml | 20 ++++++++++++++++++++ test/core/qcheck2_output.txt.expected | 8 +++++++- test/core/qcheck_output.txt.expected | 8 +++++++- 4 files changed, 54 insertions(+), 2 deletions(-) diff --git a/test/core/QCheck2_expect_test.ml b/test/core/QCheck2_expect_test.ml index da412988..516e05f5 100644 --- a/test/core/QCheck2_expect_test.ml +++ b/test/core/QCheck2_expect_test.ml @@ -128,6 +128,24 @@ end (* tests of shrinking behaviour *) module Shrink = struct + let rec fac n = match n with + | 0 -> 1 + | n -> n * fac (n - 1) + + (* example from issue #59 *) + let test_fac_issue59 = + let open QCheck2 in + Test.make ~name:"test fac issue59" + (Gen.make_primitive ~gen:(fun st -> Gen.generate1 ~rand:st (Gen.small_int_corners ())) ~shrink:(fun _ -> Seq.empty)) + (fun n -> try (fac n) mod n = 0 + with + (*| Stack_overflow -> false*) + | Division_by_zero -> (n=0)) + + let big_bound_issue59 = + QCheck2.Test.make ~name:"big bound issue59" ~print:QCheck2.Print.int + (QCheck2.Gen.small_int_corners()) (fun i -> i < 209609) + let long_shrink = let open QCheck2 in let listgen = Gen.(list_size (int_range 1000 10000) int) in @@ -211,6 +229,8 @@ let _ = Function.prop_foldleft_foldright; Function.prop_foldleft_foldright_uncurry; Function.prop_foldleft_foldright_uncurry_funlast; + (*Shrink.test_fac_issue59;*) + Shrink.big_bound_issue59; Shrink.long_shrink; Shrink.shrink_int; ] @ FindExample.find_ex :: FindExample.find_ex_uncaught_issue_99 diff --git a/test/core/QCheck_expect_test.ml b/test/core/QCheck_expect_test.ml index c75a93ca..b7337e27 100644 --- a/test/core/QCheck_expect_test.ml +++ b/test/core/QCheck_expect_test.ml @@ -122,6 +122,24 @@ end (* tests of shrinking behaviour *) module Shrink = struct + let rec fac n = match n with + | 0 -> 1 + | n -> n * fac (n - 1) + + (* example from issue #59 *) + let test_fac_issue59 = + let open QCheck in + Test.make ~name:"test fac issue59" + (set_shrink Shrink.nil (small_int_corners ())) + (fun n -> try (fac n) mod n = 0 + with + (*| Stack_overflow -> false*) + | Division_by_zero -> (n=0)) + + let big_bound_issue59 = + QCheck.Test.make ~name:"big bound issue59" + (QCheck.small_int_corners()) (fun i -> i < 209609) + let long_shrink = let open QCheck in let listgen = list_of_size (Gen.int_range 1000 10000) int in @@ -202,6 +220,8 @@ let i = Function.prop_foldleft_foldright; Function.prop_foldleft_foldright_uncurry; Function.prop_foldleft_foldright_uncurry_funlast; + (*Shrink.test_fac_issue59;*) + Shrink.big_bound_issue59; Shrink.long_shrink; Shrink.shrink_int; ] @ FindExample.find_ex :: FindExample.find_ex_uncaught_issue_99 diff --git a/test/core/qcheck2_output.txt.expected b/test/core/qcheck2_output.txt.expected index a80943f1..7705ca0e 100644 --- a/test/core/qcheck2_output.txt.expected +++ b/test/core/qcheck2_output.txt.expected @@ -113,6 +113,12 @@ Test fold_left fold_right uncurried fun last failed (25 shrink steps): --- Failure -------------------------------------------------------------------- +Test big bound issue59 failed (0 shrink steps): + +4611686018427387903 + +--- Failure -------------------------------------------------------------------- + Test long_shrink failed (3040 shrink steps): ([0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0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0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 1]) @@ -347,7 +353,7 @@ stats dist: -4611686018427387392..-4150517416584648577: 0 ================================================================================ 1 warning(s) -failure (10 tests failed, 1 tests errored, ran 26 tests) +failure (11 tests failed, 1 tests errored, ran 27 tests) random seed: 153870556 +++ Stats for stat_display_test9 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ diff --git a/test/core/qcheck_output.txt.expected b/test/core/qcheck_output.txt.expected index bce1f16d..2d54be04 100644 --- a/test/core/qcheck_output.txt.expected +++ b/test/core/qcheck_output.txt.expected @@ -113,6 +113,12 @@ Test fold_left fold_right uncurried fun last failed (26 shrink steps): --- Failure -------------------------------------------------------------------- +Test big bound issue59 failed (52 shrink steps): + +209609 + +--- Failure -------------------------------------------------------------------- + Test long_shrink failed (149 shrink steps): ([0], [-1]) @@ -347,7 +353,7 @@ stats dist: -4611686018427387392..-4150517416584648577: 0 ================================================================================ 1 warning(s) -failure (10 tests failed, 1 tests errored, ran 26 tests) +failure (11 tests failed, 1 tests errored, ran 27 tests) random seed: 153870556 +++ Stats for stat_display_test9 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ From 31a8e0c3d2035888303615492fae9572aa9e1311 Mon Sep 17 00:00:00 2001 From: Jan Midtgaard Date: Thu, 12 Aug 2021 08:56:18 +0200 Subject: [PATCH 30/49] add test (and char dist) from issue #23 --- test/core/QCheck2_expect_test.ml | 16 ++++++++++++- test/core/QCheck_expect_test.ml | 15 +++++++++++- test/core/qcheck2_output.txt.expected | 33 ++++++++++++++++++++++++++- test/core/qcheck_output.txt.expected | 33 ++++++++++++++++++++++++++- 4 files changed, 93 insertions(+), 4 deletions(-) diff --git a/test/core/QCheck2_expect_test.ml b/test/core/QCheck2_expect_test.ml index 516e05f5..4f42331c 100644 --- a/test/core/QCheck2_expect_test.ml +++ b/test/core/QCheck2_expect_test.ml @@ -57,6 +57,14 @@ module Overall = struct true) end +(* test various generators *) +module Generator = struct + (* example from issue #23 *) + let char_dist_issue_23 = + let open QCheck2 in + Test.make ~name:"char never produces '\\255'" ~count:1_000_000 ~print:Print.char Gen.char (fun c -> c <> '\255') +end + (* tests function generator and shrinker *) module Function = struct let fun1 = @@ -187,6 +195,11 @@ end (* tests of statistics and histogram display *) module Stats = struct + let char_dist = + QCheck2.(Test.make ~count:500_000 ~name:"char code dist" + ~stats:[("char code", Char.code)] Gen.char) + (fun _ -> true) + let stats_negs = QCheck2.(Test.make ~count:5_000 ~name:"stats_neg" ~stats:[("dist",fun x -> x)] Gen.small_signed_int) @@ -224,6 +237,7 @@ let _ = Overall.stats; Overall.bad_assume_warn; Overall.bad_assume_fail; + Generator.char_dist_issue_23; Function.fun1; Function.fun2; Function.prop_foldleft_foldright; @@ -234,7 +248,7 @@ let _ = Shrink.long_shrink; Shrink.shrink_int; ] @ FindExample.find_ex :: FindExample.find_ex_uncaught_issue_99 - @ Stats.stats_negs :: Stats.stats_tests) + @ [Stats.char_dist; Stats.stats_negs] @ Stats.stats_tests) let () = QCheck_base_runner.set_seed 153870556 let _ = QCheck_base_runner.run_tests ~colors:false [Stats.stat_display_test9] diff --git a/test/core/QCheck_expect_test.ml b/test/core/QCheck_expect_test.ml index b7337e27..70c27ac7 100644 --- a/test/core/QCheck_expect_test.ml +++ b/test/core/QCheck_expect_test.ml @@ -56,6 +56,13 @@ module Overall = struct true) end +(* test various generators *) +module Generator = struct + (* example from issue #23 *) + let char_dist_issue_23 = + QCheck.Test.make ~name:"char never produces '\\255'" ~count:1_000_000 QCheck.char (fun c -> c <> '\255') +end + (* tests function generator and shrinker *) module Function = struct let fun1 = @@ -178,6 +185,11 @@ end (* tests of statistics and histogram display *) module Stats = struct + let char_dist = + QCheck.(Test.make ~count:500_000 ~name:"char code dist" + (add_stat ("char code", Char.code) char)) + (fun _ -> true) + let stats_negs = QCheck.(Test.make ~count:5_000 ~name:"stats_neg" (add_stat ("dist",fun x -> x) small_signed_int)) @@ -215,6 +227,7 @@ let i = Overall.stats; Overall.bad_assume_warn; Overall.bad_assume_fail; + Generator.char_dist_issue_23; Function.fun1; Function.fun2; Function.prop_foldleft_foldright; @@ -225,7 +238,7 @@ let i = Shrink.long_shrink; Shrink.shrink_int; ] @ FindExample.find_ex :: FindExample.find_ex_uncaught_issue_99 - @ Stats.stats_negs :: Stats.stats_tests) + @ [Stats.char_dist; Stats.stats_negs] @ Stats.stats_tests) let () = QCheck_base_runner.set_seed 153870556 let _ = QCheck_base_runner.run_tests ~colors:false [Stats.stat_display_test9] diff --git a/test/core/qcheck2_output.txt.expected b/test/core/qcheck2_output.txt.expected index 7705ca0e..a27bd75a 100644 --- a/test/core/qcheck2_output.txt.expected +++ b/test/core/qcheck2_output.txt.expected @@ -74,6 +74,12 @@ ERROR: only 0.7% tests (of 2000) passed precondition for "FAIL_unlikely_precond" NOTE: it is likely that the precondition is too strong, or that the generator is buggy. +--- Failure -------------------------------------------------------------------- + +Test char never produces '\255' failed (0 shrink steps): + +'\255' + --- Failure -------------------------------------------------------------------- Test FAIL_pred_map_commute failed (16 shrink steps): @@ -137,6 +143,31 @@ ERROR: uncaught exception in generator for test FAIL_#99_1 after 100 steps: Exception: QCheck2.No_example_found("") Backtrace: ++++ Stats for char code dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats char code: + num: 500000, avg: 127.42, stddev: 73.92, median 127, min 0, max 255 + 0.. 12: ###################################################### 25509 + 13.. 25: ###################################################### 25398 + 26.. 38: ###################################################### 25293 + 39.. 51: ###################################################### 25448 + 52.. 64: ###################################################### 25392 + 65.. 77: ####################################################### 25660 + 78.. 90: ###################################################### 25462 + 91..103: ###################################################### 25331 + 104..116: ##################################################### 25129 + 117..129: ###################################################### 25351 + 130..142: ###################################################### 25492 + 143..155: ###################################################### 25370 + 156..168: ###################################################### 25658 + 169..181: ###################################################### 25400 + 182..194: ##################################################### 25167 + 195..207: ###################################################### 25338 + 208..220: ##################################################### 25181 + 221..233: ##################################################### 25145 + 234..246: ###################################################### 25567 + 247..259: ##################################### 17709 + +++ Stats for stats_neg ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: @@ -353,7 +384,7 @@ stats dist: -4611686018427387392..-4150517416584648577: 0 ================================================================================ 1 warning(s) -failure (11 tests failed, 1 tests errored, ran 27 tests) +failure (12 tests failed, 1 tests errored, ran 29 tests) random seed: 153870556 +++ Stats for stat_display_test9 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ diff --git a/test/core/qcheck_output.txt.expected b/test/core/qcheck_output.txt.expected index 2d54be04..ab889376 100644 --- a/test/core/qcheck_output.txt.expected +++ b/test/core/qcheck_output.txt.expected @@ -74,6 +74,12 @@ ERROR: only 0.5% tests (of 2000) passed precondition for "FAIL_unlikely_precond" NOTE: it is likely that the precondition is too strong, or that the generator is buggy. +--- Failure -------------------------------------------------------------------- + +Test char never produces '\255' failed (0 shrink steps): + +'\255' + --- Failure -------------------------------------------------------------------- Test FAIL_pred_map_commute failed (127 shrink steps): @@ -137,6 +143,31 @@ ERROR: uncaught exception in generator for test FAIL_#99_1 after 100 steps: Exception: QCheck.No_example_found("") Backtrace: ++++ Stats for char code dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats char code: + num: 500000, avg: 127.42, stddev: 73.92, median 127, min 0, max 255 + 0.. 12: ###################################################### 25509 + 13.. 25: ###################################################### 25398 + 26.. 38: ###################################################### 25293 + 39.. 51: ###################################################### 25448 + 52.. 64: ###################################################### 25392 + 65.. 77: ####################################################### 25660 + 78.. 90: ###################################################### 25462 + 91..103: ###################################################### 25331 + 104..116: ##################################################### 25129 + 117..129: ###################################################### 25351 + 130..142: ###################################################### 25492 + 143..155: ###################################################### 25370 + 156..168: ###################################################### 25658 + 169..181: ###################################################### 25400 + 182..194: ##################################################### 25167 + 195..207: ###################################################### 25338 + 208..220: ##################################################### 25181 + 221..233: ##################################################### 25145 + 234..246: ###################################################### 25567 + 247..259: ##################################### 17709 + +++ Stats for stats_neg ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: @@ -353,7 +384,7 @@ stats dist: -4611686018427387392..-4150517416584648577: 0 ================================================================================ 1 warning(s) -failure (11 tests failed, 1 tests errored, ran 27 tests) +failure (12 tests failed, 1 tests errored, ran 29 tests) random seed: 153870556 +++ Stats for stat_display_test9 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ From b654066f93018158d55ab0e4a3ec326d0208194d Mon Sep 17 00:00:00 2001 From: Jan Midtgaard Date: Thu, 12 Aug 2021 09:02:13 +0200 Subject: [PATCH 31/49] rename to *int_*stat tests --- test/core/QCheck2_expect_test.ml | 30 +++++++++++++-------------- test/core/QCheck_expect_test.ml | 30 +++++++++++++-------------- test/core/qcheck2_output.txt.expected | 20 +++++++++--------- test/core/qcheck_output.txt.expected | 20 +++++++++--------- 4 files changed, 50 insertions(+), 50 deletions(-) diff --git a/test/core/QCheck2_expect_test.ml b/test/core/QCheck2_expect_test.ml index 4f42331c..c978156a 100644 --- a/test/core/QCheck2_expect_test.ml +++ b/test/core/QCheck2_expect_test.ml @@ -200,28 +200,28 @@ module Stats = struct ~stats:[("char code", Char.code)] Gen.char) (fun _ -> true) - let stats_negs = - QCheck2.(Test.make ~count:5_000 ~name:"stats_neg" + let int_stats_neg = + QCheck2.(Test.make ~count:5_000 ~name:"int_stats_neg" ~stats:[("dist",fun x -> x)] Gen.small_signed_int) (fun _ -> true) - let stats_tests = + let int_stats_tests = let open QCheck2 in let dist = ("dist",fun x -> x) in [ - Test.make ~name:"stat_display_test_1" ~count:1000 ~stats:[dist] Gen.small_signed_int (fun _ -> true); - Test.make ~name:"stat_display_test_2" ~count:1000 ~stats:[dist] Gen.small_nat (fun _ -> true); - Test.make ~name:"stat_display_test_3" ~count:1000 ~stats:[dist] (Gen.int_range (-43643) 435434) (fun _ -> true); - Test.make ~name:"stat_display_test_4" ~count:1000 ~stats:[dist] (Gen.int_range (-40000) 40000) (fun _ -> true); - Test.make ~name:"stat_display_test_5" ~count:1000 ~stats:[dist] (Gen.int_range (-4) 4) (fun _ -> true); - Test.make ~name:"stat_display_test_6" ~count:1000 ~stats:[dist] (Gen.int_range (-4) 17) (fun _ -> true); - Test.make ~name:"stat_display_test_7" ~count:100000 ~stats:[dist] Gen.int (fun _ -> true); - Test.make ~name:"stat_display_test_8" ~count:1000 ~stats:[dist] (Gen.oneofl[min_int;-1;0;1;max_int]) (fun _ -> true); + Test.make ~name:"int_stat_display_test_1" ~count:1000 ~stats:[dist] Gen.small_signed_int (fun _ -> true); + Test.make ~name:"int_stat_display_test_2" ~count:1000 ~stats:[dist] Gen.small_nat (fun _ -> true); + Test.make ~name:"int_stat_display_test_3" ~count:1000 ~stats:[dist] (Gen.int_range (-43643) 435434) (fun _ -> true); + Test.make ~name:"int_stat_display_test_4" ~count:1000 ~stats:[dist] (Gen.int_range (-40000) 40000) (fun _ -> true); + Test.make ~name:"int_stat_display_test_5" ~count:1000 ~stats:[dist] (Gen.int_range (-4) 4) (fun _ -> true); + Test.make ~name:"int_stat_display_test_6" ~count:1000 ~stats:[dist] (Gen.int_range (-4) 17) (fun _ -> true); + Test.make ~name:"int_stat_display_test_7" ~count:100000 ~stats:[dist] Gen.int (fun _ -> true); + Test.make ~name:"int_stat_display_test_8" ~count:1000 ~stats:[dist] (Gen.oneofl[min_int;-1;0;1;max_int]) (fun _ -> true); ] - let stat_display_test9 = + let int_stat_display_test9 = let open QCheck2 in - Test.make ~name:"stat_display_test9" ~count:1_000 + Test.make ~name:"int_stat_display_test9" ~count:1_000 ~stats:[("dist",fun x -> x)] Gen.(oneof [small_int_corners ();int]) (fun _ -> true) end @@ -248,8 +248,8 @@ let _ = Shrink.long_shrink; Shrink.shrink_int; ] @ FindExample.find_ex :: FindExample.find_ex_uncaught_issue_99 - @ [Stats.char_dist; Stats.stats_negs] @ Stats.stats_tests) + @ [Stats.char_dist; Stats.int_stats_neg] @ Stats.int_stats_tests) let () = QCheck_base_runner.set_seed 153870556 -let _ = QCheck_base_runner.run_tests ~colors:false [Stats.stat_display_test9] +let _ = QCheck_base_runner.run_tests ~colors:false [Stats.int_stat_display_test9] diff --git a/test/core/QCheck_expect_test.ml b/test/core/QCheck_expect_test.ml index 70c27ac7..4438c543 100644 --- a/test/core/QCheck_expect_test.ml +++ b/test/core/QCheck_expect_test.ml @@ -190,28 +190,28 @@ module Stats = struct (add_stat ("char code", Char.code) char)) (fun _ -> true) - let stats_negs = - QCheck.(Test.make ~count:5_000 ~name:"stats_neg" + let int_stats_neg = + QCheck.(Test.make ~count:5_000 ~name:"int_stats_neg" (add_stat ("dist",fun x -> x) small_signed_int)) (fun _ -> true) - let stats_tests = + let int_stats_tests = let open QCheck in let dist = ("dist",fun x -> x) in [ - Test.make ~name:"stat_display_test_1" ~count:1000 (add_stat dist small_signed_int) (fun _ -> true); - Test.make ~name:"stat_display_test_2" ~count:1000 (add_stat dist small_nat) (fun _ -> true); - Test.make ~name:"stat_display_test_3" ~count:1000 (add_stat dist (int_range (-43643) 435434)) (fun _ -> true); - Test.make ~name:"stat_display_test_4" ~count:1000 (add_stat dist (int_range (-40000) 40000)) (fun _ -> true); - Test.make ~name:"stat_display_test_5" ~count:1000 (add_stat dist (int_range (-4) 4)) (fun _ -> true); - Test.make ~name:"stat_display_test_6" ~count:1000 (add_stat dist (int_range (-4) 17)) (fun _ -> true); - Test.make ~name:"stat_display_test_7" ~count:100000 (add_stat dist int) (fun _ -> true); - Test.make ~name:"stat_display_test_8" ~count:1000 (add_stat dist (oneofl[min_int;-1;0;1;max_int])) (fun _ -> true); + Test.make ~name:"int_stat_display_test_1" ~count:1000 (add_stat dist small_signed_int) (fun _ -> true); + Test.make ~name:"int_stat_display_test_2" ~count:1000 (add_stat dist small_nat) (fun _ -> true); + Test.make ~name:"int_stat_display_test_3" ~count:1000 (add_stat dist (int_range (-43643) 435434)) (fun _ -> true); + Test.make ~name:"int_stat_display_test_4" ~count:1000 (add_stat dist (int_range (-40000) 40000)) (fun _ -> true); + Test.make ~name:"int_stat_display_test_5" ~count:1000 (add_stat dist (int_range (-4) 4)) (fun _ -> true); + Test.make ~name:"int_stat_display_test_6" ~count:1000 (add_stat dist (int_range (-4) 17)) (fun _ -> true); + Test.make ~name:"int_stat_display_test_7" ~count:100000 (add_stat dist int) (fun _ -> true); + Test.make ~name:"int_stat_display_test_8" ~count:1000 (add_stat dist (oneofl[min_int;-1;0;1;max_int])) (fun _ -> true); ] - let stat_display_test9 = + let int_stat_display_test9 = let open QCheck in - Test.make ~name:"stat_display_test9" ~count:1_000 + Test.make ~name:"int_stat_display_test9" ~count:1_000 (add_stat ("dist",fun x -> x) (oneof [small_int_corners ();int])) (fun _ -> true) end @@ -238,7 +238,7 @@ let i = Shrink.long_shrink; Shrink.shrink_int; ] @ FindExample.find_ex :: FindExample.find_ex_uncaught_issue_99 - @ [Stats.char_dist; Stats.stats_negs] @ Stats.stats_tests) + @ [Stats.char_dist; Stats.int_stats_neg] @ Stats.int_stats_tests) let () = QCheck_base_runner.set_seed 153870556 -let _ = QCheck_base_runner.run_tests ~colors:false [Stats.stat_display_test9] +let _ = QCheck_base_runner.run_tests ~colors:false [Stats.int_stat_display_test9] diff --git a/test/core/qcheck2_output.txt.expected b/test/core/qcheck2_output.txt.expected index a27bd75a..83bad7c6 100644 --- a/test/core/qcheck2_output.txt.expected +++ b/test/core/qcheck2_output.txt.expected @@ -168,7 +168,7 @@ stats char code: 234..246: ###################################################### 25567 247..259: ##################################### 17709 -+++ Stats for stats_neg ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++ Stats for int_stats_neg ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 5000, avg: 0.17, stddev: 29.68, median 0, min -99, max 99 @@ -193,7 +193,7 @@ stats dist: 81.. 90: # 60 91..100: # 66 -+++ Stats for stat_display_test_1 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++ Stats for int_stat_display_test_1 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 0.90, stddev: 28.23, median 0, min -99, max 99 @@ -218,7 +218,7 @@ stats dist: 81.. 90: # 16 91..100: # 10 -+++ Stats for stat_display_test_2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++ Stats for int_stat_display_test_2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 15.11, stddev: 23.27, median 6, min 0, max 99 @@ -243,7 +243,7 @@ stats dist: 90.. 94: 5 95.. 99: # 10 -+++ Stats for stat_display_test_3 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++ Stats for int_stat_display_test_3 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 195335.64, stddev: 136803.99, median 195583, min -43624, max 435210 @@ -268,7 +268,7 @@ stats dist: 387332..411273: ########################################## 49 411274..435215: ########################################### 51 -+++ Stats for stat_display_test_4 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++ Stats for int_stat_display_test_4 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: -173.78, stddev: 23042.92, median 180, min -39859, max 39942 @@ -293,7 +293,7 @@ stats dist: 31979.. 35969: ######################################### 51 35970.. 39960: #################################### 45 -+++ Stats for stat_display_test_5 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++ Stats for int_stat_display_test_5 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 0.02, stddev: 2.55, median 0, min -4, max 4 @@ -307,7 +307,7 @@ stats dist: 3: ####################################################### 122 4: ############################################## 104 -+++ Stats for stat_display_test_6 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++ Stats for int_stat_display_test_6 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 6.67, stddev: 6.39, median 7, min -4, max 17 @@ -332,7 +332,7 @@ stats dist: 32..33: 0 34..35: 0 -+++ Stats for stat_display_test_7 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++ Stats for int_stat_display_test_7 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 100000, avg: 6126662802445055.00, stddev: 2661484817981980672.00, median 158655556399988, min -4611578348806740501, max 4611677827646819817 @@ -357,7 +357,7 @@ stats dist: 3689352210001463787.. 4150515018824141802: ###################################################### 5048 4150515018824141803.. 4611677827646819818: ###################################################### 5063 -+++ Stats for stat_display_test_8 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++ Stats for int_stat_display_test_8 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 4611686018427388.00, stddev: 2905870896563567616.00, median 0, min -4611686018427387904, max 4611686018427387903 @@ -387,7 +387,7 @@ stats dist: failure (12 tests failed, 1 tests errored, ran 29 tests) random seed: 153870556 -+++ Stats for stat_display_test9 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++ Stats for int_stat_display_test9 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: -10119269408092442.00, stddev: 1871251663919905536.00, median 9, min -4576142151952919207, max 4611686018427387903 diff --git a/test/core/qcheck_output.txt.expected b/test/core/qcheck_output.txt.expected index ab889376..07c7e0d9 100644 --- a/test/core/qcheck_output.txt.expected +++ b/test/core/qcheck_output.txt.expected @@ -168,7 +168,7 @@ stats char code: 234..246: ###################################################### 25567 247..259: ##################################### 17709 -+++ Stats for stats_neg ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++ Stats for int_stats_neg ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 5000, avg: 0.17, stddev: 29.68, median 0, min -99, max 99 @@ -193,7 +193,7 @@ stats dist: 81.. 90: # 60 91..100: # 66 -+++ Stats for stat_display_test_1 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++ Stats for int_stat_display_test_1 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 0.90, stddev: 28.23, median 0, min -99, max 99 @@ -218,7 +218,7 @@ stats dist: 81.. 90: # 16 91..100: # 10 -+++ Stats for stat_display_test_2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++ Stats for int_stat_display_test_2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 15.11, stddev: 23.27, median 6, min 0, max 99 @@ -243,7 +243,7 @@ stats dist: 90.. 94: 5 95.. 99: # 10 -+++ Stats for stat_display_test_3 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++ Stats for int_stat_display_test_3 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 195335.64, stddev: 136803.99, median 195583, min -43624, max 435210 @@ -268,7 +268,7 @@ stats dist: 387332..411273: ########################################## 49 411274..435215: ########################################### 51 -+++ Stats for stat_display_test_4 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++ Stats for int_stat_display_test_4 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: -173.78, stddev: 23042.92, median 180, min -39859, max 39942 @@ -293,7 +293,7 @@ stats dist: 31979.. 35969: ######################################### 51 35970.. 39960: #################################### 45 -+++ Stats for stat_display_test_5 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++ Stats for int_stat_display_test_5 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 0.02, stddev: 2.55, median 0, min -4, max 4 @@ -307,7 +307,7 @@ stats dist: 3: ####################################################### 122 4: ############################################## 104 -+++ Stats for stat_display_test_6 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++ Stats for int_stat_display_test_6 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 6.67, stddev: 6.39, median 7, min -4, max 17 @@ -332,7 +332,7 @@ stats dist: 32..33: 0 34..35: 0 -+++ Stats for stat_display_test_7 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++ Stats for int_stat_display_test_7 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 100000, avg: 2541076923587387.50, stddev: 2660730801206827008.00, median 158655268318060, min -4611522359435274428, max 4611540922436307689 @@ -357,7 +357,7 @@ stats dist: 3689234594249150020.. 4150387758342729155: ##################################################### 4982 4150387758342729156.. 4611540922436308291: ###################################################### 5039 -+++ Stats for stat_display_test_8 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++ Stats for int_stat_display_test_8 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 4611686018427388.00, stddev: 2905870896563567616.00, median 0, min -4611686018427387904, max 4611686018427387903 @@ -387,7 +387,7 @@ stats dist: failure (12 tests failed, 1 tests errored, ran 29 tests) random seed: 153870556 -+++ Stats for stat_display_test9 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++ Stats for int_stat_display_test9 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: -55083208105414400.00, stddev: 1847115855773139200.00, median 9, min -4590718933436425025, max 4611686018427387903 From 658476cf1e2258dcda5bb98c60a692749fa04422 Mon Sep 17 00:00:00 2001 From: Jan Midtgaard Date: Thu, 12 Aug 2021 09:17:21 +0200 Subject: [PATCH 32/49] comment tests with issue/PR --- test/core/QCheck2_expect_test.ml | 2 ++ test/core/QCheck_expect_test.ml | 2 ++ 2 files changed, 4 insertions(+) diff --git a/test/core/QCheck2_expect_test.ml b/test/core/QCheck2_expect_test.ml index c978156a..8c7a97c4 100644 --- a/test/core/QCheck2_expect_test.ml +++ b/test/core/QCheck2_expect_test.ml @@ -200,11 +200,13 @@ module Stats = struct ~stats:[("char code", Char.code)] Gen.char) (fun _ -> true) + (* test from issue #40 *) let int_stats_neg = QCheck2.(Test.make ~count:5_000 ~name:"int_stats_neg" ~stats:[("dist",fun x -> x)] Gen.small_signed_int) (fun _ -> true) + (* distribution tests from PR #45 *) let int_stats_tests = let open QCheck2 in let dist = ("dist",fun x -> x) in diff --git a/test/core/QCheck_expect_test.ml b/test/core/QCheck_expect_test.ml index 4438c543..398c8b9c 100644 --- a/test/core/QCheck_expect_test.ml +++ b/test/core/QCheck_expect_test.ml @@ -190,11 +190,13 @@ module Stats = struct (add_stat ("char code", Char.code) char)) (fun _ -> true) + (* test from issue #40 *) let int_stats_neg = QCheck.(Test.make ~count:5_000 ~name:"int_stats_neg" (add_stat ("dist",fun x -> x) small_signed_int)) (fun _ -> true) + (* distribution tests from PR #45 *) let int_stats_tests = let open QCheck in let dist = ("dist",fun x -> x) in From 42234056b0aa70425df727681ce23d71225724b0 Mon Sep 17 00:00:00 2001 From: Jan Midtgaard Date: Thu, 12 Aug 2021 09:25:33 +0200 Subject: [PATCH 33/49] add bool dist test --- test/core/QCheck2_expect_test.ml | 9 ++++++--- test/core/QCheck_expect_test.ml | 12 +++++++----- test/core/qcheck2_output.txt.expected | 9 ++++++++- test/core/qcheck_output.txt.expected | 9 ++++++++- 4 files changed, 29 insertions(+), 10 deletions(-) diff --git a/test/core/QCheck2_expect_test.ml b/test/core/QCheck2_expect_test.ml index 8c7a97c4..190f0f16 100644 --- a/test/core/QCheck2_expect_test.ml +++ b/test/core/QCheck2_expect_test.ml @@ -195,10 +195,13 @@ end (* tests of statistics and histogram display *) module Stats = struct + let bool_dist = + QCheck2.(Test.make ~count:500_000 ~name:"bool dist" + ~collect:Bool.to_string Gen.bool) (fun _ -> true) + let char_dist = QCheck2.(Test.make ~count:500_000 ~name:"char code dist" - ~stats:[("char code", Char.code)] Gen.char) - (fun _ -> true) + ~stats:[("char code", Char.code)] Gen.char) (fun _ -> true) (* test from issue #40 *) let int_stats_neg = @@ -250,7 +253,7 @@ let _ = Shrink.long_shrink; Shrink.shrink_int; ] @ FindExample.find_ex :: FindExample.find_ex_uncaught_issue_99 - @ [Stats.char_dist; Stats.int_stats_neg] @ Stats.int_stats_tests) + @ [Stats.bool_dist; Stats.char_dist; Stats.int_stats_neg] @ Stats.int_stats_tests) let () = QCheck_base_runner.set_seed 153870556 let _ = QCheck_base_runner.run_tests ~colors:false [Stats.int_stat_display_test9] diff --git a/test/core/QCheck_expect_test.ml b/test/core/QCheck_expect_test.ml index 398c8b9c..46563916 100644 --- a/test/core/QCheck_expect_test.ml +++ b/test/core/QCheck_expect_test.ml @@ -185,16 +185,18 @@ end (* tests of statistics and histogram display *) module Stats = struct + let bool_dist = + QCheck.(Test.make ~count:500_000 ~name:"bool dist" + (set_collect Bool.to_string bool)) (fun _ -> true) + let char_dist = QCheck.(Test.make ~count:500_000 ~name:"char code dist" - (add_stat ("char code", Char.code) char)) - (fun _ -> true) + (add_stat ("char code", Char.code) char)) (fun _ -> true) (* test from issue #40 *) let int_stats_neg = QCheck.(Test.make ~count:5_000 ~name:"int_stats_neg" - (add_stat ("dist",fun x -> x) small_signed_int)) - (fun _ -> true) + (add_stat ("dist",fun x -> x) small_signed_int)) (fun _ -> true) (* distribution tests from PR #45 *) let int_stats_tests = @@ -240,7 +242,7 @@ let i = Shrink.long_shrink; Shrink.shrink_int; ] @ FindExample.find_ex :: FindExample.find_ex_uncaught_issue_99 - @ [Stats.char_dist; Stats.int_stats_neg] @ Stats.int_stats_tests) + @ [Stats.bool_dist; Stats.char_dist; Stats.int_stats_neg] @ Stats.int_stats_tests) let () = QCheck_base_runner.set_seed 153870556 let _ = QCheck_base_runner.run_tests ~colors:false [Stats.int_stat_display_test9] diff --git a/test/core/qcheck2_output.txt.expected b/test/core/qcheck2_output.txt.expected index 83bad7c6..ef02359f 100644 --- a/test/core/qcheck2_output.txt.expected +++ b/test/core/qcheck2_output.txt.expected @@ -143,6 +143,13 @@ ERROR: uncaught exception in generator for test FAIL_#99_1 after 100 steps: Exception: QCheck2.No_example_found("") Backtrace: ++++ Collect ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +Collect results for test bool dist: + +true: 250134 cases +false: 249866 cases + +++ Stats for char code dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats char code: @@ -384,7 +391,7 @@ stats dist: -4611686018427387392..-4150517416584648577: 0 ================================================================================ 1 warning(s) -failure (12 tests failed, 1 tests errored, ran 29 tests) +failure (12 tests failed, 1 tests errored, ran 30 tests) random seed: 153870556 +++ Stats for int_stat_display_test9 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ diff --git a/test/core/qcheck_output.txt.expected b/test/core/qcheck_output.txt.expected index 07c7e0d9..2daaccd3 100644 --- a/test/core/qcheck_output.txt.expected +++ b/test/core/qcheck_output.txt.expected @@ -143,6 +143,13 @@ ERROR: uncaught exception in generator for test FAIL_#99_1 after 100 steps: Exception: QCheck.No_example_found("") Backtrace: ++++ Collect ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +Collect results for test bool dist: + +true: 250134 cases +false: 249866 cases + +++ Stats for char code dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats char code: @@ -384,7 +391,7 @@ stats dist: -4611686018427387392..-4150517416584648577: 0 ================================================================================ 1 warning(s) -failure (12 tests failed, 1 tests errored, ran 29 tests) +failure (12 tests failed, 1 tests errored, ran 30 tests) random seed: 153870556 +++ Stats for int_stat_display_test9 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ From 3abcc7f561319ac08b059051822733f54bac0c13 Mon Sep 17 00:00:00 2001 From: Jan Midtgaard Date: Thu, 12 Aug 2021 09:37:03 +0200 Subject: [PATCH 34/49] add list dist test --- test/core/QCheck2_expect_test.ml | 11 ++++++++++- test/core/QCheck_expect_test.ml | 11 ++++++++++- test/core/qcheck2_output.txt.expected | 27 ++++++++++++++++++++++++++- test/core/qcheck_output.txt.expected | 27 ++++++++++++++++++++++++++- 4 files changed, 72 insertions(+), 4 deletions(-) diff --git a/test/core/QCheck2_expect_test.ml b/test/core/QCheck2_expect_test.ml index 190f0f16..2c7fa448 100644 --- a/test/core/QCheck2_expect_test.ml +++ b/test/core/QCheck2_expect_test.ml @@ -203,6 +203,11 @@ module Stats = struct QCheck2.(Test.make ~count:500_000 ~name:"char code dist" ~stats:[("char code", Char.code)] Gen.char) (fun _ -> true) + (* test from issue #30 *) + let list_size_dist = + QCheck2.(Test.make ~count:5_000 ~name:"list size dist" + ~stats:[("len",List.length)] Gen.(list int)) (fun _ -> true) + (* test from issue #40 *) let int_stats_neg = QCheck2.(Test.make ~count:5_000 ~name:"int_stats_neg" @@ -253,7 +258,11 @@ let _ = Shrink.long_shrink; Shrink.shrink_int; ] @ FindExample.find_ex :: FindExample.find_ex_uncaught_issue_99 - @ [Stats.bool_dist; Stats.char_dist; Stats.int_stats_neg] @ Stats.int_stats_tests) + @ [Stats.bool_dist; + Stats.char_dist; + Stats.list_size_dist; + Stats.int_stats_neg] + @ Stats.int_stats_tests) let () = QCheck_base_runner.set_seed 153870556 let _ = QCheck_base_runner.run_tests ~colors:false [Stats.int_stat_display_test9] diff --git a/test/core/QCheck_expect_test.ml b/test/core/QCheck_expect_test.ml index 46563916..9f5f9ee9 100644 --- a/test/core/QCheck_expect_test.ml +++ b/test/core/QCheck_expect_test.ml @@ -193,6 +193,11 @@ module Stats = struct QCheck.(Test.make ~count:500_000 ~name:"char code dist" (add_stat ("char code", Char.code) char)) (fun _ -> true) + (* test from issue #30 *) + let list_size_dist = + QCheck.(Test.make ~count:5_000 ~name:"list size dist" + (add_stat ("len",List.length) (list int))) (fun _ -> true) + (* test from issue #40 *) let int_stats_neg = QCheck.(Test.make ~count:5_000 ~name:"int_stats_neg" @@ -242,7 +247,11 @@ let i = Shrink.long_shrink; Shrink.shrink_int; ] @ FindExample.find_ex :: FindExample.find_ex_uncaught_issue_99 - @ [Stats.bool_dist; Stats.char_dist; Stats.int_stats_neg] @ Stats.int_stats_tests) + @ [Stats.bool_dist; + Stats.char_dist; + Stats.list_size_dist; + Stats.int_stats_neg] + @ Stats.int_stats_tests) let () = QCheck_base_runner.set_seed 153870556 let _ = QCheck_base_runner.run_tests ~colors:false [Stats.int_stat_display_test9] diff --git a/test/core/qcheck2_output.txt.expected b/test/core/qcheck2_output.txt.expected index ef02359f..9cba6d91 100644 --- a/test/core/qcheck2_output.txt.expected +++ b/test/core/qcheck2_output.txt.expected @@ -175,6 +175,31 @@ stats char code: 234..246: ###################################################### 25567 247..259: ##################################### 17709 ++++ Stats for list size dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats len: + num: 5000, avg: 400.16, stddev: 1371.90, median 9, min 0, max 9987 + 0.. 499: ####################################################### 4246 + 500.. 999: ###### 502 + 1000.. 1499: 13 + 1500.. 1999: 10 + 2000.. 2499: 14 + 2500.. 2999: 14 + 3000.. 3499: 20 + 3500.. 3999: 7 + 4000.. 4499: 13 + 4500.. 4999: 16 + 5000.. 5499: 12 + 5500.. 5999: 15 + 6000.. 6499: 15 + 6500.. 6999: 13 + 7000.. 7499: 16 + 7500.. 7999: 12 + 8000.. 8499: 11 + 8500.. 8999: 16 + 9000.. 9499: 15 + 9500.. 9999: 20 + +++ Stats for int_stats_neg ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: @@ -391,7 +416,7 @@ stats dist: -4611686018427387392..-4150517416584648577: 0 ================================================================================ 1 warning(s) -failure (12 tests failed, 1 tests errored, ran 30 tests) +failure (12 tests failed, 1 tests errored, ran 31 tests) random seed: 153870556 +++ Stats for int_stat_display_test9 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ diff --git a/test/core/qcheck_output.txt.expected b/test/core/qcheck_output.txt.expected index 2daaccd3..4fab766a 100644 --- a/test/core/qcheck_output.txt.expected +++ b/test/core/qcheck_output.txt.expected @@ -175,6 +175,31 @@ stats char code: 234..246: ###################################################### 25567 247..259: ##################################### 17709 ++++ Stats for list size dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats len: + num: 5000, avg: 400.16, stddev: 1371.90, median 9, min 0, max 9987 + 0.. 499: ####################################################### 4246 + 500.. 999: ###### 502 + 1000.. 1499: 13 + 1500.. 1999: 10 + 2000.. 2499: 14 + 2500.. 2999: 14 + 3000.. 3499: 20 + 3500.. 3999: 7 + 4000.. 4499: 13 + 4500.. 4999: 16 + 5000.. 5499: 12 + 5500.. 5999: 15 + 6000.. 6499: 15 + 6500.. 6999: 13 + 7000.. 7499: 16 + 7500.. 7999: 12 + 8000.. 8499: 11 + 8500.. 8999: 16 + 9000.. 9499: 15 + 9500.. 9999: 20 + +++ Stats for int_stats_neg ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: @@ -391,7 +416,7 @@ stats dist: -4611686018427387392..-4150517416584648577: 0 ================================================================================ 1 warning(s) -failure (12 tests failed, 1 tests errored, ran 30 tests) +failure (12 tests failed, 1 tests errored, ran 31 tests) random seed: 153870556 +++ Stats for int_stat_display_test9 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ From f0f73fdb73853d7e8d8f8ddf447660343488ff5e Mon Sep 17 00:00:00 2001 From: Jan Midtgaard Date: Thu, 12 Aug 2021 09:50:10 +0200 Subject: [PATCH 35/49] add small_list+list_(of_)size test --- test/core/QCheck2_expect_test.ml | 16 +++++++++-- test/core/QCheck_expect_test.ml | 16 +++++++++-- test/core/qcheck2_output.txt.expected | 40 +++++++++++++++++++++++++-- test/core/qcheck_output.txt.expected | 40 +++++++++++++++++++++++++-- 4 files changed, 102 insertions(+), 10 deletions(-) diff --git a/test/core/QCheck2_expect_test.ml b/test/core/QCheck2_expect_test.ml index 2c7fa448..21ecd363 100644 --- a/test/core/QCheck2_expect_test.ml +++ b/test/core/QCheck2_expect_test.ml @@ -204,10 +204,18 @@ module Stats = struct ~stats:[("char code", Char.code)] Gen.char) (fun _ -> true) (* test from issue #30 *) - let list_size_dist = - QCheck2.(Test.make ~count:5_000 ~name:"list size dist" + let list_len_dist = + QCheck2.(Test.make ~count:5_000 ~name:"list len dist" ~stats:[("len",List.length)] Gen.(list int)) (fun _ -> true) + let small_list_len_dist = + QCheck2.(Test.make ~count:5_000 ~name:"small_list len dist" + ~stats:[("len",List.length)] Gen.(small_list int)) (fun _ -> true) + + let list_size_len_dist = + QCheck2.(Test.make ~count:5_000 ~name:"list_size len dist" + ~stats:[("len",List.length)] Gen.(list_size (int_range 5 10) int)) (fun _ -> true) + (* test from issue #40 *) let int_stats_neg = QCheck2.(Test.make ~count:5_000 ~name:"int_stats_neg" @@ -260,7 +268,9 @@ let _ = ] @ FindExample.find_ex :: FindExample.find_ex_uncaught_issue_99 @ [Stats.bool_dist; Stats.char_dist; - Stats.list_size_dist; + Stats.list_len_dist; + Stats.small_list_len_dist; + Stats.list_size_len_dist; Stats.int_stats_neg] @ Stats.int_stats_tests) diff --git a/test/core/QCheck_expect_test.ml b/test/core/QCheck_expect_test.ml index 9f5f9ee9..305066e4 100644 --- a/test/core/QCheck_expect_test.ml +++ b/test/core/QCheck_expect_test.ml @@ -194,10 +194,18 @@ module Stats = struct (add_stat ("char code", Char.code) char)) (fun _ -> true) (* test from issue #30 *) - let list_size_dist = - QCheck.(Test.make ~count:5_000 ~name:"list size dist" + let list_len_dist = + QCheck.(Test.make ~count:5_000 ~name:"list len dist" (add_stat ("len",List.length) (list int))) (fun _ -> true) + let small_list_len_dist = + QCheck.(Test.make ~count:5_000 ~name:"small_list len dist" + (add_stat ("len",List.length) (small_list int))) (fun _ -> true) + + let list_of_size_len_dist = + QCheck.(Test.make ~count:5_000 ~name:"list_of_size len dist" + (add_stat ("len",List.length) (list_of_size (Gen.int_range 5 10) int))) (fun _ -> true) + (* test from issue #40 *) let int_stats_neg = QCheck.(Test.make ~count:5_000 ~name:"int_stats_neg" @@ -249,7 +257,9 @@ let i = ] @ FindExample.find_ex :: FindExample.find_ex_uncaught_issue_99 @ [Stats.bool_dist; Stats.char_dist; - Stats.list_size_dist; + Stats.list_len_dist; + Stats.small_list_len_dist; + Stats.list_of_size_len_dist; Stats.int_stats_neg] @ Stats.int_stats_tests) diff --git a/test/core/qcheck2_output.txt.expected b/test/core/qcheck2_output.txt.expected index 9cba6d91..60556ce9 100644 --- a/test/core/qcheck2_output.txt.expected +++ b/test/core/qcheck2_output.txt.expected @@ -175,7 +175,7 @@ stats char code: 234..246: ###################################################### 25567 247..259: ##################################### 17709 -+++ Stats for list size dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++ Stats for list len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 400.16, stddev: 1371.90, median 9, min 0, max 9987 @@ -200,6 +200,42 @@ stats len: 9000.. 9499: 15 9500.. 9999: 20 ++++ Stats for small_list len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats len: + num: 5000, avg: 16.14, stddev: 24.86, median 6, min 0, max 99 + 0.. 4: ###################################################### 1923 + 5.. 9: ####################################################### 1936 + 10.. 14: # 61 + 15.. 19: # 59 + 20.. 24: # 62 + 25.. 29: # 70 + 30.. 34: # 61 + 35.. 39: # 64 + 40.. 44: # 64 + 45.. 49: # 56 + 50.. 54: # 65 + 55.. 59: # 55 + 60.. 64: # 60 + 65.. 69: # 62 + 70.. 74: # 57 + 75.. 79: # 69 + 80.. 84: ## 73 + 85.. 89: # 67 + 90.. 94: # 62 + 95.. 99: ## 74 + ++++ Stats for list_size len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats len: + num: 5000, avg: 7.49, stddev: 1.71, median 8, min 5, max 10 + 5: ####################################################### 867 + 6: ################################################### 813 + 7: ################################################### 815 + 8: #################################################### 833 + 9: ###################################################### 857 + 10: ################################################### 815 + +++ Stats for int_stats_neg ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: @@ -416,7 +452,7 @@ stats dist: -4611686018427387392..-4150517416584648577: 0 ================================================================================ 1 warning(s) -failure (12 tests failed, 1 tests errored, ran 31 tests) +failure (12 tests failed, 1 tests errored, ran 33 tests) random seed: 153870556 +++ Stats for int_stat_display_test9 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ diff --git a/test/core/qcheck_output.txt.expected b/test/core/qcheck_output.txt.expected index 4fab766a..8044674b 100644 --- a/test/core/qcheck_output.txt.expected +++ b/test/core/qcheck_output.txt.expected @@ -175,7 +175,7 @@ stats char code: 234..246: ###################################################### 25567 247..259: ##################################### 17709 -+++ Stats for list size dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++ Stats for list len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 400.16, stddev: 1371.90, median 9, min 0, max 9987 @@ -200,6 +200,42 @@ stats len: 9000.. 9499: 15 9500.. 9999: 20 ++++ Stats for small_list len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats len: + num: 5000, avg: 16.14, stddev: 24.86, median 6, min 0, max 99 + 0.. 4: ###################################################### 1923 + 5.. 9: ####################################################### 1936 + 10.. 14: # 61 + 15.. 19: # 59 + 20.. 24: # 62 + 25.. 29: # 70 + 30.. 34: # 61 + 35.. 39: # 64 + 40.. 44: # 64 + 45.. 49: # 56 + 50.. 54: # 65 + 55.. 59: # 55 + 60.. 64: # 60 + 65.. 69: # 62 + 70.. 74: # 57 + 75.. 79: # 69 + 80.. 84: ## 73 + 85.. 89: # 67 + 90.. 94: # 62 + 95.. 99: ## 74 + ++++ Stats for list_of_size len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats len: + num: 5000, avg: 7.49, stddev: 1.71, median 8, min 5, max 10 + 5: ####################################################### 867 + 6: ################################################### 813 + 7: ################################################### 815 + 8: #################################################### 833 + 9: ###################################################### 857 + 10: ################################################### 815 + +++ Stats for int_stats_neg ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: @@ -416,7 +452,7 @@ stats dist: -4611686018427387392..-4150517416584648577: 0 ================================================================================ 1 warning(s) -failure (12 tests failed, 1 tests errored, ran 31 tests) +failure (12 tests failed, 1 tests errored, ran 33 tests) random seed: 153870556 +++ Stats for int_stat_display_test9 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ From 2bd471f02bfe3fbb713f3bb00c8b7a794d398cb5 Mon Sep 17 00:00:00 2001 From: Jan Midtgaard Date: Thu, 12 Aug 2021 10:07:00 +0200 Subject: [PATCH 36/49] collect list dist tests --- test/core/QCheck2_expect_test.ml | 28 +++++++++++----------------- test/core/QCheck_expect_test.ml | 28 +++++++++++----------------- 2 files changed, 22 insertions(+), 34 deletions(-) diff --git a/test/core/QCheck2_expect_test.ml b/test/core/QCheck2_expect_test.ml index 21ecd363..cb941704 100644 --- a/test/core/QCheck2_expect_test.ml +++ b/test/core/QCheck2_expect_test.ml @@ -203,19 +203,15 @@ module Stats = struct QCheck2.(Test.make ~count:500_000 ~name:"char code dist" ~stats:[("char code", Char.code)] Gen.char) (fun _ -> true) - (* test from issue #30 *) - let list_len_dist = - QCheck2.(Test.make ~count:5_000 ~name:"list len dist" - ~stats:[("len",List.length)] Gen.(list int)) (fun _ -> true) - - let small_list_len_dist = - QCheck2.(Test.make ~count:5_000 ~name:"small_list len dist" - ~stats:[("len",List.length)] Gen.(small_list int)) (fun _ -> true) + let list_len_tests = + let open QCheck2 in + let len = ("len",List.length) in + [ (* test from issue #30 *) + Test.make ~count:5_000 ~name:"list len dist" ~stats:[len] Gen.(list int) (fun _ -> true); + Test.make ~count:5_000 ~name:"small_list len dist" ~stats:[len] Gen.(small_list int) (fun _ -> true); + Test.make ~count:5_000 ~name:"list_size len dist" ~stats:[len] Gen.(list_size (int_range 5 10) int) (fun _ -> true); + ] - let list_size_len_dist = - QCheck2.(Test.make ~count:5_000 ~name:"list_size len dist" - ~stats:[("len",List.length)] Gen.(list_size (int_range 5 10) int)) (fun _ -> true) - (* test from issue #40 *) let int_stats_neg = QCheck2.(Test.make ~count:5_000 ~name:"int_stats_neg" @@ -267,11 +263,9 @@ let _ = Shrink.shrink_int; ] @ FindExample.find_ex :: FindExample.find_ex_uncaught_issue_99 @ [Stats.bool_dist; - Stats.char_dist; - Stats.list_len_dist; - Stats.small_list_len_dist; - Stats.list_size_len_dist; - Stats.int_stats_neg] + Stats.char_dist] + @ Stats.list_len_tests + @ [Stats.int_stats_neg] @ Stats.int_stats_tests) let () = QCheck_base_runner.set_seed 153870556 diff --git a/test/core/QCheck_expect_test.ml b/test/core/QCheck_expect_test.ml index 305066e4..35e41b4e 100644 --- a/test/core/QCheck_expect_test.ml +++ b/test/core/QCheck_expect_test.ml @@ -193,18 +193,14 @@ module Stats = struct QCheck.(Test.make ~count:500_000 ~name:"char code dist" (add_stat ("char code", Char.code) char)) (fun _ -> true) - (* test from issue #30 *) - let list_len_dist = - QCheck.(Test.make ~count:5_000 ~name:"list len dist" - (add_stat ("len",List.length) (list int))) (fun _ -> true) - - let small_list_len_dist = - QCheck.(Test.make ~count:5_000 ~name:"small_list len dist" - (add_stat ("len",List.length) (small_list int))) (fun _ -> true) - - let list_of_size_len_dist = - QCheck.(Test.make ~count:5_000 ~name:"list_of_size len dist" - (add_stat ("len",List.length) (list_of_size (Gen.int_range 5 10) int))) (fun _ -> true) + let list_len_tests = + let open QCheck in + let len = ("len",List.length) in + [ (* test from issue #30 *) + Test.make ~count:5_000 ~name:"list len dist" (add_stat len (list int)) (fun _ -> true); + Test.make ~count:5_000 ~name:"small_list len dist" (add_stat len (small_list int)) (fun _ -> true); + Test.make ~count:5_000 ~name:"list_of_size len dist" (add_stat len (list_of_size (Gen.int_range 5 10) int)) (fun _ -> true); + ] (* test from issue #40 *) let int_stats_neg = @@ -256,11 +252,9 @@ let i = Shrink.shrink_int; ] @ FindExample.find_ex :: FindExample.find_ex_uncaught_issue_99 @ [Stats.bool_dist; - Stats.char_dist; - Stats.list_len_dist; - Stats.small_list_len_dist; - Stats.list_of_size_len_dist; - Stats.int_stats_neg] + Stats.char_dist] + @ Stats.list_len_tests + @ [Stats.int_stats_neg] @ Stats.int_stats_tests) let () = QCheck_base_runner.set_seed 153870556 From 42a280ef394ade65cf9e8e37436cc6053c7dfd19 Mon Sep 17 00:00:00 2001 From: Jan Midtgaard Date: Thu, 12 Aug 2021 12:15:33 +0200 Subject: [PATCH 37/49] add array and repeat tests --- test/core/QCheck2_expect_test.ml | 32 ++++++++++-- test/core/QCheck_expect_test.ml | 26 ++++++++++ test/core/qcheck2_output.txt.expected | 75 ++++++++++++++++++++++++++- test/core/qcheck_output.txt.expected | 75 ++++++++++++++++++++++++++- 4 files changed, 202 insertions(+), 6 deletions(-) diff --git a/test/core/QCheck2_expect_test.ml b/test/core/QCheck2_expect_test.ml index cb941704..4719a79e 100644 --- a/test/core/QCheck2_expect_test.ml +++ b/test/core/QCheck2_expect_test.ml @@ -63,6 +63,16 @@ module Generator = struct let char_dist_issue_23 = let open QCheck2 in Test.make ~name:"char never produces '\\255'" ~count:1_000_000 ~print:Print.char Gen.char (fun c -> c <> '\255') + + let list_repeat_test = + let open QCheck2 in + Test.make ~name:"list_repeat has constant length" ~count:1000 ~print:Print.(pair int (list unit)) + Gen.(small_nat >>= fun i -> list_repeat i unit >>= fun l -> return (i,l)) (fun (i,l) -> List.length l = i) + + let array_repeat_test = + let open QCheck2 in + Test.make ~name:"array_repeat has constant length" ~count:1000 ~print:Print.(pair int (array unit)) + Gen.(small_nat >>= fun i -> array_repeat i unit >>= fun l -> return (i,l)) (fun (i,l) -> Array.length l = i) end (* tests function generator and shrinker *) @@ -198,7 +208,7 @@ module Stats = struct let bool_dist = QCheck2.(Test.make ~count:500_000 ~name:"bool dist" ~collect:Bool.to_string Gen.bool) (fun _ -> true) - + let char_dist = QCheck2.(Test.make ~count:500_000 ~name:"char code dist" ~stats:[("char code", Char.code)] Gen.char) (fun _ -> true) @@ -207,9 +217,20 @@ module Stats = struct let open QCheck2 in let len = ("len",List.length) in [ (* test from issue #30 *) - Test.make ~count:5_000 ~name:"list len dist" ~stats:[len] Gen.(list int) (fun _ -> true); - Test.make ~count:5_000 ~name:"small_list len dist" ~stats:[len] Gen.(small_list int) (fun _ -> true); - Test.make ~count:5_000 ~name:"list_size len dist" ~stats:[len] Gen.(list_size (int_range 5 10) int) (fun _ -> true); + Test.make ~count:5_000 ~name:"list len dist" ~stats:[len] Gen.(list int) (fun _ -> true); + Test.make ~count:5_000 ~name:"small_list len dist" ~stats:[len] Gen.(small_list int) (fun _ -> true); + Test.make ~count:5_000 ~name:"list_size len dist" ~stats:[len] Gen.(list_size (int_range 5 10) int) (fun _ -> true); + Test.make ~count:5_000 ~name:"list_repeat len dist" ~stats:[len] Gen.(list_repeat 42 int) (fun _ -> true); + ] + + let array_len_tests = + let open QCheck2 in + let len = ("len",Array.length) in + [ + Test.make ~count:5_000 ~name:"array len dist" ~stats:[len] Gen.(array int) (fun _ -> true); + Test.make ~count:5_000 ~name:"small_array len dist" ~stats:[len] Gen.(small_array int) (fun _ -> true); + Test.make ~count:5_000 ~name:"array_size len dist" ~stats:[len] Gen.(array_size (int_range 5 10) int) (fun _ -> true); + Test.make ~count:5_000 ~name:"array_repeat len dist" ~stats:[len] Gen.(array_repeat 42 int) (fun _ -> true); ] (* test from issue #40 *) @@ -252,6 +273,8 @@ let _ = Overall.bad_assume_warn; Overall.bad_assume_fail; Generator.char_dist_issue_23; + Generator.list_repeat_test; + Generator.array_repeat_test; Function.fun1; Function.fun2; Function.prop_foldleft_foldright; @@ -265,6 +288,7 @@ let _ = @ [Stats.bool_dist; Stats.char_dist] @ Stats.list_len_tests + @ Stats.array_len_tests @ [Stats.int_stats_neg] @ Stats.int_stats_tests) diff --git a/test/core/QCheck_expect_test.ml b/test/core/QCheck_expect_test.ml index 35e41b4e..80c0c071 100644 --- a/test/core/QCheck_expect_test.ml +++ b/test/core/QCheck_expect_test.ml @@ -61,6 +61,18 @@ module Generator = struct (* example from issue #23 *) let char_dist_issue_23 = QCheck.Test.make ~name:"char never produces '\\255'" ~count:1_000_000 QCheck.char (fun c -> c <> '\255') + + let list_repeat_test = + let open QCheck in + let gen = Gen.(small_nat >>= fun i -> list_repeat i unit >>= fun l -> return (i,l)) in + Test.make ~name:"list_repeat has constant length" ~count:1000 + (make ~print:Print.(pair int (list unit)) gen) (fun (i,l) -> List.length l = i) + + let array_repeat_test = + let open QCheck in + let gen = Gen.(small_nat >>= fun i -> array_repeat i unit >>= fun l -> return (i,l)) in + Test.make ~name:"array_repeat has constant length" ~count:1000 + (make ~print:Print.(pair int (array unit)) gen) (fun (i,l) -> Array.length l = i) end (* tests function generator and shrinker *) @@ -200,6 +212,17 @@ module Stats = struct Test.make ~count:5_000 ~name:"list len dist" (add_stat len (list int)) (fun _ -> true); Test.make ~count:5_000 ~name:"small_list len dist" (add_stat len (small_list int)) (fun _ -> true); Test.make ~count:5_000 ~name:"list_of_size len dist" (add_stat len (list_of_size (Gen.int_range 5 10) int)) (fun _ -> true); + Test.make ~count:5_000 ~name:"list_repeat len dist" (add_stat len (make Gen.(list_repeat 42 int))) (fun _ -> true); + ] + + let array_len_tests = + let open QCheck in + let len = ("len",Array.length) in + [ + Test.make ~count:5_000 ~name:"array len dist" (add_stat len (array int)) (fun _ -> true); + Test.make ~count:5_000 ~name:"small_array len dist" (add_stat len (make Gen.(small_array int))) (fun _ -> true); + Test.make ~count:5_000 ~name:"array_of_size len dist" (add_stat len (array_of_size (Gen.int_range 5 10) int)) (fun _ -> true); + Test.make ~count:5_000 ~name:"array_repeat len dist" (add_stat len (make Gen.(array_repeat 42 int))) (fun _ -> true); ] (* test from issue #40 *) @@ -241,6 +264,8 @@ let i = Overall.bad_assume_warn; Overall.bad_assume_fail; Generator.char_dist_issue_23; + Generator.list_repeat_test; + Generator.array_repeat_test; Function.fun1; Function.fun2; Function.prop_foldleft_foldright; @@ -254,6 +279,7 @@ let i = @ [Stats.bool_dist; Stats.char_dist] @ Stats.list_len_tests + @ Stats.array_len_tests @ [Stats.int_stats_neg] @ Stats.int_stats_tests) diff --git a/test/core/qcheck2_output.txt.expected b/test/core/qcheck2_output.txt.expected index 60556ce9..99f37897 100644 --- a/test/core/qcheck2_output.txt.expected +++ b/test/core/qcheck2_output.txt.expected @@ -236,6 +236,79 @@ stats len: 9: ###################################################### 857 10: ################################################### 815 ++++ Stats for list_repeat len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats len: + num: 5000, avg: 42.00, stddev: 0.00, median 42, min 42, max 42 + 42: ####################################################### 5000 + ++++ Stats for array len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats len: + num: 5000, avg: 400.16, stddev: 1371.90, median 9, min 0, max 9987 + 0.. 499: ####################################################### 4246 + 500.. 999: ###### 502 + 1000.. 1499: 13 + 1500.. 1999: 10 + 2000.. 2499: 14 + 2500.. 2999: 14 + 3000.. 3499: 20 + 3500.. 3999: 7 + 4000.. 4499: 13 + 4500.. 4999: 16 + 5000.. 5499: 12 + 5500.. 5999: 15 + 6000.. 6499: 15 + 6500.. 6999: 13 + 7000.. 7499: 16 + 7500.. 7999: 12 + 8000.. 8499: 11 + 8500.. 8999: 16 + 9000.. 9499: 15 + 9500.. 9999: 20 + ++++ Stats for small_array len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats len: + num: 5000, avg: 16.14, stddev: 24.86, median 6, min 0, max 99 + 0.. 4: ###################################################### 1923 + 5.. 9: ####################################################### 1936 + 10.. 14: # 61 + 15.. 19: # 59 + 20.. 24: # 62 + 25.. 29: # 70 + 30.. 34: # 61 + 35.. 39: # 64 + 40.. 44: # 64 + 45.. 49: # 56 + 50.. 54: # 65 + 55.. 59: # 55 + 60.. 64: # 60 + 65.. 69: # 62 + 70.. 74: # 57 + 75.. 79: # 69 + 80.. 84: ## 73 + 85.. 89: # 67 + 90.. 94: # 62 + 95.. 99: ## 74 + ++++ Stats for array_size len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats len: + num: 5000, avg: 7.49, stddev: 1.71, median 8, min 5, max 10 + 5: ####################################################### 867 + 6: ################################################### 813 + 7: ################################################### 815 + 8: #################################################### 833 + 9: ###################################################### 857 + 10: ################################################### 815 + ++++ Stats for array_repeat len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats len: + num: 5000, avg: 42.00, stddev: 0.00, median 42, min 42, max 42 + 42: ####################################################### 5000 + +++ Stats for int_stats_neg ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: @@ -452,7 +525,7 @@ stats dist: -4611686018427387392..-4150517416584648577: 0 ================================================================================ 1 warning(s) -failure (12 tests failed, 1 tests errored, ran 33 tests) +failure (12 tests failed, 1 tests errored, ran 40 tests) random seed: 153870556 +++ Stats for int_stat_display_test9 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ diff --git a/test/core/qcheck_output.txt.expected b/test/core/qcheck_output.txt.expected index 8044674b..69389b6d 100644 --- a/test/core/qcheck_output.txt.expected +++ b/test/core/qcheck_output.txt.expected @@ -236,6 +236,79 @@ stats len: 9: ###################################################### 857 10: ################################################### 815 ++++ Stats for list_repeat len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats len: + num: 5000, avg: 42.00, stddev: 0.00, median 42, min 42, max 42 + 42: ####################################################### 5000 + ++++ Stats for array len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats len: + num: 5000, avg: 400.16, stddev: 1371.90, median 9, min 0, max 9987 + 0.. 499: ####################################################### 4246 + 500.. 999: ###### 502 + 1000.. 1499: 13 + 1500.. 1999: 10 + 2000.. 2499: 14 + 2500.. 2999: 14 + 3000.. 3499: 20 + 3500.. 3999: 7 + 4000.. 4499: 13 + 4500.. 4999: 16 + 5000.. 5499: 12 + 5500.. 5999: 15 + 6000.. 6499: 15 + 6500.. 6999: 13 + 7000.. 7499: 16 + 7500.. 7999: 12 + 8000.. 8499: 11 + 8500.. 8999: 16 + 9000.. 9499: 15 + 9500.. 9999: 20 + ++++ Stats for small_array len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats len: + num: 5000, avg: 16.14, stddev: 24.86, median 6, min 0, max 99 + 0.. 4: ###################################################### 1923 + 5.. 9: ####################################################### 1936 + 10.. 14: # 61 + 15.. 19: # 59 + 20.. 24: # 62 + 25.. 29: # 70 + 30.. 34: # 61 + 35.. 39: # 64 + 40.. 44: # 64 + 45.. 49: # 56 + 50.. 54: # 65 + 55.. 59: # 55 + 60.. 64: # 60 + 65.. 69: # 62 + 70.. 74: # 57 + 75.. 79: # 69 + 80.. 84: ## 73 + 85.. 89: # 67 + 90.. 94: # 62 + 95.. 99: ## 74 + ++++ Stats for array_of_size len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats len: + num: 5000, avg: 7.49, stddev: 1.71, median 8, min 5, max 10 + 5: ####################################################### 867 + 6: ################################################### 813 + 7: ################################################### 815 + 8: #################################################### 833 + 9: ###################################################### 857 + 10: ################################################### 815 + ++++ Stats for array_repeat len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats len: + num: 5000, avg: 42.00, stddev: 0.00, median 42, min 42, max 42 + 42: ####################################################### 5000 + +++ Stats for int_stats_neg ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: @@ -452,7 +525,7 @@ stats dist: -4611686018427387392..-4150517416584648577: 0 ================================================================================ 1 warning(s) -failure (12 tests failed, 1 tests errored, ran 33 tests) +failure (12 tests failed, 1 tests errored, ran 40 tests) random seed: 153870556 +++ Stats for int_stat_display_test9 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ From d4ab9d377bc5e5de63ff51f2e1f8c71d34097e44 Mon Sep 17 00:00:00 2001 From: Jan Midtgaard Date: Thu, 12 Aug 2021 14:14:18 +0200 Subject: [PATCH 38/49] rename int dist tests to make it easier to add more --- test/core/QCheck2_expect_test.ml | 37 ++++++++++++--------------- test/core/QCheck_expect_test.ml | 37 ++++++++++++--------------- test/core/qcheck2_output.txt.expected | 18 ++++++------- test/core/qcheck_output.txt.expected | 18 ++++++------- 4 files changed, 50 insertions(+), 60 deletions(-) diff --git a/test/core/QCheck2_expect_test.ml b/test/core/QCheck2_expect_test.ml index 4719a79e..a0efef2c 100644 --- a/test/core/QCheck2_expect_test.ml +++ b/test/core/QCheck2_expect_test.ml @@ -233,30 +233,26 @@ module Stats = struct Test.make ~count:5_000 ~name:"array_repeat len dist" ~stats:[len] Gen.(array_repeat 42 int) (fun _ -> true); ] - (* test from issue #40 *) - let int_stats_neg = - QCheck2.(Test.make ~count:5_000 ~name:"int_stats_neg" - ~stats:[("dist",fun x -> x)] Gen.small_signed_int) - (fun _ -> true) - - (* distribution tests from PR #45 *) - let int_stats_tests = + let int_dist_tests = let open QCheck2 in let dist = ("dist",fun x -> x) in [ - Test.make ~name:"int_stat_display_test_1" ~count:1000 ~stats:[dist] Gen.small_signed_int (fun _ -> true); - Test.make ~name:"int_stat_display_test_2" ~count:1000 ~stats:[dist] Gen.small_nat (fun _ -> true); - Test.make ~name:"int_stat_display_test_3" ~count:1000 ~stats:[dist] (Gen.int_range (-43643) 435434) (fun _ -> true); - Test.make ~name:"int_stat_display_test_4" ~count:1000 ~stats:[dist] (Gen.int_range (-40000) 40000) (fun _ -> true); - Test.make ~name:"int_stat_display_test_5" ~count:1000 ~stats:[dist] (Gen.int_range (-4) 4) (fun _ -> true); - Test.make ~name:"int_stat_display_test_6" ~count:1000 ~stats:[dist] (Gen.int_range (-4) 17) (fun _ -> true); - Test.make ~name:"int_stat_display_test_7" ~count:100000 ~stats:[dist] Gen.int (fun _ -> true); - Test.make ~name:"int_stat_display_test_8" ~count:1000 ~stats:[dist] (Gen.oneofl[min_int;-1;0;1;max_int]) (fun _ -> true); + (* test from issue #40 *) + Test.make ~name:"int_stats_neg" ~count:5000 ~stats:[dist] Gen.small_signed_int (fun _ -> true); + (* distribution tests from PR #45 *) + Test.make ~name:"small_signed_int dist" ~count:1000 ~stats:[dist] Gen.small_signed_int (fun _ -> true); + Test.make ~name:"small_nat dist" ~count:1000 ~stats:[dist] Gen.small_nat (fun _ -> true); + Test.make ~name:"int_range (-43643) 435434 dist" ~count:1000 ~stats:[dist] (Gen.int_range (-43643) 435434) (fun _ -> true); + Test.make ~name:"int_range (-40000) 40000 dist" ~count:1000 ~stats:[dist] (Gen.int_range (-40000) 40000) (fun _ -> true); + Test.make ~name:"int_range (-4) 4 dist" ~count:1000 ~stats:[dist] (Gen.int_range (-4) 4) (fun _ -> true); + Test.make ~name:"int_range (-4) 17 dist" ~count:1000 ~stats:[dist] (Gen.int_range (-4) 17) (fun _ -> true); + Test.make ~name:"int dist" ~count:100000 ~stats:[dist] Gen.int (fun _ -> true); + Test.make ~name:"oneof int dist" ~count:1000 ~stats:[dist] (Gen.oneofl[min_int;-1;0;1;max_int]) (fun _ -> true); ] - let int_stat_display_test9 = + let int_dist_empty_bucket = let open QCheck2 in - Test.make ~name:"int_stat_display_test9" ~count:1_000 + Test.make ~name:"int_dist_empty_bucket" ~count:1_000 ~stats:[("dist",fun x -> x)] Gen.(oneof [small_int_corners ();int]) (fun _ -> true) end @@ -289,9 +285,8 @@ let _ = Stats.char_dist] @ Stats.list_len_tests @ Stats.array_len_tests - @ [Stats.int_stats_neg] - @ Stats.int_stats_tests) + @ Stats.int_dist_tests) let () = QCheck_base_runner.set_seed 153870556 -let _ = QCheck_base_runner.run_tests ~colors:false [Stats.int_stat_display_test9] +let _ = QCheck_base_runner.run_tests ~colors:false [Stats.int_dist_empty_bucket] diff --git a/test/core/QCheck_expect_test.ml b/test/core/QCheck_expect_test.ml index 80c0c071..80323556 100644 --- a/test/core/QCheck_expect_test.ml +++ b/test/core/QCheck_expect_test.ml @@ -225,29 +225,25 @@ module Stats = struct Test.make ~count:5_000 ~name:"array_repeat len dist" (add_stat len (make Gen.(array_repeat 42 int))) (fun _ -> true); ] - (* test from issue #40 *) - let int_stats_neg = - QCheck.(Test.make ~count:5_000 ~name:"int_stats_neg" - (add_stat ("dist",fun x -> x) small_signed_int)) (fun _ -> true) - - (* distribution tests from PR #45 *) - let int_stats_tests = + let int_dist_tests = let open QCheck in let dist = ("dist",fun x -> x) in - [ - Test.make ~name:"int_stat_display_test_1" ~count:1000 (add_stat dist small_signed_int) (fun _ -> true); - Test.make ~name:"int_stat_display_test_2" ~count:1000 (add_stat dist small_nat) (fun _ -> true); - Test.make ~name:"int_stat_display_test_3" ~count:1000 (add_stat dist (int_range (-43643) 435434)) (fun _ -> true); - Test.make ~name:"int_stat_display_test_4" ~count:1000 (add_stat dist (int_range (-40000) 40000)) (fun _ -> true); - Test.make ~name:"int_stat_display_test_5" ~count:1000 (add_stat dist (int_range (-4) 4)) (fun _ -> true); - Test.make ~name:"int_stat_display_test_6" ~count:1000 (add_stat dist (int_range (-4) 17)) (fun _ -> true); - Test.make ~name:"int_stat_display_test_7" ~count:100000 (add_stat dist int) (fun _ -> true); - Test.make ~name:"int_stat_display_test_8" ~count:1000 (add_stat dist (oneofl[min_int;-1;0;1;max_int])) (fun _ -> true); + [ (* test from issue #40 *) + Test.make ~name:"int_stats_neg" ~count:5000 (add_stat dist small_signed_int) (fun _ -> true); + (* distribution tests from PR #45 *) + Test.make ~name:"small_signed_int dist" ~count:1000 (add_stat dist small_signed_int) (fun _ -> true); + Test.make ~name:"small_nat dist" ~count:1000 (add_stat dist small_nat) (fun _ -> true); + Test.make ~name:"int_range (-43643) 435434 dist" ~count:1000 (add_stat dist (int_range (-43643) 435434)) (fun _ -> true); + Test.make ~name:"int_range (-40000) 40000 dist" ~count:1000 (add_stat dist (int_range (-40000) 40000)) (fun _ -> true); + Test.make ~name:"int_range (-4) 4 dist" ~count:1000 (add_stat dist (int_range (-4) 4)) (fun _ -> true); + Test.make ~name:"int_range (-4) 17 dist" ~count:1000 (add_stat dist (int_range (-4) 17)) (fun _ -> true); + Test.make ~name:"int dist" ~count:100000 (add_stat dist int) (fun _ -> true); + Test.make ~name:"oneof int dist" ~count:1000 (add_stat dist (oneofl[min_int;-1;0;1;max_int])) (fun _ -> true); ] - let int_stat_display_test9 = + let int_dist_empty_bucket = let open QCheck in - Test.make ~name:"int_stat_display_test9" ~count:1_000 + Test.make ~name:"int_dist_empty_bucket" ~count:1_000 (add_stat ("dist",fun x -> x) (oneof [small_int_corners ();int])) (fun _ -> true) end @@ -280,8 +276,7 @@ let i = Stats.char_dist] @ Stats.list_len_tests @ Stats.array_len_tests - @ [Stats.int_stats_neg] - @ Stats.int_stats_tests) + @ Stats.int_dist_tests) let () = QCheck_base_runner.set_seed 153870556 -let _ = QCheck_base_runner.run_tests ~colors:false [Stats.int_stat_display_test9] +let _ = QCheck_base_runner.run_tests ~colors:false [Stats.int_dist_empty_bucket] diff --git a/test/core/qcheck2_output.txt.expected b/test/core/qcheck2_output.txt.expected index 99f37897..2a9836d6 100644 --- a/test/core/qcheck2_output.txt.expected +++ b/test/core/qcheck2_output.txt.expected @@ -334,7 +334,7 @@ stats dist: 81.. 90: # 60 91..100: # 66 -+++ Stats for int_stat_display_test_1 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++ Stats for small_signed_int dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 0.90, stddev: 28.23, median 0, min -99, max 99 @@ -359,7 +359,7 @@ stats dist: 81.. 90: # 16 91..100: # 10 -+++ Stats for int_stat_display_test_2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++ Stats for small_nat dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 15.11, stddev: 23.27, median 6, min 0, max 99 @@ -384,7 +384,7 @@ stats dist: 90.. 94: 5 95.. 99: # 10 -+++ Stats for int_stat_display_test_3 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++ Stats for int_range (-43643) 435434 dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 195335.64, stddev: 136803.99, median 195583, min -43624, max 435210 @@ -409,7 +409,7 @@ stats dist: 387332..411273: ########################################## 49 411274..435215: ########################################### 51 -+++ Stats for int_stat_display_test_4 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++ Stats for int_range (-40000) 40000 dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: -173.78, stddev: 23042.92, median 180, min -39859, max 39942 @@ -434,7 +434,7 @@ stats dist: 31979.. 35969: ######################################### 51 35970.. 39960: #################################### 45 -+++ Stats for int_stat_display_test_5 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++ Stats for int_range (-4) 4 dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 0.02, stddev: 2.55, median 0, min -4, max 4 @@ -448,7 +448,7 @@ stats dist: 3: ####################################################### 122 4: ############################################## 104 -+++ Stats for int_stat_display_test_6 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++ Stats for int_range (-4) 17 dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 6.67, stddev: 6.39, median 7, min -4, max 17 @@ -473,7 +473,7 @@ stats dist: 32..33: 0 34..35: 0 -+++ Stats for int_stat_display_test_7 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++ Stats for int dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 100000, avg: 6126662802445055.00, stddev: 2661484817981980672.00, median 158655556399988, min -4611578348806740501, max 4611677827646819817 @@ -498,7 +498,7 @@ stats dist: 3689352210001463787.. 4150515018824141802: ###################################################### 5048 4150515018824141803.. 4611677827646819818: ###################################################### 5063 -+++ Stats for int_stat_display_test_8 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++ Stats for oneof int dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 4611686018427388.00, stddev: 2905870896563567616.00, median 0, min -4611686018427387904, max 4611686018427387903 @@ -528,7 +528,7 @@ stats dist: failure (12 tests failed, 1 tests errored, ran 40 tests) random seed: 153870556 -+++ Stats for int_stat_display_test9 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++ Stats for int_dist_empty_bucket ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: -10119269408092442.00, stddev: 1871251663919905536.00, median 9, min -4576142151952919207, max 4611686018427387903 diff --git a/test/core/qcheck_output.txt.expected b/test/core/qcheck_output.txt.expected index 69389b6d..725031c2 100644 --- a/test/core/qcheck_output.txt.expected +++ b/test/core/qcheck_output.txt.expected @@ -334,7 +334,7 @@ stats dist: 81.. 90: # 60 91..100: # 66 -+++ Stats for int_stat_display_test_1 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++ Stats for small_signed_int dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 0.90, stddev: 28.23, median 0, min -99, max 99 @@ -359,7 +359,7 @@ stats dist: 81.. 90: # 16 91..100: # 10 -+++ Stats for int_stat_display_test_2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++ Stats for small_nat dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 15.11, stddev: 23.27, median 6, min 0, max 99 @@ -384,7 +384,7 @@ stats dist: 90.. 94: 5 95.. 99: # 10 -+++ Stats for int_stat_display_test_3 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++ Stats for int_range (-43643) 435434 dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 195335.64, stddev: 136803.99, median 195583, min -43624, max 435210 @@ -409,7 +409,7 @@ stats dist: 387332..411273: ########################################## 49 411274..435215: ########################################### 51 -+++ Stats for int_stat_display_test_4 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++ Stats for int_range (-40000) 40000 dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: -173.78, stddev: 23042.92, median 180, min -39859, max 39942 @@ -434,7 +434,7 @@ stats dist: 31979.. 35969: ######################################### 51 35970.. 39960: #################################### 45 -+++ Stats for int_stat_display_test_5 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++ Stats for int_range (-4) 4 dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 0.02, stddev: 2.55, median 0, min -4, max 4 @@ -448,7 +448,7 @@ stats dist: 3: ####################################################### 122 4: ############################################## 104 -+++ Stats for int_stat_display_test_6 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++ Stats for int_range (-4) 17 dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 6.67, stddev: 6.39, median 7, min -4, max 17 @@ -473,7 +473,7 @@ stats dist: 32..33: 0 34..35: 0 -+++ Stats for int_stat_display_test_7 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++ Stats for int dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 100000, avg: 2541076923587387.50, stddev: 2660730801206827008.00, median 158655268318060, min -4611522359435274428, max 4611540922436307689 @@ -498,7 +498,7 @@ stats dist: 3689234594249150020.. 4150387758342729155: ##################################################### 4982 4150387758342729156.. 4611540922436308291: ###################################################### 5039 -+++ Stats for int_stat_display_test_8 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++ Stats for oneof int dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 4611686018427388.00, stddev: 2905870896563567616.00, median 0, min -4611686018427387904, max 4611686018427387903 @@ -528,7 +528,7 @@ stats dist: failure (12 tests failed, 1 tests errored, ran 40 tests) random seed: 153870556 -+++ Stats for int_stat_display_test9 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++ Stats for int_dist_empty_bucket ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: -55083208105414400.00, stddev: 1847115855773139200.00, median 9, min -4590718933436425025, max 4611686018427387903 From 0f96fdb4258dcbcc78bc0c99b22a49a6a409d00a Mon Sep 17 00:00:00 2001 From: Jan Midtgaard Date: Thu, 12 Aug 2021 15:07:24 +0200 Subject: [PATCH 39/49] clean-up: avoid repeated 'let open QCheck', take ~name first, rename --- test/core/QCheck2_expect_test.ml | 171 ++++++++++++-------------- test/core/QCheck_expect_test.ml | 167 ++++++++++++------------- test/core/qcheck2_output.txt.expected | 4 +- test/core/qcheck_output.txt.expected | 4 +- 4 files changed, 159 insertions(+), 187 deletions(-) diff --git a/test/core/QCheck2_expect_test.ml b/test/core/QCheck2_expect_test.ml index a0efef2c..8e2a91b9 100644 --- a/test/core/QCheck2_expect_test.ml +++ b/test/core/QCheck2_expect_test.ml @@ -2,55 +2,46 @@ (* tests of overall functionality *) module Overall = struct + open QCheck2 + let passing = - QCheck2.Test.make ~count:100 ~long_factor:100 ~print:QCheck2.Print.(list int) - ~name:"list_rev_is_involutive" - QCheck2.Gen.(list small_int) - (fun l -> List.rev (List.rev l) = l);; + Test.make ~name:"list_rev_is_involutive" ~count:100 ~long_factor:100 + ~print:Print.(list int) + Gen.(list small_int) (fun l -> List.rev (List.rev l) = l) let failing = - QCheck2.Test.make ~count:10 - ~name:"should_fail_sort_id" ~print:QCheck2.Print.(list int) - QCheck2.Gen.(small_list small_int) - (fun l -> l = List.sort compare l);; + 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) exception Error let error = - QCheck2.Test.make ~count:10 - ~name:"should_error_raise_exn" ~print:QCheck2.Print.int - QCheck2.Gen.int - (fun _ -> raise Error) + Test.make ~name:"should_error_raise_exn" ~count:10 ~print:Print.int + Gen.int (fun _ -> raise Error) let collect = - QCheck2.Test.make ~count:100 ~long_factor:100 - ~name:"collect_results" ~print:QCheck2.Print.int - ~collect:string_of_int (QCheck2.Gen.int_bound 4) - (fun _ -> true) + Test.make ~name:"collect_results" ~count:100 ~long_factor:100 + ~print:Print.int ~collect:string_of_int + (Gen.int_bound 4) (fun _ -> true) let stats = - QCheck2.Test.make ~count:100 ~long_factor:100 - ~name:"with_stats" ~print:QCheck2.Print.int + Test.make ~name:"with_stats" ~count:100 ~long_factor:100 ~print:Print.int ~stats:[ "mod4", (fun i->i mod 4); "num", (fun i->i); ] - (QCheck2.Gen.int_bound 120) - (fun _ -> true) + (Gen.int_bound 120) (fun _ -> true) let bad_assume_warn = - let open QCheck2 in - Test.make ~count:2_000 - ~name:"WARN_unlikely_precond" ~print:Print.int + Test.make ~name:"WARN_unlikely_precond" ~count:2_000 ~print:Print.int Gen.int (fun x -> QCheck.assume (x mod 100 = 1); true) let bad_assume_fail = - let open QCheck2 in - Test.make ~count:2_000 ~if_assumptions_fail:(`Fatal, 0.1) - ~name:"FAIL_unlikely_precond" ~print:Print.int + Test.make ~name:"FAIL_unlikely_precond" ~count:2_000 + ~if_assumptions_fail:(`Fatal, 0.1) ~print:Print.int Gen.int (fun x -> QCheck.assume (x mod 100 = 1); @@ -59,48 +50,50 @@ end (* test various generators *) module Generator = struct + open QCheck2 + (* example from issue #23 *) let char_dist_issue_23 = - let open QCheck2 in - Test.make ~name:"char never produces '\\255'" ~count:1_000_000 ~print:Print.char Gen.char (fun c -> c <> '\255') + Test.make ~name:"char never produces '\\255'" ~count:1_000_000 + ~print:Print.char + Gen.char (fun c -> c <> '\255') let list_repeat_test = - let open QCheck2 in - Test.make ~name:"list_repeat has constant length" ~count:1000 ~print:Print.(pair int (list unit)) - Gen.(small_nat >>= fun i -> list_repeat i unit >>= fun l -> return (i,l)) (fun (i,l) -> List.length l = i) + Test.make ~name:"list_repeat has constant length" ~count:1000 + ~print:Print.(pair int (list unit)) + Gen.(small_nat >>= fun i -> list_repeat i unit >>= fun l -> return (i,l)) + (fun (i,l) -> List.length l = i) let array_repeat_test = - let open QCheck2 in - Test.make ~name:"array_repeat has constant length" ~count:1000 ~print:Print.(pair int (array unit)) - Gen.(small_nat >>= fun i -> array_repeat i unit >>= fun l -> return (i,l)) (fun (i,l) -> Array.length l = i) + Test.make ~name:"array_repeat has constant length" ~count:1000 + ~print:Print.(pair int (array unit)) + Gen.(small_nat >>= fun i -> array_repeat i unit >>= fun l -> return (i,l)) + (fun (i,l) -> Array.length l = i) end (* tests function generator and shrinker *) module Function = struct - let fun1 = - let open QCheck2 in - Test.make ~count:100 ~long_factor:100 - ~name:"FAIL_pred_map_commute" ~print:Print.(triple (list int) Fn.print Fn.print) + open QCheck2 + + let fail_pred_map_commute = + Test.make ~name:"fail_pred_map_commute" ~count:100 ~long_factor:100 + ~print:Print.(triple (list int) Fn.print Fn.print) Gen.(triple (small_list small_int) (fun1 ~print:Print.int Observable.int int) (fun1 ~print:Print.bool Observable.int bool)) - (fun (l,QCheck2.Fun (_,f), QCheck2.Fun (_,p)) -> + (fun (l,Fun (_,f),Fun (_,p)) -> List.filter p (List.map f l) = List.map f (List.filter p l)) - let fun2 = - let open QCheck2 in - Test.make ~count:100 - ~name:"FAIL_fun2_pred_strings" ~print:Fn.print + let fail_pred_strings = + Test.make ~name:"fail_pred_strings" ~count:100 ~print:Fn.print (fun1 Observable.string ~print:Print.bool Gen.bool) - (fun (Fun (_,p)) -> - not (p "some random string") || p "some other string") + (fun (Fun (_,p)) -> not (p "some random string") || p "some other string") - let int_gen = QCheck2.Gen.small_nat (* int *) + let int_gen = Gen.small_nat (* int *) (* Another example (false) property *) let prop_foldleft_foldright = - let open QCheck2 in Test.make ~name:"fold_left fold_right" ~count:1000 ~long_factor:20 ~print:Print.(triple int (list int) Fn.print) Gen.(triple @@ -111,15 +104,14 @@ module Function = struct let l1 = List.fold_right (Fn.apply f) xs z in let l2 = List.fold_left (Fn.apply f) z xs in if l1=l2 then true - else QCheck.Test.fail_reportf "l=%s, fold_left=%s, fold_right=%s@." - (QCheck.Print.(list int) xs) - (QCheck.Print.int l1) - (QCheck.Print.int l2) + else Test.fail_reportf "l=%s, fold_left=%s, fold_right=%s@." + (Print.(list int) xs) + (Print.int l1) + (Print.int l2) ) (* Another example (false) property *) let prop_foldleft_foldright_uncurry = - let open QCheck2 in Test.make ~name:"fold_left fold_right uncurried" ~count:1000 ~long_factor:20 ~print:Print.(triple Fn.print int (list int)) Gen.(triple @@ -132,7 +124,6 @@ module Function = struct (* Same as the above (false) property, but generating+shrinking functions last *) let prop_foldleft_foldright_uncurry_funlast = - let open QCheck2 in Test.make ~name:"fold_left fold_right uncurried fun last" ~count:1000 ~long_factor:20 ~print:Print.(triple int (list int) Fn.print) Gen.(triple @@ -146,13 +137,14 @@ end (* tests of shrinking behaviour *) module Shrink = struct + open QCheck2 + let rec fac n = match n with | 0 -> 1 | n -> n * fac (n - 1) (* example from issue #59 *) let test_fac_issue59 = - let open QCheck2 in Test.make ~name:"test fac issue59" (Gen.make_primitive ~gen:(fun st -> Gen.generate1 ~rand:st (Gen.small_int_corners ())) ~shrink:(fun _ -> Seq.empty)) (fun n -> try (fac n) mod n = 0 @@ -161,11 +153,10 @@ module Shrink = struct | Division_by_zero -> (n=0)) let big_bound_issue59 = - QCheck2.Test.make ~name:"big bound issue59" ~print:QCheck2.Print.int - (QCheck2.Gen.small_int_corners()) (fun i -> i < 209609) + Test.make ~name:"big bound issue59" ~print:Print.int + (Gen.small_int_corners()) (fun i -> i < 209609) let long_shrink = - let open QCheck2 in let listgen = Gen.(list_size (int_range 1000 10000) int) in Test.make ~name:"long_shrink" ~print:Print.(pair (list int) (list int)) (Gen.pair listgen listgen) @@ -173,15 +164,15 @@ module Shrink = struct (* test shrinking on integers *) let shrink_int = - let open QCheck2 in - Test.make ~count:1000 ~name:"mod3_should_fail" ~print:Print.int + Test.make ~name:"mod3_should_fail" ~count:1000 ~print:Print.int Gen.int (fun i -> i mod 3 <> 0) end (* tests of (inner) find_example(_gen) behaviour *) module FindExample = struct + open QCheck2 + let find_ex = - let open QCheck2 in Test.make ~name:"find_example" ~print:Print.int Gen.(2--50) (fun n -> @@ -192,49 +183,44 @@ module FindExample = struct f m with No_example_found _ -> false) - let find_ex_uncaught_issue_99 : _ list = - let open QCheck2 in - let t1 = - let rs = (find_example ~count:10 ~f:(fun _ -> false) Gen.int) in - Test.make ~name:"FAIL_#99_1" rs (fun _ -> true) in - let t2 = - Test.make ~name:"should_succeed_#99_2" ~count:10 Gen.int - (fun i -> i <= max_int) in - [t1;t2] + let find_ex_uncaught_issue_99_1_fail = + let rs = (find_example ~count:10 ~f:(fun _ -> false) Gen.int) in + Test.make ~name:"FAIL_#99_1" rs (fun _ -> true) + + let find_ex_uncaught_issue_99_2_succeed = + Test.make ~name:"should_succeed_#99_2" ~count:10 + Gen.int (fun i -> i <= max_int) end (* tests of statistics and histogram display *) module Stats = struct + open QCheck2 + let bool_dist = - QCheck2.(Test.make ~count:500_000 ~name:"bool dist" - ~collect:Bool.to_string Gen.bool) (fun _ -> true) + Test.make ~name:"bool dist" ~count:500_000 ~collect:Bool.to_string Gen.bool (fun _ -> true) let char_dist = - QCheck2.(Test.make ~count:500_000 ~name:"char code dist" - ~stats:[("char code", Char.code)] Gen.char) (fun _ -> true) + Test.make ~name:"char code dist" ~count:500_000 ~stats:[("char code", Char.code)] Gen.char (fun _ -> true) let list_len_tests = - let open QCheck2 in let len = ("len",List.length) in [ (* test from issue #30 *) - Test.make ~count:5_000 ~name:"list len dist" ~stats:[len] Gen.(list int) (fun _ -> true); - Test.make ~count:5_000 ~name:"small_list len dist" ~stats:[len] Gen.(small_list int) (fun _ -> true); - Test.make ~count:5_000 ~name:"list_size len dist" ~stats:[len] Gen.(list_size (int_range 5 10) int) (fun _ -> true); - Test.make ~count:5_000 ~name:"list_repeat len dist" ~stats:[len] Gen.(list_repeat 42 int) (fun _ -> true); + Test.make ~name:"list len dist" ~count:5_000 ~stats:[len] Gen.(list int) (fun _ -> true); + Test.make ~name:"small_list len dist" ~count:5_000 ~stats:[len] Gen.(small_list int) (fun _ -> true); + Test.make ~name:"list_size len dist" ~count:5_000 ~stats:[len] Gen.(list_size (int_range 5 10) int) (fun _ -> true); + Test.make ~name:"list_repeat len dist" ~count:5_000 ~stats:[len] Gen.(list_repeat 42 int) (fun _ -> true); ] let array_len_tests = - let open QCheck2 in let len = ("len",Array.length) in [ - Test.make ~count:5_000 ~name:"array len dist" ~stats:[len] Gen.(array int) (fun _ -> true); - Test.make ~count:5_000 ~name:"small_array len dist" ~stats:[len] Gen.(small_array int) (fun _ -> true); - Test.make ~count:5_000 ~name:"array_size len dist" ~stats:[len] Gen.(array_size (int_range 5 10) int) (fun _ -> true); - Test.make ~count:5_000 ~name:"array_repeat len dist" ~stats:[len] Gen.(array_repeat 42 int) (fun _ -> true); + Test.make ~name:"array len dist" ~count:5_000 ~stats:[len] Gen.(array int) (fun _ -> true); + Test.make ~name:"small_array len dist" ~count:5_000 ~stats:[len] Gen.(small_array int) (fun _ -> true); + Test.make ~name:"array_size len dist" ~count:5_000 ~stats:[len] Gen.(array_size (int_range 5 10) int) (fun _ -> true); + Test.make ~name:"array_repeat len dist" ~count:5_000 ~stats:[len] Gen.(array_repeat 42 int) (fun _ -> true); ] let int_dist_tests = - let open QCheck2 in let dist = ("dist",fun x -> x) in [ (* test from issue #40 *) @@ -251,9 +237,8 @@ module Stats = struct ] let int_dist_empty_bucket = - let open QCheck2 in - Test.make ~name:"int_dist_empty_bucket" ~count:1_000 - ~stats:[("dist",fun x -> x)] Gen.(oneof [small_int_corners ();int]) (fun _ -> true) + Test.make ~name:"int_dist_empty_bucket" ~count:1_000 ~stats:[("dist",fun x -> x)] + Gen.(oneof [small_int_corners ();int]) (fun _ -> true) end (* Calling runners *) @@ -271,8 +256,8 @@ let _ = Generator.char_dist_issue_23; Generator.list_repeat_test; Generator.array_repeat_test; - Function.fun1; - Function.fun2; + Function.fail_pred_map_commute; + Function.fail_pred_strings; Function.prop_foldleft_foldright; Function.prop_foldleft_foldright_uncurry; Function.prop_foldleft_foldright_uncurry_funlast; @@ -280,9 +265,11 @@ let _ = Shrink.big_bound_issue59; Shrink.long_shrink; Shrink.shrink_int; - ] @ FindExample.find_ex :: FindExample.find_ex_uncaught_issue_99 - @ [Stats.bool_dist; - Stats.char_dist] + FindExample.find_ex; + FindExample.find_ex_uncaught_issue_99_1_fail; + FindExample.find_ex_uncaught_issue_99_2_succeed; + Stats.bool_dist; + Stats.char_dist] @ Stats.list_len_tests @ Stats.array_len_tests @ Stats.int_dist_tests) diff --git a/test/core/QCheck_expect_test.ml b/test/core/QCheck_expect_test.ml index 80323556..d07b0030 100644 --- a/test/core/QCheck_expect_test.ml +++ b/test/core/QCheck_expect_test.ml @@ -2,55 +2,47 @@ (* tests of overall functionality *) module Overall = struct + open QCheck + let passing = - QCheck.Test.make ~count:100 ~long_factor:100 - ~name:"list_rev_is_involutive" - QCheck.(list small_int) - (fun l -> List.rev (List.rev l) = l) + Test.make ~name:"list_rev_is_involutive" ~count:100 ~long_factor:100 + (list small_int) (fun l -> List.rev (List.rev l) = l) let failing = - QCheck.Test.make ~count:10 - ~name:"should_fail_sort_id" - QCheck.(small_list small_int) - (fun l -> l = List.sort compare l) + Test.make ~name:"should_fail_sort_id" ~count:10 + (small_list small_int) (fun l -> l = List.sort compare l) exception Error let error = - QCheck.Test.make ~count:10 - ~name:"should_error_raise_exn" - QCheck.int - (fun _ -> raise Error) + Test.make ~name:"should_error_raise_exn" ~count:10 + int (fun _ -> raise Error) let collect = - QCheck.Test.make ~count:100 ~long_factor:100 - ~name:"collect_results" - QCheck.(make ~collect:string_of_int (Gen.int_bound 4)) + Test.make ~name:"collect_results" ~count:100 ~long_factor:100 + (make ~collect:string_of_int (Gen.int_bound 4)) (fun _ -> true) let stats = - QCheck.Test.make ~count:100 ~long_factor:100 - ~name:"with_stats" - QCheck.(make (Gen.int_bound 120) - ~stats:[ - "mod4", (fun i->i mod 4); - "num", (fun i->i); - ] - ) + Test.make ~name:"with_stats" ~count:100 ~long_factor:100 + (make (Gen.int_bound 120) + ~stats:[ + "mod4", (fun i->i mod 4); + "num", (fun i->i); + ]) (fun _ -> true) let bad_assume_warn = - QCheck.Test.make ~count:2_000 - ~name:"WARN_unlikely_precond" - QCheck.int + Test.make ~name:"WARN_unlikely_precond" ~count:2_000 + int (fun x -> QCheck.assume (x mod 100 = 1); true) let bad_assume_fail = - QCheck.Test.make ~count:2_000 ~if_assumptions_fail:(`Fatal, 0.1) - ~name:"FAIL_unlikely_precond" - QCheck.int + Test.make ~name:"FAIL_unlikely_precond" ~count:2_000 + ~if_assumptions_fail:(`Fatal, 0.1) + int (fun x -> QCheck.assume (x mod 100 = 1); true) @@ -58,18 +50,18 @@ end (* test various generators *) module Generator = struct + open QCheck + (* example from issue #23 *) let char_dist_issue_23 = - QCheck.Test.make ~name:"char never produces '\\255'" ~count:1_000_000 QCheck.char (fun c -> c <> '\255') + Test.make ~name:"char never produces '\\255'" ~count:1_000_000 char (fun c -> c <> '\255') let list_repeat_test = - let open QCheck in let gen = Gen.(small_nat >>= fun i -> list_repeat i unit >>= fun l -> return (i,l)) in Test.make ~name:"list_repeat has constant length" ~count:1000 (make ~print:Print.(pair int (list unit)) gen) (fun (i,l) -> List.length l = i) let array_repeat_test = - let open QCheck in let gen = Gen.(small_nat >>= fun i -> array_repeat i unit >>= fun l -> return (i,l)) in Test.make ~name:"array_repeat has constant length" ~count:1000 (make ~print:Print.(pair int (array unit)) gen) (fun (i,l) -> Array.length l = i) @@ -77,28 +69,26 @@ end (* tests function generator and shrinker *) module Function = struct - let fun1 = - QCheck.Test.make ~count:100 ~long_factor:100 - ~name:"FAIL_pred_map_commute" - QCheck.(triple - (small_list small_int) - (fun1 Observable.int int) - (fun1 Observable.int bool)) - (fun (l,QCheck.Fun (_,f), QCheck.Fun (_,p)) -> + open QCheck + + let fail_pred_map_commute = + Test.make ~name:"fail_pred_map_commute" ~count:100 ~long_factor:100 + (triple + (small_list small_int) + (fun1 Observable.int int) + (fun1 Observable.int bool)) + (fun (l,Fun (_,f),Fun (_,p)) -> List.filter p (List.map f l) = List.map f (List.filter p l)) - let fun2 = - QCheck.Test.make ~count:100 - ~name:"FAIL_fun2_pred_strings" - QCheck.(fun1 Observable.string bool) - (fun (QCheck.Fun (_,p)) -> - not (p "some random string") || p "some other string") + let fail_pred_strings = + Test.make ~name:"fail_pred_strings" ~count:100 + (fun1 Observable.string bool) + (fun (Fun (_,p)) -> not (p "some random string") || p "some other string") - let int_gen = QCheck.small_nat (* int *) + let int_gen = small_nat (* int *) (* Another example (false) property *) let prop_foldleft_foldright = - let open QCheck in Test.make ~name:"fold_left fold_right" ~count:1000 ~long_factor:20 (triple int_gen @@ -108,15 +98,14 @@ module Function = struct let l1 = List.fold_right (Fn.apply f) xs z in let l2 = List.fold_left (Fn.apply f) z xs in if l1=l2 then true - else QCheck.Test.fail_reportf "l=%s, fold_left=%s, fold_right=%s@." - (QCheck.Print.(list int) xs) - (QCheck.Print.int l1) - (QCheck.Print.int l2) + else Test.fail_reportf "l=%s, fold_left=%s, fold_right=%s@." + (Print.(list int) xs) + (Print.int l1) + (Print.int l2) ) (* Another example (false) property *) let prop_foldleft_foldright_uncurry = - let open QCheck in Test.make ~name:"fold_left fold_right uncurried" ~count:1000 ~long_factor:20 (triple (fun1 Observable.(pair int int) int_gen) @@ -128,7 +117,6 @@ module Function = struct (* Same as the above (false) property, but generating+shrinking functions last *) let prop_foldleft_foldright_uncurry_funlast = - let open QCheck in Test.make ~name:"fold_left fold_right uncurried fun last" ~count:1000 ~long_factor:20 (triple int_gen @@ -141,13 +129,14 @@ end (* tests of shrinking behaviour *) module Shrink = struct + open QCheck + let rec fac n = match n with | 0 -> 1 | n -> n * fac (n - 1) (* example from issue #59 *) let test_fac_issue59 = - let open QCheck in Test.make ~name:"test fac issue59" (set_shrink Shrink.nil (small_int_corners ())) (fun n -> try (fac n) mod n = 0 @@ -156,25 +145,25 @@ module Shrink = struct | Division_by_zero -> (n=0)) let big_bound_issue59 = - QCheck.Test.make ~name:"big bound issue59" - (QCheck.small_int_corners()) (fun i -> i < 209609) + Test.make ~name:"big bound issue59" + (small_int_corners()) (fun i -> i < 209609) let long_shrink = - let open QCheck in let listgen = list_of_size (Gen.int_range 1000 10000) int in Test.make ~name:"long_shrink" (pair listgen listgen) (fun (xs,ys) -> List.rev (xs@ys) = (List.rev xs)@(List.rev ys)) (* test shrinking on integers *) let shrink_int = - QCheck.Test.make ~count:1000 ~name:"mod3_should_fail" - QCheck.int (fun i -> i mod 3 <> 0) + Test.make ~name:"mod3_should_fail" ~count:1000 + int (fun i -> i mod 3 <> 0) end (* tests of (inner) find_example(_gen) behaviour *) module FindExample = struct + open QCheck + let find_ex = - let open QCheck in Test.make ~name:"find_example" (2--50) (fun n -> let st = Random.State.make [| 0 |] in @@ -184,49 +173,44 @@ module FindExample = struct f m with No_example_found _ -> false) - let find_ex_uncaught_issue_99 : _ list = - let open QCheck in - let t1 = - let rs = make (find_example ~count:10 ~f:(fun _ -> false) Gen.int) in - Test.make ~name:"FAIL_#99_1" rs (fun _ -> true) in - let t2 = - Test.make ~name:"should_succeed_#99_2" ~count:10 int - (fun i -> i <= max_int) in - [t1;t2] + let find_ex_uncaught_issue_99_1_fail = + let rs = make (find_example ~count:10 ~f:(fun _ -> false) Gen.int) in + Test.make ~name:"FAIL_#99_1" rs (fun _ -> true) + + let find_ex_uncaught_issue_99_2_succeed = + Test.make ~name:"should_succeed_#99_2" ~count:10 + int (fun i -> i <= max_int) end (* tests of statistics and histogram display *) module Stats = struct + open QCheck + let bool_dist = - QCheck.(Test.make ~count:500_000 ~name:"bool dist" - (set_collect Bool.to_string bool)) (fun _ -> true) + Test.make ~name:"bool dist" ~count:500_000 (set_collect Bool.to_string bool) (fun _ -> true) let char_dist = - QCheck.(Test.make ~count:500_000 ~name:"char code dist" - (add_stat ("char code", Char.code) char)) (fun _ -> true) + Test.make ~name:"char code dist" ~count:500_000 (add_stat ("char code", Char.code) char) (fun _ -> true) let list_len_tests = - let open QCheck in let len = ("len",List.length) in [ (* test from issue #30 *) - Test.make ~count:5_000 ~name:"list len dist" (add_stat len (list int)) (fun _ -> true); - Test.make ~count:5_000 ~name:"small_list len dist" (add_stat len (small_list int)) (fun _ -> true); - Test.make ~count:5_000 ~name:"list_of_size len dist" (add_stat len (list_of_size (Gen.int_range 5 10) int)) (fun _ -> true); - Test.make ~count:5_000 ~name:"list_repeat len dist" (add_stat len (make Gen.(list_repeat 42 int))) (fun _ -> true); + Test.make ~name:"list len dist" ~count:5_000 (add_stat len (list int)) (fun _ -> true); + Test.make ~name:"small_list len dist" ~count:5_000 (add_stat len (small_list int)) (fun _ -> true); + Test.make ~name:"list_of_size len dist" ~count:5_000 (add_stat len (list_of_size (Gen.int_range 5 10) int)) (fun _ -> true); + Test.make ~name:"list_repeat len dist" ~count:5_000 (add_stat len (make Gen.(list_repeat 42 int))) (fun _ -> true); ] let array_len_tests = - let open QCheck in let len = ("len",Array.length) in [ - Test.make ~count:5_000 ~name:"array len dist" (add_stat len (array int)) (fun _ -> true); - Test.make ~count:5_000 ~name:"small_array len dist" (add_stat len (make Gen.(small_array int))) (fun _ -> true); - Test.make ~count:5_000 ~name:"array_of_size len dist" (add_stat len (array_of_size (Gen.int_range 5 10) int)) (fun _ -> true); - Test.make ~count:5_000 ~name:"array_repeat len dist" (add_stat len (make Gen.(array_repeat 42 int))) (fun _ -> true); + Test.make ~name:"array len dist" ~count:5_000 (add_stat len (array int)) (fun _ -> true); + Test.make ~name:"small_array len dist" ~count:5_000 (add_stat len (make Gen.(small_array int))) (fun _ -> true); + Test.make ~name:"array_of_size len dist" ~count:5_000 (add_stat len (array_of_size (Gen.int_range 5 10) int)) (fun _ -> true); + Test.make ~name:"array_repeat len dist" ~count:5_000 (add_stat len (make Gen.(array_repeat 42 int))) (fun _ -> true); ] let int_dist_tests = - let open QCheck in let dist = ("dist",fun x -> x) in [ (* test from issue #40 *) Test.make ~name:"int_stats_neg" ~count:5000 (add_stat dist small_signed_int) (fun _ -> true); @@ -242,7 +226,6 @@ module Stats = struct ] let int_dist_empty_bucket = - let open QCheck in Test.make ~name:"int_dist_empty_bucket" ~count:1_000 (add_stat ("dist",fun x -> x) (oneof [small_int_corners ();int])) (fun _ -> true) end @@ -262,8 +245,8 @@ let i = Generator.char_dist_issue_23; Generator.list_repeat_test; Generator.array_repeat_test; - Function.fun1; - Function.fun2; + Function.fail_pred_map_commute; + Function.fail_pred_strings; Function.prop_foldleft_foldright; Function.prop_foldleft_foldright_uncurry; Function.prop_foldleft_foldright_uncurry_funlast; @@ -271,9 +254,11 @@ let i = Shrink.big_bound_issue59; Shrink.long_shrink; Shrink.shrink_int; - ] @ FindExample.find_ex :: FindExample.find_ex_uncaught_issue_99 - @ [Stats.bool_dist; - Stats.char_dist] + FindExample.find_ex; + FindExample.find_ex_uncaught_issue_99_1_fail; + FindExample.find_ex_uncaught_issue_99_2_succeed; + Stats.bool_dist; + Stats.char_dist] @ Stats.list_len_tests @ Stats.array_len_tests @ Stats.int_dist_tests) diff --git a/test/core/qcheck2_output.txt.expected b/test/core/qcheck2_output.txt.expected index 2a9836d6..0cd6c9d1 100644 --- a/test/core/qcheck2_output.txt.expected +++ b/test/core/qcheck2_output.txt.expected @@ -82,13 +82,13 @@ Test char never produces '\255' failed (0 shrink steps): --- Failure -------------------------------------------------------------------- -Test FAIL_pred_map_commute failed (16 shrink steps): +Test fail_pred_map_commute failed (16 shrink steps): ([2], {_ -> 0}, {1 -> false; 2 -> true; _ -> false}) --- Failure -------------------------------------------------------------------- -Test FAIL_fun2_pred_strings failed (1 shrink steps): +Test fail_pred_strings failed (1 shrink steps): {"some random string" -> true; _ -> false} diff --git a/test/core/qcheck_output.txt.expected b/test/core/qcheck_output.txt.expected index 725031c2..70a9ec09 100644 --- a/test/core/qcheck_output.txt.expected +++ b/test/core/qcheck_output.txt.expected @@ -82,13 +82,13 @@ Test char never produces '\255' failed (0 shrink steps): --- Failure -------------------------------------------------------------------- -Test FAIL_pred_map_commute failed (127 shrink steps): +Test fail_pred_map_commute failed (127 shrink steps): ([3], {_ -> 0}, {3 -> false; _ -> true}) --- Failure -------------------------------------------------------------------- -Test FAIL_fun2_pred_strings failed (1 shrink steps): +Test fail_pred_strings failed (1 shrink steps): {some random string -> true; _ -> false} From de2d0484a395df710d1cde99675c99ebbeb1b84b Mon Sep 17 00:00:00 2001 From: Jan Midtgaard Date: Thu, 12 Aug 2021 15:46:50 +0200 Subject: [PATCH 40/49] add string dist tests --- test/core/QCheck2_expect_test.ml | 11 +++ test/core/QCheck_expect_test.ml | 11 +++ test/core/qcheck2_output.txt.expected | 113 +++++++++++++++++++++++++- test/core/qcheck_output.txt.expected | 113 +++++++++++++++++++++++++- 4 files changed, 246 insertions(+), 2 deletions(-) diff --git a/test/core/QCheck2_expect_test.ml b/test/core/QCheck2_expect_test.ml index 8e2a91b9..d27852d0 100644 --- a/test/core/QCheck2_expect_test.ml +++ b/test/core/QCheck2_expect_test.ml @@ -202,6 +202,16 @@ module Stats = struct let char_dist = Test.make ~name:"char code dist" ~count:500_000 ~stats:[("char code", Char.code)] Gen.char (fun _ -> true) + let string_len_tests = + let len = ("len",String.length) in + [ + Test.make ~name:"string_size len dist" ~count:5_000 ~stats:[len] Gen.(string_size (int_range 5 10)) (fun _ -> true); + Test.make ~name:"string len dist" ~count:5_000 ~stats:[len] Gen.string (fun _ -> true); + Test.make ~name:"string_of len dist" ~count:5_000 ~stats:[len] Gen.(string_of (return 'a')) (fun _ -> true); + Test.make ~name:"string_readable len dist" ~count:5_000 ~stats:[len] Gen.string_readable (fun _ -> true); + Test.make ~name:"small_string len dist" ~count:5_000 ~stats:[len] Gen.(small_string ~gen:char)(*ugh*)(fun _ -> true); + ] + let list_len_tests = let len = ("len",List.length) in [ (* test from issue #30 *) @@ -270,6 +280,7 @@ let _ = FindExample.find_ex_uncaught_issue_99_2_succeed; Stats.bool_dist; Stats.char_dist] + @ Stats.string_len_tests @ Stats.list_len_tests @ Stats.array_len_tests @ Stats.int_dist_tests) diff --git a/test/core/QCheck_expect_test.ml b/test/core/QCheck_expect_test.ml index d07b0030..a0855826 100644 --- a/test/core/QCheck_expect_test.ml +++ b/test/core/QCheck_expect_test.ml @@ -192,6 +192,16 @@ module Stats = struct let char_dist = Test.make ~name:"char code dist" ~count:500_000 (add_stat ("char code", Char.code) char) (fun _ -> true) + let string_len_tests = + let len = ("len",String.length) in + [ + Test.make ~name:"string_size len dist" ~count:5_000 (add_stat len (string_of_size (Gen.int_range 5 10))) (fun _ -> true); + Test.make ~name:"string len dist" ~count:5_000 (add_stat len string) (fun _ -> true); + Test.make ~name:"string_of len dist" ~count:5_000 (add_stat len (string_gen (Gen.return 'a'))) (fun _ -> true); + Test.make ~name:"printable_string len dist" ~count:5_000 (add_stat len printable_string) (fun _ -> true); + Test.make ~name:"small_string len dist" ~count:5_000 (add_stat len small_string) (fun _ -> true); + ] + let list_len_tests = let len = ("len",List.length) in [ (* test from issue #30 *) @@ -259,6 +269,7 @@ let i = FindExample.find_ex_uncaught_issue_99_2_succeed; Stats.bool_dist; Stats.char_dist] + @ Stats.string_len_tests @ Stats.list_len_tests @ Stats.array_len_tests @ Stats.int_dist_tests) diff --git a/test/core/qcheck2_output.txt.expected b/test/core/qcheck2_output.txt.expected index 0cd6c9d1..b843092f 100644 --- a/test/core/qcheck2_output.txt.expected +++ b/test/core/qcheck2_output.txt.expected @@ -175,6 +175,117 @@ stats char code: 234..246: ###################################################### 25567 247..259: ##################################### 17709 ++++ Stats for string_size len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats len: + num: 5000, avg: 7.49, stddev: 1.70, median 7, min 5, max 10 + 5: ##################################################### 837 + 6: ##################################################### 826 + 7: ###################################################### 843 + 8: ####################################################### 855 + 9: #################################################### 813 + 10: ##################################################### 826 + ++++ Stats for string len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats len: + num: 5000, avg: 384.53, stddev: 1330.61, median 9, min 0, max 9969 + 0.. 498: ####################################################### 4246 + 499.. 997: ###### 518 + 998..1496: 21 + 1497..1995: 10 + 1996..2494: 11 + 2495..2993: 10 + 2994..3492: 13 + 3493..3991: 13 + 3992..4490: 5 + 4491..4989: 10 + 4990..5488: 19 + 5489..5987: 9 + 5988..6486: 10 + 6487..6985: 12 + 6986..7484: 17 + 7485..7983: 16 + 7984..8482: 16 + 8483..8981: 16 + 8982..9480: 16 + 9481..9979: 12 + ++++ Stats for string_of len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats len: + num: 5000, avg: 363.14, stddev: 1245.80, median 9, min 0, max 9986 + 0.. 499: ####################################################### 4270 + 500.. 999: ###### 493 + 1000.. 1499: 16 + 1500.. 1999: 11 + 2000.. 2499: 15 + 2500.. 2999: 17 + 3000.. 3499: 11 + 3500.. 3999: 19 + 4000.. 4499: 14 + 4500.. 4999: 10 + 5000.. 5499: 16 + 5500.. 5999: 11 + 6000.. 6499: 15 + 6500.. 6999: 13 + 7000.. 7499: 12 + 7500.. 7999: 16 + 8000.. 8499: 11 + 8500.. 8999: 4 + 9000.. 9499: 13 + 9500.. 9999: 13 + ++++ Stats for string_readable len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats len: + num: 5000, avg: 384.53, stddev: 1330.61, median 9, min 0, max 9969 + 0.. 498: ####################################################### 4246 + 499.. 997: ###### 518 + 998..1496: 21 + 1497..1995: 10 + 1996..2494: 11 + 2495..2993: 10 + 2994..3492: 13 + 3493..3991: 13 + 3992..4490: 5 + 4491..4989: 10 + 4990..5488: 19 + 5489..5987: 9 + 5988..6486: 10 + 6487..6985: 12 + 6986..7484: 17 + 7485..7983: 16 + 7984..8482: 16 + 8483..8981: 16 + 8982..9480: 16 + 9481..9979: 12 + ++++ Stats for small_string len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats len: + num: 5000, avg: 15.57, stddev: 24.36, median 6, min 0, max 99 + 0.. 4: #################################################### 1925 + 5.. 9: ####################################################### 2005 + 10.. 14: # 52 + 15.. 19: # 50 + 20.. 24: # 55 + 25.. 29: # 56 + 30.. 34: # 55 + 35.. 39: # 49 + 40.. 44: # 65 + 45.. 49: # 65 + 50.. 54: # 55 + 55.. 59: # 68 + 60.. 64: # 61 + 65.. 69: # 65 + 70.. 74: # 57 + 75.. 79: # 66 + 80.. 84: # 65 + 85.. 89: # 64 + 90.. 94: # 60 + 95.. 99: # 62 + +++ Stats for list len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: @@ -525,7 +636,7 @@ stats dist: -4611686018427387392..-4150517416584648577: 0 ================================================================================ 1 warning(s) -failure (12 tests failed, 1 tests errored, ran 40 tests) +failure (12 tests failed, 1 tests errored, ran 45 tests) random seed: 153870556 +++ Stats for int_dist_empty_bucket ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ diff --git a/test/core/qcheck_output.txt.expected b/test/core/qcheck_output.txt.expected index 70a9ec09..5b054aaa 100644 --- a/test/core/qcheck_output.txt.expected +++ b/test/core/qcheck_output.txt.expected @@ -175,6 +175,117 @@ stats char code: 234..246: ###################################################### 25567 247..259: ##################################### 17709 ++++ Stats for string_size len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats len: + num: 5000, avg: 7.49, stddev: 1.70, median 7, min 5, max 10 + 5: ##################################################### 837 + 6: ##################################################### 826 + 7: ###################################################### 843 + 8: ####################################################### 855 + 9: #################################################### 813 + 10: ##################################################### 826 + ++++ Stats for string len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats len: + num: 5000, avg: 384.53, stddev: 1330.61, median 9, min 0, max 9969 + 0.. 498: ####################################################### 4246 + 499.. 997: ###### 518 + 998..1496: 21 + 1497..1995: 10 + 1996..2494: 11 + 2495..2993: 10 + 2994..3492: 13 + 3493..3991: 13 + 3992..4490: 5 + 4491..4989: 10 + 4990..5488: 19 + 5489..5987: 9 + 5988..6486: 10 + 6487..6985: 12 + 6986..7484: 17 + 7485..7983: 16 + 7984..8482: 16 + 8483..8981: 16 + 8982..9480: 16 + 9481..9979: 12 + ++++ Stats for string_of len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats len: + num: 5000, avg: 363.14, stddev: 1245.80, median 9, min 0, max 9986 + 0.. 499: ####################################################### 4270 + 500.. 999: ###### 493 + 1000.. 1499: 16 + 1500.. 1999: 11 + 2000.. 2499: 15 + 2500.. 2999: 17 + 3000.. 3499: 11 + 3500.. 3999: 19 + 4000.. 4499: 14 + 4500.. 4999: 10 + 5000.. 5499: 16 + 5500.. 5999: 11 + 6000.. 6499: 15 + 6500.. 6999: 13 + 7000.. 7499: 12 + 7500.. 7999: 16 + 8000.. 8499: 11 + 8500.. 8999: 4 + 9000.. 9499: 13 + 9500.. 9999: 13 + ++++ Stats for printable_string len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats len: + num: 5000, avg: 384.53, stddev: 1330.61, median 9, min 0, max 9969 + 0.. 498: ####################################################### 4246 + 499.. 997: ###### 518 + 998..1496: 21 + 1497..1995: 10 + 1996..2494: 11 + 2495..2993: 10 + 2994..3492: 13 + 3493..3991: 13 + 3992..4490: 5 + 4491..4989: 10 + 4990..5488: 19 + 5489..5987: 9 + 5988..6486: 10 + 6487..6985: 12 + 6986..7484: 17 + 7485..7983: 16 + 7984..8482: 16 + 8483..8981: 16 + 8982..9480: 16 + 9481..9979: 12 + ++++ Stats for small_string len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats len: + num: 5000, avg: 15.57, stddev: 24.36, median 6, min 0, max 99 + 0.. 4: #################################################### 1925 + 5.. 9: ####################################################### 2005 + 10.. 14: # 52 + 15.. 19: # 50 + 20.. 24: # 55 + 25.. 29: # 56 + 30.. 34: # 55 + 35.. 39: # 49 + 40.. 44: # 65 + 45.. 49: # 65 + 50.. 54: # 55 + 55.. 59: # 68 + 60.. 64: # 61 + 65.. 69: # 65 + 70.. 74: # 57 + 75.. 79: # 66 + 80.. 84: # 65 + 85.. 89: # 64 + 90.. 94: # 60 + 95.. 99: # 62 + +++ Stats for list len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: @@ -525,7 +636,7 @@ stats dist: -4611686018427387392..-4150517416584648577: 0 ================================================================================ 1 warning(s) -failure (12 tests failed, 1 tests errored, ran 40 tests) +failure (12 tests failed, 1 tests errored, ran 45 tests) random seed: 153870556 +++ Stats for int_dist_empty_bucket ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ From 8680e54b36069d256a3e52e7801c3248a8fd0cff Mon Sep 17 00:00:00 2001 From: Jan Midtgaard Date: Thu, 12 Aug 2021 16:09:47 +0200 Subject: [PATCH 41/49] add false string tests --- test/core/QCheck2_expect_test.ml | 22 ++++++++++++++++++++++ test/core/QCheck_expect_test.ml | 22 ++++++++++++++++++++++ test/core/qcheck2_output.txt.expected | 14 +++++++++++++- test/core/qcheck_output.txt.expected | 14 +++++++++++++- 4 files changed, 70 insertions(+), 2 deletions(-) diff --git a/test/core/QCheck2_expect_test.ml b/test/core/QCheck2_expect_test.ml index d27852d0..2bcbd102 100644 --- a/test/core/QCheck2_expect_test.ml +++ b/test/core/QCheck2_expect_test.ml @@ -58,6 +58,25 @@ module Generator = struct ~print:Print.char Gen.char (fun c -> c <> '\255') + let string_test = + Test.make ~name:"string has right length and content" ~count:1000 ~print:Print.string + Gen.string + (fun s -> + let len = String.length s in + 0 <= len && len < 10000 + && String.to_seq s |> + Seq.fold_left (fun acc c -> acc && '\000' <= c && c <= '\255') true) + + let string_never_has_000_char = + Test.make ~name:"string never has a \\000 char" ~count:1000 ~print:Print.string + Gen.string + (fun s -> String.to_seq s |> Seq.fold_left (fun acc c -> acc && c <> '\000') true) + + let string_never_has_255_char = + Test.make ~name:"string never has a \\255 char" ~count:1000 ~print:Print.string + Gen.string + (fun s -> String.to_seq s |> Seq.fold_left (fun acc c -> acc && c <> '\255') true) + let list_repeat_test = Test.make ~name:"list_repeat has constant length" ~count:1000 ~print:Print.(pair int (list unit)) @@ -264,6 +283,9 @@ let _ = Overall.bad_assume_warn; Overall.bad_assume_fail; Generator.char_dist_issue_23; + Generator.string_test; + Generator.string_never_has_000_char; + Generator.string_never_has_255_char; Generator.list_repeat_test; Generator.array_repeat_test; Function.fail_pred_map_commute; diff --git a/test/core/QCheck_expect_test.ml b/test/core/QCheck_expect_test.ml index a0855826..de7f68d6 100644 --- a/test/core/QCheck_expect_test.ml +++ b/test/core/QCheck_expect_test.ml @@ -56,6 +56,25 @@ module Generator = struct let char_dist_issue_23 = Test.make ~name:"char never produces '\\255'" ~count:1_000_000 char (fun c -> c <> '\255') + let string_test = + Test.make ~name:"string has right length and content" ~count:1000 + string + (fun s -> + let len = String.length s in + 0 <= len && len < 10000 + && String.to_seq s |> + Seq.fold_left (fun acc c -> acc && '\000' <= c && c <= '\255') true) + + let string_never_has_000_char = + Test.make ~name:"string never has a \\000 char" ~count:1000 + string + (fun s -> String.to_seq s |> Seq.fold_left (fun acc c -> acc && c <> '\000') true) + + let string_never_has_255_char = + Test.make ~name:"string never has a \\255 char" ~count:1000 + string + (fun s -> String.to_seq s |> Seq.fold_left (fun acc c -> acc && c <> '\255') true) + let list_repeat_test = let gen = Gen.(small_nat >>= fun i -> list_repeat i unit >>= fun l -> return (i,l)) in Test.make ~name:"list_repeat has constant length" ~count:1000 @@ -253,6 +272,9 @@ let i = Overall.bad_assume_warn; Overall.bad_assume_fail; Generator.char_dist_issue_23; + Generator.string_test; + Generator.string_never_has_000_char; + Generator.string_never_has_255_char; Generator.list_repeat_test; Generator.array_repeat_test; Function.fail_pred_map_commute; diff --git a/test/core/qcheck2_output.txt.expected b/test/core/qcheck2_output.txt.expected index b843092f..33cbc537 100644 --- a/test/core/qcheck2_output.txt.expected +++ b/test/core/qcheck2_output.txt.expected @@ -82,6 +82,18 @@ Test char never produces '\255' failed (0 shrink steps): --- Failure -------------------------------------------------------------------- +Test string never has a \000 char failed (22 shrink steps): + +"aaaaaa\000aaaaaaaaaaaaaaaa" + +--- Failure -------------------------------------------------------------------- + +Test string never has a \255 char failed (59 shrink steps): + +"aaaaaaaaaaaaaaaaaaaaaaaaaa\255aaaaaaaaaaaaaaaaaaaaaaaa" + +--- Failure -------------------------------------------------------------------- + Test fail_pred_map_commute failed (16 shrink steps): ([2], {_ -> 0}, {1 -> false; 2 -> true; _ -> false}) @@ -636,7 +648,7 @@ stats dist: -4611686018427387392..-4150517416584648577: 0 ================================================================================ 1 warning(s) -failure (12 tests failed, 1 tests errored, ran 45 tests) +failure (14 tests failed, 1 tests errored, ran 48 tests) random seed: 153870556 +++ Stats for int_dist_empty_bucket ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ diff --git a/test/core/qcheck_output.txt.expected b/test/core/qcheck_output.txt.expected index 5b054aaa..344536ce 100644 --- a/test/core/qcheck_output.txt.expected +++ b/test/core/qcheck_output.txt.expected @@ -82,6 +82,18 @@ Test char never produces '\255' failed (0 shrink steps): --- Failure -------------------------------------------------------------------- +Test string never has a \000 char failed (25 shrink steps): + +"\000" + +--- Failure -------------------------------------------------------------------- + +Test string never has a \255 char failed (249 shrink steps): + +"\255" + +--- Failure -------------------------------------------------------------------- + Test fail_pred_map_commute failed (127 shrink steps): ([3], {_ -> 0}, {3 -> false; _ -> true}) @@ -636,7 +648,7 @@ stats dist: -4611686018427387392..-4150517416584648577: 0 ================================================================================ 1 warning(s) -failure (12 tests failed, 1 tests errored, ran 45 tests) +failure (14 tests failed, 1 tests errored, ran 48 tests) random seed: 153870556 +++ Stats for int_dist_empty_bucket ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ From da024c962260e36bac313689b6637fbc186cb24e Mon Sep 17 00:00:00 2001 From: Jan Midtgaard Date: Fri, 13 Aug 2021 12:45:25 +0200 Subject: [PATCH 42/49] restructure tests into positive (Generator) / negative (Shrink) --- test/core/QCheck2_expect_test.ml | 100 +++++++++++++------------- test/core/QCheck_expect_test.ml | 98 ++++++++++++------------- test/core/qcheck2_output.txt.expected | 36 +++++----- test/core/qcheck_output.txt.expected | 36 +++++----- 4 files changed, 135 insertions(+), 135 deletions(-) diff --git a/test/core/QCheck2_expect_test.ml b/test/core/QCheck2_expect_test.ml index 2bcbd102..415290d6 100644 --- a/test/core/QCheck2_expect_test.ml +++ b/test/core/QCheck2_expect_test.ml @@ -48,7 +48,7 @@ module Overall = struct true) end -(* test various generators *) +(* positive tests of the various generators *) module Generator = struct open QCheck2 @@ -67,16 +67,6 @@ module Generator = struct && String.to_seq s |> Seq.fold_left (fun acc c -> acc && '\000' <= c && c <= '\255') true) - let string_never_has_000_char = - Test.make ~name:"string never has a \\000 char" ~count:1000 ~print:Print.string - Gen.string - (fun s -> String.to_seq s |> Seq.fold_left (fun acc c -> acc && c <> '\000') true) - - let string_never_has_255_char = - Test.make ~name:"string never has a \\255 char" ~count:1000 ~print:Print.string - Gen.string - (fun s -> String.to_seq s |> Seq.fold_left (fun acc c -> acc && c <> '\255') true) - let list_repeat_test = Test.make ~name:"list_repeat has constant length" ~count:1000 ~print:Print.(pair int (list unit)) @@ -90,6 +80,49 @@ module Generator = struct (fun (i,l) -> Array.length l = i) end +(* negative tests that exercise shrinking behaviour *) +module Shrink = struct + open QCheck2 + + let rec fac n = match n with + | 0 -> 1 + | n -> n * fac (n - 1) + + (* example from issue #59 *) + let test_fac_issue59 = + Test.make ~name:"test fac issue59" + (Gen.make_primitive ~gen:(fun st -> Gen.generate1 ~rand:st (Gen.small_int_corners ())) ~shrink:(fun _ -> Seq.empty)) + (fun n -> try (fac n) mod n = 0 + with + (*| Stack_overflow -> false*) + | Division_by_zero -> (n=0)) + + let big_bound_issue59 = + Test.make ~name:"big bound issue59" ~print:Print.int + (Gen.small_int_corners()) (fun i -> i < 209609) + + let long_shrink = + let listgen = Gen.(list_size (int_range 1000 10000) int) in + Test.make ~name:"long_shrink" ~print:Print.(pair (list int) (list int)) + (Gen.pair listgen listgen) + (fun (xs,ys) -> List.rev (xs@ys) = (List.rev xs)@(List.rev ys)) + + (* test shrinking on integers *) + let shrink_int = + Test.make ~name:"mod3_should_fail" ~count:1000 ~print:Print.int + Gen.int (fun i -> i mod 3 <> 0) + + let string_never_has_000_char = + Test.make ~name:"string never has a \\000 char" ~count:1000 ~print:Print.string + Gen.string + (fun s -> String.to_seq s |> Seq.fold_left (fun acc c -> acc && c <> '\000') true) + + let string_never_has_255_char = + Test.make ~name:"string never has a \\255 char" ~count:1000 ~print:Print.string + Gen.string + (fun s -> String.to_seq s |> Seq.fold_left (fun acc c -> acc && c <> '\255') true) +end + (* tests function generator and shrinker *) module Function = struct open QCheck2 @@ -154,39 +187,6 @@ module Function = struct List.fold_left (fun x y -> Fn.apply f (x,y)) z xs) end -(* tests of shrinking behaviour *) -module Shrink = struct - open QCheck2 - - let rec fac n = match n with - | 0 -> 1 - | n -> n * fac (n - 1) - - (* example from issue #59 *) - let test_fac_issue59 = - Test.make ~name:"test fac issue59" - (Gen.make_primitive ~gen:(fun st -> Gen.generate1 ~rand:st (Gen.small_int_corners ())) ~shrink:(fun _ -> Seq.empty)) - (fun n -> try (fac n) mod n = 0 - with - (*| Stack_overflow -> false*) - | Division_by_zero -> (n=0)) - - let big_bound_issue59 = - Test.make ~name:"big bound issue59" ~print:Print.int - (Gen.small_int_corners()) (fun i -> i < 209609) - - let long_shrink = - let listgen = Gen.(list_size (int_range 1000 10000) int) in - Test.make ~name:"long_shrink" ~print:Print.(pair (list int) (list int)) - (Gen.pair listgen listgen) - (fun (xs,ys) -> List.rev (xs@ys) = (List.rev xs)@(List.rev ys)) - - (* test shrinking on integers *) - let shrink_int = - Test.make ~name:"mod3_should_fail" ~count:1000 ~print:Print.int - Gen.int (fun i -> i mod 3 <> 0) -end - (* tests of (inner) find_example(_gen) behaviour *) module FindExample = struct open QCheck2 @@ -284,19 +284,19 @@ let _ = Overall.bad_assume_fail; Generator.char_dist_issue_23; Generator.string_test; - Generator.string_never_has_000_char; - Generator.string_never_has_255_char; Generator.list_repeat_test; Generator.array_repeat_test; + (*Shrink.test_fac_issue59;*) + Shrink.big_bound_issue59; + Shrink.long_shrink; + Shrink.shrink_int; + Shrink.string_never_has_000_char; + Shrink.string_never_has_255_char; Function.fail_pred_map_commute; Function.fail_pred_strings; Function.prop_foldleft_foldright; Function.prop_foldleft_foldright_uncurry; Function.prop_foldleft_foldright_uncurry_funlast; - (*Shrink.test_fac_issue59;*) - Shrink.big_bound_issue59; - Shrink.long_shrink; - Shrink.shrink_int; FindExample.find_ex; FindExample.find_ex_uncaught_issue_99_1_fail; FindExample.find_ex_uncaught_issue_99_2_succeed; diff --git a/test/core/QCheck_expect_test.ml b/test/core/QCheck_expect_test.ml index de7f68d6..5f204eac 100644 --- a/test/core/QCheck_expect_test.ml +++ b/test/core/QCheck_expect_test.ml @@ -48,7 +48,7 @@ module Overall = struct true) end -(* test various generators *) +(* positive tests of the various generators *) module Generator = struct open QCheck @@ -65,16 +65,6 @@ module Generator = struct && String.to_seq s |> Seq.fold_left (fun acc c -> acc && '\000' <= c && c <= '\255') true) - let string_never_has_000_char = - Test.make ~name:"string never has a \\000 char" ~count:1000 - string - (fun s -> String.to_seq s |> Seq.fold_left (fun acc c -> acc && c <> '\000') true) - - let string_never_has_255_char = - Test.make ~name:"string never has a \\255 char" ~count:1000 - string - (fun s -> String.to_seq s |> Seq.fold_left (fun acc c -> acc && c <> '\255') true) - let list_repeat_test = let gen = Gen.(small_nat >>= fun i -> list_repeat i unit >>= fun l -> return (i,l)) in Test.make ~name:"list_repeat has constant length" ~count:1000 @@ -86,6 +76,48 @@ module Generator = struct (make ~print:Print.(pair int (array unit)) gen) (fun (i,l) -> Array.length l = i) end +(* negative tests that exercise shrinking behaviour *) +module Shrink = struct + open QCheck + + let rec fac n = match n with + | 0 -> 1 + | n -> n * fac (n - 1) + + (* example from issue #59 *) + let test_fac_issue59 = + Test.make ~name:"test fac issue59" + (set_shrink Shrink.nil (small_int_corners ())) + (fun n -> try (fac n) mod n = 0 + with + (*| Stack_overflow -> false*) + | Division_by_zero -> (n=0)) + + let big_bound_issue59 = + Test.make ~name:"big bound issue59" + (small_int_corners()) (fun i -> i < 209609) + + let long_shrink = + let listgen = list_of_size (Gen.int_range 1000 10000) int in + Test.make ~name:"long_shrink" (pair listgen listgen) + (fun (xs,ys) -> List.rev (xs@ys) = (List.rev xs)@(List.rev ys)) + + (* test shrinking on integers *) + let shrink_int = + Test.make ~name:"mod3_should_fail" ~count:1000 + int (fun i -> i mod 3 <> 0) + + let string_never_has_000_char = + Test.make ~name:"string never has a \\000 char" ~count:1000 + string + (fun s -> String.to_seq s |> Seq.fold_left (fun acc c -> acc && c <> '\000') true) + + let string_never_has_255_char = + Test.make ~name:"string never has a \\255 char" ~count:1000 + string + (fun s -> String.to_seq s |> Seq.fold_left (fun acc c -> acc && c <> '\255') true) +end + (* tests function generator and shrinker *) module Function = struct open QCheck @@ -146,38 +178,6 @@ module Function = struct List.fold_left (fun x y -> Fn.apply f (x,y)) z xs) end -(* tests of shrinking behaviour *) -module Shrink = struct - open QCheck - - let rec fac n = match n with - | 0 -> 1 - | n -> n * fac (n - 1) - - (* example from issue #59 *) - let test_fac_issue59 = - Test.make ~name:"test fac issue59" - (set_shrink Shrink.nil (small_int_corners ())) - (fun n -> try (fac n) mod n = 0 - with - (*| Stack_overflow -> false*) - | Division_by_zero -> (n=0)) - - let big_bound_issue59 = - Test.make ~name:"big bound issue59" - (small_int_corners()) (fun i -> i < 209609) - - let long_shrink = - let listgen = list_of_size (Gen.int_range 1000 10000) int in - Test.make ~name:"long_shrink" (pair listgen listgen) - (fun (xs,ys) -> List.rev (xs@ys) = (List.rev xs)@(List.rev ys)) - - (* test shrinking on integers *) - let shrink_int = - Test.make ~name:"mod3_should_fail" ~count:1000 - int (fun i -> i mod 3 <> 0) -end - (* tests of (inner) find_example(_gen) behaviour *) module FindExample = struct open QCheck @@ -273,19 +273,19 @@ let i = Overall.bad_assume_fail; Generator.char_dist_issue_23; Generator.string_test; - Generator.string_never_has_000_char; - Generator.string_never_has_255_char; Generator.list_repeat_test; Generator.array_repeat_test; + (*Shrink.test_fac_issue59;*) + Shrink.big_bound_issue59; + Shrink.long_shrink; + Shrink.shrink_int; + Shrink.string_never_has_000_char; + Shrink.string_never_has_255_char; Function.fail_pred_map_commute; Function.fail_pred_strings; Function.prop_foldleft_foldright; Function.prop_foldleft_foldright_uncurry; Function.prop_foldleft_foldright_uncurry_funlast; - (*Shrink.test_fac_issue59;*) - Shrink.big_bound_issue59; - Shrink.long_shrink; - Shrink.shrink_int; FindExample.find_ex; FindExample.find_ex_uncaught_issue_99_1_fail; FindExample.find_ex_uncaught_issue_99_2_succeed; diff --git a/test/core/qcheck2_output.txt.expected b/test/core/qcheck2_output.txt.expected index 33cbc537..c0a2422d 100644 --- a/test/core/qcheck2_output.txt.expected +++ b/test/core/qcheck2_output.txt.expected @@ -82,6 +82,24 @@ Test char never produces '\255' failed (0 shrink steps): --- Failure -------------------------------------------------------------------- +Test big bound issue59 failed (0 shrink steps): + +4611686018427387903 + +--- Failure -------------------------------------------------------------------- + +Test long_shrink failed (3040 shrink steps): + +([0; 0; 0; 0;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; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 1]) + +--- Failure -------------------------------------------------------------------- + +Test mod3_should_fail failed (1 shrink steps): + +0 + +--- Failure -------------------------------------------------------------------- + Test string never has a \000 char failed (22 shrink steps): "aaaaaa\000aaaaaaaaaaaaaaaa" @@ -131,24 +149,6 @@ Test fold_left fold_right uncurried fun last failed (25 shrink steps): --- Failure -------------------------------------------------------------------- -Test big bound issue59 failed (0 shrink steps): - -4611686018427387903 - ---- Failure -------------------------------------------------------------------- - -Test long_shrink failed (3040 shrink steps): - -([0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 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- ---- Failure -------------------------------------------------------------------- - Test FAIL_#99_1 failed: ERROR: uncaught exception in generator for test FAIL_#99_1 after 100 steps: diff --git a/test/core/qcheck_output.txt.expected b/test/core/qcheck_output.txt.expected index 344536ce..a427e47b 100644 --- a/test/core/qcheck_output.txt.expected +++ b/test/core/qcheck_output.txt.expected @@ -82,6 +82,24 @@ Test char never produces '\255' failed (0 shrink steps): --- Failure -------------------------------------------------------------------- +Test big bound issue59 failed (52 shrink steps): + +209609 + +--- Failure -------------------------------------------------------------------- + +Test long_shrink failed (149 shrink steps): + +([0], [-1]) + +--- Failure -------------------------------------------------------------------- + +Test mod3_should_fail failed (84 shrink steps): + +-21 + +--- Failure -------------------------------------------------------------------- + Test string never has a \000 char failed (25 shrink steps): "\000" @@ -131,24 +149,6 @@ Test fold_left fold_right uncurried fun last failed (26 shrink steps): --- Failure -------------------------------------------------------------------- -Test big bound issue59 failed (52 shrink steps): - -209609 - ---- Failure -------------------------------------------------------------------- - -Test long_shrink failed (149 shrink steps): - -([0], [-1]) - ---- Failure -------------------------------------------------------------------- - -Test mod3_should_fail failed (84 shrink steps): - --21 - ---- Failure -------------------------------------------------------------------- - Test FAIL_#99_1 failed: ERROR: uncaught exception in generator for test FAIL_#99_1 after 100 steps: From 25dc5333aabd49385128e570705f7375cf0933e0 Mon Sep 17 00:00:00 2001 From: Jan Midtgaard Date: Fri, 13 Aug 2021 13:25:29 +0200 Subject: [PATCH 43/49] add pos and neg char tests --- test/core/QCheck2_expect_test.ml | 11 ++++++++++- test/core/QCheck_expect_test.ml | 13 +++++++++++-- test/core/qcheck2_output.txt.expected | 8 +++++++- test/core/qcheck_output.txt.expected | 8 +++++++- 4 files changed, 35 insertions(+), 5 deletions(-) diff --git a/test/core/QCheck2_expect_test.ml b/test/core/QCheck2_expect_test.ml index 415290d6..e42825cd 100644 --- a/test/core/QCheck2_expect_test.ml +++ b/test/core/QCheck2_expect_test.ml @@ -58,6 +58,10 @@ module Generator = struct ~print:Print.char Gen.char (fun c -> c <> '\255') + let char_test = + Test.make ~name:"char has right range'" ~count:1000 ~print:Print.char + Gen.char (fun c -> '\000' <= c && c <= '\255') + let string_test = Test.make ~name:"string has right length and content" ~count:1000 ~print:Print.string Gen.string @@ -107,11 +111,14 @@ module Shrink = struct (Gen.pair listgen listgen) (fun (xs,ys) -> List.rev (xs@ys) = (List.rev xs)@(List.rev ys)) - (* test shrinking on integers *) let shrink_int = Test.make ~name:"mod3_should_fail" ~count:1000 ~print:Print.int Gen.int (fun i -> i mod 3 <> 0) + let char_is_never_abcdef = + Test.make ~name:"char is never produces 'abcdef'" ~count:1000 ~print:Print.char + Gen.char (fun c -> not (List.mem c ['a';'b';'c';'d';'e';'f'])) + let string_never_has_000_char = Test.make ~name:"string never has a \\000 char" ~count:1000 ~print:Print.string Gen.string @@ -283,6 +290,7 @@ let _ = Overall.bad_assume_warn; Overall.bad_assume_fail; Generator.char_dist_issue_23; + Generator.char_test; Generator.string_test; Generator.list_repeat_test; Generator.array_repeat_test; @@ -290,6 +298,7 @@ let _ = Shrink.big_bound_issue59; Shrink.long_shrink; Shrink.shrink_int; + Shrink.char_is_never_abcdef; Shrink.string_never_has_000_char; Shrink.string_never_has_255_char; Function.fail_pred_map_commute; diff --git a/test/core/QCheck_expect_test.ml b/test/core/QCheck_expect_test.ml index 5f204eac..c164759b 100644 --- a/test/core/QCheck_expect_test.ml +++ b/test/core/QCheck_expect_test.ml @@ -56,6 +56,10 @@ module Generator = struct let char_dist_issue_23 = Test.make ~name:"char never produces '\\255'" ~count:1_000_000 char (fun c -> c <> '\255') + let char_test = + Test.make ~name:"char has right range'" ~count:1000 + char (fun c -> '\000' <= c && c <= '\255') + let string_test = Test.make ~name:"string has right length and content" ~count:1000 string @@ -102,11 +106,14 @@ module Shrink = struct Test.make ~name:"long_shrink" (pair listgen listgen) (fun (xs,ys) -> List.rev (xs@ys) = (List.rev xs)@(List.rev ys)) - (* test shrinking on integers *) let shrink_int = Test.make ~name:"mod3_should_fail" ~count:1000 int (fun i -> i mod 3 <> 0) + let char_is_never_abcdef = + Test.make ~name:"char is never produces 'abcdef'" ~count:1000 + char (fun c -> not (List.mem c ['a';'b';'c';'d';'e';'f'])) + let string_never_has_000_char = Test.make ~name:"string never has a \\000 char" ~count:1000 string @@ -262,7 +269,7 @@ end (* Calling runners *) let () = QCheck_base_runner.set_seed 1234 -let i = +let _ = QCheck_base_runner.run_tests ~colors:false ([ Overall.passing; Overall.failing; @@ -272,6 +279,7 @@ let i = Overall.bad_assume_warn; Overall.bad_assume_fail; Generator.char_dist_issue_23; + Generator.char_test; Generator.string_test; Generator.list_repeat_test; Generator.array_repeat_test; @@ -279,6 +287,7 @@ let i = Shrink.big_bound_issue59; Shrink.long_shrink; Shrink.shrink_int; + Shrink.char_is_never_abcdef; Shrink.string_never_has_000_char; Shrink.string_never_has_255_char; Function.fail_pred_map_commute; diff --git a/test/core/qcheck2_output.txt.expected b/test/core/qcheck2_output.txt.expected index c0a2422d..e07e1ef9 100644 --- a/test/core/qcheck2_output.txt.expected +++ b/test/core/qcheck2_output.txt.expected @@ -100,6 +100,12 @@ Test mod3_should_fail failed (1 shrink steps): --- Failure -------------------------------------------------------------------- +Test char is never produces 'abcdef' failed (1 shrink steps): + +'a' + +--- Failure -------------------------------------------------------------------- + Test string never has a \000 char failed (22 shrink steps): "aaaaaa\000aaaaaaaaaaaaaaaa" @@ -648,7 +654,7 @@ stats dist: -4611686018427387392..-4150517416584648577: 0 ================================================================================ 1 warning(s) -failure (14 tests failed, 1 tests errored, ran 48 tests) +failure (15 tests failed, 1 tests errored, ran 50 tests) random seed: 153870556 +++ Stats for int_dist_empty_bucket ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ diff --git a/test/core/qcheck_output.txt.expected b/test/core/qcheck_output.txt.expected index a427e47b..4d0158fa 100644 --- a/test/core/qcheck_output.txt.expected +++ b/test/core/qcheck_output.txt.expected @@ -100,6 +100,12 @@ Test mod3_should_fail failed (84 shrink steps): --- Failure -------------------------------------------------------------------- +Test char is never produces 'abcdef' failed (0 shrink steps): + +'d' + +--- Failure -------------------------------------------------------------------- + Test string never has a \000 char failed (25 shrink steps): "\000" @@ -648,7 +654,7 @@ stats dist: -4611686018427387392..-4150517416584648577: 0 ================================================================================ 1 warning(s) -failure (14 tests failed, 1 tests errored, ran 48 tests) +failure (15 tests failed, 1 tests errored, ran 50 tests) random seed: 153870556 +++ Stats for int_dist_empty_bucket ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ From 06f1504cb429e85163209fc624fcf3cef7e66a53 Mon Sep 17 00:00:00 2001 From: Jan Midtgaard Date: Fri, 13 Aug 2021 17:39:19 +0200 Subject: [PATCH 44/49] add list tests (and a fun test) from issue #64 --- test/core/QCheck2_expect_test.ml | 57 +++++++++++++++++++++++++ test/core/QCheck_expect_test.ml | 56 ++++++++++++++++++++++++ test/core/qcheck2_output.txt.expected | 61 ++++++++++++++++++++++++++- test/core/qcheck_output.txt.expected | 55 +++++++++++++++++++++++- 4 files changed, 227 insertions(+), 2 deletions(-) diff --git a/test/core/QCheck2_expect_test.ml b/test/core/QCheck2_expect_test.ml index e42825cd..f04a7f03 100644 --- a/test/core/QCheck2_expect_test.ml +++ b/test/core/QCheck2_expect_test.ml @@ -71,6 +71,11 @@ module Generator = struct && String.to_seq s |> Seq.fold_left (fun acc c -> acc && '\000' <= c && c <= '\255') true) + let list_test = + Test.make ~name:"list has right length" ~count:1000 + ~print:Print.(list unit) + Gen.(list unit) (fun l -> let len = List.length l in 0 <= len && len < 10_000) + let list_repeat_test = Test.make ~name:"list_repeat has constant length" ~count:1000 ~print:Print.(pair int (list unit)) @@ -128,6 +133,38 @@ module Shrink = struct Test.make ~name:"string never has a \\255 char" ~count:1000 ~print:Print.string Gen.string (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 = []) + + let list_shorter_10 = + Test.make ~name:"lists shorter than 10" ~print:Print.(list int) + Gen.(list small_int) (fun xs -> (*print_list xs;*) List.length xs < 10) + + let length_printer xs = + Printf.sprintf "[...] list length: %i" (List.length xs) + + let size_gen = Gen.(oneof [small_nat; int_bound 750_000]) + + let list_shorter_432 = + Test.make ~name:"lists shorter than 432" ~print:length_printer + Gen.(list_size size_gen small_int) (*Gen.(list small_int)*) + (fun xs -> (*print_list xs;*) List.length xs < 432) + + let list_shorter_4332 = + Test.make ~name:"lists shorter than 4332" ~print:length_printer + Gen.(list_size size_gen small_int) (*Gen.(list small_int)*) + (fun xs -> (*print_list xs;*) List.length xs < 4332) + + let list_equal_dupl = + Test.make ~name:"lists equal to duplication" ~print:length_printer + Gen.(list_size size_gen small_int) (*Gen.(list small_int)*) + (fun xs -> try xs = xs @ xs + with Stack_overflow -> false) end (* tests function generator and shrinker *) @@ -192,6 +229,19 @@ module Function = struct (fun (z,xs,f) -> List.fold_right (fun x y -> Fn.apply f (x,y)) xs z = List.fold_left (fun x y -> Fn.apply f (x,y)) z xs) + + (* test from issue #64 *) + let fold_left_test = + Test.make ~name:"fold_left test, fun first" ~print:Print.(quad Fn.print string (list int) (list int)) + Gen.(quad (* string -> int -> string *) + (fun2 ~print:Print.string Observable.string Observable.int (small_string ~gen:char)) + (small_string ~gen:char) + (list small_int) + (list small_int)) + (fun (f,acc,is,js) -> + let f = Fn.apply f in + List.fold_left f acc (is @ js) + = List.fold_left f (List.fold_left f acc is) is) (*Typo*) end (* tests of (inner) find_example(_gen) behaviour *) @@ -292,6 +342,7 @@ let _ = Generator.char_dist_issue_23; Generator.char_test; Generator.string_test; + Generator.list_test; Generator.list_repeat_test; Generator.array_repeat_test; (*Shrink.test_fac_issue59;*) @@ -301,11 +352,17 @@ let _ = Shrink.char_is_never_abcdef; Shrink.string_never_has_000_char; Shrink.string_never_has_255_char; + Shrink.lists_are_empty_issue_64; + Shrink.list_shorter_10; + Shrink.list_shorter_432; + Shrink.list_shorter_4332; + Shrink.list_equal_dupl; Function.fail_pred_map_commute; Function.fail_pred_strings; Function.prop_foldleft_foldright; Function.prop_foldleft_foldright_uncurry; Function.prop_foldleft_foldright_uncurry_funlast; + Function.fold_left_test; FindExample.find_ex; FindExample.find_ex_uncaught_issue_99_1_fail; FindExample.find_ex_uncaught_issue_99_2_succeed; diff --git a/test/core/QCheck_expect_test.ml b/test/core/QCheck_expect_test.ml index c164759b..be19c004 100644 --- a/test/core/QCheck_expect_test.ml +++ b/test/core/QCheck_expect_test.ml @@ -69,6 +69,10 @@ module Generator = struct && String.to_seq s |> Seq.fold_left (fun acc c -> acc && '\000' <= c && c <= '\255') true) + let list_test = + Test.make ~name:"list has right length" ~count:1000 + (list unit) (fun l -> let len = List.length l in 0 <= len && len < 10_000) + let list_repeat_test = let gen = Gen.(small_nat >>= fun i -> list_repeat i unit >>= fun l -> return (i,l)) in Test.make ~name:"list_repeat has constant length" ~count:1000 @@ -123,6 +127,38 @@ module Shrink = struct Test.make ~name:"string never has a \\255 char" ~count:1000 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 = []) + + let list_shorter_10 = + Test.make ~name:"lists shorter than 10" + (list small_int) (fun xs -> (*print_list xs;*) List.length xs < 10) + + let length_printer xs = + Printf.sprintf "[...] list length: %i" (List.length xs) + + let size_gen = Gen.(oneof [small_nat; int_bound 750_000]) + + let list_shorter_432 = + Test.make ~name:"lists shorter than 432" + (set_print length_printer (list_of_size size_gen small_int)) (*(list small_int)*) + (fun xs -> (*print_list xs;*) List.length xs < 432) + + let list_shorter_4332 = + Test.make ~name:"lists shorter than 4332" + (set_shrink Shrink.list_spine (set_print length_printer (list_of_size size_gen small_int))) + (fun xs -> (*print_list xs;*) List.length xs < 4332) + + let list_equal_dupl = + Test.make ~name:"lists equal to duplication" + (set_print length_printer (list_of_size size_gen small_int)) + (*(set_print length_printer (list small_int))*) + (fun xs -> try xs = xs @ xs + with Stack_overflow -> false) end (* tests function generator and shrinker *) @@ -183,6 +219,19 @@ module Function = struct (fun (z,xs,f) -> List.fold_right (fun x y -> Fn.apply f (x,y)) xs z = List.fold_left (fun x y -> Fn.apply f (x,y)) z xs) + + (* test from issue #64 *) + let fold_left_test = + Test.make ~name:"false fold, fun first" + (quad (* string -> int -> string *) + (fun2 Observable.string Observable.int small_string) + small_string + (list small_int) + (list small_int)) + (fun (f,acc,is,js) -> + let f = Fn.apply f in + List.fold_left f acc (is @ js) + = List.fold_left f (List.fold_left f acc is) is) (*Typo*) end (* tests of (inner) find_example(_gen) behaviour *) @@ -281,6 +330,7 @@ let _ = Generator.char_dist_issue_23; Generator.char_test; Generator.string_test; + Generator.list_test; Generator.list_repeat_test; Generator.array_repeat_test; (*Shrink.test_fac_issue59;*) @@ -290,11 +340,17 @@ let _ = Shrink.char_is_never_abcdef; Shrink.string_never_has_000_char; Shrink.string_never_has_255_char; + Shrink.lists_are_empty_issue_64; + Shrink.list_shorter_10; + Shrink.list_shorter_432; + Shrink.list_shorter_4332; + Shrink.list_equal_dupl; Function.fail_pred_map_commute; Function.fail_pred_strings; Function.prop_foldleft_foldright; Function.prop_foldleft_foldright_uncurry; Function.prop_foldleft_foldright_uncurry_funlast; + Function.fold_left_test; FindExample.find_ex; FindExample.find_ex_uncaught_issue_99_1_fail; FindExample.find_ex_uncaught_issue_99_2_succeed; diff --git a/test/core/qcheck2_output.txt.expected b/test/core/qcheck2_output.txt.expected index e07e1ef9..32c01bf6 100644 --- a/test/core/qcheck2_output.txt.expected +++ b/test/core/qcheck2_output.txt.expected @@ -1,4 +1,21 @@ random seed: 1234 +[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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; 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] +[] +[0] --- Failure -------------------------------------------------------------------- @@ -118,6 +135,42 @@ Test string never has a \255 char failed (59 shrink steps): --- Failure -------------------------------------------------------------------- +Test lists are empty failed (8 shrink steps): + +[0] + +--- Failure -------------------------------------------------------------------- + +Test lists shorter than 10 failed (16 shrink steps): + +[0; 0; 0; 0; 0; 0; 0; 0; 0; 0] + +--- Failure -------------------------------------------------------------------- + +Test lists shorter than 432 failed: + +ERROR: uncaught exception in generator for test lists shorter than 432 after 100 steps: +Exception: Stack overflow +Backtrace: + +--- Failure -------------------------------------------------------------------- + +Test lists shorter than 4332 failed: + +ERROR: uncaught exception in generator for test lists shorter than 4332 after 100 steps: +Exception: Stack overflow +Backtrace: + +--- Failure -------------------------------------------------------------------- + +Test lists equal to duplication failed: + +ERROR: uncaught exception in generator for test lists equal to duplication after 100 steps: +Exception: Stack overflow +Backtrace: + +--- Failure -------------------------------------------------------------------- + Test fail_pred_map_commute failed (16 shrink steps): ([2], {_ -> 0}, {1 -> false; 2 -> true; _ -> false}) @@ -155,6 +208,12 @@ Test fold_left fold_right uncurried fun last failed (25 shrink steps): --- Failure -------------------------------------------------------------------- +Test fold_left test, fun first failed (15 shrink steps): + +({_ -> ""}, "a", [], [0]) + +--- Failure -------------------------------------------------------------------- + Test FAIL_#99_1 failed: ERROR: uncaught exception in generator for test FAIL_#99_1 after 100 steps: @@ -654,7 +713,7 @@ stats dist: -4611686018427387392..-4150517416584648577: 0 ================================================================================ 1 warning(s) -failure (15 tests failed, 1 tests errored, ran 50 tests) +failure (21 tests failed, 1 tests errored, ran 57 tests) random seed: 153870556 +++ Stats for int_dist_empty_bucket ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ diff --git a/test/core/qcheck_output.txt.expected b/test/core/qcheck_output.txt.expected index 4d0158fa..54715747 100644 --- a/test/core/qcheck_output.txt.expected +++ b/test/core/qcheck_output.txt.expected @@ -1,4 +1,21 @@ random seed: 1234 +[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; 5; 9; 3; 3; 1; 79; 4; 3; 2; 67; 5; 7; 12; 70; 8; 8; 6; 1; 3; 14; 15; 1; 61; 4; 1; 4; 1; 7; 4; 4; 4; 2; 8; 8; 7; 5; 4; 27; 0; 9; 80; 25; 1; 8; 1; 3; 7; 4; 3; 5; 5; 6; 5; 5; 31; 7; 0; 3; 3; 6; 71; 76; 28; 60; 6; 2; 6; 3; 0; 4; 1; 0; 5; 7; 0; 28; 86; 4; 7; 51; 36; 0; 5; 0; 1; 4; 3; 6; 0; 1; 1; 8; 18; 4; 2; 8; 8; 1; 4; 7; 1; 0; 93; 5; 3; 0; 80; 1; 7; 7; 8; 8; 5; 7; 8; 9; 24; 4; 25; 8; 8; 5; 4; 90; 4; 6; 8; 4; 4; 0; 60; 8; 9; 7; 44; 5; 1; 2; 9; 74; 7; 7] +[1; 3; 14; 15; 1; 61; 4; 1; 4; 1; 7; 4; 4; 4; 2; 8; 8; 7; 5; 4; 27; 0; 9; 80; 25; 1; 8; 1; 3; 7; 4; 3; 5; 5; 6; 5; 5; 31; 7; 0; 3; 3; 6; 71; 76; 28; 60; 6; 2; 6; 3; 0; 4; 1; 0; 5; 7; 0; 28; 86; 4; 7; 51; 36; 0; 5; 0; 1; 4; 3; 6; 0; 1; 1; 8; 18; 4; 2; 8; 8; 1; 4; 7; 1; 0; 93; 5; 3; 0; 80; 1; 7; 7; 8; 8; 5; 7; 8; 9; 24; 4; 25; 8; 8; 5; 4; 90; 4; 6; 8; 4; 4; 0; 60; 8; 9; 7; 44; 5; 1; 2; 9; 74; 7; 7] +[36; 0; 5; 0; 1; 4; 3; 6; 0; 1; 1; 8; 18; 4; 2; 8; 8; 1; 4; 7; 1; 0; 93; 5; 3; 0; 80; 1; 7; 7; 8; 8; 5; 7; 8; 9; 24; 4; 25; 8; 8; 5; 4; 90; 4; 6; 8; 4; 4; 0; 60; 8; 9; 7; 44; 5; 1; 2; 9; 74; 7; 7] +[8; 5; 7; 8; 9; 24; 4; 25; 8; 8; 5; 4; 90; 4; 6; 8; 4; 4; 0; 60; 8; 9; 7; 44; 5; 1; 2; 9; 74; 7; 7] +[4; 4; 0; 60; 8; 9; 7; 44; 5; 1; 2; 9; 74; 7; 7] +[5; 1; 2; 9; 74; 7; 7] +[74; 7; 7] +[7] +[] +[4] +[] +[2] +[] +[1] +[] +[0] +[] --- Failure -------------------------------------------------------------------- @@ -118,6 +135,36 @@ Test string never has a \255 char failed (249 shrink steps): --- Failure -------------------------------------------------------------------- +Test lists are empty failed (11 shrink steps): + +[0] + +--- Failure -------------------------------------------------------------------- + +Test lists shorter than 10 failed (50 shrink steps): + +[0; 0; 0; 0; 0; 0; 0; 0; 0; 0] + +--- Failure -------------------------------------------------------------------- + +Test lists shorter than 432 failed (1696 shrink steps): + +[...] list length: 432 + +--- Failure -------------------------------------------------------------------- + +Test lists shorter than 4332 failed (13 shrink steps): + +[...] list length: 4332 + +--- Failure -------------------------------------------------------------------- + +Test lists equal to duplication failed (20 shrink steps): + +[...] list length: 1 + +--- Failure -------------------------------------------------------------------- + Test fail_pred_map_commute failed (127 shrink steps): ([3], {_ -> 0}, {3 -> false; _ -> true}) @@ -155,6 +202,12 @@ Test fold_left fold_right uncurried fun last failed (26 shrink steps): --- Failure -------------------------------------------------------------------- +Test false fold, fun first failed (40 shrink steps): + +({_ -> ""}, "z", [], [0]) + +--- Failure -------------------------------------------------------------------- + Test FAIL_#99_1 failed: ERROR: uncaught exception in generator for test FAIL_#99_1 after 100 steps: @@ -654,7 +707,7 @@ stats dist: -4611686018427387392..-4150517416584648577: 0 ================================================================================ 1 warning(s) -failure (15 tests failed, 1 tests errored, ran 50 tests) +failure (21 tests failed, 1 tests errored, ran 57 tests) random seed: 153870556 +++ Stats for int_dist_empty_bucket ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ From 03f47912a654dd8b432d54b25a99d72eda7afb78 Mon Sep 17 00:00:00 2001 From: Jan Midtgaard Date: Fri, 13 Aug 2021 19:16:56 +0200 Subject: [PATCH 45/49] add more int shrinker tests (with a comparable trace) --- test/core/QCheck2_expect_test.ml | 17 +++- test/core/QCheck_expect_test.ml | 17 +++- test/core/qcheck2_output.txt.expected | 138 +++++++++++++++++++++++++- test/core/qcheck_output.txt.expected | 80 ++++++++++++++- 4 files changed, 242 insertions(+), 10 deletions(-) diff --git a/test/core/QCheck2_expect_test.ml b/test/core/QCheck2_expect_test.ml index f04a7f03..080b0659 100644 --- a/test/core/QCheck2_expect_test.ml +++ b/test/core/QCheck2_expect_test.ml @@ -116,10 +116,19 @@ module Shrink = struct (Gen.pair listgen listgen) (fun (xs,ys) -> List.rev (xs@ys) = (List.rev xs)@(List.rev ys)) - let shrink_int = - Test.make ~name:"mod3_should_fail" ~count:1000 ~print:Print.int + let ints_arent_0_mod_3 = + Test.make ~name:"ints arent 0 mod 3" ~count:1000 ~print:Print.int Gen.int (fun i -> i mod 3 <> 0) + 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) + + (* test from issue #59 *) + let ints_smaller_209609 = + Test.make ~name:"ints < 209609" ~print:Print.int + (Gen.small_int_corners()) (fun i -> i < 209609) + let char_is_never_abcdef = Test.make ~name:"char is never produces 'abcdef'" ~count:1000 ~print:Print.char Gen.char (fun c -> not (List.mem c ['a';'b';'c';'d';'e';'f'])) @@ -348,7 +357,9 @@ let _ = (*Shrink.test_fac_issue59;*) Shrink.big_bound_issue59; Shrink.long_shrink; - Shrink.shrink_int; + Shrink.ints_arent_0_mod_3; + Shrink.ints_are_0; + Shrink.ints_smaller_209609; Shrink.char_is_never_abcdef; Shrink.string_never_has_000_char; Shrink.string_never_has_255_char; diff --git a/test/core/QCheck_expect_test.ml b/test/core/QCheck_expect_test.ml index be19c004..29f1b926 100644 --- a/test/core/QCheck_expect_test.ml +++ b/test/core/QCheck_expect_test.ml @@ -110,10 +110,19 @@ module Shrink = struct Test.make ~name:"long_shrink" (pair listgen listgen) (fun (xs,ys) -> List.rev (xs@ys) = (List.rev xs)@(List.rev ys)) - let shrink_int = - Test.make ~name:"mod3_should_fail" ~count:1000 + let ints_arent_0_mod_3 = + Test.make ~name:"ints arent 0 mod 3" ~count:1000 int (fun i -> i mod 3 <> 0) + let ints_are_0 = + Test.make ~name:"ints are 0" ~count:1000 + int (fun i -> Printf.printf "%i\n" i; i = 0) + + (* test from issue #59 *) + let ints_smaller_209609 = + Test.make ~name:"ints < 209609" + (small_int_corners()) (fun i -> i < 209609) + let char_is_never_abcdef = Test.make ~name:"char is never produces 'abcdef'" ~count:1000 char (fun c -> not (List.mem c ['a';'b';'c';'d';'e';'f'])) @@ -336,7 +345,9 @@ let _ = (*Shrink.test_fac_issue59;*) Shrink.big_bound_issue59; Shrink.long_shrink; - Shrink.shrink_int; + Shrink.ints_arent_0_mod_3; + Shrink.ints_are_0; + Shrink.ints_smaller_209609; Shrink.char_is_never_abcdef; Shrink.string_never_has_000_char; Shrink.string_never_has_255_char; diff --git a/test/core/qcheck2_output.txt.expected b/test/core/qcheck2_output.txt.expected index 32c01bf6..e38efaa4 100644 --- a/test/core/qcheck2_output.txt.expected +++ b/test/core/qcheck2_output.txt.expected @@ -1,4 +1,126 @@ random seed: 1234 +1571754099758104554 +0 +785877049879052277 +0 +392938524939526138 +0 +196469262469763069 +0 +98234631234881534 +0 +49117315617440767 +0 +24558657808720383 +0 +12279328904360191 +0 +6139664452180095 +0 +3069832226090047 +0 +1534916113045023 +0 +767458056522511 +0 +383729028261255 +0 +191864514130627 +0 +95932257065313 +0 +47966128532656 +0 +23983064266328 +0 +11991532133164 +0 +5995766066582 +0 +2997883033291 +0 +1498941516645 +0 +749470758322 +0 +374735379161 +0 +187367689580 +0 +93683844790 +0 +46841922395 +0 +23420961197 +0 +11710480598 +0 +5855240299 +0 +2927620149 +0 +1463810074 +0 +731905037 +0 +365952518 +0 +182976259 +0 +91488129 +0 +45744064 +0 +22872032 +0 +11436016 +0 +5718008 +0 +2859004 +0 +1429502 +0 +714751 +0 +357375 +0 +178687 +0 +89343 +0 +44671 +0 +22335 +0 +11167 +0 +5583 +0 +2791 +0 +1395 +0 +697 +0 +348 +0 +174 +0 +87 +0 +43 +0 +21 +0 +10 +0 +5 +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; 5; 9; 3; 3; 1; 79; 4; 3; 2; 67; 5; 7; 12; 70; 8; 8; 6; 1; 3; 14; 15; 1; 61; 4; 1; 4; 1; 7; 4; 4; 4; 2; 8; 8; 7; 5; 4; 27; 0; 9; 80; 25; 1; 8; 1; 3; 7; 4; 3; 5; 5; 6; 5; 5; 31; 7; 0; 3; 3; 6; 71; 76; 28; 60; 6; 2; 6; 3; 0; 4; 1; 0; 5; 7; 0; 28; 86; 4; 7; 51; 36; 0; 5; 0; 1; 4; 3; 6; 0; 1; 1; 8; 18; 4; 2; 8; 8; 1; 4; 7; 1; 0; 93; 5; 3; 0; 80; 1; 7; 7; 8; 8; 5; 7; 8; 9; 24; 4; 25; 8; 8; 5; 4; 90; 4; 6; 8; 4; 4; 0; 60; 8; 9; 7; 44; 5; 1; 2; 9; 74; 7; 7] [] [9; 61; 8; 4; 69; 2; 0; 72; 4; 41; 3; 8; 75; 83; 7; 7; 3; 9; 5; 8; 4; 1; 0; 2; 1; 4; 7; 6; 2; 1; 4; 86; 3; 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] @@ -111,12 +233,24 @@ Test long_shrink failed (3040 shrink steps): --- Failure -------------------------------------------------------------------- -Test mod3_should_fail failed (1 shrink steps): +Test ints arent 0 mod 3 failed (1 shrink steps): 0 --- Failure -------------------------------------------------------------------- +Test ints are 0 failed (60 shrink steps): + +1 + +--- Failure -------------------------------------------------------------------- + +Test ints < 209609 failed (0 shrink steps): + +4611686018427387903 + +--- Failure -------------------------------------------------------------------- + Test char is never produces 'abcdef' failed (1 shrink steps): 'a' @@ -713,7 +847,7 @@ stats dist: -4611686018427387392..-4150517416584648577: 0 ================================================================================ 1 warning(s) -failure (21 tests failed, 1 tests errored, ran 57 tests) +failure (23 tests failed, 1 tests errored, ran 59 tests) random seed: 153870556 +++ Stats for int_dist_empty_bucket ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ diff --git a/test/core/qcheck_output.txt.expected b/test/core/qcheck_output.txt.expected index 54715747..f915746e 100644 --- a/test/core/qcheck_output.txt.expected +++ b/test/core/qcheck_output.txt.expected @@ -1,4 +1,68 @@ 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 +152 +76 +38 +19 +10 +5 +3 +2 +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;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5; 1; 2; 9; 74; 7; 7] @@ -111,12 +175,24 @@ Test long_shrink failed (149 shrink steps): --- Failure -------------------------------------------------------------------- -Test mod3_should_fail failed (84 shrink steps): +Test ints arent 0 mod 3 failed (84 shrink steps): -21 --- Failure -------------------------------------------------------------------- +Test ints are 0 failed (62 shrink steps): + +1 + +--- Failure -------------------------------------------------------------------- + +Test ints < 209609 failed (52 shrink steps): + +209609 + +--- Failure -------------------------------------------------------------------- + Test char is never produces 'abcdef' failed (0 shrink steps): 'd' @@ -707,7 +783,7 @@ stats dist: -4611686018427387392..-4150517416584648577: 0 ================================================================================ 1 warning(s) -failure (21 tests failed, 1 tests errored, ran 57 tests) +failure (23 tests failed, 1 tests errored, ran 59 tests) random seed: 153870556 +++ Stats for int_dist_empty_bucket ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ From 6acdeb52e934b3bf8e5acead95994d9bcf929a2e Mon Sep 17 00:00:00 2001 From: Jan Midtgaard Date: Mon, 16 Aug 2021 13:22:34 +0200 Subject: [PATCH 46/49] add string empty test --- test/core/QCheck2_expect_test.ml | 5 +++++ test/core/QCheck_expect_test.ml | 5 +++++ test/core/qcheck2_output.txt.expected | 8 +++++++- test/core/qcheck_output.txt.expected | 8 +++++++- 4 files changed, 24 insertions(+), 2 deletions(-) diff --git a/test/core/QCheck2_expect_test.ml b/test/core/QCheck2_expect_test.ml index 080b0659..de9a7002 100644 --- a/test/core/QCheck2_expect_test.ml +++ b/test/core/QCheck2_expect_test.ml @@ -133,6 +133,10 @@ module Shrink = struct Test.make ~name:"char is never produces 'abcdef'" ~count:1000 ~print:Print.char Gen.char (fun c -> not (List.mem c ['a';'b';'c';'d';'e';'f'])) + let strings_are_empty = + Test.make ~name:"strings are empty" ~count:1000 ~print:Print.string + Gen.string (fun s -> (*Printf.printf "\"%s\"\n" (String.escaped s);*) s = "") + let string_never_has_000_char = Test.make ~name:"string never has a \\000 char" ~count:1000 ~print:Print.string Gen.string @@ -361,6 +365,7 @@ let _ = Shrink.ints_are_0; Shrink.ints_smaller_209609; Shrink.char_is_never_abcdef; + Shrink.strings_are_empty; Shrink.string_never_has_000_char; Shrink.string_never_has_255_char; Shrink.lists_are_empty_issue_64; diff --git a/test/core/QCheck_expect_test.ml b/test/core/QCheck_expect_test.ml index 29f1b926..da9956e0 100644 --- a/test/core/QCheck_expect_test.ml +++ b/test/core/QCheck_expect_test.ml @@ -127,6 +127,10 @@ module Shrink = struct Test.make ~name:"char is never produces 'abcdef'" ~count:1000 char (fun c -> not (List.mem c ['a';'b';'c';'d';'e';'f'])) + let strings_are_empty = + Test.make ~name:"strings are empty" ~count:1000 + string (fun s -> (*Printf.printf "\"%s\"\n" (String.escaped s);*) s = "") + let string_never_has_000_char = Test.make ~name:"string never has a \\000 char" ~count:1000 string @@ -349,6 +353,7 @@ let _ = Shrink.ints_are_0; Shrink.ints_smaller_209609; Shrink.char_is_never_abcdef; + Shrink.strings_are_empty; Shrink.string_never_has_000_char; Shrink.string_never_has_255_char; Shrink.lists_are_empty_issue_64; diff --git a/test/core/qcheck2_output.txt.expected b/test/core/qcheck2_output.txt.expected index e38efaa4..7f29becd 100644 --- a/test/core/qcheck2_output.txt.expected +++ b/test/core/qcheck2_output.txt.expected @@ -257,6 +257,12 @@ Test char is never produces 'abcdef' failed (1 shrink steps): --- Failure -------------------------------------------------------------------- +Test strings are empty failed (8 shrink steps): + +"a" + +--- Failure -------------------------------------------------------------------- + Test string never has a \000 char failed (22 shrink steps): "aaaaaa\000aaaaaaaaaaaaaaaa" @@ -847,7 +853,7 @@ stats dist: -4611686018427387392..-4150517416584648577: 0 ================================================================================ 1 warning(s) -failure (23 tests failed, 1 tests errored, ran 59 tests) +failure (24 tests failed, 1 tests errored, ran 60 tests) random seed: 153870556 +++ Stats for int_dist_empty_bucket ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ diff --git a/test/core/qcheck_output.txt.expected b/test/core/qcheck_output.txt.expected index f915746e..61e2befe 100644 --- a/test/core/qcheck_output.txt.expected +++ b/test/core/qcheck_output.txt.expected @@ -199,6 +199,12 @@ Test char is never produces 'abcdef' failed (0 shrink steps): --- Failure -------------------------------------------------------------------- +Test strings are empty failed (249 shrink steps): + +"\177" + +--- Failure -------------------------------------------------------------------- + Test string never has a \000 char failed (25 shrink steps): "\000" @@ -783,7 +789,7 @@ stats dist: -4611686018427387392..-4150517416584648577: 0 ================================================================================ 1 warning(s) -failure (23 tests failed, 1 tests errored, ran 59 tests) +failure (24 tests failed, 1 tests errored, ran 60 tests) random seed: 153870556 +++ Stats for int_dist_empty_bucket ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ From 9f7a282afa793bd0ec169a4ddf406f5782c5694d Mon Sep 17 00:00:00 2001 From: Jan Midtgaard Date: Mon, 16 Aug 2021 15:29:42 +0200 Subject: [PATCH 47/49] update expected output following PR #151 --- test/core/qcheck2_output.txt.expected | 2 -- test/core/qcheck_output.txt.expected | 2 -- 2 files changed, 4 deletions(-) diff --git a/test/core/qcheck2_output.txt.expected b/test/core/qcheck2_output.txt.expected index 7f29becd..508d8f62 100644 --- a/test/core/qcheck2_output.txt.expected +++ b/test/core/qcheck2_output.txt.expected @@ -850,7 +850,6 @@ stats dist: 3228180212899171968.. 3689348814741910783: 0 3689348814741910784.. 4150517416584649599: 0 4150517416584649600.. 4611686018427387903: ################# 189 - -4611686018427387392..-4150517416584648577: 0 ================================================================================ 1 warning(s) failure (24 tests failed, 1 tests errored, ran 60 tests) @@ -880,6 +879,5 @@ stats dist: 3233511792870341913.. 3692903201389357272: # 17 3692903201389357273.. 4152294609908372632: ## 21 4152294609908372633.. 4611686018427387903: ## 27 - -4611686018427387815..-4152294609908372456: 0 ================================================================================ success (ran 1 tests) diff --git a/test/core/qcheck_output.txt.expected b/test/core/qcheck_output.txt.expected index 61e2befe..e7a08d5c 100644 --- a/test/core/qcheck_output.txt.expected +++ b/test/core/qcheck_output.txt.expected @@ -786,7 +786,6 @@ stats dist: 3228180212899171968.. 3689348814741910783: 0 3689348814741910784.. 4150517416584649599: 0 4150517416584649600.. 4611686018427387903: ################# 189 - -4611686018427387392..-4150517416584648577: 0 ================================================================================ 1 warning(s) failure (24 tests failed, 1 tests errored, ran 60 tests) @@ -816,6 +815,5 @@ stats dist: 3231325275647816127.. 3691445523241006782: ## 25 3691445523241006783.. 4151565770834197438: # 17 4151565770834197439.. 4611686018427387903: ## 24 - -4611686018427387713..-4151565770834197058: 0 ================================================================================ success (ran 1 tests) From 460a280435d7bc65fc63a65e89d4640396138bd3 Mon Sep 17 00:00:00 2001 From: Jan Midtgaard Date: Tue, 17 Aug 2021 08:30:34 +0200 Subject: [PATCH 48/49] add unique list test --- test/core/QCheck2_expect_test.ml | 7 ++++++ test/core/QCheck_expect_test.ml | 7 ++++++ test/core/qcheck2_output.txt.expected | 31 ++++++++++++++++++++++++++- test/core/qcheck_output.txt.expected | 26 +++++++++++++++++++++- 4 files changed, 69 insertions(+), 2 deletions(-) diff --git a/test/core/QCheck2_expect_test.ml b/test/core/QCheck2_expect_test.ml index de9a7002..c93e916e 100644 --- a/test/core/QCheck2_expect_test.ml +++ b/test/core/QCheck2_expect_test.ml @@ -178,6 +178,12 @@ module Shrink = struct Gen.(list_size size_gen small_int) (*Gen.(list small_int)*) (fun xs -> try xs = xs @ xs with Stack_overflow -> false) + + let list_unique_elems = + 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) end (* tests function generator and shrinker *) @@ -373,6 +379,7 @@ let _ = Shrink.list_shorter_432; Shrink.list_shorter_4332; Shrink.list_equal_dupl; + Shrink.list_unique_elems; Function.fail_pred_map_commute; Function.fail_pred_strings; Function.prop_foldleft_foldright; diff --git a/test/core/QCheck_expect_test.ml b/test/core/QCheck_expect_test.ml index da9956e0..0a1d2443 100644 --- a/test/core/QCheck_expect_test.ml +++ b/test/core/QCheck_expect_test.ml @@ -172,6 +172,12 @@ module Shrink = struct (*(set_print length_printer (list small_int))*) (fun xs -> try xs = xs @ xs with Stack_overflow -> false) + + let list_unique_elems = + 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) end (* tests function generator and shrinker *) @@ -361,6 +367,7 @@ let _ = Shrink.list_shorter_432; Shrink.list_shorter_4332; Shrink.list_equal_dupl; + Shrink.list_unique_elems; Function.fail_pred_map_commute; Function.fail_pred_strings; Function.prop_foldleft_foldright; diff --git a/test/core/qcheck2_output.txt.expected b/test/core/qcheck2_output.txt.expected index 508d8f62..86121813 100644 --- a/test/core/qcheck2_output.txt.expected +++ b/test/core/qcheck2_output.txt.expected @@ -138,6 +138,29 @@ random seed: 1234 [3] [] [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; 5; 9; 3; 3; 1; 79; 4; 3; 2; 67; 5; 7; 12; 70; 8; 8; 6; 1; 3; 14; 15; 1; 61; 4; 1; 4; 1; 7; 4; 4; 4; 2; 8; 8; 7; 5; 4; 27; 0; 9; 80; 25; 1; 8; 1; 3; 7; 4; 3; 5; 5; 6; 5; 5; 31; 7; 0; 3; 3; 6; 71; 76; 28; 60; 6; 2; 6; 3; 0; 4; 1; 0; 5; 7; 0; 28; 86; 4; 7; 51; 36; 0; 5; 0; 1; 4; 3; 6; 0; 1; 1; 8; 18; 4; 2; 8; 8; 1; 4; 7; 1; 0; 93; 5; 3; 0; 80; 1; 7; 7; 8; 8; 5; 7; 8; 9; 24; 4; 25; 8; 8; 5; 4; 90; 4; 6; 8; 4; 4; 0; 60; 8; 9; 7; 44; 5; 1; 2; 9; 74; 7; 7] +[] +[9; 61; 8; 4; 69; 2; 0; 72; 4; 41; 3; 8; 75; 83; 7; 7; 3; 9; 5; 8; 4; 1; 0; 2; 1; 4; 7; 6; 2; 1; 4; 86; 3; 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 -------------------------------------------------------------------- @@ -311,6 +334,12 @@ Backtrace: --- Failure -------------------------------------------------------------------- +Test lists have unique elems failed (11 shrink steps): + +[0; 0; 0; 0; 0] + +--- Failure -------------------------------------------------------------------- + Test fail_pred_map_commute failed (16 shrink steps): ([2], {_ -> 0}, {1 -> false; 2 -> true; _ -> false}) @@ -852,7 +881,7 @@ stats dist: 4150517416584649600.. 4611686018427387903: ################# 189 ================================================================================ 1 warning(s) -failure (24 tests failed, 1 tests errored, ran 60 tests) +failure (25 tests failed, 1 tests errored, ran 61 tests) random seed: 153870556 +++ Stats for int_dist_empty_bucket ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ diff --git a/test/core/qcheck_output.txt.expected b/test/core/qcheck_output.txt.expected index e7a08d5c..5514fb99 100644 --- a/test/core/qcheck_output.txt.expected +++ b/test/core/qcheck_output.txt.expected @@ -80,6 +80,24 @@ random seed: 1234 [] [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; 5; 9; 3; 3; 1; 79; 4; 3; 2; 67; 5; 7; 12; 70; 8; 8; 6; 1; 3; 14; 15; 1; 61; 4; 1; 4; 1; 7; 4; 4; 4; 2; 8; 8; 7; 5; 4; 27; 0; 9; 80; 25; 1; 8; 1; 3; 7; 4; 3; 5; 5; 6; 5; 5; 31; 7; 0; 3; 3; 6; 71; 76; 28; 60; 6; 2; 6; 3; 0; 4; 1; 0; 5; 7; 0; 28; 86; 4; 7; 51; 36; 0; 5; 0; 1; 4; 3; 6; 0; 1; 1; 8; 18; 4; 2; 8; 8; 1; 4; 7; 1; 0; 93; 5; 3; 0; 80; 1; 7; 7; 8; 8; 5; 7; 8; 9; 24; 4; 25; 8; 8; 5; 4; 90; 4; 6; 8; 4; 4; 0; 60; 8; 9; 7; 44; 5; 1; 2; 9; 74; 7; 7] +[1; 3; 14; 15; 1; 61; 4; 1; 4; 1; 7; 4; 4; 4; 2; 8; 8; 7; 5; 4; 27; 0; 9; 80; 25; 1; 8; 1; 3; 7; 4; 3; 5; 5; 6; 5; 5; 31; 7; 0; 3; 3; 6; 71; 76; 28; 60; 6; 2; 6; 3; 0; 4; 1; 0; 5; 7; 0; 28; 86; 4; 7; 51; 36; 0; 5; 0; 1; 4; 3; 6; 0; 1; 1; 8; 18; 4; 2; 8; 8; 1; 4; 7; 1; 0; 93; 5; 3; 0; 80; 1; 7; 7; 8; 8; 5; 7; 8; 9; 24; 4; 25; 8; 8; 5; 4; 90; 4; 6; 8; 4; 4; 0; 60; 8; 9; 7; 44; 5; 1; 2; 9; 74; 7; 7] +[36; 0; 5; 0; 1; 4; 3; 6; 0; 1; 1; 8; 18; 4; 2; 8; 8; 1; 4; 7; 1; 0; 93; 5; 3; 0; 80; 1; 7; 7; 8; 8; 5; 7; 8; 9; 24; 4; 25; 8; 8; 5; 4; 90; 4; 6; 8; 4; 4; 0; 60; 8; 9; 7; 44; 5; 1; 2; 9; 74; 7; 7] +[8; 5; 7; 8; 9; 24; 4; 25; 8; 8; 5; 4; 90; 4; 6; 8; 4; 4; 0; 60; 8; 9; 7; 44; 5; 1; 2; 9; 74; 7; 7] +[4; 4; 0; 60; 8; 9; 7; 44; 5; 1; 2; 9; 74; 7; 7] +[5; 1; 2; 9; 74; 7; 7] +[74; 7; 7] +[7] +[74] +[7; 7] +[7] +[7] +[4; 7] +[6; 7] +[6; 7] +[7; 4] +[7; 6] +[7; 6] --- Failure -------------------------------------------------------------------- @@ -247,6 +265,12 @@ Test lists equal to duplication failed (20 shrink steps): --- Failure -------------------------------------------------------------------- +Test lists have unique elems failed (7 shrink steps): + +[7; 7] + +--- Failure -------------------------------------------------------------------- + Test fail_pred_map_commute failed (127 shrink steps): ([3], {_ -> 0}, {3 -> false; _ -> true}) @@ -788,7 +812,7 @@ stats dist: 4150517416584649600.. 4611686018427387903: ################# 189 ================================================================================ 1 warning(s) -failure (24 tests failed, 1 tests errored, ran 60 tests) +failure (25 tests failed, 1 tests errored, ran 61 tests) random seed: 153870556 +++ Stats for int_dist_empty_bucket ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ From e7efdf11686d56730f9634735de9f67a52d47e12 Mon Sep 17 00:00:00 2001 From: Jan Midtgaard Date: Tue, 17 Aug 2021 17:05:07 +0200 Subject: [PATCH 49/49] add nat tests --- test/core/QCheck2_expect_test.ml | 11 +++++++++ test/core/QCheck_expect_test.ml | 11 +++++++++ test/core/qcheck2_output.txt.expected | 33 ++++++++++++++++++++++++++- test/core/qcheck_output.txt.expected | 33 ++++++++++++++++++++++++++- 4 files changed, 86 insertions(+), 2 deletions(-) diff --git a/test/core/QCheck2_expect_test.ml b/test/core/QCheck2_expect_test.ml index c93e916e..970312d9 100644 --- a/test/core/QCheck2_expect_test.ml +++ b/test/core/QCheck2_expect_test.ml @@ -62,6 +62,10 @@ module Generator = struct Test.make ~name:"char has right range'" ~count:1000 ~print:Print.char Gen.char (fun c -> '\000' <= c && c <= '\255') + let nat_test = + Test.make ~name:"nat has right range" ~count:1000 ~print:Print.int + Gen.nat (fun n -> 0 <= n && n < 10000) + let string_test = Test.make ~name:"string has right length and content" ~count:1000 ~print:Print.string Gen.string @@ -129,6 +133,10 @@ module Shrink = struct Test.make ~name:"ints < 209609" ~print:Print.int (Gen.small_int_corners()) (fun i -> i < 209609) + let nats_smaller_5001 = + Test.make ~name:"nat < 5001" ~count:1000 ~print:Print.int + Gen.nat (fun n -> n < 5001) + let char_is_never_abcdef = Test.make ~name:"char is never produces 'abcdef'" ~count:1000 ~print:Print.char Gen.char (fun c -> not (List.mem c ['a';'b';'c';'d';'e';'f'])) @@ -333,6 +341,7 @@ module Stats = struct (* distribution tests from PR #45 *) Test.make ~name:"small_signed_int dist" ~count:1000 ~stats:[dist] Gen.small_signed_int (fun _ -> true); Test.make ~name:"small_nat dist" ~count:1000 ~stats:[dist] Gen.small_nat (fun _ -> true); + Test.make ~name:"nat dist" ~count:1000 ~stats:[dist] Gen.nat (fun _ -> true); Test.make ~name:"int_range (-43643) 435434 dist" ~count:1000 ~stats:[dist] (Gen.int_range (-43643) 435434) (fun _ -> true); Test.make ~name:"int_range (-40000) 40000 dist" ~count:1000 ~stats:[dist] (Gen.int_range (-40000) 40000) (fun _ -> true); Test.make ~name:"int_range (-4) 4 dist" ~count:1000 ~stats:[dist] (Gen.int_range (-4) 4) (fun _ -> true); @@ -360,6 +369,7 @@ let _ = Overall.bad_assume_fail; Generator.char_dist_issue_23; Generator.char_test; + Generator.nat_test; Generator.string_test; Generator.list_test; Generator.list_repeat_test; @@ -370,6 +380,7 @@ let _ = Shrink.ints_arent_0_mod_3; Shrink.ints_are_0; Shrink.ints_smaller_209609; + Shrink.nats_smaller_5001; Shrink.char_is_never_abcdef; Shrink.strings_are_empty; Shrink.string_never_has_000_char; diff --git a/test/core/QCheck_expect_test.ml b/test/core/QCheck_expect_test.ml index 0a1d2443..97a8dd28 100644 --- a/test/core/QCheck_expect_test.ml +++ b/test/core/QCheck_expect_test.ml @@ -60,6 +60,10 @@ module Generator = struct Test.make ~name:"char has right range'" ~count:1000 char (fun c -> '\000' <= c && c <= '\255') + let nat_test = + Test.make ~name:"nat has right range" ~count:1000 + (make ~print:Print.int Gen.nat) (fun n -> 0 <= n && n < 10000) + let string_test = Test.make ~name:"string has right length and content" ~count:1000 string @@ -123,6 +127,10 @@ module Shrink = struct Test.make ~name:"ints < 209609" (small_int_corners()) (fun i -> i < 209609) + let nats_smaller_5001 = + Test.make ~name:"nat < 5001" ~count:1000 + (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 char (fun c -> not (List.mem c ['a';'b';'c';'d';'e';'f'])) @@ -321,6 +329,7 @@ module Stats = struct (* distribution tests from PR #45 *) Test.make ~name:"small_signed_int dist" ~count:1000 (add_stat dist small_signed_int) (fun _ -> true); Test.make ~name:"small_nat dist" ~count:1000 (add_stat dist small_nat) (fun _ -> true); + Test.make ~name:"nat dist" ~count:1000 (add_stat dist (make Gen.nat)) (fun _ -> true); Test.make ~name:"int_range (-43643) 435434 dist" ~count:1000 (add_stat dist (int_range (-43643) 435434)) (fun _ -> true); Test.make ~name:"int_range (-40000) 40000 dist" ~count:1000 (add_stat dist (int_range (-40000) 40000)) (fun _ -> true); Test.make ~name:"int_range (-4) 4 dist" ~count:1000 (add_stat dist (int_range (-4) 4)) (fun _ -> true); @@ -348,6 +357,7 @@ let _ = Overall.bad_assume_fail; Generator.char_dist_issue_23; Generator.char_test; + Generator.nat_test; Generator.string_test; Generator.list_test; Generator.list_repeat_test; @@ -358,6 +368,7 @@ let _ = Shrink.ints_arent_0_mod_3; Shrink.ints_are_0; Shrink.ints_smaller_209609; + Shrink.nats_smaller_5001; Shrink.char_is_never_abcdef; Shrink.strings_are_empty; Shrink.string_never_has_000_char; diff --git a/test/core/qcheck2_output.txt.expected b/test/core/qcheck2_output.txt.expected index 86121813..f13574bf 100644 --- a/test/core/qcheck2_output.txt.expected +++ b/test/core/qcheck2_output.txt.expected @@ -274,6 +274,12 @@ Test ints < 209609 failed (0 shrink steps): --- Failure -------------------------------------------------------------------- +Test nat < 5001 failed (7 shrink steps): + +5001 + +--- Failure -------------------------------------------------------------------- + Test char is never produces 'abcdef' failed (1 shrink steps): 'a' @@ -741,6 +747,31 @@ stats dist: 90.. 94: 5 95.. 99: # 10 ++++ Stats for nat dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats dist: + num: 1000, avg: 363.02, stddev: 1215.04, median 9, min 0, max 9476 + 0.. 473: ####################################################### 847 + 474.. 947: ###### 95 + 948..1421: 14 + 1422..1895: 3 + 1896..2369: 0 + 2370..2843: 3 + 2844..3317: 2 + 3318..3791: 3 + 3792..4265: 2 + 4266..4739: 4 + 4740..5213: 3 + 5214..5687: 4 + 5688..6161: 3 + 6162..6635: 4 + 6636..7109: 1 + 7110..7583: 4 + 7584..8057: 2 + 8058..8531: 1 + 8532..9005: 1 + 9006..9479: 4 + +++ Stats for int_range (-43643) 435434 dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: @@ -881,7 +912,7 @@ stats dist: 4150517416584649600.. 4611686018427387903: ################# 189 ================================================================================ 1 warning(s) -failure (25 tests failed, 1 tests errored, ran 61 tests) +failure (26 tests failed, 1 tests errored, ran 64 tests) random seed: 153870556 +++ Stats for int_dist_empty_bucket ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ diff --git a/test/core/qcheck_output.txt.expected b/test/core/qcheck_output.txt.expected index 5514fb99..da58eda8 100644 --- a/test/core/qcheck_output.txt.expected +++ b/test/core/qcheck_output.txt.expected @@ -211,6 +211,12 @@ Test ints < 209609 failed (52 shrink steps): --- Failure -------------------------------------------------------------------- +Test nat < 5001 failed (6 shrink steps): + +5001 + +--- Failure -------------------------------------------------------------------- + Test char is never produces 'abcdef' failed (0 shrink steps): 'd' @@ -672,6 +678,31 @@ stats dist: 90.. 94: 5 95.. 99: # 10 ++++ Stats for nat dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats dist: + num: 1000, avg: 363.02, stddev: 1215.04, median 9, min 0, max 9476 + 0.. 473: ####################################################### 847 + 474.. 947: ###### 95 + 948..1421: 14 + 1422..1895: 3 + 1896..2369: 0 + 2370..2843: 3 + 2844..3317: 2 + 3318..3791: 3 + 3792..4265: 2 + 4266..4739: 4 + 4740..5213: 3 + 5214..5687: 4 + 5688..6161: 3 + 6162..6635: 4 + 6636..7109: 1 + 7110..7583: 4 + 7584..8057: 2 + 8058..8531: 1 + 8532..9005: 1 + 9006..9479: 4 + +++ Stats for int_range (-43643) 435434 dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: @@ -812,7 +843,7 @@ stats dist: 4150517416584649600.. 4611686018427387903: ################# 189 ================================================================================ 1 warning(s) -failure (25 tests failed, 1 tests errored, ran 61 tests) +failure (26 tests failed, 1 tests errored, ran 64 tests) random seed: 153870556 +++ Stats for int_dist_empty_bucket ++++++++++++++++++++++++++++++++++++++++++++++++++++++++