New upstream snapshot.
Debian Janitor
1 year, 5 months ago
0 | 0 | # Changes |
1 | ||
2 | ## 0.20 | |
3 | ||
4 | - add an optional argument with conservative default to `Shrink.string` | |
5 | - fix shrinkers in `QCheck.{printable_string,printable_string_of_size,small_printable_string,numeral_string,numeral_string_of_size}` [#257](https://github.com/c-cube/qcheck/issues/257) | |
6 | - add `QCheck2.Gen.set_shrink` to modify the generator's shrinker | |
7 | - add `QCheck2.Gen.no_shrink` to build a generator with no shrinking | |
8 | - add an environment variable `QCHECK_MSG_INTERVAL` to control `QCheck_base_runner.time_between_msg` | |
9 | ||
10 | ## 0.19.1 | |
11 | ||
12 | - fix: allow `~count` in `Test.make` to be 0 | |
13 | - fix: allow `~long_factor` in `Test.make` to be 0 | |
14 | ||
15 | ## 0.19 | |
16 | ||
17 | - use `Float.equal` for comparing `float`s in the `Observable` module underlying function generators. | |
18 | ||
19 | - add optional `debug_shrink` parameters in alcotest interface and | |
20 | expose default `debug_shrinking_choices` in test runners | |
21 | ||
22 | - add missing `?handler` parameter to `Test.check_cell_exn` | |
23 | ||
24 | - remove `--no-buffer` option on `dune runtest` to avoid garbling the | |
25 | test output | |
26 | ||
27 | - add an option `retries` parameter to `Test.make` et al. for checking a | |
28 | property repeatedly while shrinking. | |
29 | This can be useful when testing non-deterministic code. | |
30 | [#212](https://github.com/c-cube/qcheck/pull/212) | |
31 | ||
32 | - add `tup2` to `tup9` for generators | |
33 | ||
34 | - add `Test.make_neg` for negative property-based tests, that are | |
35 | expected not to satisfy the tested property. | |
36 | ||
37 | - rename `Gen.opt` to `Gen.option` but keep the old binding for compatibility. | |
38 | ||
39 | - add additional expect and unit tests and refactor expect test suite | |
40 | ||
41 | - fix function generation affecting reproducability [#236](https://github.com/c-cube/qcheck/issues/236) | |
42 | ||
43 | - add a shrinker performance benchmark [#177](https://github.com/c-cube/qcheck/pull/177) | |
44 | ||
45 | - fix distribution of `QCheck2.printable` which would omit certain characters | |
46 | ||
47 | - shrinker changes | |
48 | - recursive list shrinker with better complexity | |
49 | - string shrinker reuses improved list shrinker and adds char shrinking | |
50 | - function shrinker now shrinks default entry first and benefits from list shrinker improvements | |
51 | - replacing the linear-time char shrinker with a faster one reusing the bisecting int shrinker algorithm | |
52 | - add `Shrink.char_numeral` and `Shrink.char_printable` | |
53 | - add shrinking for `char arbitrary`s `char`, `printable_char`, and `numeral_char` | |
54 | ||
55 | - documentation updates: | |
56 | - clarify upper bound inclusion in `Gen.int_bound` and `Gen.int_range` | |
57 | - clarify `printable_char` and `Gen.printable` distributions | |
58 | - add missing `string_gen_of_size` and `small_printable_string` documentation | |
59 | - document `QCheck_alcotest.to_alcotest` | |
60 | - fix documented size distribution for `arbitrary` generators | |
61 | `string_gen`, `string`, `printable_string`, `numeral_string`, `list`, and `array` | |
62 | - fix exception documentation for `check_result`, `check_cell_exn`, and `check_exn` | |
63 | - fix documentation for the distribution of `Gen.printable` and `printable_char` | |
64 | - fix documentation for the shrinking behaviour of `QCheck2.printable` | |
65 | ||
66 | - add environment variable `QCHECK_LONG_FACTOR` similar to `QCHECK_COUNT` [#220](https://github.com/c-cube/qcheck/pull/220) | |
67 | ||
68 | - make test suite run on 32-bit architectures | |
1 | 69 | |
2 | 70 | ## 0.18.1 |
3 | 71 |
4 | 4 | @dune build @install |
5 | 5 | |
6 | 6 | test: |
7 | @dune runtest --no-buffer --force | |
7 | @dune runtest --force | |
8 | 8 | |
9 | 9 | clean: |
10 | 10 | @dune clean |
0 | ocaml-qcheck (0.19.1+git20221027.1.98716de-1) UNRELEASED; urgency=low | |
1 | ||
2 | * New upstream snapshot. | |
3 | ||
4 | -- Debian Janitor <janitor@jelmer.uk> Fri, 28 Oct 2022 02:54:18 -0000 | |
5 | ||
0 | 6 | ocaml-qcheck (0.18.1-2) unstable; urgency=medium |
1 | 7 | |
2 | 8 | * Team upload |
34 | 34 | ] |
35 | 35 | ) |
36 | 36 | (fun _ -> true) |
37 | ||
38 | ||
39 | let neg_test_failing_as_expected = | |
40 | QCheck.Test.make_neg ~name:"neg test pass (failing as expected)" QCheck.small_int (fun i -> i mod 2 = 0) | |
41 | ||
42 | let neg_test_unexpected_success = | |
43 | QCheck.Test.make_neg ~name:"neg test unexpected success" QCheck.small_int (fun i -> i + i = i * 2) | |
44 | ||
45 | let neg_test_error = | |
46 | QCheck.Test.make_neg ~name:"neg fail with error" QCheck.small_int (fun _i -> raise Error) | |
37 | 47 | |
38 | 48 | let fun1 = |
39 | 49 | QCheck.Test.make ~count:100 ~long_factor:100 |
181 | 191 | error; |
182 | 192 | collect; |
183 | 193 | stats; |
194 | neg_test_failing_as_expected; | |
195 | neg_test_unexpected_success; | |
196 | neg_test_error; | |
184 | 197 | fun1; |
185 | 198 | fun2; |
186 | 199 | prop_foldleft_foldright; |
16 | 16 | ~name:"error_raise_exn" |
17 | 17 | QCheck.int |
18 | 18 | (fun _ -> raise Error) |
19 | ||
20 | let neg_test_failing_as_expected = | |
21 | QCheck.Test.make_neg ~name:"neg test pass (failing as expected)" QCheck.small_int (fun i -> i mod 2 = 0) | |
22 | ||
23 | let neg_test_unexpected_success = | |
24 | QCheck.Test.make_neg ~name:"neg test unexpected success" QCheck.small_int (fun i -> i + i = i * 2) | |
25 | ||
26 | let neg_test_error = | |
27 | QCheck.Test.make_neg ~name:"neg fail with error" QCheck.small_int (fun _i -> raise Error) | |
19 | 28 | |
20 | 29 | let simple_qcheck = |
21 | 30 | QCheck.Test.make ~name:"fail_check_err_message" |
47 | 56 | QCheck.(make gen_tree) |
48 | 57 | (fun tree -> rev_tree (rev_tree tree) = tree) |
49 | 58 | |
59 | let debug_shrink = | |
60 | QCheck.Test.make ~count:10 | |
61 | ~name:"debug_shrink" | |
62 | (* we use a very constrained test to have a smaller shrinking tree *) | |
63 | QCheck.(pair (1 -- 3) (1 -- 3)) | |
64 | (fun (a, b) -> a = b);; | |
65 | ||
50 | 66 | let () = |
51 | 67 | Printexc.record_backtrace true; |
52 | 68 | let module A = Alcotest in |
53 | 69 | let suite = |
54 | 70 | List.map QCheck_alcotest.to_alcotest |
55 | [ passing; failing; error; simple_qcheck; passing_tree_rev ] | |
71 | [ passing; failing; error; | |
72 | neg_test_failing_as_expected; neg_test_unexpected_success; neg_test_error; | |
73 | simple_qcheck; passing_tree_rev ] | |
56 | 74 | in |
57 | A.run "my test" [ | |
58 | "suite", suite | |
59 | ] | |
75 | A.run ~show_errors:true "my test" [ | |
76 | "suite", suite; | |
77 | "shrinking", [ | |
78 | QCheck_alcotest.to_alcotest ~verbose:true ~debug_shrink:(Some stdout) debug_shrink | |
79 | ]; | |
80 | ]; |
0 | (* -*- tuareg -*- *) | |
1 | ||
2 | let dune = Printf.sprintf {| | |
0 | 3 | |
1 | 4 | (executable |
2 | 5 | (name QCheck_alcotest_test) |
5 | 8 | (rule |
6 | 9 | (targets output.txt) |
7 | 10 | (deps ./QCheck_alcotest_test.exe) |
8 | (enabled_if (= %{os_type} "Unix")) | |
11 | (enabled_if (= %%{os_type} "Unix")) | |
9 | 12 | (action |
10 | 13 | (with-accepted-exit-codes |
11 | 14 | 1 |
12 | 15 | (setenv |
13 | 16 | QCHECK_SEED 1234 |
14 | 17 | (with-stdout-to |
15 | %{targets} | |
18 | %%{targets} | |
16 | 19 | (run ./run_alcotest.sh --color=never)))))) |
17 | 20 | |
18 | 21 | (rule |
19 | 22 | (alias runtest) |
20 | 23 | (package qcheck-alcotest) |
21 | (enabled_if (= %{os_type} "Unix")) | |
22 | (action (diff output.txt.expected output.txt))) | |
24 | (enabled_if (= %%{os_type} "Unix")) | |
25 | (action (diff output.txt.expected.%i output.txt))) | |
26 | ||
27 | |} Sys.word_size | |
28 | ||
29 | let () = Jbuild_plugin.V1.send dune |
0 | qcheck random seed: 1234 | |
1 | Testing `my test'. | |
2 | [OK] suite 0 list_rev_is_involutive. | |
3 | > [FAIL] suite 1 fail_sort_id. | |
4 | [FAIL] suite 2 error_raise_exn. | |
5 | [FAIL] suite 3 fail_check_err_message. | |
6 | [OK] suite 4 tree_rev_is_involutive. | |
7 | ┌──────────────────────────────────────────────────────────────────────────────┐ | |
8 | │ [FAIL] suite 1 fail_sort_id. │ | |
9 | └──────────────────────────────────────────────────────────────────────────────┘ | |
10 | test `fail_sort_id` failed on ≥ 1 cases: [1; 0] (after 20 shrink steps) | |
11 | [exception] test `fail_sort_id` failed on ≥ 1 cases: [1; 0] (after 20 shrink steps) | |
12 | ────────────────────────────────────────────────────────────────────────────── | |
13 | 3 failures! 5 tests run. |
0 | qcheck random seed: 1234 | |
1 | Testing `my test'. | |
2 | [OK] suite 0 list_rev_is_involutive. | |
3 | [FAIL] suite 1 fail_sort_id. | |
4 | [FAIL] suite 2 error_raise_exn. | |
5 | [OK] suite 3 neg test pass (failing as expected). | |
6 | [FAIL] suite 4 neg test unexpected success. | |
7 | [FAIL] suite 5 neg fail with error. | |
8 | [FAIL] suite 6 fail_check_err_message. | |
9 | [OK] suite 7 tree_rev_is_involutive. | |
10 | [FAIL] shrinking 0 debug_shrink. | |
11 | ┌──────────────────────────────────────────────────────────────────────────────┐ | |
12 | │ [FAIL] suite 1 fail_sort_id. │ | |
13 | └──────────────────────────────────────────────────────────────────────────────┘ | |
14 | test `fail_sort_id` failed on ≥ 1 cases: [1; 0] (after 11 shrink steps) | |
15 | [exception] test `fail_sort_id` failed on ≥ 1 cases: [1; 0] (after 11 shrink steps) | |
16 | ────────────────────────────────────────────────────────────────────────────── | |
17 | ┌──────────────────────────────────────────────────────────────────────────────┐ | |
18 | │ [FAIL] suite 2 error_raise_exn. │ | |
19 | └──────────────────────────────────────────────────────────────────────────────┘ | |
20 | test `error_raise_exn` | |
21 | raised exception `Error` | |
22 | on `0 (after 31 shrink steps)` | |
23 | [exception] test `error_raise_exn` | |
24 | raised exception `Error` | |
25 | on `0 (after 31 shrink steps)` | |
26 | ────────────────────────────────────────────────────────────────────────────── | |
27 | ┌──────────────────────────────────────────────────────────────────────────────┐ | |
28 | │ [FAIL] suite 4 neg test unexpected success. │ | |
29 | └──────────────────────────────────────────────────────────────────────────────┘ | |
30 | negative test 'neg test unexpected success' succeeded unexpectedly | |
31 | ASSERT negative test 'neg test unexpected success' succeeded unexpectedly | |
32 | FAIL negative test 'neg test unexpected success' succeeded unexpectedly | |
33 | ────────────────────────────────────────────────────────────────────────────── | |
34 | ┌──────────────────────────────────────────────────────────────────────────────┐ | |
35 | │ [FAIL] suite 5 neg fail with error. │ | |
36 | └──────────────────────────────────────────────────────────────────────────────┘ | |
37 | test `neg fail with error` | |
38 | raised exception `Error` | |
39 | on `0 (after 7 shrink steps)` | |
40 | [exception] test `neg fail with error` | |
41 | raised exception `Error` | |
42 | on `0 (after 7 shrink steps)` | |
43 | ────────────────────────────────────────────────────────────────────────────── | |
44 | ┌──────────────────────────────────────────────────────────────────────────────┐ | |
45 | │ [FAIL] suite 6 fail_check_err_message. │ | |
46 | └──────────────────────────────────────────────────────────────────────────────┘ | |
47 | test `fail_check_err_message` failed on ≥ 1 cases: | |
48 | 0 (after 7 shrink steps) | |
49 | this | |
50 | will | |
51 | always | |
52 | fail | |
53 | [exception] test `fail_check_err_message` failed on ≥ 1 cases: | |
54 | 0 (after 7 shrink steps) | |
55 | this | |
56 | will | |
57 | always | |
58 | fail | |
59 | ────────────────────────────────────────────────────────────────────────────── | |
60 | ┌──────────────────────────────────────────────────────────────────────────────┐ | |
61 | │ [FAIL] shrinking 0 debug_shrink. │ | |
62 | └──────────────────────────────────────────────────────────────────────────────┘ | |
63 | ~~~ Shrink ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
64 | Test debug_shrink successfully shrunk counter example (step 0) to: | |
65 | (3, 1) | |
66 | ~~~ Shrink ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
67 | Test debug_shrink successfully shrunk counter example (step 1) to: | |
68 | (2, 1) | |
69 | ~~~ Shrink ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
70 | Test debug_shrink successfully shrunk counter example (step 2) to: | |
71 | (2, 0) | |
72 | ~~~ Shrink ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
73 | Test debug_shrink successfully shrunk counter example (step 3) to: | |
74 | (1, 0) | |
75 | law debug_shrink: 2 relevant cases (2 total) | |
76 | test `debug_shrink` failed on ≥ 1 cases: (1, 0) (after 3 shrink steps) | |
77 | [exception] test `debug_shrink` failed on ≥ 1 cases: (1, 0) (after 3 shrink steps) | |
78 | ────────────────────────────────────────────────────────────────────────────── | |
79 | 6 failures! 9 tests run. |
0 | qcheck random seed: 1234 | |
1 | Testing `my test'. | |
2 | [OK] suite 0 list_rev_is_involutive. | |
3 | [FAIL] suite 1 fail_sort_id. | |
4 | [FAIL] suite 2 error_raise_exn. | |
5 | [OK] suite 3 neg test pass (failing as expected). | |
6 | [FAIL] suite 4 neg test unexpected success. | |
7 | [FAIL] suite 5 neg fail with error. | |
8 | [FAIL] suite 6 fail_check_err_message. | |
9 | [OK] suite 7 tree_rev_is_involutive. | |
10 | [FAIL] shrinking 0 debug_shrink. | |
11 | ┌──────────────────────────────────────────────────────────────────────────────┐ | |
12 | │ [FAIL] suite 1 fail_sort_id. │ | |
13 | └──────────────────────────────────────────────────────────────────────────────┘ | |
14 | test `fail_sort_id` failed on ≥ 1 cases: [1; 0] (after 11 shrink steps) | |
15 | [exception] test `fail_sort_id` failed on ≥ 1 cases: [1; 0] (after 11 shrink steps) | |
16 | ────────────────────────────────────────────────────────────────────────────── | |
17 | ┌──────────────────────────────────────────────────────────────────────────────┐ | |
18 | │ [FAIL] suite 2 error_raise_exn. │ | |
19 | └──────────────────────────────────────────────────────────────────────────────┘ | |
20 | test `error_raise_exn` | |
21 | raised exception `Error` | |
22 | on `0 (after 63 shrink steps)` | |
23 | [exception] test `error_raise_exn` | |
24 | raised exception `Error` | |
25 | on `0 (after 63 shrink steps)` | |
26 | ────────────────────────────────────────────────────────────────────────────── | |
27 | ┌──────────────────────────────────────────────────────────────────────────────┐ | |
28 | │ [FAIL] suite 4 neg test unexpected success. │ | |
29 | └──────────────────────────────────────────────────────────────────────────────┘ | |
30 | negative test 'neg test unexpected success' succeeded unexpectedly | |
31 | ASSERT negative test 'neg test unexpected success' succeeded unexpectedly | |
32 | FAIL negative test 'neg test unexpected success' succeeded unexpectedly | |
33 | ────────────────────────────────────────────────────────────────────────────── | |
34 | ┌──────────────────────────────────────────────────────────────────────────────┐ | |
35 | │ [FAIL] suite 5 neg fail with error. │ | |
36 | └──────────────────────────────────────────────────────────────────────────────┘ | |
37 | test `neg fail with error` | |
38 | raised exception `Error` | |
39 | on `0 (after 7 shrink steps)` | |
40 | [exception] test `neg fail with error` | |
41 | raised exception `Error` | |
42 | on `0 (after 7 shrink steps)` | |
43 | ────────────────────────────────────────────────────────────────────────────── | |
44 | ┌──────────────────────────────────────────────────────────────────────────────┐ | |
45 | │ [FAIL] suite 6 fail_check_err_message. │ | |
46 | └──────────────────────────────────────────────────────────────────────────────┘ | |
47 | test `fail_check_err_message` failed on ≥ 1 cases: | |
48 | 0 (after 7 shrink steps) | |
49 | this | |
50 | will | |
51 | always | |
52 | fail | |
53 | [exception] test `fail_check_err_message` failed on ≥ 1 cases: | |
54 | 0 (after 7 shrink steps) | |
55 | this | |
56 | will | |
57 | always | |
58 | fail | |
59 | ────────────────────────────────────────────────────────────────────────────── | |
60 | ┌──────────────────────────────────────────────────────────────────────────────┐ | |
61 | │ [FAIL] shrinking 0 debug_shrink. │ | |
62 | └──────────────────────────────────────────────────────────────────────────────┘ | |
63 | ~~~ Shrink ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
64 | Test debug_shrink successfully shrunk counter example (step 0) to: | |
65 | (3, 1) | |
66 | ~~~ Shrink ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
67 | Test debug_shrink successfully shrunk counter example (step 1) to: | |
68 | (2, 1) | |
69 | ~~~ Shrink ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
70 | Test debug_shrink successfully shrunk counter example (step 2) to: | |
71 | (2, 0) | |
72 | ~~~ Shrink ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
73 | Test debug_shrink successfully shrunk counter example (step 3) to: | |
74 | (1, 0) | |
75 | law debug_shrink: 2 relevant cases (2 total) | |
76 | test `debug_shrink` failed on ≥ 1 cases: (1, 0) (after 3 shrink steps) | |
77 | [exception] test `debug_shrink` failed on ≥ 1 cases: (1, 0) (after 3 shrink steps) | |
78 | ────────────────────────────────────────────────────────────────────────────── | |
79 | 6 failures! 9 tests run. |
11 | 11 | | grep -v 'Raised at ' \ |
12 | 12 | | grep -v 'Called from ' \ |
13 | 13 | | sed 's/! in .*s\./!/' \ |
14 | | sed 's/`.*.Error`/`Error`/g' \ | |
14 | 15 | | sed 's/[ \t]*$//g' \ |
15 | 16 | | tr -s "\n" |
16 | 17 | exit $CODE |
0 | (* -*- tuareg -*- *) | |
1 | ||
2 | let dune = Printf.sprintf {| | |
0 | 3 | |
1 | 4 | (executables |
2 | 5 | (names QCheck_runner_test) |
5 | 8 | (rule |
6 | 9 | (targets output.txt) |
7 | 10 | (deps ./QCheck_runner_test.exe) |
8 | (enabled_if (= %{os_type} "Unix")) | |
11 | (enabled_if (= %%{os_type} "Unix")) | |
9 | 12 | (action |
10 | 13 | (with-accepted-exit-codes |
11 | 14 | 1 |
12 | 15 | (with-stdout-to |
13 | %{targets} | |
16 | %%{targets} | |
14 | 17 | (run ./QCheck_runner_test.exe --no-colors -s 1234))))) |
15 | 18 | |
16 | 19 | (rule |
17 | 20 | (alias runtest) |
18 | (enabled_if (= %{os_type} "Unix")) | |
21 | (enabled_if (= %%{os_type} "Unix")) | |
19 | 22 | (package qcheck) |
20 | (action (diff output.txt.expected output.txt))) | |
23 | (action (diff output.txt.expected.%i output.txt))) | |
24 | ||
25 | |} Sys.word_size | |
26 | ||
27 | let () = Jbuild_plugin.V1.send dune |
0 | (* Tests to check integration with the 'OUnit2.test' interface *) | |
1 | ||
0 | 2 | let passing = |
1 | 3 | QCheck.Test.make ~count:1000 |
2 | 4 | ~name:"list_rev_is_involutive" |
22 | 24 | ~count: 100 |
23 | 25 | QCheck.small_int |
24 | 26 | (fun _ -> QCheck.Test.fail_reportf "@[<v>this@ will@ always@ fail@]") |
27 | ||
28 | let neg_test_failing_as_expected = | |
29 | QCheck.Test.make_neg ~name:"neg test pass (failing as expected)" QCheck.small_int (fun i -> i mod 2 = 0) | |
30 | ||
31 | let neg_test_unexpected_success = | |
32 | QCheck.Test.make_neg ~name:"neg test unexpected success" QCheck.small_int (fun i -> i + i = i * 2) | |
33 | ||
34 | let neg_test_error = | |
35 | QCheck.Test.make_neg ~name:"neg fail with error" QCheck.small_int (fun _i -> raise Error) | |
25 | 36 | |
26 | 37 | |
27 | 38 | type tree = Leaf of int | Node of tree * tree |
54 | 65 | run_test_tt_main |
55 | 66 | ("tests" >::: |
56 | 67 | List.map QCheck_ounit.to_ounit2_test |
57 | [passing; failing; error; simple_qcheck; passing_tree_rev]) | |
68 | [passing; failing; error; | |
69 | neg_test_failing_as_expected; neg_test_unexpected_success; neg_test_error; | |
70 | simple_qcheck; passing_tree_rev]) |
0 | (* Tests to check integration with the 'OUnit.test' interface *) | |
1 | ||
0 | 2 | let (|>) x f = f x |
1 | 3 | |
2 | 4 | module Q = QCheck |
21 | 23 | Q.int |
22 | 24 | (fun _ -> raise Error) |
23 | 25 | |
26 | let neg_test_failing_as_expected = | |
27 | Q.Test.make_neg ~name:"neg test pass (failing as expected)" QCheck.small_int (fun i -> i mod 2 = 0) | |
28 | ||
29 | let neg_test_unexpected_success = | |
30 | Q.Test.make_neg ~name:"neg test unexpected success" QCheck.small_int (fun i -> i + i = i * 2) | |
31 | ||
32 | let neg_test_error = | |
33 | Q.Test.make_neg ~name:"neg fail with error" QCheck.small_int (fun _i -> raise Error) | |
34 | ||
24 | 35 | open OUnit |
25 | 36 | |
26 | 37 | let regression_23 = |
36 | 47 | [ passing; |
37 | 48 | failing; |
38 | 49 | error; |
50 | neg_test_failing_as_expected; | |
51 | neg_test_unexpected_success; | |
52 | neg_test_error; | |
39 | 53 | ] |> List.map (fun t -> QCheck_ounit.to_ounit_test t) |
40 | 54 | |
41 | 55 | let suite = |
0 | (* -*- tuareg -*- *) | |
1 | ||
2 | let dune = Printf.sprintf {| | |
0 | 3 | |
1 | 4 | (executables |
2 | 5 | (names QCheck_ounit_test QCheck_test) |
5 | 8 | (rule |
6 | 9 | (targets output.txt) |
7 | 10 | (deps ./QCheck_ounit_test.exe) |
8 | (enabled_if (= %{os_type} "Unix")) | |
11 | (enabled_if (= %%{os_type} "Unix")) | |
9 | 12 | (action |
10 | 13 | (with-accepted-exit-codes |
11 | 14 | 1 |
12 | 15 | (with-stdout-to |
13 | %{targets} | |
16 | %%{targets} | |
14 | 17 | (run ./run_ounit.sh -runner=sequential -seed 1234))))) |
15 | 18 | |
16 | 19 | (rule |
17 | 20 | (alias runtest) |
18 | 21 | (package qcheck-ounit) |
19 | (enabled_if (= %{os_type} "Unix")) | |
20 | (action (diff output.txt.expected output.txt))) | |
22 | (enabled_if (= %%{os_type} "Unix")) | |
23 | (action (diff output.txt.expected.%i output.txt))) | |
24 | ||
25 | |} Sys.word_size | |
26 | ||
27 | let () = Jbuild_plugin.V1.send dune |
0 | .FEF. | |
1 | ============================================================================== | |
2 | Error: tests:2:error_raise_exn. | |
3 | ||
4 | Error: tests:2:error_raise_exn (in the log). | |
5 | ||
6 | ||
7 | test `error_raise_exn` raised exception `Dune__exe__QCheck_ounit_test.Error` | |
8 | on `0 (after 63 shrink steps)` | |
9 | ||
10 | ------------------------------------------------------------------------------ | |
11 | ============================================================================== | |
12 | Error: tests:3:fail_check_err_message. | |
13 | ||
14 | Error: tests:3:fail_check_err_message (in the log). | |
15 | ||
16 | Error: tests:3:fail_check_err_message (in the code). | |
17 | ||
18 | ||
19 | test `fail_check_err_message` failed on ≥ 1 cases: | |
20 | 0 (after 7 shrink steps) | |
21 | this | |
22 | will | |
23 | always | |
24 | fail | |
25 | ||
26 | ||
27 | ||
28 | ------------------------------------------------------------------------------ | |
29 | ============================================================================== | |
30 | Error: tests:1:fail_sort_id. | |
31 | ||
32 | Error: tests:1:fail_sort_id (in the log). | |
33 | ||
34 | Error: tests:1:fail_sort_id (in the code). | |
35 | ||
36 | ||
37 | test `fail_sort_id` failed on ≥ 1 cases: [1; 0] (after 20 shrink steps) | |
38 | ||
39 | ||
40 | ------------------------------------------------------------------------------ | |
41 | Ran: 5 tests in: <nondet> seconds. | |
42 | FAILED: Cases: 5 Tried: 5 Errors: 1 Failures: 2 Skip: 0 Todo: 0 Timeouts: 0. |
0 | .FE.FEF. | |
1 | ============================================================================== | |
2 | Error: tests:5:neg fail with error. | |
3 | ||
4 | Error: tests:5:neg fail with error (in the log). | |
5 | ||
6 | ||
7 | test `neg fail with error` | |
8 | raised exception `Dune__exe__QCheck_ounit_test.Error` | |
9 | on `0 (after 7 shrink steps)` | |
10 | ||
11 | ------------------------------------------------------------------------------ | |
12 | ============================================================================== | |
13 | Error: tests:2:error_raise_exn. | |
14 | ||
15 | Error: tests:2:error_raise_exn (in the log). | |
16 | ||
17 | ||
18 | test `error_raise_exn` raised exception `Dune__exe__QCheck_ounit_test.Error` | |
19 | on `0 (after 31 shrink steps)` | |
20 | ||
21 | ------------------------------------------------------------------------------ | |
22 | ============================================================================== | |
23 | Error: tests:6:fail_check_err_message. | |
24 | ||
25 | Error: tests:6:fail_check_err_message (in the log). | |
26 | ||
27 | Error: tests:6:fail_check_err_message (in the code). | |
28 | ||
29 | ||
30 | test `fail_check_err_message` failed on ≥ 1 cases: | |
31 | 0 (after 7 shrink steps) | |
32 | this | |
33 | will | |
34 | always | |
35 | fail | |
36 | ||
37 | ||
38 | ||
39 | ------------------------------------------------------------------------------ | |
40 | ============================================================================== | |
41 | Error: tests:4:neg test unexpected success. | |
42 | ||
43 | Error: tests:4:neg test unexpected success (in the log). | |
44 | ||
45 | Error: tests:4:neg test unexpected success (in the code). | |
46 | ||
47 | ||
48 | negative test 'neg test unexpected success' succeeded unexpectedly | |
49 | ||
50 | ------------------------------------------------------------------------------ | |
51 | ============================================================================== | |
52 | Error: tests:1:fail_sort_id. | |
53 | ||
54 | Error: tests:1:fail_sort_id (in the log). | |
55 | ||
56 | Error: tests:1:fail_sort_id (in the code). | |
57 | ||
58 | ||
59 | test `fail_sort_id` failed on ≥ 1 cases: [1; 0] (after 11 shrink steps) | |
60 | ||
61 | ||
62 | ------------------------------------------------------------------------------ | |
63 | Ran: 8 tests in: <nondet> seconds. | |
64 | FAILED: Cases: 8 Tried: 8 Errors: 2 Failures: 3 Skip: 0 Todo: 0 Timeouts: 0. |
0 | .FE.FEF. | |
1 | ============================================================================== | |
2 | Error: tests:5:neg fail with error. | |
3 | ||
4 | Error: tests:5:neg fail with error (in the log). | |
5 | ||
6 | ||
7 | test `neg fail with error` | |
8 | raised exception `Dune__exe__QCheck_ounit_test.Error` | |
9 | on `0 (after 7 shrink steps)` | |
10 | ||
11 | ------------------------------------------------------------------------------ | |
12 | ============================================================================== | |
13 | Error: tests:2:error_raise_exn. | |
14 | ||
15 | Error: tests:2:error_raise_exn (in the log). | |
16 | ||
17 | ||
18 | test `error_raise_exn` raised exception `Dune__exe__QCheck_ounit_test.Error` | |
19 | on `0 (after 63 shrink steps)` | |
20 | ||
21 | ------------------------------------------------------------------------------ | |
22 | ============================================================================== | |
23 | Error: tests:6:fail_check_err_message. | |
24 | ||
25 | Error: tests:6:fail_check_err_message (in the log). | |
26 | ||
27 | Error: tests:6:fail_check_err_message (in the code). | |
28 | ||
29 | ||
30 | test `fail_check_err_message` failed on ≥ 1 cases: | |
31 | 0 (after 7 shrink steps) | |
32 | this | |
33 | will | |
34 | always | |
35 | fail | |
36 | ||
37 | ||
38 | ||
39 | ------------------------------------------------------------------------------ | |
40 | ============================================================================== | |
41 | Error: tests:4:neg test unexpected success. | |
42 | ||
43 | Error: tests:4:neg test unexpected success (in the log). | |
44 | ||
45 | Error: tests:4:neg test unexpected success (in the code). | |
46 | ||
47 | ||
48 | negative test 'neg test unexpected success' succeeded unexpectedly | |
49 | ||
50 | ------------------------------------------------------------------------------ | |
51 | ============================================================================== | |
52 | Error: tests:1:fail_sort_id. | |
53 | ||
54 | Error: tests:1:fail_sort_id (in the log). | |
55 | ||
56 | Error: tests:1:fail_sort_id (in the code). | |
57 | ||
58 | ||
59 | test `fail_sort_id` failed on ≥ 1 cases: [1; 0] (after 11 shrink steps) | |
60 | ||
61 | ||
62 | ------------------------------------------------------------------------------ | |
63 | Ran: 8 tests in: <nondet> seconds. | |
64 | FAILED: Cases: 8 Tried: 8 Errors: 2 Failures: 3 Skip: 0 Todo: 0 Timeouts: 0. |
0 | random seed: 1234 | |
1 | ||
2 | --- Failure -------------------------------------------------------------------- | |
3 | ||
4 | Test should_fail_sort_id failed (18 shrink steps): | |
5 | ||
6 | [1; 0] | |
7 | ||
8 | === Error ====================================================================== | |
9 | ||
10 | Test should_error_raise_exn errored on (63 shrink steps): | |
11 | ||
12 | 0 | |
13 | ||
14 | exception Dune__exe__QCheck_runner_test.Error | |
15 | ||
16 | ||
17 | +++ Collect ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
18 | ||
19 | Collect results for test collect_results: | |
20 | ||
21 | 4: 20 cases | |
22 | 3: 25 cases | |
23 | 2: 17 cases | |
24 | 1: 18 cases | |
25 | 0: 20 cases | |
26 | ||
27 | +++ Stats for with_stats ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
28 | ||
29 | stats mod4: | |
30 | num: 100, avg: 1.68, stddev: 1.09, median 2, min 0, max 3 | |
31 | 0: ############################## 17 | |
32 | 1: ################################################### 29 | |
33 | 2: ######################################## 23 | |
34 | 3: ####################################################### 31 | |
35 | ||
36 | stats num: | |
37 | num: 100, avg: 66.84, stddev: 31.94, median 65, min 2, max 120 | |
38 | 2.. 7: ################## 3 | |
39 | 8.. 13: ################## 3 | |
40 | 14.. 19: 0 | |
41 | 20.. 25: ########################################## 7 | |
42 | 26.. 31: ######################## 4 | |
43 | 32.. 37: ######################## 4 | |
44 | 38.. 43: ################## 3 | |
45 | 44.. 49: ################################################ 8 | |
46 | 50.. 55: #################################### 6 | |
47 | 56.. 61: #################################### 6 | |
48 | 62.. 67: ####################################################### 9 | |
49 | 68.. 73: ########################################## 7 | |
50 | 74.. 79: ######################## 4 | |
51 | 80.. 85: ################## 3 | |
52 | 86.. 91: ############ 2 | |
53 | 92.. 97: ########################################## 7 | |
54 | 98..103: #################################### 6 | |
55 | 104..109: #################################### 6 | |
56 | 110..115: ####################################################### 9 | |
57 | 116..121: ################## 3 | |
58 | ||
59 | --- Failure -------------------------------------------------------------------- | |
60 | ||
61 | Test FAIL_pred_map_commute failed (127 shrink steps): | |
62 | ||
63 | ([3], {_ -> 0}, {3 -> false; _ -> true}) | |
64 | ||
65 | --- Failure -------------------------------------------------------------------- | |
66 | ||
67 | Test FAIL_fun2_pred_strings failed (1 shrink steps): | |
68 | ||
69 | {some random string -> true; _ -> false} | |
70 | ||
71 | --- Failure -------------------------------------------------------------------- | |
72 | ||
73 | Test fold_left fold_right failed (25 shrink steps): | |
74 | ||
75 | (0, [1], {(1, 0) -> 1; _ -> 0}) | |
76 | ||
77 | +++ Messages ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
78 | ||
79 | Messages for test fold_left fold_right: | |
80 | ||
81 | l=[1], fold_left=1, fold_right=0 | |
82 | ||
83 | ||
84 | --- Failure -------------------------------------------------------------------- | |
85 | ||
86 | Test fold_left fold_right uncurried failed (111 shrink steps): | |
87 | ||
88 | ({(5, 7) -> 0; _ -> 7}, 0, [5; 0]) | |
89 | ||
90 | --- Failure -------------------------------------------------------------------- | |
91 | ||
92 | Test long_shrink failed (149 shrink steps): | |
93 | ||
94 | ([0], [-1]) | |
95 | ||
96 | --- Failure -------------------------------------------------------------------- | |
97 | ||
98 | Test mod3_should_fail failed (84 shrink steps): | |
99 | ||
100 | -21 | |
101 | ||
102 | +++ Stats for stats_neg ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
103 | ||
104 | stats dist: | |
105 | num: 5000, avg: 0.17, stddev: 29.68, median 0, min -99, max 99 | |
106 | -99..-90: # 65 | |
107 | -89..-80: # 63 | |
108 | -79..-70: # 64 | |
109 | -69..-60: # 58 | |
110 | -59..-50: # 67 | |
111 | -49..-40: # 72 | |
112 | -39..-30: # 61 | |
113 | -29..-20: # 61 | |
114 | -19..-10: # 67 | |
115 | -9.. 0: ####################################################### 2076 | |
116 | 1.. 10: ############################################## 1764 | |
117 | 11.. 20: # 66 | |
118 | 21.. 30: # 64 | |
119 | 31.. 40: # 64 | |
120 | 41.. 50: # 67 | |
121 | 51.. 60: # 60 | |
122 | 61.. 70: # 75 | |
123 | 71.. 80: # 60 | |
124 | 81.. 90: # 60 | |
125 | 91..100: # 66 | |
126 | ||
127 | !!! Warning !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
128 | ||
129 | Warning for test WARN_unlikely_precond: | |
130 | ||
131 | WARNING: only 0.5% tests (of 2000) passed precondition for "WARN_unlikely_precond" | |
132 | ||
133 | NOTE: it is likely that the precondition is too strong, or that the generator is buggy. | |
134 | ||
135 | --- Failure -------------------------------------------------------------------- | |
136 | ||
137 | Test FAIL_unlikely_precond failed: | |
138 | ||
139 | ERROR: only 0.5% tests (of 2000) passed precondition for "FAIL_unlikely_precond" | |
140 | ||
141 | NOTE: it is likely that the precondition is too strong, or that the generator is buggy. | |
142 | ||
143 | ||
144 | --- Failure -------------------------------------------------------------------- | |
145 | ||
146 | Test FAIL_#99_1 failed: | |
147 | ||
148 | ERROR: uncaught exception in generator for test FAIL_#99_1 after 100 steps: | |
149 | Exception: QCheck.No_example_found("<example>") | |
150 | Backtrace: | |
151 | ||
152 | +++ Stats for stat_display_test_1 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
153 | ||
154 | stats dist: | |
155 | num: 1000, avg: 0.90, stddev: 28.23, median 0, min -99, max 99 | |
156 | -99..-90: # 12 | |
157 | -89..-80: # 11 | |
158 | -79..-70: # 9 | |
159 | -69..-60: 6 | |
160 | -59..-50: # 11 | |
161 | -49..-40: # 13 | |
162 | -39..-30: # 9 | |
163 | -29..-20: # 13 | |
164 | -19..-10: 8 | |
165 | -9.. 0: ####################################################### 453 | |
166 | 1.. 10: ######################################### 340 | |
167 | 11.. 20: # 15 | |
168 | 21.. 30: # 11 | |
169 | 31.. 40: # 12 | |
170 | 41.. 50: # 13 | |
171 | 51.. 60: # 13 | |
172 | 61.. 70: # 16 | |
173 | 71.. 80: # 9 | |
174 | 81.. 90: # 16 | |
175 | 91..100: # 10 | |
176 | ||
177 | +++ Stats for stat_display_test_2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
178 | ||
179 | stats dist: | |
180 | num: 1000, avg: 15.11, stddev: 23.27, median 6, min 0, max 99 | |
181 | 0.. 4: #################################################### 377 | |
182 | 5.. 9: ####################################################### 392 | |
183 | 10.. 14: ## 20 | |
184 | 15.. 19: ## 15 | |
185 | 20.. 24: # 11 | |
186 | 25.. 29: ## 17 | |
187 | 30.. 34: ## 19 | |
188 | 35.. 39: ## 17 | |
189 | 40.. 44: # 10 | |
190 | 45.. 49: # 9 | |
191 | 50.. 54: # 8 | |
192 | 55.. 59: # 9 | |
193 | 60.. 64: ## 15 | |
194 | 65.. 69: # 10 | |
195 | 70.. 74: # 13 | |
196 | 75.. 79: ## 19 | |
197 | 80.. 84: # 11 | |
198 | 85.. 89: # 13 | |
199 | 90.. 94: 5 | |
200 | 95.. 99: # 10 | |
201 | ||
202 | +++ Stats for stat_display_test_3 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
203 | ||
204 | stats dist: | |
205 | num: 1000, avg: 195335.64, stddev: 136803.99, median 195583, min -43624, max 435210 | |
206 | -43624..-19683: ############################################ 52 | |
207 | -19682.. 4259: ######################################## 47 | |
208 | 4260.. 28201: ############################## 36 | |
209 | 28202.. 52143: ############################################ 52 | |
210 | 52144.. 76085: ########################################## 50 | |
211 | 76086..100027: ####################################################### 64 | |
212 | 100028..123969: ############################################### 55 | |
213 | 123970..147911: ######################################## 47 | |
214 | 147912..171853: ############################################## 54 | |
215 | 171854..195795: #################################### 43 | |
216 | 195796..219737: ############################################## 54 | |
217 | 219738..243679: ########################################### 51 | |
218 | 243680..267621: ################################################ 57 | |
219 | 267622..291563: ########################################## 49 | |
220 | 291564..315505: #################################### 42 | |
221 | 315506..339447: ###################################### 45 | |
222 | 339448..363389: ################################################ 57 | |
223 | 363390..387331: ###################################### 45 | |
224 | 387332..411273: ########################################## 49 | |
225 | 411274..435215: ########################################### 51 | |
226 | ||
227 | +++ Stats for stat_display_test_4 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
228 | ||
229 | stats dist: | |
230 | num: 1000, avg: -173.78, stddev: 23042.92, median 180, min -39859, max 39942 | |
231 | -39859..-35869: ############################################# 56 | |
232 | -35868..-31878: ################################### 43 | |
233 | -31877..-27887: ################################################# 60 | |
234 | -27886..-23896: ##################################### 46 | |
235 | -23895..-19905: ######################################## 49 | |
236 | -19904..-15914: #################################### 45 | |
237 | -15913..-11923: ############################################ 54 | |
238 | -11922.. -7932: ############################################### 58 | |
239 | -7931.. -3941: ######################################### 51 | |
240 | -3940.. 50: ############################ 35 | |
241 | 51.. 4041: ####################################### 48 | |
242 | 4042.. 8032: ########################################## 52 | |
243 | 8033.. 12023: ######################################### 51 | |
244 | 12024.. 16014: ########################################### 53 | |
245 | 16015.. 20005: ############################################ 54 | |
246 | 20006.. 23996: ################################## 42 | |
247 | 23997.. 27987: ####################################################### 67 | |
248 | 27988.. 31978: ################################ 40 | |
249 | 31979.. 35969: ######################################### 51 | |
250 | 35970.. 39960: #################################### 45 | |
251 | ||
252 | +++ Stats for stat_display_test_5 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
253 | ||
254 | stats dist: | |
255 | num: 1000, avg: 0.02, stddev: 2.55, median 0, min -4, max 4 | |
256 | -4: ############################################ 99 | |
257 | -3: ##################################################### 118 | |
258 | -2: ################################################## 111 | |
259 | -1: ################################################## 113 | |
260 | 0: ################################################## 113 | |
261 | 1: ##################################################### 118 | |
262 | 2: ############################################# 102 | |
263 | 3: ####################################################### 122 | |
264 | 4: ############################################## 104 | |
265 | ||
266 | +++ Stats for stat_display_test_6 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
267 | ||
268 | stats dist: | |
269 | num: 1000, avg: 6.67, stddev: 6.39, median 7, min -4, max 17 | |
270 | -4..-3: ############################################# 90 | |
271 | -2..-1: ############################################# 91 | |
272 | 0.. 1: ########################################## 84 | |
273 | 2.. 3: ############################################## 92 | |
274 | 4.. 5: ########################################### 87 | |
275 | 6.. 7: ########################################### 86 | |
276 | 8.. 9: ############################################ 89 | |
277 | 10..11: ########################################### 87 | |
278 | 12..13: ####################################################### 110 | |
279 | 14..15: ############################################# 91 | |
280 | 16..17: ############################################## 93 | |
281 | 18..19: 0 | |
282 | 20..21: 0 | |
283 | 22..23: 0 | |
284 | 24..25: 0 | |
285 | 26..27: 0 | |
286 | 28..29: 0 | |
287 | 30..31: 0 | |
288 | 32..33: 0 | |
289 | 34..35: 0 | |
290 | ||
291 | +++ Stats for stat_display_test_7 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
292 | ||
293 | stats dist: | |
294 | num: 100000, avg: 2541076923587387.50, stddev: 2660730801206827008.00, median 158655268318060, min -4611522359435274428, max 4611540922436307689 | |
295 | -4611522359435274428..-4150369195341695293: ##################################################### 4976 | |
296 | -4150369195341695292..-3689216031248116157: ##################################################### 4963 | |
297 | -3689216031248116156..-3228062867154537021: ###################################################### 5038 | |
298 | -3228062867154537020..-2766909703060957885: ##################################################### 4979 | |
299 | -2766909703060957884..-2305756538967378749: ##################################################### 5001 | |
300 | -2305756538967378748..-1844603374873799613: ##################################################### 4982 | |
301 | -1844603374873799612..-1383450210780220477: ##################################################### 5025 | |
302 | -1383450210780220476.. -922297046686641341: #################################################### 4901 | |
303 | -922297046686641340.. -461143882593062205: ####################################################### 5126 | |
304 | -461143882593062204.. 9281500516931: ##################################################### 5008 | |
305 | 9281500516932.. 461162445594096067: ###################################################### 5041 | |
306 | 461162445594096068.. 922315609687675203: ##################################################### 5001 | |
307 | 922315609687675204.. 1383468773781254339: ##################################################### 4986 | |
308 | 1383468773781254340.. 1844621937874833475: ##################################################### 4949 | |
309 | 1844621937874833476.. 2305775101968412611: ##################################################### 5025 | |
310 | 2305775101968412612.. 2766928266061991747: ##################################################### 5022 | |
311 | 2766928266061991748.. 3228081430155570883: ##################################################### 4958 | |
312 | 3228081430155570884.. 3689234594249150019: ##################################################### 4998 | |
313 | 3689234594249150020.. 4150387758342729155: ##################################################### 4982 | |
314 | 4150387758342729156.. 4611540922436308291: ###################################################### 5039 | |
315 | ================================================================================ | |
316 | 1 warning(s) | |
317 | failure (9 tests failed, 1 tests errored, ran 25 tests) |
0 | random seed: 1234 | |
1 | ||
2 | --- Failure -------------------------------------------------------------------- | |
3 | ||
4 | Test should_fail_sort_id failed (13 shrink steps): | |
5 | ||
6 | [1; 0] | |
7 | ||
8 | === Error ====================================================================== | |
9 | ||
10 | Test should_error_raise_exn errored on (31 shrink steps): | |
11 | ||
12 | 0 | |
13 | ||
14 | exception Dune__exe__QCheck_runner_test.Error | |
15 | ||
16 | ||
17 | +++ Collect ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
18 | ||
19 | Collect results for test collect_results: | |
20 | ||
21 | 4: 20 cases | |
22 | 3: 25 cases | |
23 | 2: 17 cases | |
24 | 1: 18 cases | |
25 | 0: 20 cases | |
26 | ||
27 | +++ Stats for with_stats ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
28 | ||
29 | stats mod4: | |
30 | num: 100, avg: 1.68, stddev: 1.09, median 2, min 0, max 3 | |
31 | 0: ############################## 17 | |
32 | 1: ################################################### 29 | |
33 | 2: ######################################## 23 | |
34 | 3: ####################################################### 31 | |
35 | ||
36 | stats num: | |
37 | num: 100, avg: 66.84, stddev: 31.94, median 65, min 2, max 120 | |
38 | 2.. 7: ################## 3 | |
39 | 8.. 13: ################## 3 | |
40 | 14.. 19: 0 | |
41 | 20.. 25: ########################################## 7 | |
42 | 26.. 31: ######################## 4 | |
43 | 32.. 37: ######################## 4 | |
44 | 38.. 43: ################## 3 | |
45 | 44.. 49: ################################################ 8 | |
46 | 50.. 55: #################################### 6 | |
47 | 56.. 61: #################################### 6 | |
48 | 62.. 67: ####################################################### 9 | |
49 | 68.. 73: ########################################## 7 | |
50 | 74.. 79: ######################## 4 | |
51 | 80.. 85: ################## 3 | |
52 | 86.. 91: ############ 2 | |
53 | 92.. 97: ########################################## 7 | |
54 | 98..103: #################################### 6 | |
55 | 104..109: #################################### 6 | |
56 | 110..115: ####################################################### 9 | |
57 | 116..121: ################## 3 | |
58 | ||
59 | --- Failure -------------------------------------------------------------------- | |
60 | ||
61 | Test neg test unexpected success failed: | |
62 | ||
63 | Negative test neg test unexpected success succeeded but was expected to fail | |
64 | ||
65 | === Error ====================================================================== | |
66 | ||
67 | Test neg fail with error errored on (7 shrink steps): | |
68 | ||
69 | 0 | |
70 | ||
71 | exception Dune__exe__QCheck_runner_test.Error | |
72 | ||
73 | ||
74 | --- Failure -------------------------------------------------------------------- | |
75 | ||
76 | Test FAIL_pred_map_commute failed (47 shrink steps): | |
77 | ||
78 | ([1], {_ -> 0}, {0 -> false; _ -> true}) | |
79 | ||
80 | --- Failure -------------------------------------------------------------------- | |
81 | ||
82 | Test FAIL_fun2_pred_strings failed (1 shrink steps): | |
83 | ||
84 | {some other string -> false; _ -> true} | |
85 | ||
86 | --- Failure -------------------------------------------------------------------- | |
87 | ||
88 | Test fold_left fold_right failed (34 shrink steps): | |
89 | ||
90 | (0, [1], {(1, 0) -> 1; _ -> 0}) | |
91 | ||
92 | +++ Messages ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
93 | ||
94 | Messages for test fold_left fold_right: | |
95 | ||
96 | l=[1], fold_left=1, fold_right=0 | |
97 | ||
98 | ||
99 | --- Failure -------------------------------------------------------------------- | |
100 | ||
101 | Test fold_left fold_right uncurried failed (44 shrink steps): | |
102 | ||
103 | ({(0, 7) -> 1; _ -> 0}, 0, [7]) | |
104 | ||
105 | --- Failure -------------------------------------------------------------------- | |
106 | ||
107 | Test long_shrink failed (87 shrink steps): | |
108 | ||
109 | ([0], [-1]) | |
110 | ||
111 | --- Failure -------------------------------------------------------------------- | |
112 | ||
113 | Test mod3_should_fail failed (34 shrink steps): | |
114 | ||
115 | -21 | |
116 | ||
117 | +++ Stats for stats_neg ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
118 | ||
119 | stats dist: | |
120 | num: 5000, avg: 0.17, stddev: 29.68, median 0, min -99, max 99 | |
121 | -99..-90: # 65 | |
122 | -89..-80: # 63 | |
123 | -79..-70: # 64 | |
124 | -69..-60: # 58 | |
125 | -59..-50: # 67 | |
126 | -49..-40: # 72 | |
127 | -39..-30: # 61 | |
128 | -29..-20: # 61 | |
129 | -19..-10: # 67 | |
130 | -9.. 0: ####################################################### 2076 | |
131 | 1.. 10: ############################################## 1764 | |
132 | 11.. 20: # 66 | |
133 | 21.. 30: # 64 | |
134 | 31.. 40: # 64 | |
135 | 41.. 50: # 67 | |
136 | 51.. 60: # 60 | |
137 | 61.. 70: # 75 | |
138 | 71.. 80: # 60 | |
139 | 81.. 90: # 60 | |
140 | 91..100: # 66 | |
141 | ||
142 | !!! Warning !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
143 | ||
144 | Warning for test WARN_unlikely_precond: | |
145 | ||
146 | WARNING: only 0.6% tests (of 2000) passed precondition for "WARN_unlikely_precond" | |
147 | ||
148 | NOTE: it is likely that the precondition is too strong, or that the generator is buggy. | |
149 | ||
150 | --- Failure -------------------------------------------------------------------- | |
151 | ||
152 | Test FAIL_unlikely_precond failed: | |
153 | ||
154 | ERROR: only 0.6% tests (of 2000) passed precondition for "FAIL_unlikely_precond" | |
155 | ||
156 | NOTE: it is likely that the precondition is too strong, or that the generator is buggy. | |
157 | ||
158 | ||
159 | --- Failure -------------------------------------------------------------------- | |
160 | ||
161 | Test FAIL_#99_1 failed: | |
162 | ||
163 | ERROR: uncaught exception in generator for test FAIL_#99_1 after 100 steps: | |
164 | Exception: QCheck.No_example_found("<example>") | |
165 | Backtrace: | |
166 | ||
167 | +++ Stats for stat_display_test_1 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
168 | ||
169 | stats dist: | |
170 | num: 1000, avg: 0.90, stddev: 28.23, median 0, min -99, max 99 | |
171 | -99..-90: # 12 | |
172 | -89..-80: # 11 | |
173 | -79..-70: # 9 | |
174 | -69..-60: 6 | |
175 | -59..-50: # 11 | |
176 | -49..-40: # 13 | |
177 | -39..-30: # 9 | |
178 | -29..-20: # 13 | |
179 | -19..-10: 8 | |
180 | -9.. 0: ####################################################### 453 | |
181 | 1.. 10: ######################################### 340 | |
182 | 11.. 20: # 15 | |
183 | 21.. 30: # 11 | |
184 | 31.. 40: # 12 | |
185 | 41.. 50: # 13 | |
186 | 51.. 60: # 13 | |
187 | 61.. 70: # 16 | |
188 | 71.. 80: # 9 | |
189 | 81.. 90: # 16 | |
190 | 91..100: # 10 | |
191 | ||
192 | +++ Stats for stat_display_test_2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
193 | ||
194 | stats dist: | |
195 | num: 1000, avg: 15.11, stddev: 23.27, median 6, min 0, max 99 | |
196 | 0.. 4: #################################################### 377 | |
197 | 5.. 9: ####################################################### 392 | |
198 | 10.. 14: ## 20 | |
199 | 15.. 19: ## 15 | |
200 | 20.. 24: # 11 | |
201 | 25.. 29: ## 17 | |
202 | 30.. 34: ## 19 | |
203 | 35.. 39: ## 17 | |
204 | 40.. 44: # 10 | |
205 | 45.. 49: # 9 | |
206 | 50.. 54: # 8 | |
207 | 55.. 59: # 9 | |
208 | 60.. 64: ## 15 | |
209 | 65.. 69: # 10 | |
210 | 70.. 74: # 13 | |
211 | 75.. 79: ## 19 | |
212 | 80.. 84: # 11 | |
213 | 85.. 89: # 13 | |
214 | 90.. 94: 5 | |
215 | 95.. 99: # 10 | |
216 | ||
217 | +++ Stats for stat_display_test_3 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
218 | ||
219 | stats dist: | |
220 | num: 1000, avg: 195335.64, stddev: 136803.99, median 195583, min -43624, max 435210 | |
221 | -43624..-19683: ############################################ 52 | |
222 | -19682.. 4259: ######################################## 47 | |
223 | 4260.. 28201: ############################## 36 | |
224 | 28202.. 52143: ############################################ 52 | |
225 | 52144.. 76085: ########################################## 50 | |
226 | 76086..100027: ####################################################### 64 | |
227 | 100028..123969: ############################################### 55 | |
228 | 123970..147911: ######################################## 47 | |
229 | 147912..171853: ############################################## 54 | |
230 | 171854..195795: #################################### 43 | |
231 | 195796..219737: ############################################## 54 | |
232 | 219738..243679: ########################################### 51 | |
233 | 243680..267621: ################################################ 57 | |
234 | 267622..291563: ########################################## 49 | |
235 | 291564..315505: #################################### 42 | |
236 | 315506..339447: ###################################### 45 | |
237 | 339448..363389: ################################################ 57 | |
238 | 363390..387331: ###################################### 45 | |
239 | 387332..411273: ########################################## 49 | |
240 | 411274..435215: ########################################### 51 | |
241 | ||
242 | +++ Stats for stat_display_test_4 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
243 | ||
244 | stats dist: | |
245 | num: 1000, avg: -173.78, stddev: 23042.92, median 180, min -39859, max 39942 | |
246 | -39859..-35869: ############################################# 56 | |
247 | -35868..-31878: ################################### 43 | |
248 | -31877..-27887: ################################################# 60 | |
249 | -27886..-23896: ##################################### 46 | |
250 | -23895..-19905: ######################################## 49 | |
251 | -19904..-15914: #################################### 45 | |
252 | -15913..-11923: ############################################ 54 | |
253 | -11922.. -7932: ############################################### 58 | |
254 | -7931.. -3941: ######################################### 51 | |
255 | -3940.. 50: ############################ 35 | |
256 | 51.. 4041: ####################################### 48 | |
257 | 4042.. 8032: ########################################## 52 | |
258 | 8033.. 12023: ######################################### 51 | |
259 | 12024.. 16014: ########################################### 53 | |
260 | 16015.. 20005: ############################################ 54 | |
261 | 20006.. 23996: ################################## 42 | |
262 | 23997.. 27987: ####################################################### 67 | |
263 | 27988.. 31978: ################################ 40 | |
264 | 31979.. 35969: ######################################### 51 | |
265 | 35970.. 39960: #################################### 45 | |
266 | ||
267 | +++ Stats for stat_display_test_5 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
268 | ||
269 | stats dist: | |
270 | num: 1000, avg: 0.02, stddev: 2.55, median 0, min -4, max 4 | |
271 | -4: ############################################ 99 | |
272 | -3: ##################################################### 118 | |
273 | -2: ################################################## 111 | |
274 | -1: ################################################## 113 | |
275 | 0: ################################################## 113 | |
276 | 1: ##################################################### 118 | |
277 | 2: ############################################# 102 | |
278 | 3: ####################################################### 122 | |
279 | 4: ############################################## 104 | |
280 | ||
281 | +++ Stats for stat_display_test_6 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
282 | ||
283 | stats dist: | |
284 | num: 1000, avg: 6.67, stddev: 6.39, median 7, min -4, max 17 | |
285 | -4..-3: ############################################# 90 | |
286 | -2..-1: ############################################# 91 | |
287 | 0.. 1: ########################################## 84 | |
288 | 2.. 3: ############################################## 92 | |
289 | 4.. 5: ########################################### 87 | |
290 | 6.. 7: ########################################### 86 | |
291 | 8.. 9: ############################################ 89 | |
292 | 10..11: ########################################### 87 | |
293 | 12..13: ####################################################### 110 | |
294 | 14..15: ############################################# 91 | |
295 | 16..17: ############################################## 93 | |
296 | 18..19: 0 | |
297 | 20..21: 0 | |
298 | 22..23: 0 | |
299 | 24..25: 0 | |
300 | 26..27: 0 | |
301 | 28..29: 0 | |
302 | 30..31: 0 | |
303 | 32..33: 0 | |
304 | 34..35: 0 | |
305 | ||
306 | +++ Stats for stat_display_test_7 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
307 | ||
308 | stats dist: | |
309 | num: 100000, avg: 336840.90, stddev: 619301756.02, median 895228, min -1073728193, max 1073739280 | |
310 | -1073728193.. -966354820: ##################################################### 5009 | |
311 | -966354819.. -858981446: #################################################### 5004 | |
312 | -858981445.. -751608072: #################################################### 4917 | |
313 | -751608071.. -644234698: ##################################################### 5028 | |
314 | -644234697.. -536861324: #################################################### 4962 | |
315 | -536861323.. -429487950: ##################################################### 5039 | |
316 | -429487949.. -322114576: #################################################### 4927 | |
317 | -322114575.. -214741202: ##################################################### 5054 | |
318 | -214741201.. -107367828: ##################################################### 5065 | |
319 | -107367827.. 5546: #################################################### 4954 | |
320 | 5547.. 107378920: #################################################### 4943 | |
321 | 107378921.. 214752294: ################################################### 4900 | |
322 | 214752295.. 322125668: ###################################################### 5126 | |
323 | 322125669.. 429499042: ####################################################### 5198 | |
324 | 429499043.. 536872416: #################################################### 4988 | |
325 | 536872417.. 644245790: #################################################### 4940 | |
326 | 644245791.. 751619164: #################################################### 5002 | |
327 | 751619165.. 858992538: #################################################### 4928 | |
328 | 858992539.. 966365912: ##################################################### 5070 | |
329 | 966365913.. 1073739286: #################################################### 4946 | |
330 | ================================================================================ | |
331 | 1 warning(s) | |
332 | failure (10 tests failed, 2 tests errored, ran 28 tests) |
0 | random seed: 1234 | |
1 | ||
2 | --- Failure -------------------------------------------------------------------- | |
3 | ||
4 | Test should_fail_sort_id failed (13 shrink steps): | |
5 | ||
6 | [1; 0] | |
7 | ||
8 | === Error ====================================================================== | |
9 | ||
10 | Test should_error_raise_exn errored on (63 shrink steps): | |
11 | ||
12 | 0 | |
13 | ||
14 | exception Dune__exe__QCheck_runner_test.Error | |
15 | ||
16 | ||
17 | +++ Collect ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
18 | ||
19 | Collect results for test collect_results: | |
20 | ||
21 | 4: 20 cases | |
22 | 3: 25 cases | |
23 | 2: 17 cases | |
24 | 1: 18 cases | |
25 | 0: 20 cases | |
26 | ||
27 | +++ Stats for with_stats ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
28 | ||
29 | stats mod4: | |
30 | num: 100, avg: 1.68, stddev: 1.09, median 2, min 0, max 3 | |
31 | 0: ############################## 17 | |
32 | 1: ################################################### 29 | |
33 | 2: ######################################## 23 | |
34 | 3: ####################################################### 31 | |
35 | ||
36 | stats num: | |
37 | num: 100, avg: 66.84, stddev: 31.94, median 65, min 2, max 120 | |
38 | 2.. 7: ################## 3 | |
39 | 8.. 13: ################## 3 | |
40 | 14.. 19: 0 | |
41 | 20.. 25: ########################################## 7 | |
42 | 26.. 31: ######################## 4 | |
43 | 32.. 37: ######################## 4 | |
44 | 38.. 43: ################## 3 | |
45 | 44.. 49: ################################################ 8 | |
46 | 50.. 55: #################################### 6 | |
47 | 56.. 61: #################################### 6 | |
48 | 62.. 67: ####################################################### 9 | |
49 | 68.. 73: ########################################## 7 | |
50 | 74.. 79: ######################## 4 | |
51 | 80.. 85: ################## 3 | |
52 | 86.. 91: ############ 2 | |
53 | 92.. 97: ########################################## 7 | |
54 | 98..103: #################################### 6 | |
55 | 104..109: #################################### 6 | |
56 | 110..115: ####################################################### 9 | |
57 | 116..121: ################## 3 | |
58 | ||
59 | --- Failure -------------------------------------------------------------------- | |
60 | ||
61 | Test neg test unexpected success failed: | |
62 | ||
63 | Negative test neg test unexpected success succeeded but was expected to fail | |
64 | ||
65 | === Error ====================================================================== | |
66 | ||
67 | Test neg fail with error errored on (7 shrink steps): | |
68 | ||
69 | 0 | |
70 | ||
71 | exception Dune__exe__QCheck_runner_test.Error | |
72 | ||
73 | ||
74 | --- Failure -------------------------------------------------------------------- | |
75 | ||
76 | Test FAIL_pred_map_commute failed (77 shrink steps): | |
77 | ||
78 | ([1], {_ -> 0}, {1 -> true; _ -> false}) | |
79 | ||
80 | --- Failure -------------------------------------------------------------------- | |
81 | ||
82 | Test FAIL_fun2_pred_strings failed (1 shrink steps): | |
83 | ||
84 | {some other string -> false; _ -> true} | |
85 | ||
86 | --- Failure -------------------------------------------------------------------- | |
87 | ||
88 | Test fold_left fold_right failed (34 shrink steps): | |
89 | ||
90 | (0, [1], {(1, 0) -> 1; _ -> 0}) | |
91 | ||
92 | +++ Messages ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
93 | ||
94 | Messages for test fold_left fold_right: | |
95 | ||
96 | l=[1], fold_left=1, fold_right=0 | |
97 | ||
98 | ||
99 | --- Failure -------------------------------------------------------------------- | |
100 | ||
101 | Test fold_left fold_right uncurried failed (44 shrink steps): | |
102 | ||
103 | ({(0, 7) -> 1; _ -> 0}, 0, [7]) | |
104 | ||
105 | --- Failure -------------------------------------------------------------------- | |
106 | ||
107 | Test long_shrink failed (149 shrink steps): | |
108 | ||
109 | ([0], [-1]) | |
110 | ||
111 | --- Failure -------------------------------------------------------------------- | |
112 | ||
113 | Test mod3_should_fail failed (84 shrink steps): | |
114 | ||
115 | -21 | |
116 | ||
117 | +++ Stats for stats_neg ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
118 | ||
119 | stats dist: | |
120 | num: 5000, avg: 0.17, stddev: 29.68, median 0, min -99, max 99 | |
121 | -99..-90: # 65 | |
122 | -89..-80: # 63 | |
123 | -79..-70: # 64 | |
124 | -69..-60: # 58 | |
125 | -59..-50: # 67 | |
126 | -49..-40: # 72 | |
127 | -39..-30: # 61 | |
128 | -29..-20: # 61 | |
129 | -19..-10: # 67 | |
130 | -9.. 0: ####################################################### 2076 | |
131 | 1.. 10: ############################################## 1764 | |
132 | 11.. 20: # 66 | |
133 | 21.. 30: # 64 | |
134 | 31.. 40: # 64 | |
135 | 41.. 50: # 67 | |
136 | 51.. 60: # 60 | |
137 | 61.. 70: # 75 | |
138 | 71.. 80: # 60 | |
139 | 81.. 90: # 60 | |
140 | 91..100: # 66 | |
141 | ||
142 | !!! Warning !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
143 | ||
144 | Warning for test WARN_unlikely_precond: | |
145 | ||
146 | WARNING: only 0.5% tests (of 2000) passed precondition for "WARN_unlikely_precond" | |
147 | ||
148 | NOTE: it is likely that the precondition is too strong, or that the generator is buggy. | |
149 | ||
150 | --- Failure -------------------------------------------------------------------- | |
151 | ||
152 | Test FAIL_unlikely_precond failed: | |
153 | ||
154 | ERROR: only 0.5% tests (of 2000) passed precondition for "FAIL_unlikely_precond" | |
155 | ||
156 | NOTE: it is likely that the precondition is too strong, or that the generator is buggy. | |
157 | ||
158 | ||
159 | --- Failure -------------------------------------------------------------------- | |
160 | ||
161 | Test FAIL_#99_1 failed: | |
162 | ||
163 | ERROR: uncaught exception in generator for test FAIL_#99_1 after 100 steps: | |
164 | Exception: QCheck.No_example_found("<example>") | |
165 | Backtrace: | |
166 | ||
167 | +++ Stats for stat_display_test_1 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
168 | ||
169 | stats dist: | |
170 | num: 1000, avg: 0.90, stddev: 28.23, median 0, min -99, max 99 | |
171 | -99..-90: # 12 | |
172 | -89..-80: # 11 | |
173 | -79..-70: # 9 | |
174 | -69..-60: 6 | |
175 | -59..-50: # 11 | |
176 | -49..-40: # 13 | |
177 | -39..-30: # 9 | |
178 | -29..-20: # 13 | |
179 | -19..-10: 8 | |
180 | -9.. 0: ####################################################### 453 | |
181 | 1.. 10: ######################################### 340 | |
182 | 11.. 20: # 15 | |
183 | 21.. 30: # 11 | |
184 | 31.. 40: # 12 | |
185 | 41.. 50: # 13 | |
186 | 51.. 60: # 13 | |
187 | 61.. 70: # 16 | |
188 | 71.. 80: # 9 | |
189 | 81.. 90: # 16 | |
190 | 91..100: # 10 | |
191 | ||
192 | +++ Stats for stat_display_test_2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
193 | ||
194 | stats dist: | |
195 | num: 1000, avg: 15.11, stddev: 23.27, median 6, min 0, max 99 | |
196 | 0.. 4: #################################################### 377 | |
197 | 5.. 9: ####################################################### 392 | |
198 | 10.. 14: ## 20 | |
199 | 15.. 19: ## 15 | |
200 | 20.. 24: # 11 | |
201 | 25.. 29: ## 17 | |
202 | 30.. 34: ## 19 | |
203 | 35.. 39: ## 17 | |
204 | 40.. 44: # 10 | |
205 | 45.. 49: # 9 | |
206 | 50.. 54: # 8 | |
207 | 55.. 59: # 9 | |
208 | 60.. 64: ## 15 | |
209 | 65.. 69: # 10 | |
210 | 70.. 74: # 13 | |
211 | 75.. 79: ## 19 | |
212 | 80.. 84: # 11 | |
213 | 85.. 89: # 13 | |
214 | 90.. 94: 5 | |
215 | 95.. 99: # 10 | |
216 | ||
217 | +++ Stats for stat_display_test_3 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
218 | ||
219 | stats dist: | |
220 | num: 1000, avg: 195335.64, stddev: 136803.99, median 195583, min -43624, max 435210 | |
221 | -43624..-19683: ############################################ 52 | |
222 | -19682.. 4259: ######################################## 47 | |
223 | 4260.. 28201: ############################## 36 | |
224 | 28202.. 52143: ############################################ 52 | |
225 | 52144.. 76085: ########################################## 50 | |
226 | 76086..100027: ####################################################### 64 | |
227 | 100028..123969: ############################################### 55 | |
228 | 123970..147911: ######################################## 47 | |
229 | 147912..171853: ############################################## 54 | |
230 | 171854..195795: #################################### 43 | |
231 | 195796..219737: ############################################## 54 | |
232 | 219738..243679: ########################################### 51 | |
233 | 243680..267621: ################################################ 57 | |
234 | 267622..291563: ########################################## 49 | |
235 | 291564..315505: #################################### 42 | |
236 | 315506..339447: ###################################### 45 | |
237 | 339448..363389: ################################################ 57 | |
238 | 363390..387331: ###################################### 45 | |
239 | 387332..411273: ########################################## 49 | |
240 | 411274..435215: ########################################### 51 | |
241 | ||
242 | +++ Stats for stat_display_test_4 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
243 | ||
244 | stats dist: | |
245 | num: 1000, avg: -173.78, stddev: 23042.92, median 180, min -39859, max 39942 | |
246 | -39859..-35869: ############################################# 56 | |
247 | -35868..-31878: ################################### 43 | |
248 | -31877..-27887: ################################################# 60 | |
249 | -27886..-23896: ##################################### 46 | |
250 | -23895..-19905: ######################################## 49 | |
251 | -19904..-15914: #################################### 45 | |
252 | -15913..-11923: ############################################ 54 | |
253 | -11922.. -7932: ############################################### 58 | |
254 | -7931.. -3941: ######################################### 51 | |
255 | -3940.. 50: ############################ 35 | |
256 | 51.. 4041: ####################################### 48 | |
257 | 4042.. 8032: ########################################## 52 | |
258 | 8033.. 12023: ######################################### 51 | |
259 | 12024.. 16014: ########################################### 53 | |
260 | 16015.. 20005: ############################################ 54 | |
261 | 20006.. 23996: ################################## 42 | |
262 | 23997.. 27987: ####################################################### 67 | |
263 | 27988.. 31978: ################################ 40 | |
264 | 31979.. 35969: ######################################### 51 | |
265 | 35970.. 39960: #################################### 45 | |
266 | ||
267 | +++ Stats for stat_display_test_5 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
268 | ||
269 | stats dist: | |
270 | num: 1000, avg: 0.02, stddev: 2.55, median 0, min -4, max 4 | |
271 | -4: ############################################ 99 | |
272 | -3: ##################################################### 118 | |
273 | -2: ################################################## 111 | |
274 | -1: ################################################## 113 | |
275 | 0: ################################################## 113 | |
276 | 1: ##################################################### 118 | |
277 | 2: ############################################# 102 | |
278 | 3: ####################################################### 122 | |
279 | 4: ############################################## 104 | |
280 | ||
281 | +++ Stats for stat_display_test_6 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
282 | ||
283 | stats dist: | |
284 | num: 1000, avg: 6.67, stddev: 6.39, median 7, min -4, max 17 | |
285 | -4..-3: ############################################# 90 | |
286 | -2..-1: ############################################# 91 | |
287 | 0.. 1: ########################################## 84 | |
288 | 2.. 3: ############################################## 92 | |
289 | 4.. 5: ########################################### 87 | |
290 | 6.. 7: ########################################### 86 | |
291 | 8.. 9: ############################################ 89 | |
292 | 10..11: ########################################### 87 | |
293 | 12..13: ####################################################### 110 | |
294 | 14..15: ############################################# 91 | |
295 | 16..17: ############################################## 93 | |
296 | 18..19: 0 | |
297 | 20..21: 0 | |
298 | 22..23: 0 | |
299 | 24..25: 0 | |
300 | 26..27: 0 | |
301 | 28..29: 0 | |
302 | 30..31: 0 | |
303 | 32..33: 0 | |
304 | 34..35: 0 | |
305 | ||
306 | +++ Stats for stat_display_test_7 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
307 | ||
308 | stats dist: | |
309 | num: 100000, avg: 2541076923587387.50, stddev: 2660730801206827008.00, median 158655268318060, min -4611522359435274428, max 4611540922436307689 | |
310 | -4611522359435274428..-4150369195341695293: ##################################################### 4976 | |
311 | -4150369195341695292..-3689216031248116157: ##################################################### 4963 | |
312 | -3689216031248116156..-3228062867154537021: ###################################################### 5038 | |
313 | -3228062867154537020..-2766909703060957885: ##################################################### 4979 | |
314 | -2766909703060957884..-2305756538967378749: ##################################################### 5001 | |
315 | -2305756538967378748..-1844603374873799613: ##################################################### 4982 | |
316 | -1844603374873799612..-1383450210780220477: ##################################################### 5025 | |
317 | -1383450210780220476.. -922297046686641341: #################################################### 4901 | |
318 | -922297046686641340.. -461143882593062205: ####################################################### 5126 | |
319 | -461143882593062204.. 9281500516931: ##################################################### 5008 | |
320 | 9281500516932.. 461162445594096067: ###################################################### 5041 | |
321 | 461162445594096068.. 922315609687675203: ##################################################### 5001 | |
322 | 922315609687675204.. 1383468773781254339: ##################################################### 4986 | |
323 | 1383468773781254340.. 1844621937874833475: ##################################################### 4949 | |
324 | 1844621937874833476.. 2305775101968412611: ##################################################### 5025 | |
325 | 2305775101968412612.. 2766928266061991747: ##################################################### 5022 | |
326 | 2766928266061991748.. 3228081430155570883: ##################################################### 4958 | |
327 | 3228081430155570884.. 3689234594249150019: ##################################################### 4998 | |
328 | 3689234594249150020.. 4150387758342729155: ##################################################### 4982 | |
329 | 4150387758342729156.. 4611540922436308291: ###################################################### 5039 | |
330 | ================================================================================ | |
331 | 1 warning(s) | |
332 | failure (10 tests failed, 2 tests errored, ran 28 tests) |
0 | opam-version: "2.0" | |
1 | name: "ppx_deriving_qcheck" | |
2 | version: "0.2.0" | |
3 | license: "BSD-2-Clause" | |
4 | synopsis: "PPX Deriver for QCheck" | |
5 | ||
6 | maintainer: "valentin.chb@gmail.com" | |
7 | author: [ "the qcheck contributors" ] | |
8 | ||
9 | depends: [ | |
10 | "dune" {>= "2.8.0"} | |
11 | "ocaml" {>= "4.08.0"} | |
12 | "qcheck" {>= "0.19"} | |
13 | "ppxlib" {>= "0.22.0"} | |
14 | "ppx_deriving" {>= "5.2.1"} | |
15 | "odoc" {with-doc} | |
16 | "alcotest" {with-test & >= "1.4.0" } | |
17 | "qcheck-alcotest" {with-test & >= "0.17"} | |
18 | ] | |
19 | ||
20 | build: [ | |
21 | ["dune" "build" "-p" name "-j" jobs] | |
22 | ["dune" "build" "@doc" "-p" name "-j" jobs] {with-doc} | |
23 | ["dune" "runtest" "-p" name "-j" jobs] {with-test} | |
24 | ] | |
25 | ||
26 | homepage: "https://github.com/c-cube/qcheck/" | |
27 | bug-reports: "https://github.com/c-cube/qcheck/-/issues" | |
28 | dev-repo: "git+https://github.com/vch9/ppx_deriving_qcheck.git" |
4 | 4 | license: "BSD-2-Clause" |
5 | 5 | synopsis: "Alcotest backend for qcheck" |
6 | 6 | doc: ["http://c-cube.github.io/qcheck/"] |
7 | version: "0.18.1" | |
7 | version: "0.19.1" | |
8 | 8 | tags: [ |
9 | 9 | "test" |
10 | 10 | "quickcheck" |
21 | 21 | "base-bytes" |
22 | 22 | "base-unix" |
23 | 23 | "qcheck-core" { = version } |
24 | "alcotest" | |
24 | "alcotest" {>= "0.8.1"} | |
25 | 25 | "odoc" {with-doc} |
26 | 26 | "ocaml" {>= "4.08.0"} |
27 | "ocaml" {with-test & < "5.0"} | |
27 | 28 | ] |
28 | 29 | dev-repo: "git+https://github.com/c-cube/qcheck.git" |
29 | 30 | bug-reports: "https://github.com/c-cube/qcheck/issues" |
4 | 4 | license: "BSD-2-Clause" |
5 | 5 | synopsis: "Core qcheck library" |
6 | 6 | doc: ["http://c-cube.github.io/qcheck/"] |
7 | version: "0.18.1" | |
7 | version: "0.19.1" | |
8 | 8 | tags: [ |
9 | 9 | "test" |
10 | 10 | "property" |
22 | 22 | "alcotest" {with-test} |
23 | 23 | "odoc" {with-doc} |
24 | 24 | "ocaml" {>= "4.08.0"} |
25 | "ocaml" {with-test & < "5.0"} | |
25 | 26 | ] |
26 | 27 | dev-repo: "git+https://github.com/c-cube/qcheck.git" |
27 | 28 | bug-reports: "https://github.com/c-cube/qcheck/issues" |
4 | 4 | homepage: "https://github.com/c-cube/qcheck/" |
5 | 5 | doc: ["http://c-cube.github.io/qcheck/"] |
6 | 6 | synopsis: "OUnit backend for qcheck" |
7 | version: "0.18.1" | |
7 | version: "0.19.1" | |
8 | 8 | tags: [ |
9 | 9 | "qcheck" |
10 | 10 | "quickcheck" |
23 | 23 | "ounit2" |
24 | 24 | "odoc" {with-doc} |
25 | 25 | "ocaml" {>= "4.08.0"} |
26 | "ocaml" {with-test & < "5.0"} | |
26 | 27 | ] |
27 | 28 | dev-repo: "git+https://github.com/c-cube/qcheck.git" |
28 | 29 | bug-reports: "https://github.com/c-cube/qcheck/issues" |
4 | 4 | homepage: "https://github.com/c-cube/qcheck/" |
5 | 5 | license: "BSD-2-Clause" |
6 | 6 | doc: ["http://c-cube.github.io/qcheck/"] |
7 | version: "0.18.1" | |
7 | version: "0.19.1" | |
8 | 8 | tags: [ |
9 | 9 | "test" |
10 | 10 | "property" |
24 | 24 | "alcotest" {with-test} |
25 | 25 | "odoc" {with-doc} |
26 | 26 | "ocaml" {>= "4.08.0"} |
27 | "ocaml" {with-test & < "5.0"} | |
27 | 28 | ] |
28 | 29 | dev-repo: "git+https://github.com/c-cube/qcheck.git" |
29 | 30 | bug-reports: "https://github.com/c-cube/qcheck/issues" |
32 | 32 | ) |
33 | 33 | |
34 | 34 | let to_alcotest |
35 | ?(verbose=Lazy.force verbose_) ?(long=Lazy.force long_) ?(rand=default_rand()) | |
35 | ?(colors=false) ?(verbose=Lazy.force verbose_) ?(long=Lazy.force long_) | |
36 | ?(debug_shrink = None) ?debug_shrink_list ?(rand=default_rand()) | |
36 | 37 | (t:T.t) = |
37 | 38 | let T.Test cell = t in |
39 | let handler name cell r = | |
40 | match r, debug_shrink with | |
41 | | QCheck2.Test.Shrunk (step, x), Some out -> | |
42 | let go = match debug_shrink_list with | |
43 | | None -> true | |
44 | | Some test_list -> List.mem name test_list in | |
45 | if not go then () | |
46 | else | |
47 | QCheck_base_runner.debug_shrinking_choices | |
48 | ~colors ~out ~name cell ~step x | |
49 | | _ -> | |
50 | () | |
51 | in | |
38 | 52 | let print = Raw.print_std in |
39 | let run() = | |
40 | T.check_cell_exn cell | |
41 | ~long ~rand ~call:(Raw.callback ~colors:false ~verbose ~print_res:true ~print) | |
53 | let name = T.get_name cell in | |
54 | let run () = | |
55 | let call = Raw.callback ~colors ~verbose ~print_res:true ~print in | |
56 | if T.get_positive cell | |
57 | then | |
58 | T.check_cell_exn ~long ~call ~handler ~rand cell | |
59 | else | |
60 | try | |
61 | T.check_cell_exn ~long ~call ~handler ~rand cell; | |
62 | Alcotest.failf "negative test '%s' succeeded unexpectedly" name | |
63 | with | |
64 | T.Test_fail (_name,_l) -> () | |
42 | 65 | in |
43 | let name = T.get_name cell in | |
44 | name, `Slow, run | |
66 | ((name, `Slow, run) : unit Alcotest.test_case) |
11 | 11 | *) |
12 | 12 | |
13 | 13 | val to_alcotest : |
14 | ?verbose:bool -> ?long:bool -> ?rand:Random.State.t -> | |
14 | ?colors:bool -> ?verbose:bool -> ?long:bool -> | |
15 | ?debug_shrink:(out_channel option) -> | |
16 | ?debug_shrink_list:(string list) -> | |
17 | ?rand:Random.State.t -> | |
15 | 18 | QCheck2.Test.t -> unit Alcotest.test_case |
16 | (** Convert a qcheck test into an alcotest test | |
17 | @param verbose used to print information on stdout (default: [verbose()]) | |
18 | @param rand the random generator to use (default: [random_state ()]) | |
19 | (** Convert a qcheck test into an alcotest test. | |
20 | ||
21 | In addition to the environment variables mentioned above, you can control | |
22 | the behavior of QCheck tests using optional parameters that behave in the | |
23 | same way as the parameters of {!QCheck_base_runner.run_tests}. | |
24 | ||
19 | 25 | @since 0.9 |
26 | @since 0.9 parameters [verbose], [long], [rand] | |
27 | @since 0.19 parameters [colors], [debug_shrink], [debug_shrink_list] | |
20 | 28 | *) |
8 | 8 | let poly_compare=compare |
9 | 9 | open Printf |
10 | 10 | |
11 | module RS = Random.State | |
11 | module RS = struct | |
12 | (* Poor man's splitter for version < 5.0 *) | |
13 | (* This definition is shadowed by the [include] on OCaml >=5.0 *) | |
14 | let split rs = | |
15 | let bits = Random.State.bits rs in | |
16 | let rs' = Random.State.make [|bits|] in | |
17 | rs' | |
18 | include Random.State | |
19 | (* This is how OCaml 5.0 splits: *) | |
20 | (* Split a new PRNG off the given PRNG *) | |
21 | (* | |
22 | let split s = | |
23 | let i1 = bits64 s in let i2 = bits64 s in | |
24 | let i3 = bits64 s in let i4 = bits64 s in | |
25 | mk i1 i2 i3 i4 | |
26 | *) | |
27 | end | |
12 | 28 | |
13 | 29 | let (|>) x f = f x |
14 | 30 | |
41 | 57 | | Some x, Some y, Some z, Some w -> Some (f x y z w) |
42 | 58 | | _ -> None |
43 | 59 | |
60 | let _opt_map_5 ~f a b c d e = match a, b, c, d, e with | |
61 | | Some x, Some y, Some z, Some u, Some v -> Some (f x y z u v) | |
62 | | _ -> None | |
63 | ||
64 | let _opt_map_6 ~f a b c d e g = match a, b, c, d, e, g with | |
65 | | Some a, Some b, Some c, Some d, Some e, Some g -> Some (f a b c d e g) | |
66 | | _ -> None | |
67 | ||
68 | let _opt_map_7 ~f a b c d e g h = match a, b, c, d, e, g, h with | |
69 | | Some a, Some b, Some c, Some d, Some e, Some g, Some h -> Some (f a b c d e g h) | |
70 | | _ -> None | |
71 | ||
72 | let _opt_map_8 ~f a b c d e g h i = match a, b, c, d, e, g, h, i with | |
73 | | Some a, Some b, Some c, Some d, Some e, Some g, Some h, Some i -> | |
74 | Some (f a b c d e g h i) | |
75 | | _ -> None | |
76 | ||
77 | let _opt_map_9 ~f a b c d e g h i j = match a, b, c, d, e, g, h, i, j with | |
78 | | Some a, Some b, Some c, Some d, Some e, Some g, Some h, Some i, Some j -> | |
79 | Some (f a b c d e g h i j) | |
80 | | _ -> None | |
81 | ||
44 | 82 | let _opt_sum a b = match a, b with |
45 | 83 | | Some _, _ -> a |
46 | 84 | | None, _ -> b |
47 | 85 | |
48 | 86 | let sum_int = List.fold_left (+) 0 |
87 | ||
88 | (* Included for backwards compatibility, pre 4.13 *) | |
89 | let string_fold_right f s acc = | |
90 | let len = String.length s in | |
91 | let rec loop i acc = | |
92 | if i<0 | |
93 | then acc | |
94 | else loop (i-1) (f s.[i] acc) in | |
95 | loop (len-1) acc | |
49 | 96 | |
50 | 97 | exception No_example_found of string |
51 | 98 | (* raised if an example failed to be found *) |
135 | 182 | |
136 | 183 | let neg_int st = -(nat st) |
137 | 184 | |
138 | let opt ?(ratio = 0.85) f st = | |
185 | let option ?(ratio = 0.85) f st = | |
139 | 186 | let p = RS.float st 1. in |
140 | 187 | if p < (1.0 -. ratio) then None |
141 | 188 | else Some (f st) |
189 | ||
190 | let opt = option | |
142 | 191 | |
143 | 192 | (* Uniform random int generator *) |
144 | 193 | let pint = |
282 | 331 | |
283 | 332 | let char st = char_of_int (RS.int st 256) |
284 | 333 | |
334 | let tup2 = pair | |
335 | ||
336 | let tup3 = triple | |
337 | ||
338 | let tup4 = quad | |
339 | ||
340 | let tup5 (g1 : 'a t) (g2 : 'b t) (g3 : 'c t) (g4 : 'd t) (g5 : 'e t) : ('a * 'b * 'c * 'd * 'e) t = | |
341 | (fun a b c d e -> (a, b, c, d, e)) <$> g1 <*> g2 <*> g3 <*> g4 <*> g5 | |
342 | ||
343 | let tup6 (g1 : 'a t) (g2 : 'b t) (g3 : 'c t) (g4 : 'd t) (g5 : 'e t) (g6 : 'f t) : ('a * 'b * 'c * 'd * 'e * 'f) t = | |
344 | (fun a b c d e f -> (a, b, c, d, e, f)) <$> g1 <*> g2 <*> g3 <*> g4 <*> g5 <*> g6 | |
345 | ||
346 | let tup7 (g1 : 'a t) (g2 : 'b t) (g3 : 'c t) (g4 : 'd t) (g5 : 'e t) (g6 : 'f t) (g7 : 'g t) : ('a * 'b * 'c * 'd * 'e * 'f * 'g) t = | |
347 | (fun a b c d e f g -> (a, b, c, d, e, f, g)) <$> g1 <*> g2 <*> g3 <*> g4 <*> g5 <*> g6 <*> g7 | |
348 | ||
349 | let tup8 (g1 : 'a t) (g2 : 'b t) (g3 : 'c t) (g4 : 'd t) (g5 : 'e t) (g6 : 'f t) (g7 : 'g t) (g8 : 'h t) : ('a * 'b * 'c * 'd * 'e * 'f * 'g * 'h) t = | |
350 | (fun a b c d e f g h -> (a, b, c, d, e, f, g, h)) <$> g1 <*> g2 <*> g3 <*> g4 <*> g5 <*> g6 <*> g7 <*> g8 | |
351 | ||
352 | let tup9 (g1 : 'a t) (g2 : 'b t) (g3 : 'c t) (g4 : 'd t) (g5 : 'e t) (g6 : 'f t) (g7 : 'g t) (g8 : 'h t) (g9 : 'i t) : ('a * 'b * 'c * 'd * 'e * 'f * 'g * 'h * 'i) t = | |
353 | (fun a b c d e f g h i -> (a, b, c, d, e, f, g, h, i)) <$> g1 <*> g2 <*> g3 <*> g4 <*> g5 <*> g6 <*> g7 <*> g8 <*> g9 | |
354 | ||
285 | 355 | let printable_chars = |
286 | 356 | let l = 126-32+1 in |
287 | 357 | let s = Bytes.create l in |
402 | 472 | let triple a b c (x,y,z) = Printf.sprintf "(%s, %s, %s)" (a x) (b y) (c z) |
403 | 473 | let quad a b c d (x,y,z,w) = |
404 | 474 | Printf.sprintf "(%s, %s, %s, %s)" (a x) (b y) (c z) (d w) |
475 | ||
476 | let default = fun _ -> "<no printer>" | |
477 | ||
478 | let tup2 p_a p_b (a, b) = | |
479 | Printf.sprintf "(%s, %s)" (p_a a) (p_b b) | |
480 | ||
481 | let tup2_opt p_a p_b (a, b) = | |
482 | let p_a = Option.value ~default p_a in | |
483 | let p_b = Option.value ~default p_b in | |
484 | tup2 p_a p_b (a, b) | |
485 | ||
486 | let tup3 p_a p_b (p_c) (a, b, c) = | |
487 | Printf.sprintf "(%s, %s, %s)" (p_a a) (p_b b) (p_c c) | |
488 | ||
489 | let tup3_opt p_a p_b p_c (a, b, c) = | |
490 | let p_a = Option.value ~default p_a in | |
491 | let p_b = Option.value ~default p_b in | |
492 | let p_c = Option.value ~default p_c in | |
493 | tup3 p_a p_b p_c (a, b, c) | |
494 | ||
495 | let tup4 p_a p_b p_c p_d (a, b, c, d) = | |
496 | Printf.sprintf "(%s, %s, %s, %s)" | |
497 | (p_a a) (p_b b) | |
498 | (p_c c) (p_d d) | |
499 | ||
500 | let tup4_opt p_a p_b p_c p_d (a, b, c, d) = | |
501 | let p_a = Option.value ~default p_a in | |
502 | let p_b = Option.value ~default p_b in | |
503 | let p_c = Option.value ~default p_c in | |
504 | let p_d = Option.value ~default p_d in | |
505 | tup4 p_a p_b p_c p_d (a, b, c, d) | |
506 | ||
507 | let tup5 p_a p_b p_c p_d p_e (a, b, c, d, e) = | |
508 | Printf.sprintf "(%s, %s, %s, %s, %s)" | |
509 | (p_a a) (p_b b) | |
510 | (p_c c) (p_d d) | |
511 | (p_e e) | |
512 | ||
513 | let tup5_opt p_a p_b p_c p_d p_e (a, b, c, d, e) = | |
514 | let p_a = Option.value ~default p_a in | |
515 | let p_b = Option.value ~default p_b in | |
516 | let p_c = Option.value ~default p_c in | |
517 | let p_d = Option.value ~default p_d in | |
518 | let p_e = Option.value ~default p_e in | |
519 | tup5 p_a p_b p_c p_d p_e (a, b, c, d, e) | |
520 | ||
521 | let tup6 p_a p_b p_c p_d p_e p_f (a, b, c, d, e, f) = | |
522 | Printf.sprintf "(%s, %s, %s, %s, %s, %s)" | |
523 | (p_a a) (p_b b) | |
524 | (p_c c) (p_d d) | |
525 | (p_e e) (p_f f) | |
526 | ||
527 | let tup6_opt p_a p_b p_c p_d p_e p_f (a, b, c, d, e, f) = | |
528 | let p_a = Option.value ~default p_a in | |
529 | let p_b = Option.value ~default p_b in | |
530 | let p_c = Option.value ~default p_c in | |
531 | let p_d = Option.value ~default p_d in | |
532 | let p_e = Option.value ~default p_e in | |
533 | let p_f = Option.value ~default p_f in | |
534 | tup6 p_a p_b p_c p_d p_e p_f (a, b, c, d, e, f) | |
535 | ||
536 | let tup7 p_a p_b p_c p_d p_e p_f p_g (a, b, c, d, e, f, g) = | |
537 | Printf.sprintf "(%s, %s, %s, %s, %s, %s, %s)" | |
538 | (p_a a) (p_b b) | |
539 | (p_c c) (p_d d) | |
540 | (p_e e) (p_f f) | |
541 | (p_g g) | |
542 | ||
543 | let tup7_opt p_a p_b p_c p_d p_e p_f p_g (a, b, c, d, e, f, g) = | |
544 | let p_a = Option.value ~default p_a in | |
545 | let p_b = Option.value ~default p_b in | |
546 | let p_c = Option.value ~default p_c in | |
547 | let p_d = Option.value ~default p_d in | |
548 | let p_e = Option.value ~default p_e in | |
549 | let p_f = Option.value ~default p_f in | |
550 | let p_g = Option.value ~default p_g in | |
551 | tup7 p_a p_b p_c p_d p_e p_f p_g (a, b, c, d, e, f, g) | |
552 | ||
553 | let tup8 p_a p_b p_c p_d p_e p_f p_g p_h (a, b, c, d, e, f, g, h) = | |
554 | Printf.sprintf "(%s, %s, %s, %s, %s, %s, %s, %s)" | |
555 | (p_a a) (p_b b) | |
556 | (p_c c) (p_d d) | |
557 | (p_e e) (p_f f) | |
558 | (p_g g) (p_h h) | |
559 | ||
560 | let tup8_opt p_a p_b p_c p_d p_e p_f p_g p_h (a, b, c, d, e, f, g, h) = | |
561 | let p_a = Option.value ~default p_a in | |
562 | let p_b = Option.value ~default p_b in | |
563 | let p_c = Option.value ~default p_c in | |
564 | let p_d = Option.value ~default p_d in | |
565 | let p_e = Option.value ~default p_e in | |
566 | let p_f = Option.value ~default p_f in | |
567 | let p_g = Option.value ~default p_g in | |
568 | let p_h = Option.value ~default p_h in | |
569 | tup8 p_a p_b p_c p_d p_e p_f p_g p_h (a, b, c, d, e, f, g, h) | |
570 | ||
571 | let tup9 p_a p_b p_c p_d p_e p_f p_g p_h p_i (a, b, c, d, e, f, g, h, i) = | |
572 | Printf.sprintf "(%s, %s, %s, %s, %s, %s, %s, %s, %s)" | |
573 | (p_a a) (p_b b) | |
574 | (p_c c) (p_d d) | |
575 | (p_e e) (p_f f) | |
576 | (p_g g) (p_h h) | |
577 | (p_i i) | |
578 | ||
579 | let tup9_opt p_a p_b p_c p_d p_e p_f p_g p_h p_i (a, b, c, d, e, f, g, h, i) = | |
580 | let p_a = Option.value ~default p_a in | |
581 | let p_b = Option.value ~default p_b in | |
582 | let p_c = Option.value ~default p_c in | |
583 | let p_d = Option.value ~default p_d in | |
584 | let p_e = Option.value ~default p_e in | |
585 | let p_f = Option.value ~default p_f in | |
586 | let p_g = Option.value ~default p_g in | |
587 | let p_h = Option.value ~default p_h in | |
588 | let p_i = Option.value ~default p_i in | |
589 | tup9 p_a p_b p_c p_d p_e p_f p_g p_h p_i (a, b, c, d, e, f, g, h, i) | |
405 | 590 | |
406 | 591 | let list pp l = |
407 | 592 | let b = Buffer.create 25 in |
510 | 695 | |
511 | 696 | let filter f shrink x = Iter.filter f (shrink x) |
512 | 697 | |
513 | let char c yield = | |
514 | if Char.code c > 0 then yield (Char.chr (Char.code c-1)) | |
698 | let char_generic target c = | |
699 | if c = target | |
700 | then Iter.empty | |
701 | else | |
702 | let c_code = Char.code c in | |
703 | let target_code = Char.code target in | |
704 | Iter.map (fun diff -> Char.chr (target_code + diff)) (int (c_code - target_code)) | |
705 | let char = char_generic 'a' | |
706 | let char_numeral = char_generic '0' | |
707 | ||
708 | let char_printable = function | |
709 | | '\n' -> char '~' (* treat '\n' (10) as '~' (126) to ensure a non-trivial, printable output *) | |
710 | | c -> char c | |
515 | 711 | |
516 | 712 | let option s x = match x with |
517 | 713 | | None -> Iter.empty |
518 | 714 | | Some x -> Iter.(return None <+> map (fun y->Some y) (s x)) |
519 | ||
520 | let string s yield = | |
521 | for i =0 to String.length s-1 do | |
522 | let s' = Bytes.init (String.length s-1) | |
523 | (fun j -> if j<i then s.[j] else s.[j+1]) | |
524 | in | |
525 | yield (Bytes.unsafe_to_string s') | |
526 | done | |
527 | 715 | |
528 | 716 | let array ?shrink a yield = |
529 | 717 | let n = Array.length a in |
550 | 738 | ) |
551 | 739 | done |
552 | 740 | |
553 | let list_spine l yield = | |
554 | let n = List.length l in | |
555 | let chunk_size = ref ((n+1)/2) in | |
556 | ||
557 | (* push the [n] first elements of [l] into [q], return the rest of the list *) | |
558 | let rec fill_queue n l q = match n,l with | |
559 | | 0, _ -> l | |
560 | | _, x::xs -> | |
561 | Queue.push x q; | |
562 | fill_queue (n-1) xs q | |
563 | | _, _ -> assert false | |
564 | in | |
565 | ||
566 | (* remove elements from the list, by chunks of size [chunk_size] (bigger | |
567 | chunks first) *) | |
568 | while !chunk_size > 0 do | |
569 | let q = Queue.create () in | |
570 | let l' = fill_queue !chunk_size l q in | |
571 | (* remove [chunk_size] elements in queue *) | |
572 | let rec pos_loop rev_prefix suffix = | |
573 | yield (List.rev_append rev_prefix suffix); | |
574 | match suffix with | |
575 | | [] -> () | |
576 | | x::xs -> | |
577 | Queue.push x q; | |
578 | let y = Queue.pop q in | |
579 | (pos_loop [@tailcall]) (y::rev_prefix) xs | |
580 | in | |
581 | pos_loop [] l'; | |
582 | chunk_size := !chunk_size / 2; | |
583 | done | |
741 | let rec list_spine l yield = | |
742 | let rec split l len acc = match len,l with | |
743 | | _,[] | |
744 | | 0,_ -> List.rev acc, l | |
745 | | _,x::xs -> split xs (len-1) (x::acc) in | |
746 | match l with | |
747 | | [] -> () | |
748 | | [_] -> yield [] | |
749 | | [x;y] -> yield []; yield [x]; yield [y] | |
750 | | _::_ -> | |
751 | let len = List.length l in | |
752 | let xs,ys = split l ((1 + len) / 2) [] in | |
753 | yield xs; | |
754 | list_spine xs (fun xs' -> yield (xs'@ys)) | |
584 | 755 | |
585 | 756 | let list_elems shrink l yield = |
586 | 757 | (* try to shrink each element of the list *) |
598 | 769 | | None -> () |
599 | 770 | | Some shrink -> list_elems shrink l yield |
600 | 771 | |
772 | let string ?(shrink = char) s yield = | |
773 | let buf = Buffer.create 42 in | |
774 | list ~shrink | |
775 | (string_fold_right (fun c acc -> c::acc) s []) | |
776 | (fun cs -> | |
777 | List.iter (fun c -> Buffer.add_char buf c) cs; | |
778 | let s = Buffer.contents buf in | |
779 | Buffer.clear buf; | |
780 | yield s) | |
781 | ||
601 | 782 | let pair a b (x,y) yield = |
602 | 783 | a x (fun x' -> yield (x',y)); |
603 | 784 | b y (fun y' -> yield (x,y')) |
612 | 793 | b y (fun y' -> yield (x,y',z,w)); |
613 | 794 | c z (fun z' -> yield (x,y,z',w)); |
614 | 795 | d w (fun w' -> yield (x,y,z,w')) |
796 | ||
797 | let default = nil | |
798 | ||
799 | let tup2 = pair | |
800 | ||
801 | let tup2_opt a b = | |
802 | let a = Option.value ~default a in | |
803 | let b = Option.value ~default b in | |
804 | tup2 a b | |
805 | ||
806 | let tup3 = triple | |
807 | ||
808 | let tup3_opt a b c = | |
809 | let a = Option.value ~default a in | |
810 | let b = Option.value ~default b in | |
811 | let c = Option.value ~default c in | |
812 | tup3 a b c | |
813 | ||
814 | let tup4 = quad | |
815 | ||
816 | let tup4_opt a b c d = | |
817 | let a = Option.value ~default a in | |
818 | let b = Option.value ~default b in | |
819 | let c = Option.value ~default c in | |
820 | let d = Option.value ~default d in | |
821 | tup4 a b c d | |
822 | ||
823 | let tup5 a b c d e (a', b', c', d', e') yield = | |
824 | a a' (fun x -> yield (x,b',c',d',e')); | |
825 | b b' (fun x -> yield (a',x,c',d',e')); | |
826 | c c' (fun x -> yield (a',b',x,d',e')); | |
827 | d d' (fun x -> yield (a',b',c',x,e')); | |
828 | e e' (fun x -> yield (a',b',c',d',x)) | |
829 | ||
830 | let tup5_opt a b c d e = | |
831 | let a = Option.value ~default a in | |
832 | let b = Option.value ~default b in | |
833 | let c = Option.value ~default c in | |
834 | let d = Option.value ~default d in | |
835 | let e = Option.value ~default e in | |
836 | tup5 a b c d e | |
837 | ||
838 | let tup6 a b c d e f (a', b', c', d', e', f') yield = | |
839 | a a' (fun x -> yield (x,b',c',d',e',f')); | |
840 | b b' (fun x -> yield (a',x,c',d',e',f')); | |
841 | c c' (fun x -> yield (a',b',x,d',e',f')); | |
842 | d d' (fun x -> yield (a',b',c',x,e',f')); | |
843 | e e' (fun x -> yield (a',b',c',d',x,f')); | |
844 | f f' (fun x -> yield (a',b',c',d',e',x)) | |
845 | ||
846 | let tup6_opt a b c d e f = | |
847 | let a = Option.value ~default a in | |
848 | let b = Option.value ~default b in | |
849 | let c = Option.value ~default c in | |
850 | let d = Option.value ~default d in | |
851 | let e = Option.value ~default e in | |
852 | let f = Option.value ~default f in | |
853 | tup6 a b c d e f | |
854 | ||
855 | let tup7 a b c d e f g (a', b', c', d', e', f', g') yield = | |
856 | a a' (fun x -> yield (x,b',c',d',e',f',g')); | |
857 | b b' (fun x -> yield (a',x,c',d',e',f',g')); | |
858 | c c' (fun x -> yield (a',b',x,d',e',f',g')); | |
859 | d d' (fun x -> yield (a',b',c',x,e',f',g')); | |
860 | e e' (fun x -> yield (a',b',c',d',x,f',g')); | |
861 | f f' (fun x -> yield (a',b',c',d',e',x,g')); | |
862 | g g' (fun x -> yield (a',b',c',d',e',f',x)) | |
863 | ||
864 | let tup7_opt a b c d e f g = | |
865 | let a = Option.value ~default a in | |
866 | let b = Option.value ~default b in | |
867 | let c = Option.value ~default c in | |
868 | let d = Option.value ~default d in | |
869 | let e = Option.value ~default e in | |
870 | let f = Option.value ~default f in | |
871 | let g = Option.value ~default g in | |
872 | tup7 a b c d e f g | |
873 | ||
874 | let tup8 a b c d e f g h (a', b', c', d', e', f', g', h') yield = | |
875 | a a' (fun x -> yield (x,b',c',d',e',f',g',h')); | |
876 | b b' (fun x -> yield (a',x,c',d',e',f',g',h')); | |
877 | c c' (fun x -> yield (a',b',x,d',e',f',g',h')); | |
878 | d d' (fun x -> yield (a',b',c',x,e',f',g',h')); | |
879 | e e' (fun x -> yield (a',b',c',d',x,f',g',h')); | |
880 | f f' (fun x -> yield (a',b',c',d',e',x,g',h')); | |
881 | g g' (fun x -> yield (a',b',c',d',e',f',x,h')); | |
882 | h h' (fun x -> yield (a',b',c',d',e',f',g',x)) | |
883 | ||
884 | let tup8_opt a b c d e f g h = | |
885 | let a = Option.value ~default a in | |
886 | let b = Option.value ~default b in | |
887 | let c = Option.value ~default c in | |
888 | let d = Option.value ~default d in | |
889 | let e = Option.value ~default e in | |
890 | let f = Option.value ~default f in | |
891 | let g = Option.value ~default g in | |
892 | let h = Option.value ~default h in | |
893 | tup8 a b c d e f g h | |
894 | ||
895 | let tup9 a b c d e f g h i (a', b', c', d', e', f', g', h', i') yield = | |
896 | a a' (fun x -> yield (x,b',c',d',e',f',g',h',i')); | |
897 | b b' (fun x -> yield (a',x,c',d',e',f',g',h',i')); | |
898 | c c' (fun x -> yield (a',b',x,d',e',f',g',h',i')); | |
899 | d d' (fun x -> yield (a',b',c',x,e',f',g',h',i')); | |
900 | e e' (fun x -> yield (a',b',c',d',x,f',g',h',i')); | |
901 | f f' (fun x -> yield (a',b',c',d',e',x,g',h',i')); | |
902 | g g' (fun x -> yield (a',b',c',d',e',f',x,h',i')); | |
903 | h h' (fun x -> yield (a',b',c',d',e',f',g',x,i')); | |
904 | i i' (fun x -> yield (a',b',c',d',e',f',g',h',x)) | |
905 | ||
906 | let tup9_opt a b c d e f g h i = | |
907 | let a = Option.value ~default a in | |
908 | let b = Option.value ~default b in | |
909 | let c = Option.value ~default c in | |
910 | let d = Option.value ~default d in | |
911 | let e = Option.value ~default e in | |
912 | let f = Option.value ~default f in | |
913 | let g = Option.value ~default g in | |
914 | let h = Option.value ~default h in | |
915 | let i = Option.value ~default i in | |
916 | tup9 a b c d e f g h i | |
615 | 917 | end |
616 | 918 | |
617 | 919 | (** {2 Observe Values} *) |
652 | 954 | let int : int t = (=) |
653 | 955 | let string : string t = (=) |
654 | 956 | let bool : bool t = (=) |
655 | let float : float t = (=) | |
957 | let float = Float.equal | |
656 | 958 | let unit () () = true |
657 | 959 | let char : char t = (=) |
658 | 960 | |
797 | 1099 | make ~print:(fun i -> Int64.to_string i ^ "L") ~small:small1 |
798 | 1100 | ~shrink:Shrink.int64 Gen.ui64 |
799 | 1101 | |
800 | let char = make_scalar ~print:(sprintf "%C") Gen.char | |
801 | let printable_char = make_scalar ~print:(sprintf "%C") Gen.printable | |
802 | let numeral_char = make_scalar ~print:(sprintf "%C") Gen.numeral | |
1102 | let small_char target c = abs ((Char.code c) - (Char.code target)) | |
1103 | ||
1104 | let char = | |
1105 | make ~print:(sprintf "%C") ~small:(small_char 'a') ~shrink:Shrink.char Gen.char | |
1106 | let printable_char = | |
1107 | make ~print:(sprintf "%C") ~small:(small_char 'a') ~shrink:Shrink.char_printable Gen.printable | |
1108 | let numeral_char = | |
1109 | make ~print:(sprintf "%C") ~small:(small_char '0') ~shrink:Shrink.char_numeral Gen.numeral | |
803 | 1110 | |
804 | 1111 | let string_gen_of_size size gen = |
805 | 1112 | make ~shrink:Shrink.string ~small:String.length |
812 | 1119 | let string_of_size size = string_gen_of_size size Gen.char |
813 | 1120 | let small_string = string_gen_of_size Gen.small_nat Gen.char |
814 | 1121 | |
815 | let printable_string = string_gen Gen.printable | |
816 | let printable_string_of_size size = string_gen_of_size size Gen.printable | |
817 | let small_printable_string = string_gen_of_size Gen.small_nat Gen.printable | |
818 | ||
819 | let numeral_string = string_gen Gen.numeral | |
820 | let numeral_string_of_size size = string_gen_of_size size Gen.numeral | |
1122 | let printable_string = | |
1123 | make ~shrink:(Shrink.string ~shrink:Shrink.char_printable) ~small:String.length | |
1124 | ~print:(sprintf "%S") (Gen.string ~gen:Gen.printable) | |
1125 | ||
1126 | let printable_string_of_size size = | |
1127 | make ~shrink:(Shrink.string ~shrink:Shrink.char_printable) ~small:String.length | |
1128 | ~print:(sprintf "%S") (Gen.string_size ~gen:Gen.printable size) | |
1129 | ||
1130 | let small_printable_string = | |
1131 | make ~shrink:(Shrink.string ~shrink:Shrink.char_printable) ~small:String.length | |
1132 | ~print:(sprintf "%S") (Gen.string_size ~gen:Gen.printable Gen.small_nat) | |
1133 | ||
1134 | let numeral_string = | |
1135 | make ~shrink:(Shrink.string ~shrink:Shrink.char_numeral) ~small:String.length | |
1136 | ~print:(sprintf "%S") (Gen.string ~gen:Gen.numeral) | |
1137 | ||
1138 | let numeral_string_of_size size = | |
1139 | make ~shrink:(Shrink.string ~shrink:Shrink.char_numeral) ~small:String.length | |
1140 | ~print:(sprintf "%S") (Gen.string_size ~gen:Gen.numeral size) | |
821 | 1141 | |
822 | 1142 | let list_sum_ f l = List.fold_left (fun acc x-> f x+acc) 0 l |
823 | 1143 | |
874 | 1194 | (_opt_or c.shrink Shrink.nil) |
875 | 1195 | (_opt_or d.shrink Shrink.nil)) |
876 | 1196 | (Gen.quad a.gen b.gen c.gen d.gen) |
1197 | ||
1198 | let tup2 a b= | |
1199 | make | |
1200 | ?small:(_opt_map_2 ~f:(fun a b (a', b') -> a a'+b b') a.small b.small) | |
1201 | ~print:(Print.tup2_opt a.print b.print) | |
1202 | ~shrink:(Shrink.pair (_opt_or a.shrink Shrink.nil) (_opt_or b.shrink Shrink.nil)) | |
1203 | (Gen.tup2 a.gen b.gen) | |
1204 | ||
1205 | let tup3 a b c = | |
1206 | make | |
1207 | ?small:(_opt_map_3 ~f:(fun a b c (a', b', c') -> | |
1208 | a a'+b b'+c c') a.small b.small c.small) | |
1209 | ~print:(Print.tup3_opt a.print b.print c.print) | |
1210 | ~shrink:(Shrink.tup3_opt a.shrink b.shrink c.shrink) | |
1211 | (Gen.tup3 a.gen b.gen c.gen) | |
1212 | ||
1213 | let tup4 a b c d = | |
1214 | make | |
1215 | ?small:(_opt_map_4 ~f:(fun a b c d (a', b', c', d') -> | |
1216 | a a'+b b'+c c'+d d') a.small b.small c.small d.small) | |
1217 | ~print:(Print.tup4_opt a.print b.print c.print d.print) | |
1218 | ~shrink:(Shrink.tup4_opt a.shrink b.shrink c.shrink d.shrink) | |
1219 | (Gen.tup4 a.gen b.gen c.gen d.gen) | |
1220 | ||
1221 | let tup5 a b c d e = | |
1222 | make | |
1223 | ?small:(_opt_map_5 ~f:(fun a b c d e (a', b', c', d', e') -> | |
1224 | a a'+b b'+c c'+d d'+e e') a.small b.small c.small d.small e.small) | |
1225 | ~print:(Print.tup5_opt a.print b.print c.print d.print e.print) | |
1226 | ~shrink:(Shrink.tup5_opt a.shrink b.shrink c.shrink d.shrink e.shrink) | |
1227 | (Gen.tup5 a.gen b.gen c.gen d.gen e.gen) | |
1228 | ||
1229 | let tup6 a b c d e f = | |
1230 | make | |
1231 | ?small:(_opt_map_6 ~f:(fun a b c d e f (a', b', c', d', e', f') -> | |
1232 | a a'+b b'+c c'+d d'+e e'+f f') a.small b.small c.small d.small e.small f.small) | |
1233 | ~print:(Print.tup6_opt a.print b.print c.print d.print e.print f.print) | |
1234 | ~shrink:(Shrink.tup6_opt a.shrink b.shrink c.shrink d.shrink e.shrink f.shrink) | |
1235 | (Gen.tup6 a.gen b.gen c.gen d.gen e.gen f.gen) | |
1236 | ||
1237 | let tup7 a b c d e f g = | |
1238 | make | |
1239 | ?small:(_opt_map_7 ~f:(fun a b c d e f g (a', b', c', d', e', f', g') -> | |
1240 | a a'+b b'+c c'+d d'+e e'+f f'+g g') | |
1241 | a.small b.small c.small d.small e.small f.small g.small) | |
1242 | ~print:(Print.tup7_opt | |
1243 | a.print b.print c.print d.print e.print f.print g.print) | |
1244 | ~shrink:(Shrink.tup7_opt | |
1245 | a.shrink b.shrink c.shrink d.shrink e.shrink f.shrink g.shrink) | |
1246 | (Gen.tup7 a.gen b.gen c.gen d.gen e.gen f.gen g.gen) | |
1247 | ||
1248 | let tup8 a b c d e f g h = | |
1249 | make | |
1250 | ?small:(_opt_map_8 ~f:(fun a b c d e f g h (a', b', c', d', e', f', g', h') -> | |
1251 | a a'+b b'+c c'+d d'+e e'+f f'+g g'+h h') | |
1252 | a.small b.small c.small d.small e.small f.small g.small h.small) | |
1253 | ~print:(Print.tup8_opt | |
1254 | a.print b.print c.print d.print e.print f.print g.print h.print) | |
1255 | ~shrink:(Shrink.tup8_opt | |
1256 | a.shrink b.shrink c.shrink d.shrink e.shrink f.shrink g.shrink h.shrink) | |
1257 | (Gen.tup8 a.gen b.gen c.gen d.gen e.gen f.gen g.gen h.gen) | |
1258 | ||
1259 | let tup9 a b c d e f g h i = | |
1260 | make | |
1261 | ?small:(_opt_map_9 ~f:(fun a b c d e f g h i (a', b', c', d', e', f', g', h', i') -> | |
1262 | a a'+b b'+c c'+d d'+e e'+f f'+g g'+h h'+i i') | |
1263 | a.small b.small c.small d.small e.small f.small g.small h.small i.small) | |
1264 | ~print:(Print.tup9_opt | |
1265 | a.print b.print c.print d.print e.print f.print g.print h.print i.print) | |
1266 | ~shrink:(Shrink.tup9_opt | |
1267 | a.shrink b.shrink c.shrink d.shrink e.shrink f.shrink g.shrink h.shrink i.shrink) | |
1268 | (Gen.tup9 a.gen b.gen c.gen d.gen e.gen f.gen g.gen h.gen i.gen) | |
877 | 1269 | |
878 | 1270 | let option ?ratio a = |
879 | 1271 | let g = Gen.opt ?ratio a.gen |
954 | 1346 | List.iter (fun (k,v) -> T.add tbl k v) l; |
955 | 1347 | tbl |
956 | 1348 | in |
1349 | (* split random state to avoid later failed [get]s to side-effect the current [st] *) | |
1350 | let st' = RS.split st in | |
957 | 1351 | (* make a table |
958 | 1352 | @param extend if true, extend table on the fly *) |
959 | 1353 | let rec make ~extend tbl = { |
961 | 1355 | try Some (T.find tbl x) |
962 | 1356 | with Not_found -> |
963 | 1357 | if extend then ( |
964 | let v = v.gen st in | |
1358 | let v = v.gen st' in | |
965 | 1359 | T.add tbl x v; |
966 | 1360 | Some v |
967 | 1361 | ) else None); |
976 | 1370 | tbl; |
977 | 1371 | Buffer.contents b); |
978 | 1372 | p_shrink1=(fun yield -> |
979 | Shrink.list (tbl_to_list tbl) | |
1373 | Shrink.list_spine (tbl_to_list tbl) | |
980 | 1374 | (fun l -> |
981 | 1375 | yield (make ~extend:false (tbl_of_list l))) |
982 | 1376 | ); |
1047 | 1441 | = function |
1048 | 1442 | | Fun_tbl {fun_arb=a; fun_tbl=tbl; fun_default=def} -> |
1049 | 1443 | let sh_v = match a.shrink with None -> Shrink.nil | Some s->s in |
1050 | (Poly_tbl.shrink1 tbl >|= fun tbl' -> mk_repr tbl' a def) | |
1444 | (sh_v def >|= fun def' -> mk_repr tbl a def') | |
1051 | 1445 | <+> |
1052 | (sh_v def >|= fun def' -> mk_repr tbl a def') | |
1446 | (Poly_tbl.shrink1 tbl >|= fun tbl' -> mk_repr tbl' a def) | |
1053 | 1447 | <+> |
1054 | 1448 | (Poly_tbl.shrink2 sh_v tbl >|= fun tbl' -> mk_repr tbl' a def) |
1055 | 1449 | | Fun_map (g, r') -> |
1327 | 1721 | let get_long_factor = QCheck2.Test.get_long_factor |
1328 | 1722 | |
1329 | 1723 | let make_cell ?if_assumptions_fail |
1330 | ?count ?long_factor ?max_gen | |
1331 | ?max_fail ?small:_removed_in_qcheck_2 ?name arb law | |
1724 | ?count ?long_factor ?negative ?max_gen | |
1725 | ?max_fail ?small:_removed_in_qcheck_2 ?retries ?name arb law | |
1332 | 1726 | = |
1333 | 1727 | let {gen; shrink; print; collect; stats; _} = arb in |
1334 | QCheck2.Test.make_cell_from_QCheck1 ?if_assumptions_fail ?count ?long_factor ?max_gen ?max_fail ?name ~gen ?shrink ?print ?collect ~stats law | |
1335 | ||
1336 | let make ?if_assumptions_fail ?count ?long_factor ?max_gen ?max_fail ?small ?name arb law = | |
1337 | QCheck2.Test.Test (make_cell ?if_assumptions_fail ?count ?long_factor ?max_gen ?max_fail ?small ?name arb law) | |
1728 | QCheck2.Test.make_cell_from_QCheck1 ?if_assumptions_fail ?count ?long_factor ?negative ?max_gen ?max_fail ?retries ?name ~gen ?shrink ?print ?collect ~stats law | |
1729 | ||
1730 | let make' ?if_assumptions_fail ?count ?long_factor ?max_gen ?max_fail ?small ?retries ?name ~negative arb law = | |
1731 | QCheck2.Test.Test (make_cell ?if_assumptions_fail ?count ?long_factor ?max_gen ?max_fail ?small ?retries ?name ~negative arb law) | |
1732 | ||
1733 | let make = make' ~negative:false | |
1734 | let make_neg = make' ~negative:true | |
1338 | 1735 | |
1339 | 1736 | let fail_report = QCheck2.Test.fail_report |
1340 | 1737 |
292 | 292 | @since 0.5.2 *) |
293 | 293 | |
294 | 294 | val int_bound : int -> int t |
295 | (** Uniform integer generator producing integers within [0... bound]. | |
295 | (** Uniform integer generator producing integers between [0] and [bound] | |
296 | (inclusive). | |
296 | 297 | For [bound < 2^{30} - 1] uses [Random.State.int] for integer generation. |
297 | 298 | @raise Invalid_argument if the argument is negative. *) |
298 | 299 | |
299 | 300 | val int_range : int -> int -> int t |
300 | (** Uniform integer generator producing integers within [low,high]. | |
301 | (** Uniform integer generator producing integers within [low,high] (inclusive). | |
301 | 302 | @raise Invalid_argument if [low > high]. *) |
302 | 303 | |
303 | 304 | val graft_corners : 'a t -> 'a list -> unit -> 'a t |
337 | 338 | val array_repeat : int -> 'a t -> 'a array t |
338 | 339 | (** [array_repeat i g] builds an array generator from exactly [i] elements generated by [g]. *) |
339 | 340 | |
340 | val opt : ?ratio:float -> 'a t -> 'a option t | |
341 | (** An option generator, with optional ratio. | |
341 | val option : ?ratio:float -> 'a t -> 'a option t | |
342 | (** An option generator, with optional ratio. | |
342 | 343 | @param ratio a float between [0.] and [1.] indicating the probability of a sample to be [Some _] |
343 | 344 | rather than [None]. |
345 | ||
346 | @since 0.19 (renamed from [opt]) | |
347 | *) | |
348 | ||
349 | val opt : ?ratio:float -> 'a t -> 'a option t | |
350 | (** [opt] is an alias of {!val:option} for backward compatibility. | |
351 | ||
344 | 352 | @since 0.18 ([?ratio] parameter) |
345 | 353 | *) |
346 | 354 | |
352 | 360 | (** Generates quadruples. |
353 | 361 | @since 0.5.1 *) |
354 | 362 | |
363 | (** {3 Tuple of generators} *) | |
364 | ||
365 | (** {4 Shrinks on [gen1], then [gen2], then ... } *) | |
366 | ||
367 | val tup2 : 'a t -> 'b t -> ('a * 'b) t | |
368 | ||
369 | val tup3 : 'a t -> 'b t -> 'c t -> ('a * 'b * 'c) t | |
370 | ||
371 | val tup4 : 'a t -> 'b t -> 'c t -> 'd t -> ('a * 'b * 'c * 'd) t | |
372 | ||
373 | val tup5 : 'a t -> 'b t -> 'c t -> 'd t -> 'e t -> ('a * 'b * 'c * 'd * 'e) t | |
374 | ||
375 | val tup6 : 'a t -> 'b t -> 'c t -> 'd t -> 'e t -> 'f t -> | |
376 | ('a * 'b * 'c * 'd * 'e * 'f) t | |
377 | ||
378 | val tup7 : 'a t -> 'b t -> 'c t -> 'd t -> 'e t -> 'f t -> 'g t -> | |
379 | ('a * 'b * 'c * 'd * 'e * 'f * 'g) t | |
380 | ||
381 | val tup8 : 'a t -> 'b t -> 'c t -> 'd t -> 'e t -> 'f t -> 'g t -> 'h t -> | |
382 | ('a * 'b * 'c * 'd * 'e * 'f * 'g * 'h) t | |
383 | ||
384 | val tup9 : 'a t -> 'b t -> 'c t -> 'd t -> 'e t -> 'f t -> 'g t -> 'h t -> 'i t -> | |
385 | ('a * 'b * 'c * 'd * 'e * 'f * 'g * 'h * 'i) t | |
386 | ||
355 | 387 | val char : char t |
356 | 388 | (** Generates characters upto character code 255. *) |
357 | 389 | |
358 | val printable : char t (** Generates printable characters. *) | |
390 | val printable : char t (** Generates printable ascii characters - either '\n' or in the range 32 to 126, inclusive *) | |
359 | 391 | |
360 | 392 | val numeral : char t (** Generates numeral characters. *) |
361 | 393 | |
566 | 598 | val comap : ('a -> 'b) -> 'b t -> 'a t |
567 | 599 | (** [comap f p] maps [p], a printer of type ['b], to a printer of type ['a] by |
568 | 600 | first converting a printed value using [f : 'a -> 'b]. *) |
601 | ||
602 | val tup2 : 'a t -> 'b t -> ('a * 'b) t | |
603 | (** 2-tuple printer. Expects printers for each component. *) | |
604 | ||
605 | val tup3 : 'a t -> 'b t -> 'c t -> ('a * 'b * 'c) t | |
606 | (** 3-tuple printer. Expects printers for each component. *) | |
607 | ||
608 | val tup4 : 'a t -> 'b t -> 'c t -> 'd t -> ('a * 'b * 'c * 'd) t | |
609 | (** 4-tuple printer. Expects printers for each component. *) | |
610 | ||
611 | val tup5 : 'a t -> 'b t -> 'c t -> 'd t -> 'e t -> ('a * 'b * 'c * 'd * 'e) t | |
612 | (** 5-tuple printer. Expects printers for each component. *) | |
613 | ||
614 | val tup6 : 'a t -> 'b t -> 'c t -> 'd t -> 'e t -> 'f t -> | |
615 | ('a * 'b * 'c * 'd * 'e * 'f) t | |
616 | (** 6-tuple printer. Expects printers for each component. *) | |
617 | ||
618 | val tup7 : 'a t -> 'b t -> 'c t -> 'd t -> 'e t -> 'f t -> 'g t -> | |
619 | ('a * 'b * 'c * 'd * 'e * 'f * 'g) t | |
620 | (** 7-tuple printer. Expects printers for each component. *) | |
621 | ||
622 | val tup8 : 'a t -> 'b t -> 'c t -> 'd t -> 'e t -> 'f t -> 'g t -> 'h t -> | |
623 | ('a * 'b * 'c * 'd * 'e * 'f * 'g * 'h) t | |
624 | (** 8-tuple printer. Expects printers for each component. *) | |
625 | ||
626 | val tup9 : 'a t -> 'b t -> 'c t -> 'd t -> 'e t -> 'f t -> 'g t -> 'h t -> 'i t -> | |
627 | ('a * 'b * 'c * 'd * 'e * 'f * 'g * 'h * 'i) t | |
628 | (** 9-tuple printer. Expects printers for each component. *) | |
569 | 629 | end |
570 | 630 | |
571 | 631 | (** {2 Iterators} |
626 | 686 | |
627 | 687 | val unit : unit t (** @since 0.6 *) |
628 | 688 | |
629 | val char : char t (** @since 0.6 *) | |
689 | val char : char t | |
690 | (** Shrinks towards ['a']. | |
691 | @since 0.6 *) | |
692 | ||
693 | val char_numeral : char t | |
694 | (** Shrinks towards ['0']. | |
695 | @since 0.19 *) | |
696 | ||
697 | val char_printable : char t | |
698 | (** Shrinks towards ['a'] like [!char]. The output is also a printable character. | |
699 | @since 0.19 *) | |
630 | 700 | |
631 | 701 | val int : int t |
632 | 702 | |
638 | 708 | |
639 | 709 | val option : 'a t -> 'a option t |
640 | 710 | |
641 | val string : string t | |
711 | val string : ?shrink:(char t) -> string t | |
642 | 712 | |
643 | 713 | val filter : ('a -> bool) -> 'a t -> 'a t |
644 | 714 | (** [filter f shrink] shrinks values the same as [shrink], but |
681 | 751 | |
682 | 752 | val quad : 'a t -> 'b t -> 'c t -> 'd t -> ('a * 'b * 'c * 'd) t |
683 | 753 | (** Similar to {!pair} *) |
754 | ||
755 | val tup2 : 'a t -> 'b t -> ('a * 'b) t | |
756 | (** [tup2 a b] uses [a] to shrink the first element of tuples, | |
757 | then tries to shrink the second element using [b]. | |
758 | It is often better, when generating tuples, to put the "simplest" | |
759 | element first (atomic type rather than list, etc.) because it will be | |
760 | shrunk earlier. In particular, putting functions last might help. *) | |
761 | ||
762 | val tup3 : 'a t -> 'b t -> 'c t -> ('a * 'b * 'c) t | |
763 | (** Similar to {!tup2} *) | |
764 | ||
765 | val tup4 : 'a t -> 'b t -> 'c t -> 'd t -> ('a * 'b * 'c * 'd) t | |
766 | (** Similar to {!tup2} *) | |
767 | ||
768 | val tup5 : 'a t -> 'b t -> 'c t -> 'd t -> 'e t -> ('a * 'b * 'c * 'd * 'e) t | |
769 | (** Similar to {!tup2} *) | |
770 | ||
771 | val tup6 : 'a t -> 'b t -> 'c t -> 'd t -> 'e t -> 'f t -> | |
772 | ('a * 'b * 'c * 'd * 'e * 'f) t | |
773 | (** Similar to {!tup2} *) | |
774 | ||
775 | val tup7 : 'a t -> 'b t -> 'c t -> 'd t -> 'e t -> 'f t -> 'g t -> | |
776 | ('a * 'b * 'c * 'd * 'e * 'f * 'g) t | |
777 | (** Similar to {!tup2} *) | |
778 | ||
779 | val tup8 : 'a t -> 'b t -> 'c t -> 'd t -> 'e t -> 'f t -> 'g t -> 'h t -> | |
780 | ('a * 'b * 'c * 'd * 'e * 'f * 'g * 'h) t | |
781 | (** Similar to {!tup2} *) | |
782 | ||
783 | val tup9 : 'a t -> 'b t -> 'c t -> 'd t -> 'e t -> 'f t -> 'g t -> 'h t -> 'i t -> | |
784 | ('a * 'b * 'c * 'd * 'e * 'f * 'g * 'h * 'i) t | |
785 | (** Similar to {!tup2} *) | |
684 | 786 | end |
685 | 787 | |
686 | 788 | (** {2 Observe Values} *) |
805 | 907 | with an object of type [foo arbitrary] used to generate, print, etc. values |
806 | 908 | of type [foo]. |
807 | 909 | |
808 | See {!Test.make} to build a test, and {!Test.check_exn} to | |
809 | run one test simply. | |
810 | For more serious testing, it is better to create a testsuite | |
811 | and use {!QCheck_runner}. | |
910 | The main features of this module are: | |
911 | - {!Test.make} to build a test, | |
912 | - {!Test.make_neg} to build a negative test that is expected not to satisfy the tested property, | |
913 | - {!Test.check_exn} to run a single test with a simple runner. | |
914 | ||
915 | A test fails if the property does not hold for a given input. The {{!Test.fail_report} simple} form or the {{!Test.fail_reportf} rich} form) offer more elaborate forms to fail a test. | |
916 | ||
917 | For more serious testing, it is recommended to create a testsuite and use a full-fledged runner: | |
918 | - {!QCheck_base_runner} is a QCheck-only runner (useful if you don't have or don't need another test framework) | |
919 | - {!QCheck_alcotest} interfaces to the Alcotest framework | |
920 | - {!QCheck_ounit} interfaces to the to OUnit framework | |
812 | 921 | *) |
813 | 922 | |
814 | 923 | (** Result of running a test *) |
902 | 1011 | |
903 | 1012 | val make_cell : |
904 | 1013 | ?if_assumptions_fail:([`Fatal | `Warning] * float) -> |
905 | ?count:int -> ?long_factor:int -> ?max_gen:int -> ?max_fail:int -> | |
906 | ?small:('a -> int) -> ?name:string -> 'a arbitrary -> ('a -> bool) -> | |
907 | 'a cell | |
1014 | ?count:int -> ?long_factor:int -> ?negative:bool -> ?max_gen:int -> ?max_fail:int -> | |
1015 | ?small:('a -> int) -> ?retries:int -> ?name:string -> | |
1016 | 'a arbitrary -> ('a -> bool) -> 'a cell | |
908 | 1017 | (** [make_cell arb prop] builds a test that checks property [prop] on instances |
909 | 1018 | of the generator [arb]. |
910 | 1019 | @param name the name of the test. |
911 | 1020 | @param count number of test cases to run, counting only |
912 | 1021 | the test cases which satisfy preconditions. |
1022 | @param retries number of times to retry the tested property while shrinking. | |
913 | 1023 | @param long_factor the factor by which to multiply count, max_gen and |
914 | 1024 | max_fail when running a long test (default: 1). |
1025 | @param negative whether the test is expected not to satisfy the tested property. | |
915 | 1026 | @param max_gen maximum number of times the generation function |
916 | 1027 | is called in total to replace inputs that do not satisfy |
917 | 1028 | preconditions (should be >= count). |
950 | 1061 | val make : |
951 | 1062 | ?if_assumptions_fail:([`Fatal | `Warning] * float) -> |
952 | 1063 | ?count:int -> ?long_factor:int -> ?max_gen:int -> ?max_fail:int -> |
953 | ?small:('a -> int) -> ?name:string -> 'a arbitrary -> ('a -> bool) -> t | |
1064 | ?small:('a -> int) -> ?retries:int -> ?name:string -> 'a arbitrary -> | |
1065 | ('a -> bool) -> t | |
954 | 1066 | (** [make arb prop] builds a test that checks property [prop] on instances |
955 | 1067 | of the generator [arb]. |
1068 | See {!make_cell} for a description of the parameters. | |
1069 | *) | |
1070 | ||
1071 | val make_neg : | |
1072 | ?if_assumptions_fail:([`Fatal | `Warning] * float) -> | |
1073 | ?count:int -> ?long_factor:int -> ?max_gen:int -> ?max_fail:int -> | |
1074 | ?small:('a -> int) -> ?retries:int -> ?name:string -> 'a arbitrary -> | |
1075 | ('a -> bool) -> t | |
1076 | (** [make_neg arb prop] builds a test that checks property [prop] on instances | |
1077 | of the generator [arb]. | |
1078 | The test is considered negative, meaning that it is expected not to satisfy the tested property. | |
1079 | This information is recorded in an underlying test [cell] entry and interpreted suitably by test runners. | |
956 | 1080 | See {!make_cell} for a description of the parameters. |
957 | 1081 | *) |
958 | 1082 | |
972 | 1096 | ?rand:Random.State.t -> 'a cell -> 'a TestResult.t |
973 | 1097 | |
974 | 1098 | val check_cell_exn : |
975 | ?long:bool -> ?call:'a callback -> ?step:'a step -> | |
1099 | ?long:bool -> ?call:'a callback -> | |
1100 | ?step:'a step -> ?handler:'a handler -> | |
976 | 1101 | ?rand:Random.State.t -> 'a cell -> unit |
977 | 1102 | |
978 | 1103 | val check_exn : ?long:bool -> ?rand:Random.State.t -> t -> unit |
1108 | 1233 | valid latin-1). *) |
1109 | 1234 | |
1110 | 1235 | val printable_char : char arbitrary |
1111 | (** Uniformly distributed over a subset of chars. *) | |
1112 | (* FIXME: describe which subset. *) | |
1236 | (** Uniformly distributed over a subset of printable ascii chars. | |
1237 | Ascii character codes 32 to 126, inclusive - or ['\n'] with code 10. | |
1238 | *) | |
1113 | 1239 | |
1114 | 1240 | val numeral_char : char arbitrary |
1115 | 1241 | (** Uniformly distributed over ['0'..'9']. *) |
1116 | 1242 | |
1117 | 1243 | val string_gen_of_size : int Gen.t -> char Gen.t -> string arbitrary |
1244 | (** Builds a string generator from a (non-negative) size generator and a character generator. *) | |
1118 | 1245 | |
1119 | 1246 | val string_gen : char Gen.t -> string arbitrary |
1120 | (** Generates strings with a distribution of length of [small_nat]. *) | |
1247 | (** Generates strings with a distribution of length of {!Gen.nat}. *) | |
1121 | 1248 | |
1122 | 1249 | val string : string arbitrary |
1123 | (** Generates strings with a distribution of length of [small_nat] | |
1250 | (** Generates strings with a distribution of length of {!Gen.nat} | |
1124 | 1251 | and distribution of characters of [char]. *) |
1125 | 1252 | |
1126 | 1253 | val small_string : string arbitrary |
1131 | 1258 | @since 0.5.3 *) |
1132 | 1259 | |
1133 | 1260 | val string_of_size : int Gen.t -> string arbitrary |
1134 | (** Generates strings with distribution of characters if [char]. *) | |
1261 | (** Generates strings with distribution of characters of [char]. *) | |
1135 | 1262 | |
1136 | 1263 | val printable_string : string arbitrary |
1137 | (** Generates strings with a distribution of length of [small_nat] | |
1264 | (** Generates strings with a distribution of length of {!Gen.nat} | |
1138 | 1265 | and distribution of characters of [printable_char]. *) |
1139 | 1266 | |
1140 | 1267 | val printable_string_of_size : int Gen.t -> string arbitrary |
1141 | 1268 | (** Generates strings with distribution of characters of [printable_char]. *) |
1142 | 1269 | |
1143 | 1270 | val small_printable_string : string arbitrary |
1271 | (** Generates strings with a length of [small_nat] | |
1272 | and distribution of characters of [printable_char]. *) | |
1144 | 1273 | |
1145 | 1274 | val numeral_string : string arbitrary |
1146 | (** Generates strings with a distribution of length of [small_nat] | |
1275 | (** Generates strings with a distribution of length of {!Gen.nat} | |
1147 | 1276 | and distribution of characters of [numeral_char]. *) |
1148 | 1277 | |
1149 | 1278 | val numeral_string_of_size : int Gen.t -> string arbitrary |
1150 | 1279 | (** Generates strings with a distribution of characters of [numeral_char]. *) |
1151 | 1280 | |
1152 | 1281 | val list : 'a arbitrary -> 'a list arbitrary |
1153 | (** Generates lists with length generated by [small_nat]. *) | |
1282 | (** Generates lists with length generated by {!Gen.nat}. *) | |
1154 | 1283 | |
1155 | 1284 | val list_of_size : int Gen.t -> 'a arbitrary -> 'a list arbitrary |
1156 | 1285 | (** Generates lists with length from the given distribution. *) |
1157 | 1286 | |
1158 | 1287 | val array : 'a arbitrary -> 'a array arbitrary |
1159 | (** Generates arrays with length generated by [small_nat]. *) | |
1288 | (** Generates arrays with length generated by {!Gen.nat}. *) | |
1160 | 1289 | |
1161 | 1290 | val array_of_size : int Gen.t -> 'a arbitrary -> 'a array arbitrary |
1162 | 1291 | (** Generates arrays with length from the given distribution. *) |
1173 | 1302 | (** Combines four generators into a generator of 4-tuples. |
1174 | 1303 | Order matters for shrinking, see {!Shrink.pair} and the likes *) |
1175 | 1304 | |
1305 | (** {3 Tuple of generators} *) | |
1306 | ||
1307 | (** {4 Shrinks on [gen1], then [gen2], then ... } *) | |
1308 | ||
1309 | val tup2 : | |
1310 | 'a arbitrary -> | |
1311 | 'b arbitrary -> | |
1312 | ('a * 'b) arbitrary | |
1313 | (** Combines two generators into a 2-tuple generator. | |
1314 | Order of elements can matter (w.r.t shrinking, see {!Shrink.tup2}) | |
1315 | Prints as many elements as available printers *) | |
1316 | ||
1317 | val tup3 : | |
1318 | 'a arbitrary -> | |
1319 | 'b arbitrary -> | |
1320 | 'c arbitrary -> | |
1321 | ('a * 'b * 'c) arbitrary | |
1322 | (** Combines three generators into a 3-tuple generator. | |
1323 | Order of elements can matter (w.r.t shrinking, see {!Shrink.tup2}) | |
1324 | Prints as many elements as available printers *) | |
1325 | ||
1326 | val tup4 : | |
1327 | 'a arbitrary -> | |
1328 | 'b arbitrary -> | |
1329 | 'c arbitrary -> | |
1330 | 'd arbitrary -> | |
1331 | ('a * 'b * 'c * 'd) arbitrary | |
1332 | (** Combines four generators into a 4-tuple generator. | |
1333 | Order of elements can matter (w.r.t shrinking, see {!Shrink.tup2}) | |
1334 | Prints as many elements as available printers *) | |
1335 | ||
1336 | val tup5 : 'a arbitrary -> | |
1337 | 'b arbitrary -> | |
1338 | 'c arbitrary -> | |
1339 | 'd arbitrary -> | |
1340 | 'e arbitrary -> | |
1341 | ('a * 'b * 'c * 'd * 'e) arbitrary | |
1342 | (** Combines five generators into a 5-tuple generator. | |
1343 | Order of elements can matter (w.r.t shrinking, see {!Shrink.tup2}) | |
1344 | Prints as many elements as available printers *) | |
1345 | ||
1346 | val tup6 : | |
1347 | 'a arbitrary -> | |
1348 | 'b arbitrary -> | |
1349 | 'c arbitrary -> | |
1350 | 'd arbitrary -> | |
1351 | 'e arbitrary -> | |
1352 | 'f arbitrary -> | |
1353 | ('a * 'b * 'c * 'd * 'e * 'f) arbitrary | |
1354 | (** Combines six generators into a 6-tuple generator. | |
1355 | Order of elements can matter (w.r.t shrinking, see {!Shrink.tup2}) | |
1356 | Prints as many elements as available printers *) | |
1357 | ||
1358 | val tup7 : | |
1359 | 'a arbitrary -> | |
1360 | 'b arbitrary -> | |
1361 | 'c arbitrary -> | |
1362 | 'd arbitrary -> | |
1363 | 'e arbitrary -> | |
1364 | 'f arbitrary -> | |
1365 | 'g arbitrary -> | |
1366 | ('a * 'b * 'c * 'd * 'e * 'f * 'g) arbitrary | |
1367 | (** Combines seven generators into a 7-tuple generator. | |
1368 | Order of elements can matter (w.r.t shrinking, see {!Shrink.tup2}) | |
1369 | Prints as many elements as available printers *) | |
1370 | ||
1371 | val tup8 : | |
1372 | 'a arbitrary -> | |
1373 | 'b arbitrary -> | |
1374 | 'c arbitrary -> | |
1375 | 'd arbitrary -> | |
1376 | 'e arbitrary -> | |
1377 | 'f arbitrary -> | |
1378 | 'g arbitrary -> | |
1379 | 'h arbitrary -> | |
1380 | ('a * 'b * 'c * 'd * 'e * 'f * 'g * 'h) arbitrary | |
1381 | (** Combines eight generators into a 8-tuple generator. | |
1382 | Order of elements can matter (w.r.t shrinking, see {!Shrink.tup2}) | |
1383 | Prints as many elements as available printers *) | |
1384 | ||
1385 | val tup9 : | |
1386 | 'a arbitrary -> | |
1387 | 'b arbitrary -> | |
1388 | 'c arbitrary -> | |
1389 | 'd arbitrary -> | |
1390 | 'e arbitrary -> | |
1391 | 'f arbitrary -> | |
1392 | 'g arbitrary -> | |
1393 | 'h arbitrary -> | |
1394 | 'i arbitrary -> | |
1395 | ('a * 'b * 'c * 'd * 'e * 'f * 'g * 'h * 'i) arbitrary | |
1396 | (** Combines nine generators into a 9-tuple generator. | |
1397 | Order of elements can matter (w.r.t shrinking, see {!Shrink.tup2}) | |
1398 | Prints as many elements as available printers *) | |
1399 | ||
1176 | 1400 | val option : ?ratio:float -> 'a arbitrary -> 'a option arbitrary |
1177 | 1401 | (** Choose between returning Some random value with optional ratio, or None. *) |
1178 | 1402 | |
1179 | 1403 | val fun1_unsafe : 'a arbitrary -> 'b arbitrary -> ('a -> 'b) arbitrary |
1180 | 1404 | (** Generator of functions of arity 1. |
1181 | 1405 | The functions are always pure and total functions: |
1182 | - when given the same argument (as decided by Pervasives.(=)), it returns the same value | |
1406 | - when given the same argument (as decided by Stdlib.(=)), it returns the same value | |
1183 | 1407 | - it never does side effects, like printing or never raise exceptions etc. |
1184 | 1408 | The functions generated are really printable. |
1185 | 1409 |
8 | 8 | |
9 | 9 | let poly_compare=compare |
10 | 10 | |
11 | module RS = Random.State | |
11 | module RS = struct | |
12 | (* Poor man's splitter for version < 5.0 *) | |
13 | (* This definition is shadowed by the [include] on OCaml >=5.0 *) | |
14 | let split rs = | |
15 | let bits = Random.State.bits rs in | |
16 | let rs' = Random.State.make [|bits|] in | |
17 | rs' | |
18 | include Random.State | |
19 | (* This is how OCaml 5.0 splits: *) | |
20 | (* Split a new PRNG off the given PRNG *) | |
21 | (* | |
22 | let split s = | |
23 | let i1 = bits64 s in let i2 = bits64 s in | |
24 | let i3 = bits64 s in let i4 = bits64 s in | |
25 | mk i1 i2 i3 i4 | |
26 | *) | |
27 | end | |
12 | 28 | |
13 | 29 | let rec foldn ~f ~init:acc i = |
14 | 30 | if i = 0 then acc else foldn ~f ~init:(f acc i) (i-1) |
354 | 370 | |
355 | 371 | let neg_int : int t = nat >|= Int.neg |
356 | 372 | |
357 | (** [opt gen] shrinks towards [None] then towards shrinks of [gen]. *) | |
358 | let opt ?(ratio : float = 0.85) (gen : 'a t) : 'a option t = fun st -> | |
373 | (** [option gen] shrinks towards [None] then towards shrinks of [gen]. *) | |
374 | let option ?(ratio : float = 0.85) (gen : 'a t) : 'a option t = fun st -> | |
359 | 375 | let p = RS.float st 1. in |
360 | 376 | if p < (1. -. ratio) |
361 | 377 | then Tree.pure None |
362 | 378 | else Tree.opt (gen st) |
379 | ||
380 | (** [opt] is an alias of {!val:option} for backward compatibility. *) | |
381 | let opt = option | |
363 | 382 | |
364 | 383 | (* Uniform positive random int generator. |
365 | 384 | |
560 | 579 | let flatten_opt (o : 'a t option) : 'a option t = |
561 | 580 | match o with |
562 | 581 | | None -> pure None |
563 | | Some gen -> opt gen | |
582 | | Some gen -> option gen | |
564 | 583 | |
565 | 584 | let flatten_res (res : ('a t, 'e) result) : ('a, 'e) result t = |
566 | 585 | match res with |
599 | 618 | let quad (g1 : 'a t) (g2 : 'b t) (g3 : 'c t) (g4 : 'd t) : ('a * 'b * 'c * 'd) t = |
600 | 619 | (fun a b c d -> (a, b, c, d)) <$> g1 <*> g2 <*> g3 <*> g4 |
601 | 620 | |
621 | let tup2 = pair | |
622 | ||
623 | let tup3 = triple | |
624 | ||
625 | let tup4 = quad | |
626 | ||
627 | let tup5 (g1 : 'a t) (g2 : 'b t) (g3 : 'c t) (g4 : 'd t) (g5 : 'e t) : ('a * 'b * 'c * 'd * 'e) t = | |
628 | (fun a b c d e -> (a, b, c, d, e)) <$> g1 <*> g2 <*> g3 <*> g4 <*> g5 | |
629 | ||
630 | let tup6 (g1 : 'a t) (g2 : 'b t) (g3 : 'c t) (g4 : 'd t) (g5 : 'e t) (g6 : 'f t) : ('a * 'b * 'c * 'd * 'e * 'f) t = | |
631 | (fun a b c d e f -> (a, b, c, d, e, f)) <$> g1 <*> g2 <*> g3 <*> g4 <*> g5 <*> g6 | |
632 | ||
633 | let tup7 (g1 : 'a t) (g2 : 'b t) (g3 : 'c t) (g4 : 'd t) (g5 : 'e t) (g6 : 'f t) (g7 : 'g t) : ('a * 'b * 'c * 'd * 'e * 'f * 'g) t = | |
634 | (fun a b c d e f g -> (a, b, c, d, e, f, g)) <$> g1 <*> g2 <*> g3 <*> g4 <*> g5 <*> g6 <*> g7 | |
635 | ||
636 | let tup8 (g1 : 'a t) (g2 : 'b t) (g3 : 'c t) (g4 : 'd t) (g5 : 'e t) (g6 : 'f t) (g7 : 'g t) (g8 : 'h t) : ('a * 'b * 'c * 'd * 'e * 'f * 'g * 'h) t = | |
637 | (fun a b c d e f g h -> (a, b, c, d, e, f, g, h)) <$> g1 <*> g2 <*> g3 <*> g4 <*> g5 <*> g6 <*> g7 <*> g8 | |
638 | ||
639 | let tup9 (g1 : 'a t) (g2 : 'b t) (g3 : 'c t) (g4 : 'd t) (g5 : 'e t) (g6 : 'f t) (g7 : 'g t) (g8 : 'h t) (g9 : 'i t) : ('a * 'b * 'c * 'd * 'e * 'f * 'g * 'h * 'i) t = | |
640 | (fun a b c d e f g h i -> (a, b, c, d, e, f, g, h, i)) <$> g1 <*> g2 <*> g3 <*> g4 <*> g5 <*> g6 <*> g7 <*> g8 <*> g9 | |
641 | ||
602 | 642 | (** Don't reuse {!int_range} which is much less performant (many more checks because of the possible range and origins). As a [string] generator may call this hundreds or even thousands of times for a single value, it's worth optimizing. *) |
603 | 643 | let char : char t = fun st -> |
604 | 644 | let c = RS.int st 256 in |
608 | 648 | (** The first characters are the usual lower case alphabetical letters to help shrinking. *) |
609 | 649 | let printable_chars : char list = |
610 | 650 | (* Left and right inclusive *) |
611 | let range min max = List.init (max - min) (fun i -> char_of_int (i + min)) in | |
651 | let range min max = List.init (max - min + 1) (fun i -> char_of_int (i + min)) in | |
612 | 652 | let a = 97 in |
613 | 653 | let z = 122 in |
614 | 654 | let lower_alphabet = range a z in |
709 | 749 | let add_shrink_invariant (p : 'a -> bool) (gen : 'a t) : 'a t = |
710 | 750 | fun st -> gen st |> Tree.add_shrink_invariant p |
711 | 751 | |
752 | let set_shrink shrink gen = | |
753 | make_primitive | |
754 | ~gen:(fun st -> gen st |> Tree.root) | |
755 | ~shrink | |
756 | ||
757 | let no_shrink (gen: 'a t) : 'a t = set_shrink (fun _ -> Seq.empty) gen | |
758 | ||
712 | 759 | let (let+) = (>|=) |
713 | 760 | |
714 | 761 | let (and+) = pair |
767 | 814 | let contramap f p x = p (f x) |
768 | 815 | |
769 | 816 | let comap = contramap |
817 | ||
818 | let default = fun _ -> "<no printer>" | |
819 | ||
820 | let tup2 p_a p_b (a, b) = | |
821 | Printf.sprintf "(%s, %s)" (p_a a) (p_b b) | |
822 | ||
823 | let tup2_opt p_a p_b (a, b) = | |
824 | let p_a = Option.value ~default p_a in | |
825 | let p_b = Option.value ~default p_b in | |
826 | tup2 p_a p_b (a, b) | |
827 | ||
828 | let tup3 p_a p_b (p_c) (a, b, c) = | |
829 | Printf.sprintf "(%s, %s, %s)" (p_a a) (p_b b) (p_c c) | |
830 | ||
831 | let tup3_opt p_a p_b p_c (a, b, c) = | |
832 | let p_a = Option.value ~default p_a in | |
833 | let p_b = Option.value ~default p_b in | |
834 | let p_c = Option.value ~default p_c in | |
835 | tup3 p_a p_b p_c (a, b, c) | |
836 | ||
837 | let tup4 p_a p_b p_c p_d (a, b, c, d) = | |
838 | Printf.sprintf "(%s, %s, %s, %s)" | |
839 | (p_a a) (p_b b) | |
840 | (p_c c) (p_d d) | |
841 | ||
842 | let tup4_opt p_a p_b p_c p_d (a, b, c, d) = | |
843 | let p_a = Option.value ~default p_a in | |
844 | let p_b = Option.value ~default p_b in | |
845 | let p_c = Option.value ~default p_c in | |
846 | let p_d = Option.value ~default p_d in | |
847 | tup4 p_a p_b p_c p_d (a, b, c, d) | |
848 | ||
849 | let tup5 p_a p_b p_c p_d p_e (a, b, c, d, e) = | |
850 | Printf.sprintf "(%s, %s, %s, %s, %s)" | |
851 | (p_a a) (p_b b) | |
852 | (p_c c) (p_d d) | |
853 | (p_e e) | |
854 | ||
855 | let tup5_opt p_a p_b p_c p_d p_e (a, b, c, d, e) = | |
856 | let p_a = Option.value ~default p_a in | |
857 | let p_b = Option.value ~default p_b in | |
858 | let p_c = Option.value ~default p_c in | |
859 | let p_d = Option.value ~default p_d in | |
860 | let p_e = Option.value ~default p_e in | |
861 | tup5 p_a p_b p_c p_d p_e (a, b, c, d, e) | |
862 | ||
863 | let tup6 p_a p_b p_c p_d p_e p_f (a, b, c, d, e, f) = | |
864 | Printf.sprintf "(%s, %s, %s, %s, %s, %s)" | |
865 | (p_a a) (p_b b) | |
866 | (p_c c) (p_d d) | |
867 | (p_e e) (p_f f) | |
868 | ||
869 | let tup6_opt p_a p_b p_c p_d p_e p_f (a, b, c, d, e, f) = | |
870 | let p_a = Option.value ~default p_a in | |
871 | let p_b = Option.value ~default p_b in | |
872 | let p_c = Option.value ~default p_c in | |
873 | let p_d = Option.value ~default p_d in | |
874 | let p_e = Option.value ~default p_e in | |
875 | let p_f = Option.value ~default p_f in | |
876 | tup6 p_a p_b p_c p_d p_e p_f (a, b, c, d, e, f) | |
877 | ||
878 | let tup7 p_a p_b p_c p_d p_e p_f p_g (a, b, c, d, e, f, g) = | |
879 | Printf.sprintf "(%s, %s, %s, %s, %s, %s, %s)" | |
880 | (p_a a) (p_b b) | |
881 | (p_c c) (p_d d) | |
882 | (p_e e) (p_f f) | |
883 | (p_g g) | |
884 | ||
885 | let tup7_opt p_a p_b p_c p_d p_e p_f p_g (a, b, c, d, e, f, g) = | |
886 | let p_a = Option.value ~default p_a in | |
887 | let p_b = Option.value ~default p_b in | |
888 | let p_c = Option.value ~default p_c in | |
889 | let p_d = Option.value ~default p_d in | |
890 | let p_e = Option.value ~default p_e in | |
891 | let p_f = Option.value ~default p_f in | |
892 | let p_g = Option.value ~default p_g in | |
893 | tup7 p_a p_b p_c p_d p_e p_f p_g (a, b, c, d, e, f, g) | |
894 | ||
895 | let tup8 p_a p_b p_c p_d p_e p_f p_g p_h (a, b, c, d, e, f, g, h) = | |
896 | Printf.sprintf "(%s, %s, %s, %s, %s, %s, %s, %s)" | |
897 | (p_a a) (p_b b) | |
898 | (p_c c) (p_d d) | |
899 | (p_e e) (p_f f) | |
900 | (p_g g) (p_h h) | |
901 | ||
902 | let tup8_opt p_a p_b p_c p_d p_e p_f p_g p_h (a, b, c, d, e, f, g, h) = | |
903 | let p_a = Option.value ~default p_a in | |
904 | let p_b = Option.value ~default p_b in | |
905 | let p_c = Option.value ~default p_c in | |
906 | let p_d = Option.value ~default p_d in | |
907 | let p_e = Option.value ~default p_e in | |
908 | let p_f = Option.value ~default p_f in | |
909 | let p_g = Option.value ~default p_g in | |
910 | let p_h = Option.value ~default p_h in | |
911 | tup8 p_a p_b p_c p_d p_e p_f p_g p_h (a, b, c, d, e, f, g, h) | |
912 | ||
913 | let tup9 p_a p_b p_c p_d p_e p_f p_g p_h p_i (a, b, c, d, e, f, g, h, i) = | |
914 | Printf.sprintf "(%s, %s, %s, %s, %s, %s, %s, %s, %s)" | |
915 | (p_a a) (p_b b) | |
916 | (p_c c) (p_d d) | |
917 | (p_e e) (p_f f) | |
918 | (p_g g) (p_h h) | |
919 | (p_i i) | |
920 | ||
921 | let tup9_opt p_a p_b p_c p_d p_e p_f p_g p_h p_i (a, b, c, d, e, f, g, h, i) = | |
922 | let p_a = Option.value ~default p_a in | |
923 | let p_b = Option.value ~default p_b in | |
924 | let p_c = Option.value ~default p_c in | |
925 | let p_d = Option.value ~default p_d in | |
926 | let p_e = Option.value ~default p_e in | |
927 | let p_f = Option.value ~default p_f in | |
928 | let p_g = Option.value ~default p_g in | |
929 | let p_h = Option.value ~default p_h in | |
930 | let p_i = Option.value ~default p_i in | |
931 | tup9 p_a p_b p_c p_d p_e p_f p_g p_h p_i (a, b, c, d, e, f, g, h, i) | |
770 | 932 | end |
771 | 933 | |
772 | 934 | (** {2 Observe Values} *) |
801 | 963 | |
802 | 964 | let string (x:string) = Hashtbl.hash x |
803 | 965 | |
804 | let opt f = function | |
966 | let option f = function | |
805 | 967 | | None -> 42 |
806 | 968 | | Some x -> combine 43 (f x) |
807 | 969 | let list f l = List.fold_left (combine_f f) 0x42 l |
820 | 982 | |
821 | 983 | let bool : bool t = (=) |
822 | 984 | |
823 | let float : float t = (=) | |
985 | let float = Float.equal | |
824 | 986 | |
825 | 987 | let unit () () = true |
826 | 988 | |
862 | 1024 | let char = make ~hash:H.char ~eq:Eq.char Print.char |
863 | 1025 | |
864 | 1026 | let option p = |
865 | make ~hash:(H.opt p.hash) ~eq:(Eq.option p.eq) | |
1027 | make ~hash:(H.option p.hash) ~eq:(Eq.option p.eq) | |
866 | 1028 | (Print.option p.print) |
867 | 1029 | |
868 | 1030 | let array p = |
923 | 1085 | let equal = k_obs.Observable.eq |
924 | 1086 | let hash = k_obs.Observable.hash |
925 | 1087 | end) in |
1088 | (* split random state to avoid later failed [get]s to side-effect the current [st] *) | |
1089 | let st' = RS.split st in | |
926 | 1090 | (* make a table |
927 | 1091 | @param extend if [true], extend table [tbl] on the fly (during test execution, to "record" input values and generate an associated output value). [false] during shrinking (use the default value if the input value is not in the table). *) |
928 | 1092 | let make ~extend tbl = |
933 | 1097 | with Not_found -> |
934 | 1098 | if extend then ( |
935 | 1099 | (* Generate a new value and "record" the binding for potential future display/shrinking *) |
936 | let value_tree = v_gen st in | |
1100 | let value_tree = v_gen st' in | |
937 | 1101 | p_tree_bindings_rev := (key, value_tree) :: !p_tree_bindings_rev; |
938 | 1102 | let v = Tree.root value_tree in |
939 | 1103 | T.add tbl key v; |
1209 | 1373 | let is_success r = match r.state with |
1210 | 1374 | | Success -> true |
1211 | 1375 | | Failed _ | Error _ | Failed_other _ -> false |
1376 | ||
1377 | let is_failed r = match r.state with | |
1378 | | Failed _ -> true | |
1379 | | Success | Error _ | Failed_other _ -> false | |
1212 | 1380 | end |
1213 | 1381 | |
1214 | 1382 | module Test_exceptions = struct |
1222 | 1390 | type 'a cell = { |
1223 | 1391 | count : int; (* number of tests to do *) |
1224 | 1392 | long_factor : int; (* multiplicative factor for long test count *) |
1393 | positive : bool; (* indicates whether test is considered positive or negative *) | |
1225 | 1394 | max_gen : int; (* max number of instances to generate (>= count) *) |
1226 | 1395 | max_fail : int; (* max number of failures *) |
1396 | retries : int; (* max number of retries during shrinking *) | |
1227 | 1397 | law : 'a -> bool; (* the law to check *) |
1228 | 1398 | gen : 'a Gen.t; (* how to generate/shrink instances *) |
1229 | 1399 | print : 'a Print.t option; (* how to print values *) |
1254 | 1424 | |
1255 | 1425 | let get_long_factor {long_factor; _} = long_factor |
1256 | 1426 | |
1427 | let get_positive {positive; _} = positive | |
1428 | ||
1257 | 1429 | let default_count = 100 |
1258 | 1430 | |
1259 | let global_count count = | |
1260 | let count = match (count, Sys.getenv_opt "QCHECK_COUNT") with | |
1431 | let default_long_factor = 1 | |
1432 | ||
1433 | let global_nonnegative_var default env_var var = | |
1434 | let var = match (var, Sys.getenv_opt env_var) with | |
1261 | 1435 | | (Some x, _) -> x |
1262 | 1436 | | (_, Some x) -> int_of_string x |
1263 | | (None, None) -> default_count | |
1437 | | (None, None) -> default | |
1264 | 1438 | in |
1265 | if count < 0 then invalid_arg ("count must be > 0 but value is " ^ string_of_int count) else count | |
1439 | if var < 0 then invalid_arg (env_var ^ " must be >= 0 but value is " ^ string_of_int var) else var | |
1440 | ||
1441 | let global_count count = global_nonnegative_var default_count "QCHECK_COUNT" count | |
1442 | ||
1443 | let global_long_factor long_factor = global_nonnegative_var default_long_factor "QCHECK_LONG_FACTOR" long_factor | |
1266 | 1444 | |
1267 | 1445 | let fresh_name = |
1268 | 1446 | let r = ref 0 in |
1271 | 1449 | let default_if_assumptions_fail = `Warning, 0.05 |
1272 | 1450 | |
1273 | 1451 | let make_cell ?(if_assumptions_fail=default_if_assumptions_fail) |
1274 | ?(count) ?(long_factor=1) ?max_gen | |
1275 | ?(max_fail=1) ?(name=fresh_name()) ?print ?collect ?(stats=[]) gen law | |
1452 | ?(count) ?long_factor ?(negative=false) ?max_gen | |
1453 | ?(max_fail=1) ?(retries=1) ?(name=fresh_name()) ?print ?collect ?(stats=[]) gen law | |
1276 | 1454 | = |
1277 | 1455 | let count = global_count count in |
1456 | let long_factor = global_long_factor long_factor in | |
1457 | let positive = not negative in | |
1278 | 1458 | let max_gen = match max_gen with None -> count + 200 | Some x->x in |
1279 | 1459 | { |
1280 | 1460 | law; |
1284 | 1464 | stats; |
1285 | 1465 | max_gen; |
1286 | 1466 | max_fail; |
1467 | retries; | |
1287 | 1468 | name; |
1288 | 1469 | count; |
1289 | 1470 | long_factor; |
1471 | positive; | |
1290 | 1472 | if_assumptions_fail; |
1291 | 1473 | qcheck1_shrink = None; |
1292 | 1474 | } |
1293 | 1475 | |
1294 | 1476 | let make_cell_from_QCheck1 ?(if_assumptions_fail=default_if_assumptions_fail) |
1295 | ?(count) ?(long_factor=1) ?max_gen | |
1296 | ?(max_fail=1) ?(name=fresh_name()) ~gen ?shrink ?print ?collect ~stats law | |
1477 | ?(count) ?long_factor ?(negative=false) ?max_gen | |
1478 | ?(max_fail=1) ?(retries=1) ?(name=fresh_name()) ~gen ?shrink ?print ?collect ~stats law | |
1297 | 1479 | = |
1298 | 1480 | let count = global_count count in |
1481 | let long_factor = global_long_factor long_factor in | |
1482 | let positive = not negative in | |
1299 | 1483 | (* Make a "fake" QCheck2 arbitrary with no shrinking *) |
1300 | 1484 | let fake_gen = Gen.make_primitive ~gen ~shrink:(fun _ -> Seq.empty) in |
1301 | 1485 | let max_gen = match max_gen with None -> count + 200 | Some x->x in |
1307 | 1491 | stats; |
1308 | 1492 | max_gen; |
1309 | 1493 | max_fail; |
1494 | retries; | |
1310 | 1495 | name; |
1311 | 1496 | count; |
1312 | 1497 | long_factor; |
1498 | positive; | |
1313 | 1499 | if_assumptions_fail; |
1314 | 1500 | qcheck1_shrink = shrink; |
1315 | 1501 | } |
1316 | 1502 | |
1317 | let make ?if_assumptions_fail ?count ?long_factor ?max_gen ?max_fail ?name ?print ?collect ?stats gen law = | |
1318 | Test (make_cell ?if_assumptions_fail ?count ?long_factor ?max_gen ?max_fail ?name ?print ?collect ?stats gen law) | |
1503 | let make' ?if_assumptions_fail ?count ?long_factor ?max_gen ?max_fail ?retries ?name ?print ?collect ?stats ~negative arb law = | |
1504 | Test (make_cell ?if_assumptions_fail ?count ?long_factor ?max_gen ?max_fail ?retries ?name ?print ?collect ?stats ~negative arb law) | |
1505 | ||
1506 | let make = make' ~negative:false | |
1507 | let make_neg = make' ~negative:true | |
1319 | 1508 | |
1320 | 1509 | let test_get_count (Test cell) = get_count cell |
1510 | ||
1511 | let test_get_long_factor (Test cell) = get_long_factor cell | |
1321 | 1512 | |
1322 | 1513 | (** {6 Running the test} *) |
1323 | 1514 | |
1406 | 1597 | | Run_ok |
1407 | 1598 | | Run_fail of string list |
1408 | 1599 | |
1409 | let run_law law x = | |
1600 | (* run_law is a helper function for testing a property [law] on a | |
1601 | generated input [x]. | |
1602 | ||
1603 | When passed a ~retries number n>1, the tested property is checked | |
1604 | n times for each shrunk input candidate. The default value is 1, | |
1605 | thus causing no change in behaviour. | |
1606 | ||
1607 | Retrying a property can be useful when testing non-deterministic | |
1608 | code with QCheck, e.g., for multicore execution. The idea is | |
1609 | described in | |
1610 | 'Testing a Database for Race Conditions with QuickCheck' | |
1611 | Hughes and Bolinder, Erlang 2011, Sec.6: | |
1612 | ||
1613 | "As we explained in section 4, we ensure that tests fail when | |
1614 | races are present simply by repeating each test a large number of | |
1615 | times, and by running on a dual core machine. We obtained the | |
1616 | minimal failing cases in the previous section by repeating each | |
1617 | test 100 times during shrinking: thus we stopped shrinking a test | |
1618 | case only when all of its candidate shrinkings passed 100 tests | |
1619 | in a row." *) | |
1620 | let run_law ~retries law x = | |
1621 | let rec loop i = match law x with | |
1622 | | false -> Run_fail [] | |
1623 | | true -> | |
1624 | if i<=1 then Run_ok else loop (i-1) in | |
1410 | 1625 | try |
1411 | if law x then Run_ok else Run_fail [] | |
1626 | loop retries | |
1412 | 1627 | with User_fail msg -> Run_fail [msg] |
1413 | 1628 | |
1414 | 1629 | (* QCheck1-compatibility code *) |
1438 | 1653 | try |
1439 | 1654 | incr count; |
1440 | 1655 | st.handler st.test.name st.test (Shrinking (steps, !count, x)); |
1441 | begin match run_law st.test.law x with | |
1656 | begin match run_law ~retries:st.test.retries st.test.law x with | |
1442 | 1657 | | Run_fail m when not is_err -> Some (Tree.pure x, Shrink_fail, m) |
1443 | 1658 | | _ -> None |
1444 | 1659 | end |
1453 | 1668 | try |
1454 | 1669 | incr count; |
1455 | 1670 | st.handler st.test.name st.test (Shrinking (steps, !count, x)); |
1456 | begin match run_law st.test.law x with | |
1671 | begin match run_law ~retries:st.test.retries st.test.law x with | |
1457 | 1672 | | Run_fail m when not is_err -> Some (x_tree, Shrink_fail, m) |
1458 | 1673 | | _ -> None |
1459 | 1674 | end |
1531 | 1746 | let res = |
1532 | 1747 | try |
1533 | 1748 | state.handler state.test.name state.test (Testing input); |
1534 | begin match run_law state.test.law input with | |
1749 | begin match run_law ~retries:1 state.test.law input with | |
1535 | 1750 | | Run_ok -> |
1536 | 1751 | (* one test ok *) |
1537 | 1752 | decr_count state; |
1754 | 1969 | let print_fail_other name ~msg = |
1755 | 1970 | print_test_fail name [msg] |
1756 | 1971 | |
1972 | let print_expected_failure cell c_exs = match c_exs with | |
1973 | | [] -> Format.sprintf "negative test `%s` failed as expected\n" (get_name cell) | |
1974 | | c_ex::_ -> Format.sprintf "negative test `%s` failed as expected on: %s\n" (get_name cell) (print_c_ex cell c_ex) | |
1975 | ||
1757 | 1976 | let print_error ?(st="") arb name (i,e) = |
1758 | 1977 | print_test_error name (print_c_ex arb i) e st |
1759 | 1978 | |
1767 | 1986 | | R.Failed_other {msg} -> |
1768 | 1987 | raise (Test_fail (cell.name, [msg])) |
1769 | 1988 | |
1770 | let check_cell_exn ?long ?call ?step ?rand cell = | |
1771 | let res = check_cell ?long ?call ?step ?rand cell in | |
1989 | let check_cell_exn ?long ?call ?step ?handler ?rand cell = | |
1990 | let res = check_cell ?long ?call ?step ?handler ?rand cell in | |
1772 | 1991 | check_result cell res |
1773 | 1992 | |
1774 | 1993 | let check_exn ?long ?rand (Test cell) = check_cell_exn ?long ?rand cell |
279 | 279 | - [32] to [126], inclusive |
280 | 280 | - ['\n'] |
281 | 281 | |
282 | Shrinks towards ['a']. | |
282 | Shrinks towards ['a'] or lower character codes. | |
283 | 283 | *) |
284 | 284 | |
285 | 285 | val numeral : char t |
372 | 372 | keep it and wait for users feedback (hence deprecation to raise attention). |
373 | 373 | *) |
374 | 374 | |
375 | val set_shrink : ('a -> 'a Seq.t) -> 'a t -> 'a t | |
376 | (** [set_shrink shrink gen] sets the shrinker to [shrink] for [gen]. *) | |
377 | ||
378 | val no_shrink : 'a t -> 'a t | |
379 | (** [no_shrink gen] returns a generator using [gen] but with shrinking | |
380 | disabled *) | |
381 | ||
375 | 382 | (** {3 Ranges} *) |
376 | 383 | |
377 | 384 | val int_bound : int -> int t |
594 | 601 | Shrinks on elements only. |
595 | 602 | *) |
596 | 603 | |
597 | val opt : ?ratio:float -> 'a t -> 'a option t | |
598 | (** [opt gen] is an [option] generator that uses [gen] when generating [Some] values. | |
604 | val option : ?ratio:float -> 'a t -> 'a option t | |
605 | (** [option gen] is an [option] generator that uses [gen] when generating [Some] values. | |
599 | 606 | |
600 | 607 | Shrinks towards {!None} then towards shrinks of [gen]. |
601 | 608 | |
602 | 609 | @param ratio a float between [0.] and [1.] indicating the probability of a sample to be [Some _] |
603 | 610 | rather than [None] (value is [0.85]). |
604 | *) | |
611 | ||
612 | @since 0.19 (renamed from [opt]) | |
613 | *) | |
614 | ||
615 | val opt : ?ratio:float -> 'a t -> 'a option t | |
616 | (** [opt] is an alias of {!val:option} for backward compatibility. *) | |
605 | 617 | |
606 | 618 | (** {3 Combining generators} *) |
607 | 619 | |
624 | 636 | |
625 | 637 | @since 0.5.1 |
626 | 638 | *) |
639 | ||
640 | (** {3 Tuple of generators} *) | |
641 | ||
642 | (** {4 Shrinks on [gen1], then [gen2], then ... } *) | |
643 | ||
644 | val tup2 : 'a t -> 'b t -> ('a * 'b) t | |
645 | ||
646 | val tup3 : 'a t -> 'b t -> 'c t -> ('a * 'b * 'c) t | |
647 | ||
648 | val tup4 : 'a t -> 'b t -> 'c t -> 'd t -> ('a * 'b * 'c * 'd) t | |
649 | ||
650 | val tup5 : 'a t -> 'b t -> 'c t -> 'd t -> 'e t -> ('a * 'b * 'c * 'd * 'e) t | |
651 | ||
652 | val tup6 : 'a t -> 'b t -> 'c t -> 'd t -> 'e t -> 'f t -> ('a * 'b * 'c * 'd * 'e * 'f) t | |
653 | ||
654 | val tup7 : 'a t -> 'b t -> 'c t -> 'd t -> 'e t -> 'f t -> 'g t -> ('a * 'b * 'c * 'd * 'e * 'f * 'g) t | |
655 | ||
656 | val tup8 : 'a t -> 'b t -> 'c t -> 'd t -> 'e t -> 'f t -> 'g t -> 'h t -> ('a * 'b * 'c * 'd * 'e * 'f * 'g * 'h) t | |
657 | ||
658 | val tup9 : 'a t -> 'b t -> 'c t -> 'd t -> 'e t -> 'f t -> 'g t -> 'h t -> 'i t -> ('a * 'b * 'c * 'd * 'e * 'f * 'g * 'h * 'i) t | |
627 | 659 | |
628 | 660 | (** {3 Convert a structure of generator to a generator of structure} *) |
629 | 661 | |
1035 | 1067 | |
1036 | 1068 | val comap : ('b -> 'a) -> 'a t -> 'b t |
1037 | 1069 | (** @deprecated use {!contramap} instead. *) |
1070 | ||
1071 | val tup2 : 'a t -> 'b t -> ('a * 'b) t | |
1072 | (** 2-tuple printer. Expects printers for each component. *) | |
1073 | ||
1074 | val tup3 : 'a t -> 'b t -> 'c t -> ('a * 'b * 'c) t | |
1075 | (** 3-tuple printer. Expects printers for each component. *) | |
1076 | ||
1077 | val tup4 : 'a t -> 'b t -> 'c t -> 'd t -> ('a * 'b * 'c * 'd) t | |
1078 | (** 4-tuple printer. Expects printers for each component. *) | |
1079 | ||
1080 | val tup5 : 'a t -> 'b t -> 'c t -> 'd t -> 'e t -> ('a * 'b * 'c * 'd * 'e) t | |
1081 | (** 5-tuple printer. Expects printers for each component. *) | |
1082 | ||
1083 | val tup6 : 'a t -> 'b t -> 'c t -> 'd t -> 'e t -> 'f t -> | |
1084 | ('a * 'b * 'c * 'd * 'e * 'f) t | |
1085 | (** 6-tuple printer. Expects printers for each component. *) | |
1086 | ||
1087 | val tup7 : 'a t -> 'b t -> 'c t -> 'd t -> 'e t -> 'f t -> 'g t -> | |
1088 | ('a * 'b * 'c * 'd * 'e * 'f * 'g) t | |
1089 | (** 7-tuple printer. Expects printers for each component. *) | |
1090 | ||
1091 | val tup8 : 'a t -> 'b t -> 'c t -> 'd t -> 'e t -> 'f t -> 'g t -> 'h t -> | |
1092 | ('a * 'b * 'c * 'd * 'e * 'f * 'g * 'h) t | |
1093 | (** 8-tuple printer. Expects printers for each component. *) | |
1094 | ||
1095 | val tup9 : 'a t -> 'b t -> 'c t -> 'd t -> 'e t -> 'f t -> 'g t -> 'h t -> 'i t -> | |
1096 | ('a * 'b * 'c * 'd * 'e * 'f * 'g * 'h * 'i) t | |
1097 | (** 9-tuple printer. Expects printers for each component. *) | |
1038 | 1098 | end |
1039 | 1099 | |
1040 | 1100 | (** Shrinking helper functions. *) |
1483 | 1543 | @since 0.18 *) |
1484 | 1544 | |
1485 | 1545 | val is_success : _ t -> bool |
1486 | (** Returns true iff the state if [Success] | |
1546 | (** Returns true iff the state is [Success] | |
1487 | 1547 | @since 0.9 *) |
1548 | ||
1549 | val is_failed : _ t -> bool | |
1550 | (** Returns true iff the state is [Failed _] *) | |
1488 | 1551 | |
1489 | 1552 | val stats : 'a t -> ('a stat * (int,int) Hashtbl.t) list |
1490 | 1553 | (** Obtain statistics |
1516 | 1579 | stacktrace (if enabled) or an empty string. *) |
1517 | 1580 | end |
1518 | 1581 | |
1519 | (** A test is a pair of an generator and a property thar all generated values must satisfy. *) | |
1582 | (** A test is a pair of a generator and a property that all generated values must satisfy. *) | |
1520 | 1583 | module Test : sig |
1521 | 1584 | (** The main features of this module are: |
1522 | - {!make} a test | |
1523 | - fail the test if a property does not hold (using either the {{!fail_report} simple} form or the {{!fail_reportf} rich} form) | |
1524 | - {!check_exn} a single test | |
1585 | - {!make} to create a test | |
1586 | - {!make_neg} to create a negative test that is expected not to satisfy the tested property | |
1587 | - {!check_exn} to run a single test with a simple runner. | |
1588 | ||
1589 | A test fails if the property does not hold for a given input. The {{!fail_report} simple} form or the {{!fail_reportf} rich} form) offer more elaborate forms to fail a test. | |
1525 | 1590 | |
1526 | 1591 | Note that while {!check_exn} is provided for convenience to discover QCheck or to run a single test in {{: https://opam.ocaml.org/blog/about-utop/} utop}, to run QCheck tests in your project you probably want to opt for a more advanced runner, or convert |
1527 | 1592 | QCheck tests to your favorite test framework: |
1533 | 1598 | type 'a cell |
1534 | 1599 | (** A single property test on a value of type ['a]. A {!Test.t} wraps a [cell] |
1535 | 1600 | and hides its type parameter. *) |
1536 | ||
1601 | ||
1537 | 1602 | val make_cell : |
1538 | 1603 | ?if_assumptions_fail:([`Fatal | `Warning] * float) -> |
1539 | ?count:int -> ?long_factor:int -> ?max_gen:int -> ?max_fail:int -> ?name:string -> | |
1540 | ?print:'a Print.t -> ?collect:('a -> string) -> ?stats:('a stat list) -> | |
1604 | ?count:int -> ?long_factor:int -> ?negative:bool -> ?max_gen:int -> ?max_fail:int -> ?retries:int -> | |
1605 | ?name:string -> ?print:'a Print.t -> ?collect:('a -> string) -> ?stats:('a stat list) -> | |
1541 | 1606 | 'a Gen.t -> ('a -> bool) -> |
1542 | 1607 | 'a cell |
1543 | 1608 | (** [make_cell gen prop] builds a test that checks property [prop] on instances |
1547 | 1612 | the test cases which satisfy preconditions. |
1548 | 1613 | @param long_factor the factor by which to multiply count, max_gen and |
1549 | 1614 | max_fail when running a long test (default: 1). |
1615 | @param negative whether the test is expected not to satisfy the tested property. | |
1550 | 1616 | @param max_gen maximum number of times the generation function |
1551 | 1617 | is called in total to replace inputs that do not satisfy |
1552 | 1618 | preconditions (should be >= count). |
1553 | 1619 | @param max_fail maximum number of failures before we stop generating |
1554 | 1620 | inputs. This is useful if shrinking takes too much time. |
1621 | @param retries number of times to retry the tested property while shrinking. | |
1555 | 1622 | @param if_assumptions_fail the minimum |
1556 | 1623 | fraction of tests that must satisfy the precondition for a success |
1557 | 1624 | to be considered valid. |
1566 | 1633 | |
1567 | 1634 | val make_cell_from_QCheck1 : |
1568 | 1635 | ?if_assumptions_fail:([`Fatal | `Warning] * float) -> |
1569 | ?count:int -> ?long_factor:int -> ?max_gen:int -> ?max_fail:int -> | |
1570 | ?name:string -> gen:(Random.State.t -> 'a) -> ?shrink:('a -> ('a -> unit) -> unit) -> | |
1636 | ?count:int -> ?long_factor:int -> ?negative:bool -> ?max_gen:int -> ?max_fail:int -> | |
1637 | ?retries:int -> ?name:string -> gen:(Random.State.t -> 'a) -> ?shrink:('a -> ('a -> unit) -> unit) -> | |
1571 | 1638 | ?print:('a -> string) -> ?collect:('a -> string) -> stats:'a stat list -> ('a -> bool) -> |
1572 | 1639 | 'a cell |
1573 | (** ⚠️ Do not use, this is exposed for internal reasons only. ⚠️ | |
1640 | (** ⚠️ Do not use, this is exposed for internal reasons only. ⚠️ | |
1574 | 1641 | |
1575 | 1642 | @deprecated Migrate to QCheck2 and use {!make_cell} instead. |
1576 | 1643 | *) |
1591 | 1658 | (** Get the long factor of a cell. |
1592 | 1659 | @since 0.5.3 *) |
1593 | 1660 | |
1661 | val get_positive : _ cell -> bool | |
1662 | (** Get the expected mode of a cell: positive indicates expected to satisfy the tested property, negative indicates expected not to satisfy the tested property. *) | |
1663 | ||
1594 | 1664 | type t = Test : 'a cell -> t |
1595 | 1665 | (** Same as ['a cell], but masking the type parameter. This allows to |
1596 | 1666 | put tests on different types in the same list of tests. *) |
1597 | 1667 | |
1598 | 1668 | val make : |
1599 | 1669 | ?if_assumptions_fail:([`Fatal | `Warning] * float) -> |
1600 | ?count:int -> ?long_factor:int -> ?max_gen:int -> ?max_fail:int -> ?name:string -> | |
1601 | ?print:('a Print.t) -> ?collect:('a -> string) -> ?stats:('a stat list) -> | |
1670 | ?count:int -> ?long_factor:int -> ?max_gen:int -> ?max_fail:int -> ?retries:int -> | |
1671 | ?name:string -> ?print:('a Print.t) -> ?collect:('a -> string) -> ?stats:('a stat list) -> | |
1602 | 1672 | 'a Gen.t -> ('a -> bool) -> t |
1603 | 1673 | (** [make gen prop] builds a test that checks property [prop] on instances |
1604 | 1674 | of the generator [gen]. |
1605 | 1675 | See {!make_cell} for a description of the parameters. |
1606 | 1676 | *) |
1607 | 1677 | |
1678 | val make_neg : | |
1679 | ?if_assumptions_fail:([`Fatal | `Warning] * float) -> | |
1680 | ?count:int -> ?long_factor:int -> ?max_gen:int -> ?max_fail:int -> ?retries:int -> | |
1681 | ?name:string -> ?print:('a Print.t) -> ?collect:('a -> string) -> ?stats:('a stat list) -> | |
1682 | 'a Gen.t -> ('a -> bool) -> t | |
1683 | (** [make_neg gen prop] builds a test that checks property [prop] on instances | |
1684 | of the generator [gen]. | |
1685 | The test is considered negative, meaning that it is expected not to satisfy the tested property. | |
1686 | This information is recorded in an underlying test [cell] entry and interpreted suitably by test runners. | |
1687 | See {!make_cell} for a description of the parameters. | |
1688 | *) | |
1689 | ||
1608 | 1690 | val test_get_count : t -> int |
1691 | ||
1692 | val test_get_long_factor : t -> int | |
1609 | 1693 | |
1610 | 1694 | val fail_report : string -> 'a |
1611 | 1695 | (** Fail the test with some additional message that will be reported. |
1631 | 1715 | val print_c_ex : 'a cell -> 'a TestResult.counter_ex -> string |
1632 | 1716 | val print_fail : 'a cell -> string -> 'a TestResult.counter_ex list -> string |
1633 | 1717 | val print_fail_other : string -> msg:string -> string |
1718 | val print_expected_failure : 'a cell -> 'a TestResult.counter_ex list -> string | |
1634 | 1719 | val print_error : ?st:string -> 'a cell -> string -> 'a TestResult.counter_ex * exn -> string |
1635 | 1720 | val print_test_fail : string -> string list -> string |
1636 | 1721 | val print_test_error : string -> string -> exn -> string -> string |
1646 | 1731 | val check_result : 'a cell -> 'a TestResult.t -> unit |
1647 | 1732 | (** [check_result cell res] checks that [res] is [Ok _], and returns unit. |
1648 | 1733 | Otherwise, it raises some exception. |
1649 | @raise Test_error if [res = Error _] | |
1650 | @raise Test_error if [res = Failed _] *) | |
1734 | @raise Test_fail if [res = Failed _] | |
1735 | @raise Test_error if [res = Error _] *) | |
1651 | 1736 | |
1652 | 1737 | type res = |
1653 | 1738 | | Success |
1691 | 1776 | *) |
1692 | 1777 | |
1693 | 1778 | val check_cell_exn : |
1694 | ?long:bool -> ?call:'a callback -> ?step:'a step -> | |
1779 | ?long:bool -> ?call:'a callback -> | |
1780 | ?step:'a step -> ?handler:'a handler -> | |
1695 | 1781 | ?rand:Random.State.t -> 'a cell -> unit |
1696 | 1782 | (** Same as {!check_cell} but calls {!check_result} on the result. |
1697 | @raise Test_error if [res = Error _] | |
1698 | @raise Test_error if [res = Failed _] *) | |
1783 | @raise Test_fail if [res = Failed _] | |
1784 | @raise Test_error if [res = Error _] *) | |
1699 | 1785 | |
1700 | 1786 | val check_exn : ?long:bool -> ?rand:Random.State.t -> t -> unit |
1701 | 1787 | (** Checks the property against some test cases, and calls {!check_result}, |
1702 | 1788 | which might raise an exception in case of failure. |
1703 | @raise Test_error if [res = Error _] | |
1704 | @raise Test_error if [res = Failed _] *) | |
1789 | @raise Test_fail if [res = Failed _] | |
1790 | @raise Test_error if [res = Error _] *) | |
1705 | 1791 | end |
1706 | 1792 | |
1707 | 1793 | (** {2 Sub-tests} *) |
1 | 1 | open OUnit |
2 | 2 | open QCheck_base_runner |
3 | 3 | |
4 | let ps = print_string | |
4 | let ps = Printf.printf "%s" | |
5 | 5 | let va = Printf.sprintf |
6 | 6 | let pf = Printf.printf |
7 | 7 | |
71 | 71 | fail = (fun fmt -> Printf.ksprintf assert_failure fmt); |
72 | 72 | err = (fun fmt -> logf ctxt `Error fmt); |
73 | 73 | } in |
74 | T.check_cell_exn cell | |
75 | ~long ~rand ~call:(Raw.callback ~colors:false ~verbose ~print_res:true ~print)) | |
74 | if QCheck2.Test.get_positive cell | |
75 | then | |
76 | T.check_cell_exn cell | |
77 | ~long ~rand ~call:(Raw.callback ~colors:false ~verbose ~print_res:true ~print) | |
78 | else | |
79 | try | |
80 | T.check_cell_exn cell | |
81 | ~long ~rand ~call:(Raw.callback ~colors:false ~verbose ~print_res:true ~print); | |
82 | () | |
83 | with T.Test_fail (_,_) -> ()) | |
76 | 84 | |
77 | 85 | let to_ounit2_test_list ?rand lst = |
78 | 86 | List.rev (List.rev_map (to_ounit2_test ?rand) lst) |
84 | 92 | let module T = QCheck2.Test in |
85 | 93 | let name = T.get_name cell in |
86 | 94 | let run () = |
87 | try | |
88 | T.check_cell_exn cell ~long ~rand | |
89 | ~call:(Raw.callback ~colors:false ~verbose ~print_res:verbose ~print:Raw.print_std); | |
90 | true | |
91 | with T.Test_fail _ -> | |
92 | false | |
95 | ||
96 | let res = | |
97 | try | |
98 | T.check_cell_exn cell ~long ~rand | |
99 | ~call:(Raw.callback ~colors:false ~verbose ~print_res:verbose ~print:Raw.print_std); | |
100 | true | |
101 | with T.Test_fail _ -> | |
102 | false | |
103 | in | |
104 | if QCheck2.Test.get_positive cell | |
105 | then res | |
106 | else not res | |
93 | 107 | in |
94 | 108 | name >:: (fun () -> assert_bool name (run ())) |
95 | 109 |
0 | open Ppxlib | |
1 | ||
2 | (** This module contains all generators from QCheck used to | |
3 | derive a type declaration *) | |
4 | ||
5 | (** {2. Type} *) | |
6 | ||
7 | let ty = Ldot (Ldot (Lident "QCheck", "Gen"), "t") | |
8 | ||
9 | (** {2. Primitive generators} *) | |
10 | ||
11 | let unit loc = [%expr QCheck.Gen.unit] | |
12 | ||
13 | let int loc = [%expr QCheck.Gen.int] | |
14 | ||
15 | let string loc = [%expr QCheck.Gen.string] | |
16 | ||
17 | let char loc = [%expr QCheck.Gen.char] | |
18 | ||
19 | let bool loc = [%expr QCheck.Gen.bool] | |
20 | ||
21 | let float loc = [%expr QCheck.Gen.float] | |
22 | ||
23 | let int32 loc = [%expr QCheck.Gen.ui32] | |
24 | ||
25 | let int64 loc = [%expr QCheck.Gen.ui64] | |
26 | ||
27 | let option ~loc e = [%expr QCheck.Gen.option [%e e]] | |
28 | ||
29 | let list ~loc e = [%expr QCheck.Gen.list [%e e]] | |
30 | ||
31 | let array ~loc e = [%expr QCheck.Gen.array [%e e]] | |
32 | ||
33 | (** {2. Generator combinators} *) | |
34 | ||
35 | let pure ~loc x = [%expr QCheck.Gen.pure [%e x]] | |
36 | ||
37 | let frequency ~loc l = | |
38 | match l with | |
39 | | [%expr [([%e? _], [%e? x])]] -> x | |
40 | | _ -> | |
41 | [%expr QCheck.Gen.frequency [%e l]] | |
42 | ||
43 | let map ~loc pat expr gen = | |
44 | [%expr QCheck.Gen.map (fun [%p pat] -> [%e expr]) [%e gen]] | |
45 | ||
46 | let pair ~loc a b = | |
47 | [%expr QCheck.Gen.pair [%e a] [%e b]] | |
48 | ||
49 | let triple ~loc a b c = | |
50 | [%expr QCheck.Gen.triple [%e a] [%e b] [%e c]] | |
51 | ||
52 | let quad ~loc a b c d= | |
53 | [%expr QCheck.Gen.quad [%e a] [%e b] [%e c] [%e d]] | |
54 | ||
55 | let sized ~loc e = | |
56 | [%expr QCheck.Gen.sized @@ [%e e]] | |
57 | ||
58 | let fix ~loc e = | |
59 | [%expr QCheck.Gen.fix [%e e]] | |
60 | ||
61 | (** Observable generators *) | |
62 | module Observable = struct | |
63 | (** {2. Primitive generators} *) | |
64 | let unit loc = [%expr QCheck.Observable.unit] | |
65 | ||
66 | let int loc = [%expr QCheck.Observable.int] | |
67 | ||
68 | let string loc = [%expr QCheck.Observable.string] | |
69 | ||
70 | let char loc = [%expr QCheck.Observable.char] | |
71 | ||
72 | let bool loc = [%expr QCheck.Observable.bool] | |
73 | ||
74 | let float loc = [%expr QCheck.Observable.float] | |
75 | ||
76 | let int32 loc = [%expr QCheck.Observable.int32] | |
77 | ||
78 | let int64 loc = [%expr QCheck.Observable.int64] | |
79 | ||
80 | let option ~loc e = [%expr QCheck.Observable.option [%e e]] | |
81 | ||
82 | let list ~loc e = [%expr QCheck.Observable.list [%e e]] | |
83 | ||
84 | let array ~loc e = [%expr QCheck.Observable.array [%e e]] | |
85 | ||
86 | (** {2. Observable combinators} *) | |
87 | let pair ~loc a b = | |
88 | [%expr QCheck.Observable.pair [%e a] [%e b]] | |
89 | ||
90 | let triple ~loc a b c = | |
91 | [%expr QCheck.Observable.triple [%e a] [%e b] [%e c]] | |
92 | ||
93 | let quad ~loc a b c d= | |
94 | [%expr QCheck.Observable.quad [%e a] [%e b] [%e c] [%e d]] | |
95 | end |
0 | # ppx_deriving_qcheck | |
1 | ||
2 | ## Generator | |
3 | Derive `QCheck.Gen.t` from a type declaration | |
4 | ||
5 | ```ocaml | |
6 | type tree = Leaf of int | Node of tree * tree | |
7 | [@@deriving qcheck] | |
8 | ||
9 | let rec rev tree = match tree with | |
10 | | Leaf _ -> tree | |
11 | | Node (left, right) -> Node (rev right, rev left) | |
12 | ||
13 | let test = | |
14 | QCheck.Test.make | |
15 | ~name:"tree -> rev (rev tree) = tree" | |
16 | (QCheck.make gen_tree) | |
17 | (fun tree -> rev (rev tree) = tree) | |
18 | ``` | |
19 | ||
20 | For `type tree` we derive two generators: | |
21 | - `val gen_tree : tree Gen.t` and | |
22 | - `val gen_tree_sized : int -> tree Gen.t` | |
23 | ||
24 | For non-recursive types the latter is however not derived. | |
25 | ||
26 | For types with the name `t` (i.e. `type t = ...`) which is a common idiom in OCaml code, | |
27 | the deriver omits the name from the derived generators, | |
28 | thus producing `val gen : t Gen.t` and optionally `val gen_sized : int -> t Gen.t`. | |
29 | ||
30 | ### Overwrite generator | |
31 | If you wan't to specify your own `generator` for any type you can | |
32 | add an attribute to the type: | |
33 | ||
34 | ```ocaml | |
35 | type t = (int : [@gen QCheck.Gen.(0 -- 10)]) | |
36 | [@@deriving qcheck] | |
37 | ||
38 | (* produces ==> *) | |
39 | ||
40 | let gen : t QCheck.Gen.t = QCheck.Gen.(0 -- 10) | |
41 | ``` | |
42 | ||
43 | This attribute has 2 advantages: | |
44 | * Use your own generator for a specific type (see above) | |
45 | * There is no generator available for the type | |
46 | ```ocaml | |
47 | type my_foo = | |
48 | | Foo of my_other_type | |
49 | | Bar of bool | |
50 | [@@deriving qcheck] | |
51 | ^^^^^^^^^^^^^^^^ | |
52 | Error: Unbound value gen_my_other_type | |
53 | ||
54 | (* Possible fix *) | |
55 | let gen_my_other_type = (* add your implementation here *) | |
56 | ||
57 | type my_foo = | |
58 | | Foo of my_other_type [@gen gen_my_other_type] | |
59 | | Bar of bool | |
60 | [@@deriving qcheck] | |
61 | ``` | |
62 | ||
63 | ## How to use | |
64 | ||
65 | Add to your OCaml libraries with dune | |
66 | ```ocaml | |
67 | ... | |
68 | (preprocess (pps ppx_deriving_qcheck))) | |
69 | ... | |
70 | ``` | |
71 | ||
72 | ## Supported types | |
73 | ||
74 | ### Primitive types | |
75 | ||
76 | * Unit | |
77 | ```ocaml | |
78 | type t = unit [@@deriving qcheck] | |
79 | ||
80 | (* ==> *) | |
81 | ||
82 | let gen = QCheck.Gen.unit | |
83 | ``` | |
84 | ||
85 | * Bool | |
86 | ```ocaml | |
87 | type t = bool [@@deriving qcheck] | |
88 | ||
89 | (* ==> *) | |
90 | ||
91 | let gen = QCheck.Gen.bool | |
92 | ``` | |
93 | ||
94 | * Integer | |
95 | ```ocaml | |
96 | type t = int [@@deriving qcheck] | |
97 | ||
98 | (* ==> *) | |
99 | ||
100 | let gen = QCheck.Gen.int | |
101 | ``` | |
102 | ||
103 | * Float | |
104 | ```ocaml | |
105 | type t = float [@@deriving qcheck] | |
106 | ||
107 | (* ==> *) | |
108 | ||
109 | let gen = QCheck.Gen.float | |
110 | ``` | |
111 | ||
112 | * String | |
113 | ```ocaml | |
114 | type t = string [@@deriving qcheck] | |
115 | ||
116 | (* ==> *) | |
117 | ||
118 | let gen = QCheck.Gen.string | |
119 | ``` | |
120 | ||
121 | * Char | |
122 | ```ocaml | |
123 | type t = char [@@deriving qcheck] | |
124 | ||
125 | (* ==> *) | |
126 | ||
127 | let gen = QCheck.Gen.char | |
128 | ``` | |
129 | ||
130 | * Option | |
131 | ```ocaml | |
132 | type 'a t = 'a option [@@deriving qcheck] | |
133 | ||
134 | (* ==> *) | |
135 | ||
136 | let gen gen_a = QCheck.Gen.option gen_a | |
137 | ``` | |
138 | ||
139 | * List | |
140 | ```ocaml | |
141 | type 'a t = 'a list [@@deriving qcheck] | |
142 | ||
143 | (* ==> *) | |
144 | ||
145 | let gen gen_a = QCheck.Gen.list gen_a | |
146 | ``` | |
147 | ||
148 | * Array | |
149 | ```ocaml | |
150 | type 'a t = 'a array [@@deriving qcheck] | |
151 | ||
152 | (* ==> *) | |
153 | ||
154 | let gen gen_a = QCheck.Gen.array gen_a | |
155 | ``` | |
156 | ||
157 | ### Tuples of size `n` | |
158 | ||
159 | * n = 2 | |
160 | ```ocaml | |
161 | type t = int * int [@@deriving qcheck] | |
162 | ||
163 | (* ==> *) | |
164 | ||
165 | let gen = QCheck.Gen.pair QCheck.Gen.int QCheck.Gen.int | |
166 | ``` | |
167 | ||
168 | * n = 3 | |
169 | ```ocaml | |
170 | type t = int * int * int [@@deriving qcheck] | |
171 | ||
172 | (* ==> *) | |
173 | ||
174 | let gen = QCheck.Gen.triple QCheck.Gen.int QCheck.Gen.int QCheck.Gen.int | |
175 | ``` | |
176 | ||
177 | * n = 4 | |
178 | ```ocaml | |
179 | type t = int * int * int * int [@@deriving qcheck] | |
180 | ||
181 | (* ==> *) | |
182 | ||
183 | let gen = QCheck.Gen.quad QCheck.Gen.int QCheck.Gen.int QCheck.Gen.int QCheck.Gen.int | |
184 | ``` | |
185 | ||
186 | * n > 4, tuples are split between pairs, for instance n = 8 | |
187 | ```ocaml | |
188 | type t = int * int * int * int * int * int * int * int [@@deriving qcheck] | |
189 | ||
190 | (* ==> *) | |
191 | ||
192 | let gen = | |
193 | QCheck.Gen.pair | |
194 | (QCheck.Gen.quad QCheck.Gen.int QCheck.Gen.int QCheck.Gen.int QCheck.Gen.int) | |
195 | (QCheck.Gen.quad QCheck.Gen.int QCheck.Gen.int QCheck.Gen.int QCheck.Gen.int) | |
196 | ``` | |
197 | ||
198 | ## Records | |
199 | ```ocaml | |
200 | type service = { | |
201 | service_name : string; | |
202 | port : int; | |
203 | protocol : string; | |
204 | } [@@deriving qcheck] | |
205 | ||
206 | (* ==> *) | |
207 | ||
208 | let gen_service = | |
209 | QCheck.Gen.map | |
210 | (fun (gen0, gen1, gen2) -> | |
211 | { service_name = gen0; port = gen1; protocol = gen2 }) | |
212 | (QCheck.Gen.triple QCheck.Gen.string QCheck.Gen.int QCheck.Gen.string) | |
213 | ``` | |
214 | ||
215 | ## Variants | |
216 | * Variants | |
217 | ```ocaml | |
218 | type color = Red | Blue | Green | |
219 | [@@deriving qcheck] | |
220 | ||
221 | (* ==> *) | |
222 | ||
223 | let gen_color = | |
224 | QCheck.Gen.frequency | |
225 | [(1, (QCheck.Gen.pure Red)); | |
226 | (1, (QCheck.Gen.pure Blue)); | |
227 | (1, (QCheck.Gen.pure Green))] | |
228 | ``` | |
229 | ||
230 | * Polymorphic variants | |
231 | ```ocaml | |
232 | type color = [ `Red | `Blue | `Green ] | |
233 | [@@deriving qcheck] | |
234 | ||
235 | (* ==> *) | |
236 | ||
237 | let gen_color = | |
238 | (QCheck.Gen.frequency | |
239 | [(1, (QCheck.Gen.pure `Red)); | |
240 | (1, (QCheck.Gen.pure `Blue)); | |
241 | (1, (QCheck.Gen.pure `Green))] : color QCheck.Gen.t) | |
242 | ``` | |
243 | ||
244 | ## Recursive variants | |
245 | * Recursive variants | |
246 | ```ocaml | |
247 | type tree = Leaf of int | Node of tree * tree | |
248 | [@@deriving qcheck] | |
249 | ||
250 | (* ==> *) | |
251 | ||
252 | let rec gen_tree_sized n = | |
253 | match n with | |
254 | | 0 -> QCheck.Gen.map (fun gen0 -> Leaf gen0) QCheck.Gen.int | |
255 | | n -> | |
256 | QCheck.Gen.frequency | |
257 | [(1, (QCheck.Gen.map (fun gen0 -> Leaf gen0) QCheck.Gen.int)); | |
258 | (1, | |
259 | (QCheck.Gen.map (fun (gen0, gen1) -> Node (gen0, gen1)) | |
260 | (QCheck.Gen.pair (self (n / 2)) (self (n / 2)))))])) | |
261 | ||
262 | let gen_tree = QCheck.Gen.sized @@ gen_tree_sized | |
263 | ``` | |
264 | ||
265 | * Recursive polymorphic variants | |
266 | ```ocaml | |
267 | type tree = [ `Leaf of int | `Node of tree * tree ] | |
268 | [@@deriving qcheck] | |
269 | ||
270 | (* ==> *) | |
271 | ||
272 | let gen_tree = | |
273 | (QCheck.Gen.sized @@ QCheck.Gen.fix (fun self -> function | |
274 | | 0 -> | |
275 | QCheck.Gen.frequency [ | |
276 | ( 1, QCheck.Gen.map (fun gen0 -> `Leaf gen0) QCheck.Gen.int); | |
277 | ] | |
278 | | n -> | |
279 | QCheck.Gen.frequency [ | |
280 | ( 1, QCheck.Gen.map (fun gen0 -> `Leaf gen0) QCheck.Gen.int); | |
281 | ( 1, | |
282 | QCheck.Gen.map (fun gen0 -> `Node gen0) | |
283 | (QCheck.Gen.map | |
284 | (fun (gen0, gen1) -> (gen0, gen1)) | |
285 | (QCheck.Gen.pair (self (n / 2)) (self (n / 2))))) | |
286 | ]) | |
287 | : tree QCheck.Gen.t) | |
288 | ``` | |
289 | ||
290 | ## Mutual recursive types | |
291 | ```ocaml | |
292 | type tree = Node of (int * forest) | |
293 | and forest = Nil | Cons of (tree * forest) | |
294 | [@@deriving qcheck] | |
295 | ||
296 | (* ==> *) | |
297 | ||
298 | let rec gen_tree () = | |
299 | QCheck.Gen.frequency | |
300 | [(1, | |
301 | (QCheck.Gen.map (fun gen0 -> Node gen0) | |
302 | (QCheck.Gen.map (fun (gen0, gen1) -> (gen0, gen1)) | |
303 | (QCheck.Gen.pair QCheck.Gen.int (gen_forest ())))))] | |
304 | ||
305 | and gen_forest () = | |
306 | QCheck.Gen.sized @@ | |
307 | (QCheck.Gen.fix | |
308 | (fun self -> function | |
309 | | 0 -> QCheck.Gen.frequency [(1, (QCheck.Gen.pure Nil))] | |
310 | | n -> | |
311 | QCheck.Gen.frequency | |
312 | [(1, (QCheck.Gen.pure Nil)); | |
313 | (1, | |
314 | (QCheck.Gen.map (fun gen0 -> Cons gen0) | |
315 | (QCheck.Gen.map (fun (gen0, gen1) -> (gen0, gen1)) | |
316 | (QCheck.Gen.pair (gen_tree ()) (self (n / 2))))))])) | |
317 | ||
318 | let gen_tree = gen_tree () | |
319 | ||
320 | let gen_forest = gen_forest () | |
321 | ``` | |
322 | ||
323 | ## Unsupported types | |
324 | ||
325 | ### GADT | |
326 | Deriving a GADT currently produces an ill-typed generator. | |
327 | ||
328 | ### Let us know | |
329 | If you encounter a unsupported type (that should be), please let us know by creating | |
330 | an issue. |
0 | open Ppxlib | |
1 | ||
2 | (** [curry_args args body] adds parameter to [body] | |
3 | ||
4 | e.g.: | |
5 | curry_args [gen_a; gen_b] () => fun gen_a -> fun gen_b -> () | |
6 | *) | |
7 | let rec curry_args ~loc args body = | |
8 | match args with | |
9 | | [] -> body | |
10 | | x :: xs -> [%expr fun [%p x] -> [%e curry_args ~loc xs body]] | |
11 | ||
12 | (** [apply_args args body] applies parameters to [body] | |
13 | ||
14 | e.g.: | |
15 | apply_args [gen_a; gen_b] f => f gen_a gen_b | |
16 | *) | |
17 | let apply_args ~loc args body = | |
18 | let rec aux acc = function | |
19 | | [] -> acc | |
20 | | [arg] -> [%expr [%e acc] [%e arg]] | |
21 | | arg :: args -> aux [%expr [%e acc] [%e arg]] args | |
22 | in | |
23 | aux body args |
0 | open Ppxlib | |
1 | ||
2 | (** [find_first_attribute xs name] returns the first attribute found in [xs] | |
3 | named [name] *) | |
4 | let find_attribute_opt xs name = | |
5 | List.find_opt (fun attribute -> attribute.attr_name.txt = name) xs | |
6 | ||
7 | let get_expr_payload x = | |
8 | match x.attr_payload with | |
9 | | PStr [ { pstr_desc = Pstr_eval (e, _); _ } ] -> Some [%expr [%e e]] | |
10 | | _ -> None | |
11 | ||
12 | let gen ct = | |
13 | Option.fold ~none:None ~some:get_expr_payload | |
14 | @@ find_attribute_opt ct.ptyp_attributes "gen" | |
15 | ||
16 | let weight xs = | |
17 | Option.fold ~none:None ~some:get_expr_payload | |
18 | @@ find_attribute_opt xs "weight" |
0 | open Ppxlib | |
1 | (** This file handles every attributes to be found in a core_type definition *) | |
2 | ||
3 | val gen : core_type -> expression option | |
4 | (** [gen loc ct] look for an attribute "gen" in [ct] | |
5 | ||
6 | example: | |
7 | {[ | |
8 | type t = | |
9 | | A of int | |
10 | | B of (int [@gen QCheck.int32]) | |
11 | ]} | |
12 | ||
13 | It allows the user to specify which generator he wants for a specific type. | |
14 | Returns the generator as an expression and returns None if no attribute | |
15 | is present *) | |
16 | ||
17 | val weight : attributes -> expression option | |
18 | (** [weight loc ct] look for an attribute "weight" in [ct] | |
19 | ||
20 | example: | |
21 | {[ | |
22 | type t = | |
23 | | A [@weight 5] | |
24 | | B [@weight 6] | |
25 | | C | |
26 | ]} | |
27 | It allows the user to specify the weight of a type case. *) |
0 | (library | |
1 | (name ppx_deriving_qcheck) | |
2 | (public_name ppx_deriving_qcheck) | |
3 | (libraries ppxlib) | |
4 | (preprocess (pps ppxlib.metaquot)) | |
5 | (ppx_runtime_libraries qcheck-core) | |
6 | (kind ppx_deriver)) |
0 | open Ppxlib | |
1 | module G = QCheck_generators | |
2 | module O = G.Observable | |
3 | ||
4 | (** {1. ppx_deriving_qcheck} *) | |
5 | ||
6 | (** ppx_deriving_qcheck is a ppx deriver for QCheck generators. It does a | |
7 | traversal map on type declarations annoted with [QCheck]. | |
8 | ||
9 | Example: | |
10 | {[ | |
11 | module Tree : sig | |
12 | type t | |
13 | ||
14 | val gen : t QCheck.Gen.t | |
15 | end = struct | |
16 | type t = Leaf | Node of int * t * t | |
17 | [@@deriving qcheck] | |
18 | end | |
19 | ]} | |
20 | *) | |
21 | ||
22 | (** {2. Misc. helpers} *) | |
23 | ||
24 | (** [name s] produces the generator name based on [s] *) | |
25 | let name ?(sized = false) s = | |
26 | let prefix = "gen" in | |
27 | (match s with "t" -> prefix | s -> prefix ^ "_" ^ s) ^ | |
28 | (if sized then "_sized" else "") | |
29 | ||
30 | (** [pat ~loc s] creates a pattern for a generator based on {!name}. *) | |
31 | let pat ~loc ?sized s = | |
32 | let (module A) = Ast_builder.make loc in | |
33 | let s = name ?sized s in | |
34 | A.pvar s | |
35 | ||
36 | (** {2. Recursive generators} *) | |
37 | ||
38 | (** Recursive generators must be treated separatly: | |
39 | ||
40 | {[ | |
41 | type 'a list = Cons of 'a * 'a list | Nil | |
42 | ]} | |
43 | ||
44 | becomes: | |
45 | ||
46 | {[ | |
47 | let rec gen_list_sized gen_a n = | |
48 | match n with | |
49 | | 0 -> pure Nil | |
50 | | n -> map2 (fun x xs -> Cons (x, xs) gen_a (gen_list_sized gen_a (n/2)) | |
51 | ||
52 | let gen_list_sized gen_a = sized @@ (gen_list_sized gen_a) | |
53 | ]} | |
54 | ||
55 | In the basic derivation {[ 'a list ]} would be translated to {[gen_list]}. | |
56 | However, we want the generator to call itsef. | |
57 | *) | |
58 | ||
59 | module Env = struct | |
60 | (** [env] contains: | |
61 | - the list of recursive types during the derivation | |
62 | - the list of types to derive (i.e. mutual types) | |
63 | - the current type to derive *) | |
64 | type env = { | |
65 | rec_types : string list; | |
66 | curr_types : string list; | |
67 | curr_type : string; | |
68 | } | |
69 | ||
70 | let is_rec env x = List.mem x env.rec_types | |
71 | end | |
72 | ||
73 | let rec longident_to_str = function | |
74 | | Lident s -> s | |
75 | | Ldot (lg, s) -> Printf.sprintf "%s.%s" (longident_to_str lg) s | |
76 | | Lapply (lg1, lg2) -> | |
77 | Printf.sprintf "%s %s" (longident_to_str lg1) (longident_to_str lg2) | |
78 | ||
79 | let rec is_rec_typ env = function | |
80 | | { ptyp_desc = Ptyp_constr ({ txt = x; _ }, _); _ } -> | |
81 | List.exists (fun typ_name -> longident_to_str x = typ_name) env.Env.curr_types | |
82 | | { ptyp_desc = Ptyp_tuple xs; _ } -> List.exists (is_rec_typ env) xs | |
83 | | { ptyp_desc = Ptyp_variant (rws, _, _); _ } -> | |
84 | List.exists (is_rec_row_field env) rws | |
85 | | _ -> false | |
86 | ||
87 | and is_rec_row_field env rw = | |
88 | match rw.prf_desc with | |
89 | | Rtag (lab, _, cts) -> | |
90 | List.exists (fun typ_name -> lab.txt = typ_name) env.Env.curr_types || | |
91 | List.exists (is_rec_typ env) cts | |
92 | | Rinherit ct -> is_rec_typ env ct | |
93 | ||
94 | let is_rec_constr_decl env cd = | |
95 | match cd.pcd_args with | |
96 | | Pcstr_tuple cts -> List.exists (is_rec_typ env) cts | |
97 | | _ -> false | |
98 | ||
99 | (** [is_rec_type_decl env typ] looks for elements of [env.curr_types] | |
100 | recursively in [typ]. *) | |
101 | let is_rec_type_decl env typ = | |
102 | let in_type_kind = | |
103 | match typ.ptype_kind with | |
104 | | Ptype_variant cstrs -> List.exists (is_rec_constr_decl env) cstrs | |
105 | | _ -> false | |
106 | in | |
107 | let in_manifest = | |
108 | match typ.ptype_manifest with | |
109 | | Some x -> is_rec_typ env x | |
110 | | None -> false | |
111 | in | |
112 | in_type_kind || in_manifest | |
113 | ||
114 | ||
115 | (** is_n_used looks for `n` (size indication) in an expression. | |
116 | ||
117 | For instance: | |
118 | {[ | |
119 | type foo = A of bar | B of bar | |
120 | and bar = Any | |
121 | [@@deriving qcheck] | |
122 | ||
123 | let rec gen_sized_foo n = | |
124 | let open QCheck.Gen in | |
125 | frequency [ | |
126 | (map (fun x -> A x) gen_bar); | |
127 | (map (fun x -> B x) gen_bar); | |
128 | ] | |
129 | and gen_bar = p | |
130 | let open QCheck.Gen in | |
131 | pure Any | |
132 | ]} | |
133 | ||
134 | The type [foo] is recursive because it has a dependency to [bar] but does | |
135 | not use the fuel as there is no "leaves" for this type. | |
136 | ||
137 | We begin by looking for occurences of variables `n`, iff we did not find | |
138 | any occurences, we replace `n` by `_n` in the generator's parameters. Thus, | |
139 | avoiding an unused variable. | |
140 | *) | |
141 | exception N_is_used | |
142 | ||
143 | class is_n_used (expr : expression) = | |
144 | object(self) | |
145 | inherit Ast_traverse.map as super | |
146 | ||
147 | method! expression expr = | |
148 | match expr with | |
149 | | [%expr n ] -> | |
150 | raise N_is_used | |
151 | | _ -> super#expression expr | |
152 | ||
153 | method go () = | |
154 | match self#expression expr |> ignore with | |
155 | | exception N_is_used -> true | |
156 | | () -> false | |
157 | end | |
158 | ||
159 | let is_n_used expr = (new is_n_used expr)#go () | |
160 | ||
161 | (** {2. Generator constructors} *) | |
162 | ||
163 | (** [gen_longident lg args] creates a generator using [lg]. | |
164 | ||
165 | The longident can either be a: | |
166 | - Lident s: We transform to gen_s (or gen if s = "t") | |
167 | - Ldot (lg, s): We transform to qualified generator (e.g. B.gen) | |
168 | *) | |
169 | let gen_longident ~loc ~env lg args = | |
170 | let (module A) = Ast_builder.make loc in | |
171 | match lg with | |
172 | | Lident s -> | |
173 | if Env.is_rec env s then | |
174 | name ~sized:true s |> A.evar |> | |
175 | Args.apply_args ~loc args |> | |
176 | Args.apply_args ~loc [ [%expr (n / 2)] ] | |
177 | else | |
178 | name s |> A.evar |> Args.apply_args ~loc args | |
179 | | Ldot (lg, s) -> | |
180 | A.(pexp_ident (Located.mk @@ Ldot (lg, name s))) |> | |
181 | Args.apply_args ~loc args | |
182 | | Lapply (_, _) -> raise (Invalid_argument "gen received an Lapply") | |
183 | ||
184 | (** [gen_sized typ_name is_rec to_gen xs] uses [is_rec] to determine recursive | |
185 | nodes in [xs]. | |
186 | ||
187 | If no recursive node is found, the type is _not_ recursive, we build a | |
188 | generator using frequency. | |
189 | ||
190 | However, if recursive nodes are found, we build a tree like generator using | |
191 | {!gen_sized}. | |
192 | ||
193 | The function is generalized for variants and polymorphic variants: | |
194 | ||
195 | {[ | |
196 | type t = Leaf | Node of int * t * t | |
197 | ||
198 | (* or *) | |
199 | ||
200 | type t = [`Leaf | `Node of int * t * t] | |
201 | ]} | |
202 | ||
203 | Therefore, [is_rec] and [to_gen] are different for variants and polymorphic | |
204 | variants. *) | |
205 | let gen_sized ~loc (is_rec : 'a -> bool) (to_gen : 'a -> expression) (xs : 'a list) = | |
206 | let (module A) = Ast_builder.make loc in | |
207 | let leaves = | |
208 | List.filter (fun x -> not (is_rec x)) xs |> List.map to_gen | |
209 | in | |
210 | let nodes = List.filter is_rec xs in | |
211 | ||
212 | if List.length nodes = 0 then | |
213 | G.frequency ~loc (A.elist leaves) | |
214 | else if List.length leaves = 0 then | |
215 | let nodes = List.map to_gen nodes in | |
216 | G.frequency ~loc (A.elist nodes) | |
217 | else | |
218 | let nodes = List.map to_gen nodes in | |
219 | let leaves = A.elist leaves |> G.frequency ~loc | |
220 | and nodes = A.elist (leaves @ nodes) |> G.frequency ~loc in | |
221 | [%expr | |
222 | match n with | |
223 | | 0 -> [%e leaves] | |
224 | | _ -> [%e nodes] | |
225 | ] | |
226 | ||
227 | (** [gen_tuple ~loc ?f tys] transforms list of type [tys] into a tuple generator. | |
228 | ||
229 | [f] can be used to transform tuples, for instance: | |
230 | {[ | |
231 | type t = Foo of int * int | |
232 | ]} | |
233 | ||
234 | Without [f]: | |
235 | {[ | |
236 | let gen = QCheck.Gen.(map (fun (x, y) -> (x, y)) (pair int int)) | |
237 | ]} | |
238 | ||
239 | With [f], building Foo: | |
240 | {[ | |
241 | let gen = QCheck.Gen.(map (fun (x, y) -> Foo (x, y)) (pair int int)) | |
242 | ]} | |
243 | *) | |
244 | let gen_tuple ~loc ?(f = fun x -> x) tys = | |
245 | let tuple = Tuple.from_list tys in | |
246 | let gen = Tuple.to_gen ~loc tuple in | |
247 | let expr = Tuple.to_expr ~loc tuple |> f in | |
248 | let pat = Tuple.to_pat ~loc tuple in | |
249 | G.map ~loc pat expr gen | |
250 | ||
251 | (** [gen_record loc gens ?f label_decls] transforms [gens] and [label_decls] to | |
252 | a record generator. | |
253 | ||
254 | Similarly to {!gen_tuple}, we can use [f] to transform records, for instance: | |
255 | {[ | |
256 | type t = Foo of { left : int; right : int } | |
257 | ]} | |
258 | ||
259 | Without [f]: | |
260 | {[ | |
261 | let gen = QCheck.Gen.(map (fun (x, y) -> {left = x; right = y}) (pair int int)) | |
262 | ]} | |
263 | ||
264 | With [f], building Foo: | |
265 | {[ | |
266 | let gen = QCheck.Gen.(map (fun (x, y) -> Foo {left = x; right = y}) (pair int int)) | |
267 | ]} | |
268 | ||
269 | *) | |
270 | let gen_record ~loc ~gens ?(f = fun x -> x) xs = | |
271 | let (module A) = Ast_builder.make loc in | |
272 | let tuple = Tuple.from_list gens in | |
273 | let gen = Tuple.to_gen ~loc tuple in | |
274 | let pat = Tuple.to_pat ~loc tuple in | |
275 | (* TODO: this should be handled in {!Tuple} *) | |
276 | let gens = | |
277 | List.mapi | |
278 | (fun i _ -> | |
279 | let s = Printf.sprintf "gen%d" i in | |
280 | A.evar s) | |
281 | gens | |
282 | in | |
283 | let fields = | |
284 | List.map2 | |
285 | (fun { pld_name; _ } value -> | |
286 | (A.Located.mk @@ Lident pld_name.txt, value)) | |
287 | xs gens | |
288 | in | |
289 | let expr = A.pexp_record fields None |> f in | |
290 | ||
291 | G.map ~loc pat expr gen | |
292 | ||
293 | (** {2. Core derivation} *) | |
294 | ||
295 | (** [gen_from_type typ] performs the AST traversal and derivation to qcheck generators *) | |
296 | let rec gen_from_type ~loc ~env typ = | |
297 | Option.value (Attributes.gen typ) | |
298 | ~default: | |
299 | (match typ with | |
300 | | [%type: unit] -> G.unit loc | |
301 | | [%type: int] -> G.int loc | |
302 | | [%type: string] | [%type: String.t] -> G.string loc | |
303 | | [%type: char] -> G.char loc | |
304 | | [%type: bool] -> G.bool loc | |
305 | | [%type: float] -> G.float loc | |
306 | | [%type: int32] | [%type: Int32.t] -> G.int32 loc | |
307 | | [%type: int64] | [%type: Int64.t] -> G.int64 loc | |
308 | | [%type: [%t? typ] option] -> G.option ~loc (gen_from_type ~loc ~env typ) | |
309 | | [%type: [%t? typ] list] -> G.list ~loc (gen_from_type ~loc ~env typ) | |
310 | | [%type: [%t? typ] array] -> G.array ~loc (gen_from_type ~loc ~env typ) | |
311 | | { ptyp_desc = Ptyp_tuple typs; _ } -> | |
312 | let tys = List.map (gen_from_type ~loc ~env) typs in | |
313 | gen_tuple ~loc tys | |
314 | | { ptyp_desc = Ptyp_constr ({ txt = ty; _ }, args); _ } -> | |
315 | let args = List.map (gen_from_type ~loc ~env) args in | |
316 | gen_longident ~loc ~env ty args | |
317 | | { ptyp_desc = Ptyp_var s; _ } -> | |
318 | gen_longident ~loc ~env (Lident s) [] | |
319 | | { ptyp_desc = Ptyp_variant (rws, _, _); _ } -> | |
320 | gen_from_variant ~loc ~env rws | |
321 | | { ptyp_desc = Ptyp_arrow (_, left, right); _ } -> | |
322 | gen_from_arrow ~loc ~env left right | |
323 | | _ -> | |
324 | Ppxlib.Location.raise_errorf ~loc | |
325 | "This type is not supported in ppx_deriving_qcheck") | |
326 | ||
327 | and gen_from_constr ~loc ~env { pcd_name; pcd_args; pcd_attributes; _ } = | |
328 | let (module A) = Ast_builder.make loc in | |
329 | let constr_decl = | |
330 | A.constructor_declaration ~name:pcd_name ~args:pcd_args ~res:None | |
331 | in | |
332 | let mk_constr expr = A.econstruct constr_decl (Some expr) in | |
333 | let weight = Attributes.weight pcd_attributes in | |
334 | let gen = | |
335 | match pcd_args with | |
336 | | Pcstr_tuple [] | Pcstr_record [] -> | |
337 | G.pure ~loc @@ A.econstruct constr_decl None | |
338 | | Pcstr_tuple xs -> | |
339 | let tys = List.map (gen_from_type ~loc ~env) xs in | |
340 | gen_tuple ~loc ~f:mk_constr tys | |
341 | | Pcstr_record xs -> | |
342 | let tys = List.map (fun x -> gen_from_type ~loc ~env x.pld_type) xs in | |
343 | gen_record ~loc ~f:mk_constr ~gens:tys xs | |
344 | in | |
345 | ||
346 | A.pexp_tuple [ Option.value ~default:[%expr 1] weight; gen ] | |
347 | ||
348 | and gen_from_variant ~loc ~env rws = | |
349 | let (module A) = Ast_builder.make loc in | |
350 | let is_rec = is_rec_row_field env in | |
351 | let to_gen (row : row_field) : expression = | |
352 | let w = | |
353 | Attributes.weight row.prf_attributes |> Option.value ~default:[%expr 1] | |
354 | in | |
355 | let gen = | |
356 | match row.prf_desc with | |
357 | | Rinherit typ -> gen_from_type ~loc ~env typ | |
358 | | Rtag (label, _, []) -> G.pure ~loc @@ A.pexp_variant label.txt None | |
359 | | Rtag (label, _, typs) -> | |
360 | let f expr = A.pexp_variant label.txt (Some expr) in | |
361 | gen_tuple ~loc ~f (List.map (gen_from_type ~loc ~env) typs) | |
362 | in | |
363 | [%expr [%e w], [%e gen]] | |
364 | in | |
365 | let gen = gen_sized ~loc is_rec to_gen rws in | |
366 | let typ_t = A.ptyp_constr (A.Located.mk @@ Lident env.curr_type) [] in | |
367 | let typ_gen = A.Located.mk G.ty in | |
368 | let typ = A.ptyp_constr typ_gen [ typ_t ] in | |
369 | [%expr ([%e gen] : [%t typ])] | |
370 | ||
371 | and gen_from_arrow ~loc ~env left right = | |
372 | let rec observable = function | |
373 | | [%type: unit] -> O.unit loc | |
374 | | [%type: bool] -> O.bool loc | |
375 | | [%type: int] -> O.int loc | |
376 | | [%type: float] -> O.float loc | |
377 | | [%type: string] -> O.string loc | |
378 | | [%type: char] -> O.char loc | |
379 | | [%type: [%t? typ] option] -> O.option ~loc (observable typ) | |
380 | | [%type: [%t? typ] array] -> O.array ~loc (observable typ) | |
381 | | [%type: [%t? typ] list] -> O.list ~loc (observable typ) | |
382 | | { ptyp_desc = Ptyp_tuple xs; _ } -> | |
383 | let obs = List.map observable xs in | |
384 | Tuple.from_list obs |> Tuple.to_obs ~loc | |
385 | | { ptyp_loc = loc; _ } -> | |
386 | Ppxlib.Location.raise_errorf ~loc | |
387 | "This type is not supported in ppx_deriving_qcheck" | |
388 | in | |
389 | let rec aux = function | |
390 | | { ptyp_desc = Ptyp_arrow (_, x, xs); _ } -> | |
391 | let res, xs = aux xs in | |
392 | let obs = observable x in | |
393 | (res, [%expr [%e obs] @-> [%e xs]]) | |
394 | | x -> (gen_from_type ~loc ~env x, [%expr o_nil]) | |
395 | in | |
396 | let x, obs = aux right in | |
397 | (* TODO: export this in qcheck_generators for https://github.com/c-cube/qcheck/issues/190 *) | |
398 | let arb = [%expr QCheck.make [%e x]] in | |
399 | [%expr | |
400 | QCheck.fun_nary QCheck.Tuple.([%e observable left] @-> [%e obs]) [%e arb] | |
401 | |> QCheck.gen] | |
402 | ||
403 | (** [gen_from_type_declaration loc td] creates a generator from the type declaration. | |
404 | ||
405 | It returns either `Recursive or `Normal. | |
406 | ||
407 | - `Normal of expression: | |
408 | The derived generator is not recursive, we return only the generator. | |
409 | ||
410 | - `Recursive of expression * expression | |
411 | The derived generator was recursive (i.e. val gen : n -> t Gen.t), we return | |
412 | the sized generator version, and a normal generator using this last with | |
413 | [Gen.sized]. | |
414 | *) | |
415 | let gen_from_type_declaration ~loc ~env td = | |
416 | let (module A) = Ast_builder.make loc in | |
417 | let ty = env.Env.curr_type in | |
418 | let is_rec = Env.is_rec env ty in | |
419 | ||
420 | let args = | |
421 | List.map | |
422 | (fun (typ, _) -> | |
423 | match typ.ptyp_desc with | |
424 | | Ptyp_var s -> (pat ~loc s, name s |> A.evar) | |
425 | | _ -> assert false) | |
426 | td.ptype_params | |
427 | in | |
428 | let (args_pat, args_expr) = List.split args in | |
429 | ||
430 | let gen = | |
431 | match td.ptype_kind with | |
432 | | Ptype_variant xs -> | |
433 | let is_rec cd = is_rec_constr_decl env cd in | |
434 | gen_sized ~loc is_rec (gen_from_constr ~loc ~env) xs | |
435 | | Ptype_record xs -> | |
436 | let gens = List.map (fun x -> gen_from_type ~loc ~env x.pld_type) xs in | |
437 | gen_record ~loc ~gens xs | |
438 | | _ -> | |
439 | let typ = Option.get td.ptype_manifest in | |
440 | gen_from_type ~loc ~env typ | |
441 | in | |
442 | ||
443 | let pat_gen = pat ~loc ty in | |
444 | if not is_rec then | |
445 | let gen = Args.curry_args ~loc args_pat gen in | |
446 | `Normal [%stri let [%p pat_gen] = [%e gen]] | |
447 | else | |
448 | let args = | |
449 | if is_n_used gen then args_pat @ [A.pvar "n"] | |
450 | else args_pat @ [A.pvar "_n"] | |
451 | in | |
452 | let gen = Args.curry_args ~loc args gen in | |
453 | let pat_gen_sized = pat ~loc ~sized:true ty in | |
454 | let gen_sized = name ~sized:true ty |> A.evar in | |
455 | let gen_normal = | |
456 | Args.curry_args ~loc args_pat | |
457 | (G.sized ~loc (Args.apply_args ~loc args_expr gen_sized)) | |
458 | in | |
459 | `Recursive ( | |
460 | [%stri let rec [%p pat_gen_sized] = [%e gen]], | |
461 | [%stri let [%p pat_gen] = [%e gen_normal]] | |
462 | ) | |
463 | ||
464 | let mutually_recursive_gens ~loc gens = | |
465 | let (module A) = Ast_builder.make loc in | |
466 | let to_mutualize_gens = | |
467 | List.map (function | |
468 | | `Recursive (x, _) -> x | |
469 | | `Normal x -> x) gens | |
470 | in | |
471 | let normal_gens = | |
472 | List.filter_map (function | |
473 | | `Recursive (_, x) -> Some x | |
474 | | `Normal _ -> None) gens | |
475 | in | |
476 | let gens = | |
477 | List.map (function | |
478 | | [%stri let [%p? pat] = [%e? expr]] | |
479 | | [%stri let rec [%p? pat] = [%e? expr]] -> | |
480 | A.value_binding ~pat ~expr | |
481 | | _ -> assert false) to_mutualize_gens | |
482 | in | |
483 | let mutual_gens = A.pstr_value Recursive gens in | |
484 | mutual_gens :: normal_gens | |
485 | ||
486 | (** [derive_gen ~loc xs] creates generators for type declaration in [xs]. *) | |
487 | let derive_gen ~loc (xs : rec_flag * type_declaration list) : structure = | |
488 | let open Env in | |
489 | let add_if_rec env typ x = | |
490 | if is_rec_type_decl env typ then | |
491 | { env with rec_types = x :: env.rec_types} | |
492 | else env | |
493 | in | |
494 | match xs with | |
495 | | (_, [ x ]) -> | |
496 | let typ_name = x.ptype_name.txt in | |
497 | let env = { curr_type = typ_name; rec_types = []; curr_types = [typ_name] } in | |
498 | let env = add_if_rec env x typ_name in | |
499 | (match gen_from_type_declaration ~loc ~env x with | |
500 | | `Recursive (gen_sized, gen) -> [gen_sized; gen] | |
501 | | `Normal gen -> [gen]) | |
502 | | _, xs -> | |
503 | let typ_names = List.map (fun x -> x.ptype_name.txt) xs in | |
504 | let env = { curr_type = ""; rec_types = []; curr_types = typ_names } in | |
505 | let env = | |
506 | List.fold_left | |
507 | (fun env x -> add_if_rec env x x.ptype_name.txt) | |
508 | env xs | |
509 | in | |
510 | let gens = | |
511 | List.map (fun x -> | |
512 | let env = { env with curr_type = x.ptype_name.txt }in | |
513 | gen_from_type_declaration ~loc ~env x) xs | |
514 | in | |
515 | mutually_recursive_gens ~loc gens | |
516 | ||
517 | (** {2. Ppxlib machinery} *) | |
518 | ||
519 | let create_gen ~ctxt (decls : rec_flag * type_declaration list) : structure = | |
520 | let loc = Expansion_context.Deriver.derived_item_loc ctxt in | |
521 | derive_gen ~loc decls | |
522 | ||
523 | let gen_expander = Deriving.Generator.V2.make_noarg create_gen | |
524 | ||
525 | let _ = Deriving.add "qcheck" ~str_type_decl:gen_expander |
0 | open Ppxlib | |
1 | ||
2 | val derive_gen : loc:location -> rec_flag * type_declaration list -> structure | |
3 | (** [derive_gen loc xs] derives a generator for each type_declaration in [xs] *) |
0 | open Ppxlib | |
1 | module G = QCheck_generators | |
2 | module O = G.Observable | |
3 | ||
4 | (** {1. Tuple } *) | |
5 | ||
6 | (** This module implements nested tuples based on QCheck tuples generators (or observables): | |
7 | - [Gen.pair] | |
8 | - [Gen.triple] | |
9 | - [Gen.quad] | |
10 | ||
11 | It can be used to nest large tuples in a generator. | |
12 | - e.g. | |
13 | {[ | |
14 | type t = int * int * int | |
15 | ]} | |
16 | ||
17 | Lets say QCheck does not have combinator to generate a triple. One has to write: | |
18 | ||
19 | {[ | |
20 | let gen = QCheck.Gen.(map (fun ((x, y), z) -> (x, y, z) (pair (pair int int) int)) | |
21 | ]} | |
22 | ||
23 | We copy this nesting mechanism with this module. | |
24 | *) | |
25 | ||
26 | type 'a t = | |
27 | | Pair of 'a t * 'a t | |
28 | | Triple of 'a * 'a * 'a | |
29 | | Quad of 'a * 'a * 'a * 'a | |
30 | | Elem of 'a | |
31 | ||
32 | (** [from_list l] builds an {!'a t}, if len of [l] is greater than 4, the list | |
33 | is split into a [Pair] of generators. *) | |
34 | let rec from_list = function | |
35 | | [ a; b; c; d ] -> Quad (a, b, c, d) | |
36 | | [ a; b; c ] -> Triple (a, b, c) | |
37 | | [ a; b ] -> Pair (Elem a, Elem b) | |
38 | | [ a ] -> Elem a | |
39 | | l -> | |
40 | let n = List.length l / 2 in | |
41 | let i = ref 0 in | |
42 | let l1 = | |
43 | List.filter | |
44 | (fun _ -> | |
45 | let x = !i in | |
46 | i := x + 1; | |
47 | x < n) | |
48 | l | |
49 | in | |
50 | i := 0; | |
51 | let l2 = | |
52 | List.filter | |
53 | (fun _ -> | |
54 | let x = !i in | |
55 | i := x + 1; | |
56 | x >= n) | |
57 | l | |
58 | in | |
59 | Pair (from_list l1, from_list l2) | |
60 | ||
61 | let rec to_list = function | |
62 | | Quad (a, b, c, d) -> [ a; b; c; d ] | |
63 | | Triple (a, b, c) -> [ a; b; c ] | |
64 | | Pair (a, b) -> to_list a @ to_list b | |
65 | | Elem a -> [ a ] | |
66 | ||
67 | (** [to_expr ~loc t] creates a tuple expression based on [t]. | |
68 | [t] is transformed to a list, and each element from the list becomes | |
69 | a variable referencing a generator. | |
70 | ||
71 | - e.g. | |
72 | to_expr (Pair (_, _)) => (gen0, gen1) | |
73 | *) | |
74 | let to_expr ~loc t = | |
75 | let l = to_list t in | |
76 | let (module A) = Ast_builder.make loc in | |
77 | List.mapi | |
78 | (fun i _ -> | |
79 | let s = Printf.sprintf "gen%d" i in | |
80 | A.evar s) | |
81 | l | |
82 | |> A.pexp_tuple | |
83 | ||
84 | (** [nest pair triple quad t] creates a generator expression for [t] using | |
85 | ||
86 | - [pair] to combine Pair (_, _) | |
87 | - [triple] to combine Triple (_, _, ) | |
88 | - [quad] to combine Quad (_, _, _, _) | |
89 | *) | |
90 | let rec nest ~pair ~triple ~quad = function | |
91 | | Quad (a, b, c, d) -> quad a b c d | |
92 | | Triple (a, b, c) -> triple a b c | |
93 | | Pair (a, b) -> | |
94 | pair | |
95 | (nest ~pair ~triple ~quad a) | |
96 | (nest ~pair ~triple ~quad b) | |
97 | | Elem a -> a | |
98 | ||
99 | (** [to_gen t] creates a Gen.t with generators' combinators *) | |
100 | let to_gen ~loc t = | |
101 | nest ~pair:(G.pair ~loc) ~triple:(G.triple ~loc) ~quad:(G.quad ~loc) t | |
102 | ||
103 | (** [to_obs t] creates a Obs.t with obsersvables' combinators *) | |
104 | let to_obs ~loc t = | |
105 | nest ~pair:(O.pair ~loc) ~triple:(O.triple ~loc) ~quad:(O.quad ~loc) t | |
106 | ||
107 | let to_pat ~loc t = | |
108 | let fresh_id = | |
109 | let id = ref 0 in | |
110 | fun () -> | |
111 | let x = !id in | |
112 | let () = id := x + 1 in | |
113 | Printf.sprintf "gen%d" x | |
114 | in | |
115 | let (module A) = Ast_builder.make loc in | |
116 | let rec aux = function | |
117 | | Quad (_, _, _, _) -> | |
118 | let a = A.pvar @@ fresh_id () in | |
119 | let b = A.pvar @@ fresh_id () in | |
120 | let c = A.pvar @@ fresh_id () in | |
121 | let d = A.pvar @@ fresh_id () in | |
122 | [%pat? [%p a], [%p b], [%p c], [%p d]] | |
123 | | Triple (_, _, _) -> | |
124 | let a = A.pvar @@ fresh_id () in | |
125 | let b = A.pvar @@ fresh_id () in | |
126 | let c = A.pvar @@ fresh_id () in | |
127 | [%pat? [%p a], [%p b], [%p c]] | |
128 | | Pair (a, b) -> | |
129 | let a = aux a in | |
130 | let b = aux b in | |
131 | [%pat? [%p a], [%p b]] | |
132 | | Elem _ -> A.pvar @@ fresh_id () | |
133 | in | |
134 | aux t |
59 | 59 | (* time of last printed message. Useful for rate limiting in verbose mode *) |
60 | 60 | let last_msg = ref 0. |
61 | 61 | |
62 | let time_between_msg = ref 0.1 | |
62 | let time_between_msg = | |
63 | let env_var = "QCHECK_MSG_INTERVAL" in | |
64 | let default_interval = 0.1 in | |
65 | let interval = match Sys.getenv_opt env_var with | |
66 | | None -> default_interval | |
67 | | Some f -> | |
68 | match float_of_string_opt f with | |
69 | | None -> invalid_arg (env_var ^ " must be a float") | |
70 | | Some i -> i in | |
71 | if interval < 0. then invalid_arg (env_var ^ " must be >= 0 but value is " ^ string_of_float interval); | |
72 | ref interval | |
63 | 73 | |
64 | 74 | let get_time_between_msg () = !time_between_msg |
65 | 75 | |
134 | 144 | if print_res then ( |
135 | 145 | (* even if [not verbose], print errors *) |
136 | 146 | match R.get_state result with |
137 | | R.Success -> () | |
147 | | R.Success -> | |
148 | if not (T.get_positive cell) | |
149 | then | |
150 | print.fail "%snegative test '%s' succeeded unexpectedly\n" reset_line name; | |
138 | 151 | | R.Failed {instances=l} -> |
139 | print.fail "%s%s\n" reset_line (T.print_fail cell name l); | |
152 | if T.get_positive cell | |
153 | then print.fail "%s%s\n" reset_line (T.print_fail cell name l) | |
154 | else print.info "%s%s\n" reset_line (T.print_expected_failure cell l) | |
140 | 155 | | R.Failed_other {msg} -> |
141 | 156 | print.fail "%s%s\n" reset_line (T.print_fail_other name ~msg); |
142 | 157 | | R.Error {instance; exn; backtrace} -> |
218 | 233 | | None -> Printf.fprintf out "<no printer provided>" |
219 | 234 | | Some print -> Printf.fprintf out "%s" (print x) |
220 | 235 | |
221 | let debug_shrinking_choices_aux ~colors out name i cell x = | |
236 | let debug_shrinking_choices ~colors ~out ~name cell ~step x = | |
222 | 237 | Printf.fprintf out "\n~~~ %a %s\n\n" |
223 | 238 | (Color.pp_str_c ~colors `Cyan) "Shrink" (String.make 69 '~'); |
224 | 239 | Printf.fprintf out |
225 | 240 | "Test %s successfully shrunk counter example (step %d) to:\n\n%a\n%!" |
226 | name i | |
241 | name step | |
227 | 242 | (debug_shrinking_counter_example cell) x |
228 | ||
229 | let debug_shrinking_choices | |
230 | ~colors ~debug_shrink ~debug_shrink_list name cell i x = | |
231 | match debug_shrink with | |
232 | | None -> () | |
233 | | Some out -> | |
234 | begin match debug_shrink_list with | |
235 | | [] -> | |
236 | debug_shrinking_choices_aux ~colors out name i cell x | |
237 | | l when List.mem name l -> | |
238 | debug_shrinking_choices_aux ~colors out name i cell x | |
239 | | _ -> () | |
240 | end | |
241 | ||
242 | 243 | |
243 | 244 | let default_handler |
244 | 245 | ~colors ~debug_shrink ~debug_shrink_list |
255 | 256 | in |
256 | 257 | (* debug shrinking choices *) |
257 | 258 | begin match r with |
258 | | QCheck2.Test.Shrunk (i, x) -> | |
259 | debug_shrinking_choices | |
260 | ~colors ~debug_shrink ~debug_shrink_list name cell i x | |
259 | | QCheck2.Test.Shrunk (step, x) -> | |
260 | begin match debug_shrink with | |
261 | | None -> () | |
262 | | Some out -> | |
263 | let go = | |
264 | match debug_shrink_list with | |
265 | | [] -> true | |
266 | | test_list -> List.mem name test_list | |
267 | in | |
268 | if not go then () | |
269 | else | |
270 | debug_shrinking_choices | |
271 | ~colors ~out ~name cell ~step x | |
272 | end | |
261 | 273 | | _ -> |
262 | 274 | () |
263 | 275 | end; |
288 | 300 | (if colors then Color.reset_line else "\n") (pp_counter ~size) c name |
289 | 301 | ) |
290 | 302 | |
291 | let callback ~size ~out ~verbose ~colors c name _ r = | |
292 | let pass = QCheck2.TestResult.is_success r in | |
303 | let callback ~size ~out ~verbose ~colors c name cell r = | |
304 | let pass = | |
305 | if QCheck2.Test.get_positive cell | |
306 | then QCheck2.TestResult.is_success r | |
307 | else QCheck2.TestResult.is_failed r in | |
293 | 308 | let color = if pass then `Green else `Red in |
294 | 309 | if verbose then ( |
295 | 310 | Printf.fprintf out "%s[%a] %a %s\n%!" |
357 | 372 | let print_fail_other ~colors out cell msg = |
358 | 373 | Printf.fprintf out "\n--- %a %s\n\n" (Color.pp_str_c ~colors `Red) "Failure" (String.make 68 '-'); |
359 | 374 | Printf.fprintf out "Test %s failed:\n\n%s\n%!" (QCheck2.Test.get_name cell) msg |
375 | ||
376 | let print_expected_failure ~colors out cell c_ex = | |
377 | Printf.fprintf out "\n--- %a %s\n\n" (Color.pp_str_c ~colors `Blue) "Info" (String.make 71 '-'); | |
378 | Printf.fprintf out "Negative test %s failed as expected (%d shrink steps):\n\n%s\n%!" | |
379 | (QCheck2.Test.get_name cell) c_ex.QCheck2.TestResult.shrink_steps | |
380 | (print_inst cell c_ex.QCheck2.TestResult.instance); | |
381 | print_messages ~colors out cell c_ex.QCheck2.TestResult.msg_l | |
360 | 382 | |
361 | 383 | let print_error ~colors out cell c_ex exn bt = |
362 | 384 | Printf.fprintf out "\n=== %a %s\n\n" (Color.pp_str_c ~colors `Red) "Error" (String.make 70 '='); |
408 | 430 | let res = List.map aux_map l in |
409 | 431 | let aux_fold (total, fail, error, warns) (Res (cell, r)) = |
410 | 432 | let warns = warns + List.length (R.get_warnings r) in |
411 | let acc = match R.get_state r with | |
412 | | R.Success -> | |
433 | let acc = match R.get_state r, QCheck2.Test.get_positive cell with | |
434 | | R.Success, true -> | |
413 | 435 | print_success ~colors out cell r; |
414 | 436 | (total + 1, fail, error, warns) |
415 | | R.Failed {instances=l} -> | |
437 | | R.Success, false -> | |
438 | let msg = Printf.sprintf "Negative test %s succeeded but was expected to fail" (QCheck2.Test.get_name cell) in | |
439 | print_fail_other ~colors out cell msg; | |
440 | (total + 1, fail + 1, error, warns) | |
441 | | R.Failed {instances=l}, true -> | |
416 | 442 | List.iter (print_fail ~colors out cell) l; |
417 | 443 | (total + 1, fail + 1, error, warns) |
418 | | R.Failed_other {msg} -> | |
444 | | R.Failed {instances=l}, false -> | |
445 | if verbose then List.iter (print_expected_failure ~colors out cell) l; | |
446 | (total + 1, fail, error, warns) | |
447 | | R.Failed_other {msg}, _ -> (* Failed_other is also considered a failure *) | |
419 | 448 | print_fail_other ~colors out cell msg; |
420 | 449 | (total + 1, fail + 1, error, warns) |
421 | | R.Error {instance=c_ex; exn; backtrace=bt} -> | |
450 | | R.Error {instance=c_ex; exn; backtrace=bt}, _ -> (* Error is always considered a failure *) | |
422 | 451 | print_error ~colors out cell c_ex exn bt; |
423 | 452 | (total + 1, fail, error + 1, warns) |
424 | 453 | in |
86 | 86 | val default_handler : handler_gen |
87 | 87 | (** The default handler used. *) |
88 | 88 | |
89 | val debug_shrinking_choices: | |
90 | colors:bool -> | |
91 | out:out_channel -> | |
92 | name:string -> 'a QCheck2.Test.cell -> step:int -> 'a -> unit | |
93 | (** The function used by the default handler to debug shrinking choices. | |
94 | This can be useful to outside users trying to reproduce some of the | |
95 | base-runner behavior. | |
96 | ||
97 | @since 0.19 | |
98 | *) | |
89 | 99 | |
90 | 100 | (** {2 Run a Suite of Tests and Get Results} *) |
91 | 101 |
0 | random seed: 1234 | |
1 | 50 7 0 0 0 0 0 0 0 0 0 0 3 3 3 3 3 3 3 3 3 3 5 5 5 5 5 5 5 5 5 5 6 6 6 6 6 6 6 6 6 6 (6,fun,50) (0,fun,2) (7,fun,66) (54,fun,9) (2,fun,5) (90,fun,4) (1,fun,4) (37,fun,7) (7,fun,1) (8,fun,5) | |
2 | (6,fun,50) (0,fun,2) (7,fun,66) (54,fun,9) (2,fun,5) (90,fun,4) (1,fun,4) (37,fun,7) (7,fun,1) (8,fun,5) | |
3 | (6,fun,50) (0,fun,2) (7,fun,66) (54,fun,9) (2,fun,5) (90,fun,4) (1,fun,4) (37,fun,7) (7,fun,1) (8,fun,5) | |
4 | (6,fun,50) (0,fun,2) (7,fun,66) (54,fun,9) (2,fun,5) (90,fun,4) (1,fun,4) (37,fun,7) (7,fun,1) (8,fun,5) | |
5 | (6,fun,50) (0,fun,2) (7,fun,66) (54,fun,9) (2,fun,5) (90,fun,4) (1,fun,4) (37,fun,7) (7,fun,1) (8,fun,5) | |
6 | (6,fun,50) (0,fun,2) (7,fun,66) (54,fun,9) (2,fun,5) (90,fun,4) (1,fun,4) (37,fun,7) (7,fun,1) (8,fun,5) | |
7 | (6,fun,50) (0,fun,2) (7,fun,66) (54,fun,9) (2,fun,5) (90,fun,4) (1,fun,4) (37,fun,7) (7,fun,1) (8,fun,5) | |
8 | (6,fun,50) (0,fun,2) (7,fun,66) (54,fun,9) (2,fun,5) (90,fun,4) (1,fun,4) (37,fun,7) (7,fun,1) (8,fun,5) | |
9 | 911769578 | |
10 | 0 | |
11 | 455884789 | |
12 | 0 | |
13 | 227942394 | |
14 | 0 | |
15 | 113971197 | |
16 | 0 | |
17 | 56985598 | |
18 | 0 | |
19 | 28492799 | |
20 | 0 | |
21 | 14246399 | |
22 | 0 | |
23 | 7123199 | |
24 | 0 | |
25 | 3561599 | |
26 | 0 | |
27 | 1780799 | |
28 | 0 | |
29 | 890399 | |
30 | 0 | |
31 | 445199 | |
32 | 0 | |
33 | 222599 | |
34 | 0 | |
35 | 111299 | |
36 | 0 | |
37 | 55649 | |
38 | 0 | |
39 | 27824 | |
40 | 0 | |
41 | 13912 | |
42 | 0 | |
43 | 6956 | |
44 | 0 | |
45 | 3478 | |
46 | 0 | |
47 | 1739 | |
48 | 0 | |
49 | 869 | |
50 | 0 | |
51 | 434 | |
52 | 0 | |
53 | 217 | |
54 | 0 | |
55 | 108 | |
56 | 0 | |
57 | 54 | |
58 | 0 | |
59 | 27 | |
60 | 0 | |
61 | 13 | |
62 | 0 | |
63 | 6 | |
64 | 0 | |
65 | 3 | |
66 | 0 | |
67 | 1 | |
68 | 0 | |
69 | [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] | |
70 | [] | |
71 | [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] | |
72 | [] | |
73 | [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] | |
74 | [] | |
75 | [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] | |
76 | [] | |
77 | [9; 8; 73; 5; 8; 2; 1; 8; 2; 6; 4; 18; 5; 76; 3] | |
78 | [] | |
79 | [0; 6; 2; 8; 8; 1; 4] | |
80 | [] | |
81 | [5; 2; 3] | |
82 | [] | |
83 | [3] | |
84 | [] | |
85 | [0] | |
86 | [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] | |
87 | [] | |
88 | [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] | |
89 | [] | |
90 | [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] | |
91 | [] | |
92 | [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] | |
93 | [] | |
94 | [9; 8; 73; 5; 8; 2; 1; 8; 2; 6; 4; 18; 5; 76; 3] | |
95 | [] | |
96 | [0; 6; 2; 8; 8; 1; 4] | |
97 | [] | |
98 | [5; 2; 3] | |
99 | [3; 2; 7; 3; 3] | |
100 | [] | |
101 | [5; 3] | |
102 | [5; 3; 2] | |
103 | [9; 87; 7; 0] | |
104 | [0; 2; 7; 3; 3] | |
105 | [0; 0; 7; 3; 3] | |
106 | [0; 0; 0; 3; 3] | |
107 | [0; 0; 0; 0; 3] | |
108 | [0; 0; 0; 0; 0] | |
109 | ||
110 | --- Failure -------------------------------------------------------------------- | |
111 | ||
112 | Test should_fail_sort_id failed (9 shrink steps): | |
113 | ||
114 | [1; 0] | |
115 | ||
116 | === Error ====================================================================== | |
117 | ||
118 | Test should_error_raise_exn errored on (1 shrink steps): | |
119 | ||
120 | 0 | |
121 | ||
122 | exception QCheck2_tests.Overall.Error | |
123 | ||
124 | ||
125 | +++ Collect ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
126 | ||
127 | Collect results for test collect_results: | |
128 | ||
129 | 4: 20 cases | |
130 | 3: 25 cases | |
131 | 2: 17 cases | |
132 | 1: 18 cases | |
133 | 0: 20 cases | |
134 | ||
135 | +++ Stats for with_stats ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
136 | ||
137 | stats mod4: | |
138 | num: 100, avg: 1.68, stddev: 1.09, median 2, min 0, max 3 | |
139 | 0: ############################## 17 | |
140 | 1: ################################################### 29 | |
141 | 2: ######################################## 23 | |
142 | 3: ####################################################### 31 | |
143 | ||
144 | stats num: | |
145 | num: 100, avg: 66.84, stddev: 31.94, median 65, min 2, max 120 | |
146 | 2.. 7: ################## 3 | |
147 | 8.. 13: ################## 3 | |
148 | 14.. 19: 0 | |
149 | 20.. 25: ########################################## 7 | |
150 | 26.. 31: ######################## 4 | |
151 | 32.. 37: ######################## 4 | |
152 | 38.. 43: ################## 3 | |
153 | 44.. 49: ################################################ 8 | |
154 | 50.. 55: #################################### 6 | |
155 | 56.. 61: #################################### 6 | |
156 | 62.. 67: ####################################################### 9 | |
157 | 68.. 73: ########################################## 7 | |
158 | 74.. 79: ######################## 4 | |
159 | 80.. 85: ################## 3 | |
160 | 86.. 91: ############ 2 | |
161 | 92.. 97: ########################################## 7 | |
162 | 98..103: #################################### 6 | |
163 | 104..109: #################################### 6 | |
164 | 110..115: ####################################################### 9 | |
165 | 116..121: ################## 3 | |
166 | ||
167 | --- Failure -------------------------------------------------------------------- | |
168 | ||
169 | Test with shrinking retries failed (0 shrink steps): | |
170 | ||
171 | 7 | |
172 | ||
173 | !!! Warning !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
174 | ||
175 | Warning for test WARN_unlikely_precond: | |
176 | ||
177 | WARNING: only 0.6% tests (of 2000) passed precondition for "WARN_unlikely_precond" | |
178 | ||
179 | NOTE: it is likely that the precondition is too strong, or that the generator is buggy. | |
180 | ||
181 | --- Failure -------------------------------------------------------------------- | |
182 | ||
183 | Test FAIL_unlikely_precond failed: | |
184 | ||
185 | ERROR: only 0.6% tests (of 2000) passed precondition for "FAIL_unlikely_precond" | |
186 | ||
187 | NOTE: it is likely that the precondition is too strong, or that the generator is buggy. | |
188 | ||
189 | ||
190 | --- Failure -------------------------------------------------------------------- | |
191 | ||
192 | Test FAIL_bad_gen failed: | |
193 | ||
194 | ERROR: uncaught exception in generator for test FAIL_bad_gen after 100 steps: | |
195 | Exception: Invalid_argument("Gen.int_bound") | |
196 | Backtrace: | |
197 | ||
198 | --- Failure -------------------------------------------------------------------- | |
199 | ||
200 | Test int double failed: | |
201 | ||
202 | Negative test int double succeeded but was expected to fail | |
203 | ||
204 | === Error ====================================================================== | |
205 | ||
206 | Test pos fail with error errored on (1 shrink steps): | |
207 | ||
208 | 0 | |
209 | ||
210 | exception QCheck2_tests.Overall.Error | |
211 | ||
212 | ||
213 | === Error ====================================================================== | |
214 | ||
215 | Test neg fail with error errored on (1 shrink steps): | |
216 | ||
217 | 0 | |
218 | ||
219 | exception QCheck2_tests.Overall.Error | |
220 | ||
221 | ||
222 | --- Failure -------------------------------------------------------------------- | |
223 | ||
224 | Test char never produces '\255' failed (0 shrink steps): | |
225 | ||
226 | '\255' | |
227 | ||
228 | --- Failure -------------------------------------------------------------------- | |
229 | ||
230 | Test big bound issue59 failed (0 shrink steps): | |
231 | ||
232 | 1073741823 | |
233 | ||
234 | --- Failure -------------------------------------------------------------------- | |
235 | ||
236 | Test long_shrink failed (3018 shrink steps): | |
237 | ||
238 | ([0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0], [0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 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]) | |
239 | ||
240 | --- Failure -------------------------------------------------------------------- | |
241 | ||
242 | Test ints arent 0 mod 3 failed (2 shrink steps): | |
243 | ||
244 | 0 | |
245 | ||
246 | --- Failure -------------------------------------------------------------------- | |
247 | ||
248 | Test ints are 0 failed (29 shrink steps): | |
249 | ||
250 | 1 | |
251 | ||
252 | --- Failure -------------------------------------------------------------------- | |
253 | ||
254 | Test ints < 209609 failed (0 shrink steps): | |
255 | ||
256 | 1073741823 | |
257 | ||
258 | --- Failure -------------------------------------------------------------------- | |
259 | ||
260 | Test nat < 5001 failed (7 shrink steps): | |
261 | ||
262 | 5001 | |
263 | ||
264 | --- Failure -------------------------------------------------------------------- | |
265 | ||
266 | Test char never produces 'abcdef' failed (1 shrink steps): | |
267 | ||
268 | 'a' | |
269 | ||
270 | --- Failure -------------------------------------------------------------------- | |
271 | ||
272 | Test printable never produces '!"#$%&'' failed (1 shrink steps): | |
273 | ||
274 | '!' | |
275 | ||
276 | --- Failure -------------------------------------------------------------------- | |
277 | ||
278 | Test printable never produces less than '5 failed (1 shrink steps): | |
279 | ||
280 | '0' | |
281 | ||
282 | --- Failure -------------------------------------------------------------------- | |
283 | ||
284 | Test strings are empty failed (8 shrink steps): | |
285 | ||
286 | "a" | |
287 | ||
288 | --- Failure -------------------------------------------------------------------- | |
289 | ||
290 | Test string never has a \000 char failed (22 shrink steps): | |
291 | ||
292 | "aaaaaa\000aaaaaaaaaaaaaaaa" | |
293 | ||
294 | --- Failure -------------------------------------------------------------------- | |
295 | ||
296 | Test string never has a \255 char failed (59 shrink steps): | |
297 | ||
298 | "aaaaaaaaaaaaaaaaaaaaaaaaaa\255aaaaaaaaaaaaaaaaaaaaaaaa" | |
299 | ||
300 | --- Failure -------------------------------------------------------------------- | |
301 | ||
302 | Test strings have unique chars failed (18 shrink steps): | |
303 | ||
304 | "aaaaaaaaaaaaa" | |
305 | ||
306 | --- Failure -------------------------------------------------------------------- | |
307 | ||
308 | Test pairs have different components failed (0 shrink steps): | |
309 | ||
310 | (4, 4) | |
311 | ||
312 | --- Failure -------------------------------------------------------------------- | |
313 | ||
314 | Test pairs have same components failed (31 shrink steps): | |
315 | ||
316 | (0, 1) | |
317 | ||
318 | --- Failure -------------------------------------------------------------------- | |
319 | ||
320 | Test pairs have a zero component failed (58 shrink steps): | |
321 | ||
322 | (1, 1) | |
323 | ||
324 | --- Failure -------------------------------------------------------------------- | |
325 | ||
326 | Test pairs are (0,0) failed (31 shrink steps): | |
327 | ||
328 | (0, 1) | |
329 | ||
330 | --- Failure -------------------------------------------------------------------- | |
331 | ||
332 | Test pairs are ordered failed (43 shrink steps): | |
333 | ||
334 | (1, 0) | |
335 | ||
336 | --- Failure -------------------------------------------------------------------- | |
337 | ||
338 | Test pairs are ordered reversely failed (29 shrink steps): | |
339 | ||
340 | (0, 1) | |
341 | ||
342 | --- Failure -------------------------------------------------------------------- | |
343 | ||
344 | Test pairs sum to less than 128 failed (25 shrink steps): | |
345 | ||
346 | (0, 128) | |
347 | ||
348 | --- Failure -------------------------------------------------------------------- | |
349 | ||
350 | Test pairs lists rev concat failed (41 shrink steps): | |
351 | ||
352 | ([0], [1]) | |
353 | ||
354 | --- Failure -------------------------------------------------------------------- | |
355 | ||
356 | Test pairs lists no overlap failed (27 shrink steps): | |
357 | ||
358 | ([0], [0; 0; 0; 0]) | |
359 | ||
360 | --- Failure -------------------------------------------------------------------- | |
361 | ||
362 | Test triples have pair-wise different components failed (3 shrink steps): | |
363 | ||
364 | (0, 0, 0) | |
365 | ||
366 | --- Failure -------------------------------------------------------------------- | |
367 | ||
368 | Test triples have same components failed (33 shrink steps): | |
369 | ||
370 | (0, 1, 0) | |
371 | ||
372 | --- Failure -------------------------------------------------------------------- | |
373 | ||
374 | Test triples are ordered failed (4 shrink steps): | |
375 | ||
376 | (0, -1, 0) | |
377 | ||
378 | --- Failure -------------------------------------------------------------------- | |
379 | ||
380 | Test triples are ordered reversely failed (33 shrink steps): | |
381 | ||
382 | (0, 0, 1) | |
383 | ||
384 | --- Failure -------------------------------------------------------------------- | |
385 | ||
386 | Test quadruples have pair-wise different components failed (4 shrink steps): | |
387 | ||
388 | (0, 0, 0, 0) | |
389 | ||
390 | --- Failure -------------------------------------------------------------------- | |
391 | ||
392 | Test quadruples have same components failed (61 shrink steps): | |
393 | ||
394 | (0, 1, 0, 1) | |
395 | ||
396 | --- Failure -------------------------------------------------------------------- | |
397 | ||
398 | Test quadruples are ordered failed (5 shrink steps): | |
399 | ||
400 | (0, 0, -1, 0) | |
401 | ||
402 | --- Failure -------------------------------------------------------------------- | |
403 | ||
404 | Test quadruples are ordered reversely failed (34 shrink steps): | |
405 | ||
406 | (0, 0, 0, 1) | |
407 | ||
408 | --- Failure -------------------------------------------------------------------- | |
409 | ||
410 | Test forall (a, b) in nat: a < b failed (6 shrink steps): | |
411 | ||
412 | (0, 0) | |
413 | ||
414 | --- Failure -------------------------------------------------------------------- | |
415 | ||
416 | Test forall (a, b, c) in nat: a < b < c failed (3 shrink steps): | |
417 | ||
418 | (0, 0, 0) | |
419 | ||
420 | --- Failure -------------------------------------------------------------------- | |
421 | ||
422 | Test forall (a, b, c, d) in nat: a < b < c < d failed (4 shrink steps): | |
423 | ||
424 | (0, 0, 0, 0) | |
425 | ||
426 | --- Failure -------------------------------------------------------------------- | |
427 | ||
428 | Test forall (a, b, c, d, e) in nat: a < b < c < d < e failed (5 shrink steps): | |
429 | ||
430 | (0, 0, 0, 0, 0) | |
431 | ||
432 | --- Failure -------------------------------------------------------------------- | |
433 | ||
434 | Test forall (a, b, c, d, e, f) in nat: a < b < c < d < e < f failed (6 shrink steps): | |
435 | ||
436 | (0, 0, 0, 0, 0, 0) | |
437 | ||
438 | --- Failure -------------------------------------------------------------------- | |
439 | ||
440 | Test forall (a, b, c, d, e, f, g) in nat: a < b < c < d < e < f < g failed (7 shrink steps): | |
441 | ||
442 | (0, 0, 0, 0, 0, 0, 0) | |
443 | ||
444 | --- Failure -------------------------------------------------------------------- | |
445 | ||
446 | Test forall (a, b, c, d, e, f, g, h) in nat: a < b < c < d < e < f < g < h failed (8 shrink steps): | |
447 | ||
448 | (0, 0, 0, 0, 0, 0, 0, 0) | |
449 | ||
450 | --- Failure -------------------------------------------------------------------- | |
451 | ||
452 | Test forall (a, b, c, d, e, f, g, h, i) in nat: a < b < c < d < e < f < g < h < i failed (9 shrink steps): | |
453 | ||
454 | (0, 0, 0, 0, 0, 0, 0, 0, 0) | |
455 | ||
456 | --- Failure -------------------------------------------------------------------- | |
457 | ||
458 | Test bind ordered pairs failed (1 shrink steps): | |
459 | ||
460 | (0, 0) | |
461 | ||
462 | --- Failure -------------------------------------------------------------------- | |
463 | ||
464 | Test bind list_size constant failed (12 shrink steps): | |
465 | ||
466 | (4, [0; 0; 0; 0]) | |
467 | ||
468 | --- Failure -------------------------------------------------------------------- | |
469 | ||
470 | Test lists are empty failed (8 shrink steps): | |
471 | ||
472 | [0] | |
473 | ||
474 | --- Failure -------------------------------------------------------------------- | |
475 | ||
476 | Test lists shorter than 10 failed (16 shrink steps): | |
477 | ||
478 | [0; 0; 0; 0; 0; 0; 0; 0; 0; 0] | |
479 | ||
480 | --- Failure -------------------------------------------------------------------- | |
481 | ||
482 | Test lists shorter than 432 failed (412 shrink steps): | |
483 | ||
484 | [...] list length: 432 | |
485 | ||
486 | --- Failure -------------------------------------------------------------------- | |
487 | ||
488 | Test lists shorter than 4332 failed (4022 shrink steps): | |
489 | ||
490 | [...] list length: 4332 | |
491 | ||
492 | --- Failure -------------------------------------------------------------------- | |
493 | ||
494 | Test lists have unique elems failed (11 shrink steps): | |
495 | ||
496 | [0; 0; 0; 0; 0] | |
497 | ||
498 | --- Failure -------------------------------------------------------------------- | |
499 | ||
500 | Test tree contains only 42 failed (2 shrink steps): | |
501 | ||
502 | Leaf 0 | |
503 | ||
504 | --- Failure -------------------------------------------------------------------- | |
505 | ||
506 | Test fail_pred_map_commute failed (37 shrink steps): | |
507 | ||
508 | ([1], {_ -> 0}, {0 -> false; 1 -> true; -489114431 -> false; -334037599 -> false; -1002044798 -> false; 3 -> false; 607479396 -> false; 4 -> false; 5 -> false; 442140485 -> false; 50542662 -> false; 38 -> false; 281414086 -> false; 757535206 -> false; 6 -> false; 7 -> false; 8 -> false; 629085609 -> false; 10 -> false; -765856245 -> false; 44 -> false; 12 -> false; -386873971 -> false; 15 -> false; 47 -> false; -842421617 -> false; 588710735 -> false; 49 -> false; 18 -> false; 51 -> false; 449695123 -> false; 20 -> false; 21 -> false; -386709771 -> false; -92591850 -> false; 136918038 -> false; 54 -> false; -484444937 -> false; -1042148456 -> false; 24 -> false; 1062551480 -> false; 747852089 -> false; 25 -> false; -737785766 -> false; 58 -> false; -530708612 -> false; -60654788 -> false; 28 -> false; 60 -> false; 29 -> false; 947455871 -> false; _ -> false}) | |
509 | ||
510 | --- Failure -------------------------------------------------------------------- | |
511 | ||
512 | Test fail_pred_strings failed (2 shrink steps): | |
513 | ||
514 | {"some random string" -> true; _ -> false} | |
515 | ||
516 | --- Failure -------------------------------------------------------------------- | |
517 | ||
518 | Test fold_left fold_right failed (56 shrink steps): | |
519 | ||
520 | (0, [1], {(1, 0) -> 1; (8, 0) -> 0; (6, 4) -> 0; (2, 6) -> 0; (3, 6) -> 0; (2, 16) -> 0; (0, 60) -> 0; (20, 3) -> 0; (12, 60) -> 0; (0, 2) -> 0; (2, 4) -> 0; (1, 6) -> 0; (6, 1) -> 0; (60, 83) -> 0; (3, 5) -> 0; (7, 12) -> 0; (6, 8) -> 0; (2, 2) -> 0; (56, 6) -> 0; (6, 5) -> 0; (12, 3) -> 0; (6, 6) -> 0; (0, 8) -> 0; (0, 58) -> 0; (5, 5) -> 0; (20, 2) -> 0; (54, 0) -> 0; (0, 6) -> 0; (4, 6) -> 0; (4, 56) -> 0; (5, 54) -> 0; (9, 8) -> 0; (8, 6) -> 0; (60, 47) -> 0; (9, 12) -> 0; (4, 20) -> 0; (0, 20) -> 0; (1, 2) -> 0; (28, 2) -> 0; (4, 1) -> 0; (0, 4) -> 0; (8, 3) -> 0; (4, 28) -> 0; (42, 8) -> 0; (6, 0) -> 0; (58, 65) -> 0; (12, 12) -> 0; (5, 6) -> 0; _ -> 0}) | |
521 | ||
522 | +++ Messages ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
523 | ||
524 | Messages for test fold_left fold_right: | |
525 | ||
526 | l=[1], fold_left=1, fold_right=0 | |
527 | ||
528 | ||
529 | --- Failure -------------------------------------------------------------------- | |
530 | ||
531 | Test fold_left fold_right uncurried failed (376 shrink steps): | |
532 | ||
533 | ({(0, 2) -> 0; (13, 0) -> 0; (22, 3) -> 0; (20, 5) -> 0; (2, 93) -> 0; (65, 34) -> 0; (2, 7) -> 0; (0, 7) -> 0; (49, 3) -> 0; (8, 62) -> 0; (8, 2) -> 0; (54, 6) -> 0; (38, 4) -> 0; (7, 0) -> 1; (6, 25) -> 0; (0, 0) -> 0; (3, 4) -> 0; (1, 7) -> 0; (4, 6) -> 0; (8, 1) -> 0; (48, 42) -> 0; (18, 1) -> 0; (90, 14) -> 0; (8, 70) -> 0; (9, 1) -> 0; (38, 2) -> 0; (3, 5) -> 0; (8, 8) -> 0; (9, 3) -> 0; (2, 36) -> 0; (45, 2) -> 0; (18, 6) -> 0; (7, 98) -> 0; (3, 9) -> 0; (2, 31) -> 0; (86, 2) -> 0; (4, 7) -> 0; (1, 1) -> 0; (0, 5) -> 0; (2, 9) -> 0; (1, 5) -> 0; (44, 0) -> 0; (77, 7) -> 0; (5, 8) -> 0; (1, 4) -> 0; (9, 79) -> 0; (48, 1) -> 0; (30, 7) -> 0; (6, 79) -> 0; (5, 1) -> 0; (65, 4) -> 0; (2, 1) -> 0; (4, 1) -> 0; (66, 12) -> 0; (6, 5) -> 0; (7, 3) -> 0; (3, 7) -> 0; (9, 7) -> 0; (9, 9) -> 0; (2, 6) -> 0; (3, 15) -> 0; (5, 3) -> 0; (67, 1) -> 0; (3, 28) -> 0; (1, 87) -> 0; (7, 31) -> 0; (9, 13) -> 0; (32, 1) -> 0; (0, 27) -> 0; (6, 15) -> 0; (20, 0) -> 0; (6, 8) -> 0; (1, 6) -> 0; (0, 6) -> 0; (3, 1) -> 0; (9, 71) -> 0; (95, 4) -> 0; (97, 1) -> 0; (7, 4) -> 0; (84, 3) -> 0; (92, 6) -> 0; (6, 2) -> 0; (8, 4) -> 0; (5, 0) -> 0; (7, 5) -> 0; (9, 8) -> 0; (90, 26) -> 0; (0, 19) -> 0; (1, 13) -> 0; (6, 1) -> 0; (9, 28) -> 0; (9, 6) -> 0; (8, 6) -> 0; (3, 8) -> 0; (7, 62) -> 0; (86, 0) -> 0; (65, 1) -> 0; (7, 1) -> 0; (6, 6) -> 0; (30, 4) -> 0; (7, 67) -> 0; (0, 9) -> 0; (78, 5) -> 0; (17, 3) -> 0; (9, 60) -> 0; (3, 71) -> 0; (88, 1) -> 0; (4, 61) -> 0; (9, 0) -> 0; (45, 0) -> 0; (2, 5) -> 0; (9, 47) -> 0; (18, 5) -> 0; (66, 0) -> 0; (0, 76) -> 0; (8, 3) -> 0; (74, 6) -> 0; (5, 60) -> 0; (5, 80) -> 0; (8, 9) -> 0; (7, 8) -> 0; (39, 4) -> 0; (72, 8) -> 0; (4, 38) -> 0; (70, 31) -> 0; (19, 5) -> 0; (4, 9) -> 0; (0, 1) -> 0; (1, 37) -> 0; (7, 6) -> 0; (6, 3) -> 0; (9, 5) -> 0; (58, 4) -> 0; (54, 5) -> 0; (7, 86) -> 0; (67, 6) -> 0; (0, 8) -> 0; (8, 7) -> 0; (44, 18) -> 0; (3, 0) -> 0; (4, 41) -> 0; (0, 31) -> 0; (1, 51) -> 0; (6, 0) -> 0; (1, 3) -> 0; (70, 1) -> 0; (9, 4) -> 0; (4, 5) -> 0; (1, 8) -> 0; (5, 9) -> 0; (0, 14) -> 0; (3, 3) -> 0; (4, 0) -> 0; (78, 9) -> 0; (0, 4) -> 0; (2, 3) -> 0; (9, 62) -> 0; (35, 1) -> 0; (55, 1) -> 0; _ -> 0}, 0, [7; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0]) | |
534 | ||
535 | --- Failure -------------------------------------------------------------------- | |
536 | ||
537 | Test fold_left fold_right uncurried fun last failed (56 shrink steps): | |
538 | ||
539 | (0, [1], {(0, 2) -> 0; (3, 6) -> 0; (0, 20) -> 0; (20, 4) -> 0; (6, 42) -> 0; (47, 6) -> 0; (6, 12) -> 0; (2, 6) -> 0; (0, 58) -> 0; (8, 2) -> 0; (6, 6) -> 0; (8, 60) -> 0; (12, 3) -> 0; (6, 4) -> 0; (16, 8) -> 0; (6, 0) -> 0; (3, 4) -> 0; (12, 0) -> 0; (60, 5) -> 0; (8, 1) -> 0; (6, 8) -> 0; (2, 5) -> 0; (2, 42) -> 0; (5, 4) -> 0; (4, 20) -> 0; (54, 0) -> 0; (12, 4) -> 0; (3, 2) -> 0; (8, 0) -> 0; (4, 7) -> 0; (28, 3) -> 0; (2, 9) -> 0; (65, 54) -> 0; (5, 28) -> 0; (20, 2) -> 0; (6, 2) -> 0; (83, 6) -> 0; (58, 5) -> 0; (5, 6) -> 0; (56, 12) -> 0; (1, 60) -> 0; (4, 9) -> 0; (0, 1) -> 1; (2, 8) -> 0; (2, 0) -> 0; (6, 1) -> 0; (1, 12) -> 0; (60, 0) -> 0; _ -> 0}) | |
540 | ||
541 | --- Failure -------------------------------------------------------------------- | |
542 | ||
543 | Test fold_left test, fun first failed (15 shrink steps): | |
544 | ||
545 | ({_ -> ""}, "a", [], [0]) | |
546 | ||
547 | --- Failure -------------------------------------------------------------------- | |
548 | ||
549 | Test FAIL_#99_1 failed: | |
550 | ||
551 | ERROR: uncaught exception in generator for test FAIL_#99_1 after 100 steps: | |
552 | Exception: QCheck2.No_example_found("<example>") | |
553 | Backtrace: | |
554 | ||
555 | +++ Collect ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
556 | ||
557 | Collect results for test bool dist: | |
558 | ||
559 | true: 250134 cases | |
560 | false: 249866 cases | |
561 | ||
562 | +++ Stats for char code dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
563 | ||
564 | stats char code: | |
565 | num: 500000, avg: 127.42, stddev: 73.92, median 127, min 0, max 255 | |
566 | 0.. 12: ###################################################### 25509 | |
567 | 13.. 25: ###################################################### 25398 | |
568 | 26.. 38: ###################################################### 25293 | |
569 | 39.. 51: ###################################################### 25448 | |
570 | 52.. 64: ###################################################### 25392 | |
571 | 65.. 77: ####################################################### 25660 | |
572 | 78.. 90: ###################################################### 25462 | |
573 | 91..103: ###################################################### 25331 | |
574 | 104..116: ##################################################### 25129 | |
575 | 117..129: ###################################################### 25351 | |
576 | 130..142: ###################################################### 25492 | |
577 | 143..155: ###################################################### 25370 | |
578 | 156..168: ###################################################### 25658 | |
579 | 169..181: ###################################################### 25400 | |
580 | 182..194: ##################################################### 25167 | |
581 | 195..207: ###################################################### 25338 | |
582 | 208..220: ##################################################### 25181 | |
583 | 221..233: ##################################################### 25145 | |
584 | 234..246: ###################################################### 25567 | |
585 | 247..259: ##################################### 17709 | |
586 | ||
587 | +++ Stats for printable char code dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
588 | ||
589 | stats char code: | |
590 | num: 500000, avg: 78.26, stddev: 28.15, median 78, min 10, max 126 | |
591 | 10.. 15: ######### 5149 | |
592 | 16.. 21: 0 | |
593 | 22.. 27: 0 | |
594 | 28.. 33: ################## 10379 | |
595 | 34.. 39: ###################################################### 31153 | |
596 | 40.. 45: ###################################################### 31341 | |
597 | 46.. 51: ###################################################### 31408 | |
598 | 52.. 57: ####################################################### 31456 | |
599 | 58.. 63: ###################################################### 31310 | |
600 | 64.. 69: ###################################################### 31152 | |
601 | 70.. 75: ###################################################### 31308 | |
602 | 76.. 81: ###################################################### 31156 | |
603 | 82.. 87: ###################################################### 31170 | |
604 | 88.. 93: ###################################################### 31286 | |
605 | 94.. 99: ###################################################### 31364 | |
606 | 100..105: ###################################################### 31368 | |
607 | 106..111: ###################################################### 31024 | |
608 | 112..117: ###################################################### 31261 | |
609 | 118..123: ###################################################### 31064 | |
610 | 124..129: ########################### 15651 | |
611 | ||
612 | +++ Stats for numeral char code dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
613 | ||
614 | stats char code: | |
615 | num: 500000, avg: 52.50, stddev: 2.87, median 52, min 48, max 57 | |
616 | 48: ###################################################### 50260 | |
617 | 49: ###################################################### 49590 | |
618 | 50: ###################################################### 50170 | |
619 | 51: ####################################################### 50270 | |
620 | 52: ###################################################### 49805 | |
621 | 53: ###################################################### 50161 | |
622 | 54: ###################################################### 49919 | |
623 | 55: ###################################################### 49971 | |
624 | 56: ###################################################### 49980 | |
625 | 57: ###################################################### 49874 | |
626 | ||
627 | +++ Stats for tree's depth ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
628 | ||
629 | stats depth: | |
630 | num: 1000, avg: 3.74, stddev: 3.28, median 3, min 1, max 15 | |
631 | 1: ####################################################### 377 | |
632 | 2: ################ 113 | |
633 | 3: ############ 87 | |
634 | 4: ################# 123 | |
635 | 5: ########### 81 | |
636 | 6: #### 33 | |
637 | 7: ##### 40 | |
638 | 8: ##### 39 | |
639 | 9: # 9 | |
640 | 10: ### 25 | |
641 | 11: ####### 49 | |
642 | 12: 4 | |
643 | 13: # 9 | |
644 | 14: # 7 | |
645 | 15: 4 | |
646 | ||
647 | +++ Stats for string_size len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
648 | ||
649 | stats len: | |
650 | num: 5000, avg: 7.49, stddev: 1.70, median 7, min 5, max 10 | |
651 | 5: ##################################################### 837 | |
652 | 6: ##################################################### 826 | |
653 | 7: ###################################################### 843 | |
654 | 8: ####################################################### 855 | |
655 | 9: #################################################### 813 | |
656 | 10: ##################################################### 826 | |
657 | ||
658 | +++ Stats for string len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
659 | ||
660 | stats len: | |
661 | num: 5000, avg: 384.53, stddev: 1330.61, median 9, min 0, max 9969 | |
662 | 0.. 498: ####################################################### 4246 | |
663 | 499.. 997: ###### 518 | |
664 | 998..1496: 21 | |
665 | 1497..1995: 10 | |
666 | 1996..2494: 11 | |
667 | 2495..2993: 10 | |
668 | 2994..3492: 13 | |
669 | 3493..3991: 13 | |
670 | 3992..4490: 5 | |
671 | 4491..4989: 10 | |
672 | 4990..5488: 19 | |
673 | 5489..5987: 9 | |
674 | 5988..6486: 10 | |
675 | 6487..6985: 12 | |
676 | 6986..7484: 17 | |
677 | 7485..7983: 16 | |
678 | 7984..8482: 16 | |
679 | 8483..8981: 16 | |
680 | 8982..9480: 16 | |
681 | 9481..9979: 12 | |
682 | ||
683 | +++ Stats for string_of len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
684 | ||
685 | stats len: | |
686 | num: 5000, avg: 363.14, stddev: 1245.80, median 9, min 0, max 9986 | |
687 | 0.. 499: ####################################################### 4270 | |
688 | 500.. 999: ###### 493 | |
689 | 1000.. 1499: 16 | |
690 | 1500.. 1999: 11 | |
691 | 2000.. 2499: 15 | |
692 | 2500.. 2999: 17 | |
693 | 3000.. 3499: 11 | |
694 | 3500.. 3999: 19 | |
695 | 4000.. 4499: 14 | |
696 | 4500.. 4999: 10 | |
697 | 5000.. 5499: 16 | |
698 | 5500.. 5999: 11 | |
699 | 6000.. 6499: 15 | |
700 | 6500.. 6999: 13 | |
701 | 7000.. 7499: 12 | |
702 | 7500.. 7999: 16 | |
703 | 8000.. 8499: 11 | |
704 | 8500.. 8999: 4 | |
705 | 9000.. 9499: 13 | |
706 | 9500.. 9999: 13 | |
707 | ||
708 | +++ Stats for string_printable len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
709 | ||
710 | stats len: | |
711 | num: 5000, avg: 384.53, stddev: 1330.61, median 9, min 0, max 9969 | |
712 | 0.. 498: ####################################################### 4246 | |
713 | 499.. 997: ###### 518 | |
714 | 998..1496: 21 | |
715 | 1497..1995: 10 | |
716 | 1996..2494: 11 | |
717 | 2495..2993: 10 | |
718 | 2994..3492: 13 | |
719 | 3493..3991: 13 | |
720 | 3992..4490: 5 | |
721 | 4491..4989: 10 | |
722 | 4990..5488: 19 | |
723 | 5489..5987: 9 | |
724 | 5988..6486: 10 | |
725 | 6487..6985: 12 | |
726 | 6986..7484: 17 | |
727 | 7485..7983: 16 | |
728 | 7984..8482: 16 | |
729 | 8483..8981: 16 | |
730 | 8982..9480: 16 | |
731 | 9481..9979: 12 | |
732 | ||
733 | +++ Stats for small_string len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
734 | ||
735 | stats len: | |
736 | num: 5000, avg: 15.57, stddev: 24.36, median 6, min 0, max 99 | |
737 | 0.. 4: #################################################### 1925 | |
738 | 5.. 9: ####################################################### 2005 | |
739 | 10.. 14: # 52 | |
740 | 15.. 19: # 50 | |
741 | 20.. 24: # 55 | |
742 | 25.. 29: # 56 | |
743 | 30.. 34: # 55 | |
744 | 35.. 39: # 49 | |
745 | 40.. 44: # 65 | |
746 | 45.. 49: # 65 | |
747 | 50.. 54: # 55 | |
748 | 55.. 59: # 68 | |
749 | 60.. 64: # 61 | |
750 | 65.. 69: # 65 | |
751 | 70.. 74: # 57 | |
752 | 75.. 79: # 66 | |
753 | 80.. 84: # 65 | |
754 | 85.. 89: # 64 | |
755 | 90.. 94: # 60 | |
756 | 95.. 99: # 62 | |
757 | ||
758 | +++ Stats for pair dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
759 | ||
760 | stats pair sum: | |
761 | num: 500000, avg: 100.02, stddev: 41.22, median 100, min 0, max 200 | |
762 | 0.. 9: ### 2685 | |
763 | 10.. 19: ######## 7622 | |
764 | 20.. 29: ############## 12474 | |
765 | 30.. 39: #################### 17330 | |
766 | 40.. 49: ########################## 22263 | |
767 | 50.. 59: ############################### 26982 | |
768 | 60.. 69: ##################################### 32182 | |
769 | 70.. 79: ########################################### 37125 | |
770 | 80.. 89: ################################################# 42287 | |
771 | 90.. 99: ###################################################### 46691 | |
772 | 100..109: ####################################################### 46977 | |
773 | 110..119: ################################################# 42444 | |
774 | 120..129: ############################################ 37719 | |
775 | 130..139: ###################################### 32595 | |
776 | 140..149: ################################ 27588 | |
777 | 150..159: ########################## 22792 | |
778 | 160..169: #################### 17805 | |
779 | 170..179: ############### 13068 | |
780 | 180..189: ######### 8218 | |
781 | 190..199: ### 3115 | |
782 | 200..209: 38 | |
783 | ||
784 | +++ Stats for triple dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
785 | ||
786 | stats triple sum: | |
787 | num: 500000, avg: 150.08, stddev: 50.51, median 150, min 0, max 299 | |
788 | 0.. 14: 345 | |
789 | 15.. 29: ## 2121 | |
790 | 30.. 44: ##### 5372 | |
791 | 45.. 59: ########## 10501 | |
792 | 60.. 74: ################# 17031 | |
793 | 75.. 89: ######################### 25417 | |
794 | 90..104: ################################### 35148 | |
795 | 105..119: ############################################# 45134 | |
796 | 120..134: ################################################### 51751 | |
797 | 135..149: ####################################################### 55090 | |
798 | 150..164: ###################################################### 55074 | |
799 | 165..179: #################################################### 52238 | |
800 | 180..194: ############################################# 45651 | |
801 | 195..209: ################################### 35994 | |
802 | 210..224: ######################### 26039 | |
803 | 225..239: ################# 17749 | |
804 | 240..254: ########## 10870 | |
805 | 255..269: ##### 5765 | |
806 | 270..284: ## 2313 | |
807 | 285..299: 397 | |
808 | ||
809 | +++ Stats for quad dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
810 | ||
811 | stats quad sum: | |
812 | num: 500000, avg: 200.13, stddev: 58.33, median 200, min 5, max 394 | |
813 | 5.. 24: 102 | |
814 | 25.. 44: 842 | |
815 | 45.. 64: ## 3023 | |
816 | 65.. 84: ###### 7154 | |
817 | 85..104: ############ 14368 | |
818 | 105..124: ##################### 25397 | |
819 | 125..144: ############################### 37547 | |
820 | 145..164: ########################################## 50174 | |
821 | 165..184: ################################################## 60558 | |
822 | 185..204: ####################################################### 65376 | |
823 | 205..224: ##################################################### 63687 | |
824 | 225..244: ############################################### 56248 | |
825 | 245..264: ###################################### 45384 | |
826 | 265..284: ########################## 31780 | |
827 | 285..304: ################ 20158 | |
828 | 305..324: ######### 10899 | |
829 | 325..344: #### 5045 | |
830 | 345..364: # 1848 | |
831 | 365..384: 386 | |
832 | 385..404: 24 | |
833 | ||
834 | +++ Stats for bind dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
835 | ||
836 | stats ordered pair difference: | |
837 | num: 1000000, avg: 25.02, stddev: 22.36, median 19, min 0, max 100 | |
838 | 0.. 4: ####################################################### 193184 | |
839 | 5.. 9: ##################################### 130024 | |
840 | 10.. 14: ############################# 103828 | |
841 | 15.. 19: ######################## 87496 | |
842 | 20.. 24: ##################### 74431 | |
843 | 25.. 29: ################## 64629 | |
844 | 30.. 34: ################ 56663 | |
845 | 35.. 39: ############# 48986 | |
846 | 40.. 44: ############ 43424 | |
847 | 45.. 49: ########## 37599 | |
848 | 50.. 54: ######### 32787 | |
849 | 55.. 59: ######## 28332 | |
850 | 60.. 64: ###### 24023 | |
851 | 65.. 69: ##### 20312 | |
852 | 70.. 74: #### 16649 | |
853 | 75.. 79: ### 13338 | |
854 | 80.. 84: ## 10239 | |
855 | 85.. 89: ## 7391 | |
856 | 90.. 94: # 4548 | |
857 | 95.. 99: 2015 | |
858 | 100..104: 102 | |
859 | ||
860 | stats ordered pair sum: | |
861 | num: 1000000, avg: 75.12, stddev: 46.93, median 72, min 0, max 200 | |
862 | 0.. 9: ####################################################### 70423 | |
863 | 10.. 19: ##################################################### 68068 | |
864 | 20.. 29: ##################################################### 68449 | |
865 | 30.. 39: ##################################################### 68577 | |
866 | 40.. 49: ##################################################### 68763 | |
867 | 50.. 59: ##################################################### 68351 | |
868 | 60.. 69: ##################################################### 68744 | |
869 | 70.. 79: ##################################################### 68451 | |
870 | 80.. 89: ##################################################### 68309 | |
871 | 90.. 99: ##################################################### 68835 | |
872 | 100..109: ################################################## 64544 | |
873 | 110..119: ########################################### 55512 | |
874 | 120..129: ##################################### 47595 | |
875 | 130..139: ############################### 39809 | |
876 | 140..149: ######################### 32677 | |
877 | 150..159: #################### 26312 | |
878 | 160..169: ############### 20180 | |
879 | 170..179: ########### 14265 | |
880 | 180..189: ###### 8625 | |
881 | 190..199: ## 3433 | |
882 | 200..209: 78 | |
883 | ||
884 | +++ Stats for list len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
885 | ||
886 | stats len: | |
887 | num: 5000, avg: 361.42, stddev: 1230.75, median 9, min 0, max 9974 | |
888 | 0.. 498: ####################################################### 4212 | |
889 | 499.. 997: ####### 578 | |
890 | 998..1496: 11 | |
891 | 1497..1995: 15 | |
892 | 1996..2494: 11 | |
893 | 2495..2993: 10 | |
894 | 2994..3492: 13 | |
895 | 3493..3991: 12 | |
896 | 3992..4490: 7 | |
897 | 4491..4989: 8 | |
898 | 4990..5488: 15 | |
899 | 5489..5987: 14 | |
900 | 5988..6486: 12 | |
901 | 6487..6985: 8 | |
902 | 6986..7484: 9 | |
903 | 7485..7983: 19 | |
904 | 7984..8482: 14 | |
905 | 8483..8981: 11 | |
906 | 8982..9480: 11 | |
907 | 9481..9979: 10 | |
908 | ||
909 | +++ Stats for small_list len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
910 | ||
911 | stats len: | |
912 | num: 5000, avg: 15.79, stddev: 24.64, median 6, min 0, max 99 | |
913 | 0.. 4: ###################################################### 1930 | |
914 | 5.. 9: ####################################################### 1957 | |
915 | 10.. 14: # 59 | |
916 | 15.. 19: # 66 | |
917 | 20.. 24: # 61 | |
918 | 25.. 29: # 52 | |
919 | 30.. 34: # 61 | |
920 | 35.. 39: # 65 | |
921 | 40.. 44: # 62 | |
922 | 45.. 49: # 64 | |
923 | 50.. 54: # 70 | |
924 | 55.. 59: # 63 | |
925 | 60.. 64: # 50 | |
926 | 65.. 69: # 51 | |
927 | 70.. 74: # 52 | |
928 | 75.. 79: # 63 | |
929 | 80.. 84: # 56 | |
930 | 85.. 89: ## 75 | |
931 | 90.. 94: ## 73 | |
932 | 95.. 99: # 70 | |
933 | ||
934 | +++ Stats for list_size len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
935 | ||
936 | stats len: | |
937 | num: 5000, avg: 7.51, stddev: 1.71, median 8, min 5, max 10 | |
938 | 5: ###################################################### 834 | |
939 | 6: ##################################################### 825 | |
940 | 7: ##################################################### 820 | |
941 | 8: ###################################################### 833 | |
942 | 9: ####################################################### 844 | |
943 | 10: ####################################################### 844 | |
944 | ||
945 | +++ Stats for list_repeat len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
946 | ||
947 | stats len: | |
948 | num: 5000, avg: 42.00, stddev: 0.00, median 42, min 42, max 42 | |
949 | 42: ####################################################### 5000 | |
950 | ||
951 | +++ Stats for array len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
952 | ||
953 | stats len: | |
954 | num: 5000, avg: 361.42, stddev: 1230.75, median 9, min 0, max 9974 | |
955 | 0.. 498: ####################################################### 4212 | |
956 | 499.. 997: ####### 578 | |
957 | 998..1496: 11 | |
958 | 1497..1995: 15 | |
959 | 1996..2494: 11 | |
960 | 2495..2993: 10 | |
961 | 2994..3492: 13 | |
962 | 3493..3991: 12 | |
963 | 3992..4490: 7 | |
964 | 4491..4989: 8 | |
965 | 4990..5488: 15 | |
966 | 5489..5987: 14 | |
967 | 5988..6486: 12 | |
968 | 6487..6985: 8 | |
969 | 6986..7484: 9 | |
970 | 7485..7983: 19 | |
971 | 7984..8482: 14 | |
972 | 8483..8981: 11 | |
973 | 8982..9480: 11 | |
974 | 9481..9979: 10 | |
975 | ||
976 | +++ Stats for small_array len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
977 | ||
978 | stats len: | |
979 | num: 5000, avg: 15.79, stddev: 24.64, median 6, min 0, max 99 | |
980 | 0.. 4: ###################################################### 1930 | |
981 | 5.. 9: ####################################################### 1957 | |
982 | 10.. 14: # 59 | |
983 | 15.. 19: # 66 | |
984 | 20.. 24: # 61 | |
985 | 25.. 29: # 52 | |
986 | 30.. 34: # 61 | |
987 | 35.. 39: # 65 | |
988 | 40.. 44: # 62 | |
989 | 45.. 49: # 64 | |
990 | 50.. 54: # 70 | |
991 | 55.. 59: # 63 | |
992 | 60.. 64: # 50 | |
993 | 65.. 69: # 51 | |
994 | 70.. 74: # 52 | |
995 | 75.. 79: # 63 | |
996 | 80.. 84: # 56 | |
997 | 85.. 89: ## 75 | |
998 | 90.. 94: ## 73 | |
999 | 95.. 99: # 70 | |
1000 | ||
1001 | +++ Stats for array_size len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
1002 | ||
1003 | stats len: | |
1004 | num: 5000, avg: 7.51, stddev: 1.71, median 8, min 5, max 10 | |
1005 | 5: ###################################################### 834 | |
1006 | 6: ##################################################### 825 | |
1007 | 7: ##################################################### 820 | |
1008 | 8: ###################################################### 833 | |
1009 | 9: ####################################################### 844 | |
1010 | 10: ####################################################### 844 | |
1011 | ||
1012 | +++ Stats for array_repeat len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
1013 | ||
1014 | stats len: | |
1015 | num: 5000, avg: 42.00, stddev: 0.00, median 42, min 42, max 42 | |
1016 | 42: ####################################################### 5000 | |
1017 | ||
1018 | +++ Stats for int_stats_neg ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
1019 | ||
1020 | stats dist: | |
1021 | num: 5000, avg: 0.17, stddev: 29.68, median 0, min -99, max 99 | |
1022 | -99..-90: # 65 | |
1023 | -89..-80: # 63 | |
1024 | -79..-70: # 64 | |
1025 | -69..-60: # 58 | |
1026 | -59..-50: # 67 | |
1027 | -49..-40: # 72 | |
1028 | -39..-30: # 61 | |
1029 | -29..-20: # 61 | |
1030 | -19..-10: # 67 | |
1031 | -9.. 0: ####################################################### 2076 | |
1032 | 1.. 10: ############################################## 1764 | |
1033 | 11.. 20: # 66 | |
1034 | 21.. 30: # 64 | |
1035 | 31.. 40: # 64 | |
1036 | 41.. 50: # 67 | |
1037 | 51.. 60: # 60 | |
1038 | 61.. 70: # 75 | |
1039 | 71.. 80: # 60 | |
1040 | 81.. 90: # 60 | |
1041 | 91..100: # 66 | |
1042 | ||
1043 | +++ Stats for small_signed_int dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
1044 | ||
1045 | stats dist: | |
1046 | num: 1000, avg: 0.90, stddev: 28.23, median 0, min -99, max 99 | |
1047 | -99..-90: # 12 | |
1048 | -89..-80: # 11 | |
1049 | -79..-70: # 9 | |
1050 | -69..-60: 6 | |
1051 | -59..-50: # 11 | |
1052 | -49..-40: # 13 | |
1053 | -39..-30: # 9 | |
1054 | -29..-20: # 13 | |
1055 | -19..-10: 8 | |
1056 | -9.. 0: ####################################################### 453 | |
1057 | 1.. 10: ######################################### 340 | |
1058 | 11.. 20: # 15 | |
1059 | 21.. 30: # 11 | |
1060 | 31.. 40: # 12 | |
1061 | 41.. 50: # 13 | |
1062 | 51.. 60: # 13 | |
1063 | 61.. 70: # 16 | |
1064 | 71.. 80: # 9 | |
1065 | 81.. 90: # 16 | |
1066 | 91..100: # 10 | |
1067 | ||
1068 | +++ Stats for small_nat dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
1069 | ||
1070 | stats dist: | |
1071 | num: 1000, avg: 15.11, stddev: 23.27, median 6, min 0, max 99 | |
1072 | 0.. 4: #################################################### 377 | |
1073 | 5.. 9: ####################################################### 392 | |
1074 | 10.. 14: ## 20 | |
1075 | 15.. 19: ## 15 | |
1076 | 20.. 24: # 11 | |
1077 | 25.. 29: ## 17 | |
1078 | 30.. 34: ## 19 | |
1079 | 35.. 39: ## 17 | |
1080 | 40.. 44: # 10 | |
1081 | 45.. 49: # 9 | |
1082 | 50.. 54: # 8 | |
1083 | 55.. 59: # 9 | |
1084 | 60.. 64: ## 15 | |
1085 | 65.. 69: # 10 | |
1086 | 70.. 74: # 13 | |
1087 | 75.. 79: ## 19 | |
1088 | 80.. 84: # 11 | |
1089 | 85.. 89: # 13 | |
1090 | 90.. 94: 5 | |
1091 | 95.. 99: # 10 | |
1092 | ||
1093 | +++ Stats for nat dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
1094 | ||
1095 | stats dist: | |
1096 | num: 1000, avg: 363.02, stddev: 1215.04, median 9, min 0, max 9476 | |
1097 | 0.. 473: ####################################################### 847 | |
1098 | 474.. 947: ###### 95 | |
1099 | 948..1421: 14 | |
1100 | 1422..1895: 3 | |
1101 | 1896..2369: 0 | |
1102 | 2370..2843: 3 | |
1103 | 2844..3317: 2 | |
1104 | 3318..3791: 3 | |
1105 | 3792..4265: 2 | |
1106 | 4266..4739: 4 | |
1107 | 4740..5213: 3 | |
1108 | 5214..5687: 4 | |
1109 | 5688..6161: 3 | |
1110 | 6162..6635: 4 | |
1111 | 6636..7109: 1 | |
1112 | 7110..7583: 4 | |
1113 | 7584..8057: 2 | |
1114 | 8058..8531: 1 | |
1115 | 8532..9005: 1 | |
1116 | 9006..9479: 4 | |
1117 | ||
1118 | +++ Stats for int_range (-43643) 435434 dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
1119 | ||
1120 | stats dist: | |
1121 | num: 1000, avg: 195335.64, stddev: 136803.99, median 195583, min -43624, max 435210 | |
1122 | -43624..-19683: ############################################ 52 | |
1123 | -19682.. 4259: ######################################## 47 | |
1124 | 4260.. 28201: ############################## 36 | |
1125 | 28202.. 52143: ############################################ 52 | |
1126 | 52144.. 76085: ########################################## 50 | |
1127 | 76086..100027: ####################################################### 64 | |
1128 | 100028..123969: ############################################### 55 | |
1129 | 123970..147911: ######################################## 47 | |
1130 | 147912..171853: ############################################## 54 | |
1131 | 171854..195795: #################################### 43 | |
1132 | 195796..219737: ############################################## 54 | |
1133 | 219738..243679: ########################################### 51 | |
1134 | 243680..267621: ################################################ 57 | |
1135 | 267622..291563: ########################################## 49 | |
1136 | 291564..315505: #################################### 42 | |
1137 | 315506..339447: ###################################### 45 | |
1138 | 339448..363389: ################################################ 57 | |
1139 | 363390..387331: ###################################### 45 | |
1140 | 387332..411273: ########################################## 49 | |
1141 | 411274..435215: ########################################### 51 | |
1142 | ||
1143 | +++ Stats for int_range (-40000) 40000 dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
1144 | ||
1145 | stats dist: | |
1146 | num: 1000, avg: -173.78, stddev: 23042.92, median 180, min -39859, max 39942 | |
1147 | -39859..-35869: ############################################# 56 | |
1148 | -35868..-31878: ################################### 43 | |
1149 | -31877..-27887: ################################################# 60 | |
1150 | -27886..-23896: ##################################### 46 | |
1151 | -23895..-19905: ######################################## 49 | |
1152 | -19904..-15914: #################################### 45 | |
1153 | -15913..-11923: ############################################ 54 | |
1154 | -11922.. -7932: ############################################### 58 | |
1155 | -7931.. -3941: ######################################### 51 | |
1156 | -3940.. 50: ############################ 35 | |
1157 | 51.. 4041: ####################################### 48 | |
1158 | 4042.. 8032: ########################################## 52 | |
1159 | 8033.. 12023: ######################################### 51 | |
1160 | 12024.. 16014: ########################################### 53 | |
1161 | 16015.. 20005: ############################################ 54 | |
1162 | 20006.. 23996: ################################## 42 | |
1163 | 23997.. 27987: ####################################################### 67 | |
1164 | 27988.. 31978: ################################ 40 | |
1165 | 31979.. 35969: ######################################### 51 | |
1166 | 35970.. 39960: #################################### 45 | |
1167 | ||
1168 | +++ Stats for int_range (-4) 4 dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
1169 | ||
1170 | stats dist: | |
1171 | num: 1000, avg: 0.02, stddev: 2.55, median 0, min -4, max 4 | |
1172 | -4: ############################################ 99 | |
1173 | -3: ##################################################### 118 | |
1174 | -2: ################################################## 111 | |
1175 | -1: ################################################## 113 | |
1176 | 0: ################################################## 113 | |
1177 | 1: ##################################################### 118 | |
1178 | 2: ############################################# 102 | |
1179 | 3: ####################################################### 122 | |
1180 | 4: ############################################## 104 | |
1181 | ||
1182 | +++ Stats for int_range (-4) 17 dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
1183 | ||
1184 | stats dist: | |
1185 | num: 1000, avg: 6.67, stddev: 6.39, median 7, min -4, max 17 | |
1186 | -4..-3: ############################################# 90 | |
1187 | -2..-1: ############################################# 91 | |
1188 | 0.. 1: ########################################## 84 | |
1189 | 2.. 3: ############################################## 92 | |
1190 | 4.. 5: ########################################### 87 | |
1191 | 6.. 7: ########################################### 86 | |
1192 | 8.. 9: ############################################ 89 | |
1193 | 10..11: ########################################### 87 | |
1194 | 12..13: ####################################################### 110 | |
1195 | 14..15: ############################################# 91 | |
1196 | 16..17: ############################################## 93 | |
1197 | 18..19: 0 | |
1198 | 20..21: 0 | |
1199 | 22..23: 0 | |
1200 | 24..25: 0 | |
1201 | 26..27: 0 | |
1202 | 28..29: 0 | |
1203 | 30..31: 0 | |
1204 | 32..33: 0 | |
1205 | 34..35: 0 | |
1206 | ||
1207 | +++ Stats for int dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
1208 | ||
1209 | stats dist: | |
1210 | num: 100000, avg: 336840.90, stddev: 619301756.02, median 895228, min -1073728193, max 1073739280 | |
1211 | -1073728193.. -966354820: ##################################################### 5009 | |
1212 | -966354819.. -858981446: #################################################### 5004 | |
1213 | -858981445.. -751608072: #################################################### 4917 | |
1214 | -751608071.. -644234698: ##################################################### 5028 | |
1215 | -644234697.. -536861324: #################################################### 4962 | |
1216 | -536861323.. -429487950: ##################################################### 5039 | |
1217 | -429487949.. -322114576: #################################################### 4927 | |
1218 | -322114575.. -214741202: ##################################################### 5054 | |
1219 | -214741201.. -107367828: ##################################################### 5065 | |
1220 | -107367827.. 5546: #################################################### 4954 | |
1221 | 5547.. 107378920: #################################################### 4943 | |
1222 | 107378921.. 214752294: ################################################### 4900 | |
1223 | 214752295.. 322125668: ###################################################### 5126 | |
1224 | 322125669.. 429499042: ####################################################### 5198 | |
1225 | 429499043.. 536872416: #################################################### 4988 | |
1226 | 536872417.. 644245790: #################################################### 4940 | |
1227 | 644245791.. 751619164: #################################################### 5002 | |
1228 | 751619165.. 858992538: #################################################### 4928 | |
1229 | 858992539.. 966365912: ##################################################### 5070 | |
1230 | 966365913.. 1073739286: #################################################### 4946 | |
1231 | ||
1232 | +++ Stats for oneof int dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
1233 | ||
1234 | stats dist: | |
1235 | num: 1000, avg: 1073741.63, stddev: 676575790.92, median 0, min -1073741824, max 1073741823 | |
1236 | -1073741824.. -966367642: ################## 208 | |
1237 | -966367641.. -858993459: 0 | |
1238 | -858993458.. -751619276: 0 | |
1239 | -751619275.. -644245093: 0 | |
1240 | -644245092.. -536870910: 0 | |
1241 | -536870909.. -429496727: 0 | |
1242 | -429496726.. -322122544: 0 | |
1243 | -322122543.. -214748361: 0 | |
1244 | -214748360.. -107374178: 0 | |
1245 | -107374177.. 5: ####################################################### 603 | |
1246 | 6.. 107374188: 0 | |
1247 | 107374189.. 214748371: 0 | |
1248 | 214748372.. 322122554: 0 | |
1249 | 322122555.. 429496737: 0 | |
1250 | 429496738.. 536870920: 0 | |
1251 | 536870921.. 644245103: 0 | |
1252 | 644245104.. 751619286: 0 | |
1253 | 751619287.. 858993469: 0 | |
1254 | 858993470.. 966367652: 0 | |
1255 | 966367653.. 1073741823: ################# 189 | |
1256 | ================================================================================ | |
1257 | 1 warning(s) | |
1258 | failure (59 tests failed, 3 tests errored, ran 130 tests) | |
1259 | random seed: 153870556 | |
1260 | ||
1261 | +++ Stats for int_dist_empty_bucket ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
1262 | ||
1263 | stats dist: | |
1264 | num: 1000, avg: 10351291.88, stddev: 432212939.52, median 9, min -1066972208, max 1073741823 | |
1265 | -1066972208.. -959936507: ## 27 | |
1266 | -959936506.. -852900805: ## 22 | |
1267 | -852900804.. -745865103: ## 22 | |
1268 | -745865102.. -638829401: # 18 | |
1269 | -638829400.. -531793699: # 17 | |
1270 | -531793698.. -424757997: ## 21 | |
1271 | -424757996.. -317722295: ### 33 | |
1272 | -317722294.. -210686593: ### 33 | |
1273 | -210686592.. -103650891: ### 32 | |
1274 | -103650890.. 3384811: ####################################################### 516 | |
1275 | 3384812.. 110420513: ### 34 | |
1276 | 110420514.. 217456215: ### 34 | |
1277 | 217456216.. 324491917: # 17 | |
1278 | 324491918.. 431527619: ## 24 | |
1279 | 431527620.. 538563321: ## 26 | |
1280 | 538563322.. 645599023: ## 20 | |
1281 | 645599024.. 752634725: ## 24 | |
1282 | 752634726.. 859670427: ## 27 | |
1283 | 859670428.. 966706129: ## 27 | |
1284 | 966706130.. 1073741823: ## 26 | |
1285 | ================================================================================ | |
1286 | success (ran 1 tests) |
0 | random seed: 1234 | |
1 | 50 7 0 0 0 0 0 0 0 0 0 0 3 3 3 3 3 3 3 3 3 3 5 5 5 5 5 5 5 5 5 5 6 6 6 6 6 6 6 6 6 6 (6,fun,50) (0,fun,2) (7,fun,66) (54,fun,9) (2,fun,5) (90,fun,4) (1,fun,4) (37,fun,7) (7,fun,1) (8,fun,5) | |
2 | (6,fun,50) (0,fun,2) (7,fun,66) (54,fun,9) (2,fun,5) (90,fun,4) (1,fun,4) (37,fun,7) (7,fun,1) (8,fun,5) | |
3 | (6,fun,50) (0,fun,2) (7,fun,66) (54,fun,9) (2,fun,5) (90,fun,4) (1,fun,4) (37,fun,7) (7,fun,1) (8,fun,5) | |
4 | (6,fun,50) (0,fun,2) (7,fun,66) (54,fun,9) (2,fun,5) (90,fun,4) (1,fun,4) (37,fun,7) (7,fun,1) (8,fun,5) | |
5 | (6,fun,50) (0,fun,2) (7,fun,66) (54,fun,9) (2,fun,5) (90,fun,4) (1,fun,4) (37,fun,7) (7,fun,1) (8,fun,5) | |
6 | (6,fun,50) (0,fun,2) (7,fun,66) (54,fun,9) (2,fun,5) (90,fun,4) (1,fun,4) (37,fun,7) (7,fun,1) (8,fun,5) | |
7 | (6,fun,50) (0,fun,2) (7,fun,66) (54,fun,9) (2,fun,5) (90,fun,4) (1,fun,4) (37,fun,7) (7,fun,1) (8,fun,5) | |
8 | (6,fun,50) (0,fun,2) (7,fun,66) (54,fun,9) (2,fun,5) (90,fun,4) (1,fun,4) (37,fun,7) (7,fun,1) (8,fun,5) | |
9 | 2724675603984413065 | |
10 | 0 | |
11 | 1362337801992206532 | |
12 | 0 | |
13 | 681168900996103266 | |
14 | 0 | |
15 | 340584450498051633 | |
16 | 0 | |
17 | 170292225249025816 | |
18 | 0 | |
19 | 85146112624512908 | |
20 | 0 | |
21 | 42573056312256454 | |
22 | 0 | |
23 | 21286528156128227 | |
24 | 0 | |
25 | 10643264078064113 | |
26 | 0 | |
27 | 5321632039032056 | |
28 | 0 | |
29 | 2660816019516028 | |
30 | 0 | |
31 | 1330408009758014 | |
32 | 0 | |
33 | 665204004879007 | |
34 | 0 | |
35 | 332602002439503 | |
36 | 0 | |
37 | 166301001219751 | |
38 | 0 | |
39 | 83150500609875 | |
40 | 0 | |
41 | 41575250304937 | |
42 | 0 | |
43 | 20787625152468 | |
44 | 0 | |
45 | 10393812576234 | |
46 | 0 | |
47 | 5196906288117 | |
48 | 0 | |
49 | 2598453144058 | |
50 | 0 | |
51 | 1299226572029 | |
52 | 0 | |
53 | 649613286014 | |
54 | 0 | |
55 | 324806643007 | |
56 | 0 | |
57 | 162403321503 | |
58 | 0 | |
59 | 81201660751 | |
60 | 0 | |
61 | 40600830375 | |
62 | 0 | |
63 | 20300415187 | |
64 | 0 | |
65 | 10150207593 | |
66 | 0 | |
67 | 5075103796 | |
68 | 0 | |
69 | 2537551898 | |
70 | 0 | |
71 | 1268775949 | |
72 | 0 | |
73 | 634387974 | |
74 | 0 | |
75 | 317193987 | |
76 | 0 | |
77 | 158596993 | |
78 | 0 | |
79 | 79298496 | |
80 | 0 | |
81 | 39649248 | |
82 | 0 | |
83 | 19824624 | |
84 | 0 | |
85 | 9912312 | |
86 | 0 | |
87 | 4956156 | |
88 | 0 | |
89 | 2478078 | |
90 | 0 | |
91 | 1239039 | |
92 | 0 | |
93 | 619519 | |
94 | 0 | |
95 | 309759 | |
96 | 0 | |
97 | 154879 | |
98 | 0 | |
99 | 77439 | |
100 | 0 | |
101 | 38719 | |
102 | 0 | |
103 | 19359 | |
104 | 0 | |
105 | 9679 | |
106 | 0 | |
107 | 4839 | |
108 | 0 | |
109 | 2419 | |
110 | 0 | |
111 | 1209 | |
112 | 0 | |
113 | 604 | |
114 | 0 | |
115 | 302 | |
116 | 0 | |
117 | 151 | |
118 | 0 | |
119 | 75 | |
120 | 0 | |
121 | 37 | |
122 | 0 | |
123 | 18 | |
124 | 0 | |
125 | 9 | |
126 | 0 | |
127 | 4 | |
128 | 0 | |
129 | 2 | |
130 | 0 | |
131 | 1 | |
132 | 0 | |
133 | [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] | |
134 | [] | |
135 | [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] | |
136 | [] | |
137 | [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] | |
138 | [] | |
139 | [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] | |
140 | [] | |
141 | [9; 8; 73; 5; 8; 2; 1; 8; 2; 6; 4; 18; 5; 76; 3] | |
142 | [] | |
143 | [0; 6; 2; 8; 8; 1; 4] | |
144 | [] | |
145 | [5; 2; 3] | |
146 | [] | |
147 | [3] | |
148 | [] | |
149 | [0] | |
150 | [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] | |
151 | [] | |
152 | [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] | |
153 | [] | |
154 | [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] | |
155 | [] | |
156 | [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] | |
157 | [] | |
158 | [9; 8; 73; 5; 8; 2; 1; 8; 2; 6; 4; 18; 5; 76; 3] | |
159 | [] | |
160 | [0; 6; 2; 8; 8; 1; 4] | |
161 | [] | |
162 | [5; 2; 3] | |
163 | [3; 2; 7; 3; 3] | |
164 | [] | |
165 | [5; 3] | |
166 | [5; 3; 2] | |
167 | [9; 87; 7; 0] | |
168 | [0; 2; 7; 3; 3] | |
169 | [0; 0; 7; 3; 3] | |
170 | [0; 0; 0; 3; 3] | |
171 | [0; 0; 0; 0; 3] | |
172 | [0; 0; 0; 0; 0] | |
173 | ||
174 | --- Failure -------------------------------------------------------------------- | |
175 | ||
176 | Test should_fail_sort_id failed (9 shrink steps): | |
177 | ||
178 | [1; 0] | |
179 | ||
180 | === Error ====================================================================== | |
181 | ||
182 | Test should_error_raise_exn errored on (1 shrink steps): | |
183 | ||
184 | 0 | |
185 | ||
186 | exception QCheck2_tests.Overall.Error | |
187 | ||
188 | ||
189 | +++ Collect ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
190 | ||
191 | Collect results for test collect_results: | |
192 | ||
193 | 4: 20 cases | |
194 | 3: 25 cases | |
195 | 2: 17 cases | |
196 | 1: 18 cases | |
197 | 0: 20 cases | |
198 | ||
199 | +++ Stats for with_stats ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
200 | ||
201 | stats mod4: | |
202 | num: 100, avg: 1.68, stddev: 1.09, median 2, min 0, max 3 | |
203 | 0: ############################## 17 | |
204 | 1: ################################################### 29 | |
205 | 2: ######################################## 23 | |
206 | 3: ####################################################### 31 | |
207 | ||
208 | stats num: | |
209 | num: 100, avg: 66.84, stddev: 31.94, median 65, min 2, max 120 | |
210 | 2.. 7: ################## 3 | |
211 | 8.. 13: ################## 3 | |
212 | 14.. 19: 0 | |
213 | 20.. 25: ########################################## 7 | |
214 | 26.. 31: ######################## 4 | |
215 | 32.. 37: ######################## 4 | |
216 | 38.. 43: ################## 3 | |
217 | 44.. 49: ################################################ 8 | |
218 | 50.. 55: #################################### 6 | |
219 | 56.. 61: #################################### 6 | |
220 | 62.. 67: ####################################################### 9 | |
221 | 68.. 73: ########################################## 7 | |
222 | 74.. 79: ######################## 4 | |
223 | 80.. 85: ################## 3 | |
224 | 86.. 91: ############ 2 | |
225 | 92.. 97: ########################################## 7 | |
226 | 98..103: #################################### 6 | |
227 | 104..109: #################################### 6 | |
228 | 110..115: ####################################################### 9 | |
229 | 116..121: ################## 3 | |
230 | ||
231 | --- Failure -------------------------------------------------------------------- | |
232 | ||
233 | Test with shrinking retries failed (0 shrink steps): | |
234 | ||
235 | 7 | |
236 | ||
237 | !!! Warning !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
238 | ||
239 | Warning for test WARN_unlikely_precond: | |
240 | ||
241 | WARNING: only 0.5% tests (of 2000) passed precondition for "WARN_unlikely_precond" | |
242 | ||
243 | NOTE: it is likely that the precondition is too strong, or that the generator is buggy. | |
244 | ||
245 | --- Failure -------------------------------------------------------------------- | |
246 | ||
247 | Test FAIL_unlikely_precond failed: | |
248 | ||
249 | ERROR: only 0.5% tests (of 2000) passed precondition for "FAIL_unlikely_precond" | |
250 | ||
251 | NOTE: it is likely that the precondition is too strong, or that the generator is buggy. | |
252 | ||
253 | ||
254 | --- Failure -------------------------------------------------------------------- | |
255 | ||
256 | Test FAIL_bad_gen failed: | |
257 | ||
258 | ERROR: uncaught exception in generator for test FAIL_bad_gen after 100 steps: | |
259 | Exception: Invalid_argument("Gen.int_bound") | |
260 | Backtrace: | |
261 | ||
262 | --- Failure -------------------------------------------------------------------- | |
263 | ||
264 | Test int double failed: | |
265 | ||
266 | Negative test int double succeeded but was expected to fail | |
267 | ||
268 | === Error ====================================================================== | |
269 | ||
270 | Test pos fail with error errored on (1 shrink steps): | |
271 | ||
272 | 0 | |
273 | ||
274 | exception QCheck2_tests.Overall.Error | |
275 | ||
276 | ||
277 | === Error ====================================================================== | |
278 | ||
279 | Test neg fail with error errored on (1 shrink steps): | |
280 | ||
281 | 0 | |
282 | ||
283 | exception QCheck2_tests.Overall.Error | |
284 | ||
285 | ||
286 | --- Failure -------------------------------------------------------------------- | |
287 | ||
288 | Test char never produces '\255' failed (0 shrink steps): | |
289 | ||
290 | '\255' | |
291 | ||
292 | --- Failure -------------------------------------------------------------------- | |
293 | ||
294 | Test big bound issue59 failed (0 shrink steps): | |
295 | ||
296 | 4611686018427387903 | |
297 | ||
298 | --- Failure -------------------------------------------------------------------- | |
299 | ||
300 | Test long_shrink failed (3039 shrink steps): | |
301 | ||
302 | ([0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0], [0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 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]) | |
303 | ||
304 | --- Failure -------------------------------------------------------------------- | |
305 | ||
306 | Test ints arent 0 mod 3 failed (2 shrink steps): | |
307 | ||
308 | 0 | |
309 | ||
310 | --- Failure -------------------------------------------------------------------- | |
311 | ||
312 | Test ints are 0 failed (61 shrink steps): | |
313 | ||
314 | 1 | |
315 | ||
316 | --- Failure -------------------------------------------------------------------- | |
317 | ||
318 | Test ints < 209609 failed (0 shrink steps): | |
319 | ||
320 | 4611686018427387903 | |
321 | ||
322 | --- Failure -------------------------------------------------------------------- | |
323 | ||
324 | Test nat < 5001 failed (7 shrink steps): | |
325 | ||
326 | 5001 | |
327 | ||
328 | --- Failure -------------------------------------------------------------------- | |
329 | ||
330 | Test char never produces 'abcdef' failed (1 shrink steps): | |
331 | ||
332 | 'a' | |
333 | ||
334 | --- Failure -------------------------------------------------------------------- | |
335 | ||
336 | Test printable never produces '!"#$%&'' failed (1 shrink steps): | |
337 | ||
338 | '!' | |
339 | ||
340 | --- Failure -------------------------------------------------------------------- | |
341 | ||
342 | Test printable never produces less than '5 failed (1 shrink steps): | |
343 | ||
344 | '0' | |
345 | ||
346 | --- Failure -------------------------------------------------------------------- | |
347 | ||
348 | Test strings are empty failed (8 shrink steps): | |
349 | ||
350 | "a" | |
351 | ||
352 | --- Failure -------------------------------------------------------------------- | |
353 | ||
354 | Test string never has a \000 char failed (22 shrink steps): | |
355 | ||
356 | "aaaaaa\000aaaaaaaaaaaaaaaa" | |
357 | ||
358 | --- Failure -------------------------------------------------------------------- | |
359 | ||
360 | Test string never has a \255 char failed (59 shrink steps): | |
361 | ||
362 | "aaaaaaaaaaaaaaaaaaaaaaaaaa\255aaaaaaaaaaaaaaaaaaaaaaaa" | |
363 | ||
364 | --- Failure -------------------------------------------------------------------- | |
365 | ||
366 | Test strings have unique chars failed (18 shrink steps): | |
367 | ||
368 | "aaaaaaaaaaaaa" | |
369 | ||
370 | --- Failure -------------------------------------------------------------------- | |
371 | ||
372 | Test pairs have different components failed (0 shrink steps): | |
373 | ||
374 | (4, 4) | |
375 | ||
376 | --- Failure -------------------------------------------------------------------- | |
377 | ||
378 | Test pairs have same components failed (63 shrink steps): | |
379 | ||
380 | (0, 1) | |
381 | ||
382 | --- Failure -------------------------------------------------------------------- | |
383 | ||
384 | Test pairs have a zero component failed (122 shrink steps): | |
385 | ||
386 | (1, 1) | |
387 | ||
388 | --- Failure -------------------------------------------------------------------- | |
389 | ||
390 | Test pairs are (0,0) failed (63 shrink steps): | |
391 | ||
392 | (0, 1) | |
393 | ||
394 | --- Failure -------------------------------------------------------------------- | |
395 | ||
396 | Test pairs are ordered failed (94 shrink steps): | |
397 | ||
398 | (1, 0) | |
399 | ||
400 | --- Failure -------------------------------------------------------------------- | |
401 | ||
402 | Test pairs are ordered reversely failed (62 shrink steps): | |
403 | ||
404 | (0, 1) | |
405 | ||
406 | --- Failure -------------------------------------------------------------------- | |
407 | ||
408 | Test pairs sum to less than 128 failed (56 shrink steps): | |
409 | ||
410 | (0, 128) | |
411 | ||
412 | --- Failure -------------------------------------------------------------------- | |
413 | ||
414 | Test pairs lists rev concat failed (83 shrink steps): | |
415 | ||
416 | ([0], [1]) | |
417 | ||
418 | --- Failure -------------------------------------------------------------------- | |
419 | ||
420 | Test pairs lists no overlap failed (27 shrink steps): | |
421 | ||
422 | ([0], [0; 0; 0; 0]) | |
423 | ||
424 | --- Failure -------------------------------------------------------------------- | |
425 | ||
426 | Test triples have pair-wise different components failed (3 shrink steps): | |
427 | ||
428 | (0, 0, 0) | |
429 | ||
430 | --- Failure -------------------------------------------------------------------- | |
431 | ||
432 | Test triples have same components failed (64 shrink steps): | |
433 | ||
434 | (0, 1, 0) | |
435 | ||
436 | --- Failure -------------------------------------------------------------------- | |
437 | ||
438 | Test triples are ordered failed (3 shrink steps): | |
439 | ||
440 | (0, -1, 0) | |
441 | ||
442 | --- Failure -------------------------------------------------------------------- | |
443 | ||
444 | Test triples are ordered reversely failed (64 shrink steps): | |
445 | ||
446 | (0, 0, 1) | |
447 | ||
448 | --- Failure -------------------------------------------------------------------- | |
449 | ||
450 | Test quadruples have pair-wise different components failed (4 shrink steps): | |
451 | ||
452 | (0, 0, 0, 0) | |
453 | ||
454 | --- Failure -------------------------------------------------------------------- | |
455 | ||
456 | Test quadruples have same components failed (126 shrink steps): | |
457 | ||
458 | (0, 1, 0, 1) | |
459 | ||
460 | --- Failure -------------------------------------------------------------------- | |
461 | ||
462 | Test quadruples are ordered failed (5 shrink steps): | |
463 | ||
464 | (0, 0, -1, 0) | |
465 | ||
466 | --- Failure -------------------------------------------------------------------- | |
467 | ||
468 | Test quadruples are ordered reversely failed (66 shrink steps): | |
469 | ||
470 | (0, 0, 0, 1) | |
471 | ||
472 | --- Failure -------------------------------------------------------------------- | |
473 | ||
474 | Test forall (a, b) in nat: a < b failed (6 shrink steps): | |
475 | ||
476 | (0, 0) | |
477 | ||
478 | --- Failure -------------------------------------------------------------------- | |
479 | ||
480 | Test forall (a, b, c) in nat: a < b < c failed (3 shrink steps): | |
481 | ||
482 | (0, 0, 0) | |
483 | ||
484 | --- Failure -------------------------------------------------------------------- | |
485 | ||
486 | Test forall (a, b, c, d) in nat: a < b < c < d failed (4 shrink steps): | |
487 | ||
488 | (0, 0, 0, 0) | |
489 | ||
490 | --- Failure -------------------------------------------------------------------- | |
491 | ||
492 | Test forall (a, b, c, d, e) in nat: a < b < c < d < e failed (5 shrink steps): | |
493 | ||
494 | (0, 0, 0, 0, 0) | |
495 | ||
496 | --- Failure -------------------------------------------------------------------- | |
497 | ||
498 | Test forall (a, b, c, d, e, f) in nat: a < b < c < d < e < f failed (6 shrink steps): | |
499 | ||
500 | (0, 0, 0, 0, 0, 0) | |
501 | ||
502 | --- Failure -------------------------------------------------------------------- | |
503 | ||
504 | Test forall (a, b, c, d, e, f, g) in nat: a < b < c < d < e < f < g failed (7 shrink steps): | |
505 | ||
506 | (0, 0, 0, 0, 0, 0, 0) | |
507 | ||
508 | --- Failure -------------------------------------------------------------------- | |
509 | ||
510 | Test forall (a, b, c, d, e, f, g, h) in nat: a < b < c < d < e < f < g < h failed (8 shrink steps): | |
511 | ||
512 | (0, 0, 0, 0, 0, 0, 0, 0) | |
513 | ||
514 | --- Failure -------------------------------------------------------------------- | |
515 | ||
516 | Test forall (a, b, c, d, e, f, g, h, i) in nat: a < b < c < d < e < f < g < h < i failed (9 shrink steps): | |
517 | ||
518 | (0, 0, 0, 0, 0, 0, 0, 0, 0) | |
519 | ||
520 | --- Failure -------------------------------------------------------------------- | |
521 | ||
522 | Test bind ordered pairs failed (1 shrink steps): | |
523 | ||
524 | (0, 0) | |
525 | ||
526 | --- Failure -------------------------------------------------------------------- | |
527 | ||
528 | Test bind list_size constant failed (12 shrink steps): | |
529 | ||
530 | (4, [0; 0; 0; 0]) | |
531 | ||
532 | --- Failure -------------------------------------------------------------------- | |
533 | ||
534 | Test lists are empty failed (8 shrink steps): | |
535 | ||
536 | [0] | |
537 | ||
538 | --- Failure -------------------------------------------------------------------- | |
539 | ||
540 | Test lists shorter than 10 failed (16 shrink steps): | |
541 | ||
542 | [0; 0; 0; 0; 0; 0; 0; 0; 0; 0] | |
543 | ||
544 | --- Failure -------------------------------------------------------------------- | |
545 | ||
546 | Test lists shorter than 432 failed (412 shrink steps): | |
547 | ||
548 | [...] list length: 432 | |
549 | ||
550 | --- Failure -------------------------------------------------------------------- | |
551 | ||
552 | Test lists shorter than 4332 failed (4022 shrink steps): | |
553 | ||
554 | [...] list length: 4332 | |
555 | ||
556 | --- Failure -------------------------------------------------------------------- | |
557 | ||
558 | Test lists have unique elems failed (11 shrink steps): | |
559 | ||
560 | [0; 0; 0; 0; 0] | |
561 | ||
562 | --- Failure -------------------------------------------------------------------- | |
563 | ||
564 | Test tree contains only 42 failed (2 shrink steps): | |
565 | ||
566 | Leaf 0 | |
567 | ||
568 | --- Failure -------------------------------------------------------------------- | |
569 | ||
570 | Test sum list = 0 failed (0 shrink steps): | |
571 | ||
572 | [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] | |
573 | ||
574 | --- Failure -------------------------------------------------------------------- | |
575 | ||
576 | Test fail_pred_map_commute failed (122 shrink steps): | |
577 | ||
578 | ([0], {0 -> 1; 2 -> 0; 20 -> 0; 4 -> 0; 54 -> 0; 6 -> 0; 8 -> 0; 60 -> 0; 12 -> 0; _ -> 0}, {0 -> true; -1487654178632829215 -> false; -2792235260416531278 -> false; 2 -> false; 3324124342680534771 -> false; 20 -> false; 4 -> false; -2849913598173370635 -> false; 54 -> false; 6 -> false; 8 -> false; 815755449952469177 -> false; 4035005642433201833 -> false; -2961585594425353332 -> false; 60 -> false; 12 -> false; 3780670741311086221 -> false; _ -> false}) | |
579 | ||
580 | --- Failure -------------------------------------------------------------------- | |
581 | ||
582 | Test fail_pred_strings failed (2 shrink steps): | |
583 | ||
584 | {"some random string" -> true; _ -> false} | |
585 | ||
586 | --- Failure -------------------------------------------------------------------- | |
587 | ||
588 | Test fold_left fold_right failed (56 shrink steps): | |
589 | ||
590 | (0, [1], {(1, 0) -> 1; (8, 0) -> 0; (6, 4) -> 0; (2, 6) -> 0; (3, 6) -> 0; (2, 16) -> 0; (0, 60) -> 0; (20, 3) -> 0; (12, 60) -> 0; (0, 2) -> 0; (2, 4) -> 0; (1, 6) -> 0; (6, 1) -> 0; (60, 83) -> 0; (3, 5) -> 0; (7, 12) -> 0; (6, 8) -> 0; (2, 2) -> 0; (56, 6) -> 0; (6, 5) -> 0; (12, 3) -> 0; (6, 6) -> 0; (0, 8) -> 0; (0, 58) -> 0; (5, 5) -> 0; (20, 2) -> 0; (54, 0) -> 0; (0, 6) -> 0; (4, 6) -> 0; (4, 56) -> 0; (5, 54) -> 0; (9, 8) -> 0; (8, 6) -> 0; (60, 47) -> 0; (9, 12) -> 0; (4, 20) -> 0; (0, 20) -> 0; (1, 2) -> 0; (28, 2) -> 0; (4, 1) -> 0; (0, 4) -> 0; (8, 3) -> 0; (4, 28) -> 0; (42, 8) -> 0; (6, 0) -> 0; (58, 65) -> 0; (12, 12) -> 0; (5, 6) -> 0; _ -> 0}) | |
591 | ||
592 | +++ Messages ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
593 | ||
594 | Messages for test fold_left fold_right: | |
595 | ||
596 | l=[1], fold_left=1, fold_right=0 | |
597 | ||
598 | ||
599 | --- Failure -------------------------------------------------------------------- | |
600 | ||
601 | Test fold_left fold_right uncurried failed (376 shrink steps): | |
602 | ||
603 | ({(0, 2) -> 0; (13, 0) -> 0; (22, 3) -> 0; (20, 5) -> 0; (2, 93) -> 0; (65, 34) -> 0; (2, 7) -> 0; (0, 7) -> 0; (49, 3) -> 0; (8, 62) -> 0; (8, 2) -> 0; (54, 6) -> 0; (38, 4) -> 0; (7, 0) -> 1; (6, 25) -> 0; (0, 0) -> 0; (3, 4) -> 0; (1, 7) -> 0; (4, 6) -> 0; (8, 1) -> 0; (48, 42) -> 0; (18, 1) -> 0; (90, 14) -> 0; (8, 70) -> 0; (9, 1) -> 0; (38, 2) -> 0; (3, 5) -> 0; (8, 8) -> 0; (9, 3) -> 0; (2, 36) -> 0; (45, 2) -> 0; (18, 6) -> 0; (7, 98) -> 0; (3, 9) -> 0; (2, 31) -> 0; (86, 2) -> 0; (4, 7) -> 0; (1, 1) -> 0; (0, 5) -> 0; (2, 9) -> 0; (1, 5) -> 0; (44, 0) -> 0; (77, 7) -> 0; (5, 8) -> 0; (1, 4) -> 0; (9, 79) -> 0; (48, 1) -> 0; (30, 7) -> 0; (6, 79) -> 0; (5, 1) -> 0; (65, 4) -> 0; (2, 1) -> 0; (4, 1) -> 0; (66, 12) -> 0; (6, 5) -> 0; (7, 3) -> 0; (3, 7) -> 0; (9, 7) -> 0; (9, 9) -> 0; (2, 6) -> 0; (3, 15) -> 0; (5, 3) -> 0; (67, 1) -> 0; (3, 28) -> 0; (1, 87) -> 0; (7, 31) -> 0; (9, 13) -> 0; (32, 1) -> 0; (0, 27) -> 0; (6, 15) -> 0; (20, 0) -> 0; (6, 8) -> 0; (1, 6) -> 0; (0, 6) -> 0; (3, 1) -> 0; (9, 71) -> 0; (95, 4) -> 0; (97, 1) -> 0; (7, 4) -> 0; (84, 3) -> 0; (92, 6) -> 0; (6, 2) -> 0; (8, 4) -> 0; (5, 0) -> 0; (7, 5) -> 0; (9, 8) -> 0; (90, 26) -> 0; (0, 19) -> 0; (1, 13) -> 0; (6, 1) -> 0; (9, 28) -> 0; (9, 6) -> 0; (8, 6) -> 0; (3, 8) -> 0; (7, 62) -> 0; (86, 0) -> 0; (65, 1) -> 0; (7, 1) -> 0; (6, 6) -> 0; (30, 4) -> 0; (7, 67) -> 0; (0, 9) -> 0; (78, 5) -> 0; (17, 3) -> 0; (9, 60) -> 0; (3, 71) -> 0; (88, 1) -> 0; (4, 61) -> 0; (9, 0) -> 0; (45, 0) -> 0; (2, 5) -> 0; (9, 47) -> 0; (18, 5) -> 0; (66, 0) -> 0; (0, 76) -> 0; (8, 3) -> 0; (74, 6) -> 0; (5, 60) -> 0; (5, 80) -> 0; (8, 9) -> 0; (7, 8) -> 0; (39, 4) -> 0; (72, 8) -> 0; (4, 38) -> 0; (70, 31) -> 0; (19, 5) -> 0; (4, 9) -> 0; (0, 1) -> 0; (1, 37) -> 0; (7, 6) -> 0; (6, 3) -> 0; (9, 5) -> 0; (58, 4) -> 0; (54, 5) -> 0; (7, 86) -> 0; (67, 6) -> 0; (0, 8) -> 0; (8, 7) -> 0; (44, 18) -> 0; (3, 0) -> 0; (4, 41) -> 0; (0, 31) -> 0; (1, 51) -> 0; (6, 0) -> 0; (1, 3) -> 0; (70, 1) -> 0; (9, 4) -> 0; (4, 5) -> 0; (1, 8) -> 0; (5, 9) -> 0; (0, 14) -> 0; (3, 3) -> 0; (4, 0) -> 0; (78, 9) -> 0; (0, 4) -> 0; (2, 3) -> 0; (9, 62) -> 0; (35, 1) -> 0; (55, 1) -> 0; _ -> 0}, 0, [7; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0]) | |
604 | ||
605 | --- Failure -------------------------------------------------------------------- | |
606 | ||
607 | Test fold_left fold_right uncurried fun last failed (56 shrink steps): | |
608 | ||
609 | (0, [1], {(0, 2) -> 0; (3, 6) -> 0; (0, 20) -> 0; (20, 4) -> 0; (6, 42) -> 0; (47, 6) -> 0; (6, 12) -> 0; (2, 6) -> 0; (0, 58) -> 0; (8, 2) -> 0; (6, 6) -> 0; (8, 60) -> 0; (12, 3) -> 0; (6, 4) -> 0; (16, 8) -> 0; (6, 0) -> 0; (3, 4) -> 0; (12, 0) -> 0; (60, 5) -> 0; (8, 1) -> 0; (6, 8) -> 0; (2, 5) -> 0; (2, 42) -> 0; (5, 4) -> 0; (4, 20) -> 0; (54, 0) -> 0; (12, 4) -> 0; (3, 2) -> 0; (8, 0) -> 0; (4, 7) -> 0; (28, 3) -> 0; (2, 9) -> 0; (65, 54) -> 0; (5, 28) -> 0; (20, 2) -> 0; (6, 2) -> 0; (83, 6) -> 0; (58, 5) -> 0; (5, 6) -> 0; (56, 12) -> 0; (1, 60) -> 0; (4, 9) -> 0; (0, 1) -> 1; (2, 8) -> 0; (2, 0) -> 0; (6, 1) -> 0; (1, 12) -> 0; (60, 0) -> 0; _ -> 0}) | |
610 | ||
611 | --- Failure -------------------------------------------------------------------- | |
612 | ||
613 | Test fold_left test, fun first failed (15 shrink steps): | |
614 | ||
615 | ({_ -> ""}, "a", [], [0]) | |
616 | ||
617 | --- Failure -------------------------------------------------------------------- | |
618 | ||
619 | Test FAIL_#99_1 failed: | |
620 | ||
621 | ERROR: uncaught exception in generator for test FAIL_#99_1 after 100 steps: | |
622 | Exception: QCheck2.No_example_found("<example>") | |
623 | Backtrace: | |
624 | ||
625 | +++ Collect ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
626 | ||
627 | Collect results for test bool dist: | |
628 | ||
629 | true: 250134 cases | |
630 | false: 249866 cases | |
631 | ||
632 | +++ Stats for char code dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
633 | ||
634 | stats char code: | |
635 | num: 500000, avg: 127.42, stddev: 73.92, median 127, min 0, max 255 | |
636 | 0.. 12: ###################################################### 25509 | |
637 | 13.. 25: ###################################################### 25398 | |
638 | 26.. 38: ###################################################### 25293 | |
639 | 39.. 51: ###################################################### 25448 | |
640 | 52.. 64: ###################################################### 25392 | |
641 | 65.. 77: ####################################################### 25660 | |
642 | 78.. 90: ###################################################### 25462 | |
643 | 91..103: ###################################################### 25331 | |
644 | 104..116: ##################################################### 25129 | |
645 | 117..129: ###################################################### 25351 | |
646 | 130..142: ###################################################### 25492 | |
647 | 143..155: ###################################################### 25370 | |
648 | 156..168: ###################################################### 25658 | |
649 | 169..181: ###################################################### 25400 | |
650 | 182..194: ##################################################### 25167 | |
651 | 195..207: ###################################################### 25338 | |
652 | 208..220: ##################################################### 25181 | |
653 | 221..233: ##################################################### 25145 | |
654 | 234..246: ###################################################### 25567 | |
655 | 247..259: ##################################### 17709 | |
656 | ||
657 | +++ Stats for printable char code dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
658 | ||
659 | stats char code: | |
660 | num: 500000, avg: 78.26, stddev: 28.15, median 78, min 10, max 126 | |
661 | 10.. 15: ######### 5149 | |
662 | 16.. 21: 0 | |
663 | 22.. 27: 0 | |
664 | 28.. 33: ################## 10379 | |
665 | 34.. 39: ###################################################### 31153 | |
666 | 40.. 45: ###################################################### 31341 | |
667 | 46.. 51: ###################################################### 31408 | |
668 | 52.. 57: ####################################################### 31456 | |
669 | 58.. 63: ###################################################### 31310 | |
670 | 64.. 69: ###################################################### 31152 | |
671 | 70.. 75: ###################################################### 31308 | |
672 | 76.. 81: ###################################################### 31156 | |
673 | 82.. 87: ###################################################### 31170 | |
674 | 88.. 93: ###################################################### 31286 | |
675 | 94.. 99: ###################################################### 31364 | |
676 | 100..105: ###################################################### 31368 | |
677 | 106..111: ###################################################### 31024 | |
678 | 112..117: ###################################################### 31261 | |
679 | 118..123: ###################################################### 31064 | |
680 | 124..129: ########################### 15651 | |
681 | ||
682 | +++ Stats for numeral char code dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
683 | ||
684 | stats char code: | |
685 | num: 500000, avg: 52.50, stddev: 2.87, median 52, min 48, max 57 | |
686 | 48: ###################################################### 50260 | |
687 | 49: ###################################################### 49590 | |
688 | 50: ###################################################### 50170 | |
689 | 51: ####################################################### 50270 | |
690 | 52: ###################################################### 49805 | |
691 | 53: ###################################################### 50161 | |
692 | 54: ###################################################### 49919 | |
693 | 55: ###################################################### 49971 | |
694 | 56: ###################################################### 49980 | |
695 | 57: ###################################################### 49874 | |
696 | ||
697 | +++ Stats for tree's depth ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
698 | ||
699 | stats depth: | |
700 | num: 1000, avg: 3.74, stddev: 3.28, median 3, min 1, max 15 | |
701 | 1: ####################################################### 377 | |
702 | 2: ################ 113 | |
703 | 3: ############ 87 | |
704 | 4: ################# 123 | |
705 | 5: ########### 81 | |
706 | 6: #### 33 | |
707 | 7: ##### 40 | |
708 | 8: ##### 39 | |
709 | 9: # 9 | |
710 | 10: ### 25 | |
711 | 11: ####### 49 | |
712 | 12: 4 | |
713 | 13: # 9 | |
714 | 14: # 7 | |
715 | 15: 4 | |
716 | ||
717 | +++ Stats for string_size len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
718 | ||
719 | stats len: | |
720 | num: 5000, avg: 7.49, stddev: 1.70, median 7, min 5, max 10 | |
721 | 5: ##################################################### 837 | |
722 | 6: ##################################################### 826 | |
723 | 7: ###################################################### 843 | |
724 | 8: ####################################################### 855 | |
725 | 9: #################################################### 813 | |
726 | 10: ##################################################### 826 | |
727 | ||
728 | +++ Stats for string len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
729 | ||
730 | stats len: | |
731 | num: 5000, avg: 384.53, stddev: 1330.61, median 9, min 0, max 9969 | |
732 | 0.. 498: ####################################################### 4246 | |
733 | 499.. 997: ###### 518 | |
734 | 998..1496: 21 | |
735 | 1497..1995: 10 | |
736 | 1996..2494: 11 | |
737 | 2495..2993: 10 | |
738 | 2994..3492: 13 | |
739 | 3493..3991: 13 | |
740 | 3992..4490: 5 | |
741 | 4491..4989: 10 | |
742 | 4990..5488: 19 | |
743 | 5489..5987: 9 | |
744 | 5988..6486: 10 | |
745 | 6487..6985: 12 | |
746 | 6986..7484: 17 | |
747 | 7485..7983: 16 | |
748 | 7984..8482: 16 | |
749 | 8483..8981: 16 | |
750 | 8982..9480: 16 | |
751 | 9481..9979: 12 | |
752 | ||
753 | +++ Stats for string_of len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
754 | ||
755 | stats len: | |
756 | num: 5000, avg: 363.14, stddev: 1245.80, median 9, min 0, max 9986 | |
757 | 0.. 499: ####################################################### 4270 | |
758 | 500.. 999: ###### 493 | |
759 | 1000.. 1499: 16 | |
760 | 1500.. 1999: 11 | |
761 | 2000.. 2499: 15 | |
762 | 2500.. 2999: 17 | |
763 | 3000.. 3499: 11 | |
764 | 3500.. 3999: 19 | |
765 | 4000.. 4499: 14 | |
766 | 4500.. 4999: 10 | |
767 | 5000.. 5499: 16 | |
768 | 5500.. 5999: 11 | |
769 | 6000.. 6499: 15 | |
770 | 6500.. 6999: 13 | |
771 | 7000.. 7499: 12 | |
772 | 7500.. 7999: 16 | |
773 | 8000.. 8499: 11 | |
774 | 8500.. 8999: 4 | |
775 | 9000.. 9499: 13 | |
776 | 9500.. 9999: 13 | |
777 | ||
778 | +++ Stats for string_printable len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
779 | ||
780 | stats len: | |
781 | num: 5000, avg: 384.53, stddev: 1330.61, median 9, min 0, max 9969 | |
782 | 0.. 498: ####################################################### 4246 | |
783 | 499.. 997: ###### 518 | |
784 | 998..1496: 21 | |
785 | 1497..1995: 10 | |
786 | 1996..2494: 11 | |
787 | 2495..2993: 10 | |
788 | 2994..3492: 13 | |
789 | 3493..3991: 13 | |
790 | 3992..4490: 5 | |
791 | 4491..4989: 10 | |
792 | 4990..5488: 19 | |
793 | 5489..5987: 9 | |
794 | 5988..6486: 10 | |
795 | 6487..6985: 12 | |
796 | 6986..7484: 17 | |
797 | 7485..7983: 16 | |
798 | 7984..8482: 16 | |
799 | 8483..8981: 16 | |
800 | 8982..9480: 16 | |
801 | 9481..9979: 12 | |
802 | ||
803 | +++ Stats for small_string len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
804 | ||
805 | stats len: | |
806 | num: 5000, avg: 15.57, stddev: 24.36, median 6, min 0, max 99 | |
807 | 0.. 4: #################################################### 1925 | |
808 | 5.. 9: ####################################################### 2005 | |
809 | 10.. 14: # 52 | |
810 | 15.. 19: # 50 | |
811 | 20.. 24: # 55 | |
812 | 25.. 29: # 56 | |
813 | 30.. 34: # 55 | |
814 | 35.. 39: # 49 | |
815 | 40.. 44: # 65 | |
816 | 45.. 49: # 65 | |
817 | 50.. 54: # 55 | |
818 | 55.. 59: # 68 | |
819 | 60.. 64: # 61 | |
820 | 65.. 69: # 65 | |
821 | 70.. 74: # 57 | |
822 | 75.. 79: # 66 | |
823 | 80.. 84: # 65 | |
824 | 85.. 89: # 64 | |
825 | 90.. 94: # 60 | |
826 | 95.. 99: # 62 | |
827 | ||
828 | +++ Stats for pair dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
829 | ||
830 | stats pair sum: | |
831 | num: 500000, avg: 100.02, stddev: 41.22, median 100, min 0, max 200 | |
832 | 0.. 9: ### 2685 | |
833 | 10.. 19: ######## 7622 | |
834 | 20.. 29: ############## 12474 | |
835 | 30.. 39: #################### 17330 | |
836 | 40.. 49: ########################## 22263 | |
837 | 50.. 59: ############################### 26982 | |
838 | 60.. 69: ##################################### 32182 | |
839 | 70.. 79: ########################################### 37125 | |
840 | 80.. 89: ################################################# 42287 | |
841 | 90.. 99: ###################################################### 46691 | |
842 | 100..109: ####################################################### 46977 | |
843 | 110..119: ################################################# 42444 | |
844 | 120..129: ############################################ 37719 | |
845 | 130..139: ###################################### 32595 | |
846 | 140..149: ################################ 27588 | |
847 | 150..159: ########################## 22792 | |
848 | 160..169: #################### 17805 | |
849 | 170..179: ############### 13068 | |
850 | 180..189: ######### 8218 | |
851 | 190..199: ### 3115 | |
852 | 200..209: 38 | |
853 | ||
854 | +++ Stats for triple dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
855 | ||
856 | stats triple sum: | |
857 | num: 500000, avg: 150.08, stddev: 50.51, median 150, min 0, max 299 | |
858 | 0.. 14: 345 | |
859 | 15.. 29: ## 2121 | |
860 | 30.. 44: ##### 5372 | |
861 | 45.. 59: ########## 10501 | |
862 | 60.. 74: ################# 17031 | |
863 | 75.. 89: ######################### 25417 | |
864 | 90..104: ################################### 35148 | |
865 | 105..119: ############################################# 45134 | |
866 | 120..134: ################################################### 51751 | |
867 | 135..149: ####################################################### 55090 | |
868 | 150..164: ###################################################### 55074 | |
869 | 165..179: #################################################### 52238 | |
870 | 180..194: ############################################# 45651 | |
871 | 195..209: ################################### 35994 | |
872 | 210..224: ######################### 26039 | |
873 | 225..239: ################# 17749 | |
874 | 240..254: ########## 10870 | |
875 | 255..269: ##### 5765 | |
876 | 270..284: ## 2313 | |
877 | 285..299: 397 | |
878 | ||
879 | +++ Stats for quad dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
880 | ||
881 | stats quad sum: | |
882 | num: 500000, avg: 200.13, stddev: 58.33, median 200, min 5, max 394 | |
883 | 5.. 24: 102 | |
884 | 25.. 44: 842 | |
885 | 45.. 64: ## 3023 | |
886 | 65.. 84: ###### 7154 | |
887 | 85..104: ############ 14368 | |
888 | 105..124: ##################### 25397 | |
889 | 125..144: ############################### 37547 | |
890 | 145..164: ########################################## 50174 | |
891 | 165..184: ################################################## 60558 | |
892 | 185..204: ####################################################### 65376 | |
893 | 205..224: ##################################################### 63687 | |
894 | 225..244: ############################################### 56248 | |
895 | 245..264: ###################################### 45384 | |
896 | 265..284: ########################## 31780 | |
897 | 285..304: ################ 20158 | |
898 | 305..324: ######### 10899 | |
899 | 325..344: #### 5045 | |
900 | 345..364: # 1848 | |
901 | 365..384: 386 | |
902 | 385..404: 24 | |
903 | ||
904 | +++ Stats for bind dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
905 | ||
906 | stats ordered pair difference: | |
907 | num: 1000000, avg: 25.02, stddev: 22.36, median 19, min 0, max 100 | |
908 | 0.. 4: ####################################################### 193184 | |
909 | 5.. 9: ##################################### 130024 | |
910 | 10.. 14: ############################# 103828 | |
911 | 15.. 19: ######################## 87496 | |
912 | 20.. 24: ##################### 74431 | |
913 | 25.. 29: ################## 64629 | |
914 | 30.. 34: ################ 56663 | |
915 | 35.. 39: ############# 48986 | |
916 | 40.. 44: ############ 43424 | |
917 | 45.. 49: ########## 37599 | |
918 | 50.. 54: ######### 32787 | |
919 | 55.. 59: ######## 28332 | |
920 | 60.. 64: ###### 24023 | |
921 | 65.. 69: ##### 20312 | |
922 | 70.. 74: #### 16649 | |
923 | 75.. 79: ### 13338 | |
924 | 80.. 84: ## 10239 | |
925 | 85.. 89: ## 7391 | |
926 | 90.. 94: # 4548 | |
927 | 95.. 99: 2015 | |
928 | 100..104: 102 | |
929 | ||
930 | stats ordered pair sum: | |
931 | num: 1000000, avg: 75.12, stddev: 46.93, median 72, min 0, max 200 | |
932 | 0.. 9: ####################################################### 70423 | |
933 | 10.. 19: ##################################################### 68068 | |
934 | 20.. 29: ##################################################### 68449 | |
935 | 30.. 39: ##################################################### 68577 | |
936 | 40.. 49: ##################################################### 68763 | |
937 | 50.. 59: ##################################################### 68351 | |
938 | 60.. 69: ##################################################### 68744 | |
939 | 70.. 79: ##################################################### 68451 | |
940 | 80.. 89: ##################################################### 68309 | |
941 | 90.. 99: ##################################################### 68835 | |
942 | 100..109: ################################################## 64544 | |
943 | 110..119: ########################################### 55512 | |
944 | 120..129: ##################################### 47595 | |
945 | 130..139: ############################### 39809 | |
946 | 140..149: ######################### 32677 | |
947 | 150..159: #################### 26312 | |
948 | 160..169: ############### 20180 | |
949 | 170..179: ########### 14265 | |
950 | 180..189: ###### 8625 | |
951 | 190..199: ## 3433 | |
952 | 200..209: 78 | |
953 | ||
954 | +++ Stats for list len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
955 | ||
956 | stats len: | |
957 | num: 5000, avg: 400.16, stddev: 1371.90, median 9, min 0, max 9987 | |
958 | 0.. 499: ####################################################### 4246 | |
959 | 500.. 999: ###### 502 | |
960 | 1000.. 1499: 13 | |
961 | 1500.. 1999: 10 | |
962 | 2000.. 2499: 14 | |
963 | 2500.. 2999: 14 | |
964 | 3000.. 3499: 20 | |
965 | 3500.. 3999: 7 | |
966 | 4000.. 4499: 13 | |
967 | 4500.. 4999: 16 | |
968 | 5000.. 5499: 12 | |
969 | 5500.. 5999: 15 | |
970 | 6000.. 6499: 15 | |
971 | 6500.. 6999: 13 | |
972 | 7000.. 7499: 16 | |
973 | 7500.. 7999: 12 | |
974 | 8000.. 8499: 11 | |
975 | 8500.. 8999: 16 | |
976 | 9000.. 9499: 15 | |
977 | 9500.. 9999: 20 | |
978 | ||
979 | +++ Stats for small_list len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
980 | ||
981 | stats len: | |
982 | num: 5000, avg: 16.14, stddev: 24.86, median 6, min 0, max 99 | |
983 | 0.. 4: ###################################################### 1923 | |
984 | 5.. 9: ####################################################### 1936 | |
985 | 10.. 14: # 61 | |
986 | 15.. 19: # 59 | |
987 | 20.. 24: # 62 | |
988 | 25.. 29: # 70 | |
989 | 30.. 34: # 61 | |
990 | 35.. 39: # 64 | |
991 | 40.. 44: # 64 | |
992 | 45.. 49: # 56 | |
993 | 50.. 54: # 65 | |
994 | 55.. 59: # 55 | |
995 | 60.. 64: # 60 | |
996 | 65.. 69: # 62 | |
997 | 70.. 74: # 57 | |
998 | 75.. 79: # 69 | |
999 | 80.. 84: ## 73 | |
1000 | 85.. 89: # 67 | |
1001 | 90.. 94: # 62 | |
1002 | 95.. 99: ## 74 | |
1003 | ||
1004 | +++ Stats for list_size len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
1005 | ||
1006 | stats len: | |
1007 | num: 5000, avg: 7.49, stddev: 1.71, median 8, min 5, max 10 | |
1008 | 5: ####################################################### 867 | |
1009 | 6: ################################################### 813 | |
1010 | 7: ################################################### 815 | |
1011 | 8: #################################################### 833 | |
1012 | 9: ###################################################### 857 | |
1013 | 10: ################################################### 815 | |
1014 | ||
1015 | +++ Stats for list_repeat len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
1016 | ||
1017 | stats len: | |
1018 | num: 5000, avg: 42.00, stddev: 0.00, median 42, min 42, max 42 | |
1019 | 42: ####################################################### 5000 | |
1020 | ||
1021 | +++ Stats for array len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
1022 | ||
1023 | stats len: | |
1024 | num: 5000, avg: 400.16, stddev: 1371.90, median 9, min 0, max 9987 | |
1025 | 0.. 499: ####################################################### 4246 | |
1026 | 500.. 999: ###### 502 | |
1027 | 1000.. 1499: 13 | |
1028 | 1500.. 1999: 10 | |
1029 | 2000.. 2499: 14 | |
1030 | 2500.. 2999: 14 | |
1031 | 3000.. 3499: 20 | |
1032 | 3500.. 3999: 7 | |
1033 | 4000.. 4499: 13 | |
1034 | 4500.. 4999: 16 | |
1035 | 5000.. 5499: 12 | |
1036 | 5500.. 5999: 15 | |
1037 | 6000.. 6499: 15 | |
1038 | 6500.. 6999: 13 | |
1039 | 7000.. 7499: 16 | |
1040 | 7500.. 7999: 12 | |
1041 | 8000.. 8499: 11 | |
1042 | 8500.. 8999: 16 | |
1043 | 9000.. 9499: 15 | |
1044 | 9500.. 9999: 20 | |
1045 | ||
1046 | +++ Stats for small_array len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
1047 | ||
1048 | stats len: | |
1049 | num: 5000, avg: 16.14, stddev: 24.86, median 6, min 0, max 99 | |
1050 | 0.. 4: ###################################################### 1923 | |
1051 | 5.. 9: ####################################################### 1936 | |
1052 | 10.. 14: # 61 | |
1053 | 15.. 19: # 59 | |
1054 | 20.. 24: # 62 | |
1055 | 25.. 29: # 70 | |
1056 | 30.. 34: # 61 | |
1057 | 35.. 39: # 64 | |
1058 | 40.. 44: # 64 | |
1059 | 45.. 49: # 56 | |
1060 | 50.. 54: # 65 | |
1061 | 55.. 59: # 55 | |
1062 | 60.. 64: # 60 | |
1063 | 65.. 69: # 62 | |
1064 | 70.. 74: # 57 | |
1065 | 75.. 79: # 69 | |
1066 | 80.. 84: ## 73 | |
1067 | 85.. 89: # 67 | |
1068 | 90.. 94: # 62 | |
1069 | 95.. 99: ## 74 | |
1070 | ||
1071 | +++ Stats for array_size len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
1072 | ||
1073 | stats len: | |
1074 | num: 5000, avg: 7.49, stddev: 1.71, median 8, min 5, max 10 | |
1075 | 5: ####################################################### 867 | |
1076 | 6: ################################################### 813 | |
1077 | 7: ################################################### 815 | |
1078 | 8: #################################################### 833 | |
1079 | 9: ###################################################### 857 | |
1080 | 10: ################################################### 815 | |
1081 | ||
1082 | +++ Stats for array_repeat len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
1083 | ||
1084 | stats len: | |
1085 | num: 5000, avg: 42.00, stddev: 0.00, median 42, min 42, max 42 | |
1086 | 42: ####################################################### 5000 | |
1087 | ||
1088 | +++ Stats for int_stats_neg ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
1089 | ||
1090 | stats dist: | |
1091 | num: 5000, avg: 0.17, stddev: 29.68, median 0, min -99, max 99 | |
1092 | -99..-90: # 65 | |
1093 | -89..-80: # 63 | |
1094 | -79..-70: # 64 | |
1095 | -69..-60: # 58 | |
1096 | -59..-50: # 67 | |
1097 | -49..-40: # 72 | |
1098 | -39..-30: # 61 | |
1099 | -29..-20: # 61 | |
1100 | -19..-10: # 67 | |
1101 | -9.. 0: ####################################################### 2076 | |
1102 | 1.. 10: ############################################## 1764 | |
1103 | 11.. 20: # 66 | |
1104 | 21.. 30: # 64 | |
1105 | 31.. 40: # 64 | |
1106 | 41.. 50: # 67 | |
1107 | 51.. 60: # 60 | |
1108 | 61.. 70: # 75 | |
1109 | 71.. 80: # 60 | |
1110 | 81.. 90: # 60 | |
1111 | 91..100: # 66 | |
1112 | ||
1113 | +++ Stats for small_signed_int dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
1114 | ||
1115 | stats dist: | |
1116 | num: 1000, avg: 0.90, stddev: 28.23, median 0, min -99, max 99 | |
1117 | -99..-90: # 12 | |
1118 | -89..-80: # 11 | |
1119 | -79..-70: # 9 | |
1120 | -69..-60: 6 | |
1121 | -59..-50: # 11 | |
1122 | -49..-40: # 13 | |
1123 | -39..-30: # 9 | |
1124 | -29..-20: # 13 | |
1125 | -19..-10: 8 | |
1126 | -9.. 0: ####################################################### 453 | |
1127 | 1.. 10: ######################################### 340 | |
1128 | 11.. 20: # 15 | |
1129 | 21.. 30: # 11 | |
1130 | 31.. 40: # 12 | |
1131 | 41.. 50: # 13 | |
1132 | 51.. 60: # 13 | |
1133 | 61.. 70: # 16 | |
1134 | 71.. 80: # 9 | |
1135 | 81.. 90: # 16 | |
1136 | 91..100: # 10 | |
1137 | ||
1138 | +++ Stats for small_nat dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
1139 | ||
1140 | stats dist: | |
1141 | num: 1000, avg: 15.11, stddev: 23.27, median 6, min 0, max 99 | |
1142 | 0.. 4: #################################################### 377 | |
1143 | 5.. 9: ####################################################### 392 | |
1144 | 10.. 14: ## 20 | |
1145 | 15.. 19: ## 15 | |
1146 | 20.. 24: # 11 | |
1147 | 25.. 29: ## 17 | |
1148 | 30.. 34: ## 19 | |
1149 | 35.. 39: ## 17 | |
1150 | 40.. 44: # 10 | |
1151 | 45.. 49: # 9 | |
1152 | 50.. 54: # 8 | |
1153 | 55.. 59: # 9 | |
1154 | 60.. 64: ## 15 | |
1155 | 65.. 69: # 10 | |
1156 | 70.. 74: # 13 | |
1157 | 75.. 79: ## 19 | |
1158 | 80.. 84: # 11 | |
1159 | 85.. 89: # 13 | |
1160 | 90.. 94: 5 | |
1161 | 95.. 99: # 10 | |
1162 | ||
1163 | +++ Stats for nat dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
1164 | ||
1165 | stats dist: | |
1166 | num: 1000, avg: 363.02, stddev: 1215.04, median 9, min 0, max 9476 | |
1167 | 0.. 473: ####################################################### 847 | |
1168 | 474.. 947: ###### 95 | |
1169 | 948..1421: 14 | |
1170 | 1422..1895: 3 | |
1171 | 1896..2369: 0 | |
1172 | 2370..2843: 3 | |
1173 | 2844..3317: 2 | |
1174 | 3318..3791: 3 | |
1175 | 3792..4265: 2 | |
1176 | 4266..4739: 4 | |
1177 | 4740..5213: 3 | |
1178 | 5214..5687: 4 | |
1179 | 5688..6161: 3 | |
1180 | 6162..6635: 4 | |
1181 | 6636..7109: 1 | |
1182 | 7110..7583: 4 | |
1183 | 7584..8057: 2 | |
1184 | 8058..8531: 1 | |
1185 | 8532..9005: 1 | |
1186 | 9006..9479: 4 | |
1187 | ||
1188 | +++ Stats for int_range (-43643) 435434 dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
1189 | ||
1190 | stats dist: | |
1191 | num: 1000, avg: 195335.64, stddev: 136803.99, median 195583, min -43624, max 435210 | |
1192 | -43624..-19683: ############################################ 52 | |
1193 | -19682.. 4259: ######################################## 47 | |
1194 | 4260.. 28201: ############################## 36 | |
1195 | 28202.. 52143: ############################################ 52 | |
1196 | 52144.. 76085: ########################################## 50 | |
1197 | 76086..100027: ####################################################### 64 | |
1198 | 100028..123969: ############################################### 55 | |
1199 | 123970..147911: ######################################## 47 | |
1200 | 147912..171853: ############################################## 54 | |
1201 | 171854..195795: #################################### 43 | |
1202 | 195796..219737: ############################################## 54 | |
1203 | 219738..243679: ########################################### 51 | |
1204 | 243680..267621: ################################################ 57 | |
1205 | 267622..291563: ########################################## 49 | |
1206 | 291564..315505: #################################### 42 | |
1207 | 315506..339447: ###################################### 45 | |
1208 | 339448..363389: ################################################ 57 | |
1209 | 363390..387331: ###################################### 45 | |
1210 | 387332..411273: ########################################## 49 | |
1211 | 411274..435215: ########################################### 51 | |
1212 | ||
1213 | +++ Stats for int_range (-40000) 40000 dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
1214 | ||
1215 | stats dist: | |
1216 | num: 1000, avg: -173.78, stddev: 23042.92, median 180, min -39859, max 39942 | |
1217 | -39859..-35869: ############################################# 56 | |
1218 | -35868..-31878: ################################### 43 | |
1219 | -31877..-27887: ################################################# 60 | |
1220 | -27886..-23896: ##################################### 46 | |
1221 | -23895..-19905: ######################################## 49 | |
1222 | -19904..-15914: #################################### 45 | |
1223 | -15913..-11923: ############################################ 54 | |
1224 | -11922.. -7932: ############################################### 58 | |
1225 | -7931.. -3941: ######################################### 51 | |
1226 | -3940.. 50: ############################ 35 | |
1227 | 51.. 4041: ####################################### 48 | |
1228 | 4042.. 8032: ########################################## 52 | |
1229 | 8033.. 12023: ######################################### 51 | |
1230 | 12024.. 16014: ########################################### 53 | |
1231 | 16015.. 20005: ############################################ 54 | |
1232 | 20006.. 23996: ################################## 42 | |
1233 | 23997.. 27987: ####################################################### 67 | |
1234 | 27988.. 31978: ################################ 40 | |
1235 | 31979.. 35969: ######################################### 51 | |
1236 | 35970.. 39960: #################################### 45 | |
1237 | ||
1238 | +++ Stats for int_range (-4) 4 dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
1239 | ||
1240 | stats dist: | |
1241 | num: 1000, avg: 0.02, stddev: 2.55, median 0, min -4, max 4 | |
1242 | -4: ############################################ 99 | |
1243 | -3: ##################################################### 118 | |
1244 | -2: ################################################## 111 | |
1245 | -1: ################################################## 113 | |
1246 | 0: ################################################## 113 | |
1247 | 1: ##################################################### 118 | |
1248 | 2: ############################################# 102 | |
1249 | 3: ####################################################### 122 | |
1250 | 4: ############################################## 104 | |
1251 | ||
1252 | +++ Stats for int_range (-4) 17 dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
1253 | ||
1254 | stats dist: | |
1255 | num: 1000, avg: 6.67, stddev: 6.39, median 7, min -4, max 17 | |
1256 | -4..-3: ############################################# 90 | |
1257 | -2..-1: ############################################# 91 | |
1258 | 0.. 1: ########################################## 84 | |
1259 | 2.. 3: ############################################## 92 | |
1260 | 4.. 5: ########################################### 87 | |
1261 | 6.. 7: ########################################### 86 | |
1262 | 8.. 9: ############################################ 89 | |
1263 | 10..11: ########################################### 87 | |
1264 | 12..13: ####################################################### 110 | |
1265 | 14..15: ############################################# 91 | |
1266 | 16..17: ############################################## 93 | |
1267 | 18..19: 0 | |
1268 | 20..21: 0 | |
1269 | 22..23: 0 | |
1270 | 24..25: 0 | |
1271 | 26..27: 0 | |
1272 | 28..29: 0 | |
1273 | 30..31: 0 | |
1274 | 32..33: 0 | |
1275 | 34..35: 0 | |
1276 | ||
1277 | +++ Stats for int dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
1278 | ||
1279 | stats dist: | |
1280 | num: 100000, avg: 2541076923587387.50, stddev: 2660730801206827008.00, median 158655268318060, min -4611522359435274428, max 4611540922436307689 | |
1281 | -4611522359435274428..-4150369195341695293: ##################################################### 4976 | |
1282 | -4150369195341695292..-3689216031248116157: ##################################################### 4963 | |
1283 | -3689216031248116156..-3228062867154537021: ###################################################### 5038 | |
1284 | -3228062867154537020..-2766909703060957885: ##################################################### 4979 | |
1285 | -2766909703060957884..-2305756538967378749: ##################################################### 5001 | |
1286 | -2305756538967378748..-1844603374873799613: ##################################################### 4982 | |
1287 | -1844603374873799612..-1383450210780220477: ##################################################### 5025 | |
1288 | -1383450210780220476.. -922297046686641341: #################################################### 4901 | |
1289 | -922297046686641340.. -461143882593062205: ####################################################### 5126 | |
1290 | -461143882593062204.. 9281500516931: ##################################################### 5008 | |
1291 | 9281500516932.. 461162445594096067: ###################################################### 5041 | |
1292 | 461162445594096068.. 922315609687675203: ##################################################### 5001 | |
1293 | 922315609687675204.. 1383468773781254339: ##################################################### 4986 | |
1294 | 1383468773781254340.. 1844621937874833475: ##################################################### 4949 | |
1295 | 1844621937874833476.. 2305775101968412611: ##################################################### 5025 | |
1296 | 2305775101968412612.. 2766928266061991747: ##################################################### 5022 | |
1297 | 2766928266061991748.. 3228081430155570883: ##################################################### 4958 | |
1298 | 3228081430155570884.. 3689234594249150019: ##################################################### 4998 | |
1299 | 3689234594249150020.. 4150387758342729155: ##################################################### 4982 | |
1300 | 4150387758342729156.. 4611540922436308291: ###################################################### 5039 | |
1301 | ||
1302 | +++ Stats for oneof int dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
1303 | ||
1304 | stats dist: | |
1305 | num: 1000, avg: 4611686018427388.00, stddev: 2905870896563567616.00, median 0, min -4611686018427387904, max 4611686018427387903 | |
1306 | -4611686018427387904..-4150517416584649089: ################## 208 | |
1307 | -4150517416584649088..-3689348814741910273: 0 | |
1308 | -3689348814741910272..-3228180212899171457: 0 | |
1309 | -3228180212899171456..-2767011611056432641: 0 | |
1310 | -2767011611056432640..-2305843009213693825: 0 | |
1311 | -2305843009213693824..-1844674407370955009: 0 | |
1312 | -1844674407370955008..-1383505805528216193: 0 | |
1313 | -1383505805528216192.. -922337203685477377: 0 | |
1314 | -922337203685477376.. -461168601842738561: 0 | |
1315 | -461168601842738560.. 255: ####################################################### 603 | |
1316 | 256.. 461168601842739071: 0 | |
1317 | 461168601842739072.. 922337203685477887: 0 | |
1318 | 922337203685477888.. 1383505805528216703: 0 | |
1319 | 1383505805528216704.. 1844674407370955519: 0 | |
1320 | 1844674407370955520.. 2305843009213694335: 0 | |
1321 | 2305843009213694336.. 2767011611056433151: 0 | |
1322 | 2767011611056433152.. 3228180212899171967: 0 | |
1323 | 3228180212899171968.. 3689348814741910783: 0 | |
1324 | 3689348814741910784.. 4150517416584649599: 0 | |
1325 | 4150517416584649600.. 4611686018427387903: ################# 189 | |
1326 | ================================================================================ | |
1327 | 1 warning(s) | |
1328 | failure (60 tests failed, 3 tests errored, ran 131 tests) | |
1329 | random seed: 153870556 | |
1330 | ||
1331 | +++ Stats for int_dist_empty_bucket ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
1332 | ||
1333 | stats dist: | |
1334 | num: 1000, avg: -55083208105414400.00, stddev: 1847115855773139200.00, median 9, min -4590718933436425025, max 4611686018427387903 | |
1335 | -4590718933436425025..-4130598685843234370: ## 26 | |
1336 | -4130598685843234369..-3670478438250043714: # 13 | |
1337 | -3670478438250043713..-3210358190656853058: ### 37 | |
1338 | -3210358190656853057..-2750237943063662402: ### 30 | |
1339 | -2750237943063662401..-2290117695470471746: ## 27 | |
1340 | -2290117695470471745..-1829997447877281090: ## 24 | |
1341 | -1829997447877281089..-1369877200284090434: ## 27 | |
1342 | -1369877200284090433.. -909756952690899778: ## 27 | |
1343 | -909756952690899777.. -449636705097709122: ## 21 | |
1344 | -449636705097709121.. 10483542495481534: ####################################################### 531 | |
1345 | 10483542495481535.. 470603790088672190: ## 21 | |
1346 | 470603790088672191.. 930724037681862846: ## 27 | |
1347 | 930724037681862847.. 1390844285275053502: ## 24 | |
1348 | 1390844285275053503.. 1850964532868244158: ## 25 | |
1349 | 1850964532868244159.. 2311084780461434814: ## 28 | |
1350 | 2311084780461434815.. 2771205028054625470: ## 23 | |
1351 | 2771205028054625471.. 3231325275647816126: ## 23 | |
1352 | 3231325275647816127.. 3691445523241006782: ## 25 | |
1353 | 3691445523241006783.. 4151565770834197438: # 17 | |
1354 | 4151565770834197439.. 4611686018427387903: ## 24 | |
1355 | ================================================================================ | |
1356 | success (ran 1 tests) |
0 | (** QCheck2 tests **) | |
1 | ||
2 | (** Module representing a integer tree data structure, used in tests *) | |
3 | module IntTree = struct | |
4 | type tree = Leaf of int | Node of tree * tree | |
5 | ||
6 | let leaf x = Leaf x | |
7 | let node x y = Node (x,y) | |
8 | ||
9 | let rec depth = function | |
10 | | Leaf _ -> 1 | |
11 | | Node (x, y) -> 1 + max (depth x) (depth y) | |
12 | ||
13 | let rec print_tree = function | |
14 | | Leaf x -> Printf.sprintf "Leaf %d" x | |
15 | | Node (x, y) -> Printf.sprintf "Node (%s, %s)" (print_tree x) (print_tree y) | |
16 | ||
17 | let gen_tree = QCheck2.Gen.(sized @@ fix | |
18 | (fun self n -> match n with | |
19 | | 0 -> map leaf nat | |
20 | | n -> | |
21 | frequency | |
22 | [1, map leaf nat; | |
23 | 2, map2 node (self (n/2)) (self (n/2))] | |
24 | )) | |
25 | ||
26 | let rec rev_tree = function | |
27 | | Node (x, y) -> Node (rev_tree y, rev_tree x) | |
28 | | Leaf x -> Leaf x | |
29 | ||
30 | let rec contains_only_n tree n = match tree with | |
31 | | Leaf n' -> n = n' | |
32 | | Node (x, y) -> contains_only_n x n && contains_only_n y n | |
33 | end | |
34 | ||
35 | (* tests of overall functionality *) | |
36 | module Overall = struct | |
37 | open QCheck2 | |
38 | ||
39 | let passing = | |
40 | Test.make ~name:"list_rev_is_involutive" ~count:100 ~long_factor:100 | |
41 | ~print:Print.(list int) | |
42 | Gen.(list small_int) (fun l -> List.rev (List.rev l) = l) | |
43 | ||
44 | let failing = | |
45 | Test.make ~name:"should_fail_sort_id" ~count:10 ~print:Print.(list int) | |
46 | Gen.(small_list small_int) (fun l -> l = List.sort compare l) | |
47 | ||
48 | exception Error | |
49 | ||
50 | let error = | |
51 | Test.make ~name:"should_error_raise_exn" ~count:10 ~print:Print.int | |
52 | Gen.int (fun _ -> raise Error) | |
53 | ||
54 | let collect = | |
55 | Test.make ~name:"collect_results" ~count:100 ~long_factor:100 | |
56 | ~print:Print.int ~collect:string_of_int | |
57 | (Gen.int_bound 4) (fun _ -> true) | |
58 | ||
59 | let stats = | |
60 | Test.make ~name:"with_stats" ~count:100 ~long_factor:100 ~print:Print.int | |
61 | ~stats:[ | |
62 | "mod4", (fun i->i mod 4); | |
63 | "num", (fun i->i); | |
64 | ] | |
65 | (Gen.int_bound 120) (fun _ -> true) | |
66 | ||
67 | let bad_assume_warn = | |
68 | Test.make ~name:"WARN_unlikely_precond" ~count:2_000 ~print:Print.int | |
69 | Gen.int | |
70 | (fun x -> | |
71 | QCheck.assume (x mod 100 = 1); | |
72 | true) | |
73 | ||
74 | let bad_assume_fail = | |
75 | Test.make ~name:"FAIL_unlikely_precond" ~count:2_000 | |
76 | ~if_assumptions_fail:(`Fatal, 0.1) ~print:Print.int | |
77 | Gen.int | |
78 | (fun x -> | |
79 | QCheck.assume (x mod 100 = 1); | |
80 | true) | |
81 | end | |
82 | ||
83 | (* positive tests of the various generators *) | |
84 | module Generator = struct | |
85 | open QCheck2 | |
86 | ||
87 | (* example from issue #23 *) | |
88 | let char_dist_issue_23 = | |
89 | Test.make ~name:"char never produces '\\255'" ~count:1_000_000 | |
90 | ~print:Print.char | |
91 | Gen.char (fun c -> c <> '\255') | |
92 | ||
93 | let char_test = | |
94 | Test.make ~name:"char has right range'" ~count:1000 ~print:Print.char | |
95 | Gen.char (fun c -> '\000' <= c && c <= '\255') | |
96 | ||
97 | let nat_test = | |
98 | Test.make ~name:"nat has right range" ~count:1000 ~print:Print.int | |
99 | Gen.nat (fun n -> 0 <= n && n < 10000) | |
100 | ||
101 | let string_test = | |
102 | Test.make ~name:"string has right length and content" ~count:1000 ~print:Print.string | |
103 | Gen.string | |
104 | (fun s -> | |
105 | let len = String.length s in | |
106 | 0 <= len && len < 10000 | |
107 | && String.to_seq s |> | |
108 | Seq.fold_left (fun acc c -> acc && '\000' <= c && c <= '\255') true) | |
109 | ||
110 | let list_test = | |
111 | Test.make ~name:"list has right length" ~count:1000 | |
112 | ~print:Print.(list unit) | |
113 | Gen.(list unit) (fun l -> let len = List.length l in 0 <= len && len < 10_000) | |
114 | ||
115 | let list_repeat_test = | |
116 | Test.make ~name:"list_repeat has constant length" ~count:1000 | |
117 | ~print:Print.(pair int (list unit)) | |
118 | Gen.(small_nat >>= fun i -> list_repeat i unit >>= fun l -> return (i,l)) | |
119 | (fun (i,l) -> List.length l = i) | |
120 | ||
121 | let array_repeat_test = | |
122 | Test.make ~name:"array_repeat has constant length" ~count:1000 | |
123 | ~print:Print.(pair int (array unit)) | |
124 | Gen.(small_nat >>= fun i -> array_repeat i unit >>= fun l -> return (i,l)) | |
125 | (fun (i,l) -> Array.length l = i) | |
126 | ||
127 | let passing_tree_rev = | |
128 | Test.make ~count:1000 | |
129 | ~name:"tree_rev_is_involutive" | |
130 | IntTree.gen_tree | |
131 | (fun tree -> IntTree.(rev_tree (rev_tree tree)) = tree) | |
132 | end | |
133 | ||
134 | (* negative tests that exercise shrinking behaviour *) | |
135 | module Shrink = struct | |
136 | open QCheck2 | |
137 | ||
138 | let rec fac n = match n with | |
139 | | 0 -> 1 | |
140 | | n -> n * fac (n - 1) | |
141 | ||
142 | (* example from issue #59 *) | |
143 | let test_fac_issue59 = | |
144 | Test.make ~name:"test fac issue59" | |
145 | (Gen.make_primitive ~gen:(fun st -> Gen.generate1 ~rand:st (Gen.small_int_corners ())) ~shrink:(fun _ -> Seq.empty)) | |
146 | (fun n -> try (fac n) mod n = 0 | |
147 | with | |
148 | (*| Stack_overflow -> false*) | |
149 | | Division_by_zero -> (n=0)) | |
150 | ||
151 | let big_bound_issue59 = | |
152 | Test.make ~name:"big bound issue59" ~print:Print.int | |
153 | (Gen.small_int_corners()) (fun i -> i < 209609) | |
154 | ||
155 | let long_shrink = | |
156 | let listgen = Gen.(list_size (int_range 1000 10000) int) in | |
157 | Test.make ~name:"long_shrink" ~print:Print.(pair (list int) (list int)) | |
158 | (Gen.pair listgen listgen) | |
159 | (fun (xs,ys) -> List.rev (xs@ys) = (List.rev xs)@(List.rev ys)) | |
160 | ||
161 | let ints_arent_0_mod_3 = | |
162 | Test.make ~name:"ints arent 0 mod 3" ~count:1000 ~print:Print.int | |
163 | Gen.int (fun i -> i mod 3 <> 0) | |
164 | ||
165 | let ints_are_0 = | |
166 | Test.make ~name:"ints are 0" ~count:1000 ~print:Print.int | |
167 | Gen.int (fun i -> Printf.printf "%i\n" i; i = 0) | |
168 | ||
169 | (* test from issue #59 *) | |
170 | let ints_smaller_209609 = | |
171 | Test.make ~name:"ints < 209609" ~print:Print.int | |
172 | (Gen.small_int_corners()) (fun i -> i < 209609) | |
173 | ||
174 | let nats_smaller_5001 = | |
175 | Test.make ~name:"nat < 5001" ~count:1000 ~print:Print.int | |
176 | Gen.nat (fun n -> n < 5001) | |
177 | ||
178 | let char_is_never_abcdef = | |
179 | Test.make ~name:"char is never produces 'abcdef'" ~count:1000 ~print:Print.char | |
180 | Gen.char (fun c -> not (List.mem c ['a';'b';'c';'d';'e';'f'])) | |
181 | ||
182 | let strings_are_empty = | |
183 | Test.make ~name:"strings are empty" ~count:1000 ~print:Print.string | |
184 | Gen.string (fun s -> s = "") | |
185 | ||
186 | let string_never_has_000_char = | |
187 | Test.make ~name:"string never has a \\000 char" ~count:1000 ~print:Print.string | |
188 | Gen.string | |
189 | (fun s -> String.to_seq s |> Seq.fold_left (fun acc c -> acc && c <> '\000') true) | |
190 | ||
191 | let string_never_has_255_char = | |
192 | Test.make ~name:"string never has a \\255 char" ~count:1000 ~print:Print.string | |
193 | Gen.string | |
194 | (fun s -> String.to_seq s |> Seq.fold_left (fun acc c -> acc && c <> '\255') true) | |
195 | ||
196 | (* tests from issue #64 *) | |
197 | let print_list xs = print_endline Print.(list int xs) | |
198 | ||
199 | let lists_are_empty_issue_64 = | |
200 | Test.make ~name:"lists are empty" ~print:Print.(list int) | |
201 | Gen.(list small_int) (fun xs -> print_list xs; xs = []) | |
202 | ||
203 | let list_shorter_10 = | |
204 | Test.make ~name:"lists shorter than 10" ~print:Print.(list int) | |
205 | Gen.(list small_int) (fun xs -> List.length xs < 10) | |
206 | ||
207 | let length_printer xs = | |
208 | Printf.sprintf "[...] list length: %i" (List.length xs) | |
209 | ||
210 | let size_gen = Gen.(oneof [small_nat; int_bound 750_000]) | |
211 | ||
212 | let list_shorter_432 = | |
213 | Test.make ~name:"lists shorter than 432" ~print:length_printer | |
214 | Gen.(list_size size_gen small_int) | |
215 | (fun xs -> List.length xs < 432) | |
216 | ||
217 | let list_shorter_4332 = | |
218 | Test.make ~name:"lists shorter than 4332" ~print:length_printer | |
219 | Gen.(list_size size_gen small_int) | |
220 | (fun xs -> List.length xs < 4332) | |
221 | ||
222 | let list_equal_dupl = | |
223 | Test.make ~name:"lists equal to duplication" ~print:Print.(list int) | |
224 | Gen.(list_size size_gen small_int) | |
225 | (fun xs -> try xs = xs @ xs | |
226 | with Stack_overflow -> false) | |
227 | ||
228 | let list_unique_elems = | |
229 | Test.make ~name:"lists have unique elems" ~print:Print.(list int) | |
230 | Gen.(list small_int) | |
231 | (fun xs -> let ys = List.sort_uniq Int.compare xs in | |
232 | print_list xs; List.length xs = List.length ys) | |
233 | ||
234 | let tree_contains_only_42 = | |
235 | Test.make ~name:"tree contains only 42" ~print:IntTree.print_tree | |
236 | IntTree.gen_tree | |
237 | (fun tree -> IntTree.contains_only_n tree 42) | |
238 | end | |
239 | ||
240 | (* tests function generator and shrinker *) | |
241 | module Function = struct | |
242 | open QCheck2 | |
243 | ||
244 | let fail_pred_map_commute = | |
245 | Test.make ~name:"fail_pred_map_commute" ~count:100 ~long_factor:100 | |
246 | ~print:Print.(triple (list int) Fn.print Fn.print) | |
247 | Gen.(triple | |
248 | (small_list small_int) | |
249 | (fun1 ~print:Print.int Observable.int int) | |
250 | (fun1 ~print:Print.bool Observable.int bool)) | |
251 | (fun (l,Fun (_,f),Fun (_,p)) -> | |
252 | List.filter p (List.map f l) = List.map f (List.filter p l)) | |
253 | ||
254 | let fail_pred_strings = | |
255 | Test.make ~name:"fail_pred_strings" ~count:100 ~print:Fn.print | |
256 | (fun1 Observable.string ~print:Print.bool Gen.bool) | |
257 | (fun (Fun (_,p)) -> not (p "some random string") || p "some other string") | |
258 | ||
259 | let int_gen = Gen.small_nat (* int *) | |
260 | ||
261 | (* Another example (false) property *) | |
262 | let prop_foldleft_foldright = | |
263 | Test.make ~name:"fold_left fold_right" ~count:1000 ~long_factor:20 | |
264 | ~print:Print.(triple int (list int) Fn.print) | |
265 | Gen.(triple | |
266 | int_gen | |
267 | (list int_gen) | |
268 | (fun2 ~print:Print.int Observable.int Observable.int int_gen)) | |
269 | (fun (z,xs,f) -> | |
270 | let l1 = List.fold_right (Fn.apply f) xs z in | |
271 | let l2 = List.fold_left (Fn.apply f) z xs in | |
272 | if l1=l2 then true | |
273 | else Test.fail_reportf "l=%s, fold_left=%s, fold_right=%s@." | |
274 | (Print.(list int) xs) | |
275 | (Print.int l1) | |
276 | (Print.int l2) | |
277 | ) | |
278 | ||
279 | (* Another example (false) property *) | |
280 | let prop_foldleft_foldright_uncurry = | |
281 | Test.make ~name:"fold_left fold_right uncurried" ~count:1000 ~long_factor:20 | |
282 | ~print:Print.(triple Fn.print int (list int)) | |
283 | Gen.(triple | |
284 | (fun1 ~print:Print.int Observable.(pair int int) int_gen) | |
285 | int_gen | |
286 | (list int_gen)) | |
287 | (fun (f,z,xs) -> | |
288 | List.fold_right (fun x y -> Fn.apply f (x,y)) xs z = | |
289 | List.fold_left (fun x y -> Fn.apply f (x,y)) z xs) | |
290 | ||
291 | (* Same as the above (false) property, but generating+shrinking functions last *) | |
292 | let prop_foldleft_foldright_uncurry_funlast = | |
293 | Test.make ~name:"fold_left fold_right uncurried fun last" ~count:1000 ~long_factor:20 | |
294 | ~print:Print.(triple int (list int) Fn.print) | |
295 | Gen.(triple | |
296 | int_gen | |
297 | (list int_gen) | |
298 | (fun1 ~print:Print.int Observable.(pair int int) int_gen)) | |
299 | (fun (z,xs,f) -> | |
300 | List.fold_right (fun x y -> Fn.apply f (x,y)) xs z = | |
301 | List.fold_left (fun x y -> Fn.apply f (x,y)) z xs) | |
302 | ||
303 | (* test from issue #64 *) | |
304 | let fold_left_test = | |
305 | Test.make ~name:"fold_left test, fun first" ~print:Print.(quad Fn.print string (list int) (list int)) | |
306 | Gen.(quad (* string -> int -> string *) | |
307 | (fun2 ~print:Print.string Observable.string Observable.int (small_string ~gen:char)) | |
308 | (small_string ~gen:char) | |
309 | (list small_int) | |
310 | (list small_int)) | |
311 | (fun (f,acc,is,js) -> | |
312 | let f = Fn.apply f in | |
313 | List.fold_left f acc (is @ js) | |
314 | = List.fold_left f (List.fold_left f acc is) is) (*Typo*) | |
315 | end | |
316 | ||
317 | (* tests of (inner) find_example(_gen) behaviour *) | |
318 | module FindExample = struct | |
319 | open QCheck2 | |
320 | ||
321 | let find_ex = | |
322 | Test.make ~name:"find_example" ~print:Print.int | |
323 | Gen.(2--50) | |
324 | (fun n -> | |
325 | let st = Random.State.make [| 0 |] in | |
326 | let f m = n < m && m < 2 * n in | |
327 | try | |
328 | let m = find_example_gen ~rand:st ~count:100_000 ~f Gen.(0 -- 1000) in | |
329 | f m | |
330 | with No_example_found _ -> false) | |
331 | ||
332 | let find_ex_uncaught_issue_99_1_fail = | |
333 | let rs = (find_example ~count:10 ~f:(fun _ -> false) Gen.int) in | |
334 | Test.make ~name:"FAIL_#99_1" rs (fun _ -> true) | |
335 | ||
336 | let find_ex_uncaught_issue_99_2_succeed = | |
337 | Test.make ~name:"should_succeed_#99_2" ~count:10 | |
338 | Gen.int (fun i -> i <= max_int) | |
339 | end | |
340 | ||
341 | (* tests of statistics and histogram display *) | |
342 | module Stats = struct | |
343 | open QCheck2 | |
344 | ||
345 | let bool_dist = | |
346 | Test.make ~name:"bool dist" ~count:500_000 ~collect:Bool.to_string Gen.bool (fun _ -> true) | |
347 | ||
348 | let char_dist = | |
349 | Test.make ~name:"char code dist" ~count:500_000 ~stats:[("char code", Char.code)] Gen.char (fun _ -> true) | |
350 | ||
351 | let string_len_tests = | |
352 | let len = ("len",String.length) in | |
353 | [ | |
354 | Test.make ~name:"string_size len dist" ~count:5_000 ~stats:[len] Gen.(string_size (int_range 5 10)) (fun _ -> true); | |
355 | Test.make ~name:"string len dist" ~count:5_000 ~stats:[len] Gen.string (fun _ -> true); | |
356 | Test.make ~name:"string_of len dist" ~count:5_000 ~stats:[len] Gen.(string_of (return 'a')) (fun _ -> true); | |
357 | Test.make ~name:"string_printable len dist" ~count:5_000 ~stats:[len] Gen.string_printable (fun _ -> true); | |
358 | Test.make ~name:"small_string len dist" ~count:5_000 ~stats:[len] Gen.(small_string ~gen:char)(*ugh*)(fun _ -> true); | |
359 | ] | |
360 | ||
361 | let list_len_tests = | |
362 | let len = ("len",List.length) in | |
363 | [ (* test from issue #30 *) | |
364 | Test.make ~name:"list len dist" ~count:5_000 ~stats:[len] Gen.(list int) (fun _ -> true); | |
365 | Test.make ~name:"small_list len dist" ~count:5_000 ~stats:[len] Gen.(small_list int) (fun _ -> true); | |
366 | Test.make ~name:"list_size len dist" ~count:5_000 ~stats:[len] Gen.(list_size (int_range 5 10) int) (fun _ -> true); | |
367 | Test.make ~name:"list_repeat len dist" ~count:5_000 ~stats:[len] Gen.(list_repeat 42 int) (fun _ -> true); | |
368 | ] | |
369 | ||
370 | let array_len_tests = | |
371 | let len = ("len",Array.length) in | |
372 | [ | |
373 | Test.make ~name:"array len dist" ~count:5_000 ~stats:[len] Gen.(array int) (fun _ -> true); | |
374 | Test.make ~name:"small_array len dist" ~count:5_000 ~stats:[len] Gen.(small_array int) (fun _ -> true); | |
375 | Test.make ~name:"array_size len dist" ~count:5_000 ~stats:[len] Gen.(array_size (int_range 5 10) int) (fun _ -> true); | |
376 | Test.make ~name:"array_repeat len dist" ~count:5_000 ~stats:[len] Gen.(array_repeat 42 int) (fun _ -> true); | |
377 | ] | |
378 | ||
379 | let int_dist_tests = | |
380 | let dist = ("dist",fun x -> x) in | |
381 | [ | |
382 | (* test from issue #40 *) | |
383 | Test.make ~name:"int_stats_neg" ~count:5000 ~stats:[dist] Gen.small_signed_int (fun _ -> true); | |
384 | (* distribution tests from PR #45 *) | |
385 | Test.make ~name:"small_signed_int dist" ~count:1000 ~stats:[dist] Gen.small_signed_int (fun _ -> true); | |
386 | Test.make ~name:"small_nat dist" ~count:1000 ~stats:[dist] Gen.small_nat (fun _ -> true); | |
387 | Test.make ~name:"nat dist" ~count:1000 ~stats:[dist] Gen.nat (fun _ -> true); | |
388 | Test.make ~name:"int_range (-43643) 435434 dist" ~count:1000 ~stats:[dist] (Gen.int_range (-43643) 435434) (fun _ -> true); | |
389 | Test.make ~name:"int_range (-40000) 40000 dist" ~count:1000 ~stats:[dist] (Gen.int_range (-40000) 40000) (fun _ -> true); | |
390 | Test.make ~name:"int_range (-4) 4 dist" ~count:1000 ~stats:[dist] (Gen.int_range (-4) 4) (fun _ -> true); | |
391 | Test.make ~name:"int_range (-4) 17 dist" ~count:1000 ~stats:[dist] (Gen.int_range (-4) 17) (fun _ -> true); | |
392 | Test.make ~name:"int dist" ~count:100000 ~stats:[dist] Gen.int (fun _ -> true); | |
393 | Test.make ~name:"oneof int dist" ~count:1000 ~stats:[dist] (Gen.oneofl[min_int;-1;0;1;max_int]) (fun _ -> true); | |
394 | ] | |
395 | ||
396 | let int_dist_empty_bucket = | |
397 | Test.make ~name:"int_dist_empty_bucket" ~count:1_000 ~stats:[("dist",fun x -> x)] | |
398 | Gen.(oneof [small_int_corners ();int]) (fun _ -> true) | |
399 | ||
400 | let tree_depth_test = | |
401 | let depth = ("depth", IntTree.depth) in | |
402 | Test.make ~name:"tree's depth" ~count:1000 ~stats:[depth] IntTree.gen_tree (fun _ -> true) | |
403 | end | |
0 | open QCheck2_tests | |
404 | 1 | |
405 | 2 | (* Calling runners *) |
406 | 3 | |
407 | 4 | let () = QCheck_base_runner.set_seed 1234 |
408 | 5 | let _ = |
409 | QCheck_base_runner.run_tests ~colors:false ([ | |
410 | Overall.passing; | |
411 | Overall.failing; | |
412 | Overall.error; | |
413 | Overall.collect; | |
414 | Overall.stats; | |
415 | Overall.bad_assume_warn; | |
416 | Overall.bad_assume_fail; | |
417 | Generator.char_dist_issue_23; | |
418 | Generator.char_test; | |
419 | Generator.nat_test; | |
420 | Generator.string_test; | |
421 | Generator.list_test; | |
422 | Generator.list_repeat_test; | |
423 | Generator.array_repeat_test; | |
424 | Generator.passing_tree_rev; | |
425 | (*Shrink.test_fac_issue59;*) | |
426 | Shrink.big_bound_issue59; | |
427 | Shrink.long_shrink; | |
428 | Shrink.ints_arent_0_mod_3; | |
429 | Shrink.ints_are_0; | |
430 | Shrink.ints_smaller_209609; | |
431 | Shrink.nats_smaller_5001; | |
432 | Shrink.char_is_never_abcdef; | |
433 | Shrink.strings_are_empty; | |
434 | Shrink.string_never_has_000_char; | |
435 | Shrink.string_never_has_255_char; | |
436 | Shrink.lists_are_empty_issue_64; | |
437 | Shrink.list_shorter_10; | |
438 | Shrink.list_shorter_432; | |
439 | Shrink.list_shorter_4332; | |
440 | Shrink.list_equal_dupl; | |
441 | Shrink.list_unique_elems; | |
442 | Shrink.tree_contains_only_42; | |
443 | Function.fail_pred_map_commute; | |
444 | Function.fail_pred_strings; | |
445 | Function.prop_foldleft_foldright; | |
446 | Function.prop_foldleft_foldright_uncurry; | |
447 | Function.prop_foldleft_foldright_uncurry_funlast; | |
448 | Function.fold_left_test; | |
449 | FindExample.find_ex; | |
450 | FindExample.find_ex_uncaught_issue_99_1_fail; | |
451 | FindExample.find_ex_uncaught_issue_99_2_succeed; | |
452 | Stats.bool_dist; | |
453 | Stats.char_dist; | |
454 | Stats.tree_depth_test ] | |
455 | @ Stats.string_len_tests | |
456 | @ Stats.list_len_tests | |
457 | @ Stats.array_len_tests | |
458 | @ Stats.int_dist_tests) | |
6 | QCheck_base_runner.run_tests ~colors:false ( | |
7 | Overall.tests @ | |
8 | Generator.tests @ | |
9 | Shrink.tests @ | |
10 | Function.tests @ | |
11 | FindExample.tests @ | |
12 | Stats.tests) | |
459 | 13 | |
460 | 14 | let () = QCheck_base_runner.set_seed 153870556 |
461 | 15 | let _ = QCheck_base_runner.run_tests ~colors:false [Stats.int_dist_empty_bucket] |
462 |
0 | (** QCheck2 tests **) | |
1 | ||
2 | (* Please add any additional tests to both [QCheck_tests.ml] and [QCheck2_tests.ml]. | |
3 | This ensures that both generator approaches continue to work as expected | |
4 | and furthermore allows us to compare their behaviour with | |
5 | [diff -y test/core/QCheck_expect_test.expected test/core/QCheck2_expect_test.expected] *) | |
6 | ||
7 | (** Module representing a integer tree data structure, used in tests *) | |
8 | module IntTree = struct | |
9 | type tree = Leaf of int | Node of tree * tree | |
10 | ||
11 | let leaf x = Leaf x | |
12 | let node x y = Node (x,y) | |
13 | ||
14 | let rec depth = function | |
15 | | Leaf _ -> 1 | |
16 | | Node (x, y) -> 1 + max (depth x) (depth y) | |
17 | ||
18 | let rec print_tree = function | |
19 | | Leaf x -> Printf.sprintf "Leaf %d" x | |
20 | | Node (x, y) -> Printf.sprintf "Node (%s, %s)" (print_tree x) (print_tree y) | |
21 | ||
22 | let gen_tree = QCheck2.Gen.(sized @@ fix | |
23 | (fun self n -> match n with | |
24 | | 0 -> map leaf nat | |
25 | | n -> | |
26 | frequency | |
27 | [1, map leaf nat; | |
28 | 2, map2 node (self (n/2)) (self (n/2))] | |
29 | )) | |
30 | ||
31 | let rec rev_tree = function | |
32 | | Node (x, y) -> Node (rev_tree y, rev_tree x) | |
33 | | Leaf x -> Leaf x | |
34 | ||
35 | let rec contains_only_n tree n = match tree with | |
36 | | Leaf n' -> n = n' | |
37 | | Node (x, y) -> contains_only_n x n && contains_only_n y n | |
38 | end | |
39 | ||
40 | (* tests of overall functionality *) | |
41 | module Overall = struct | |
42 | open QCheck2 | |
43 | ||
44 | let passing = | |
45 | Test.make ~name:"list_rev_is_involutive" ~count:100 ~long_factor:100 | |
46 | ~print:Print.(list int) | |
47 | Gen.(list small_int) (fun l -> List.rev (List.rev l) = l) | |
48 | ||
49 | let failing = | |
50 | Test.make ~name:"should_fail_sort_id" ~count:10 ~print:Print.(list int) | |
51 | Gen.(small_list small_int) (fun l -> l = List.sort compare l) | |
52 | ||
53 | exception Error | |
54 | ||
55 | let error = | |
56 | Test.make ~name:"should_error_raise_exn" ~count:10 ~print:Print.int | |
57 | Gen.int (fun _ -> raise Error) | |
58 | ||
59 | let collect = | |
60 | Test.make ~name:"collect_results" ~count:100 ~long_factor:100 | |
61 | ~print:Print.int ~collect:string_of_int | |
62 | (Gen.int_bound 4) (fun _ -> true) | |
63 | ||
64 | let stats = | |
65 | Test.make ~name:"with_stats" ~count:100 ~long_factor:100 ~print:Print.int | |
66 | ~stats:[ | |
67 | "mod4", (fun i->i mod 4); | |
68 | "num", (fun i->i); | |
69 | ] | |
70 | (Gen.int_bound 120) (fun _ -> true) | |
71 | ||
72 | let retries = | |
73 | Test.make ~name:"with shrinking retries" ~retries:10 ~print:Print.int | |
74 | Gen.small_nat (fun i -> Printf.printf "%i %!" i; i mod 3 <> 1) | |
75 | ||
76 | let bad_assume_warn = | |
77 | Test.make ~name:"WARN_unlikely_precond" ~count:2_000 ~print:Print.int | |
78 | Gen.int | |
79 | (fun x -> | |
80 | QCheck.assume (x mod 100 = 1); | |
81 | true) | |
82 | ||
83 | let bad_assume_fail = | |
84 | Test.make ~name:"FAIL_unlikely_precond" ~count:2_000 | |
85 | ~if_assumptions_fail:(`Fatal, 0.1) ~print:Print.int | |
86 | Gen.int | |
87 | (fun x -> | |
88 | QCheck.assume (x mod 100 = 1); | |
89 | true) | |
90 | ||
91 | let bad_gen_fail = | |
92 | Test.make ~name:"FAIL_bad_gen" | |
93 | Gen.(int >>= fun j -> int_bound j >>= fun i -> return (i,j)) | |
94 | (fun (_i,_j) -> true) (* i may be negative, causing int_bound to fail *) | |
95 | ||
96 | let bad_shrinker_fail = | |
97 | Test.make ~name:"FAIL_bad_shrinker" | |
98 | (Gen.make_primitive | |
99 | ~shrink:(fun _i -> raise Error) | |
100 | ~gen:(fun rs -> Random.State.int rs)) | |
101 | (fun _i -> false) | |
102 | ||
103 | let neg_test_fail_as_expected = | |
104 | Test.make_neg ~name:"all ints are even" ~print:Print.int Gen.small_int (fun i -> i mod 2 = 0) | |
105 | ||
106 | let neg_test_unexpected_success = | |
107 | Test.make_neg ~name:"int double" ~print:Print.int Gen.small_int (fun i -> i + i = i * 2) | |
108 | ||
109 | let neg_test_fail_with_shrinking = | |
110 | Test.make_neg ~name:"list rev concat" ~print:Print.(pair (list int) (list int)) | |
111 | Gen.(pair (list small_int) (list small_int)) (fun (is,js) -> (List.rev is)@(List.rev js) = List.rev (is@js)) | |
112 | ||
113 | let pos_test_fails_with_error = | |
114 | Test.make ~name:"pos fail with error" ~print:Print.int Gen.small_int (fun _i -> raise Error) | |
115 | ||
116 | let neg_test_fail_with_error = | |
117 | Test.make_neg ~name:"neg fail with error" ~print:Print.int Gen.small_int (fun _i -> raise Error) | |
118 | ||
119 | (* [apply_n f x n] computes f(f(...f(x))) with n applications of f *) | |
120 | let rec apply_n f x n = | |
121 | if n=0 | |
122 | then x | |
123 | else apply_n f (f x) (pred n) | |
124 | ||
125 | (* test from #236 *) | |
126 | let bad_fun_repro = | |
127 | let sleep_time = 0.175 in | |
128 | let count = ref 0 in | |
129 | Test.make ~count:10 ~name:"bad function reproducability" | |
130 | Gen.(triple small_int (fun1 Observable.int small_int) small_int) | |
131 | (fun (i,f,j) -> | |
132 | incr count; | |
133 | Printf.printf "(%i,fun,%i)%s%!" i j (if !count mod 10 = 0 then "\n" else " "); | |
134 | Unix.sleepf sleep_time; | |
135 | if 1 = Float.to_int (Unix.time ()) mod 2 | |
136 | then | |
137 | (ignore(apply_n (Fn.apply f) i j > 0); true) | |
138 | else | |
139 | (ignore(apply_n (Fn.apply f) i i > 0); true)) | |
140 | ||
141 | let tests = [ | |
142 | passing; | |
143 | failing; | |
144 | error; | |
145 | collect; | |
146 | stats; | |
147 | retries; | |
148 | bad_assume_warn; | |
149 | bad_assume_fail; | |
150 | bad_gen_fail; | |
151 | (*bad_shrinker_fail;*) | |
152 | neg_test_fail_as_expected; | |
153 | neg_test_unexpected_success; | |
154 | neg_test_fail_with_shrinking; | |
155 | pos_test_fails_with_error; | |
156 | neg_test_fail_with_error; | |
157 | (* we repeat the following multiple times to check the expected output for duplicate lines *) | |
158 | bad_fun_repro; | |
159 | bad_fun_repro; | |
160 | bad_fun_repro; | |
161 | bad_fun_repro; | |
162 | bad_fun_repro; | |
163 | bad_fun_repro; | |
164 | bad_fun_repro; | |
165 | bad_fun_repro; | |
166 | ] | |
167 | end | |
168 | ||
169 | (* positive tests of the various generators *) | |
170 | module Generator = struct | |
171 | open QCheck2 | |
172 | ||
173 | (* example from issue #23 *) | |
174 | let char_dist_issue_23 = | |
175 | Test.make ~name:"char never produces '\\255'" ~count:1_000_000 | |
176 | ~print:Print.char | |
177 | Gen.char (fun c -> c <> '\255') | |
178 | ||
179 | let char_test = | |
180 | Test.make ~name:"char has right range'" ~count:1000 ~print:Print.char | |
181 | Gen.char (fun c -> '\000' <= c && c <= '\255') | |
182 | ||
183 | let printable_test = | |
184 | Test.make ~name:"printable has right range" ~count:1000 ~print:Print.char | |
185 | Gen.printable (fun c -> c = '\n' || 32 <= Char.code c && Char.code c <= 126) | |
186 | ||
187 | let numeral_test = | |
188 | Test.make ~name:"numeral has right range" ~count:1000 ~print:Print.char | |
189 | Gen.numeral (fun c -> '0' <= c && c <= '9') | |
190 | ||
191 | let nat_test = | |
192 | Test.make ~name:"nat has right range" ~count:1000 ~print:Print.int | |
193 | Gen.nat (fun n -> 0 <= n && n < 10000) | |
194 | ||
195 | let string_test = | |
196 | Test.make ~name:"string has right length and content" ~count:1000 ~print:Print.string | |
197 | Gen.string | |
198 | (fun s -> | |
199 | let len = String.length s in | |
200 | 0 <= len && len < 10000 | |
201 | && String.to_seq s |> | |
202 | Seq.fold_left (fun acc c -> acc && '\000' <= c && c <= '\255') true) | |
203 | ||
204 | let pair_test = | |
205 | Test.make ~name:"int pairs - commute over +" ~count:1000 ~print:Print.(pair int int) | |
206 | Gen.(pair small_nat small_nat) (fun (i,j) -> i+j = j+i) | |
207 | ||
208 | let triple_test = | |
209 | Test.make ~name:"int triples - associative over +" ~count:1000 | |
210 | ~print:Print.(triple int int int) | |
211 | Gen.(triple small_nat small_nat small_nat) (fun (i,j,k) -> i+(j+k) = (i+j)+k) | |
212 | ||
213 | let quad_test = | |
214 | Test.make ~name:"int quadruples - product of sums" ~count:1000 | |
215 | ~print:Print.(quad int int int int) | |
216 | Gen.(quad small_nat small_nat small_nat small_nat) | |
217 | (fun (h,i,j,k) -> (h+i)*(j+k) = h*j + h*k + i*j + i*k) | |
218 | ||
219 | let test_tup2 = | |
220 | Test.make ~count:10 | |
221 | ~name:"forall x in (0, 1): x = (0, 1)" | |
222 | Gen.(tup2 (pure 0) (pure 1)) | |
223 | (fun x -> x = (0, 1)) | |
224 | ||
225 | let test_tup3 = | |
226 | Test.make ~count:10 | |
227 | ~name:"forall x in (0, 1, 2): x = (0, 1, 2)" | |
228 | Gen.(tup3 (pure 0) (pure 1) (pure 2)) | |
229 | (fun x -> x = (0, 1, 2)) | |
230 | ||
231 | let test_tup4 = | |
232 | Test.make ~count:10 | |
233 | ~name:"forall x in (0, 1, 2, 3): x = (0, 1, 2, 3)" | |
234 | Gen.(tup4 (pure 0) (pure 1) (pure 2) (pure 3)) | |
235 | (fun x -> x = (0, 1, 2, 3)) | |
236 | ||
237 | let test_tup5 = | |
238 | Test.make ~count:10 | |
239 | ~name:"forall x in (0, 1, 2, 3, 4): x = (0, 1, 2, 3, 4)" | |
240 | Gen.(tup5 (pure 0) (pure 1) (pure 2) (pure 3) (pure 4)) | |
241 | (fun x -> x = (0, 1, 2, 3, 4)) | |
242 | ||
243 | let test_tup6 = | |
244 | Test.make ~count:10 | |
245 | ~name:"forall x in (0, 1, 2, 3, 4, 5): x = (0, 1, 2, 3, 4, 5)" | |
246 | Gen.(tup6 (pure 0) (pure 1) (pure 2) (pure 3) (pure 4) (pure 5)) | |
247 | (fun x -> x = (0, 1, 2, 3, 4, 5)) | |
248 | ||
249 | let test_tup7 = | |
250 | Test.make ~count:10 | |
251 | ~name:"forall x in (0, 1, 2, 3, 4, 5, 6): x = (0, 1, 2, 3, 4, 5, 6)" | |
252 | Gen.(tup7 | |
253 | (pure 0) (pure 1) (pure 2) (pure 3) (pure 4) | |
254 | (pure 5) (pure 6)) | |
255 | (fun x -> x = (0, 1, 2, 3, 4, 5, 6)) | |
256 | ||
257 | let test_tup8 = | |
258 | Test.make ~count:10 | |
259 | ~name:"forall x in (0, 1, 2, 3, 4, 5, 6, 7): x = (0, 1, 2, 3, 4, 5, 6, 7)" | |
260 | Gen.(tup8 | |
261 | (pure 0) (pure 1) (pure 2) (pure 3) (pure 4) | |
262 | (pure 5) (pure 6) (pure 7)) | |
263 | (fun x -> x = (0, 1, 2, 3, 4, 5, 6, 7)) | |
264 | ||
265 | let test_tup9 = | |
266 | Test.make ~count:10 | |
267 | ~name:"forall x in (0, 1, 2, 3, 4, 5, 6, 7, 8): x = (0, 1, 2, 3, 4, 5, 6, 7, 8)" | |
268 | Gen.(tup9 | |
269 | (pure 0) (pure 1) (pure 2) (pure 3) (pure 4) | |
270 | (pure 5) (pure 6) (pure 7) (pure 8)) | |
271 | (fun x -> x = (0, 1, 2, 3, 4, 5, 6, 7, 8)) | |
272 | ||
273 | let bind_test = | |
274 | Test.make ~name:"bind test for ordered pairs" ~count:1000 ~print:Print.(pair int int) | |
275 | Gen.(small_nat >>= fun j -> int_bound j >>= fun i -> return (i,j)) | |
276 | (fun (i,j) -> i<=j) | |
277 | ||
278 | let bind_pair_list_length = | |
279 | Test.make ~name:"bind list length" ~count:1000 ~print:Print.(pair int (list int)) | |
280 | Gen.(int_bound 1000 >>= fun len -> | |
281 | list_size (return len) (int_bound 10) >>= fun xs -> return (len,xs)) | |
282 | (fun (len,xs) -> len = List.length xs) | |
283 | ||
284 | let list_test = | |
285 | Test.make ~name:"list has right length" ~count:1000 | |
286 | ~print:Print.(list unit) | |
287 | Gen.(list unit) (fun l -> let len = List.length l in 0 <= len && len < 10_000) | |
288 | ||
289 | let list_repeat_test = | |
290 | Test.make ~name:"list_repeat has constant length" ~count:1000 | |
291 | ~print:Print.(pair int (list unit)) | |
292 | Gen.(small_nat >>= fun i -> list_repeat i unit >>= fun l -> return (i,l)) | |
293 | (fun (i,l) -> List.length l = i) | |
294 | ||
295 | let array_repeat_test = | |
296 | Test.make ~name:"array_repeat has constant length" ~count:1000 | |
297 | ~print:Print.(pair int (array unit)) | |
298 | Gen.(small_nat >>= fun i -> array_repeat i unit >>= fun l -> return (i,l)) | |
299 | (fun (i,l) -> Array.length l = i) | |
300 | ||
301 | let passing_tree_rev = | |
302 | Test.make ~name:"tree_rev_is_involutive" ~count:1000 | |
303 | IntTree.gen_tree | |
304 | (fun tree -> IntTree.(rev_tree (rev_tree tree)) = tree) | |
305 | ||
306 | let tests = [ | |
307 | char_dist_issue_23; | |
308 | char_test; | |
309 | nat_test; | |
310 | string_test; | |
311 | pair_test; | |
312 | triple_test; | |
313 | quad_test; | |
314 | test_tup2; | |
315 | test_tup3; | |
316 | test_tup4; | |
317 | test_tup5; | |
318 | test_tup6; | |
319 | test_tup7; | |
320 | test_tup8; | |
321 | test_tup9; | |
322 | bind_test; | |
323 | bind_pair_list_length; | |
324 | list_test; | |
325 | list_repeat_test; | |
326 | array_repeat_test; | |
327 | passing_tree_rev; | |
328 | ] | |
329 | end | |
330 | ||
331 | (* negative tests that exercise shrinking behaviour *) | |
332 | module Shrink = struct | |
333 | open QCheck2 | |
334 | ||
335 | let rec fac n = match n with | |
336 | | 0 -> 1 | |
337 | | n -> n * fac (n - 1) | |
338 | ||
339 | (* example from issue #59 *) | |
340 | let test_fac_issue59 = | |
341 | Test.make ~name:"test fac issue59" | |
342 | (Gen.make_primitive ~gen:(fun st -> Gen.generate1 ~rand:st (Gen.small_int_corners ())) ~shrink:(fun _ -> Seq.empty)) | |
343 | (fun n -> try (fac n) mod n = 0 | |
344 | with | |
345 | (*| Stack_overflow -> false*) | |
346 | | Division_by_zero -> (n=0)) | |
347 | ||
348 | let big_bound_issue59 = | |
349 | Test.make ~name:"big bound issue59" ~print:Print.int | |
350 | (Gen.small_int_corners()) (fun i -> i < 209609) | |
351 | ||
352 | let long_shrink = | |
353 | let listgen = Gen.(list_size (int_range 1000 10000) int) in | |
354 | Test.make ~name:"long_shrink" ~print:Print.(pair (list int) (list int)) | |
355 | (Gen.pair listgen listgen) | |
356 | (fun (xs,ys) -> List.rev (xs@ys) = (List.rev xs)@(List.rev ys)) | |
357 | ||
358 | (* test from issue #36 *) | |
359 | let ints_arent_0_mod_3 = | |
360 | Test.make ~name:"ints arent 0 mod 3" ~count:1000 ~print:Print.int | |
361 | Gen.int (fun i -> i mod 3 <> 0) | |
362 | ||
363 | let ints_are_0 = | |
364 | Test.make ~name:"ints are 0" ~count:1000 ~print:Print.int | |
365 | Gen.int (fun i -> Printf.printf "%i\n" i; i = 0) | |
366 | ||
367 | (* test from issue #59 *) | |
368 | let ints_smaller_209609 = | |
369 | Test.make ~name:"ints < 209609" ~print:Print.int | |
370 | (Gen.small_int_corners()) (fun i -> i < 209609) | |
371 | ||
372 | let nats_smaller_5001 = | |
373 | Test.make ~name:"nat < 5001" ~count:1000 ~print:Print.int | |
374 | Gen.nat (fun n -> n < 5001) | |
375 | ||
376 | let char_is_never_abcdef = | |
377 | Test.make ~name:"char never produces 'abcdef'" ~count:1000 ~print:Print.char | |
378 | Gen.char (fun c -> not (List.mem c ['a';'b';'c';'d';'e';'f'])) | |
379 | ||
380 | let printable_is_never_sign = (* should shrink towards '!' with lowest ascii code 33 *) | |
381 | Test.make ~name:"printable never produces '!\"#$%&''" ~count:1000 ~print:Print.char | |
382 | Gen.printable (fun c -> not (List.mem c ['!';'@';'#';'$';'%'])) | |
383 | ||
384 | let numeral_is_never_less_5 = | |
385 | Test.make ~name:"printable never produces less than '5" ~count:1000 ~print:Print.char | |
386 | Gen.numeral (fun c -> c >= '5') | |
387 | ||
388 | let strings_are_empty = | |
389 | Test.make ~name:"strings are empty" ~count:1000 ~print:Print.string | |
390 | Gen.string (fun s -> s = "") | |
391 | ||
392 | let string_never_has_000_char = | |
393 | Test.make ~name:"string never has a \\000 char" ~count:1000 ~print:Print.string | |
394 | Gen.string | |
395 | (fun s -> String.to_seq s |> Seq.fold_left (fun acc c -> acc && c <> '\000') true) | |
396 | ||
397 | let string_never_has_255_char = | |
398 | Test.make ~name:"string never has a \\255 char" ~count:1000 ~print:Print.string | |
399 | Gen.string | |
400 | (fun s -> String.to_seq s |> Seq.fold_left (fun acc c -> acc && c <> '\255') true) | |
401 | ||
402 | let string_unique_chars = | |
403 | Test.make ~name:"strings have unique chars" ~count:1000 ~print:Print.string | |
404 | Gen.string | |
405 | (fun s -> | |
406 | let ch_list = String.to_seq s |> List.of_seq in | |
407 | List.length ch_list = List.length (List.sort_uniq Char.compare ch_list)) | |
408 | ||
409 | (* test from issue #167 *) | |
410 | let pair_diff_issue_64 = | |
411 | Test.make ~name:"pairs have different components" ~print:Print.(pair int int) | |
412 | Gen.(pair small_int small_int) (fun (i,j) -> i<>j) | |
413 | ||
414 | let pair_same = | |
415 | Test.make ~name:"pairs have same components" ~print:Print.(pair int int) | |
416 | Gen.(pair int int) (fun (i,j) -> i=j) | |
417 | ||
418 | let pair_one_zero = | |
419 | Test.make ~name:"pairs have a zero component" ~print:Print.(pair int int) | |
420 | Gen.(pair int int) (fun (i,j) -> i=0 || j=0) | |
421 | ||
422 | let pair_all_zero = | |
423 | Test.make ~name:"pairs are (0,0)" ~print:Print.(pair int int) | |
424 | Gen.(pair int int) (fun (i,j) -> i=0 && j=0) | |
425 | ||
426 | let pair_ordered = | |
427 | Test.make ~name:"pairs are ordered" ~print:Print.(pair int int) | |
428 | Gen.(pair (pint ~origin:0) (pint ~origin:0)) (fun (i,j) -> i<=j) | |
429 | ||
430 | let pair_ordered_rev = | |
431 | Test.make ~name:"pairs are ordered reversely" ~print:Print.(pair int int) | |
432 | Gen.(pair (pint ~origin:0) (pint ~origin:0)) (fun (i,j) -> i>=j) | |
433 | ||
434 | let pair_sum_lt_128 = | |
435 | Test.make ~name:"pairs sum to less than 128" ~print:Print.(pair int int) | |
436 | Gen.(pair (pint ~origin:0) (pint ~origin:0)) (fun (i,j) -> i+j<128) | |
437 | ||
438 | let pair_lists_rev_concat = | |
439 | Test.make ~name:"pairs lists rev concat" ~print:Print.(pair (list int) (list int)) | |
440 | Gen.(pair (list (pint ~origin:0)) (list (pint ~origin:0))) | |
441 | (fun (xs,ys) -> List.rev (xs@ys) = (List.rev xs)@(List.rev ys)) | |
442 | ||
443 | let pair_lists_no_overlap = | |
444 | Test.make ~name:"pairs lists no overlap" ~print:Print.(pair (list int) (list int)) | |
445 | Gen.(pair (list small_nat) (list small_nat)) | |
446 | (fun (xs,ys) -> List.for_all (fun x -> not (List.mem x ys)) xs) | |
447 | ||
448 | let triple_diff = | |
449 | Test.make ~name:"triples have pair-wise different components" ~print:Print.(triple int int int) | |
450 | Gen.(triple small_int small_int small_int) (fun (i,j,k) -> i<>j && j<>k) | |
451 | ||
452 | let triple_same = | |
453 | Test.make ~name:"triples have same components" ~print:Print.(triple int int int) | |
454 | Gen.(triple int int int) (fun (i,j,k) -> i=j || j=k) | |
455 | ||
456 | let triple_ordered = | |
457 | Test.make ~name:"triples are ordered" ~print:Print.(triple int int int) | |
458 | Gen.(triple int int int) (fun (i,j,k) -> i<=j && j<=k) | |
459 | ||
460 | let triple_ordered_rev = | |
461 | Test.make ~name:"triples are ordered reversely" ~print:Print.(triple int int int) | |
462 | Gen.(triple int int int) (fun (i,j,k) -> i>=j && j>=k) | |
463 | ||
464 | let quad_diff = | |
465 | Test.make ~name:"quadruples have pair-wise different components" ~print:Print.(quad int int int int) | |
466 | Gen.(quad small_int small_int small_int small_int) (fun (h,i,j,k) -> h<>i && i<>j && j<>k) | |
467 | ||
468 | let quad_same = | |
469 | Test.make ~name:"quadruples have same components" ~print:Print.(quad int int int int) | |
470 | Gen.(quad int int int int) (fun (h,i,j,k) -> h=i || i=j || j=k) | |
471 | ||
472 | let quad_ordered = | |
473 | Test.make ~name:"quadruples are ordered" ~print:Print.(quad int int int int) | |
474 | Gen.(quad int int int int) (fun (h,i,j,k) -> h <= i && i <= j && j <= k) | |
475 | ||
476 | let quad_ordered_rev = | |
477 | Test.make ~name:"quadruples are ordered reversely" ~print:Print.(quad int int int int) | |
478 | Gen.(quad int int int int) (fun (h,i,j,k) -> h >= i && i >= j && j >= k) | |
479 | ||
480 | let test_tup2 = | |
481 | Test.make | |
482 | ~print:Print.(tup2 int int) | |
483 | ~name:"forall (a, b) in nat: a < b" | |
484 | Gen.(tup2 small_int small_int) | |
485 | (fun (a, b) -> a < b) | |
486 | ||
487 | let test_tup3 = | |
488 | Test.make | |
489 | ~print:Print.(tup3 int int int) | |
490 | ~name:"forall (a, b, c) in nat: a < b < c" | |
491 | Gen.(tup3 small_int small_int small_int) | |
492 | (fun (a, b, c) -> a < b && b < c) | |
493 | ||
494 | let test_tup4 = | |
495 | Test.make | |
496 | ~print:Print.(tup4 int int int int) | |
497 | ~name:"forall (a, b, c, d) in nat: a < b < c < d" | |
498 | Gen.(tup4 small_int small_int small_int small_int) | |
499 | (fun (a, b, c, d) -> a < b && b < c && c < d) | |
500 | ||
501 | let test_tup5 = | |
502 | Test.make | |
503 | ~print:Print.(tup5 int int int int int) | |
504 | ~name:"forall (a, b, c, d, e) in nat: a < b < c < d < e" | |
505 | Gen.(tup5 small_int small_int small_int small_int small_int) | |
506 | (fun (a, b, c, d, e) -> a < b && b < c && c < d && d < e) | |
507 | ||
508 | let test_tup6 = | |
509 | Test.make | |
510 | ~print:Print.(tup6 int int int int int int) | |
511 | ~name:"forall (a, b, c, d, e, f) in nat: a < b < c < d < e < f" | |
512 | Gen.(tup6 small_int small_int small_int small_int small_int small_int) | |
513 | (fun (a, b, c, d, e, f) -> a < b && b < c && c < d && d < e && e < f) | |
514 | ||
515 | let test_tup7 = | |
516 | Test.make | |
517 | ~print:Print.(tup7 int int int int int int int) | |
518 | ~name:"forall (a, b, c, d, e, f, g) in nat: a < b < c < d < e < f < g" | |
519 | Gen.(tup7 small_int small_int small_int small_int small_int small_int small_int) | |
520 | (fun (a, b, c, d, e, f, g) -> a < b && b < c && c < d && d < e && e < f && f < g) | |
521 | ||
522 | let test_tup8 = | |
523 | Test.make | |
524 | ~print:Print.(tup8 int int int int int int int int) | |
525 | ~name:"forall (a, b, c, d, e, f, g, h) in nat: a < b < c < d < e < f < g < h" | |
526 | Gen.(tup8 small_int small_int small_int small_int small_int small_int small_int small_int) | |
527 | (fun (a, b, c, d, e, f, g, h) -> a < b && b < c && c < d && d < e && e < f && f < g && g < h) | |
528 | ||
529 | let test_tup9 = | |
530 | Test.make | |
531 | ~print:Print.(tup9 int int int int int int int int int) | |
532 | ~name:"forall (a, b, c, d, e, f, g, h, i) in nat: a < b < c < d < e < f < g < h < i" | |
533 | Gen.(tup9 small_int small_int small_int small_int small_int small_int small_int small_int small_int) | |
534 | (fun (a, b, c, d, e, f, g, h, i) -> a < b && b < c && c < d && d < e && e < f && f < g && g < h && h < i) | |
535 | ||
536 | let bind_pair_ordered = | |
537 | Test.make ~name:"bind ordered pairs" ~print:Print.(pair int int) | |
538 | Gen.(pint ~origin:0 >>= fun j -> int_bound j >>= fun i -> return (i,j)) | |
539 | (fun (_i,_j) -> false) | |
540 | ||
541 | let bind_pair_list_size = | |
542 | Test.make ~name:"bind list_size constant" ~print:Print.(pair int (list int)) | |
543 | Gen.(int_bound 1000 >>= fun len -> | |
544 | list_size (return len) (int_bound 1000) >>= fun xs -> return (len,xs)) | |
545 | (fun (len,xs) -> let len' = List.length xs in len=len' && len' < 4) | |
546 | ||
547 | (* tests from issue #64 *) | |
548 | let print_list xs = print_endline Print.(list int xs) | |
549 | ||
550 | let lists_are_empty_issue_64 = | |
551 | Test.make ~name:"lists are empty" ~print:Print.(list int) | |
552 | Gen.(list small_int) (fun xs -> print_list xs; xs = []) | |
553 | ||
554 | let list_shorter_10 = | |
555 | Test.make ~name:"lists shorter than 10" ~print:Print.(list int) | |
556 | Gen.(list small_int) (fun xs -> List.length xs < 10) | |
557 | ||
558 | let length_printer xs = | |
559 | Printf.sprintf "[...] list length: %i" (List.length xs) | |
560 | ||
561 | let size_gen = Gen.(oneof [small_nat; int_bound 750_000]) | |
562 | ||
563 | let list_shorter_432 = | |
564 | Test.make ~name:"lists shorter than 432" ~print:length_printer | |
565 | Gen.(list_size size_gen small_int) | |
566 | (fun xs -> List.length xs < 432) | |
567 | ||
568 | let list_shorter_4332 = | |
569 | Test.make ~name:"lists shorter than 4332" ~print:length_printer | |
570 | Gen.(list_size size_gen small_int) | |
571 | (fun xs -> List.length xs < 4332) | |
572 | ||
573 | let list_equal_dupl = | |
574 | Test.make ~name:"lists equal to duplication" ~print:Print.(list int) | |
575 | Gen.(list_size size_gen small_int) | |
576 | (fun xs -> try xs = xs @ xs | |
577 | with Stack_overflow -> false) | |
578 | ||
579 | let list_unique_elems = | |
580 | Test.make ~name:"lists have unique elems" ~print:Print.(list int) | |
581 | Gen.(list small_int) | |
582 | (fun xs -> let ys = List.sort_uniq Int.compare xs in | |
583 | print_list xs; List.length xs = List.length ys) | |
584 | ||
585 | let tree_contains_only_42 = | |
586 | Test.make ~name:"tree contains only 42" ~print:IntTree.print_tree | |
587 | IntTree.gen_tree | |
588 | (fun tree -> IntTree.contains_only_n tree 42) | |
589 | ||
590 | let test_gen_no_shrink = | |
591 | Test.make ~name:"sum list = 0" ~print:Print.(list int) | |
592 | Gen.(no_shrink @@ list small_int) | |
593 | (fun xs -> List.fold_left (+) 0 xs = 0) | |
594 | ||
595 | let tests = [ | |
596 | (*test_fac_issue59;*) | |
597 | big_bound_issue59; | |
598 | long_shrink; | |
599 | ints_arent_0_mod_3; | |
600 | ints_are_0; | |
601 | ints_smaller_209609; | |
602 | nats_smaller_5001; | |
603 | char_is_never_abcdef; | |
604 | printable_is_never_sign; | |
605 | numeral_is_never_less_5; | |
606 | strings_are_empty; | |
607 | string_never_has_000_char; | |
608 | string_never_has_255_char; | |
609 | string_unique_chars; | |
610 | pair_diff_issue_64; | |
611 | pair_same; | |
612 | pair_one_zero; | |
613 | pair_all_zero; | |
614 | pair_ordered; | |
615 | pair_ordered_rev; | |
616 | pair_sum_lt_128; | |
617 | pair_lists_rev_concat; | |
618 | pair_lists_no_overlap; | |
619 | triple_diff; | |
620 | triple_same; | |
621 | triple_ordered; | |
622 | triple_ordered_rev; | |
623 | quad_diff; | |
624 | quad_same; | |
625 | quad_ordered; | |
626 | quad_ordered_rev; | |
627 | test_tup2; | |
628 | test_tup3; | |
629 | test_tup4; | |
630 | test_tup5; | |
631 | test_tup6; | |
632 | test_tup7; | |
633 | test_tup8; | |
634 | test_tup9; | |
635 | bind_pair_ordered; | |
636 | bind_pair_list_size; | |
637 | lists_are_empty_issue_64; | |
638 | list_shorter_10; | |
639 | list_shorter_432; | |
640 | list_shorter_4332; | |
641 | (*list_equal_dupl;*) | |
642 | list_unique_elems; | |
643 | tree_contains_only_42; | |
644 | test_gen_no_shrink; | |
645 | ] | |
646 | end | |
647 | ||
648 | (* tests function generator and shrinker *) | |
649 | module Function = struct | |
650 | open QCheck2 | |
651 | ||
652 | let fail_pred_map_commute = | |
653 | Test.make ~name:"fail_pred_map_commute" ~count:100 ~long_factor:100 | |
654 | ~print:Print.(triple (list int) Fn.print Fn.print) | |
655 | Gen.(triple | |
656 | (small_list small_int) | |
657 | (fun1 ~print:Print.int Observable.int int) | |
658 | (fun1 ~print:Print.bool Observable.int bool)) | |
659 | (fun (l,Fun (_,f),Fun (_,p)) -> | |
660 | List.filter p (List.map f l) = List.map f (List.filter p l)) | |
661 | ||
662 | let fail_pred_strings = | |
663 | Test.make ~name:"fail_pred_strings" ~count:100 ~print:Fn.print | |
664 | (fun1 Observable.string ~print:Print.bool Gen.bool) | |
665 | (fun (Fun (_,p)) -> not (p "some random string") || p "some other string") | |
666 | ||
667 | let int_gen = Gen.small_nat (* int *) | |
668 | ||
669 | (* Another example (false) property *) | |
670 | let prop_foldleft_foldright = | |
671 | Test.make ~name:"fold_left fold_right" ~count:1000 ~long_factor:20 | |
672 | ~print:Print.(triple int (list int) Fn.print) | |
673 | Gen.(triple | |
674 | int_gen | |
675 | (list int_gen) | |
676 | (fun2 ~print:Print.int Observable.int Observable.int int_gen)) | |
677 | (fun (z,xs,f) -> | |
678 | let l1 = List.fold_right (Fn.apply f) xs z in | |
679 | let l2 = List.fold_left (Fn.apply f) z xs in | |
680 | if l1=l2 then true | |
681 | else Test.fail_reportf "l=%s, fold_left=%s, fold_right=%s@." | |
682 | (Print.(list int) xs) | |
683 | (Print.int l1) | |
684 | (Print.int l2) | |
685 | ) | |
686 | ||
687 | (* Another example (false) property *) | |
688 | let prop_foldleft_foldright_uncurry = | |
689 | Test.make ~name:"fold_left fold_right uncurried" ~count:1000 ~long_factor:20 | |
690 | ~print:Print.(triple Fn.print int (list int)) | |
691 | Gen.(triple | |
692 | (fun1 ~print:Print.int Observable.(pair int int) int_gen) | |
693 | int_gen | |
694 | (list int_gen)) | |
695 | (fun (f,z,xs) -> | |
696 | List.fold_right (fun x y -> Fn.apply f (x,y)) xs z = | |
697 | List.fold_left (fun x y -> Fn.apply f (x,y)) z xs) | |
698 | ||
699 | (* Same as the above (false) property, but generating+shrinking functions last *) | |
700 | let prop_foldleft_foldright_uncurry_funlast = | |
701 | Test.make ~name:"fold_left fold_right uncurried fun last" ~count:1000 ~long_factor:20 | |
702 | ~print:Print.(triple int (list int) Fn.print) | |
703 | Gen.(triple | |
704 | int_gen | |
705 | (list int_gen) | |
706 | (fun1 ~print:Print.int Observable.(pair int int) int_gen)) | |
707 | (fun (z,xs,f) -> | |
708 | List.fold_right (fun x y -> Fn.apply f (x,y)) xs z = | |
709 | List.fold_left (fun x y -> Fn.apply f (x,y)) z xs) | |
710 | ||
711 | (* test from issue #64 *) | |
712 | let fold_left_test = | |
713 | Test.make ~name:"fold_left test, fun first" ~print:Print.(quad Fn.print string (list int) (list int)) | |
714 | Gen.(quad (* string -> int -> string *) | |
715 | (fun2 ~print:Print.string Observable.string Observable.int (small_string ~gen:char)) | |
716 | (small_string ~gen:char) | |
717 | (list small_int) | |
718 | (list small_int)) | |
719 | (fun (f,acc,is,js) -> | |
720 | let f = Fn.apply f in | |
721 | List.fold_left f acc (is @ js) | |
722 | = List.fold_left f (List.fold_left f acc is) is) (*Typo*) | |
723 | ||
724 | let tests = [ | |
725 | fail_pred_map_commute; | |
726 | fail_pred_strings; | |
727 | prop_foldleft_foldright; | |
728 | prop_foldleft_foldright_uncurry; | |
729 | prop_foldleft_foldright_uncurry_funlast; | |
730 | fold_left_test; | |
731 | ] | |
732 | end | |
733 | ||
734 | (* tests of (inner) find_example(_gen) behaviour *) | |
735 | module FindExample = struct | |
736 | open QCheck2 | |
737 | ||
738 | let find_ex = | |
739 | Test.make ~name:"find_example" ~print:Print.int | |
740 | Gen.(2--50) | |
741 | (fun n -> | |
742 | let st = Random.State.make [| 0 |] in | |
743 | let f m = n < m && m < 2 * n in | |
744 | try | |
745 | let m = find_example_gen ~rand:st ~count:100_000 ~f Gen.(0 -- 1000) in | |
746 | f m | |
747 | with No_example_found _ -> false) | |
748 | ||
749 | let find_ex_uncaught_issue_99_1_fail = | |
750 | let rs = (find_example ~count:10 ~f:(fun _ -> false) Gen.int) in | |
751 | Test.make ~name:"FAIL_#99_1" rs (fun _ -> true) | |
752 | ||
753 | let find_ex_uncaught_issue_99_2_succeed = | |
754 | Test.make ~name:"should_succeed_#99_2" ~count:10 | |
755 | Gen.int (fun i -> i <= max_int) | |
756 | ||
757 | let tests = [ | |
758 | find_ex; | |
759 | find_ex_uncaught_issue_99_1_fail; | |
760 | find_ex_uncaught_issue_99_2_succeed; | |
761 | ] | |
762 | end | |
763 | ||
764 | (* tests of statistics and histogram display *) | |
765 | module Stats = struct | |
766 | open QCheck2 | |
767 | ||
768 | let bool_dist = | |
769 | Test.make ~name:"bool dist" ~count:500_000 ~collect:Bool.to_string Gen.bool (fun _ -> true) | |
770 | ||
771 | let char_dist_tests = | |
772 | [ | |
773 | Test.make ~name:"char code dist" ~count:500_000 ~stats:[("char code", Char.code)] Gen.char (fun _ -> true); | |
774 | Test.make ~name:"printable char code dist" ~count:500_000 ~stats:[("char code", Char.code)] Gen.printable (fun _ -> true); | |
775 | Test.make ~name:"numeral char code dist" ~count:500_000 ~stats:[("char code", Char.code)] Gen.numeral (fun _ -> true); | |
776 | ] | |
777 | ||
778 | let string_len_tests = | |
779 | let len = ("len",String.length) in | |
780 | [ | |
781 | Test.make ~name:"string_size len dist" ~count:5_000 ~stats:[len] Gen.(string_size (int_range 5 10)) (fun _ -> true); | |
782 | Test.make ~name:"string len dist" ~count:5_000 ~stats:[len] Gen.string (fun _ -> true); | |
783 | Test.make ~name:"string_of len dist" ~count:5_000 ~stats:[len] Gen.(string_of (return 'a')) (fun _ -> true); | |
784 | Test.make ~name:"string_printable len dist" ~count:5_000 ~stats:[len] Gen.string_printable (fun _ -> true); | |
785 | Test.make ~name:"small_string len dist" ~count:5_000 ~stats:[len] Gen.(small_string ~gen:char)(*ugh*)(fun _ -> true); | |
786 | ] | |
787 | ||
788 | let pair_dist = | |
789 | Test.make ~name:"pair dist" ~count:500_000 ~stats:[("pair sum", (fun (i,j) -> i+j))] | |
790 | Gen.(pair (int_bound 100) (int_bound 100)) (fun _ -> true) | |
791 | ||
792 | let triple_dist = | |
793 | Test.make ~name:"triple dist" ~count:500_000 ~stats:[("triple sum", (fun (i,j,k) -> i+j+k))] | |
794 | Gen.(triple (int_bound 100) (int_bound 100) (int_bound 100)) (fun _ -> true) | |
795 | ||
796 | let quad_dist = | |
797 | Test.make ~name:"quad dist" ~count:500_000 ~stats:[("quad sum", (fun (h,i,j,k) -> h+i+j+k))] | |
798 | Gen.(quad (int_bound 100) (int_bound 100) (int_bound 100) (int_bound 100)) (fun _ -> true) | |
799 | ||
800 | let bind_dist = | |
801 | Test.make ~name:"bind dist" ~count:1_000_000 | |
802 | ~stats:[("ordered pair difference", (fun (i,j) -> j-i));("ordered pair sum", (fun (i,j) -> i+j))] | |
803 | Gen.(int_bound 100 >>= fun j -> int_bound j >>= fun i -> return (i,j)) (fun _ -> true) | |
804 | ||
805 | let list_len_tests = | |
806 | let len = ("len",List.length) in | |
807 | [ (* test from issue #30 *) | |
808 | Test.make ~name:"list len dist" ~count:5_000 ~stats:[len] Gen.(list int) (fun _ -> true); | |
809 | Test.make ~name:"small_list len dist" ~count:5_000 ~stats:[len] Gen.(small_list int) (fun _ -> true); | |
810 | Test.make ~name:"list_size len dist" ~count:5_000 ~stats:[len] Gen.(list_size (int_range 5 10) int) (fun _ -> true); | |
811 | Test.make ~name:"list_repeat len dist" ~count:5_000 ~stats:[len] Gen.(list_repeat 42 int) (fun _ -> true); | |
812 | ] | |
813 | ||
814 | let array_len_tests = | |
815 | let len = ("len",Array.length) in | |
816 | [ | |
817 | Test.make ~name:"array len dist" ~count:5_000 ~stats:[len] Gen.(array int) (fun _ -> true); | |
818 | Test.make ~name:"small_array len dist" ~count:5_000 ~stats:[len] Gen.(small_array int) (fun _ -> true); | |
819 | Test.make ~name:"array_size len dist" ~count:5_000 ~stats:[len] Gen.(array_size (int_range 5 10) int) (fun _ -> true); | |
820 | Test.make ~name:"array_repeat len dist" ~count:5_000 ~stats:[len] Gen.(array_repeat 42 int) (fun _ -> true); | |
821 | ] | |
822 | ||
823 | let int_dist_tests = | |
824 | let dist = ("dist",fun x -> x) in | |
825 | [ | |
826 | (* test from issue #40 *) | |
827 | Test.make ~name:"int_stats_neg" ~count:5000 ~stats:[dist] Gen.small_signed_int (fun _ -> true); | |
828 | (* distribution tests from PR #45 *) | |
829 | Test.make ~name:"small_signed_int dist" ~count:1000 ~stats:[dist] Gen.small_signed_int (fun _ -> true); | |
830 | Test.make ~name:"small_nat dist" ~count:1000 ~stats:[dist] Gen.small_nat (fun _ -> true); | |
831 | Test.make ~name:"nat dist" ~count:1000 ~stats:[dist] Gen.nat (fun _ -> true); | |
832 | Test.make ~name:"int_range (-43643) 435434 dist" ~count:1000 ~stats:[dist] (Gen.int_range (-43643) 435434) (fun _ -> true); | |
833 | Test.make ~name:"int_range (-40000) 40000 dist" ~count:1000 ~stats:[dist] (Gen.int_range (-40000) 40000) (fun _ -> true); | |
834 | Test.make ~name:"int_range (-4) 4 dist" ~count:1000 ~stats:[dist] (Gen.int_range (-4) 4) (fun _ -> true); | |
835 | Test.make ~name:"int_range (-4) 17 dist" ~count:1000 ~stats:[dist] (Gen.int_range (-4) 17) (fun _ -> true); | |
836 | Test.make ~name:"int dist" ~count:100000 ~stats:[dist] Gen.int (fun _ -> true); | |
837 | Test.make ~name:"oneof int dist" ~count:1000 ~stats:[dist] (Gen.oneofl[min_int;-1;0;1;max_int]) (fun _ -> true); | |
838 | ] | |
839 | ||
840 | let tree_depth_test = | |
841 | let depth = ("depth", IntTree.depth) in | |
842 | Test.make ~name:"tree's depth" ~count:1000 ~stats:[depth] IntTree.gen_tree (fun _ -> true) | |
843 | ||
844 | let int_dist_empty_bucket = | |
845 | Test.make ~name:"int_dist_empty_bucket" ~count:1_000 ~stats:[("dist",fun x -> x)] | |
846 | Gen.(oneof [small_int_corners ();int]) (fun _ -> true) | |
847 | ||
848 | let tests = | |
849 | [ bool_dist; ] | |
850 | @ char_dist_tests | |
851 | @ [ tree_depth_test;] | |
852 | @ string_len_tests | |
853 | @ [pair_dist; | |
854 | triple_dist; | |
855 | quad_dist; | |
856 | bind_dist;] | |
857 | @ list_len_tests | |
858 | @ array_len_tests | |
859 | @ int_dist_tests | |
860 | end |
0 | open QCheck2 | |
1 | ||
2 | let rand_init i = Random.State.make [|i|] | |
3 | ||
4 | let rec repeated_success t = | |
5 | Tree.root t :: match Tree.children t () with | |
6 | | Seq.Nil -> [] | |
7 | | Seq.Cons (t,_) -> repeated_success t | |
8 | ||
9 | let repeated_failure t = | |
10 | Tree.root t :: match Tree.children t () with | |
11 | | Seq.Nil -> [] | |
12 | | Seq.Cons (t,ts) -> Tree.root t :: (Seq.map Tree.root ts |> List.of_seq) | |
13 | ||
14 | ||
15 | module Shrink = struct | |
16 | let test_int_towards () = | |
17 | Alcotest.(check' (list int)) | |
18 | ~msg:"int_towards 0 100" | |
19 | ~actual:(Shrink.int_towards 0 100 |> List.of_seq) | |
20 | ~expected:[0; 50; 75; 88; 94; 97; 99]; | |
21 | Alcotest.(check' (list int)) | |
22 | ~msg:"int_towards 500 1000" | |
23 | ~actual:(Shrink.int_towards 500 1000 |> List.of_seq) | |
24 | ~expected:[500; 750; 875; 938; 969; 985; 993; 997; 999]; | |
25 | Alcotest.(check' (list int)) | |
26 | ~msg:"int_towards (-50) (-26)" | |
27 | ~actual:(Shrink.int_towards (-50) (-26) |> List.of_seq) | |
28 | ~expected:[-50; -38; -32; -29; -28; -27] | |
29 | ||
30 | let test_int32_towards () = | |
31 | Alcotest.(check' (list int32)) | |
32 | ~msg:"int32_towards 0l 100l" | |
33 | ~actual:(Shrink.int32_towards 0l 100l |> List.of_seq) | |
34 | ~expected:[0l; 50l; 75l; 88l; 94l; 97l; 99l]; | |
35 | Alcotest.(check' (list int32)) | |
36 | ~msg:"int32_towards 500l 1000l" | |
37 | ~actual:(Shrink.int32_towards 500l 1000l |> List.of_seq) | |
38 | ~expected:[500l; 750l; 875l; 938l; 969l; 985l; 993l; 997l; 999l]; | |
39 | Alcotest.(check' (list int32)) | |
40 | ~msg:"int32_towards (-50l) (-26l)" | |
41 | ~actual:(Shrink.int32_towards (-50l) (-26l) |> List.of_seq) | |
42 | ~expected:[-50l; -38l; -32l; -29l; -28l; -27l] | |
43 | ||
44 | let test_int64_towards () = | |
45 | Alcotest.(check' (list int64)) | |
46 | ~msg:"int64_towards 0L 100L" | |
47 | ~actual:(Shrink.int64_towards 0L 100L |> List.of_seq) | |
48 | ~expected:[0L; 50L; 75L; 88L; 94L; 97L; 99L]; | |
49 | Alcotest.(check' (list int64)) | |
50 | ~msg:"int64_towards 500L 1000L" | |
51 | ~actual:(Shrink.int64_towards 500L 1000L |> List.of_seq) | |
52 | ~expected:[500L; 750L; 875L; 938L; 969L; 985L; 993L; 997L; 999L]; | |
53 | Alcotest.(check' (list int64)) | |
54 | ~msg:"int64_towards (-50L) (-26L)" | |
55 | ~actual:(Shrink.int64_towards (-50L) (-26L) |> List.of_seq) | |
56 | ~expected:[-50L; -38L; -32L; -29L; -28L; -27L] | |
57 | ||
58 | let test_float_towards () = | |
59 | Alcotest.(check' (list (float 0.0001))) | |
60 | ~msg:"float_towards 0. 100." | |
61 | ~actual:(Shrink.float_towards 0. 100. |> List.of_seq) | |
62 | ~expected:[0.; 50.; 75.; 87.5; 93.75; 96.875; 98.4375; 99.2188; 99.6094; 99.8047; 99.9023; 99.9512; 99.9756; 99.9878; 99.9939]; | |
63 | Alcotest.(check' (list (float 0.001))) | |
64 | ~msg:"float_towards 500. 1000." | |
65 | ~actual:(Shrink.float_towards 500. 1000. |> List.of_seq) | |
66 | ~expected:[500.; 750.; 875.; 937.5; 968.75; 984.375; 992.188; 996.094; 998.047; 999.023; 999.512; 999.756; 999.878; 999.939; 999.969]; | |
67 | Alcotest.(check' (list (float 0.0001))) | |
68 | ~msg:"float_towards (-50.) (-26.)" | |
69 | ~actual:(Shrink.float_towards (-50.) (-26.) |> List.of_seq) | |
70 | ~expected:[-50.; -38.; -32.; -29.; -27.5; -26.75; -26.375; -26.1875; -26.0938; -26.0469; -26.0234; -26.0117; -26.0059; -26.0029; -26.0015] | |
71 | ||
72 | let test_char () = | |
73 | Alcotest.(check' (list char)) | |
74 | ~msg:"'k' on repeated failure" | |
75 | ~actual:(Gen.(generate_tree ~rand:(rand_init 1234) char) |> repeated_failure) | |
76 | ~expected:['k'; 'a'; 'f'; 'h'; 'i'; 'j']; | |
77 | Alcotest.(check' (list char)) | |
78 | ~msg:"'1' on repeated failure" | |
79 | ~actual:(Gen.(generate_tree ~rand:(rand_init 3345) char) |> repeated_failure) | |
80 | ~expected:['1'; 'a'; 'I'; '='; '7'; '4'; '2']; | |
81 | Alcotest.(check' (list char)) | |
82 | ~msg:"'k' on repeated success" | |
83 | ~actual:(Gen.(generate_tree ~rand:(rand_init 1234) char) |> repeated_success) | |
84 | ~expected:['k'; 'a';]; | |
85 | Alcotest.(check' (list char)) | |
86 | ~msg:"'1' on repeated success" | |
87 | ~actual:(Gen.(generate_tree ~rand:(rand_init 3345) char) |> repeated_success) | |
88 | ~expected:['1'; 'a';] | |
89 | ||
90 | let test_char_numeral () = | |
91 | Alcotest.(check' (list char)) | |
92 | ~msg:"'3' on repeated failure" | |
93 | ~actual:(Gen.(generate_tree ~rand:(rand_init 1234) numeral) |> repeated_failure) | |
94 | ~expected:['3'; '0'; '1'; '2']; | |
95 | Alcotest.(check' (list char)) | |
96 | ~msg:"'0' on repeated failure" | |
97 | ~actual:(Gen.(generate_tree ~rand:(rand_init 3346) numeral) |> repeated_failure) | |
98 | ~expected:['0']; | |
99 | Alcotest.(check' (list char)) | |
100 | ~msg:"'3' on repeated success" | |
101 | ~actual:(Gen.(generate_tree ~rand:(rand_init 1234) numeral) |> repeated_success) | |
102 | ~expected:['3'; '0';]; | |
103 | Alcotest.(check' (list char)) | |
104 | ~msg:"'0' on repeated success" | |
105 | ~actual:(Gen.(generate_tree ~rand:(rand_init 3346) numeral) |> repeated_success) | |
106 | ~expected:['0';] | |
107 | ||
108 | let test_char_printable () = | |
109 | Alcotest.(check' (list char)) | |
110 | ~msg:"'l' on repeated failure" | |
111 | ~actual:(Gen.(generate_tree ~rand:(rand_init 1234) printable) |> repeated_failure) | |
112 | ~expected:['l'; 'a'; 'f'; 'i'; 'j'; 'k']; | |
113 | Alcotest.(check' (list char)) | |
114 | ~msg:"'8' on repeated failure" | |
115 | ~actual:(Gen.(generate_tree ~rand:(rand_init 3346) printable) |> repeated_failure) | |
116 | ~expected:['8'; 'a'; 'z'; ','; '2'; '5'; '7']; | |
117 | Alcotest.(check' (list char)) | |
118 | ~msg:"'l' on repeated success" | |
119 | ~actual:(Gen.(generate_tree ~rand:(rand_init 1234) printable) |> repeated_success) | |
120 | ~expected:['l'; 'a';]; | |
121 | Alcotest.(check' (list char)) | |
122 | ~msg:"'8' on repeated success" | |
123 | ~actual:(Gen.(generate_tree ~rand:(rand_init 3346) printable) |> repeated_success) | |
124 | ~expected:['8'; 'a';] | |
125 | ||
126 | let tests = ("Shrink", Alcotest.[ | |
127 | test_case "int_towards" `Quick test_int_towards; | |
128 | test_case "int32_towards" `Quick test_int32_towards; | |
129 | test_case "int64_towards" `Quick test_int64_towards; | |
130 | test_case "float_towards" `Quick test_float_towards; | |
131 | test_case "Gen.char tree" `Quick test_char; | |
132 | test_case "Gen.numeral tree" `Quick test_char_numeral; | |
133 | test_case "Gen.printable tree" `Quick test_char_printable; | |
134 | ]) | |
135 | end | |
136 | ||
137 | module Gen = struct | |
138 | let test_gen_option ~ratio = | |
139 | let opt_int = Gen.option ?ratio Gen.int in | |
140 | let nb = ref 0 in | |
141 | for _i = 0 to 1000 do | |
142 | Gen.generate1 opt_int |> function None -> () | Some _ -> nb := !nb + 1 | |
143 | done; | |
144 | !nb | |
145 | ||
146 | let test_gen_option_default () = | |
147 | let nb = test_gen_option ~ratio:None in | |
148 | let b = nb > 800 && nb < 900 in | |
149 | Alcotest.(check bool) "Gen.option produces around 85% of Some" b true | |
150 | ||
151 | let test_gen_option_custom () = | |
152 | let nb = test_gen_option ~ratio:(Some 0.5) in | |
153 | let b = nb > 450 && nb < 550 in | |
154 | Alcotest.(check bool) "Gen.option produces around 50% of Some" b true | |
155 | ||
156 | let tests = | |
157 | ("Gen", Alcotest.[ | |
158 | test_case "option with default ratio" `Quick test_gen_option_default; | |
159 | test_case "option with custom ratio" `Quick test_gen_option_custom; | |
160 | ]) | |
161 | end | |
162 | ||
163 | module TestCount = struct | |
164 | let test_count_n ?count expected = | |
165 | let t = QCheck2.(Test.make ?count Gen.int (fun _ -> true)) in | |
166 | let msg = Printf.sprintf "QCheck2.Test.make ~count:%s |> get_count = %d" | |
167 | (Option.fold ~none:"None" ~some:string_of_int count) expected | |
168 | in | |
169 | Alcotest.(check int) msg expected (QCheck2.Test.test_get_count t) | |
170 | ||
171 | let test_count_10 () = test_count_n ~count:10 10 | |
172 | ||
173 | let test_count_default () = test_count_n 100 | |
174 | ||
175 | let test_count_env () = | |
176 | let () = Unix.putenv "QCHECK_COUNT" "5" in | |
177 | let t = QCheck2.(Test.make Gen.int (fun _ -> true)) in | |
178 | let actual = QCheck2.Test.test_get_count t in | |
179 | Alcotest.(check int) "default count is from QCHECK_COUNT" 5 actual | |
180 | ||
181 | let test_count_0 () = test_count_n ~count:0 0 | |
182 | ||
183 | let test_count_negative_fail () = | |
184 | try | |
185 | let _ = test_count_n ~count:(-1) (-1) in | |
186 | Alcotest.fail "A negative count in a test should fail" | |
187 | with | |
188 | | _ -> () | |
189 | ||
190 | let tests = | |
191 | ("Test.make ~count", Alcotest.[ | |
192 | test_case "make with custom count" `Quick test_count_10; | |
193 | test_case "make with default count" `Quick test_count_default; | |
194 | test_case "make with env count" `Quick test_count_env; | |
195 | test_case "make with 0 count" `Quick test_count_0; | |
196 | test_case "make with negative count should fail" | |
197 | `Quick test_count_negative_fail; | |
198 | ]) | |
199 | end | |
200 | ||
201 | module TestLongFactor = struct | |
202 | let test_long_factor_n ?long_factor expected = | |
203 | let t = QCheck2.(Test.make ?long_factor Gen.int (fun _ -> true)) in | |
204 | let msg = Printf.sprintf "QCheck2.Test.make ~long_factor:%s |> long_factor = %d" | |
205 | (Option.fold ~none:"None" ~some:string_of_int long_factor) expected | |
206 | in | |
207 | Alcotest.(check int) msg expected (QCheck2.Test.test_get_long_factor t) | |
208 | ||
209 | let test_long_factor_10 () = test_long_factor_n ~long_factor:10 10 | |
210 | ||
211 | let test_long_factor_default () = test_long_factor_n 1 | |
212 | ||
213 | let test_long_factor_env () = | |
214 | let () = Unix.putenv "QCHECK_LONG_FACTOR" "5" in | |
215 | let t = QCheck2.(Test.make Gen.int (fun _ -> true)) in | |
216 | let actual = QCheck2.Test.test_get_long_factor t in | |
217 | Alcotest.(check int) "default long factor is from QCHECK_LONG_FACTOR" 5 actual | |
218 | ||
219 | let test_long_factor_0 () = test_long_factor_n ~long_factor:0 0 | |
220 | ||
221 | let test_long_factor_negative_fail () = | |
222 | try | |
223 | let _ = test_long_factor_n ~long_factor:(-1) (-1) in | |
224 | Alcotest.fail "A negative long factor in a test should fail" | |
225 | with | |
226 | | _ -> () | |
227 | ||
228 | let tests = | |
229 | ("Test.make ~long_factor", Alcotest.[ | |
230 | test_case "make with custom long_factor" `Quick test_long_factor_10; | |
231 | test_case "make with default long_factor" `Quick test_long_factor_default; | |
232 | test_case "make with env long_factor" `Quick test_long_factor_env; | |
233 | test_case "make with 0 long_factor" `Quick test_long_factor_0; | |
234 | test_case "make with negative long_factor fail should" | |
235 | `Quick test_long_factor_negative_fail; | |
236 | ]) | |
237 | end | |
238 | ||
239 | module String = struct | |
240 | ||
241 | let test_string_shrinking () = | |
242 | let shrink_result = QCheck2.(find_example_gen ~f:(fun s -> s <> s ^ s) Gen.string) in | |
243 | Alcotest.(check string) "Shrinking a non-empty string shrinks to \"a\"" "a" shrink_result | |
244 | ||
245 | let tests = ("String", Alcotest.[test_case "shrinking" `Quick test_string_shrinking]) | |
246 | end | |
247 | ||
248 | module Check_exn = struct | |
249 | ||
250 | (* String.starts_with was introduced in 4.13. | |
251 | Include the below to support pre-4.13 OCaml. *) | |
252 | let string_starts_with ~prefix s = | |
253 | let open Stdlib in | |
254 | let prefix_len = String.length prefix in | |
255 | prefix_len <= String.length s | |
256 | && prefix = String.sub s 0 prefix_len | |
257 | ||
258 | let check_exn = Test.check_exn | |
259 | ||
260 | let test_pass_trivial () = | |
261 | let run_test () = check_exn QCheck2.(Test.make Gen.int (fun _ -> true)) in | |
262 | Alcotest.(check unit) "Success-trivial" () @@ run_test () | |
263 | ||
264 | let test_pass_random () = | |
265 | let run_test () = | |
266 | check_exn QCheck2.(Test.make Gen.(list int) (fun l -> List.rev (List.rev l) = l)) in | |
267 | Alcotest.(check unit) "Success-random" () @@ run_test () | |
268 | ||
269 | let test_fail_always () = | |
270 | let name = "will-always-fail" in | |
271 | try | |
272 | check_exn QCheck2.(Test.make ~name ~print:Print.int Gen.int (fun _ -> false)); | |
273 | Alcotest.failf "%s: Unexpected success" name | |
274 | with | |
275 | (Test.Test_fail (n,[c_ex_str])) -> | |
276 | Alcotest.(check string) (Printf.sprintf "%s: name" name) n name; | |
277 | if not (string_starts_with ~prefix:"0" c_ex_str) | |
278 | then | |
279 | Alcotest.failf "%s: counter-example prefix. Received: \"%s\"" name c_ex_str | |
280 | ||
281 | let test_fail_random () = | |
282 | let name = "list is own reverse" in | |
283 | try | |
284 | check_exn | |
285 | QCheck2.(Test.make ~name ~print:Print.(list int) | |
286 | Gen.(list int) (fun l -> List.rev l = l)); | |
287 | Alcotest.failf "%s: Unexpected success" name | |
288 | with | |
289 | (Test.Test_fail (n,[c_ex_str])) -> | |
290 | Alcotest.(check string) (Printf.sprintf "%s: name" name) n name; | |
291 | if not (string_starts_with ~prefix:"[0; 1]" c_ex_str) | |
292 | then | |
293 | Alcotest.failf "%s: counter-example prefix. Received \"%s\"" name c_ex_str | |
294 | ||
295 | exception MyError | |
296 | ||
297 | let test_error () = | |
298 | let name = "will-always-error" in | |
299 | try | |
300 | Printexc.record_backtrace false; (* for easier pattern-matching below *) | |
301 | check_exn QCheck2.(Test.make ~name ~print:Print.int Gen.int (fun _ -> raise MyError)); | |
302 | Alcotest.failf "%s: Unexpected success" name | |
303 | with | |
304 | (Test.Test_error (n,c_ex_str,MyError,"")) -> | |
305 | Alcotest.(check string) (Printf.sprintf "%s: name" name) n name; | |
306 | if not (string_starts_with ~prefix:"0" c_ex_str) | |
307 | then | |
308 | Alcotest.failf "%s: counter-example prefix. Received \"%s\"" name c_ex_str | |
309 | ||
310 | let tests = | |
311 | ("Test.check_exn", Alcotest.[ | |
312 | test_case "check_exn pass trivial" `Quick test_pass_trivial; | |
313 | test_case "check_exn pass random" `Quick test_pass_random; | |
314 | test_case "check_exn fail always" `Quick test_fail_always; | |
315 | test_case "check_exn fail random" `Quick test_fail_random; | |
316 | test_case "check_exn Error" `Quick test_error; | |
317 | ]) | |
318 | end | |
319 | ||
320 | let () = | |
321 | Alcotest.run "QCheck2" | |
322 | [ | |
323 | Shrink.tests; | |
324 | Gen.tests; | |
325 | TestCount.tests; | |
326 | TestLongFactor.tests; | |
327 | String.tests; | |
328 | Check_exn.tests; | |
329 | ] |
0 | random seed: 1234 | |
1 | 50 7 4 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 (6,fun,50) (0,fun,2) (7,fun,66) (54,fun,9) (2,fun,5) (90,fun,4) (1,fun,4) (37,fun,7) (7,fun,1) (8,fun,5) | |
2 | (6,fun,50) (0,fun,2) (7,fun,66) (54,fun,9) (2,fun,5) (90,fun,4) (1,fun,4) (37,fun,7) (7,fun,1) (8,fun,5) | |
3 | (6,fun,50) (0,fun,2) (7,fun,66) (54,fun,9) (2,fun,5) (90,fun,4) (1,fun,4) (37,fun,7) (7,fun,1) (8,fun,5) | |
4 | (6,fun,50) (0,fun,2) (7,fun,66) (54,fun,9) (2,fun,5) (90,fun,4) (1,fun,4) (37,fun,7) (7,fun,1) (8,fun,5) | |
5 | (6,fun,50) (0,fun,2) (7,fun,66) (54,fun,9) (2,fun,5) (90,fun,4) (1,fun,4) (37,fun,7) (7,fun,1) (8,fun,5) | |
6 | (6,fun,50) (0,fun,2) (7,fun,66) (54,fun,9) (2,fun,5) (90,fun,4) (1,fun,4) (37,fun,7) (7,fun,1) (8,fun,5) | |
7 | (6,fun,50) (0,fun,2) (7,fun,66) (54,fun,9) (2,fun,5) (90,fun,4) (1,fun,4) (37,fun,7) (7,fun,1) (8,fun,5) | |
8 | (6,fun,50) (0,fun,2) (7,fun,66) (54,fun,9) (2,fun,5) (90,fun,4) (1,fun,4) (37,fun,7) (7,fun,1) (8,fun,5) | |
9 | 911769578 | |
10 | 455884789 | |
11 | 227942395 | |
12 | 113971198 | |
13 | 56985599 | |
14 | 28492800 | |
15 | 14246400 | |
16 | 7123200 | |
17 | 3561600 | |
18 | 1780800 | |
19 | 890400 | |
20 | 445200 | |
21 | 222600 | |
22 | 111300 | |
23 | 55650 | |
24 | 27825 | |
25 | 13913 | |
26 | 6957 | |
27 | 3479 | |
28 | 1740 | |
29 | 870 | |
30 | 435 | |
31 | 218 | |
32 | 109 | |
33 | 55 | |
34 | 28 | |
35 | 14 | |
36 | 7 | |
37 | 4 | |
38 | 2 | |
39 | 1 | |
40 | 0 | |
41 | [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] | |
42 | [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] | |
43 | [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] | |
44 | [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] | |
45 | [7; 1; 42; 1; 8; 5; 3; 9; 5; 38; 3; 3; 0; 1; 98; 1] | |
46 | [7; 1; 42; 1; 8; 5; 3; 9] | |
47 | [7; 1; 42; 1] | |
48 | [7; 1] | |
49 | [] | |
50 | [7] | |
51 | [] | |
52 | [4] | |
53 | [] | |
54 | [2] | |
55 | [] | |
56 | [1] | |
57 | [] | |
58 | [0] | |
59 | [] | |
60 | [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] | |
61 | [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] | |
62 | [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] | |
63 | [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] | |
64 | [7; 1; 42; 1; 8; 5; 3; 9; 5; 38; 3; 3; 0; 1; 98; 1] | |
65 | [7; 1; 42; 1; 8; 5; 3; 9] | |
66 | [7; 1; 42; 1] | |
67 | [7; 1] | |
68 | [42; 1] | |
69 | [7; 42; 1] | |
70 | [1; 42; 1] | |
71 | [1; 42] | |
72 | [1] | |
73 | [1; 1] | |
74 | [] | |
75 | [1] | |
76 | [1] | |
77 | [0; 1] | |
78 | [1; 0] | |
79 | ||
80 | --- Failure -------------------------------------------------------------------- | |
81 | ||
82 | Test should_fail_sort_id failed (13 shrink steps): | |
83 | ||
84 | [1; 0] | |
85 | ||
86 | === Error ====================================================================== | |
87 | ||
88 | Test should_error_raise_exn errored on (31 shrink steps): | |
89 | ||
90 | 0 | |
91 | ||
92 | exception QCheck_tests.Overall.Error | |
93 | ||
94 | ||
95 | +++ Collect ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
96 | ||
97 | Collect results for test collect_results: | |
98 | ||
99 | 4: 20 cases | |
100 | 3: 25 cases | |
101 | 2: 17 cases | |
102 | 1: 18 cases | |
103 | 0: 20 cases | |
104 | ||
105 | +++ Stats for with_stats ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
106 | ||
107 | stats mod4: | |
108 | num: 100, avg: 1.68, stddev: 1.09, median 2, min 0, max 3 | |
109 | 0: ############################## 17 | |
110 | 1: ################################################### 29 | |
111 | 2: ######################################## 23 | |
112 | 3: ####################################################### 31 | |
113 | ||
114 | stats num: | |
115 | num: 100, avg: 66.84, stddev: 31.94, median 65, min 2, max 120 | |
116 | 2.. 7: ################## 3 | |
117 | 8.. 13: ################## 3 | |
118 | 14.. 19: 0 | |
119 | 20.. 25: ########################################## 7 | |
120 | 26.. 31: ######################## 4 | |
121 | 32.. 37: ######################## 4 | |
122 | 38.. 43: ################## 3 | |
123 | 44.. 49: ################################################ 8 | |
124 | 50.. 55: #################################### 6 | |
125 | 56.. 61: #################################### 6 | |
126 | 62.. 67: ####################################################### 9 | |
127 | 68.. 73: ########################################## 7 | |
128 | 74.. 79: ######################## 4 | |
129 | 80.. 85: ################## 3 | |
130 | 86.. 91: ############ 2 | |
131 | 92.. 97: ########################################## 7 | |
132 | 98..103: #################################### 6 | |
133 | 104..109: #################################### 6 | |
134 | 110..115: ####################################################### 9 | |
135 | 116..121: ################## 3 | |
136 | ||
137 | --- Failure -------------------------------------------------------------------- | |
138 | ||
139 | Test with shrinking retries failed (1 shrink steps): | |
140 | ||
141 | 4 | |
142 | ||
143 | !!! Warning !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
144 | ||
145 | Warning for test WARN_unlikely_precond: | |
146 | ||
147 | WARNING: only 0.6% tests (of 2000) passed precondition for "WARN_unlikely_precond" | |
148 | ||
149 | NOTE: it is likely that the precondition is too strong, or that the generator is buggy. | |
150 | ||
151 | --- Failure -------------------------------------------------------------------- | |
152 | ||
153 | Test FAIL_unlikely_precond failed: | |
154 | ||
155 | ERROR: only 0.6% tests (of 2000) passed precondition for "FAIL_unlikely_precond" | |
156 | ||
157 | NOTE: it is likely that the precondition is too strong, or that the generator is buggy. | |
158 | ||
159 | ||
160 | --- Failure -------------------------------------------------------------------- | |
161 | ||
162 | Test FAIL_bad_gen failed: | |
163 | ||
164 | ERROR: uncaught exception in generator for test FAIL_bad_gen after 100 steps: | |
165 | Exception: Invalid_argument("Gen.int_bound") | |
166 | Backtrace: | |
167 | ||
168 | --- Failure -------------------------------------------------------------------- | |
169 | ||
170 | Test int double failed: | |
171 | ||
172 | Negative test int double succeeded but was expected to fail | |
173 | ||
174 | === Error ====================================================================== | |
175 | ||
176 | Test pos fail with error errored on (7 shrink steps): | |
177 | ||
178 | 0 | |
179 | ||
180 | exception QCheck_tests.Overall.Error | |
181 | ||
182 | ||
183 | === Error ====================================================================== | |
184 | ||
185 | Test neg fail with error errored on (7 shrink steps): | |
186 | ||
187 | 0 | |
188 | ||
189 | exception QCheck_tests.Overall.Error | |
190 | ||
191 | ||
192 | --- Failure -------------------------------------------------------------------- | |
193 | ||
194 | Test char never produces '\255' failed (0 shrink steps): | |
195 | ||
196 | '\255' | |
197 | ||
198 | --- Failure -------------------------------------------------------------------- | |
199 | ||
200 | Test big bound issue59 failed (20 shrink steps): | |
201 | ||
202 | 209609 | |
203 | ||
204 | --- Failure -------------------------------------------------------------------- | |
205 | ||
206 | Test long_shrink failed (87 shrink steps): | |
207 | ||
208 | ([0], [-1]) | |
209 | ||
210 | --- Failure -------------------------------------------------------------------- | |
211 | ||
212 | Test ints arent 0 mod 3 failed (34 shrink steps): | |
213 | ||
214 | -21 | |
215 | ||
216 | --- Failure -------------------------------------------------------------------- | |
217 | ||
218 | Test ints are 0 failed (30 shrink steps): | |
219 | ||
220 | 1 | |
221 | ||
222 | --- Failure -------------------------------------------------------------------- | |
223 | ||
224 | Test ints < 209609 failed (20 shrink steps): | |
225 | ||
226 | 209609 | |
227 | ||
228 | --- Failure -------------------------------------------------------------------- | |
229 | ||
230 | Test nat < 5001 failed (6 shrink steps): | |
231 | ||
232 | 5001 | |
233 | ||
234 | --- Failure -------------------------------------------------------------------- | |
235 | ||
236 | Test char never produces 'abcdef' failed (3 shrink steps): | |
237 | ||
238 | 'a' | |
239 | ||
240 | --- Failure -------------------------------------------------------------------- | |
241 | ||
242 | Test printable never produces '!"#$%&' failed (2 shrink steps): | |
243 | ||
244 | '&' | |
245 | ||
246 | --- Failure -------------------------------------------------------------------- | |
247 | ||
248 | Test printable never produces less than '5 failed (3 shrink steps): | |
249 | ||
250 | '0' | |
251 | ||
252 | --- Failure -------------------------------------------------------------------- | |
253 | ||
254 | Test strings are empty failed (15 shrink steps): | |
255 | ||
256 | "a" | |
257 | ||
258 | --- Failure -------------------------------------------------------------------- | |
259 | ||
260 | Test string never has a \000 char failed (8 shrink steps): | |
261 | ||
262 | "\000" | |
263 | ||
264 | --- Failure -------------------------------------------------------------------- | |
265 | ||
266 | Test string never has a \255 char failed (14 shrink steps): | |
267 | ||
268 | "\255" | |
269 | ||
270 | --- Failure -------------------------------------------------------------------- | |
271 | ||
272 | Test strings have unique chars failed (13 shrink steps): | |
273 | ||
274 | "\129\129" | |
275 | ||
276 | --- Failure -------------------------------------------------------------------- | |
277 | ||
278 | Test pairs have different components failed (0 shrink steps): | |
279 | ||
280 | (4, 4) | |
281 | ||
282 | --- Failure -------------------------------------------------------------------- | |
283 | ||
284 | Test pairs have same components failed (60 shrink steps): | |
285 | ||
286 | (0, 1) | |
287 | ||
288 | --- Failure -------------------------------------------------------------------- | |
289 | ||
290 | Test pairs have a zero component failed (59 shrink steps): | |
291 | ||
292 | (-1, 1) | |
293 | ||
294 | --- Failure -------------------------------------------------------------------- | |
295 | ||
296 | Test pairs are (0,0) failed (60 shrink steps): | |
297 | ||
298 | (0, 1) | |
299 | ||
300 | --- Failure -------------------------------------------------------------------- | |
301 | ||
302 | Test pairs are ordered failed (214 shrink steps): | |
303 | ||
304 | (1, 0) | |
305 | ||
306 | --- Failure -------------------------------------------------------------------- | |
307 | ||
308 | Test pairs are ordered reversely failed (59 shrink steps): | |
309 | ||
310 | (0, 1) | |
311 | ||
312 | --- Failure -------------------------------------------------------------------- | |
313 | ||
314 | Test pairs sum to less than 128 failed (54 shrink steps): | |
315 | ||
316 | (0, 128) | |
317 | ||
318 | --- Failure -------------------------------------------------------------------- | |
319 | ||
320 | Test pairs lists rev concat failed (72 shrink steps): | |
321 | ||
322 | ([0], [1]) | |
323 | ||
324 | --- Failure -------------------------------------------------------------------- | |
325 | ||
326 | Test pairs lists no overlap failed (26 shrink steps): | |
327 | ||
328 | ([0], [0]) | |
329 | ||
330 | --- Failure -------------------------------------------------------------------- | |
331 | ||
332 | Test triples have pair-wise different components failed (7 shrink steps): | |
333 | ||
334 | (0, 7, 7) | |
335 | ||
336 | --- Failure -------------------------------------------------------------------- | |
337 | ||
338 | Test triples have same components failed (90 shrink steps): | |
339 | ||
340 | (0, -1, 0) | |
341 | ||
342 | --- Failure -------------------------------------------------------------------- | |
343 | ||
344 | Test triples are ordered failed (90 shrink steps): | |
345 | ||
346 | (0, -1, 0) | |
347 | ||
348 | --- Failure -------------------------------------------------------------------- | |
349 | ||
350 | Test triples are ordered reversely failed (90 shrink steps): | |
351 | ||
352 | (0, 0, 1) | |
353 | ||
354 | --- Failure -------------------------------------------------------------------- | |
355 | ||
356 | Test quadruples have pair-wise different components failed (23 shrink steps): | |
357 | ||
358 | (0, 0, 0, 0) | |
359 | ||
360 | --- Failure -------------------------------------------------------------------- | |
361 | ||
362 | Test quadruples have same components failed (119 shrink steps): | |
363 | ||
364 | (0, -1, -2, 0) | |
365 | ||
366 | --- Failure -------------------------------------------------------------------- | |
367 | ||
368 | Test quadruples are ordered failed (121 shrink steps): | |
369 | ||
370 | (0, 0, -1, 0) | |
371 | ||
372 | --- Failure -------------------------------------------------------------------- | |
373 | ||
374 | Test quadruples are ordered reversely failed (121 shrink steps): | |
375 | ||
376 | (0, 0, 0, 1) | |
377 | ||
378 | --- Failure -------------------------------------------------------------------- | |
379 | ||
380 | Test forall (a, b) in nat: a < b failed (13 shrink steps): | |
381 | ||
382 | (0, 0) | |
383 | ||
384 | --- Failure -------------------------------------------------------------------- | |
385 | ||
386 | Test forall (a, b, c) in nat: a < b < c failed (15 shrink steps): | |
387 | ||
388 | (0, 0, 0) | |
389 | ||
390 | --- Failure -------------------------------------------------------------------- | |
391 | ||
392 | Test forall (a, b, c, d) in nat: a < b < c < d failed (23 shrink steps): | |
393 | ||
394 | (0, 0, 0, 0) | |
395 | ||
396 | --- Failure -------------------------------------------------------------------- | |
397 | ||
398 | Test forall (a, b, c, d, e) in nat: a < b < c < d < e failed (28 shrink steps): | |
399 | ||
400 | (0, 0, 0, 0, 0) | |
401 | ||
402 | --- Failure -------------------------------------------------------------------- | |
403 | ||
404 | Test forall (a, b, c, d, e, f) in nat: a < b < c < d < e < f failed (30 shrink steps): | |
405 | ||
406 | (0, 0, 0, 0, 0, 0) | |
407 | ||
408 | --- Failure -------------------------------------------------------------------- | |
409 | ||
410 | Test forall (a, b, c, d, e, f, g) in nat: a < b < c < d < e < f < g failed (31 shrink steps): | |
411 | ||
412 | (0, 0, 0, 0, 0, 0, 0) | |
413 | ||
414 | --- Failure -------------------------------------------------------------------- | |
415 | ||
416 | Test forall (a, b, c, d, e, f, g, h) in nat: a < b < c < d < e < f < g < h failed (35 shrink steps): | |
417 | ||
418 | (0, 0, 0, 0, 0, 0, 0, 0) | |
419 | ||
420 | --- Failure -------------------------------------------------------------------- | |
421 | ||
422 | Test forall (a, b, c, d, e, f, g, h, i) in nat: a < b < c < d < e < f < g < h < i failed (42 shrink steps): | |
423 | ||
424 | (0, 0, 0, 0, 0, 0, 0, 0, 0) | |
425 | ||
426 | --- Failure -------------------------------------------------------------------- | |
427 | ||
428 | Test bind ordered pairs failed (61 shrink steps): | |
429 | ||
430 | (0, 0) | |
431 | ||
432 | --- Failure -------------------------------------------------------------------- | |
433 | ||
434 | Test bind list_size constant failed (49 shrink steps): | |
435 | ||
436 | (4, [0; 0; 0; 0]) | |
437 | ||
438 | --- Failure -------------------------------------------------------------------- | |
439 | ||
440 | Test lists are empty failed (12 shrink steps): | |
441 | ||
442 | [0] | |
443 | ||
444 | --- Failure -------------------------------------------------------------------- | |
445 | ||
446 | Test lists shorter than 10 failed (39 shrink steps): | |
447 | ||
448 | [0; 0; 0; 0; 0; 0; 0; 0; 0; 0] | |
449 | ||
450 | --- Failure -------------------------------------------------------------------- | |
451 | ||
452 | Test lists shorter than 432 failed (1632 shrink steps): | |
453 | ||
454 | [...] list length: 432 | |
455 | ||
456 | --- Failure -------------------------------------------------------------------- | |
457 | ||
458 | Test lists shorter than 4332 failed (13 shrink steps): | |
459 | ||
460 | [...] list length: 4332 | |
461 | ||
462 | --- Failure -------------------------------------------------------------------- | |
463 | ||
464 | Test lists have unique elems failed (8 shrink steps): | |
465 | ||
466 | [1; 1] | |
467 | ||
468 | --- Failure -------------------------------------------------------------------- | |
469 | ||
470 | Test tree contains only 42 failed (10 shrink steps): | |
471 | ||
472 | Leaf 0 | |
473 | ||
474 | --- Failure -------------------------------------------------------------------- | |
475 | ||
476 | Test fail_pred_map_commute failed (47 shrink steps): | |
477 | ||
478 | ([1], {_ -> 0}, {0 -> false; _ -> true}) | |
479 | ||
480 | --- Failure -------------------------------------------------------------------- | |
481 | ||
482 | Test fail_pred_strings failed (1 shrink steps): | |
483 | ||
484 | {some other string -> false; _ -> true} | |
485 | ||
486 | --- Failure -------------------------------------------------------------------- | |
487 | ||
488 | Test fold_left fold_right failed (34 shrink steps): | |
489 | ||
490 | (0, [1], {(1, 0) -> 1; _ -> 0}) | |
491 | ||
492 | +++ Messages ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
493 | ||
494 | Messages for test fold_left fold_right: | |
495 | ||
496 | l=[1], fold_left=1, fold_right=0 | |
497 | ||
498 | ||
499 | --- Failure -------------------------------------------------------------------- | |
500 | ||
501 | Test fold_left fold_right uncurried failed (44 shrink steps): | |
502 | ||
503 | ({(0, 7) -> 1; _ -> 0}, 0, [7]) | |
504 | ||
505 | --- Failure -------------------------------------------------------------------- | |
506 | ||
507 | Test fold_left fold_right uncurried fun last failed (34 shrink steps): | |
508 | ||
509 | (0, [1], {(1, 0) -> 1; _ -> 0}) | |
510 | ||
511 | --- Failure -------------------------------------------------------------------- | |
512 | ||
513 | Test fold_left test, fun first failed (36 shrink steps): | |
514 | ||
515 | ({_ -> ""}, "a", [], [0]) | |
516 | ||
517 | --- Failure -------------------------------------------------------------------- | |
518 | ||
519 | Test FAIL_#99_1 failed: | |
520 | ||
521 | ERROR: uncaught exception in generator for test FAIL_#99_1 after 100 steps: | |
522 | Exception: QCheck.No_example_found("<example>") | |
523 | Backtrace: | |
524 | ||
525 | +++ Collect ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
526 | ||
527 | Collect results for test bool dist: | |
528 | ||
529 | true: 250134 cases | |
530 | false: 249866 cases | |
531 | ||
532 | +++ Stats for char code dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
533 | ||
534 | stats char code: | |
535 | num: 500000, avg: 127.42, stddev: 73.92, median 127, min 0, max 255 | |
536 | 0.. 12: ###################################################### 25509 | |
537 | 13.. 25: ###################################################### 25398 | |
538 | 26.. 38: ###################################################### 25293 | |
539 | 39.. 51: ###################################################### 25448 | |
540 | 52.. 64: ###################################################### 25392 | |
541 | 65.. 77: ####################################################### 25660 | |
542 | 78.. 90: ###################################################### 25462 | |
543 | 91..103: ###################################################### 25331 | |
544 | 104..116: ##################################################### 25129 | |
545 | 117..129: ###################################################### 25351 | |
546 | 130..142: ###################################################### 25492 | |
547 | 143..155: ###################################################### 25370 | |
548 | 156..168: ###################################################### 25658 | |
549 | 169..181: ###################################################### 25400 | |
550 | 182..194: ##################################################### 25167 | |
551 | 195..207: ###################################################### 25338 | |
552 | 208..220: ##################################################### 25181 | |
553 | 221..233: ##################################################### 25145 | |
554 | 234..246: ###################################################### 25567 | |
555 | 247..259: ##################################### 17709 | |
556 | ||
557 | +++ Stats for printable char code dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
558 | ||
559 | stats char code: | |
560 | num: 500000, avg: 77.76, stddev: 27.92, median 78, min 10, max 125 | |
561 | 10.. 15: ######### 5392 | |
562 | 16.. 21: 0 | |
563 | 22.. 27: 0 | |
564 | 28.. 33: ################## 10661 | |
565 | 34.. 39: ###################################################### 31788 | |
566 | 40.. 45: ###################################################### 31217 | |
567 | 46.. 51: ####################################################### 31790 | |
568 | 52.. 57: ###################################################### 31625 | |
569 | 58.. 63: ###################################################### 31421 | |
570 | 64.. 69: ###################################################### 31732 | |
571 | 70.. 75: ###################################################### 31446 | |
572 | 76.. 81: ###################################################### 31382 | |
573 | 82.. 87: ###################################################### 31623 | |
574 | 88.. 93: ###################################################### 31730 | |
575 | 94.. 99: ##################################################### 31193 | |
576 | 100..105: ###################################################### 31424 | |
577 | 106..111: ###################################################### 31675 | |
578 | 112..117: ###################################################### 31651 | |
579 | 118..123: ###################################################### 31682 | |
580 | 124..129: ################## 10568 | |
581 | ||
582 | +++ Stats for numeral char code dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
583 | ||
584 | stats char code: | |
585 | num: 500000, avg: 52.50, stddev: 2.87, median 52, min 48, max 57 | |
586 | 48: ###################################################### 50260 | |
587 | 49: ###################################################### 49590 | |
588 | 50: ###################################################### 50170 | |
589 | 51: ####################################################### 50270 | |
590 | 52: ###################################################### 49805 | |
591 | 53: ###################################################### 50161 | |
592 | 54: ###################################################### 49919 | |
593 | 55: ###################################################### 49971 | |
594 | 56: ###################################################### 49980 | |
595 | 57: ###################################################### 49874 | |
596 | ||
597 | +++ Stats for tree's depth ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
598 | ||
599 | stats depth: | |
600 | num: 1000, avg: 3.74, stddev: 3.28, median 3, min 1, max 15 | |
601 | 1: ####################################################### 377 | |
602 | 2: ################ 113 | |
603 | 3: ############ 87 | |
604 | 4: ################# 123 | |
605 | 5: ########### 81 | |
606 | 6: #### 33 | |
607 | 7: ##### 40 | |
608 | 8: ##### 39 | |
609 | 9: # 9 | |
610 | 10: ### 25 | |
611 | 11: ####### 49 | |
612 | 12: 4 | |
613 | 13: # 9 | |
614 | 14: # 7 | |
615 | 15: 4 | |
616 | ||
617 | +++ Stats for range_subset_spec ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
618 | ||
619 | stats dist: | |
620 | num: 5000, avg: 9.97, stddev: 6.08, median 10, min 0, max 20 | |
621 | 0: ################################################# 246 | |
622 | 1: ################################################ 244 | |
623 | 2: ################################################ 240 | |
624 | 3: ################################################ 243 | |
625 | 4: ############################################## 232 | |
626 | 5: ############################################## 230 | |
627 | 6: ############################################### 239 | |
628 | 7: ############################################### 235 | |
629 | 8: ####################################################### 274 | |
630 | 9: ############################################## 233 | |
631 | 10: ########################################## 212 | |
632 | 11: ############################################## 231 | |
633 | 12: ############################################### 239 | |
634 | 13: ############################################# 226 | |
635 | 14: ############################################# 225 | |
636 | 15: ################################################### 256 | |
637 | 16: ################################################ 240 | |
638 | 17: ############################################# 229 | |
639 | 18: ################################################ 243 | |
640 | 19: ################################################## 253 | |
641 | 20: ############################################## 230 | |
642 | ||
643 | +++ Stats for string_size len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
644 | ||
645 | stats len: | |
646 | num: 5000, avg: 7.49, stddev: 1.70, median 7, min 5, max 10 | |
647 | 5: ##################################################### 837 | |
648 | 6: ##################################################### 826 | |
649 | 7: ###################################################### 843 | |
650 | 8: ####################################################### 855 | |
651 | 9: #################################################### 813 | |
652 | 10: ##################################################### 826 | |
653 | ||
654 | +++ Stats for string len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
655 | ||
656 | stats len: | |
657 | num: 5000, avg: 384.53, stddev: 1330.61, median 9, min 0, max 9969 | |
658 | 0.. 498: ####################################################### 4246 | |
659 | 499.. 997: ###### 518 | |
660 | 998..1496: 21 | |
661 | 1497..1995: 10 | |
662 | 1996..2494: 11 | |
663 | 2495..2993: 10 | |
664 | 2994..3492: 13 | |
665 | 3493..3991: 13 | |
666 | 3992..4490: 5 | |
667 | 4491..4989: 10 | |
668 | 4990..5488: 19 | |
669 | 5489..5987: 9 | |
670 | 5988..6486: 10 | |
671 | 6487..6985: 12 | |
672 | 6986..7484: 17 | |
673 | 7485..7983: 16 | |
674 | 7984..8482: 16 | |
675 | 8483..8981: 16 | |
676 | 8982..9480: 16 | |
677 | 9481..9979: 12 | |
678 | ||
679 | +++ Stats for string_of len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
680 | ||
681 | stats len: | |
682 | num: 5000, avg: 363.14, stddev: 1245.80, median 9, min 0, max 9986 | |
683 | 0.. 499: ####################################################### 4270 | |
684 | 500.. 999: ###### 493 | |
685 | 1000.. 1499: 16 | |
686 | 1500.. 1999: 11 | |
687 | 2000.. 2499: 15 | |
688 | 2500.. 2999: 17 | |
689 | 3000.. 3499: 11 | |
690 | 3500.. 3999: 19 | |
691 | 4000.. 4499: 14 | |
692 | 4500.. 4999: 10 | |
693 | 5000.. 5499: 16 | |
694 | 5500.. 5999: 11 | |
695 | 6000.. 6499: 15 | |
696 | 6500.. 6999: 13 | |
697 | 7000.. 7499: 12 | |
698 | 7500.. 7999: 16 | |
699 | 8000.. 8499: 11 | |
700 | 8500.. 8999: 4 | |
701 | 9000.. 9499: 13 | |
702 | 9500.. 9999: 13 | |
703 | ||
704 | +++ Stats for printable_string len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
705 | ||
706 | stats len: | |
707 | num: 5000, avg: 384.53, stddev: 1330.61, median 9, min 0, max 9969 | |
708 | 0.. 498: ####################################################### 4246 | |
709 | 499.. 997: ###### 518 | |
710 | 998..1496: 21 | |
711 | 1497..1995: 10 | |
712 | 1996..2494: 11 | |
713 | 2495..2993: 10 | |
714 | 2994..3492: 13 | |
715 | 3493..3991: 13 | |
716 | 3992..4490: 5 | |
717 | 4491..4989: 10 | |
718 | 4990..5488: 19 | |
719 | 5489..5987: 9 | |
720 | 5988..6486: 10 | |
721 | 6487..6985: 12 | |
722 | 6986..7484: 17 | |
723 | 7485..7983: 16 | |
724 | 7984..8482: 16 | |
725 | 8483..8981: 16 | |
726 | 8982..9480: 16 | |
727 | 9481..9979: 12 | |
728 | ||
729 | +++ Stats for small_string len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
730 | ||
731 | stats len: | |
732 | num: 5000, avg: 15.57, stddev: 24.36, median 6, min 0, max 99 | |
733 | 0.. 4: #################################################### 1925 | |
734 | 5.. 9: ####################################################### 2005 | |
735 | 10.. 14: # 52 | |
736 | 15.. 19: # 50 | |
737 | 20.. 24: # 55 | |
738 | 25.. 29: # 56 | |
739 | 30.. 34: # 55 | |
740 | 35.. 39: # 49 | |
741 | 40.. 44: # 65 | |
742 | 45.. 49: # 65 | |
743 | 50.. 54: # 55 | |
744 | 55.. 59: # 68 | |
745 | 60.. 64: # 61 | |
746 | 65.. 69: # 65 | |
747 | 70.. 74: # 57 | |
748 | 75.. 79: # 66 | |
749 | 80.. 84: # 65 | |
750 | 85.. 89: # 64 | |
751 | 90.. 94: # 60 | |
752 | 95.. 99: # 62 | |
753 | ||
754 | +++ Stats for pair dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
755 | ||
756 | stats pair sum: | |
757 | num: 500000, avg: 100.02, stddev: 41.22, median 100, min 0, max 200 | |
758 | 0.. 9: ### 2685 | |
759 | 10.. 19: ######## 7622 | |
760 | 20.. 29: ############## 12474 | |
761 | 30.. 39: #################### 17330 | |
762 | 40.. 49: ########################## 22263 | |
763 | 50.. 59: ############################### 26982 | |
764 | 60.. 69: ##################################### 32182 | |
765 | 70.. 79: ########################################### 37125 | |
766 | 80.. 89: ################################################# 42287 | |
767 | 90.. 99: ###################################################### 46691 | |
768 | 100..109: ####################################################### 46977 | |
769 | 110..119: ################################################# 42444 | |
770 | 120..129: ############################################ 37719 | |
771 | 130..139: ###################################### 32595 | |
772 | 140..149: ################################ 27588 | |
773 | 150..159: ########################## 22792 | |
774 | 160..169: #################### 17805 | |
775 | 170..179: ############### 13068 | |
776 | 180..189: ######### 8218 | |
777 | 190..199: ### 3115 | |
778 | 200..209: 38 | |
779 | ||
780 | +++ Stats for triple dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
781 | ||
782 | stats triple sum: | |
783 | num: 500000, avg: 150.08, stddev: 50.51, median 150, min 0, max 299 | |
784 | 0.. 14: 345 | |
785 | 15.. 29: ## 2121 | |
786 | 30.. 44: ##### 5372 | |
787 | 45.. 59: ########## 10501 | |
788 | 60.. 74: ################# 17031 | |
789 | 75.. 89: ######################### 25417 | |
790 | 90..104: ################################### 35148 | |
791 | 105..119: ############################################# 45134 | |
792 | 120..134: ################################################### 51751 | |
793 | 135..149: ####################################################### 55090 | |
794 | 150..164: ###################################################### 55074 | |
795 | 165..179: #################################################### 52238 | |
796 | 180..194: ############################################# 45651 | |
797 | 195..209: ################################### 35994 | |
798 | 210..224: ######################### 26039 | |
799 | 225..239: ################# 17749 | |
800 | 240..254: ########## 10870 | |
801 | 255..269: ##### 5765 | |
802 | 270..284: ## 2313 | |
803 | 285..299: 397 | |
804 | ||
805 | +++ Stats for quad dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
806 | ||
807 | stats quad sum: | |
808 | num: 500000, avg: 200.13, stddev: 58.33, median 200, min 5, max 394 | |
809 | 5.. 24: 102 | |
810 | 25.. 44: 842 | |
811 | 45.. 64: ## 3023 | |
812 | 65.. 84: ###### 7154 | |
813 | 85..104: ############ 14368 | |
814 | 105..124: ##################### 25397 | |
815 | 125..144: ############################### 37547 | |
816 | 145..164: ########################################## 50174 | |
817 | 165..184: ################################################## 60558 | |
818 | 185..204: ####################################################### 65376 | |
819 | 205..224: ##################################################### 63687 | |
820 | 225..244: ############################################### 56248 | |
821 | 245..264: ###################################### 45384 | |
822 | 265..284: ########################## 31780 | |
823 | 285..304: ################ 20158 | |
824 | 305..324: ######### 10899 | |
825 | 325..344: #### 5045 | |
826 | 345..364: # 1848 | |
827 | 365..384: 386 | |
828 | 385..404: 24 | |
829 | ||
830 | +++ Stats for bind dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
831 | ||
832 | stats ordered pair difference: | |
833 | num: 1000000, avg: 25.02, stddev: 22.36, median 19, min 0, max 100 | |
834 | 0.. 4: ####################################################### 193184 | |
835 | 5.. 9: ##################################### 130024 | |
836 | 10.. 14: ############################# 103828 | |
837 | 15.. 19: ######################## 87496 | |
838 | 20.. 24: ##################### 74431 | |
839 | 25.. 29: ################## 64629 | |
840 | 30.. 34: ################ 56663 | |
841 | 35.. 39: ############# 48986 | |
842 | 40.. 44: ############ 43424 | |
843 | 45.. 49: ########## 37599 | |
844 | 50.. 54: ######### 32787 | |
845 | 55.. 59: ######## 28332 | |
846 | 60.. 64: ###### 24023 | |
847 | 65.. 69: ##### 20312 | |
848 | 70.. 74: #### 16649 | |
849 | 75.. 79: ### 13338 | |
850 | 80.. 84: ## 10239 | |
851 | 85.. 89: ## 7391 | |
852 | 90.. 94: # 4548 | |
853 | 95.. 99: 2015 | |
854 | 100..104: 102 | |
855 | ||
856 | stats ordered pair sum: | |
857 | num: 1000000, avg: 75.12, stddev: 46.93, median 72, min 0, max 200 | |
858 | 0.. 9: ####################################################### 70423 | |
859 | 10.. 19: ##################################################### 68068 | |
860 | 20.. 29: ##################################################### 68449 | |
861 | 30.. 39: ##################################################### 68577 | |
862 | 40.. 49: ##################################################### 68763 | |
863 | 50.. 59: ##################################################### 68351 | |
864 | 60.. 69: ##################################################### 68744 | |
865 | 70.. 79: ##################################################### 68451 | |
866 | 80.. 89: ##################################################### 68309 | |
867 | 90.. 99: ##################################################### 68835 | |
868 | 100..109: ################################################## 64544 | |
869 | 110..119: ########################################### 55512 | |
870 | 120..129: ##################################### 47595 | |
871 | 130..139: ############################### 39809 | |
872 | 140..149: ######################### 32677 | |
873 | 150..159: #################### 26312 | |
874 | 160..169: ############### 20180 | |
875 | 170..179: ########### 14265 | |
876 | 180..189: ###### 8625 | |
877 | 190..199: ## 3433 | |
878 | 200..209: 78 | |
879 | ||
880 | +++ Stats for list len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
881 | ||
882 | stats len: | |
883 | num: 5000, avg: 361.42, stddev: 1230.75, median 9, min 0, max 9974 | |
884 | 0.. 498: ####################################################### 4212 | |
885 | 499.. 997: ####### 578 | |
886 | 998..1496: 11 | |
887 | 1497..1995: 15 | |
888 | 1996..2494: 11 | |
889 | 2495..2993: 10 | |
890 | 2994..3492: 13 | |
891 | 3493..3991: 12 | |
892 | 3992..4490: 7 | |
893 | 4491..4989: 8 | |
894 | 4990..5488: 15 | |
895 | 5489..5987: 14 | |
896 | 5988..6486: 12 | |
897 | 6487..6985: 8 | |
898 | 6986..7484: 9 | |
899 | 7485..7983: 19 | |
900 | 7984..8482: 14 | |
901 | 8483..8981: 11 | |
902 | 8982..9480: 11 | |
903 | 9481..9979: 10 | |
904 | ||
905 | +++ Stats for small_list len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
906 | ||
907 | stats len: | |
908 | num: 5000, avg: 15.79, stddev: 24.64, median 6, min 0, max 99 | |
909 | 0.. 4: ###################################################### 1930 | |
910 | 5.. 9: ####################################################### 1957 | |
911 | 10.. 14: # 59 | |
912 | 15.. 19: # 66 | |
913 | 20.. 24: # 61 | |
914 | 25.. 29: # 52 | |
915 | 30.. 34: # 61 | |
916 | 35.. 39: # 65 | |
917 | 40.. 44: # 62 | |
918 | 45.. 49: # 64 | |
919 | 50.. 54: # 70 | |
920 | 55.. 59: # 63 | |
921 | 60.. 64: # 50 | |
922 | 65.. 69: # 51 | |
923 | 70.. 74: # 52 | |
924 | 75.. 79: # 63 | |
925 | 80.. 84: # 56 | |
926 | 85.. 89: ## 75 | |
927 | 90.. 94: ## 73 | |
928 | 95.. 99: # 70 | |
929 | ||
930 | +++ Stats for list_of_size len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
931 | ||
932 | stats len: | |
933 | num: 5000, avg: 7.51, stddev: 1.71, median 8, min 5, max 10 | |
934 | 5: ###################################################### 834 | |
935 | 6: ##################################################### 825 | |
936 | 7: ##################################################### 820 | |
937 | 8: ###################################################### 833 | |
938 | 9: ####################################################### 844 | |
939 | 10: ####################################################### 844 | |
940 | ||
941 | +++ Stats for list_repeat len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
942 | ||
943 | stats len: | |
944 | num: 5000, avg: 42.00, stddev: 0.00, median 42, min 42, max 42 | |
945 | 42: ####################################################### 5000 | |
946 | ||
947 | +++ Stats for array len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
948 | ||
949 | stats len: | |
950 | num: 5000, avg: 361.42, stddev: 1230.75, median 9, min 0, max 9974 | |
951 | 0.. 498: ####################################################### 4212 | |
952 | 499.. 997: ####### 578 | |
953 | 998..1496: 11 | |
954 | 1497..1995: 15 | |
955 | 1996..2494: 11 | |
956 | 2495..2993: 10 | |
957 | 2994..3492: 13 | |
958 | 3493..3991: 12 | |
959 | 3992..4490: 7 | |
960 | 4491..4989: 8 | |
961 | 4990..5488: 15 | |
962 | 5489..5987: 14 | |
963 | 5988..6486: 12 | |
964 | 6487..6985: 8 | |
965 | 6986..7484: 9 | |
966 | 7485..7983: 19 | |
967 | 7984..8482: 14 | |
968 | 8483..8981: 11 | |
969 | 8982..9480: 11 | |
970 | 9481..9979: 10 | |
971 | ||
972 | +++ Stats for small_array len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
973 | ||
974 | stats len: | |
975 | num: 5000, avg: 15.79, stddev: 24.64, median 6, min 0, max 99 | |
976 | 0.. 4: ###################################################### 1930 | |
977 | 5.. 9: ####################################################### 1957 | |
978 | 10.. 14: # 59 | |
979 | 15.. 19: # 66 | |
980 | 20.. 24: # 61 | |
981 | 25.. 29: # 52 | |
982 | 30.. 34: # 61 | |
983 | 35.. 39: # 65 | |
984 | 40.. 44: # 62 | |
985 | 45.. 49: # 64 | |
986 | 50.. 54: # 70 | |
987 | 55.. 59: # 63 | |
988 | 60.. 64: # 50 | |
989 | 65.. 69: # 51 | |
990 | 70.. 74: # 52 | |
991 | 75.. 79: # 63 | |
992 | 80.. 84: # 56 | |
993 | 85.. 89: ## 75 | |
994 | 90.. 94: ## 73 | |
995 | 95.. 99: # 70 | |
996 | ||
997 | +++ Stats for array_of_size len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
998 | ||
999 | stats len: | |
1000 | num: 5000, avg: 7.51, stddev: 1.71, median 8, min 5, max 10 | |
1001 | 5: ###################################################### 834 | |
1002 | 6: ##################################################### 825 | |
1003 | 7: ##################################################### 820 | |
1004 | 8: ###################################################### 833 | |
1005 | 9: ####################################################### 844 | |
1006 | 10: ####################################################### 844 | |
1007 | ||
1008 | +++ Stats for array_repeat len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
1009 | ||
1010 | stats len: | |
1011 | num: 5000, avg: 42.00, stddev: 0.00, median 42, min 42, max 42 | |
1012 | 42: ####################################################### 5000 | |
1013 | ||
1014 | +++ Stats for int_stats_neg ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
1015 | ||
1016 | stats dist: | |
1017 | num: 5000, avg: 0.17, stddev: 29.68, median 0, min -99, max 99 | |
1018 | -99..-90: # 65 | |
1019 | -89..-80: # 63 | |
1020 | -79..-70: # 64 | |
1021 | -69..-60: # 58 | |
1022 | -59..-50: # 67 | |
1023 | -49..-40: # 72 | |
1024 | -39..-30: # 61 | |
1025 | -29..-20: # 61 | |
1026 | -19..-10: # 67 | |
1027 | -9.. 0: ####################################################### 2076 | |
1028 | 1.. 10: ############################################## 1764 | |
1029 | 11.. 20: # 66 | |
1030 | 21.. 30: # 64 | |
1031 | 31.. 40: # 64 | |
1032 | 41.. 50: # 67 | |
1033 | 51.. 60: # 60 | |
1034 | 61.. 70: # 75 | |
1035 | 71.. 80: # 60 | |
1036 | 81.. 90: # 60 | |
1037 | 91..100: # 66 | |
1038 | ||
1039 | +++ Stats for small_signed_int dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
1040 | ||
1041 | stats dist: | |
1042 | num: 1000, avg: 0.90, stddev: 28.23, median 0, min -99, max 99 | |
1043 | -99..-90: # 12 | |
1044 | -89..-80: # 11 | |
1045 | -79..-70: # 9 | |
1046 | -69..-60: 6 | |
1047 | -59..-50: # 11 | |
1048 | -49..-40: # 13 | |
1049 | -39..-30: # 9 | |
1050 | -29..-20: # 13 | |
1051 | -19..-10: 8 | |
1052 | -9.. 0: ####################################################### 453 | |
1053 | 1.. 10: ######################################### 340 | |
1054 | 11.. 20: # 15 | |
1055 | 21.. 30: # 11 | |
1056 | 31.. 40: # 12 | |
1057 | 41.. 50: # 13 | |
1058 | 51.. 60: # 13 | |
1059 | 61.. 70: # 16 | |
1060 | 71.. 80: # 9 | |
1061 | 81.. 90: # 16 | |
1062 | 91..100: # 10 | |
1063 | ||
1064 | +++ Stats for small_nat dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
1065 | ||
1066 | stats dist: | |
1067 | num: 1000, avg: 15.11, stddev: 23.27, median 6, min 0, max 99 | |
1068 | 0.. 4: #################################################### 377 | |
1069 | 5.. 9: ####################################################### 392 | |
1070 | 10.. 14: ## 20 | |
1071 | 15.. 19: ## 15 | |
1072 | 20.. 24: # 11 | |
1073 | 25.. 29: ## 17 | |
1074 | 30.. 34: ## 19 | |
1075 | 35.. 39: ## 17 | |
1076 | 40.. 44: # 10 | |
1077 | 45.. 49: # 9 | |
1078 | 50.. 54: # 8 | |
1079 | 55.. 59: # 9 | |
1080 | 60.. 64: ## 15 | |
1081 | 65.. 69: # 10 | |
1082 | 70.. 74: # 13 | |
1083 | 75.. 79: ## 19 | |
1084 | 80.. 84: # 11 | |
1085 | 85.. 89: # 13 | |
1086 | 90.. 94: 5 | |
1087 | 95.. 99: # 10 | |
1088 | ||
1089 | +++ Stats for nat dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
1090 | ||
1091 | stats dist: | |
1092 | num: 1000, avg: 363.02, stddev: 1215.04, median 9, min 0, max 9476 | |
1093 | 0.. 473: ####################################################### 847 | |
1094 | 474.. 947: ###### 95 | |
1095 | 948..1421: 14 | |
1096 | 1422..1895: 3 | |
1097 | 1896..2369: 0 | |
1098 | 2370..2843: 3 | |
1099 | 2844..3317: 2 | |
1100 | 3318..3791: 3 | |
1101 | 3792..4265: 2 | |
1102 | 4266..4739: 4 | |
1103 | 4740..5213: 3 | |
1104 | 5214..5687: 4 | |
1105 | 5688..6161: 3 | |
1106 | 6162..6635: 4 | |
1107 | 6636..7109: 1 | |
1108 | 7110..7583: 4 | |
1109 | 7584..8057: 2 | |
1110 | 8058..8531: 1 | |
1111 | 8532..9005: 1 | |
1112 | 9006..9479: 4 | |
1113 | ||
1114 | +++ Stats for int_range (-43643) 435434 dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
1115 | ||
1116 | stats dist: | |
1117 | num: 1000, avg: 195335.64, stddev: 136803.99, median 195583, min -43624, max 435210 | |
1118 | -43624..-19683: ############################################ 52 | |
1119 | -19682.. 4259: ######################################## 47 | |
1120 | 4260.. 28201: ############################## 36 | |
1121 | 28202.. 52143: ############################################ 52 | |
1122 | 52144.. 76085: ########################################## 50 | |
1123 | 76086..100027: ####################################################### 64 | |
1124 | 100028..123969: ############################################### 55 | |
1125 | 123970..147911: ######################################## 47 | |
1126 | 147912..171853: ############################################## 54 | |
1127 | 171854..195795: #################################### 43 | |
1128 | 195796..219737: ############################################## 54 | |
1129 | 219738..243679: ########################################### 51 | |
1130 | 243680..267621: ################################################ 57 | |
1131 | 267622..291563: ########################################## 49 | |
1132 | 291564..315505: #################################### 42 | |
1133 | 315506..339447: ###################################### 45 | |
1134 | 339448..363389: ################################################ 57 | |
1135 | 363390..387331: ###################################### 45 | |
1136 | 387332..411273: ########################################## 49 | |
1137 | 411274..435215: ########################################### 51 | |
1138 | ||
1139 | +++ Stats for int_range (-40000) 40000 dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
1140 | ||
1141 | stats dist: | |
1142 | num: 1000, avg: -173.78, stddev: 23042.92, median 180, min -39859, max 39942 | |
1143 | -39859..-35869: ############################################# 56 | |
1144 | -35868..-31878: ################################### 43 | |
1145 | -31877..-27887: ################################################# 60 | |
1146 | -27886..-23896: ##################################### 46 | |
1147 | -23895..-19905: ######################################## 49 | |
1148 | -19904..-15914: #################################### 45 | |
1149 | -15913..-11923: ############################################ 54 | |
1150 | -11922.. -7932: ############################################### 58 | |
1151 | -7931.. -3941: ######################################### 51 | |
1152 | -3940.. 50: ############################ 35 | |
1153 | 51.. 4041: ####################################### 48 | |
1154 | 4042.. 8032: ########################################## 52 | |
1155 | 8033.. 12023: ######################################### 51 | |
1156 | 12024.. 16014: ########################################### 53 | |
1157 | 16015.. 20005: ############################################ 54 | |
1158 | 20006.. 23996: ################################## 42 | |
1159 | 23997.. 27987: ####################################################### 67 | |
1160 | 27988.. 31978: ################################ 40 | |
1161 | 31979.. 35969: ######################################### 51 | |
1162 | 35970.. 39960: #################################### 45 | |
1163 | ||
1164 | +++ Stats for int_range (-4) 4 dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
1165 | ||
1166 | stats dist: | |
1167 | num: 1000, avg: 0.02, stddev: 2.55, median 0, min -4, max 4 | |
1168 | -4: ############################################ 99 | |
1169 | -3: ##################################################### 118 | |
1170 | -2: ################################################## 111 | |
1171 | -1: ################################################## 113 | |
1172 | 0: ################################################## 113 | |
1173 | 1: ##################################################### 118 | |
1174 | 2: ############################################# 102 | |
1175 | 3: ####################################################### 122 | |
1176 | 4: ############################################## 104 | |
1177 | ||
1178 | +++ Stats for int_range (-4) 17 dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
1179 | ||
1180 | stats dist: | |
1181 | num: 1000, avg: 6.67, stddev: 6.39, median 7, min -4, max 17 | |
1182 | -4..-3: ############################################# 90 | |
1183 | -2..-1: ############################################# 91 | |
1184 | 0.. 1: ########################################## 84 | |
1185 | 2.. 3: ############################################## 92 | |
1186 | 4.. 5: ########################################### 87 | |
1187 | 6.. 7: ########################################### 86 | |
1188 | 8.. 9: ############################################ 89 | |
1189 | 10..11: ########################################### 87 | |
1190 | 12..13: ####################################################### 110 | |
1191 | 14..15: ############################################# 91 | |
1192 | 16..17: ############################################## 93 | |
1193 | 18..19: 0 | |
1194 | 20..21: 0 | |
1195 | 22..23: 0 | |
1196 | 24..25: 0 | |
1197 | 26..27: 0 | |
1198 | 28..29: 0 | |
1199 | 30..31: 0 | |
1200 | 32..33: 0 | |
1201 | 34..35: 0 | |
1202 | ||
1203 | +++ Stats for int dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
1204 | ||
1205 | stats dist: | |
1206 | num: 100000, avg: 336840.90, stddev: 619301756.02, median 895228, min -1073728193, max 1073739280 | |
1207 | -1073728193.. -966354820: ##################################################### 5009 | |
1208 | -966354819.. -858981446: #################################################### 5004 | |
1209 | -858981445.. -751608072: #################################################### 4917 | |
1210 | -751608071.. -644234698: ##################################################### 5028 | |
1211 | -644234697.. -536861324: #################################################### 4962 | |
1212 | -536861323.. -429487950: ##################################################### 5039 | |
1213 | -429487949.. -322114576: #################################################### 4927 | |
1214 | -322114575.. -214741202: ##################################################### 5054 | |
1215 | -214741201.. -107367828: ##################################################### 5065 | |
1216 | -107367827.. 5546: #################################################### 4954 | |
1217 | 5547.. 107378920: #################################################### 4943 | |
1218 | 107378921.. 214752294: ################################################### 4900 | |
1219 | 214752295.. 322125668: ###################################################### 5126 | |
1220 | 322125669.. 429499042: ####################################################### 5198 | |
1221 | 429499043.. 536872416: #################################################### 4988 | |
1222 | 536872417.. 644245790: #################################################### 4940 | |
1223 | 644245791.. 751619164: #################################################### 5002 | |
1224 | 751619165.. 858992538: #################################################### 4928 | |
1225 | 858992539.. 966365912: ##################################################### 5070 | |
1226 | 966365913.. 1073739286: #################################################### 4946 | |
1227 | ||
1228 | +++ Stats for oneof int dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
1229 | ||
1230 | stats dist: | |
1231 | num: 1000, avg: 1073741.63, stddev: 676575790.92, median 0, min -1073741824, max 1073741823 | |
1232 | -1073741824.. -966367642: ################## 208 | |
1233 | -966367641.. -858993459: 0 | |
1234 | -858993458.. -751619276: 0 | |
1235 | -751619275.. -644245093: 0 | |
1236 | -644245092.. -536870910: 0 | |
1237 | -536870909.. -429496727: 0 | |
1238 | -429496726.. -322122544: 0 | |
1239 | -322122543.. -214748361: 0 | |
1240 | -214748360.. -107374178: 0 | |
1241 | -107374177.. 5: ####################################################### 603 | |
1242 | 6.. 107374188: 0 | |
1243 | 107374189.. 214748371: 0 | |
1244 | 214748372.. 322122554: 0 | |
1245 | 322122555.. 429496737: 0 | |
1246 | 429496738.. 536870920: 0 | |
1247 | 536870921.. 644245103: 0 | |
1248 | 644245104.. 751619286: 0 | |
1249 | 751619287.. 858993469: 0 | |
1250 | 858993470.. 966367652: 0 | |
1251 | 966367653.. 1073741823: ################# 189 | |
1252 | ================================================================================ | |
1253 | 1 warning(s) | |
1254 | failure (59 tests failed, 3 tests errored, ran 139 tests) | |
1255 | random seed: 153870556 | |
1256 | ||
1257 | +++ Stats for int_dist_empty_bucket ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
1258 | ||
1259 | stats dist: | |
1260 | num: 1000, avg: 10351291.88, stddev: 432212939.52, median 9, min -1066972208, max 1073741823 | |
1261 | -1066972208.. -959936507: ## 27 | |
1262 | -959936506.. -852900805: ## 22 | |
1263 | -852900804.. -745865103: ## 22 | |
1264 | -745865102.. -638829401: # 18 | |
1265 | -638829400.. -531793699: # 17 | |
1266 | -531793698.. -424757997: ## 21 | |
1267 | -424757996.. -317722295: ### 33 | |
1268 | -317722294.. -210686593: ### 33 | |
1269 | -210686592.. -103650891: ### 32 | |
1270 | -103650890.. 3384811: ####################################################### 516 | |
1271 | 3384812.. 110420513: ### 34 | |
1272 | 110420514.. 217456215: ### 34 | |
1273 | 217456216.. 324491917: # 17 | |
1274 | 324491918.. 431527619: ## 24 | |
1275 | 431527620.. 538563321: ## 26 | |
1276 | 538563322.. 645599023: ## 20 | |
1277 | 645599024.. 752634725: ## 24 | |
1278 | 752634726.. 859670427: ## 27 | |
1279 | 859670428.. 966706129: ## 27 | |
1280 | 966706130.. 1073741823: ## 26 | |
1281 | ================================================================================ | |
1282 | success (ran 1 tests) |
0 | random seed: 1234 | |
1 | 50 7 4 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 (6,fun,50) (0,fun,2) (7,fun,66) (54,fun,9) (2,fun,5) (90,fun,4) (1,fun,4) (37,fun,7) (7,fun,1) (8,fun,5) | |
2 | (6,fun,50) (0,fun,2) (7,fun,66) (54,fun,9) (2,fun,5) (90,fun,4) (1,fun,4) (37,fun,7) (7,fun,1) (8,fun,5) | |
3 | (6,fun,50) (0,fun,2) (7,fun,66) (54,fun,9) (2,fun,5) (90,fun,4) (1,fun,4) (37,fun,7) (7,fun,1) (8,fun,5) | |
4 | (6,fun,50) (0,fun,2) (7,fun,66) (54,fun,9) (2,fun,5) (90,fun,4) (1,fun,4) (37,fun,7) (7,fun,1) (8,fun,5) | |
5 | (6,fun,50) (0,fun,2) (7,fun,66) (54,fun,9) (2,fun,5) (90,fun,4) (1,fun,4) (37,fun,7) (7,fun,1) (8,fun,5) | |
6 | (6,fun,50) (0,fun,2) (7,fun,66) (54,fun,9) (2,fun,5) (90,fun,4) (1,fun,4) (37,fun,7) (7,fun,1) (8,fun,5) | |
7 | (6,fun,50) (0,fun,2) (7,fun,66) (54,fun,9) (2,fun,5) (90,fun,4) (1,fun,4) (37,fun,7) (7,fun,1) (8,fun,5) | |
8 | (6,fun,50) (0,fun,2) (7,fun,66) (54,fun,9) (2,fun,5) (90,fun,4) (1,fun,4) (37,fun,7) (7,fun,1) (8,fun,5) | |
9 | 2724675603984413065 | |
10 | 1362337801992206533 | |
11 | 681168900996103267 | |
12 | 340584450498051634 | |
13 | 170292225249025817 | |
14 | 85146112624512909 | |
15 | 42573056312256455 | |
16 | 21286528156128228 | |
17 | 10643264078064114 | |
18 | 5321632039032057 | |
19 | 2660816019516029 | |
20 | 1330408009758015 | |
21 | 665204004879008 | |
22 | 332602002439504 | |
23 | 166301001219752 | |
24 | 83150500609876 | |
25 | 41575250304938 | |
26 | 20787625152469 | |
27 | 10393812576235 | |
28 | 5196906288118 | |
29 | 2598453144059 | |
30 | 1299226572030 | |
31 | 649613286015 | |
32 | 324806643008 | |
33 | 162403321504 | |
34 | 81201660752 | |
35 | 40600830376 | |
36 | 20300415188 | |
37 | 10150207594 | |
38 | 5075103797 | |
39 | 2537551899 | |
40 | 1268775950 | |
41 | 634387975 | |
42 | 317193988 | |
43 | 158596994 | |
44 | 79298497 | |
45 | 39649249 | |
46 | 19824625 | |
47 | 9912313 | |
48 | 4956157 | |
49 | 2478079 | |
50 | 1239040 | |
51 | 619520 | |
52 | 309760 | |
53 | 154880 | |
54 | 77440 | |
55 | 38720 | |
56 | 19360 | |
57 | 9680 | |
58 | 4840 | |
59 | 2420 | |
60 | 1210 | |
61 | 605 | |
62 | 303 | |
63 | 152 | |
64 | 76 | |
65 | 38 | |
66 | 19 | |
67 | 10 | |
68 | 5 | |
69 | 3 | |
70 | 2 | |
71 | 1 | |
72 | 0 | |
73 | [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] | |
74 | [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] | |
75 | [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] | |
76 | [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] | |
77 | [7; 1; 42; 1; 8; 5; 3; 9; 5; 38; 3; 3; 0; 1; 98; 1] | |
78 | [7; 1; 42; 1; 8; 5; 3; 9] | |
79 | [7; 1; 42; 1] | |
80 | [7; 1] | |
81 | [] | |
82 | [7] | |
83 | [] | |
84 | [4] | |
85 | [] | |
86 | [2] | |
87 | [] | |
88 | [1] | |
89 | [] | |
90 | [0] | |
91 | [] | |
92 | [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] | |
93 | [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] | |
94 | [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] | |
95 | [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] | |
96 | [7; 1; 42; 1; 8; 5; 3; 9; 5; 38; 3; 3; 0; 1; 98; 1] | |
97 | [7; 1; 42; 1; 8; 5; 3; 9] | |
98 | [7; 1; 42; 1] | |
99 | [7; 1] | |
100 | [42; 1] | |
101 | [7; 42; 1] | |
102 | [1; 42; 1] | |
103 | [1; 42] | |
104 | [1] | |
105 | [1; 1] | |
106 | [] | |
107 | [1] | |
108 | [1] | |
109 | [0; 1] | |
110 | [1; 0] | |
111 | ||
112 | --- Failure -------------------------------------------------------------------- | |
113 | ||
114 | Test should_fail_sort_id failed (13 shrink steps): | |
115 | ||
116 | [1; 0] | |
117 | ||
118 | === Error ====================================================================== | |
119 | ||
120 | Test should_error_raise_exn errored on (63 shrink steps): | |
121 | ||
122 | 0 | |
123 | ||
124 | exception QCheck_tests.Overall.Error | |
125 | ||
126 | ||
127 | +++ Collect ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
128 | ||
129 | Collect results for test collect_results: | |
130 | ||
131 | 4: 20 cases | |
132 | 3: 25 cases | |
133 | 2: 17 cases | |
134 | 1: 18 cases | |
135 | 0: 20 cases | |
136 | ||
137 | +++ Stats for with_stats ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
138 | ||
139 | stats mod4: | |
140 | num: 100, avg: 1.68, stddev: 1.09, median 2, min 0, max 3 | |
141 | 0: ############################## 17 | |
142 | 1: ################################################### 29 | |
143 | 2: ######################################## 23 | |
144 | 3: ####################################################### 31 | |
145 | ||
146 | stats num: | |
147 | num: 100, avg: 66.84, stddev: 31.94, median 65, min 2, max 120 | |
148 | 2.. 7: ################## 3 | |
149 | 8.. 13: ################## 3 | |
150 | 14.. 19: 0 | |
151 | 20.. 25: ########################################## 7 | |
152 | 26.. 31: ######################## 4 | |
153 | 32.. 37: ######################## 4 | |
154 | 38.. 43: ################## 3 | |
155 | 44.. 49: ################################################ 8 | |
156 | 50.. 55: #################################### 6 | |
157 | 56.. 61: #################################### 6 | |
158 | 62.. 67: ####################################################### 9 | |
159 | 68.. 73: ########################################## 7 | |
160 | 74.. 79: ######################## 4 | |
161 | 80.. 85: ################## 3 | |
162 | 86.. 91: ############ 2 | |
163 | 92.. 97: ########################################## 7 | |
164 | 98..103: #################################### 6 | |
165 | 104..109: #################################### 6 | |
166 | 110..115: ####################################################### 9 | |
167 | 116..121: ################## 3 | |
168 | ||
169 | --- Failure -------------------------------------------------------------------- | |
170 | ||
171 | Test with shrinking retries failed (1 shrink steps): | |
172 | ||
173 | 4 | |
174 | ||
175 | !!! Warning !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
176 | ||
177 | Warning for test WARN_unlikely_precond: | |
178 | ||
179 | WARNING: only 0.5% tests (of 2000) passed precondition for "WARN_unlikely_precond" | |
180 | ||
181 | NOTE: it is likely that the precondition is too strong, or that the generator is buggy. | |
182 | ||
183 | --- Failure -------------------------------------------------------------------- | |
184 | ||
185 | Test FAIL_unlikely_precond failed: | |
186 | ||
187 | ERROR: only 0.5% tests (of 2000) passed precondition for "FAIL_unlikely_precond" | |
188 | ||
189 | NOTE: it is likely that the precondition is too strong, or that the generator is buggy. | |
190 | ||
191 | ||
192 | --- Failure -------------------------------------------------------------------- | |
193 | ||
194 | Test FAIL_bad_gen failed: | |
195 | ||
196 | ERROR: uncaught exception in generator for test FAIL_bad_gen after 100 steps: | |
197 | Exception: Invalid_argument("Gen.int_bound") | |
198 | Backtrace: | |
199 | ||
200 | --- Failure -------------------------------------------------------------------- | |
201 | ||
202 | Test int double failed: | |
203 | ||
204 | Negative test int double succeeded but was expected to fail | |
205 | ||
206 | === Error ====================================================================== | |
207 | ||
208 | Test pos fail with error errored on (7 shrink steps): | |
209 | ||
210 | 0 | |
211 | ||
212 | exception QCheck_tests.Overall.Error | |
213 | ||
214 | ||
215 | === Error ====================================================================== | |
216 | ||
217 | Test neg fail with error errored on (7 shrink steps): | |
218 | ||
219 | 0 | |
220 | ||
221 | exception QCheck_tests.Overall.Error | |
222 | ||
223 | ||
224 | --- Failure -------------------------------------------------------------------- | |
225 | ||
226 | Test char never produces '\255' failed (0 shrink steps): | |
227 | ||
228 | '\255' | |
229 | ||
230 | --- Failure -------------------------------------------------------------------- | |
231 | ||
232 | Test big bound issue59 failed (52 shrink steps): | |
233 | ||
234 | 209609 | |
235 | ||
236 | --- Failure -------------------------------------------------------------------- | |
237 | ||
238 | Test long_shrink failed (149 shrink steps): | |
239 | ||
240 | ([0], [-1]) | |
241 | ||
242 | --- Failure -------------------------------------------------------------------- | |
243 | ||
244 | Test ints arent 0 mod 3 failed (84 shrink steps): | |
245 | ||
246 | -21 | |
247 | ||
248 | --- Failure -------------------------------------------------------------------- | |
249 | ||
250 | Test ints are 0 failed (62 shrink steps): | |
251 | ||
252 | 1 | |
253 | ||
254 | --- Failure -------------------------------------------------------------------- | |
255 | ||
256 | Test ints < 209609 failed (52 shrink steps): | |
257 | ||
258 | 209609 | |
259 | ||
260 | --- Failure -------------------------------------------------------------------- | |
261 | ||
262 | Test nat < 5001 failed (6 shrink steps): | |
263 | ||
264 | 5001 | |
265 | ||
266 | --- Failure -------------------------------------------------------------------- | |
267 | ||
268 | Test char never produces 'abcdef' failed (3 shrink steps): | |
269 | ||
270 | 'a' | |
271 | ||
272 | --- Failure -------------------------------------------------------------------- | |
273 | ||
274 | Test printable never produces '!"#$%&' failed (2 shrink steps): | |
275 | ||
276 | '&' | |
277 | ||
278 | --- Failure -------------------------------------------------------------------- | |
279 | ||
280 | Test printable never produces less than '5 failed (3 shrink steps): | |
281 | ||
282 | '0' | |
283 | ||
284 | --- Failure -------------------------------------------------------------------- | |
285 | ||
286 | Test strings are empty failed (15 shrink steps): | |
287 | ||
288 | "a" | |
289 | ||
290 | --- Failure -------------------------------------------------------------------- | |
291 | ||
292 | Test string never has a \000 char failed (8 shrink steps): | |
293 | ||
294 | "\000" | |
295 | ||
296 | --- Failure -------------------------------------------------------------------- | |
297 | ||
298 | Test string never has a \255 char failed (14 shrink steps): | |
299 | ||
300 | "\255" | |
301 | ||
302 | --- Failure -------------------------------------------------------------------- | |
303 | ||
304 | Test strings have unique chars failed (13 shrink steps): | |
305 | ||
306 | "\129\129" | |
307 | ||
308 | --- Failure -------------------------------------------------------------------- | |
309 | ||
310 | Test pairs have different components failed (0 shrink steps): | |
311 | ||
312 | (4, 4) | |
313 | ||
314 | --- Failure -------------------------------------------------------------------- | |
315 | ||
316 | Test pairs have same components failed (125 shrink steps): | |
317 | ||
318 | (0, 1) | |
319 | ||
320 | --- Failure -------------------------------------------------------------------- | |
321 | ||
322 | Test pairs have a zero component failed (124 shrink steps): | |
323 | ||
324 | (-1, 1) | |
325 | ||
326 | --- Failure -------------------------------------------------------------------- | |
327 | ||
328 | Test pairs are (0,0) failed (125 shrink steps): | |
329 | ||
330 | (0, 1) | |
331 | ||
332 | --- Failure -------------------------------------------------------------------- | |
333 | ||
334 | Test pairs are ordered failed (827 shrink steps): | |
335 | ||
336 | (1, 0) | |
337 | ||
338 | --- Failure -------------------------------------------------------------------- | |
339 | ||
340 | Test pairs are ordered reversely failed (124 shrink steps): | |
341 | ||
342 | (0, 1) | |
343 | ||
344 | --- Failure -------------------------------------------------------------------- | |
345 | ||
346 | Test pairs sum to less than 128 failed (116 shrink steps): | |
347 | ||
348 | (0, 128) | |
349 | ||
350 | --- Failure -------------------------------------------------------------------- | |
351 | ||
352 | Test pairs lists rev concat failed (147 shrink steps): | |
353 | ||
354 | ([0], [1]) | |
355 | ||
356 | --- Failure -------------------------------------------------------------------- | |
357 | ||
358 | Test pairs lists no overlap failed (26 shrink steps): | |
359 | ||
360 | ([0], [0]) | |
361 | ||
362 | --- Failure -------------------------------------------------------------------- | |
363 | ||
364 | Test triples have pair-wise different components failed (7 shrink steps): | |
365 | ||
366 | (0, 7, 7) | |
367 | ||
368 | --- Failure -------------------------------------------------------------------- | |
369 | ||
370 | Test triples have same components failed (188 shrink steps): | |
371 | ||
372 | (0, -1, 0) | |
373 | ||
374 | --- Failure -------------------------------------------------------------------- | |
375 | ||
376 | Test triples are ordered failed (188 shrink steps): | |
377 | ||
378 | (0, -1, 0) | |
379 | ||
380 | --- Failure -------------------------------------------------------------------- | |
381 | ||
382 | Test triples are ordered reversely failed (188 shrink steps): | |
383 | ||
384 | (0, 0, 1) | |
385 | ||
386 | --- Failure -------------------------------------------------------------------- | |
387 | ||
388 | Test quadruples have pair-wise different components failed (23 shrink steps): | |
389 | ||
390 | (0, 0, 0, 0) | |
391 | ||
392 | --- Failure -------------------------------------------------------------------- | |
393 | ||
394 | Test quadruples have same components failed (250 shrink steps): | |
395 | ||
396 | (0, 1, 0, 1) | |
397 | ||
398 | --- Failure -------------------------------------------------------------------- | |
399 | ||
400 | Test quadruples are ordered failed (251 shrink steps): | |
401 | ||
402 | (0, 0, -1, 0) | |
403 | ||
404 | --- Failure -------------------------------------------------------------------- | |
405 | ||
406 | Test quadruples are ordered reversely failed (251 shrink steps): | |
407 | ||
408 | (0, 0, 0, 1) | |
409 | ||
410 | --- Failure -------------------------------------------------------------------- | |
411 | ||
412 | Test forall (a, b) in nat: a < b failed (13 shrink steps): | |
413 | ||
414 | (0, 0) | |
415 | ||
416 | --- Failure -------------------------------------------------------------------- | |
417 | ||
418 | Test forall (a, b, c) in nat: a < b < c failed (15 shrink steps): | |
419 | ||
420 | (0, 0, 0) | |
421 | ||
422 | --- Failure -------------------------------------------------------------------- | |
423 | ||
424 | Test forall (a, b, c, d) in nat: a < b < c < d failed (23 shrink steps): | |
425 | ||
426 | (0, 0, 0, 0) | |
427 | ||
428 | --- Failure -------------------------------------------------------------------- | |
429 | ||
430 | Test forall (a, b, c, d, e) in nat: a < b < c < d < e failed (28 shrink steps): | |
431 | ||
432 | (0, 0, 0, 0, 0) | |
433 | ||
434 | --- Failure -------------------------------------------------------------------- | |
435 | ||
436 | Test forall (a, b, c, d, e, f) in nat: a < b < c < d < e < f failed (30 shrink steps): | |
437 | ||
438 | (0, 0, 0, 0, 0, 0) | |
439 | ||
440 | --- Failure -------------------------------------------------------------------- | |
441 | ||
442 | Test forall (a, b, c, d, e, f, g) in nat: a < b < c < d < e < f < g failed (31 shrink steps): | |
443 | ||
444 | (0, 0, 0, 0, 0, 0, 0) | |
445 | ||
446 | --- Failure -------------------------------------------------------------------- | |
447 | ||
448 | Test forall (a, b, c, d, e, f, g, h) in nat: a < b < c < d < e < f < g < h failed (35 shrink steps): | |
449 | ||
450 | (0, 0, 0, 0, 0, 0, 0, 0) | |
451 | ||
452 | --- Failure -------------------------------------------------------------------- | |
453 | ||
454 | Test forall (a, b, c, d, e, f, g, h, i) in nat: a < b < c < d < e < f < g < h < i failed (42 shrink steps): | |
455 | ||
456 | (0, 0, 0, 0, 0, 0, 0, 0, 0) | |
457 | ||
458 | --- Failure -------------------------------------------------------------------- | |
459 | ||
460 | Test bind ordered pairs failed (125 shrink steps): | |
461 | ||
462 | (0, 0) | |
463 | ||
464 | --- Failure -------------------------------------------------------------------- | |
465 | ||
466 | Test bind list_size constant failed (49 shrink steps): | |
467 | ||
468 | (4, [0; 0; 0; 0]) | |
469 | ||
470 | --- Failure -------------------------------------------------------------------- | |
471 | ||
472 | Test lists are empty failed (12 shrink steps): | |
473 | ||
474 | [0] | |
475 | ||
476 | --- Failure -------------------------------------------------------------------- | |
477 | ||
478 | Test lists shorter than 10 failed (39 shrink steps): | |
479 | ||
480 | [0; 0; 0; 0; 0; 0; 0; 0; 0; 0] | |
481 | ||
482 | --- Failure -------------------------------------------------------------------- | |
483 | ||
484 | Test lists shorter than 432 failed (1632 shrink steps): | |
485 | ||
486 | [...] list length: 432 | |
487 | ||
488 | --- Failure -------------------------------------------------------------------- | |
489 | ||
490 | Test lists shorter than 4332 failed (13 shrink steps): | |
491 | ||
492 | [...] list length: 4332 | |
493 | ||
494 | --- Failure -------------------------------------------------------------------- | |
495 | ||
496 | Test lists have unique elems failed (8 shrink steps): | |
497 | ||
498 | [1; 1] | |
499 | ||
500 | --- Failure -------------------------------------------------------------------- | |
501 | ||
502 | Test tree contains only 42 failed (10 shrink steps): | |
503 | ||
504 | Leaf 0 | |
505 | ||
506 | --- Failure -------------------------------------------------------------------- | |
507 | ||
508 | Test fail_pred_map_commute failed (77 shrink steps): | |
509 | ||
510 | ([1], {_ -> 0}, {1 -> true; _ -> false}) | |
511 | ||
512 | --- Failure -------------------------------------------------------------------- | |
513 | ||
514 | Test fail_pred_strings failed (1 shrink steps): | |
515 | ||
516 | {some other string -> false; _ -> true} | |
517 | ||
518 | --- Failure -------------------------------------------------------------------- | |
519 | ||
520 | Test fold_left fold_right failed (34 shrink steps): | |
521 | ||
522 | (0, [1], {(1, 0) -> 1; _ -> 0}) | |
523 | ||
524 | +++ Messages ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
525 | ||
526 | Messages for test fold_left fold_right: | |
527 | ||
528 | l=[1], fold_left=1, fold_right=0 | |
529 | ||
530 | ||
531 | --- Failure -------------------------------------------------------------------- | |
532 | ||
533 | Test fold_left fold_right uncurried failed (44 shrink steps): | |
534 | ||
535 | ({(0, 7) -> 1; _ -> 0}, 0, [7]) | |
536 | ||
537 | --- Failure -------------------------------------------------------------------- | |
538 | ||
539 | Test fold_left fold_right uncurried fun last failed (34 shrink steps): | |
540 | ||
541 | (0, [1], {(1, 0) -> 1; _ -> 0}) | |
542 | ||
543 | --- Failure -------------------------------------------------------------------- | |
544 | ||
545 | Test fold_left test, fun first failed (36 shrink steps): | |
546 | ||
547 | ({_ -> ""}, "a", [], [0]) | |
548 | ||
549 | --- Failure -------------------------------------------------------------------- | |
550 | ||
551 | Test FAIL_#99_1 failed: | |
552 | ||
553 | ERROR: uncaught exception in generator for test FAIL_#99_1 after 100 steps: | |
554 | Exception: QCheck.No_example_found("<example>") | |
555 | Backtrace: | |
556 | ||
557 | +++ Collect ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
558 | ||
559 | Collect results for test bool dist: | |
560 | ||
561 | true: 250134 cases | |
562 | false: 249866 cases | |
563 | ||
564 | +++ Stats for char code dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
565 | ||
566 | stats char code: | |
567 | num: 500000, avg: 127.42, stddev: 73.92, median 127, min 0, max 255 | |
568 | 0.. 12: ###################################################### 25509 | |
569 | 13.. 25: ###################################################### 25398 | |
570 | 26.. 38: ###################################################### 25293 | |
571 | 39.. 51: ###################################################### 25448 | |
572 | 52.. 64: ###################################################### 25392 | |
573 | 65.. 77: ####################################################### 25660 | |
574 | 78.. 90: ###################################################### 25462 | |
575 | 91..103: ###################################################### 25331 | |
576 | 104..116: ##################################################### 25129 | |
577 | 117..129: ###################################################### 25351 | |
578 | 130..142: ###################################################### 25492 | |
579 | 143..155: ###################################################### 25370 | |
580 | 156..168: ###################################################### 25658 | |
581 | 169..181: ###################################################### 25400 | |
582 | 182..194: ##################################################### 25167 | |
583 | 195..207: ###################################################### 25338 | |
584 | 208..220: ##################################################### 25181 | |
585 | 221..233: ##################################################### 25145 | |
586 | 234..246: ###################################################### 25567 | |
587 | 247..259: ##################################### 17709 | |
588 | ||
589 | +++ Stats for printable char code dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
590 | ||
591 | stats char code: | |
592 | num: 500000, avg: 77.76, stddev: 27.92, median 78, min 10, max 125 | |
593 | 10.. 15: ######### 5392 | |
594 | 16.. 21: 0 | |
595 | 22.. 27: 0 | |
596 | 28.. 33: ################## 10661 | |
597 | 34.. 39: ###################################################### 31788 | |
598 | 40.. 45: ###################################################### 31217 | |
599 | 46.. 51: ####################################################### 31790 | |
600 | 52.. 57: ###################################################### 31625 | |
601 | 58.. 63: ###################################################### 31421 | |
602 | 64.. 69: ###################################################### 31732 | |
603 | 70.. 75: ###################################################### 31446 | |
604 | 76.. 81: ###################################################### 31382 | |
605 | 82.. 87: ###################################################### 31623 | |
606 | 88.. 93: ###################################################### 31730 | |
607 | 94.. 99: ##################################################### 31193 | |
608 | 100..105: ###################################################### 31424 | |
609 | 106..111: ###################################################### 31675 | |
610 | 112..117: ###################################################### 31651 | |
611 | 118..123: ###################################################### 31682 | |
612 | 124..129: ################## 10568 | |
613 | ||
614 | +++ Stats for numeral char code dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
615 | ||
616 | stats char code: | |
617 | num: 500000, avg: 52.50, stddev: 2.87, median 52, min 48, max 57 | |
618 | 48: ###################################################### 50260 | |
619 | 49: ###################################################### 49590 | |
620 | 50: ###################################################### 50170 | |
621 | 51: ####################################################### 50270 | |
622 | 52: ###################################################### 49805 | |
623 | 53: ###################################################### 50161 | |
624 | 54: ###################################################### 49919 | |
625 | 55: ###################################################### 49971 | |
626 | 56: ###################################################### 49980 | |
627 | 57: ###################################################### 49874 | |
628 | ||
629 | +++ Stats for tree's depth ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
630 | ||
631 | stats depth: | |
632 | num: 1000, avg: 3.74, stddev: 3.28, median 3, min 1, max 15 | |
633 | 1: ####################################################### 377 | |
634 | 2: ################ 113 | |
635 | 3: ############ 87 | |
636 | 4: ################# 123 | |
637 | 5: ########### 81 | |
638 | 6: #### 33 | |
639 | 7: ##### 40 | |
640 | 8: ##### 39 | |
641 | 9: # 9 | |
642 | 10: ### 25 | |
643 | 11: ####### 49 | |
644 | 12: 4 | |
645 | 13: # 9 | |
646 | 14: # 7 | |
647 | 15: 4 | |
648 | ||
649 | +++ Stats for range_subset_spec ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
650 | ||
651 | stats dist: | |
652 | num: 5000, avg: 9.97, stddev: 6.08, median 10, min 0, max 20 | |
653 | 0: ################################################# 246 | |
654 | 1: ################################################ 244 | |
655 | 2: ################################################ 240 | |
656 | 3: ################################################ 243 | |
657 | 4: ############################################## 232 | |
658 | 5: ############################################## 230 | |
659 | 6: ############################################### 239 | |
660 | 7: ############################################### 235 | |
661 | 8: ####################################################### 274 | |
662 | 9: ############################################## 233 | |
663 | 10: ########################################## 212 | |
664 | 11: ############################################## 231 | |
665 | 12: ############################################### 239 | |
666 | 13: ############################################# 226 | |
667 | 14: ############################################# 225 | |
668 | 15: ################################################### 256 | |
669 | 16: ################################################ 240 | |
670 | 17: ############################################# 229 | |
671 | 18: ################################################ 243 | |
672 | 19: ################################################## 253 | |
673 | 20: ############################################## 230 | |
674 | ||
675 | +++ Stats for string_size len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
676 | ||
677 | stats len: | |
678 | num: 5000, avg: 7.49, stddev: 1.70, median 7, min 5, max 10 | |
679 | 5: ##################################################### 837 | |
680 | 6: ##################################################### 826 | |
681 | 7: ###################################################### 843 | |
682 | 8: ####################################################### 855 | |
683 | 9: #################################################### 813 | |
684 | 10: ##################################################### 826 | |
685 | ||
686 | +++ Stats for string len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
687 | ||
688 | stats len: | |
689 | num: 5000, avg: 384.53, stddev: 1330.61, median 9, min 0, max 9969 | |
690 | 0.. 498: ####################################################### 4246 | |
691 | 499.. 997: ###### 518 | |
692 | 998..1496: 21 | |
693 | 1497..1995: 10 | |
694 | 1996..2494: 11 | |
695 | 2495..2993: 10 | |
696 | 2994..3492: 13 | |
697 | 3493..3991: 13 | |
698 | 3992..4490: 5 | |
699 | 4491..4989: 10 | |
700 | 4990..5488: 19 | |
701 | 5489..5987: 9 | |
702 | 5988..6486: 10 | |
703 | 6487..6985: 12 | |
704 | 6986..7484: 17 | |
705 | 7485..7983: 16 | |
706 | 7984..8482: 16 | |
707 | 8483..8981: 16 | |
708 | 8982..9480: 16 | |
709 | 9481..9979: 12 | |
710 | ||
711 | +++ Stats for string_of len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
712 | ||
713 | stats len: | |
714 | num: 5000, avg: 363.14, stddev: 1245.80, median 9, min 0, max 9986 | |
715 | 0.. 499: ####################################################### 4270 | |
716 | 500.. 999: ###### 493 | |
717 | 1000.. 1499: 16 | |
718 | 1500.. 1999: 11 | |
719 | 2000.. 2499: 15 | |
720 | 2500.. 2999: 17 | |
721 | 3000.. 3499: 11 | |
722 | 3500.. 3999: 19 | |
723 | 4000.. 4499: 14 | |
724 | 4500.. 4999: 10 | |
725 | 5000.. 5499: 16 | |
726 | 5500.. 5999: 11 | |
727 | 6000.. 6499: 15 | |
728 | 6500.. 6999: 13 | |
729 | 7000.. 7499: 12 | |
730 | 7500.. 7999: 16 | |
731 | 8000.. 8499: 11 | |
732 | 8500.. 8999: 4 | |
733 | 9000.. 9499: 13 | |
734 | 9500.. 9999: 13 | |
735 | ||
736 | +++ Stats for printable_string len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
737 | ||
738 | stats len: | |
739 | num: 5000, avg: 384.53, stddev: 1330.61, median 9, min 0, max 9969 | |
740 | 0.. 498: ####################################################### 4246 | |
741 | 499.. 997: ###### 518 | |
742 | 998..1496: 21 | |
743 | 1497..1995: 10 | |
744 | 1996..2494: 11 | |
745 | 2495..2993: 10 | |
746 | 2994..3492: 13 | |
747 | 3493..3991: 13 | |
748 | 3992..4490: 5 | |
749 | 4491..4989: 10 | |
750 | 4990..5488: 19 | |
751 | 5489..5987: 9 | |
752 | 5988..6486: 10 | |
753 | 6487..6985: 12 | |
754 | 6986..7484: 17 | |
755 | 7485..7983: 16 | |
756 | 7984..8482: 16 | |
757 | 8483..8981: 16 | |
758 | 8982..9480: 16 | |
759 | 9481..9979: 12 | |
760 | ||
761 | +++ Stats for small_string len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
762 | ||
763 | stats len: | |
764 | num: 5000, avg: 15.57, stddev: 24.36, median 6, min 0, max 99 | |
765 | 0.. 4: #################################################### 1925 | |
766 | 5.. 9: ####################################################### 2005 | |
767 | 10.. 14: # 52 | |
768 | 15.. 19: # 50 | |
769 | 20.. 24: # 55 | |
770 | 25.. 29: # 56 | |
771 | 30.. 34: # 55 | |
772 | 35.. 39: # 49 | |
773 | 40.. 44: # 65 | |
774 | 45.. 49: # 65 | |
775 | 50.. 54: # 55 | |
776 | 55.. 59: # 68 | |
777 | 60.. 64: # 61 | |
778 | 65.. 69: # 65 | |
779 | 70.. 74: # 57 | |
780 | 75.. 79: # 66 | |
781 | 80.. 84: # 65 | |
782 | 85.. 89: # 64 | |
783 | 90.. 94: # 60 | |
784 | 95.. 99: # 62 | |
785 | ||
786 | +++ Stats for pair dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
787 | ||
788 | stats pair sum: | |
789 | num: 500000, avg: 100.02, stddev: 41.22, median 100, min 0, max 200 | |
790 | 0.. 9: ### 2685 | |
791 | 10.. 19: ######## 7622 | |
792 | 20.. 29: ############## 12474 | |
793 | 30.. 39: #################### 17330 | |
794 | 40.. 49: ########################## 22263 | |
795 | 50.. 59: ############################### 26982 | |
796 | 60.. 69: ##################################### 32182 | |
797 | 70.. 79: ########################################### 37125 | |
798 | 80.. 89: ################################################# 42287 | |
799 | 90.. 99: ###################################################### 46691 | |
800 | 100..109: ####################################################### 46977 | |
801 | 110..119: ################################################# 42444 | |
802 | 120..129: ############################################ 37719 | |
803 | 130..139: ###################################### 32595 | |
804 | 140..149: ################################ 27588 | |
805 | 150..159: ########################## 22792 | |
806 | 160..169: #################### 17805 | |
807 | 170..179: ############### 13068 | |
808 | 180..189: ######### 8218 | |
809 | 190..199: ### 3115 | |
810 | 200..209: 38 | |
811 | ||
812 | +++ Stats for triple dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
813 | ||
814 | stats triple sum: | |
815 | num: 500000, avg: 150.08, stddev: 50.51, median 150, min 0, max 299 | |
816 | 0.. 14: 345 | |
817 | 15.. 29: ## 2121 | |
818 | 30.. 44: ##### 5372 | |
819 | 45.. 59: ########## 10501 | |
820 | 60.. 74: ################# 17031 | |
821 | 75.. 89: ######################### 25417 | |
822 | 90..104: ################################### 35148 | |
823 | 105..119: ############################################# 45134 | |
824 | 120..134: ################################################### 51751 | |
825 | 135..149: ####################################################### 55090 | |
826 | 150..164: ###################################################### 55074 | |
827 | 165..179: #################################################### 52238 | |
828 | 180..194: ############################################# 45651 | |
829 | 195..209: ################################### 35994 | |
830 | 210..224: ######################### 26039 | |
831 | 225..239: ################# 17749 | |
832 | 240..254: ########## 10870 | |
833 | 255..269: ##### 5765 | |
834 | 270..284: ## 2313 | |
835 | 285..299: 397 | |
836 | ||
837 | +++ Stats for quad dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
838 | ||
839 | stats quad sum: | |
840 | num: 500000, avg: 200.13, stddev: 58.33, median 200, min 5, max 394 | |
841 | 5.. 24: 102 | |
842 | 25.. 44: 842 | |
843 | 45.. 64: ## 3023 | |
844 | 65.. 84: ###### 7154 | |
845 | 85..104: ############ 14368 | |
846 | 105..124: ##################### 25397 | |
847 | 125..144: ############################### 37547 | |
848 | 145..164: ########################################## 50174 | |
849 | 165..184: ################################################## 60558 | |
850 | 185..204: ####################################################### 65376 | |
851 | 205..224: ##################################################### 63687 | |
852 | 225..244: ############################################### 56248 | |
853 | 245..264: ###################################### 45384 | |
854 | 265..284: ########################## 31780 | |
855 | 285..304: ################ 20158 | |
856 | 305..324: ######### 10899 | |
857 | 325..344: #### 5045 | |
858 | 345..364: # 1848 | |
859 | 365..384: 386 | |
860 | 385..404: 24 | |
861 | ||
862 | +++ Stats for bind dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
863 | ||
864 | stats ordered pair difference: | |
865 | num: 1000000, avg: 25.02, stddev: 22.36, median 19, min 0, max 100 | |
866 | 0.. 4: ####################################################### 193184 | |
867 | 5.. 9: ##################################### 130024 | |
868 | 10.. 14: ############################# 103828 | |
869 | 15.. 19: ######################## 87496 | |
870 | 20.. 24: ##################### 74431 | |
871 | 25.. 29: ################## 64629 | |
872 | 30.. 34: ################ 56663 | |
873 | 35.. 39: ############# 48986 | |
874 | 40.. 44: ############ 43424 | |
875 | 45.. 49: ########## 37599 | |
876 | 50.. 54: ######### 32787 | |
877 | 55.. 59: ######## 28332 | |
878 | 60.. 64: ###### 24023 | |
879 | 65.. 69: ##### 20312 | |
880 | 70.. 74: #### 16649 | |
881 | 75.. 79: ### 13338 | |
882 | 80.. 84: ## 10239 | |
883 | 85.. 89: ## 7391 | |
884 | 90.. 94: # 4548 | |
885 | 95.. 99: 2015 | |
886 | 100..104: 102 | |
887 | ||
888 | stats ordered pair sum: | |
889 | num: 1000000, avg: 75.12, stddev: 46.93, median 72, min 0, max 200 | |
890 | 0.. 9: ####################################################### 70423 | |
891 | 10.. 19: ##################################################### 68068 | |
892 | 20.. 29: ##################################################### 68449 | |
893 | 30.. 39: ##################################################### 68577 | |
894 | 40.. 49: ##################################################### 68763 | |
895 | 50.. 59: ##################################################### 68351 | |
896 | 60.. 69: ##################################################### 68744 | |
897 | 70.. 79: ##################################################### 68451 | |
898 | 80.. 89: ##################################################### 68309 | |
899 | 90.. 99: ##################################################### 68835 | |
900 | 100..109: ################################################## 64544 | |
901 | 110..119: ########################################### 55512 | |
902 | 120..129: ##################################### 47595 | |
903 | 130..139: ############################### 39809 | |
904 | 140..149: ######################### 32677 | |
905 | 150..159: #################### 26312 | |
906 | 160..169: ############### 20180 | |
907 | 170..179: ########### 14265 | |
908 | 180..189: ###### 8625 | |
909 | 190..199: ## 3433 | |
910 | 200..209: 78 | |
911 | ||
912 | +++ Stats for list len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
913 | ||
914 | stats len: | |
915 | num: 5000, avg: 400.16, stddev: 1371.90, median 9, min 0, max 9987 | |
916 | 0.. 499: ####################################################### 4246 | |
917 | 500.. 999: ###### 502 | |
918 | 1000.. 1499: 13 | |
919 | 1500.. 1999: 10 | |
920 | 2000.. 2499: 14 | |
921 | 2500.. 2999: 14 | |
922 | 3000.. 3499: 20 | |
923 | 3500.. 3999: 7 | |
924 | 4000.. 4499: 13 | |
925 | 4500.. 4999: 16 | |
926 | 5000.. 5499: 12 | |
927 | 5500.. 5999: 15 | |
928 | 6000.. 6499: 15 | |
929 | 6500.. 6999: 13 | |
930 | 7000.. 7499: 16 | |
931 | 7500.. 7999: 12 | |
932 | 8000.. 8499: 11 | |
933 | 8500.. 8999: 16 | |
934 | 9000.. 9499: 15 | |
935 | 9500.. 9999: 20 | |
936 | ||
937 | +++ Stats for small_list len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
938 | ||
939 | stats len: | |
940 | num: 5000, avg: 16.14, stddev: 24.86, median 6, min 0, max 99 | |
941 | 0.. 4: ###################################################### 1923 | |
942 | 5.. 9: ####################################################### 1936 | |
943 | 10.. 14: # 61 | |
944 | 15.. 19: # 59 | |
945 | 20.. 24: # 62 | |
946 | 25.. 29: # 70 | |
947 | 30.. 34: # 61 | |
948 | 35.. 39: # 64 | |
949 | 40.. 44: # 64 | |
950 | 45.. 49: # 56 | |
951 | 50.. 54: # 65 | |
952 | 55.. 59: # 55 | |
953 | 60.. 64: # 60 | |
954 | 65.. 69: # 62 | |
955 | 70.. 74: # 57 | |
956 | 75.. 79: # 69 | |
957 | 80.. 84: ## 73 | |
958 | 85.. 89: # 67 | |
959 | 90.. 94: # 62 | |
960 | 95.. 99: ## 74 | |
961 | ||
962 | +++ Stats for list_of_size len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
963 | ||
964 | stats len: | |
965 | num: 5000, avg: 7.49, stddev: 1.71, median 8, min 5, max 10 | |
966 | 5: ####################################################### 867 | |
967 | 6: ################################################### 813 | |
968 | 7: ################################################### 815 | |
969 | 8: #################################################### 833 | |
970 | 9: ###################################################### 857 | |
971 | 10: ################################################### 815 | |
972 | ||
973 | +++ Stats for list_repeat len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
974 | ||
975 | stats len: | |
976 | num: 5000, avg: 42.00, stddev: 0.00, median 42, min 42, max 42 | |
977 | 42: ####################################################### 5000 | |
978 | ||
979 | +++ Stats for array len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
980 | ||
981 | stats len: | |
982 | num: 5000, avg: 400.16, stddev: 1371.90, median 9, min 0, max 9987 | |
983 | 0.. 499: ####################################################### 4246 | |
984 | 500.. 999: ###### 502 | |
985 | 1000.. 1499: 13 | |
986 | 1500.. 1999: 10 | |
987 | 2000.. 2499: 14 | |
988 | 2500.. 2999: 14 | |
989 | 3000.. 3499: 20 | |
990 | 3500.. 3999: 7 | |
991 | 4000.. 4499: 13 | |
992 | 4500.. 4999: 16 | |
993 | 5000.. 5499: 12 | |
994 | 5500.. 5999: 15 | |
995 | 6000.. 6499: 15 | |
996 | 6500.. 6999: 13 | |
997 | 7000.. 7499: 16 | |
998 | 7500.. 7999: 12 | |
999 | 8000.. 8499: 11 | |
1000 | 8500.. 8999: 16 | |
1001 | 9000.. 9499: 15 | |
1002 | 9500.. 9999: 20 | |
1003 | ||
1004 | +++ Stats for small_array len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
1005 | ||
1006 | stats len: | |
1007 | num: 5000, avg: 16.14, stddev: 24.86, median 6, min 0, max 99 | |
1008 | 0.. 4: ###################################################### 1923 | |
1009 | 5.. 9: ####################################################### 1936 | |
1010 | 10.. 14: # 61 | |
1011 | 15.. 19: # 59 | |
1012 | 20.. 24: # 62 | |
1013 | 25.. 29: # 70 | |
1014 | 30.. 34: # 61 | |
1015 | 35.. 39: # 64 | |
1016 | 40.. 44: # 64 | |
1017 | 45.. 49: # 56 | |
1018 | 50.. 54: # 65 | |
1019 | 55.. 59: # 55 | |
1020 | 60.. 64: # 60 | |
1021 | 65.. 69: # 62 | |
1022 | 70.. 74: # 57 | |
1023 | 75.. 79: # 69 | |
1024 | 80.. 84: ## 73 | |
1025 | 85.. 89: # 67 | |
1026 | 90.. 94: # 62 | |
1027 | 95.. 99: ## 74 | |
1028 | ||
1029 | +++ Stats for array_of_size len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
1030 | ||
1031 | stats len: | |
1032 | num: 5000, avg: 7.49, stddev: 1.71, median 8, min 5, max 10 | |
1033 | 5: ####################################################### 867 | |
1034 | 6: ################################################### 813 | |
1035 | 7: ################################################### 815 | |
1036 | 8: #################################################### 833 | |
1037 | 9: ###################################################### 857 | |
1038 | 10: ################################################### 815 | |
1039 | ||
1040 | +++ Stats for array_repeat len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
1041 | ||
1042 | stats len: | |
1043 | num: 5000, avg: 42.00, stddev: 0.00, median 42, min 42, max 42 | |
1044 | 42: ####################################################### 5000 | |
1045 | ||
1046 | +++ Stats for int_stats_neg ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
1047 | ||
1048 | stats dist: | |
1049 | num: 5000, avg: 0.17, stddev: 29.68, median 0, min -99, max 99 | |
1050 | -99..-90: # 65 | |
1051 | -89..-80: # 63 | |
1052 | -79..-70: # 64 | |
1053 | -69..-60: # 58 | |
1054 | -59..-50: # 67 | |
1055 | -49..-40: # 72 | |
1056 | -39..-30: # 61 | |
1057 | -29..-20: # 61 | |
1058 | -19..-10: # 67 | |
1059 | -9.. 0: ####################################################### 2076 | |
1060 | 1.. 10: ############################################## 1764 | |
1061 | 11.. 20: # 66 | |
1062 | 21.. 30: # 64 | |
1063 | 31.. 40: # 64 | |
1064 | 41.. 50: # 67 | |
1065 | 51.. 60: # 60 | |
1066 | 61.. 70: # 75 | |
1067 | 71.. 80: # 60 | |
1068 | 81.. 90: # 60 | |
1069 | 91..100: # 66 | |
1070 | ||
1071 | +++ Stats for small_signed_int dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
1072 | ||
1073 | stats dist: | |
1074 | num: 1000, avg: 0.90, stddev: 28.23, median 0, min -99, max 99 | |
1075 | -99..-90: # 12 | |
1076 | -89..-80: # 11 | |
1077 | -79..-70: # 9 | |
1078 | -69..-60: 6 | |
1079 | -59..-50: # 11 | |
1080 | -49..-40: # 13 | |
1081 | -39..-30: # 9 | |
1082 | -29..-20: # 13 | |
1083 | -19..-10: 8 | |
1084 | -9.. 0: ####################################################### 453 | |
1085 | 1.. 10: ######################################### 340 | |
1086 | 11.. 20: # 15 | |
1087 | 21.. 30: # 11 | |
1088 | 31.. 40: # 12 | |
1089 | 41.. 50: # 13 | |
1090 | 51.. 60: # 13 | |
1091 | 61.. 70: # 16 | |
1092 | 71.. 80: # 9 | |
1093 | 81.. 90: # 16 | |
1094 | 91..100: # 10 | |
1095 | ||
1096 | +++ Stats for small_nat dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
1097 | ||
1098 | stats dist: | |
1099 | num: 1000, avg: 15.11, stddev: 23.27, median 6, min 0, max 99 | |
1100 | 0.. 4: #################################################### 377 | |
1101 | 5.. 9: ####################################################### 392 | |
1102 | 10.. 14: ## 20 | |
1103 | 15.. 19: ## 15 | |
1104 | 20.. 24: # 11 | |
1105 | 25.. 29: ## 17 | |
1106 | 30.. 34: ## 19 | |
1107 | 35.. 39: ## 17 | |
1108 | 40.. 44: # 10 | |
1109 | 45.. 49: # 9 | |
1110 | 50.. 54: # 8 | |
1111 | 55.. 59: # 9 | |
1112 | 60.. 64: ## 15 | |
1113 | 65.. 69: # 10 | |
1114 | 70.. 74: # 13 | |
1115 | 75.. 79: ## 19 | |
1116 | 80.. 84: # 11 | |
1117 | 85.. 89: # 13 | |
1118 | 90.. 94: 5 | |
1119 | 95.. 99: # 10 | |
1120 | ||
1121 | +++ Stats for nat dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
1122 | ||
1123 | stats dist: | |
1124 | num: 1000, avg: 363.02, stddev: 1215.04, median 9, min 0, max 9476 | |
1125 | 0.. 473: ####################################################### 847 | |
1126 | 474.. 947: ###### 95 | |
1127 | 948..1421: 14 | |
1128 | 1422..1895: 3 | |
1129 | 1896..2369: 0 | |
1130 | 2370..2843: 3 | |
1131 | 2844..3317: 2 | |
1132 | 3318..3791: 3 | |
1133 | 3792..4265: 2 | |
1134 | 4266..4739: 4 | |
1135 | 4740..5213: 3 | |
1136 | 5214..5687: 4 | |
1137 | 5688..6161: 3 | |
1138 | 6162..6635: 4 | |
1139 | 6636..7109: 1 | |
1140 | 7110..7583: 4 | |
1141 | 7584..8057: 2 | |
1142 | 8058..8531: 1 | |
1143 | 8532..9005: 1 | |
1144 | 9006..9479: 4 | |
1145 | ||
1146 | +++ Stats for int_range (-43643) 435434 dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
1147 | ||
1148 | stats dist: | |
1149 | num: 1000, avg: 195335.64, stddev: 136803.99, median 195583, min -43624, max 435210 | |
1150 | -43624..-19683: ############################################ 52 | |
1151 | -19682.. 4259: ######################################## 47 | |
1152 | 4260.. 28201: ############################## 36 | |
1153 | 28202.. 52143: ############################################ 52 | |
1154 | 52144.. 76085: ########################################## 50 | |
1155 | 76086..100027: ####################################################### 64 | |
1156 | 100028..123969: ############################################### 55 | |
1157 | 123970..147911: ######################################## 47 | |
1158 | 147912..171853: ############################################## 54 | |
1159 | 171854..195795: #################################### 43 | |
1160 | 195796..219737: ############################################## 54 | |
1161 | 219738..243679: ########################################### 51 | |
1162 | 243680..267621: ################################################ 57 | |
1163 | 267622..291563: ########################################## 49 | |
1164 | 291564..315505: #################################### 42 | |
1165 | 315506..339447: ###################################### 45 | |
1166 | 339448..363389: ################################################ 57 | |
1167 | 363390..387331: ###################################### 45 | |
1168 | 387332..411273: ########################################## 49 | |
1169 | 411274..435215: ########################################### 51 | |
1170 | ||
1171 | +++ Stats for int_range (-40000) 40000 dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
1172 | ||
1173 | stats dist: | |
1174 | num: 1000, avg: -173.78, stddev: 23042.92, median 180, min -39859, max 39942 | |
1175 | -39859..-35869: ############################################# 56 | |
1176 | -35868..-31878: ################################### 43 | |
1177 | -31877..-27887: ################################################# 60 | |
1178 | -27886..-23896: ##################################### 46 | |
1179 | -23895..-19905: ######################################## 49 | |
1180 | -19904..-15914: #################################### 45 | |
1181 | -15913..-11923: ############################################ 54 | |
1182 | -11922.. -7932: ############################################### 58 | |
1183 | -7931.. -3941: ######################################### 51 | |
1184 | -3940.. 50: ############################ 35 | |
1185 | 51.. 4041: ####################################### 48 | |
1186 | 4042.. 8032: ########################################## 52 | |
1187 | 8033.. 12023: ######################################### 51 | |
1188 | 12024.. 16014: ########################################### 53 | |
1189 | 16015.. 20005: ############################################ 54 | |
1190 | 20006.. 23996: ################################## 42 | |
1191 | 23997.. 27987: ####################################################### 67 | |
1192 | 27988.. 31978: ################################ 40 | |
1193 | 31979.. 35969: ######################################### 51 | |
1194 | 35970.. 39960: #################################### 45 | |
1195 | ||
1196 | +++ Stats for int_range (-4) 4 dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
1197 | ||
1198 | stats dist: | |
1199 | num: 1000, avg: 0.02, stddev: 2.55, median 0, min -4, max 4 | |
1200 | -4: ############################################ 99 | |
1201 | -3: ##################################################### 118 | |
1202 | -2: ################################################## 111 | |
1203 | -1: ################################################## 113 | |
1204 | 0: ################################################## 113 | |
1205 | 1: ##################################################### 118 | |
1206 | 2: ############################################# 102 | |
1207 | 3: ####################################################### 122 | |
1208 | 4: ############################################## 104 | |
1209 | ||
1210 | +++ Stats for int_range (-4) 17 dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
1211 | ||
1212 | stats dist: | |
1213 | num: 1000, avg: 6.67, stddev: 6.39, median 7, min -4, max 17 | |
1214 | -4..-3: ############################################# 90 | |
1215 | -2..-1: ############################################# 91 | |
1216 | 0.. 1: ########################################## 84 | |
1217 | 2.. 3: ############################################## 92 | |
1218 | 4.. 5: ########################################### 87 | |
1219 | 6.. 7: ########################################### 86 | |
1220 | 8.. 9: ############################################ 89 | |
1221 | 10..11: ########################################### 87 | |
1222 | 12..13: ####################################################### 110 | |
1223 | 14..15: ############################################# 91 | |
1224 | 16..17: ############################################## 93 | |
1225 | 18..19: 0 | |
1226 | 20..21: 0 | |
1227 | 22..23: 0 | |
1228 | 24..25: 0 | |
1229 | 26..27: 0 | |
1230 | 28..29: 0 | |
1231 | 30..31: 0 | |
1232 | 32..33: 0 | |
1233 | 34..35: 0 | |
1234 | ||
1235 | +++ Stats for int dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
1236 | ||
1237 | stats dist: | |
1238 | num: 100000, avg: 2541076923587387.50, stddev: 2660730801206827008.00, median 158655268318060, min -4611522359435274428, max 4611540922436307689 | |
1239 | -4611522359435274428..-4150369195341695293: ##################################################### 4976 | |
1240 | -4150369195341695292..-3689216031248116157: ##################################################### 4963 | |
1241 | -3689216031248116156..-3228062867154537021: ###################################################### 5038 | |
1242 | -3228062867154537020..-2766909703060957885: ##################################################### 4979 | |
1243 | -2766909703060957884..-2305756538967378749: ##################################################### 5001 | |
1244 | -2305756538967378748..-1844603374873799613: ##################################################### 4982 | |
1245 | -1844603374873799612..-1383450210780220477: ##################################################### 5025 | |
1246 | -1383450210780220476.. -922297046686641341: #################################################### 4901 | |
1247 | -922297046686641340.. -461143882593062205: ####################################################### 5126 | |
1248 | -461143882593062204.. 9281500516931: ##################################################### 5008 | |
1249 | 9281500516932.. 461162445594096067: ###################################################### 5041 | |
1250 | 461162445594096068.. 922315609687675203: ##################################################### 5001 | |
1251 | 922315609687675204.. 1383468773781254339: ##################################################### 4986 | |
1252 | 1383468773781254340.. 1844621937874833475: ##################################################### 4949 | |
1253 | 1844621937874833476.. 2305775101968412611: ##################################################### 5025 | |
1254 | 2305775101968412612.. 2766928266061991747: ##################################################### 5022 | |
1255 | 2766928266061991748.. 3228081430155570883: ##################################################### 4958 | |
1256 | 3228081430155570884.. 3689234594249150019: ##################################################### 4998 | |
1257 | 3689234594249150020.. 4150387758342729155: ##################################################### 4982 | |
1258 | 4150387758342729156.. 4611540922436308291: ###################################################### 5039 | |
1259 | ||
1260 | +++ Stats for oneof int dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
1261 | ||
1262 | stats dist: | |
1263 | num: 1000, avg: 4611686018427388.00, stddev: 2905870896563567616.00, median 0, min -4611686018427387904, max 4611686018427387903 | |
1264 | -4611686018427387904..-4150517416584649089: ################## 208 | |
1265 | -4150517416584649088..-3689348814741910273: 0 | |
1266 | -3689348814741910272..-3228180212899171457: 0 | |
1267 | -3228180212899171456..-2767011611056432641: 0 | |
1268 | -2767011611056432640..-2305843009213693825: 0 | |
1269 | -2305843009213693824..-1844674407370955009: 0 | |
1270 | -1844674407370955008..-1383505805528216193: 0 | |
1271 | -1383505805528216192.. -922337203685477377: 0 | |
1272 | -922337203685477376.. -461168601842738561: 0 | |
1273 | -461168601842738560.. 255: ####################################################### 603 | |
1274 | 256.. 461168601842739071: 0 | |
1275 | 461168601842739072.. 922337203685477887: 0 | |
1276 | 922337203685477888.. 1383505805528216703: 0 | |
1277 | 1383505805528216704.. 1844674407370955519: 0 | |
1278 | 1844674407370955520.. 2305843009213694335: 0 | |
1279 | 2305843009213694336.. 2767011611056433151: 0 | |
1280 | 2767011611056433152.. 3228180212899171967: 0 | |
1281 | 3228180212899171968.. 3689348814741910783: 0 | |
1282 | 3689348814741910784.. 4150517416584649599: 0 | |
1283 | 4150517416584649600.. 4611686018427387903: ################# 189 | |
1284 | ================================================================================ | |
1285 | 1 warning(s) | |
1286 | failure (59 tests failed, 3 tests errored, ran 139 tests) | |
1287 | random seed: 153870556 | |
1288 | ||
1289 | +++ Stats for int_dist_empty_bucket ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
1290 | ||
1291 | stats dist: | |
1292 | num: 1000, avg: -55083208105414400.00, stddev: 1847115855773139200.00, median 9, min -4590718933436425025, max 4611686018427387903 | |
1293 | -4590718933436425025..-4130598685843234370: ## 26 | |
1294 | -4130598685843234369..-3670478438250043714: # 13 | |
1295 | -3670478438250043713..-3210358190656853058: ### 37 | |
1296 | -3210358190656853057..-2750237943063662402: ### 30 | |
1297 | -2750237943063662401..-2290117695470471746: ## 27 | |
1298 | -2290117695470471745..-1829997447877281090: ## 24 | |
1299 | -1829997447877281089..-1369877200284090434: ## 27 | |
1300 | -1369877200284090433.. -909756952690899778: ## 27 | |
1301 | -909756952690899777.. -449636705097709122: ## 21 | |
1302 | -449636705097709121.. 10483542495481534: ####################################################### 531 | |
1303 | 10483542495481535.. 470603790088672190: ## 21 | |
1304 | 470603790088672191.. 930724037681862846: ## 27 | |
1305 | 930724037681862847.. 1390844285275053502: ## 24 | |
1306 | 1390844285275053503.. 1850964532868244158: ## 25 | |
1307 | 1850964532868244159.. 2311084780461434814: ## 28 | |
1308 | 2311084780461434815.. 2771205028054625470: ## 23 | |
1309 | 2771205028054625471.. 3231325275647816126: ## 23 | |
1310 | 3231325275647816127.. 3691445523241006782: ## 25 | |
1311 | 3691445523241006783.. 4151565770834197438: # 17 | |
1312 | 4151565770834197439.. 4611686018427387903: ## 24 | |
1313 | ================================================================================ | |
1314 | success (ran 1 tests) |
0 | (** QCheck(1) tests **) | |
1 | ||
2 | (** Module representing a tree data structure, used in tests *) | |
3 | module IntTree = struct | |
4 | type tree = Leaf of int | Node of tree * tree | |
5 | ||
6 | let leaf x = Leaf x | |
7 | let node x y = Node (x,y) | |
8 | ||
9 | let rec depth = function | |
10 | | Leaf _ -> 1 | |
11 | | Node (x, y) -> 1 + max (depth x) (depth y) | |
12 | ||
13 | let rec print_tree = function | |
14 | | Leaf x -> Printf.sprintf "Leaf %d" x | |
15 | | Node (x, y) -> Printf.sprintf "Node (%s, %s)" (print_tree x) (print_tree y) | |
16 | ||
17 | let gen_tree = QCheck.Gen.(sized @@ fix | |
18 | (fun self n -> match n with | |
19 | | 0 -> map leaf nat | |
20 | | n -> | |
21 | frequency | |
22 | [1, map leaf nat; | |
23 | 2, map2 node (self (n/2)) (self (n/2))] | |
24 | )) | |
25 | ||
26 | let rec rev_tree = function | |
27 | | Node (x, y) -> Node (rev_tree y, rev_tree x) | |
28 | | Leaf x -> Leaf x | |
29 | ||
30 | let passing_tree_rev = | |
31 | QCheck.Test.make ~count:1000 | |
32 | ~name:"tree_rev_is_involutive" | |
33 | QCheck.(make gen_tree) | |
34 | (fun tree -> rev_tree (rev_tree tree) = tree) | |
35 | end | |
36 | ||
37 | (* tests of overall functionality *) | |
38 | module Overall = struct | |
39 | open QCheck | |
40 | ||
41 | let passing = | |
42 | Test.make ~name:"list_rev_is_involutive" ~count:100 ~long_factor:100 | |
43 | (list small_int) (fun l -> List.rev (List.rev l) = l) | |
44 | ||
45 | let failing = | |
46 | Test.make ~name:"should_fail_sort_id" ~count:10 | |
47 | (small_list small_int) (fun l -> l = List.sort compare l) | |
48 | ||
49 | exception Error | |
50 | ||
51 | let error = | |
52 | Test.make ~name:"should_error_raise_exn" ~count:10 | |
53 | int (fun _ -> raise Error) | |
54 | ||
55 | let collect = | |
56 | Test.make ~name:"collect_results" ~count:100 ~long_factor:100 | |
57 | (make ~collect:string_of_int (Gen.int_bound 4)) | |
58 | (fun _ -> true) | |
59 | ||
60 | let stats = | |
61 | Test.make ~name:"with_stats" ~count:100 ~long_factor:100 | |
62 | (make (Gen.int_bound 120) | |
63 | ~stats:[ | |
64 | "mod4", (fun i->i mod 4); | |
65 | "num", (fun i->i); | |
66 | ]) | |
67 | (fun _ -> true) | |
68 | ||
69 | let bad_assume_warn = | |
70 | Test.make ~name:"WARN_unlikely_precond" ~count:2_000 | |
71 | int | |
72 | (fun x -> | |
73 | QCheck.assume (x mod 100 = 1); | |
74 | true) | |
75 | ||
76 | let bad_assume_fail = | |
77 | Test.make ~name:"FAIL_unlikely_precond" ~count:2_000 | |
78 | ~if_assumptions_fail:(`Fatal, 0.1) | |
79 | int | |
80 | (fun x -> | |
81 | QCheck.assume (x mod 100 = 1); | |
82 | true) | |
83 | end | |
84 | ||
85 | (* positive tests of the various generators | |
86 | ||
87 | Note: it is important to disable shrinking for these tests, as the | |
88 | shrinkers will suggest inputs that are coming from the generator | |
89 | themselves -- which we want to test -- so their reduced | |
90 | counter-example are confusing rather than helpful. | |
91 | ||
92 | This is achieved by using (Test.make ~print ...), without a ~shrink | |
93 | argument. | |
94 | *) | |
95 | module Generator = struct | |
96 | open QCheck | |
97 | ||
98 | (* example from issue #23 *) | |
99 | let char_dist_issue_23 = | |
100 | Test.make ~name:"char never produces '\\255'" ~count:1_000_000 char (fun c -> c <> '\255') | |
101 | ||
102 | let char_test = | |
103 | Test.make ~name:"char has right range'" ~count:1000 | |
104 | char (fun c -> '\000' <= c && c <= '\255') | |
105 | ||
106 | let nat_test = | |
107 | Test.make ~name:"nat has right range" ~count:1000 | |
108 | (make ~print:Print.int Gen.nat) (fun n -> 0 <= n && n < 10000) | |
109 | ||
110 | let string_test = | |
111 | Test.make ~name:"string has right length and content" ~count:1000 | |
112 | string | |
113 | (fun s -> | |
114 | let len = String.length s in | |
115 | 0 <= len && len < 10000 | |
116 | && String.to_seq s |> | |
117 | Seq.fold_left (fun acc c -> acc && '\000' <= c && c <= '\255') true) | |
118 | ||
119 | let list_test = | |
120 | Test.make ~name:"list has right length" ~count:1000 | |
121 | (list unit) (fun l -> let len = List.length l in 0 <= len && len < 10_000) | |
122 | ||
123 | let list_repeat_test = | |
124 | let gen = Gen.(small_nat >>= fun i -> list_repeat i unit >>= fun l -> return (i,l)) in | |
125 | Test.make ~name:"list_repeat has constant length" ~count:1000 | |
126 | (make ~print:Print.(pair int (list unit)) gen) (fun (i,l) -> List.length l = i) | |
127 | ||
128 | let array_repeat_test = | |
129 | let gen = Gen.(small_nat >>= fun i -> array_repeat i unit >>= fun l -> return (i,l)) in | |
130 | Test.make ~name:"array_repeat has constant length" ~count:1000 | |
131 | (make ~print:Print.(pair int (array unit)) gen) (fun (i,l) -> Array.length l = i) | |
132 | ||
133 | let passing_tree_rev = | |
134 | QCheck.Test.make ~count:1000 | |
135 | ~name:"tree_rev_is_involutive" | |
136 | QCheck.(make IntTree.gen_tree) | |
137 | (fun tree -> IntTree.(rev_tree (rev_tree tree)) = tree) | |
138 | ||
139 | let nat_split2_spec = | |
140 | Test.make ~name:"nat_split2 spec" | |
141 | (make | |
142 | ~print:Print.(pair int (pair int int)) | |
143 | Gen.(small_nat >>= fun n -> | |
144 | pair (return n) (nat_split2 n))) | |
145 | (fun (n, (a, b)) -> | |
146 | 0 <= a && 0 <= b && a + b = n) | |
147 | ||
148 | let pos_split2_spec = | |
149 | Test.make ~name:"pos_split2 spec" | |
150 | (make | |
151 | ~print:Print.(pair int (pair int int)) | |
152 | Gen.(small_nat >>= fun n -> | |
153 | (* we need n > 2 *) | |
154 | let n = n + 2 in | |
155 | pair (return n) (pos_split2 n))) | |
156 | (fun (n, (a, b)) -> | |
157 | (0 < a && 0 < b && a + b = n)) | |
158 | ||
159 | let range_subset_spec = | |
160 | Test.make ~name:"range_subset_spec" | |
161 | (make | |
162 | ~print:Print.(quad int int int (array int)) | |
163 | Gen.(pair small_nat small_nat >>= fun (m, n) -> | |
164 | (* we must guarantee [low <= high] | |
165 | and [size <= high - low + 1] *) | |
166 | let low = m and high = m + n in | |
167 | int_range 0 (high - low + 1) >>= fun size -> | |
168 | quad (return size) (return low) (return high) | |
169 | (range_subset ~size low high))) | |
170 | (fun (size, low, high, arr) -> | |
171 | if size = 0 then arr = [||] | |
172 | else | |
173 | Array.length arr = size | |
174 | && low <= arr.(0) | |
175 | && Array.for_all (fun (a, b) -> a < b) | |
176 | (Array.init (size - 1) (fun k -> arr.(k), arr.(k+1))) | |
177 | && arr.(size - 1) <= high) | |
178 | ||
179 | let nat_split_n_way = | |
180 | Test.make ~name:"nat_split n-way" | |
181 | (make | |
182 | ~print:Print.(pair int (array int)) | |
183 | Gen.(small_nat >>= fun n -> | |
184 | pair (return n) (nat_split ~size:n n))) | |
185 | (fun (n, arr) -> | |
186 | Array.length arr = n | |
187 | && Array.for_all (fun k -> 0 <= k) arr | |
188 | && Array.fold_left (+) 0 arr = n) | |
189 | ||
190 | let nat_split_smaller = | |
191 | Test.make ~name:"nat_split smaller" | |
192 | (make | |
193 | ~print:Print.(triple int int (array int)) | |
194 | Gen.(small_nat >>= fun size -> | |
195 | int_bound size >>= fun n -> | |
196 | triple (return size) (return n) (nat_split ~size n))) | |
197 | (fun (m, n, arr) -> | |
198 | Array.length arr = m | |
199 | && Array.for_all (fun k -> 0 <= k) arr | |
200 | && Array.fold_left (+) 0 arr = n) | |
201 | ||
202 | let pos_split = | |
203 | Test.make ~name:"pos_split" | |
204 | (make | |
205 | ~print:Print.(triple int int (array int)) | |
206 | Gen.(pair small_nat small_nat >>= fun (m, n) -> | |
207 | (* we need both size>0 and n>0 and size <= n *) | |
208 | let size = 1 + min m n and n = 1 + max m n in | |
209 | triple (return size) (return n) (pos_split ~size n))) | |
210 | (fun (m, n, arr) -> | |
211 | Array.length arr = m | |
212 | && Array.for_all (fun k -> 0 < k) arr | |
213 | && Array.fold_left (+) 0 arr = n) | |
214 | end | |
215 | ||
216 | (* negative tests that exercise shrinking behaviour *) | |
217 | module Shrink = struct | |
218 | open QCheck | |
219 | ||
220 | let rec fac n = match n with | |
221 | | 0 -> 1 | |
222 | | n -> n * fac (n - 1) | |
223 | ||
224 | (* example from issue #59 *) | |
225 | let test_fac_issue59 = | |
226 | Test.make ~name:"test fac issue59" | |
227 | (set_shrink Shrink.nil (small_int_corners ())) | |
228 | (fun n -> try (fac n) mod n = 0 | |
229 | with | |
230 | (*| Stack_overflow -> false*) | |
231 | | Division_by_zero -> (n=0)) | |
232 | ||
233 | let big_bound_issue59 = | |
234 | Test.make ~name:"big bound issue59" | |
235 | (small_int_corners()) (fun i -> i < 209609) | |
236 | ||
237 | let long_shrink = | |
238 | let listgen = list_of_size (Gen.int_range 1000 10000) int in | |
239 | Test.make ~name:"long_shrink" (pair listgen listgen) | |
240 | (fun (xs,ys) -> List.rev (xs@ys) = (List.rev xs)@(List.rev ys)) | |
241 | ||
242 | let ints_arent_0_mod_3 = | |
243 | Test.make ~name:"ints arent 0 mod 3" ~count:1000 | |
244 | int (fun i -> i mod 3 <> 0) | |
245 | ||
246 | let ints_are_0 = | |
247 | Test.make ~name:"ints are 0" ~count:1000 | |
248 | int (fun i -> Printf.printf "%i\n" i; i = 0) | |
249 | ||
250 | (* test from issue #59 *) | |
251 | let ints_smaller_209609 = | |
252 | Test.make ~name:"ints < 209609" | |
253 | (small_int_corners()) (fun i -> i < 209609) | |
254 | ||
255 | let nats_smaller_5001 = | |
256 | Test.make ~name:"nat < 5001" ~count:1000 | |
257 | (make ~print:Print.int ~shrink:Shrink.int Gen.nat) (fun n -> n < 5001) | |
258 | ||
259 | let char_is_never_abcdef = | |
260 | Test.make ~name:"char is never produces 'abcdef'" ~count:1000 | |
261 | char (fun c -> not (List.mem c ['a';'b';'c';'d';'e';'f'])) | |
262 | ||
263 | let strings_are_empty = | |
264 | Test.make ~name:"strings are empty" ~count:1000 | |
265 | string (fun s -> s = "") | |
266 | ||
267 | let string_never_has_000_char = | |
268 | Test.make ~name:"string never has a \\000 char" ~count:1000 | |
269 | string | |
270 | (fun s -> String.to_seq s |> Seq.fold_left (fun acc c -> acc && c <> '\000') true) | |
271 | ||
272 | let string_never_has_255_char = | |
273 | Test.make ~name:"string never has a \\255 char" ~count:1000 | |
274 | string | |
275 | (fun s -> String.to_seq s |> Seq.fold_left (fun acc c -> acc && c <> '\255') true) | |
276 | ||
277 | let print_list xs = print_endline Print.(list int xs) | |
278 | (* test from issue #64 *) | |
279 | let lists_are_empty_issue_64 = | |
280 | Test.make ~name:"lists are empty" | |
281 | (list small_int) (fun xs -> print_list xs; xs = []) | |
282 | ||
283 | let list_shorter_10 = | |
284 | Test.make ~name:"lists shorter than 10" | |
285 | (list small_int) (fun xs -> List.length xs < 10) | |
286 | ||
287 | let length_printer xs = | |
288 | Printf.sprintf "[...] list length: %i" (List.length xs) | |
289 | ||
290 | let size_gen = Gen.(oneof [small_nat; int_bound 750_000]) | |
291 | ||
292 | let list_shorter_432 = | |
293 | Test.make ~name:"lists shorter than 432" | |
294 | (set_print length_printer (list_of_size size_gen small_int)) | |
295 | (fun xs -> List.length xs < 432) | |
296 | ||
297 | let list_shorter_4332 = | |
298 | Test.make ~name:"lists shorter than 4332" | |
299 | (set_shrink Shrink.list_spine (set_print length_printer (list_of_size size_gen small_int))) | |
300 | (fun xs -> List.length xs < 4332) | |
301 | ||
302 | let list_equal_dupl = | |
303 | Test.make ~name:"lists equal to duplication" | |
304 | (list_of_size size_gen small_int) | |
305 | (fun xs -> try xs = xs @ xs | |
306 | with Stack_overflow -> false) | |
307 | ||
308 | let list_unique_elems = | |
309 | Test.make ~name:"lists have unique elems" | |
310 | (list small_int) | |
311 | (fun xs -> let ys = List.sort_uniq Int.compare xs in | |
312 | print_list xs; List.length xs = List.length ys) | |
313 | end | |
314 | ||
315 | (* tests function generator and shrinker *) | |
316 | module Function = struct | |
317 | open QCheck | |
318 | ||
319 | let fail_pred_map_commute = | |
320 | Test.make ~name:"fail_pred_map_commute" ~count:100 ~long_factor:100 | |
321 | (triple | |
322 | (small_list small_int) | |
323 | (fun1 Observable.int int) | |
324 | (fun1 Observable.int bool)) | |
325 | (fun (l,Fun (_,f),Fun (_,p)) -> | |
326 | List.filter p (List.map f l) = List.map f (List.filter p l)) | |
327 | ||
328 | let fail_pred_strings = | |
329 | Test.make ~name:"fail_pred_strings" ~count:100 | |
330 | (fun1 Observable.string bool) | |
331 | (fun (Fun (_,p)) -> not (p "some random string") || p "some other string") | |
332 | ||
333 | let int_gen = small_nat (* int *) | |
334 | ||
335 | (* Another example (false) property *) | |
336 | let prop_foldleft_foldright = | |
337 | Test.make ~name:"fold_left fold_right" ~count:1000 ~long_factor:20 | |
338 | (triple | |
339 | int_gen | |
340 | (list int_gen) | |
341 | (fun2 Observable.int Observable.int int_gen)) | |
342 | (fun (z,xs,f) -> | |
343 | let l1 = List.fold_right (Fn.apply f) xs z in | |
344 | let l2 = List.fold_left (Fn.apply f) z xs in | |
345 | if l1=l2 then true | |
346 | else Test.fail_reportf "l=%s, fold_left=%s, fold_right=%s@." | |
347 | (Print.(list int) xs) | |
348 | (Print.int l1) | |
349 | (Print.int l2) | |
350 | ) | |
351 | ||
352 | (* Another example (false) property *) | |
353 | let prop_foldleft_foldright_uncurry = | |
354 | Test.make ~name:"fold_left fold_right uncurried" ~count:1000 ~long_factor:20 | |
355 | (triple | |
356 | (fun1 Observable.(pair int int) int_gen) | |
357 | int_gen | |
358 | (list int_gen)) | |
359 | (fun (f,z,xs) -> | |
360 | List.fold_right (fun x y -> Fn.apply f (x,y)) xs z = | |
361 | List.fold_left (fun x y -> Fn.apply f (x,y)) z xs) | |
362 | ||
363 | (* Same as the above (false) property, but generating+shrinking functions last *) | |
364 | let prop_foldleft_foldright_uncurry_funlast = | |
365 | Test.make ~name:"fold_left fold_right uncurried fun last" ~count:1000 ~long_factor:20 | |
366 | (triple | |
367 | int_gen | |
368 | (list int_gen) | |
369 | (fun1 Observable.(pair int int) int_gen)) | |
370 | (fun (z,xs,f) -> | |
371 | List.fold_right (fun x y -> Fn.apply f (x,y)) xs z = | |
372 | List.fold_left (fun x y -> Fn.apply f (x,y)) z xs) | |
373 | ||
374 | (* test from issue #64 *) | |
375 | let fold_left_test = | |
376 | Test.make ~name:"false fold, fun first" | |
377 | (quad (* string -> int -> string *) | |
378 | (fun2 Observable.string Observable.int small_string) | |
379 | small_string | |
380 | (list small_int) | |
381 | (list small_int)) | |
382 | (fun (f,acc,is,js) -> | |
383 | let f = Fn.apply f in | |
384 | List.fold_left f acc (is @ js) | |
385 | = List.fold_left f (List.fold_left f acc is) is) (*Typo*) | |
386 | end | |
387 | ||
388 | (* tests of (inner) find_example(_gen) behaviour *) | |
389 | module FindExample = struct | |
390 | open QCheck | |
391 | ||
392 | let find_ex = | |
393 | Test.make ~name:"find_example" (2--50) | |
394 | (fun n -> | |
395 | let st = Random.State.make [| 0 |] in | |
396 | let f m = n < m && m < 2 * n in | |
397 | try | |
398 | let m = find_example_gen ~rand:st ~count:100_000 ~f Gen.(0 -- 1000) in | |
399 | f m | |
400 | with No_example_found _ -> false) | |
401 | ||
402 | let find_ex_uncaught_issue_99_1_fail = | |
403 | let rs = make (find_example ~count:10 ~f:(fun _ -> false) Gen.int) in | |
404 | Test.make ~name:"FAIL_#99_1" rs (fun _ -> true) | |
405 | ||
406 | let find_ex_uncaught_issue_99_2_succeed = | |
407 | Test.make ~name:"should_succeed_#99_2" ~count:10 | |
408 | int (fun i -> i <= max_int) | |
409 | end | |
410 | ||
411 | (* tests of statistics and histogram display *) | |
412 | module Stats = struct | |
413 | open QCheck | |
414 | ||
415 | let bool_dist = | |
416 | Test.make ~name:"bool dist" ~count:500_000 (set_collect Bool.to_string bool) (fun _ -> true) | |
417 | ||
418 | let char_dist = | |
419 | Test.make ~name:"char code dist" ~count:500_000 (add_stat ("char code", Char.code) char) (fun _ -> true) | |
420 | ||
421 | let string_len_tests = | |
422 | let len = ("len",String.length) in | |
423 | [ | |
424 | Test.make ~name:"string_size len dist" ~count:5_000 (add_stat len (string_of_size (Gen.int_range 5 10))) (fun _ -> true); | |
425 | Test.make ~name:"string len dist" ~count:5_000 (add_stat len string) (fun _ -> true); | |
426 | Test.make ~name:"string_of len dist" ~count:5_000 (add_stat len (string_gen (Gen.return 'a'))) (fun _ -> true); | |
427 | Test.make ~name:"printable_string len dist" ~count:5_000 (add_stat len printable_string) (fun _ -> true); | |
428 | Test.make ~name:"small_string len dist" ~count:5_000 (add_stat len small_string) (fun _ -> true); | |
429 | ] | |
430 | ||
431 | let list_len_tests = | |
432 | let len = ("len",List.length) in | |
433 | [ (* test from issue #30 *) | |
434 | Test.make ~name:"list len dist" ~count:5_000 (add_stat len (list int)) (fun _ -> true); | |
435 | Test.make ~name:"small_list len dist" ~count:5_000 (add_stat len (small_list int)) (fun _ -> true); | |
436 | 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); | |
437 | Test.make ~name:"list_repeat len dist" ~count:5_000 (add_stat len (make Gen.(list_repeat 42 int))) (fun _ -> true); | |
438 | ] | |
439 | ||
440 | let array_len_tests = | |
441 | let len = ("len",Array.length) in | |
442 | [ | |
443 | Test.make ~name:"array len dist" ~count:5_000 (add_stat len (array int)) (fun _ -> true); | |
444 | Test.make ~name:"small_array len dist" ~count:5_000 (add_stat len (make Gen.(small_array int))) (fun _ -> true); | |
445 | 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); | |
446 | Test.make ~name:"array_repeat len dist" ~count:5_000 (add_stat len (make Gen.(array_repeat 42 int))) (fun _ -> true); | |
447 | ] | |
448 | ||
449 | let int_dist_tests = | |
450 | let dist = ("dist",fun x -> x) in | |
451 | [ (* test from issue #40 *) | |
452 | Test.make ~name:"int_stats_neg" ~count:5000 (add_stat dist small_signed_int) (fun _ -> true); | |
453 | (* distribution tests from PR #45 *) | |
454 | Test.make ~name:"small_signed_int dist" ~count:1000 (add_stat dist small_signed_int) (fun _ -> true); | |
455 | Test.make ~name:"small_nat dist" ~count:1000 (add_stat dist small_nat) (fun _ -> true); | |
456 | Test.make ~name:"nat dist" ~count:1000 (add_stat dist (make Gen.nat)) (fun _ -> true); | |
457 | Test.make ~name:"int_range (-43643) 435434 dist" ~count:1000 (add_stat dist (int_range (-43643) 435434)) (fun _ -> true); | |
458 | Test.make ~name:"int_range (-40000) 40000 dist" ~count:1000 (add_stat dist (int_range (-40000) 40000)) (fun _ -> true); | |
459 | Test.make ~name:"int_range (-4) 4 dist" ~count:1000 (add_stat dist (int_range (-4) 4)) (fun _ -> true); | |
460 | Test.make ~name:"int_range (-4) 17 dist" ~count:1000 (add_stat dist (int_range (-4) 17)) (fun _ -> true); | |
461 | Test.make ~name:"int dist" ~count:100000 (add_stat dist int) (fun _ -> true); | |
462 | Test.make ~name:"oneof int dist" ~count:1000 (add_stat dist (oneofl[min_int;-1;0;1;max_int])) (fun _ -> true); | |
463 | ] | |
464 | ||
465 | let int_dist_empty_bucket = | |
466 | Test.make ~name:"int_dist_empty_bucket" ~count:1_000 | |
467 | (add_stat ("dist",fun x -> x) (oneof [small_int_corners ();int])) (fun _ -> true) | |
468 | ||
469 | let tree_depth_test = | |
470 | let depth = ("depth", IntTree.depth) in | |
471 | Test.make ~name:"tree's depth" ~count:1000 (add_stat depth (make IntTree.gen_tree)) (fun _ -> true) | |
472 | ||
473 | let range_subset_test = | |
474 | Test.make ~name:"range_subset_spec" ~count:5_000 | |
475 | (add_stat ("dist", fun a -> a.(0)) (make (Gen.range_subset ~size:1 0 20))) | |
476 | (fun a -> Array.length a = 1) | |
477 | end | |
0 | open QCheck_tests | |
478 | 1 | |
479 | 2 | (* Calling runners *) |
480 | 3 | |
481 | 4 | let () = QCheck_base_runner.set_seed 1234 |
482 | 5 | let _ = |
483 | QCheck_base_runner.run_tests ~colors:false ([ | |
484 | Overall.passing; | |
485 | Overall.failing; | |
486 | Overall.error; | |
487 | Overall.collect; | |
488 | Overall.stats; | |
489 | Overall.bad_assume_warn; | |
490 | Overall.bad_assume_fail; | |
491 | Generator.char_dist_issue_23; | |
492 | Generator.char_test; | |
493 | Generator.nat_test; | |
494 | Generator.string_test; | |
495 | Generator.list_test; | |
496 | Generator.list_repeat_test; | |
497 | Generator.array_repeat_test; | |
498 | Generator.passing_tree_rev; | |
499 | Generator.nat_split2_spec; | |
500 | Generator.pos_split2_spec; | |
501 | Generator.range_subset_spec; | |
502 | Generator.nat_split_n_way; | |
503 | Generator.nat_split_smaller; | |
504 | Generator.pos_split; | |
505 | (*Shrink.test_fac_issue59;*) | |
506 | Shrink.big_bound_issue59; | |
507 | Shrink.long_shrink; | |
508 | Shrink.ints_arent_0_mod_3; | |
509 | Shrink.ints_are_0; | |
510 | Shrink.ints_smaller_209609; | |
511 | Shrink.nats_smaller_5001; | |
512 | Shrink.char_is_never_abcdef; | |
513 | Shrink.strings_are_empty; | |
514 | Shrink.string_never_has_000_char; | |
515 | Shrink.string_never_has_255_char; | |
516 | Shrink.lists_are_empty_issue_64; | |
517 | Shrink.list_shorter_10; | |
518 | Shrink.list_shorter_432; | |
519 | Shrink.list_shorter_4332; | |
520 | Shrink.list_equal_dupl; | |
521 | Shrink.list_unique_elems; | |
522 | Function.fail_pred_map_commute; | |
523 | Function.fail_pred_strings; | |
524 | Function.prop_foldleft_foldright; | |
525 | Function.prop_foldleft_foldright_uncurry; | |
526 | Function.prop_foldleft_foldright_uncurry_funlast; | |
527 | Function.fold_left_test; | |
528 | FindExample.find_ex; | |
529 | FindExample.find_ex_uncaught_issue_99_1_fail; | |
530 | FindExample.find_ex_uncaught_issue_99_2_succeed; | |
531 | Stats.bool_dist; | |
532 | Stats.char_dist; | |
533 | Stats.tree_depth_test; | |
534 | Stats.range_subset_test] | |
535 | @ Stats.string_len_tests | |
536 | @ Stats.list_len_tests | |
537 | @ Stats.array_len_tests | |
538 | @ Stats.int_dist_tests) | |
6 | QCheck_base_runner.run_tests ~colors:false ( | |
7 | Overall.tests @ | |
8 | Generator.tests @ | |
9 | Shrink.tests @ | |
10 | Function.tests @ | |
11 | FindExample.tests @ | |
12 | Stats.tests) | |
539 | 13 | |
540 | 14 | let () = QCheck_base_runner.set_seed 153870556 |
541 | 15 | let _ = QCheck_base_runner.run_tests ~colors:false [Stats.int_dist_empty_bucket] |
0 | (** QCheck(1) tests **) | |
1 | ||
2 | (* Please add any additional tests to both [QCheck_tests.ml] and [QCheck2_tests.ml]. | |
3 | This ensures that both generator approaches continue to work as expected | |
4 | and furthermore allows us to compare their behaviour with | |
5 | [diff -y test/core/QCheck_expect_test.expected test/core/QCheck2_expect_test.expected] *) | |
6 | ||
7 | (** Module representing a tree data structure, used in tests *) | |
8 | module IntTree = struct | |
9 | open QCheck | |
10 | ||
11 | type tree = Leaf of int | Node of tree * tree | |
12 | ||
13 | let leaf x = Leaf x | |
14 | let node x y = Node (x,y) | |
15 | ||
16 | let rec depth = function | |
17 | | Leaf _ -> 1 | |
18 | | Node (x, y) -> 1 + max (depth x) (depth y) | |
19 | ||
20 | let rec print_tree = function | |
21 | | Leaf x -> Printf.sprintf "Leaf %d" x | |
22 | | Node (x, y) -> Printf.sprintf "Node (%s, %s)" (print_tree x) (print_tree y) | |
23 | ||
24 | let gen_tree = Gen.(sized @@ fix | |
25 | (fun self n -> match n with | |
26 | | 0 -> map leaf nat | |
27 | | n -> | |
28 | frequency | |
29 | [1, map leaf nat; | |
30 | 2, map2 node (self (n/2)) (self (n/2))] | |
31 | )) | |
32 | ||
33 | let rec shrink_tree t = match t with | |
34 | | Leaf l -> Iter.map (fun l' -> Leaf l') (Shrink.int l) | |
35 | | Node (x,y) -> | |
36 | let open Iter in | |
37 | of_list [x;y] | |
38 | <+> map (fun x' -> Node (x',y)) (shrink_tree x) | |
39 | <+> map (fun y' -> Node (x,y')) (shrink_tree y) | |
40 | ||
41 | let rec rev_tree = function | |
42 | | Node (x, y) -> Node (rev_tree y, rev_tree x) | |
43 | | Leaf x -> Leaf x | |
44 | ||
45 | let rec contains_only_n tree n = match tree with | |
46 | | Leaf n' -> n = n' | |
47 | | Node (x, y) -> contains_only_n x n && contains_only_n y n | |
48 | end | |
49 | ||
50 | (* tests of overall functionality *) | |
51 | module Overall = struct | |
52 | open QCheck | |
53 | ||
54 | let passing = | |
55 | Test.make ~name:"list_rev_is_involutive" ~count:100 ~long_factor:100 | |
56 | (list small_int) (fun l -> List.rev (List.rev l) = l) | |
57 | ||
58 | let failing = | |
59 | Test.make ~name:"should_fail_sort_id" ~count:10 | |
60 | (small_list small_int) (fun l -> l = List.sort compare l) | |
61 | ||
62 | exception Error | |
63 | ||
64 | let error = | |
65 | Test.make ~name:"should_error_raise_exn" ~count:10 | |
66 | int (fun _ -> raise Error) | |
67 | ||
68 | let collect = | |
69 | Test.make ~name:"collect_results" ~count:100 ~long_factor:100 | |
70 | (make ~collect:string_of_int (Gen.int_bound 4)) | |
71 | (fun _ -> true) | |
72 | ||
73 | let stats = | |
74 | Test.make ~name:"with_stats" ~count:100 ~long_factor:100 | |
75 | (make (Gen.int_bound 120) | |
76 | ~stats:[ | |
77 | "mod4", (fun i->i mod 4); | |
78 | "num", (fun i->i); | |
79 | ]) | |
80 | (fun _ -> true) | |
81 | ||
82 | let retries = | |
83 | Test.make ~name:"with shrinking retries" ~retries:10 | |
84 | small_nat (fun i -> Printf.printf "%i %!" i; i mod 3 <> 1) | |
85 | ||
86 | let bad_assume_warn = | |
87 | Test.make ~name:"WARN_unlikely_precond" ~count:2_000 | |
88 | int | |
89 | (fun x -> | |
90 | QCheck.assume (x mod 100 = 1); | |
91 | true) | |
92 | ||
93 | let bad_assume_fail = | |
94 | Test.make ~name:"FAIL_unlikely_precond" ~count:2_000 | |
95 | ~if_assumptions_fail:(`Fatal, 0.1) | |
96 | int | |
97 | (fun x -> | |
98 | QCheck.assume (x mod 100 = 1); | |
99 | true) | |
100 | ||
101 | let bad_gen_fail = | |
102 | Test.make ~name:"FAIL_bad_gen" | |
103 | (make Gen.(int >>= fun j -> int_bound j >>= fun i -> return (i,j))) | |
104 | (fun (_i,_j) -> true) (* i may be negative, causing int_bound to fail *) | |
105 | ||
106 | let bad_shrinker_fail = | |
107 | Test.make ~name:"FAIL_bad_shrinker" | |
108 | (make | |
109 | ~shrink:(fun _i -> raise Error) | |
110 | Gen.int) | |
111 | (fun _i -> false) | |
112 | ||
113 | let neg_test_fail_as_expected = | |
114 | Test.make_neg ~name:"all ints are even" small_int (fun i -> i mod 2 = 0) | |
115 | ||
116 | let neg_test_unexpected_success = | |
117 | Test.make_neg ~name:"int double" small_int (fun i -> i + i = i * 2) | |
118 | ||
119 | let neg_test_fail_with_shrinking = | |
120 | Test.make_neg ~name:"list rev concat" | |
121 | (pair (list small_int) (list small_int)) (fun (is,js) -> (List.rev is)@(List.rev js) = List.rev (is@js)) | |
122 | ||
123 | let pos_test_fails_with_error = | |
124 | Test.make ~name:"pos fail with error" small_int (fun _i -> raise Error) | |
125 | ||
126 | let neg_test_fail_with_error = | |
127 | Test.make_neg ~name:"neg fail with error" small_int (fun _i -> raise Error) | |
128 | ||
129 | (* [apply_n f x n] computes f(f(...f(x))) with n applications of f *) | |
130 | let rec apply_n f x n = | |
131 | if n=0 | |
132 | then x | |
133 | else apply_n f (f x) (pred n) | |
134 | ||
135 | (* test from #236 *) | |
136 | let bad_fun_repro = | |
137 | let sleep_time = 0.175 in | |
138 | let count = ref 0 in | |
139 | Test.make ~count:10 ~name:"bad function reproducability" | |
140 | (set_shrink Shrink.nil (triple small_int (fun1 Observable.int small_int) small_int)) | |
141 | (fun (i,f,j) -> | |
142 | incr count; | |
143 | Printf.printf "(%i,fun,%i)%s%!" i j (if !count mod 10 = 0 then "\n" else " "); | |
144 | Unix.sleepf sleep_time; | |
145 | if 1 = Float.to_int (Unix.time ()) mod 2 | |
146 | then | |
147 | (ignore(apply_n (Fn.apply f) i j > 0); true) | |
148 | else | |
149 | (ignore(apply_n (Fn.apply f) i i > 0); true)) | |
150 | ||
151 | let tests = [ | |
152 | passing; | |
153 | failing; | |
154 | error; | |
155 | collect; | |
156 | stats; | |
157 | retries; | |
158 | bad_assume_warn; | |
159 | bad_assume_fail; | |
160 | bad_gen_fail; | |
161 | (*bad_shrinker_fail;*) | |
162 | neg_test_fail_as_expected; | |
163 | neg_test_unexpected_success; | |
164 | neg_test_fail_with_shrinking; | |
165 | pos_test_fails_with_error; | |
166 | neg_test_fail_with_error; | |
167 | (* we repeat the following multiple times to check the expected output for duplicate lines *) | |
168 | bad_fun_repro; | |
169 | bad_fun_repro; | |
170 | bad_fun_repro; | |
171 | bad_fun_repro; | |
172 | bad_fun_repro; | |
173 | bad_fun_repro; | |
174 | bad_fun_repro; | |
175 | bad_fun_repro; | |
176 | ] | |
177 | end | |
178 | ||
179 | (* positive tests of the various generators *) | |
180 | module Generator = struct | |
181 | open QCheck | |
182 | ||
183 | (* example from issue #23 *) | |
184 | let char_dist_issue_23 = | |
185 | Test.make ~name:"char never produces '\\255'" ~count:1_000_000 char (fun c -> c <> '\255') | |
186 | ||
187 | let char_test = | |
188 | Test.make ~name:"char has right range" ~count:1000 | |
189 | char (fun c -> '\000' <= c && c <= '\255') | |
190 | ||
191 | let printable_test = | |
192 | Test.make ~name:"printable has right range" ~count:1000 | |
193 | printable_char (fun c -> c = '\n' || 32 <= Char.code c && Char.code c <= 126) | |
194 | ||
195 | let numeral_test = | |
196 | Test.make ~name:"numeral has right range" ~count:1000 | |
197 | numeral_char (fun c -> '0' <= c && c <= '9') | |
198 | ||
199 | let nat_test = | |
200 | Test.make ~name:"nat has right range" ~count:1000 | |
201 | (make ~print:Print.int Gen.nat) (fun n -> 0 <= n && n < 10000) | |
202 | ||
203 | let string_test = | |
204 | Test.make ~name:"string has right length and content" ~count:1000 | |
205 | string | |
206 | (fun s -> | |
207 | let len = String.length s in | |
208 | 0 <= len && len < 10000 | |
209 | && String.to_seq s |> | |
210 | Seq.fold_left (fun acc c -> acc && '\000' <= c && c <= '\255') true) | |
211 | ||
212 | let pair_test = | |
213 | Test.make ~name:"int pairs - commute over +" ~count:1000 | |
214 | (pair small_nat small_nat) (fun (i,j) -> i+j = j+i) | |
215 | ||
216 | let triple_test = | |
217 | Test.make ~name:"int triples - associative over +" ~count:1000 | |
218 | (triple small_nat small_nat small_nat) (fun (i,j,k) -> i+(j+k) = (i+j)+k) | |
219 | ||
220 | let quad_test = | |
221 | Test.make ~name:"int quadruples - product of sums" ~count:1000 | |
222 | (quad small_nat small_nat small_nat small_nat) | |
223 | (fun (h,i,j,k) -> (h+i)*(j+k) = h*j + h*k + i*j + i*k) | |
224 | ||
225 | let test_tup2 = | |
226 | Test.make ~count:10 | |
227 | ~name:"forall x in (0, 1): x = (0, 1)" | |
228 | (tup2 (always 0) (always 1)) | |
229 | (fun x -> x = (0, 1)) | |
230 | ||
231 | let test_tup3 = | |
232 | Test.make ~count:10 | |
233 | ~name:"forall x in (0, 1, 2): x = (0, 1, 2)" | |
234 | (tup3 (always 0) (always 1) (always 2)) | |
235 | (fun x -> x = (0, 1, 2)) | |
236 | ||
237 | let test_tup4 = | |
238 | Test.make ~count:10 | |
239 | ~name:"forall x in (0, 1, 2, 3): x = (0, 1, 2, 3)" | |
240 | (tup4 (always 0) (always 1) (always 2) (always 3)) | |
241 | (fun x -> x = (0, 1, 2, 3)) | |
242 | ||
243 | let test_tup5 = | |
244 | Test.make ~count:10 | |
245 | ~name:"forall x in (0, 1, 2, 3, 4): x = (0, 1, 2, 3, 4)" | |
246 | (tup5 (always 0) (always 1) (always 2) (always 3) (always 4)) | |
247 | (fun x -> x = (0, 1, 2, 3, 4)) | |
248 | ||
249 | let test_tup6 = | |
250 | Test.make ~count:10 | |
251 | ~name:"forall x in (0, 1, 2, 3, 4, 5): x = (0, 1, 2, 3, 4, 5)" | |
252 | (tup6 (always 0) (always 1) (always 2) (always 3) (always 4) (always 5)) | |
253 | (fun x -> x = (0, 1, 2, 3, 4, 5)) | |
254 | ||
255 | let test_tup7 = | |
256 | Test.make ~count:10 | |
257 | ~name:"forall x in (0, 1, 2, 3, 4, 5, 6): x = (0, 1, 2, 3, 4, 5, 6)" | |
258 | (tup7 | |
259 | (always 0) (always 1) (always 2) (always 3) (always 4) | |
260 | (always 5) (always 6)) | |
261 | (fun x -> x = (0, 1, 2, 3, 4, 5, 6)) | |
262 | ||
263 | let test_tup8 = | |
264 | Test.make ~count:10 | |
265 | ~name:"forall x in (0, 1, 2, 3, 4, 5, 6, 7): x = (0, 1, 2, 3, 4, 5, 6, 7)" | |
266 | (tup8 | |
267 | (always 0) (always 1) (always 2) (always 3) (always 4) | |
268 | (always 5) (always 6) (always 7)) | |
269 | (fun x -> x = (0, 1, 2, 3, 4, 5, 6, 7)) | |
270 | ||
271 | let test_tup9 = | |
272 | Test.make ~count:10 | |
273 | ~name:"forall x in (0, 1, 2, 3, 4, 5, 6, 7, 8): x = (0, 1, 2, 3, 4, 5, 6, 7, 8)" | |
274 | (tup9 | |
275 | (always 0) (always 1) (always 2) (always 3) (always 4) | |
276 | (always 5) (always 6) (always 7) (always 8)) | |
277 | (fun x -> x = (0, 1, 2, 3, 4, 5, 6, 7, 8)) | |
278 | ||
279 | let bind_test = | |
280 | Test.make ~name:"bind test for ordered pairs" ~count:1000 | |
281 | (make Gen.(small_nat >>= fun j -> int_bound j >>= fun i -> return (i,j))) | |
282 | (fun (i,j) -> i<=j) | |
283 | ||
284 | let bind_pair_list_length = | |
285 | Test.make ~name:"bind list length" ~count:1000 | |
286 | (make Gen.(int_bound 1000 >>= fun len -> | |
287 | list_size (return len) (int_bound 1000) >>= fun xs -> return (len,xs))) | |
288 | (fun (len,xs) -> len = List.length xs) | |
289 | ||
290 | let list_test = | |
291 | Test.make ~name:"list has right length" ~count:1000 | |
292 | (list unit) (fun l -> let len = List.length l in 0 <= len && len < 10_000) | |
293 | ||
294 | let list_repeat_test = | |
295 | let gen = Gen.(small_nat >>= fun i -> list_repeat i unit >>= fun l -> return (i,l)) in | |
296 | Test.make ~name:"list_repeat has constant length" ~count:1000 | |
297 | (make ~print:Print.(pair int (list unit)) gen) (fun (i,l) -> List.length l = i) | |
298 | ||
299 | let array_repeat_test = | |
300 | let gen = Gen.(small_nat >>= fun i -> array_repeat i unit >>= fun l -> return (i,l)) in | |
301 | Test.make ~name:"array_repeat has constant length" ~count:1000 | |
302 | (make ~print:Print.(pair int (array unit)) gen) (fun (i,l) -> Array.length l = i) | |
303 | ||
304 | let passing_tree_rev = | |
305 | Test.make ~name:"tree_rev_is_involutive" ~count:1000 | |
306 | (make IntTree.gen_tree) | |
307 | (fun tree -> IntTree.(rev_tree (rev_tree tree)) = tree) | |
308 | ||
309 | let nat_split2_spec = | |
310 | Test.make ~name:"nat_split2 spec" | |
311 | (make | |
312 | ~print:Print.(pair int (pair int int)) | |
313 | Gen.(small_nat >>= fun n -> | |
314 | pair (return n) (nat_split2 n))) | |
315 | (fun (n, (a, b)) -> | |
316 | 0 <= a && 0 <= b && a + b = n) | |
317 | ||
318 | let pos_split2_spec = | |
319 | Test.make ~name:"pos_split2 spec" | |
320 | (make | |
321 | ~print:Print.(pair int (pair int int)) | |
322 | Gen.(small_nat >>= fun n -> | |
323 | (* we need n > 2 *) | |
324 | let n = n + 2 in | |
325 | pair (return n) (pos_split2 n))) | |
326 | (fun (n, (a, b)) -> | |
327 | (0 < a && 0 < b && a + b = n)) | |
328 | ||
329 | let range_subset_spec = | |
330 | Test.make ~name:"range_subset_spec" | |
331 | (make | |
332 | ~print:Print.(quad int int int (array int)) | |
333 | Gen.(pair small_nat small_nat >>= fun (m, n) -> | |
334 | (* we must guarantee [low <= high] | |
335 | and [size <= high - low + 1] *) | |
336 | let low = m and high = m + n in | |
337 | int_range 0 (high - low + 1) >>= fun size -> | |
338 | quad (return size) (return low) (return high) | |
339 | (range_subset ~size low high))) | |
340 | (fun (size, low, high, arr) -> | |
341 | if size = 0 then arr = [||] | |
342 | else | |
343 | Array.length arr = size | |
344 | && low <= arr.(0) | |
345 | && Array.for_all (fun (a, b) -> a < b) | |
346 | (Array.init (size - 1) (fun k -> arr.(k), arr.(k+1))) | |
347 | && arr.(size - 1) <= high) | |
348 | ||
349 | let nat_split_n_way = | |
350 | Test.make ~name:"nat_split n-way" | |
351 | (make | |
352 | ~print:Print.(pair int (array int)) | |
353 | Gen.(small_nat >>= fun n -> | |
354 | pair (return n) (nat_split ~size:n n))) | |
355 | (fun (n, arr) -> | |
356 | Array.length arr = n | |
357 | && Array.for_all (fun k -> 0 <= k) arr | |
358 | && Array.fold_left (+) 0 arr = n) | |
359 | ||
360 | let nat_split_smaller = | |
361 | Test.make ~name:"nat_split smaller" | |
362 | (make | |
363 | ~print:Print.(triple int int (array int)) | |
364 | Gen.(small_nat >>= fun size -> | |
365 | int_bound size >>= fun n -> | |
366 | triple (return size) (return n) (nat_split ~size n))) | |
367 | (fun (m, n, arr) -> | |
368 | Array.length arr = m | |
369 | && Array.for_all (fun k -> 0 <= k) arr | |
370 | && Array.fold_left (+) 0 arr = n) | |
371 | ||
372 | let pos_split = | |
373 | Test.make ~name:"pos_split" | |
374 | (make | |
375 | ~print:Print.(triple int int (array int)) | |
376 | Gen.(pair small_nat small_nat >>= fun (m, n) -> | |
377 | (* we need both size>0 and n>0 and size <= n *) | |
378 | let size = 1 + min m n and n = 1 + max m n in | |
379 | triple (return size) (return n) (pos_split ~size n))) | |
380 | (fun (m, n, arr) -> | |
381 | Array.length arr = m | |
382 | && Array.for_all (fun k -> 0 < k) arr | |
383 | && Array.fold_left (+) 0 arr = n) | |
384 | ||
385 | let tests = [ | |
386 | char_dist_issue_23; | |
387 | char_test; | |
388 | printable_test; | |
389 | numeral_test; | |
390 | nat_test; | |
391 | string_test; | |
392 | pair_test; | |
393 | triple_test; | |
394 | quad_test; | |
395 | test_tup2; | |
396 | test_tup3; | |
397 | test_tup4; | |
398 | test_tup5; | |
399 | test_tup6; | |
400 | test_tup7; | |
401 | test_tup8; | |
402 | test_tup9; | |
403 | bind_test; | |
404 | bind_pair_list_length; | |
405 | list_test; | |
406 | list_repeat_test; | |
407 | array_repeat_test; | |
408 | passing_tree_rev; | |
409 | nat_split2_spec; | |
410 | pos_split2_spec; | |
411 | range_subset_spec; | |
412 | nat_split_n_way; | |
413 | nat_split_smaller; | |
414 | pos_split; | |
415 | ] | |
416 | end | |
417 | ||
418 | (* negative tests that exercise shrinking behaviour *) | |
419 | module Shrink = struct | |
420 | open QCheck | |
421 | ||
422 | let rec fac n = match n with | |
423 | | 0 -> 1 | |
424 | | n -> n * fac (n - 1) | |
425 | ||
426 | (* example from issue #59 *) | |
427 | let test_fac_issue59 = | |
428 | Test.make ~name:"test fac issue59" | |
429 | (set_shrink Shrink.nil (small_int_corners ())) | |
430 | (fun n -> try (fac n) mod n = 0 | |
431 | with | |
432 | (*| Stack_overflow -> false*) | |
433 | | Division_by_zero -> (n=0)) | |
434 | ||
435 | let big_bound_issue59 = | |
436 | Test.make ~name:"big bound issue59" | |
437 | (small_int_corners()) (fun i -> i < 209609) | |
438 | ||
439 | let long_shrink = | |
440 | let listgen = list_of_size (Gen.int_range 1000 10000) int in | |
441 | Test.make ~name:"long_shrink" (pair listgen listgen) | |
442 | (fun (xs,ys) -> List.rev (xs@ys) = (List.rev xs)@(List.rev ys)) | |
443 | ||
444 | (* test from issue #36 *) | |
445 | let ints_arent_0_mod_3 = | |
446 | Test.make ~name:"ints arent 0 mod 3" ~count:1000 | |
447 | int (fun i -> i mod 3 <> 0) | |
448 | ||
449 | let ints_are_0 = | |
450 | Test.make ~name:"ints are 0" ~count:1000 | |
451 | int (fun i -> Printf.printf "%i\n" i; i = 0) | |
452 | ||
453 | (* test from issue #59 *) | |
454 | let ints_smaller_209609 = | |
455 | Test.make ~name:"ints < 209609" | |
456 | (small_int_corners()) (fun i -> i < 209609) | |
457 | ||
458 | let nats_smaller_5001 = | |
459 | Test.make ~name:"nat < 5001" ~count:1000 | |
460 | (make ~print:Print.int ~shrink:Shrink.int Gen.nat) (fun n -> n < 5001) | |
461 | ||
462 | let char_is_never_abcdef = | |
463 | Test.make ~name:"char never produces 'abcdef'" ~count:1000 | |
464 | char (fun c -> not (List.mem c ['a';'b';'c';'d';'e';'f'])) | |
465 | ||
466 | let printable_is_never_sign = (* should shrink towards 'a', hence produce '&' with highest ascii code 38 *) | |
467 | Test.make ~name:"printable never produces '!\"#$%&'" ~count:1000 | |
468 | printable_char (fun c -> not (List.mem c ['!';'"';'#';'$';'%';'&'])) | |
469 | ||
470 | let numeral_is_never_less_5 = | |
471 | Test.make ~name:"printable never produces less than '5" ~count:1000 | |
472 | numeral_char (fun c -> c >= '5') | |
473 | ||
474 | let strings_are_empty = | |
475 | Test.make ~name:"strings are empty" ~count:1000 | |
476 | string (fun s -> s = "") | |
477 | ||
478 | let string_never_has_000_char = | |
479 | Test.make ~name:"string never has a \\000 char" ~count:1000 | |
480 | string | |
481 | (fun s -> String.to_seq s |> Seq.fold_left (fun acc c -> acc && c <> '\000') true) | |
482 | ||
483 | let string_never_has_255_char = | |
484 | Test.make ~name:"string never has a \\255 char" ~count:1000 | |
485 | string | |
486 | (fun s -> String.to_seq s |> Seq.fold_left (fun acc c -> acc && c <> '\255') true) | |
487 | ||
488 | let string_unique_chars = | |
489 | Test.make ~name:"strings have unique chars" ~count:1000 | |
490 | string | |
491 | (fun s -> | |
492 | let ch_list = String.to_seq s |> List.of_seq in | |
493 | List.length ch_list = List.length (List.sort_uniq Char.compare ch_list)) | |
494 | ||
495 | (* test from issue #167 *) | |
496 | let pair_diff_issue_64 = | |
497 | Test.make ~name:"pairs have different components" | |
498 | (pair small_int small_int) (fun (i,j) -> i<>j) | |
499 | ||
500 | let pair_same = | |
501 | Test.make ~name:"pairs have same components" (pair int int) (fun (i,j) -> i=j) | |
502 | ||
503 | let pair_one_zero = | |
504 | Test.make ~name:"pairs have a zero component" (pair int int) (fun (i,j) -> i=0 || j=0) | |
505 | ||
506 | let pair_all_zero = | |
507 | Test.make ~name:"pairs are (0,0)" (pair int int) (fun (i,j) -> i=0 && j=0) | |
508 | ||
509 | let pair_ordered = | |
510 | Test.make ~name:"pairs are ordered" (pair pos_int pos_int) (fun (i,j) -> i<=j) | |
511 | ||
512 | let pair_ordered_rev = | |
513 | Test.make ~name:"pairs are ordered reversely" (pair pos_int pos_int) (fun (i,j) -> i>=j) | |
514 | ||
515 | let pair_sum_lt_128 = | |
516 | Test.make ~name:"pairs sum to less than 128" (pair pos_int pos_int) (fun (i,j) -> i+j<128) | |
517 | ||
518 | let pair_lists_rev_concat = | |
519 | Test.make ~name:"pairs lists rev concat" | |
520 | (pair (list pos_int) (list pos_int)) | |
521 | (fun (xs,ys) -> List.rev (xs@ys) = (List.rev xs)@(List.rev ys)) | |
522 | ||
523 | let pair_lists_no_overlap = | |
524 | Test.make ~name:"pairs lists no overlap" | |
525 | (pair (list small_nat) (list small_nat)) | |
526 | (fun (xs,ys) -> List.for_all (fun x -> not (List.mem x ys)) xs) | |
527 | ||
528 | let triple_diff = | |
529 | Test.make ~name:"triples have pair-wise different components" | |
530 | (triple small_int small_int small_int) (fun (i,j,k) -> i<>j && j<>k) | |
531 | ||
532 | let triple_same = | |
533 | Test.make ~name:"triples have same components" | |
534 | (triple int int int) (fun (i,j,k) -> i=j || j=k) | |
535 | ||
536 | let triple_ordered = | |
537 | Test.make ~name:"triples are ordered" | |
538 | (triple int int int) (fun (i,j,k) -> i<=j && j<=k) | |
539 | ||
540 | let triple_ordered_rev = | |
541 | Test.make ~name:"triples are ordered reversely" | |
542 | (triple int int int) (fun (i,j,k) -> i>=j && j>=k) | |
543 | ||
544 | let quad_diff = | |
545 | Test.make ~name:"quadruples have pair-wise different components" | |
546 | (quad small_int small_int small_int small_int) (fun (h,i,j,k) -> h<>i && i<>j && j<>k) | |
547 | ||
548 | let quad_same = | |
549 | Test.make ~name:"quadruples have same components" | |
550 | (quad int int int int) (fun (h,i,j,k) -> h=i || i=j || j=k) | |
551 | ||
552 | let quad_ordered = | |
553 | Test.make ~name:"quadruples are ordered" | |
554 | (quad int int int int) (fun (h,i,j,k) -> h <= i && i <= j && j <= k) | |
555 | ||
556 | let quad_ordered_rev = | |
557 | Test.make ~name:"quadruples are ordered reversely" | |
558 | (quad int int int int) (fun (h,i,j,k) -> h >= i && i >= j && j >= k) | |
559 | ||
560 | let test_tup2 = | |
561 | Test.make | |
562 | ~name:"forall (a, b) in nat: a < b" | |
563 | (tup2 small_int small_int) | |
564 | (fun (a, b) -> a < b) | |
565 | ||
566 | let test_tup3 = | |
567 | Test.make | |
568 | ~name:"forall (a, b, c) in nat: a < b < c" | |
569 | (tup3 small_int small_int small_int) | |
570 | (fun (a, b, c) -> a < b && b < c) | |
571 | ||
572 | let test_tup4 = | |
573 | Test.make | |
574 | ~name:"forall (a, b, c, d) in nat: a < b < c < d" | |
575 | (tup4 small_int small_int small_int small_int) | |
576 | (fun (a, b, c, d) -> a < b && b < c && c < d) | |
577 | ||
578 | let test_tup5 = | |
579 | Test.make | |
580 | ~name:"forall (a, b, c, d, e) in nat: a < b < c < d < e" | |
581 | (tup5 small_int small_int small_int small_int small_int) | |
582 | (fun (a, b, c, d, e) -> a < b && b < c && c < d && d < e) | |
583 | ||
584 | let test_tup6 = | |
585 | Test.make | |
586 | ~name:"forall (a, b, c, d, e, f) in nat: a < b < c < d < e < f" | |
587 | (tup6 small_int small_int small_int small_int small_int small_int) | |
588 | (fun (a, b, c, d, e, f) -> a < b && b < c && c < d && d < e && e < f) | |
589 | ||
590 | let test_tup7 = | |
591 | Test.make | |
592 | ~name:"forall (a, b, c, d, e, f, g) in nat: a < b < c < d < e < f < g" | |
593 | (tup7 small_int small_int small_int small_int small_int small_int small_int) | |
594 | (fun (a, b, c, d, e, f, g) -> a < b && b < c && c < d && d < e && e < f && f < g) | |
595 | ||
596 | let test_tup8 = | |
597 | Test.make | |
598 | ~name:"forall (a, b, c, d, e, f, g, h) in nat: a < b < c < d < e < f < g < h" | |
599 | (tup8 small_int small_int small_int small_int small_int small_int small_int small_int) | |
600 | (fun (a, b, c, d, e, f, g, h) -> a < b && b < c && c < d && d < e && e < f && f < g && g < h) | |
601 | ||
602 | let test_tup9 = | |
603 | Test.make | |
604 | ~name:"forall (a, b, c, d, e, f, g, h, i) in nat: a < b < c < d < e < f < g < h < i" | |
605 | (tup9 small_int small_int small_int small_int small_int small_int small_int small_int small_int) | |
606 | (fun (a, b, c, d, e, f, g, h, i) -> a < b && b < c && c < d && d < e && e < f && f < g && g < h && h < i) | |
607 | ||
608 | let bind_pair_ordered = | |
609 | Test.make ~name:"bind ordered pairs" | |
610 | (make ~print:Print.(pair int int) | |
611 | ~shrink:Shrink.(filter (fun (i,j) -> i<=j) (pair int int)) | |
612 | Gen.(pint >>= fun j -> int_bound j >>= fun i -> return (i,j))) | |
613 | (fun (_i,_j) -> false) | |
614 | ||
615 | let bind_pair_list_size = | |
616 | let shrink (_l,xs) = | |
617 | Iter.map (fun xs' -> (List.length xs',xs')) Shrink.(list ~shrink:int xs) in | |
618 | Test.make ~name:"bind list_size constant" | |
619 | (make ~print:Print.(pair int (list int)) ~shrink | |
620 | Gen.(int_bound 1000 >>= fun len -> | |
621 | list_size (return len) (int_bound 1000) >>= fun xs -> return (len,xs))) | |
622 | (fun (len,xs) -> let len' = List.length xs in len=len' && len' < 4) | |
623 | ||
624 | let print_list xs = print_endline Print.(list int xs) | |
625 | ||
626 | (* test from issue #64 *) | |
627 | let lists_are_empty_issue_64 = | |
628 | Test.make ~name:"lists are empty" | |
629 | (list small_int) (fun xs -> print_list xs; xs = []) | |
630 | ||
631 | let list_shorter_10 = | |
632 | Test.make ~name:"lists shorter than 10" | |
633 | (list small_int) (fun xs -> List.length xs < 10) | |
634 | ||
635 | let length_printer xs = | |
636 | Printf.sprintf "[...] list length: %i" (List.length xs) | |
637 | ||
638 | let size_gen = Gen.(oneof [small_nat; int_bound 750_000]) | |
639 | ||
640 | let list_shorter_432 = | |
641 | Test.make ~name:"lists shorter than 432" | |
642 | (set_print length_printer (list_of_size size_gen small_int)) | |
643 | (fun xs -> List.length xs < 432) | |
644 | ||
645 | let list_shorter_4332 = | |
646 | Test.make ~name:"lists shorter than 4332" | |
647 | (set_shrink Shrink.list_spine (set_print length_printer (list_of_size size_gen small_int))) | |
648 | (fun xs -> List.length xs < 4332) | |
649 | ||
650 | let list_equal_dupl = | |
651 | Test.make ~name:"lists equal to duplication" | |
652 | (list_of_size size_gen small_int) | |
653 | (fun xs -> try xs = xs @ xs | |
654 | with Stack_overflow -> false) | |
655 | ||
656 | let list_unique_elems = | |
657 | Test.make ~name:"lists have unique elems" | |
658 | (list small_int) | |
659 | (fun xs -> let ys = List.sort_uniq Int.compare xs in | |
660 | print_list xs; List.length xs = List.length ys) | |
661 | ||
662 | let tree_contains_only_42 = | |
663 | Test.make ~name:"tree contains only 42" | |
664 | IntTree.(make ~print:print_tree ~shrink:shrink_tree gen_tree) | |
665 | (fun tree -> IntTree.contains_only_n tree 42) | |
666 | ||
667 | let tests = [ | |
668 | (*test_fac_issue59;*) | |
669 | big_bound_issue59; | |
670 | long_shrink; | |
671 | ints_arent_0_mod_3; | |
672 | ints_are_0; | |
673 | ints_smaller_209609; | |
674 | nats_smaller_5001; | |
675 | char_is_never_abcdef; | |
676 | printable_is_never_sign; | |
677 | numeral_is_never_less_5; | |
678 | strings_are_empty; | |
679 | string_never_has_000_char; | |
680 | string_never_has_255_char; | |
681 | string_unique_chars; | |
682 | pair_diff_issue_64; | |
683 | pair_same; | |
684 | pair_one_zero; | |
685 | pair_all_zero; | |
686 | pair_ordered; | |
687 | pair_ordered_rev; | |
688 | pair_sum_lt_128; | |
689 | pair_lists_rev_concat; | |
690 | pair_lists_no_overlap; | |
691 | triple_diff; | |
692 | triple_same; | |
693 | triple_ordered; | |
694 | triple_ordered_rev; | |
695 | quad_diff; | |
696 | quad_same; | |
697 | quad_ordered; | |
698 | quad_ordered_rev; | |
699 | test_tup2; | |
700 | test_tup3; | |
701 | test_tup4; | |
702 | test_tup5; | |
703 | test_tup6; | |
704 | test_tup7; | |
705 | test_tup8; | |
706 | test_tup9; | |
707 | bind_pair_ordered; | |
708 | bind_pair_list_size; | |
709 | lists_are_empty_issue_64; | |
710 | list_shorter_10; | |
711 | list_shorter_432; | |
712 | list_shorter_4332; | |
713 | (*list_equal_dupl;*) | |
714 | list_unique_elems; | |
715 | tree_contains_only_42; | |
716 | ] | |
717 | end | |
718 | ||
719 | (* tests function generator and shrinker *) | |
720 | module Function = struct | |
721 | open QCheck | |
722 | ||
723 | let fail_pred_map_commute = | |
724 | Test.make ~name:"fail_pred_map_commute" ~count:100 ~long_factor:100 | |
725 | (triple | |
726 | (small_list small_int) | |
727 | (fun1 Observable.int int) | |
728 | (fun1 Observable.int bool)) | |
729 | (fun (l,Fun (_,f),Fun (_,p)) -> | |
730 | List.filter p (List.map f l) = List.map f (List.filter p l)) | |
731 | ||
732 | let fail_pred_strings = | |
733 | Test.make ~name:"fail_pred_strings" ~count:100 | |
734 | (fun1 Observable.string bool) | |
735 | (fun (Fun (_,p)) -> not (p "some random string") || p "some other string") | |
736 | ||
737 | let int_gen = small_nat (* int *) | |
738 | ||
739 | (* Another example (false) property *) | |
740 | let prop_foldleft_foldright = | |
741 | Test.make ~name:"fold_left fold_right" ~count:1000 ~long_factor:20 | |
742 | (triple | |
743 | int_gen | |
744 | (list int_gen) | |
745 | (fun2 Observable.int Observable.int int_gen)) | |
746 | (fun (z,xs,f) -> | |
747 | let l1 = List.fold_right (Fn.apply f) xs z in | |
748 | let l2 = List.fold_left (Fn.apply f) z xs in | |
749 | if l1=l2 then true | |
750 | else Test.fail_reportf "l=%s, fold_left=%s, fold_right=%s@." | |
751 | (Print.(list int) xs) | |
752 | (Print.int l1) | |
753 | (Print.int l2) | |
754 | ) | |
755 | ||
756 | (* Another example (false) property *) | |
757 | let prop_foldleft_foldright_uncurry = | |
758 | Test.make ~name:"fold_left fold_right uncurried" ~count:1000 ~long_factor:20 | |
759 | (triple | |
760 | (fun1 Observable.(pair int int) int_gen) | |
761 | int_gen | |
762 | (list int_gen)) | |
763 | (fun (f,z,xs) -> | |
764 | List.fold_right (fun x y -> Fn.apply f (x,y)) xs z = | |
765 | List.fold_left (fun x y -> Fn.apply f (x,y)) z xs) | |
766 | ||
767 | (* Same as the above (false) property, but generating+shrinking functions last *) | |
768 | let prop_foldleft_foldright_uncurry_funlast = | |
769 | Test.make ~name:"fold_left fold_right uncurried fun last" ~count:1000 ~long_factor:20 | |
770 | (triple | |
771 | int_gen | |
772 | (list int_gen) | |
773 | (fun1 Observable.(pair int int) int_gen)) | |
774 | (fun (z,xs,f) -> | |
775 | List.fold_right (fun x y -> Fn.apply f (x,y)) xs z = | |
776 | List.fold_left (fun x y -> Fn.apply f (x,y)) z xs) | |
777 | ||
778 | (* test from issue #64 *) | |
779 | let fold_left_test = | |
780 | Test.make ~name:"fold_left test, fun first" | |
781 | (quad (* string -> int -> string *) | |
782 | (fun2 Observable.string Observable.int small_string) | |
783 | small_string | |
784 | (list small_int) | |
785 | (list small_int)) | |
786 | (fun (f,acc,is,js) -> | |
787 | let f = Fn.apply f in | |
788 | List.fold_left f acc (is @ js) | |
789 | = List.fold_left f (List.fold_left f acc is) is) (*Typo*) | |
790 | ||
791 | let tests = [ | |
792 | fail_pred_map_commute; | |
793 | fail_pred_strings; | |
794 | prop_foldleft_foldright; | |
795 | prop_foldleft_foldright_uncurry; | |
796 | prop_foldleft_foldright_uncurry_funlast; | |
797 | fold_left_test; | |
798 | ] | |
799 | end | |
800 | ||
801 | (* tests of (inner) find_example(_gen) behaviour *) | |
802 | module FindExample = struct | |
803 | open QCheck | |
804 | ||
805 | let find_ex = | |
806 | Test.make ~name:"find_example" (2--50) | |
807 | (fun n -> | |
808 | let st = Random.State.make [| 0 |] in | |
809 | let f m = n < m && m < 2 * n in | |
810 | try | |
811 | let m = find_example_gen ~rand:st ~count:100_000 ~f Gen.(0 -- 1000) in | |
812 | f m | |
813 | with No_example_found _ -> false) | |
814 | ||
815 | let find_ex_uncaught_issue_99_1_fail = | |
816 | let rs = make (find_example ~count:10 ~f:(fun _ -> false) Gen.int) in | |
817 | Test.make ~name:"FAIL_#99_1" rs (fun _ -> true) | |
818 | ||
819 | let find_ex_uncaught_issue_99_2_succeed = | |
820 | Test.make ~name:"should_succeed_#99_2" ~count:10 | |
821 | int (fun i -> i <= max_int) | |
822 | ||
823 | let tests = [ | |
824 | find_ex; | |
825 | find_ex_uncaught_issue_99_1_fail; | |
826 | find_ex_uncaught_issue_99_2_succeed; | |
827 | ] | |
828 | end | |
829 | ||
830 | (* tests of statistics and histogram display *) | |
831 | module Stats = struct | |
832 | open QCheck | |
833 | ||
834 | let bool_dist = | |
835 | Test.make ~name:"bool dist" ~count:500_000 (set_collect Bool.to_string bool) (fun _ -> true) | |
836 | ||
837 | let char_dist_tests = | |
838 | [ | |
839 | Test.make ~name:"char code dist" ~count:500_000 (add_stat ("char code", Char.code) char) (fun _ -> true); | |
840 | Test.make ~name:"printable char code dist" ~count:500_000 (add_stat ("char code", Char.code) printable_char) (fun _ -> true); | |
841 | Test.make ~name:"numeral char code dist" ~count:500_000 (add_stat ("char code", Char.code) numeral_char) (fun _ -> true); | |
842 | ] | |
843 | ||
844 | let string_len_tests = | |
845 | let len = ("len",String.length) in | |
846 | [ | |
847 | Test.make ~name:"string_size len dist" ~count:5_000 (add_stat len (string_of_size (Gen.int_range 5 10))) (fun _ -> true); | |
848 | Test.make ~name:"string len dist" ~count:5_000 (add_stat len string) (fun _ -> true); | |
849 | Test.make ~name:"string_of len dist" ~count:5_000 (add_stat len (string_gen (Gen.return 'a'))) (fun _ -> true); | |
850 | Test.make ~name:"printable_string len dist" ~count:5_000 (add_stat len printable_string) (fun _ -> true); | |
851 | Test.make ~name:"small_string len dist" ~count:5_000 (add_stat len small_string) (fun _ -> true); | |
852 | ] | |
853 | ||
854 | let pair_dist = | |
855 | Test.make ~name:"pair dist" ~count:500_000 | |
856 | (add_stat ("pair sum", (fun (i,j) -> i+j)) | |
857 | (pair (int_bound 100) (int_bound 100))) (fun _ -> true) | |
858 | ||
859 | let triple_dist = | |
860 | Test.make ~name:"triple dist" ~count:500_000 | |
861 | (add_stat ("triple sum", (fun (i,j,k) -> i+j+k)) | |
862 | (triple (int_bound 100) (int_bound 100) (int_bound 100))) (fun _ -> true) | |
863 | ||
864 | let quad_dist = | |
865 | Test.make ~name:"quad dist" ~count:500_000 | |
866 | (add_stat ("quad sum", (fun (h,i,j,k) -> h+i+j+k)) | |
867 | (quad (int_bound 100) (int_bound 100) (int_bound 100) (int_bound 100))) (fun _ -> true) | |
868 | ||
869 | let bind_dist = | |
870 | Test.make ~name:"bind dist" ~count:1_000_000 | |
871 | (make ~stats:[("ordered pair difference", (fun (i,j) -> j-i));("ordered pair sum", (fun (i,j) -> i+j))] | |
872 | Gen.(int_bound 100 >>= fun j -> int_bound j >>= fun i -> return (i,j))) (fun _ -> true) | |
873 | ||
874 | let list_len_tests = | |
875 | let len = ("len",List.length) in | |
876 | [ (* test from issue #30 *) | |
877 | Test.make ~name:"list len dist" ~count:5_000 (add_stat len (list int)) (fun _ -> true); | |
878 | Test.make ~name:"small_list len dist" ~count:5_000 (add_stat len (small_list int)) (fun _ -> true); | |
879 | 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); | |
880 | Test.make ~name:"list_repeat len dist" ~count:5_000 (add_stat len (make Gen.(list_repeat 42 int))) (fun _ -> true); | |
881 | ] | |
882 | ||
883 | let array_len_tests = | |
884 | let len = ("len",Array.length) in | |
885 | [ | |
886 | Test.make ~name:"array len dist" ~count:5_000 (add_stat len (array int)) (fun _ -> true); | |
887 | Test.make ~name:"small_array len dist" ~count:5_000 (add_stat len (make Gen.(small_array int))) (fun _ -> true); | |
888 | 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); | |
889 | Test.make ~name:"array_repeat len dist" ~count:5_000 (add_stat len (make Gen.(array_repeat 42 int))) (fun _ -> true); | |
890 | ] | |
891 | ||
892 | let int_dist_tests = | |
893 | let dist = ("dist",fun x -> x) in | |
894 | [ (* test from issue #40 *) | |
895 | Test.make ~name:"int_stats_neg" ~count:5000 (add_stat dist small_signed_int) (fun _ -> true); | |
896 | (* distribution tests from PR #45 *) | |
897 | Test.make ~name:"small_signed_int dist" ~count:1000 (add_stat dist small_signed_int) (fun _ -> true); | |
898 | Test.make ~name:"small_nat dist" ~count:1000 (add_stat dist small_nat) (fun _ -> true); | |
899 | Test.make ~name:"nat dist" ~count:1000 (add_stat dist (make Gen.nat)) (fun _ -> true); | |
900 | Test.make ~name:"int_range (-43643) 435434 dist" ~count:1000 (add_stat dist (int_range (-43643) 435434)) (fun _ -> true); | |
901 | Test.make ~name:"int_range (-40000) 40000 dist" ~count:1000 (add_stat dist (int_range (-40000) 40000)) (fun _ -> true); | |
902 | Test.make ~name:"int_range (-4) 4 dist" ~count:1000 (add_stat dist (int_range (-4) 4)) (fun _ -> true); | |
903 | Test.make ~name:"int_range (-4) 17 dist" ~count:1000 (add_stat dist (int_range (-4) 17)) (fun _ -> true); | |
904 | Test.make ~name:"int dist" ~count:100000 (add_stat dist int) (fun _ -> true); | |
905 | Test.make ~name:"oneof int dist" ~count:1000 (add_stat dist (oneofl[min_int;-1;0;1;max_int])) (fun _ -> true); | |
906 | ] | |
907 | ||
908 | let tree_depth_test = | |
909 | let depth = ("depth", IntTree.depth) in | |
910 | Test.make ~name:"tree's depth" ~count:1000 (add_stat depth (make IntTree.gen_tree)) (fun _ -> true) | |
911 | ||
912 | let range_subset_test = | |
913 | Test.make ~name:"range_subset_spec" ~count:5_000 | |
914 | (add_stat ("dist", fun a -> a.(0)) (make (Gen.range_subset ~size:1 0 20))) | |
915 | (fun a -> Array.length a = 1) | |
916 | ||
917 | let int_dist_empty_bucket = | |
918 | Test.make ~name:"int_dist_empty_bucket" ~count:1_000 | |
919 | (add_stat ("dist",fun x -> x) (oneof [small_int_corners ();int])) (fun _ -> true) | |
920 | ||
921 | let tests = | |
922 | [ bool_dist; ] | |
923 | @ char_dist_tests | |
924 | @ [tree_depth_test; | |
925 | range_subset_test;] | |
926 | @ string_len_tests | |
927 | @ [pair_dist; | |
928 | triple_dist; | |
929 | quad_dist; | |
930 | bind_dist;] | |
931 | @ list_len_tests | |
932 | @ array_len_tests | |
933 | @ int_dist_tests | |
934 | end |
0 | open QCheck | |
1 | ||
2 | module Shrink = struct | |
3 | ||
4 | let trace_false shrinker x = | |
5 | let res = ref [] in | |
6 | shrinker x (fun x -> res := x::!res); | |
7 | List.rev !res | |
8 | ||
9 | let trace_true shrinker x = | |
10 | let rec loop x = | |
11 | match Iter.find (fun _ -> true) (shrinker x) with | |
12 | | None -> [] | |
13 | | Some y -> y::loop y in | |
14 | loop x | |
15 | ||
16 | let alco_check typ func msg_suffix (msg,input,expected) = | |
17 | Alcotest.(check (list typ)) (msg ^ " - " ^ msg_suffix) expected (func input) | |
18 | ||
19 | let test_int () = | |
20 | List.iter (alco_check Alcotest.int (trace_false Shrink.int) "on repeated failure") | |
21 | [ ("int 100", 100, [50; 75; 88; 94; 97; 99; 99]); (*WTF?*) | |
22 | ("int 1000", 1000, [500; 750; 875; 938; 969; 985; 993; 997; 999; 999]); (*WTF?*) | |
23 | ("int (-26)", -26, [-13; -20; -23; -25; -25]) ]; (*WTF?*) | |
24 | List.iter (alco_check Alcotest.int (trace_true Shrink.int) "on repeated success") | |
25 | [ ("int 100", 100, [50; 25; 13; 7; 4; 2; 1; 0]); | |
26 | ("int 1000", 1000, [500; 250; 125; 63; 32; 16; 8; 4; 2; 1; 0]); | |
27 | ("int (-26)", -26, [-13; -7; -4; -2; -1; 0]) ] | |
28 | ||
29 | let test_int32 () = | |
30 | List.iter (alco_check Alcotest.int32 (trace_false Shrink.int32) "on repeated failure") | |
31 | [ ("int 100", 100l, [50l; 75l; 88l; 94l; 97l; 99l; 99l]); | |
32 | ("int 1000", 1000l, [500l; 750l; 875l; 938l; 969l; 985l; 993l; 997l; 999l; 999l]); | |
33 | ("int (-26)", -26l, [-13l; -20l; -23l; -25l; -25l]) ]; | |
34 | List.iter (alco_check Alcotest.int32 (trace_true Shrink.int32) "on repeated success") | |
35 | [ ("int 100", 100l, [50l; 25l; 13l; 7l; 4l; 2l; 1l; 0l]); | |
36 | ("int 1000", 1000l, [500l; 250l; 125l; 63l; 32l; 16l; 8l; 4l; 2l; 1l; 0l]); | |
37 | ("int (-26)", -26l, [-13l; -7l; -4l; -2l; -1l; 0l]) ] | |
38 | ||
39 | let test_int64 () = | |
40 | List.iter (alco_check Alcotest.int64 (trace_false Shrink.int64) "on repeated failure") | |
41 | [ ("int 100", 100L, [50L; 75L; 88L; 94L; 97L; 99L; 99L]); | |
42 | ("int 1000", 1000L, [500L; 750L; 875L; 938L; 969L; 985L; 993L; 997L; 999L; 999L]); | |
43 | ("int (-26)", -26L, [-13L; -20L; -23L; -25L; -25L]) ]; | |
44 | List.iter (alco_check Alcotest.int64 (trace_true Shrink.int64) "on repeated success") | |
45 | [ ("int 100", 100L, [50L; 25L; 13L; 7L; 4L; 2L; 1L; 0L]); | |
46 | ("int 1000", 1000L, [500L; 250L; 125L; 63L; 32L; 16L; 8L; 4L; 2L; 1L; 0L]); | |
47 | ("int (-26)", -26L, [-13L; -7L; -4L; -2L; -1L; 0L]) ] | |
48 | ||
49 | let test_char () = | |
50 | List.iter (alco_check Alcotest.char (trace_false Shrink.char) "on repeated failure") | |
51 | [ ("char 'a'", 'a', []); | |
52 | ("char 'z'", 'z', ['n'; 't'; 'w'; 'y'; 'y']); (*WTF?*) | |
53 | ("char 'A'", 'A', ['Q'; 'I'; 'E'; 'C'; 'B']); | |
54 | ("char '~'", '~', ['p'; 'w'; '{'; '}'; '}']) ]; (*WTF?*) | |
55 | List.iter (alco_check Alcotest.char (trace_true Shrink.char) "on repeated success") | |
56 | [ ("char 'a'", 'a', []); | |
57 | ("char 'z'", 'z', ['n'; 'h'; 'e'; 'c'; 'b'; 'a']); | |
58 | ("char 'A'", 'A', ['Q'; 'Y'; ']'; '_'; '`'; 'a']); | |
59 | ("char '~'", '~', ['p'; 'i'; 'e'; 'c'; 'b'; 'a']); ] | |
60 | ||
61 | let test_char_numeral () = | |
62 | List.iter (alco_check Alcotest.char (trace_false Shrink.char_numeral) "on repeated failure") | |
63 | [ ("char '0'", '0', []); | |
64 | ("char '9'", '9', ['5'; '7'; '8']) ]; | |
65 | List.iter (alco_check Alcotest.char (trace_true Shrink.char_numeral) "on repeated success") | |
66 | [ ("char '0'", '0', []); | |
67 | ("char '9'", '9', ['5'; '3'; '2'; '1'; '0']); ] | |
68 | ||
69 | let test_char_printable () = | |
70 | List.iter (alco_check Alcotest.char (trace_false Shrink.char_printable) "on repeated failure") | |
71 | [ ("char 'A'", 'A', ['Q'; 'I'; 'E'; 'C'; 'B']); | |
72 | ("char 'a'", 'a', []); | |
73 | ("char ' '", ' ', ['@'; '0'; '('; '$'; '"'; '!']); | |
74 | ("char '~'", '~', ['p'; 'w'; '{'; '}'; '}']); (*WTF?*) | |
75 | ("char '\\n'", '\n', ['p'; 'w'; '{'; '}'; '}']); ]; (*WTF?*) | |
76 | List.iter (alco_check Alcotest.char (trace_true Shrink.char_printable) "on repeated success") | |
77 | [ ("char 'A'", 'A', ['Q'; 'Y'; ']'; '_'; '`'; 'a']); | |
78 | ("char 'a'", 'a', []); | |
79 | ("char ' '", ' ', ['@'; 'P'; 'X'; '\\'; '^'; '_'; '`'; 'a']); | |
80 | ("char '~'", '~', ['p'; 'i'; 'e'; 'c'; 'b'; 'a']); | |
81 | ("char '\\n'", '\n', ['p'; 'i'; 'e'; 'c'; 'b'; 'a']); ] | |
82 | ||
83 | let tests = ("Shrink", Alcotest.[ | |
84 | test_case "int" `Quick test_int; | |
85 | test_case "int32" `Quick test_int32; | |
86 | test_case "int64" `Quick test_int64; | |
87 | test_case "char" `Quick test_char; | |
88 | test_case "char_numeral" `Quick test_char_numeral; | |
89 | test_case "char_printable" `Quick test_char_printable; | |
90 | ]) | |
91 | end | |
92 | ||
93 | module Check_exn = struct | |
94 | ||
95 | (* String.starts_with was introduced in 4.13. | |
96 | Include the below to support pre-4.13 OCaml. *) | |
97 | let string_starts_with ~prefix s = | |
98 | let prefix_len = String.length prefix in | |
99 | prefix_len <= String.length s | |
100 | && prefix = String.sub s 0 prefix_len | |
101 | ||
102 | let check_exn = Test.check_exn | |
103 | ||
104 | let test_pass_trivial () = | |
105 | let run_test () = check_exn QCheck.(Test.make int (fun _ -> true)) in | |
106 | Alcotest.(check unit) "Success-trivial" () @@ run_test () | |
107 | ||
108 | let test_pass_random () = | |
109 | let run_test () = | |
110 | check_exn QCheck.(Test.make (list int) (fun l -> List.rev (List.rev l) = l)) in | |
111 | Alcotest.(check unit) "Success-random" () @@ run_test () | |
112 | ||
113 | let test_fail_always () = | |
114 | let name = "will-always-fail" in | |
115 | try | |
116 | check_exn QCheck.(Test.make ~name int (fun _ -> false)); | |
117 | Alcotest.failf "%s: Unexpected success" name | |
118 | with | |
119 | (Test.Test_fail (n,[c_ex_str])) -> | |
120 | Alcotest.(check string) (Printf.sprintf "%s: name" name) n name; | |
121 | if not (string_starts_with ~prefix:"0" c_ex_str) | |
122 | then | |
123 | Alcotest.failf "%s: counter-example prefix. Received \"%s\"" name c_ex_str | |
124 | ||
125 | let test_fail_random () = | |
126 | let name = "list is own reverse" in | |
127 | try | |
128 | check_exn QCheck.(Test.make ~name (list int) (fun l -> List.rev l = l)); | |
129 | Alcotest.failf "%s: Unexpected success" name | |
130 | with | |
131 | (Test.Test_fail (n,[c_ex_str])) -> | |
132 | Alcotest.(check string) (Printf.sprintf "%s: name" name) n name; | |
133 | if not (string_starts_with ~prefix:"[0; 1]" c_ex_str | |
134 | || string_starts_with ~prefix:"[0; -1]" c_ex_str) | |
135 | then | |
136 | Alcotest.failf "%s: counter-example prefix. Received \"%s\"" name c_ex_str | |
137 | ||
138 | exception MyError | |
139 | ||
140 | let test_error () = | |
141 | let name = "will-always-error" in | |
142 | try | |
143 | Printexc.record_backtrace false; (* for easier pattern-matching below *) | |
144 | check_exn QCheck.(Test.make ~name int (fun _ -> raise MyError)); | |
145 | Alcotest.failf "%s: Unexpected success" name | |
146 | with | |
147 | (Test.Test_error (n,c_ex_str,MyError,"")) -> | |
148 | Alcotest.(check string) (Printf.sprintf "%s: name" name) n name; | |
149 | if not (string_starts_with ~prefix:"0" c_ex_str) | |
150 | then | |
151 | Alcotest.failf "%s: counter-example prefix. Received \"%s\"" name c_ex_str | |
152 | ||
153 | let tests = | |
154 | ("Test.check_exn", Alcotest.[ | |
155 | test_case "check_exn pass trivial" `Quick test_pass_trivial; | |
156 | test_case "check_exn pass random" `Quick test_pass_random; | |
157 | test_case "check_exn fail always" `Quick test_fail_always; | |
158 | test_case "check_exn fail random" `Quick test_fail_random; | |
159 | test_case "check_exn Error" `Quick test_error; | |
160 | ]) | |
161 | end | |
162 | ||
163 | module TestCount = struct | |
164 | let test_count_n ?count expected = | |
165 | let (Test cell) = QCheck.(Test.make ?count int (fun _ -> true)) in | |
166 | let msg = Printf.sprintf "QCheck.Test.make ~count:%s |> get_count = %d" | |
167 | (Option.fold ~none:"None" ~some:string_of_int count) expected | |
168 | in | |
169 | Alcotest.(check int) msg expected (QCheck.Test.get_count cell) | |
170 | ||
171 | let test_count_10 () = test_count_n ~count:10 10 | |
172 | ||
173 | let test_count_default () = test_count_n 100 | |
174 | ||
175 | let test_count_env () = | |
176 | let () = Unix.putenv "QCHECK_COUNT" "5" in | |
177 | let (Test cell) = QCheck.(Test.make int (fun _ -> true)) in | |
178 | let actual = QCheck.Test.get_count cell in | |
179 | Alcotest.(check int) "default count is from QCHECK_COUNT" 5 actual | |
180 | ||
181 | let test_count_0 () = test_count_n ~count:0 0 | |
182 | ||
183 | let test_count_negative_fail () = | |
184 | try | |
185 | let _ = test_count_n ~count:(-1) (-1) in | |
186 | Alcotest.fail "A negative count in a test should fail" | |
187 | with | |
188 | | _ -> () | |
189 | ||
190 | let tests = | |
191 | ("Test.make ~count", Alcotest.[ | |
192 | test_case "make with custom count" `Quick test_count_10; | |
193 | test_case "make with default count" `Quick test_count_default; | |
194 | test_case "make with env count" `Quick test_count_env; | |
195 | test_case "make with 0 count" `Quick test_count_0; | |
196 | test_case "make with negative count should fail" | |
197 | `Quick test_count_negative_fail; | |
198 | ]) | |
199 | end | |
200 | ||
201 | module TestLongFactor = struct | |
202 | let test_long_factor_n ?long_factor expected = | |
203 | let (Test cell) = QCheck.(Test.make ?long_factor int (fun _ -> true)) in | |
204 | let msg = Printf.sprintf "QCheck.Test.make ~long_factor:%s |> long_factor = %d" | |
205 | (Option.fold ~none:"None" ~some:string_of_int long_factor) expected | |
206 | in | |
207 | Alcotest.(check int) msg expected (QCheck.Test.get_long_factor cell) | |
208 | ||
209 | let test_long_factor_10 () = test_long_factor_n ~long_factor:10 10 | |
210 | ||
211 | let test_long_factor_default () = test_long_factor_n 1 | |
212 | ||
213 | let test_long_factor_env () = | |
214 | let () = Unix.putenv "QCHECK_LONG_FACTOR" "5" in | |
215 | let (Test cell) = QCheck.(Test.make int (fun _ -> true)) in | |
216 | let actual = QCheck.Test.get_long_factor cell in | |
217 | Alcotest.(check int) "default long factor is from QCHECK_LONG_FACTOR" 5 actual | |
218 | ||
219 | let test_long_factor_0 () = test_long_factor_n ~long_factor:0 0 | |
220 | ||
221 | let test_long_factor_negative_fail () = | |
222 | try | |
223 | let _ = test_long_factor_n ~long_factor:(-1) (-1) in | |
224 | Alcotest.fail "A negative long factor in a test should fail" | |
225 | with | |
226 | | _ -> () | |
227 | ||
228 | let tests = | |
229 | ("Test.make ~long_factor", Alcotest.[ | |
230 | test_case "make with custom long_factor" `Quick test_long_factor_10; | |
231 | test_case "make with default long_factor" `Quick test_long_factor_default; | |
232 | test_case "make with env long_factor" `Quick test_long_factor_env; | |
233 | test_case "make with 0 long_factor" `Quick test_long_factor_0; | |
234 | test_case "make with negative long_factor should fail" | |
235 | `Quick test_long_factor_negative_fail; | |
236 | ]) | |
237 | end | |
238 | ||
239 | let () = | |
240 | Alcotest.run "QCheck" | |
241 | [ | |
242 | Shrink.tests; | |
243 | Check_exn.tests; | |
244 | TestCount.tests; | |
245 | TestLongFactor.tests; | |
246 | ] |
0 | (* -*- tuareg -*- *) | |
0 | 1 | |
1 | (test | |
2 | (name test) | |
3 | (modules test) | |
4 | (package qcheck-core) | |
5 | (libraries qcheck-core alcotest)) | |
2 | let dune = Printf.sprintf {| | |
6 | 3 | |
7 | (executables | |
8 | (names QCheck_expect_test QCheck2_expect_test) | |
9 | (modules QCheck_expect_test QCheck2_expect_test) | |
10 | (libraries qcheck-core qcheck-core.runner)) | |
4 | (library | |
5 | (name QCheck_tests) | |
6 | (modules QCheck_tests) | |
7 | (libraries qcheck-core)) | |
11 | 8 | |
12 | ;; rules for QCheck_expect_test | |
9 | (library | |
10 | (name QCheck2_tests) | |
11 | (modules QCheck2_tests) | |
12 | (libraries qcheck-core)) | |
13 | ||
14 | (executable | |
15 | (name QCheck_expect_test) | |
16 | (modules QCheck_expect_test) | |
17 | (libraries qcheck-core qcheck-core.runner QCheck_tests)) | |
18 | ||
13 | 19 | (rule |
14 | (targets qcheck_output.txt) | |
15 | (deps ./QCheck_expect_test.exe) | |
16 | (package qcheck-core) | |
17 | (enabled_if (= %{os_type} "Unix")) | |
20 | (targets QCheck_expect_test.out) | |
18 | 21 | (action |
19 | (with-stdout-to | |
20 | %{targets} | |
21 | (run ./QCheck_expect_test.exe --no-colors)))) | |
22 | (with-stdout-to %%{targets} | |
23 | (run ./QCheck_expect_test.exe --no-colors -s 1234)))) | |
22 | 24 | |
23 | 25 | (rule |
24 | 26 | (alias runtest) |
25 | 27 | (package qcheck-core) |
26 | (enabled_if (= %{os_type} "Unix")) | |
27 | (action (diff qcheck_output.txt.expected qcheck_output.txt))) | |
28 | (action (diff QCheck_expect_test.expected.%i QCheck_expect_test.out))) | |
28 | 29 | |
29 | ;; rules for QCheck2_expect_test | |
30 | (executable | |
31 | (name QCheck2_expect_test) | |
32 | (modules QCheck2_expect_test) | |
33 | (libraries qcheck-core qcheck-core.runner QCheck2_tests)) | |
34 | ||
30 | 35 | (rule |
31 | (targets qcheck2_output.txt) | |
32 | (deps ./QCheck2_expect_test.exe) | |
33 | (package qcheck-core) | |
34 | (enabled_if (= %{os_type} "Unix")) | |
36 | (targets QCheck2_expect_test.out) | |
35 | 37 | (action |
36 | (with-stdout-to | |
37 | %{targets} | |
38 | (run ./QCheck2_expect_test.exe --no-colors)))) | |
38 | (with-stdout-to %%{targets} | |
39 | (run ./QCheck2_expect_test.exe --no-colors -s 1234)))) | |
39 | 40 | |
40 | 41 | (rule |
41 | 42 | (alias runtest) |
42 | 43 | (package qcheck-core) |
43 | (enabled_if (= %{os_type} "Unix")) | |
44 | (action (diff qcheck2_output.txt.expected qcheck2_output.txt))) | |
44 | (action (diff QCheck2_expect_test.expected.%i QCheck2_expect_test.out))) | |
45 | ||
46 | (tests | |
47 | (names QCheck_unit_tests QCheck2_unit_tests) | |
48 | (modules QCheck_unit_tests QCheck2_unit_tests) | |
49 | (package qcheck-core) | |
50 | (libraries qcheck-core alcotest)) | |
51 | ||
52 | (executable | |
53 | (name shrink_benchmark) | |
54 | (modules shrink_benchmark) | |
55 | (libraries qcheck-core qcheck-core.runner QCheck_tests QCheck2_tests)) | |
56 | ||
57 | |} Sys.word_size Sys.word_size | |
58 | ||
59 | let () = Jbuild_plugin.V1.send dune |
0 | random seed: 1234 | |
1 | 2724675603984413065 | |
2 | 0 | |
3 | 1362337801992206532 | |
4 | 0 | |
5 | 681168900996103266 | |
6 | 0 | |
7 | 340584450498051633 | |
8 | 0 | |
9 | 170292225249025816 | |
10 | 0 | |
11 | 85146112624512908 | |
12 | 0 | |
13 | 42573056312256454 | |
14 | 0 | |
15 | 21286528156128227 | |
16 | 0 | |
17 | 10643264078064113 | |
18 | 0 | |
19 | 5321632039032056 | |
20 | 0 | |
21 | 2660816019516028 | |
22 | 0 | |
23 | 1330408009758014 | |
24 | 0 | |
25 | 665204004879007 | |
26 | 0 | |
27 | 332602002439503 | |
28 | 0 | |
29 | 166301001219751 | |
30 | 0 | |
31 | 83150500609875 | |
32 | 0 | |
33 | 41575250304937 | |
34 | 0 | |
35 | 20787625152468 | |
36 | 0 | |
37 | 10393812576234 | |
38 | 0 | |
39 | 5196906288117 | |
40 | 0 | |
41 | 2598453144058 | |
42 | 0 | |
43 | 1299226572029 | |
44 | 0 | |
45 | 649613286014 | |
46 | 0 | |
47 | 324806643007 | |
48 | 0 | |
49 | 162403321503 | |
50 | 0 | |
51 | 81201660751 | |
52 | 0 | |
53 | 40600830375 | |
54 | 0 | |
55 | 20300415187 | |
56 | 0 | |
57 | 10150207593 | |
58 | 0 | |
59 | 5075103796 | |
60 | 0 | |
61 | 2537551898 | |
62 | 0 | |
63 | 1268775949 | |
64 | 0 | |
65 | 634387974 | |
66 | 0 | |
67 | 317193987 | |
68 | 0 | |
69 | 158596993 | |
70 | 0 | |
71 | 79298496 | |
72 | 0 | |
73 | 39649248 | |
74 | 0 | |
75 | 19824624 | |
76 | 0 | |
77 | 9912312 | |
78 | 0 | |
79 | 4956156 | |
80 | 0 | |
81 | 2478078 | |
82 | 0 | |
83 | 1239039 | |
84 | 0 | |
85 | 619519 | |
86 | 0 | |
87 | 309759 | |
88 | 0 | |
89 | 154879 | |
90 | 0 | |
91 | 77439 | |
92 | 0 | |
93 | 38719 | |
94 | 0 | |
95 | 19359 | |
96 | 0 | |
97 | 9679 | |
98 | 0 | |
99 | 4839 | |
100 | 0 | |
101 | 2419 | |
102 | 0 | |
103 | 1209 | |
104 | 0 | |
105 | 604 | |
106 | 0 | |
107 | 302 | |
108 | 0 | |
109 | 151 | |
110 | 0 | |
111 | 75 | |
112 | 0 | |
113 | 37 | |
114 | 0 | |
115 | 18 | |
116 | 0 | |
117 | 9 | |
118 | 0 | |
119 | 4 | |
120 | 0 | |
121 | 2 | |
122 | 0 | |
123 | 1 | |
124 | 0 | |
125 | [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] | |
126 | [] | |
127 | [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] | |
128 | [] | |
129 | [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] | |
130 | [] | |
131 | [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] | |
132 | [] | |
133 | [9; 8; 73; 5; 8; 2; 1; 8; 2; 6; 4; 18; 5; 76; 3] | |
134 | [] | |
135 | [0; 6; 2; 8; 8; 1; 4] | |
136 | [] | |
137 | [5; 2; 3] | |
138 | [] | |
139 | [3] | |
140 | [] | |
141 | [0] | |
142 | [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] | |
143 | [] | |
144 | [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] | |
145 | [] | |
146 | [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] | |
147 | [] | |
148 | [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] | |
149 | [] | |
150 | [9; 8; 73; 5; 8; 2; 1; 8; 2; 6; 4; 18; 5; 76; 3] | |
151 | [] | |
152 | [0; 6; 2; 8; 8; 1; 4] | |
153 | [] | |
154 | [5; 2; 3] | |
155 | [3; 2; 7; 3; 3] | |
156 | [] | |
157 | [5; 3] | |
158 | [5; 3; 2] | |
159 | [9; 87; 7; 0] | |
160 | [0; 2; 7; 3; 3] | |
161 | [0; 0; 7; 3; 3] | |
162 | [0; 0; 0; 3; 3] | |
163 | [0; 0; 0; 0; 3] | |
164 | [0; 0; 0; 0; 0] | |
165 | ||
166 | --- Failure -------------------------------------------------------------------- | |
167 | ||
168 | Test should_fail_sort_id failed (9 shrink steps): | |
169 | ||
170 | [1; 0] | |
171 | ||
172 | === Error ====================================================================== | |
173 | ||
174 | Test should_error_raise_exn errored on (1 shrink steps): | |
175 | ||
176 | 0 | |
177 | ||
178 | exception Dune__exe__QCheck2_expect_test.Overall.Error | |
179 | ||
180 | ||
181 | +++ Collect ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
182 | ||
183 | Collect results for test collect_results: | |
184 | ||
185 | 4: 20 cases | |
186 | 3: 25 cases | |
187 | 2: 17 cases | |
188 | 1: 18 cases | |
189 | 0: 20 cases | |
190 | ||
191 | +++ Stats for with_stats ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
192 | ||
193 | stats mod4: | |
194 | num: 100, avg: 1.68, stddev: 1.09, median 2, min 0, max 3 | |
195 | 0: ############################## 17 | |
196 | 1: ################################################### 29 | |
197 | 2: ######################################## 23 | |
198 | 3: ####################################################### 31 | |
199 | ||
200 | stats num: | |
201 | num: 100, avg: 66.84, stddev: 31.94, median 65, min 2, max 120 | |
202 | 2.. 7: ################## 3 | |
203 | 8.. 13: ################## 3 | |
204 | 14.. 19: 0 | |
205 | 20.. 25: ########################################## 7 | |
206 | 26.. 31: ######################## 4 | |
207 | 32.. 37: ######################## 4 | |
208 | 38.. 43: ################## 3 | |
209 | 44.. 49: ################################################ 8 | |
210 | 50.. 55: #################################### 6 | |
211 | 56.. 61: #################################### 6 | |
212 | 62.. 67: ####################################################### 9 | |
213 | 68.. 73: ########################################## 7 | |
214 | 74.. 79: ######################## 4 | |
215 | 80.. 85: ################## 3 | |
216 | 86.. 91: ############ 2 | |
217 | 92.. 97: ########################################## 7 | |
218 | 98..103: #################################### 6 | |
219 | 104..109: #################################### 6 | |
220 | 110..115: ####################################################### 9 | |
221 | 116..121: ################## 3 | |
222 | ||
223 | !!! Warning !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
224 | ||
225 | Warning for test WARN_unlikely_precond: | |
226 | ||
227 | WARNING: only 0.5% tests (of 2000) passed precondition for "WARN_unlikely_precond" | |
228 | ||
229 | NOTE: it is likely that the precondition is too strong, or that the generator is buggy. | |
230 | ||
231 | --- Failure -------------------------------------------------------------------- | |
232 | ||
233 | Test FAIL_unlikely_precond failed: | |
234 | ||
235 | ERROR: only 0.5% tests (of 2000) passed precondition for "FAIL_unlikely_precond" | |
236 | ||
237 | NOTE: it is likely that the precondition is too strong, or that the generator is buggy. | |
238 | ||
239 | ||
240 | --- Failure -------------------------------------------------------------------- | |
241 | ||
242 | Test char never produces '\255' failed (0 shrink steps): | |
243 | ||
244 | '\255' | |
245 | ||
246 | --- Failure -------------------------------------------------------------------- | |
247 | ||
248 | Test big bound issue59 failed (0 shrink steps): | |
249 | ||
250 | 4611686018427387903 | |
251 | ||
252 | --- Failure -------------------------------------------------------------------- | |
253 | ||
254 | Test long_shrink failed (3039 shrink steps): | |
255 | ||
256 | ([0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0], [0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 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]) | |
257 | ||
258 | --- Failure -------------------------------------------------------------------- | |
259 | ||
260 | Test ints arent 0 mod 3 failed (2 shrink steps): | |
261 | ||
262 | 0 | |
263 | ||
264 | --- Failure -------------------------------------------------------------------- | |
265 | ||
266 | Test ints are 0 failed (61 shrink steps): | |
267 | ||
268 | 1 | |
269 | ||
270 | --- Failure -------------------------------------------------------------------- | |
271 | ||
272 | Test ints < 209609 failed (0 shrink steps): | |
273 | ||
274 | 4611686018427387903 | |
275 | ||
276 | --- Failure -------------------------------------------------------------------- | |
277 | ||
278 | Test nat < 5001 failed (7 shrink steps): | |
279 | ||
280 | 5001 | |
281 | ||
282 | --- Failure -------------------------------------------------------------------- | |
283 | ||
284 | Test char is never produces 'abcdef' failed (1 shrink steps): | |
285 | ||
286 | 'a' | |
287 | ||
288 | --- Failure -------------------------------------------------------------------- | |
289 | ||
290 | Test strings are empty failed (8 shrink steps): | |
291 | ||
292 | "a" | |
293 | ||
294 | --- Failure -------------------------------------------------------------------- | |
295 | ||
296 | Test string never has a \000 char failed (22 shrink steps): | |
297 | ||
298 | "aaaaaa\000aaaaaaaaaaaaaaaa" | |
299 | ||
300 | --- Failure -------------------------------------------------------------------- | |
301 | ||
302 | Test string never has a \255 char failed (59 shrink steps): | |
303 | ||
304 | "aaaaaaaaaaaaaaaaaaaaaaaaaa\255aaaaaaaaaaaaaaaaaaaaaaaa" | |
305 | ||
306 | --- Failure -------------------------------------------------------------------- | |
307 | ||
308 | Test lists are empty failed (8 shrink steps): | |
309 | ||
310 | [0] | |
311 | ||
312 | --- Failure -------------------------------------------------------------------- | |
313 | ||
314 | Test lists shorter than 10 failed (16 shrink steps): | |
315 | ||
316 | [0; 0; 0; 0; 0; 0; 0; 0; 0; 0] | |
317 | ||
318 | --- Failure -------------------------------------------------------------------- | |
319 | ||
320 | Test lists shorter than 432 failed (412 shrink steps): | |
321 | ||
322 | [...] list length: 432 | |
323 | ||
324 | --- Failure -------------------------------------------------------------------- | |
325 | ||
326 | Test lists shorter than 4332 failed (4022 shrink steps): | |
327 | ||
328 | [...] list length: 4332 | |
329 | ||
330 | --- Failure -------------------------------------------------------------------- | |
331 | ||
332 | Test lists equal to duplication failed (4 shrink steps): | |
333 | ||
334 | [0] | |
335 | ||
336 | --- Failure -------------------------------------------------------------------- | |
337 | ||
338 | Test lists have unique elems failed (11 shrink steps): | |
339 | ||
340 | [0; 0; 0; 0; 0] | |
341 | ||
342 | --- Failure -------------------------------------------------------------------- | |
343 | ||
344 | Test tree contains only 42 failed (2 shrink steps): | |
345 | ||
346 | Leaf 0 | |
347 | ||
348 | --- Failure -------------------------------------------------------------------- | |
349 | ||
350 | Test fail_pred_map_commute failed (16 shrink steps): | |
351 | ||
352 | ([2], {_ -> 0}, {1 -> false; 2 -> true; _ -> false}) | |
353 | ||
354 | --- Failure -------------------------------------------------------------------- | |
355 | ||
356 | Test fail_pred_strings failed (1 shrink steps): | |
357 | ||
358 | {"some random string" -> true; _ -> false} | |
359 | ||
360 | --- Failure -------------------------------------------------------------------- | |
361 | ||
362 | Test fold_left fold_right failed (22 shrink steps): | |
363 | ||
364 | (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}) | |
365 | ||
366 | +++ Messages ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
367 | ||
368 | Messages for test fold_left fold_right: | |
369 | ||
370 | l=[1], fold_left=1, fold_right=0 | |
371 | ||
372 | ||
373 | --- Failure -------------------------------------------------------------------- | |
374 | ||
375 | Test fold_left fold_right uncurried failed (325 shrink steps): | |
376 | ||
377 | ({(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]) | |
378 | ||
379 | --- Failure -------------------------------------------------------------------- | |
380 | ||
381 | Test fold_left fold_right uncurried fun last failed (25 shrink steps): | |
382 | ||
383 | (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}) | |
384 | ||
385 | --- Failure -------------------------------------------------------------------- | |
386 | ||
387 | Test fold_left test, fun first failed (15 shrink steps): | |
388 | ||
389 | ({_ -> ""}, "a", [], [0]) | |
390 | ||
391 | --- Failure -------------------------------------------------------------------- | |
392 | ||
393 | Test FAIL_#99_1 failed: | |
394 | ||
395 | ERROR: uncaught exception in generator for test FAIL_#99_1 after 100 steps: | |
396 | Exception: QCheck2.No_example_found("<example>") | |
397 | Backtrace: | |
398 | ||
399 | +++ Collect ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
400 | ||
401 | Collect results for test bool dist: | |
402 | ||
403 | true: 250134 cases | |
404 | false: 249866 cases | |
405 | ||
406 | +++ Stats for char code dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
407 | ||
408 | stats char code: | |
409 | num: 500000, avg: 127.42, stddev: 73.92, median 127, min 0, max 255 | |
410 | 0.. 12: ###################################################### 25509 | |
411 | 13.. 25: ###################################################### 25398 | |
412 | 26.. 38: ###################################################### 25293 | |
413 | 39.. 51: ###################################################### 25448 | |
414 | 52.. 64: ###################################################### 25392 | |
415 | 65.. 77: ####################################################### 25660 | |
416 | 78.. 90: ###################################################### 25462 | |
417 | 91..103: ###################################################### 25331 | |
418 | 104..116: ##################################################### 25129 | |
419 | 117..129: ###################################################### 25351 | |
420 | 130..142: ###################################################### 25492 | |
421 | 143..155: ###################################################### 25370 | |
422 | 156..168: ###################################################### 25658 | |
423 | 169..181: ###################################################### 25400 | |
424 | 182..194: ##################################################### 25167 | |
425 | 195..207: ###################################################### 25338 | |
426 | 208..220: ##################################################### 25181 | |
427 | 221..233: ##################################################### 25145 | |
428 | 234..246: ###################################################### 25567 | |
429 | 247..259: ##################################### 17709 | |
430 | ||
431 | +++ Stats for tree's depth ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
432 | ||
433 | stats depth: | |
434 | num: 1000, avg: 3.74, stddev: 3.28, median 3, min 1, max 15 | |
435 | 1: ####################################################### 377 | |
436 | 2: ################ 113 | |
437 | 3: ############ 87 | |
438 | 4: ################# 123 | |
439 | 5: ########### 81 | |
440 | 6: #### 33 | |
441 | 7: ##### 40 | |
442 | 8: ##### 39 | |
443 | 9: # 9 | |
444 | 10: ### 25 | |
445 | 11: ####### 49 | |
446 | 12: 4 | |
447 | 13: # 9 | |
448 | 14: # 7 | |
449 | 15: 4 | |
450 | ||
451 | +++ Stats for string_size len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
452 | ||
453 | stats len: | |
454 | num: 5000, avg: 7.49, stddev: 1.70, median 7, min 5, max 10 | |
455 | 5: ##################################################### 837 | |
456 | 6: ##################################################### 826 | |
457 | 7: ###################################################### 843 | |
458 | 8: ####################################################### 855 | |
459 | 9: #################################################### 813 | |
460 | 10: ##################################################### 826 | |
461 | ||
462 | +++ Stats for string len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
463 | ||
464 | stats len: | |
465 | num: 5000, avg: 384.53, stddev: 1330.61, median 9, min 0, max 9969 | |
466 | 0.. 498: ####################################################### 4246 | |
467 | 499.. 997: ###### 518 | |
468 | 998..1496: 21 | |
469 | 1497..1995: 10 | |
470 | 1996..2494: 11 | |
471 | 2495..2993: 10 | |
472 | 2994..3492: 13 | |
473 | 3493..3991: 13 | |
474 | 3992..4490: 5 | |
475 | 4491..4989: 10 | |
476 | 4990..5488: 19 | |
477 | 5489..5987: 9 | |
478 | 5988..6486: 10 | |
479 | 6487..6985: 12 | |
480 | 6986..7484: 17 | |
481 | 7485..7983: 16 | |
482 | 7984..8482: 16 | |
483 | 8483..8981: 16 | |
484 | 8982..9480: 16 | |
485 | 9481..9979: 12 | |
486 | ||
487 | +++ Stats for string_of len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
488 | ||
489 | stats len: | |
490 | num: 5000, avg: 363.14, stddev: 1245.80, median 9, min 0, max 9986 | |
491 | 0.. 499: ####################################################### 4270 | |
492 | 500.. 999: ###### 493 | |
493 | 1000.. 1499: 16 | |
494 | 1500.. 1999: 11 | |
495 | 2000.. 2499: 15 | |
496 | 2500.. 2999: 17 | |
497 | 3000.. 3499: 11 | |
498 | 3500.. 3999: 19 | |
499 | 4000.. 4499: 14 | |
500 | 4500.. 4999: 10 | |
501 | 5000.. 5499: 16 | |
502 | 5500.. 5999: 11 | |
503 | 6000.. 6499: 15 | |
504 | 6500.. 6999: 13 | |
505 | 7000.. 7499: 12 | |
506 | 7500.. 7999: 16 | |
507 | 8000.. 8499: 11 | |
508 | 8500.. 8999: 4 | |
509 | 9000.. 9499: 13 | |
510 | 9500.. 9999: 13 | |
511 | ||
512 | +++ Stats for string_printable len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
513 | ||
514 | stats len: | |
515 | num: 5000, avg: 384.53, stddev: 1330.61, median 9, min 0, max 9969 | |
516 | 0.. 498: ####################################################### 4246 | |
517 | 499.. 997: ###### 518 | |
518 | 998..1496: 21 | |
519 | 1497..1995: 10 | |
520 | 1996..2494: 11 | |
521 | 2495..2993: 10 | |
522 | 2994..3492: 13 | |
523 | 3493..3991: 13 | |
524 | 3992..4490: 5 | |
525 | 4491..4989: 10 | |
526 | 4990..5488: 19 | |
527 | 5489..5987: 9 | |
528 | 5988..6486: 10 | |
529 | 6487..6985: 12 | |
530 | 6986..7484: 17 | |
531 | 7485..7983: 16 | |
532 | 7984..8482: 16 | |
533 | 8483..8981: 16 | |
534 | 8982..9480: 16 | |
535 | 9481..9979: 12 | |
536 | ||
537 | +++ Stats for small_string len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
538 | ||
539 | stats len: | |
540 | num: 5000, avg: 15.57, stddev: 24.36, median 6, min 0, max 99 | |
541 | 0.. 4: #################################################### 1925 | |
542 | 5.. 9: ####################################################### 2005 | |
543 | 10.. 14: # 52 | |
544 | 15.. 19: # 50 | |
545 | 20.. 24: # 55 | |
546 | 25.. 29: # 56 | |
547 | 30.. 34: # 55 | |
548 | 35.. 39: # 49 | |
549 | 40.. 44: # 65 | |
550 | 45.. 49: # 65 | |
551 | 50.. 54: # 55 | |
552 | 55.. 59: # 68 | |
553 | 60.. 64: # 61 | |
554 | 65.. 69: # 65 | |
555 | 70.. 74: # 57 | |
556 | 75.. 79: # 66 | |
557 | 80.. 84: # 65 | |
558 | 85.. 89: # 64 | |
559 | 90.. 94: # 60 | |
560 | 95.. 99: # 62 | |
561 | ||
562 | +++ Stats for list len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
563 | ||
564 | stats len: | |
565 | num: 5000, avg: 400.16, stddev: 1371.90, median 9, min 0, max 9987 | |
566 | 0.. 499: ####################################################### 4246 | |
567 | 500.. 999: ###### 502 | |
568 | 1000.. 1499: 13 | |
569 | 1500.. 1999: 10 | |
570 | 2000.. 2499: 14 | |
571 | 2500.. 2999: 14 | |
572 | 3000.. 3499: 20 | |
573 | 3500.. 3999: 7 | |
574 | 4000.. 4499: 13 | |
575 | 4500.. 4999: 16 | |
576 | 5000.. 5499: 12 | |
577 | 5500.. 5999: 15 | |
578 | 6000.. 6499: 15 | |
579 | 6500.. 6999: 13 | |
580 | 7000.. 7499: 16 | |
581 | 7500.. 7999: 12 | |
582 | 8000.. 8499: 11 | |
583 | 8500.. 8999: 16 | |
584 | 9000.. 9499: 15 | |
585 | 9500.. 9999: 20 | |
586 | ||
587 | +++ Stats for small_list len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
588 | ||
589 | stats len: | |
590 | num: 5000, avg: 16.14, stddev: 24.86, median 6, min 0, max 99 | |
591 | 0.. 4: ###################################################### 1923 | |
592 | 5.. 9: ####################################################### 1936 | |
593 | 10.. 14: # 61 | |
594 | 15.. 19: # 59 | |
595 | 20.. 24: # 62 | |
596 | 25.. 29: # 70 | |
597 | 30.. 34: # 61 | |
598 | 35.. 39: # 64 | |
599 | 40.. 44: # 64 | |
600 | 45.. 49: # 56 | |
601 | 50.. 54: # 65 | |
602 | 55.. 59: # 55 | |
603 | 60.. 64: # 60 | |
604 | 65.. 69: # 62 | |
605 | 70.. 74: # 57 | |
606 | 75.. 79: # 69 | |
607 | 80.. 84: ## 73 | |
608 | 85.. 89: # 67 | |
609 | 90.. 94: # 62 | |
610 | 95.. 99: ## 74 | |
611 | ||
612 | +++ Stats for list_size len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
613 | ||
614 | stats len: | |
615 | num: 5000, avg: 7.49, stddev: 1.71, median 8, min 5, max 10 | |
616 | 5: ####################################################### 867 | |
617 | 6: ################################################### 813 | |
618 | 7: ################################################### 815 | |
619 | 8: #################################################### 833 | |
620 | 9: ###################################################### 857 | |
621 | 10: ################################################### 815 | |
622 | ||
623 | +++ Stats for list_repeat len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
624 | ||
625 | stats len: | |
626 | num: 5000, avg: 42.00, stddev: 0.00, median 42, min 42, max 42 | |
627 | 42: ####################################################### 5000 | |
628 | ||
629 | +++ Stats for array len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
630 | ||
631 | stats len: | |
632 | num: 5000, avg: 400.16, stddev: 1371.90, median 9, min 0, max 9987 | |
633 | 0.. 499: ####################################################### 4246 | |
634 | 500.. 999: ###### 502 | |
635 | 1000.. 1499: 13 | |
636 | 1500.. 1999: 10 | |
637 | 2000.. 2499: 14 | |
638 | 2500.. 2999: 14 | |
639 | 3000.. 3499: 20 | |
640 | 3500.. 3999: 7 | |
641 | 4000.. 4499: 13 | |
642 | 4500.. 4999: 16 | |
643 | 5000.. 5499: 12 | |
644 | 5500.. 5999: 15 | |
645 | 6000.. 6499: 15 | |
646 | 6500.. 6999: 13 | |
647 | 7000.. 7499: 16 | |
648 | 7500.. 7999: 12 | |
649 | 8000.. 8499: 11 | |
650 | 8500.. 8999: 16 | |
651 | 9000.. 9499: 15 | |
652 | 9500.. 9999: 20 | |
653 | ||
654 | +++ Stats for small_array len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
655 | ||
656 | stats len: | |
657 | num: 5000, avg: 16.14, stddev: 24.86, median 6, min 0, max 99 | |
658 | 0.. 4: ###################################################### 1923 | |
659 | 5.. 9: ####################################################### 1936 | |
660 | 10.. 14: # 61 | |
661 | 15.. 19: # 59 | |
662 | 20.. 24: # 62 | |
663 | 25.. 29: # 70 | |
664 | 30.. 34: # 61 | |
665 | 35.. 39: # 64 | |
666 | 40.. 44: # 64 | |
667 | 45.. 49: # 56 | |
668 | 50.. 54: # 65 | |
669 | 55.. 59: # 55 | |
670 | 60.. 64: # 60 | |
671 | 65.. 69: # 62 | |
672 | 70.. 74: # 57 | |
673 | 75.. 79: # 69 | |
674 | 80.. 84: ## 73 | |
675 | 85.. 89: # 67 | |
676 | 90.. 94: # 62 | |
677 | 95.. 99: ## 74 | |
678 | ||
679 | +++ Stats for array_size len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
680 | ||
681 | stats len: | |
682 | num: 5000, avg: 7.49, stddev: 1.71, median 8, min 5, max 10 | |
683 | 5: ####################################################### 867 | |
684 | 6: ################################################### 813 | |
685 | 7: ################################################### 815 | |
686 | 8: #################################################### 833 | |
687 | 9: ###################################################### 857 | |
688 | 10: ################################################### 815 | |
689 | ||
690 | +++ Stats for array_repeat len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
691 | ||
692 | stats len: | |
693 | num: 5000, avg: 42.00, stddev: 0.00, median 42, min 42, max 42 | |
694 | 42: ####################################################### 5000 | |
695 | ||
696 | +++ Stats for int_stats_neg ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
697 | ||
698 | stats dist: | |
699 | num: 5000, avg: 0.17, stddev: 29.68, median 0, min -99, max 99 | |
700 | -99..-90: # 65 | |
701 | -89..-80: # 63 | |
702 | -79..-70: # 64 | |
703 | -69..-60: # 58 | |
704 | -59..-50: # 67 | |
705 | -49..-40: # 72 | |
706 | -39..-30: # 61 | |
707 | -29..-20: # 61 | |
708 | -19..-10: # 67 | |
709 | -9.. 0: ####################################################### 2076 | |
710 | 1.. 10: ############################################## 1764 | |
711 | 11.. 20: # 66 | |
712 | 21.. 30: # 64 | |
713 | 31.. 40: # 64 | |
714 | 41.. 50: # 67 | |
715 | 51.. 60: # 60 | |
716 | 61.. 70: # 75 | |
717 | 71.. 80: # 60 | |
718 | 81.. 90: # 60 | |
719 | 91..100: # 66 | |
720 | ||
721 | +++ Stats for small_signed_int dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
722 | ||
723 | stats dist: | |
724 | num: 1000, avg: 0.90, stddev: 28.23, median 0, min -99, max 99 | |
725 | -99..-90: # 12 | |
726 | -89..-80: # 11 | |
727 | -79..-70: # 9 | |
728 | -69..-60: 6 | |
729 | -59..-50: # 11 | |
730 | -49..-40: # 13 | |
731 | -39..-30: # 9 | |
732 | -29..-20: # 13 | |
733 | -19..-10: 8 | |
734 | -9.. 0: ####################################################### 453 | |
735 | 1.. 10: ######################################### 340 | |
736 | 11.. 20: # 15 | |
737 | 21.. 30: # 11 | |
738 | 31.. 40: # 12 | |
739 | 41.. 50: # 13 | |
740 | 51.. 60: # 13 | |
741 | 61.. 70: # 16 | |
742 | 71.. 80: # 9 | |
743 | 81.. 90: # 16 | |
744 | 91..100: # 10 | |
745 | ||
746 | +++ Stats for small_nat dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
747 | ||
748 | stats dist: | |
749 | num: 1000, avg: 15.11, stddev: 23.27, median 6, min 0, max 99 | |
750 | 0.. 4: #################################################### 377 | |
751 | 5.. 9: ####################################################### 392 | |
752 | 10.. 14: ## 20 | |
753 | 15.. 19: ## 15 | |
754 | 20.. 24: # 11 | |
755 | 25.. 29: ## 17 | |
756 | 30.. 34: ## 19 | |
757 | 35.. 39: ## 17 | |
758 | 40.. 44: # 10 | |
759 | 45.. 49: # 9 | |
760 | 50.. 54: # 8 | |
761 | 55.. 59: # 9 | |
762 | 60.. 64: ## 15 | |
763 | 65.. 69: # 10 | |
764 | 70.. 74: # 13 | |
765 | 75.. 79: ## 19 | |
766 | 80.. 84: # 11 | |
767 | 85.. 89: # 13 | |
768 | 90.. 94: 5 | |
769 | 95.. 99: # 10 | |
770 | ||
771 | +++ Stats for nat dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
772 | ||
773 | stats dist: | |
774 | num: 1000, avg: 363.02, stddev: 1215.04, median 9, min 0, max 9476 | |
775 | 0.. 473: ####################################################### 847 | |
776 | 474.. 947: ###### 95 | |
777 | 948..1421: 14 | |
778 | 1422..1895: 3 | |
779 | 1896..2369: 0 | |
780 | 2370..2843: 3 | |
781 | 2844..3317: 2 | |
782 | 3318..3791: 3 | |
783 | 3792..4265: 2 | |
784 | 4266..4739: 4 | |
785 | 4740..5213: 3 | |
786 | 5214..5687: 4 | |
787 | 5688..6161: 3 | |
788 | 6162..6635: 4 | |
789 | 6636..7109: 1 | |
790 | 7110..7583: 4 | |
791 | 7584..8057: 2 | |
792 | 8058..8531: 1 | |
793 | 8532..9005: 1 | |
794 | 9006..9479: 4 | |
795 | ||
796 | +++ Stats for int_range (-43643) 435434 dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
797 | ||
798 | stats dist: | |
799 | num: 1000, avg: 195335.64, stddev: 136803.99, median 195583, min -43624, max 435210 | |
800 | -43624..-19683: ############################################ 52 | |
801 | -19682.. 4259: ######################################## 47 | |
802 | 4260.. 28201: ############################## 36 | |
803 | 28202.. 52143: ############################################ 52 | |
804 | 52144.. 76085: ########################################## 50 | |
805 | 76086..100027: ####################################################### 64 | |
806 | 100028..123969: ############################################### 55 | |
807 | 123970..147911: ######################################## 47 | |
808 | 147912..171853: ############################################## 54 | |
809 | 171854..195795: #################################### 43 | |
810 | 195796..219737: ############################################## 54 | |
811 | 219738..243679: ########################################### 51 | |
812 | 243680..267621: ################################################ 57 | |
813 | 267622..291563: ########################################## 49 | |
814 | 291564..315505: #################################### 42 | |
815 | 315506..339447: ###################################### 45 | |
816 | 339448..363389: ################################################ 57 | |
817 | 363390..387331: ###################################### 45 | |
818 | 387332..411273: ########################################## 49 | |
819 | 411274..435215: ########################################### 51 | |
820 | ||
821 | +++ Stats for int_range (-40000) 40000 dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
822 | ||
823 | stats dist: | |
824 | num: 1000, avg: -173.78, stddev: 23042.92, median 180, min -39859, max 39942 | |
825 | -39859..-35869: ############################################# 56 | |
826 | -35868..-31878: ################################### 43 | |
827 | -31877..-27887: ################################################# 60 | |
828 | -27886..-23896: ##################################### 46 | |
829 | -23895..-19905: ######################################## 49 | |
830 | -19904..-15914: #################################### 45 | |
831 | -15913..-11923: ############################################ 54 | |
832 | -11922.. -7932: ############################################### 58 | |
833 | -7931.. -3941: ######################################### 51 | |
834 | -3940.. 50: ############################ 35 | |
835 | 51.. 4041: ####################################### 48 | |
836 | 4042.. 8032: ########################################## 52 | |
837 | 8033.. 12023: ######################################### 51 | |
838 | 12024.. 16014: ########################################### 53 | |
839 | 16015.. 20005: ############################################ 54 | |
840 | 20006.. 23996: ################################## 42 | |
841 | 23997.. 27987: ####################################################### 67 | |
842 | 27988.. 31978: ################################ 40 | |
843 | 31979.. 35969: ######################################### 51 | |
844 | 35970.. 39960: #################################### 45 | |
845 | ||
846 | +++ Stats for int_range (-4) 4 dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
847 | ||
848 | stats dist: | |
849 | num: 1000, avg: 0.02, stddev: 2.55, median 0, min -4, max 4 | |
850 | -4: ############################################ 99 | |
851 | -3: ##################################################### 118 | |
852 | -2: ################################################## 111 | |
853 | -1: ################################################## 113 | |
854 | 0: ################################################## 113 | |
855 | 1: ##################################################### 118 | |
856 | 2: ############################################# 102 | |
857 | 3: ####################################################### 122 | |
858 | 4: ############################################## 104 | |
859 | ||
860 | +++ Stats for int_range (-4) 17 dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
861 | ||
862 | stats dist: | |
863 | num: 1000, avg: 6.67, stddev: 6.39, median 7, min -4, max 17 | |
864 | -4..-3: ############################################# 90 | |
865 | -2..-1: ############################################# 91 | |
866 | 0.. 1: ########################################## 84 | |
867 | 2.. 3: ############################################## 92 | |
868 | 4.. 5: ########################################### 87 | |
869 | 6.. 7: ########################################### 86 | |
870 | 8.. 9: ############################################ 89 | |
871 | 10..11: ########################################### 87 | |
872 | 12..13: ####################################################### 110 | |
873 | 14..15: ############################################# 91 | |
874 | 16..17: ############################################## 93 | |
875 | 18..19: 0 | |
876 | 20..21: 0 | |
877 | 22..23: 0 | |
878 | 24..25: 0 | |
879 | 26..27: 0 | |
880 | 28..29: 0 | |
881 | 30..31: 0 | |
882 | 32..33: 0 | |
883 | 34..35: 0 | |
884 | ||
885 | +++ Stats for int dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
886 | ||
887 | stats dist: | |
888 | num: 100000, avg: 2541076923587387.50, stddev: 2660730801206827008.00, median 158655268318060, min -4611522359435274428, max 4611540922436307689 | |
889 | -4611522359435274428..-4150369195341695293: ##################################################### 4976 | |
890 | -4150369195341695292..-3689216031248116157: ##################################################### 4963 | |
891 | -3689216031248116156..-3228062867154537021: ###################################################### 5038 | |
892 | -3228062867154537020..-2766909703060957885: ##################################################### 4979 | |
893 | -2766909703060957884..-2305756538967378749: ##################################################### 5001 | |
894 | -2305756538967378748..-1844603374873799613: ##################################################### 4982 | |
895 | -1844603374873799612..-1383450210780220477: ##################################################### 5025 | |
896 | -1383450210780220476.. -922297046686641341: #################################################### 4901 | |
897 | -922297046686641340.. -461143882593062205: ####################################################### 5126 | |
898 | -461143882593062204.. 9281500516931: ##################################################### 5008 | |
899 | 9281500516932.. 461162445594096067: ###################################################### 5041 | |
900 | 461162445594096068.. 922315609687675203: ##################################################### 5001 | |
901 | 922315609687675204.. 1383468773781254339: ##################################################### 4986 | |
902 | 1383468773781254340.. 1844621937874833475: ##################################################### 4949 | |
903 | 1844621937874833476.. 2305775101968412611: ##################################################### 5025 | |
904 | 2305775101968412612.. 2766928266061991747: ##################################################### 5022 | |
905 | 2766928266061991748.. 3228081430155570883: ##################################################### 4958 | |
906 | 3228081430155570884.. 3689234594249150019: ##################################################### 4998 | |
907 | 3689234594249150020.. 4150387758342729155: ##################################################### 4982 | |
908 | 4150387758342729156.. 4611540922436308291: ###################################################### 5039 | |
909 | ||
910 | +++ Stats for oneof int dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
911 | ||
912 | stats dist: | |
913 | num: 1000, avg: 4611686018427388.00, stddev: 2905870896563567616.00, median 0, min -4611686018427387904, max 4611686018427387903 | |
914 | -4611686018427387904..-4150517416584649089: ################## 208 | |
915 | -4150517416584649088..-3689348814741910273: 0 | |
916 | -3689348814741910272..-3228180212899171457: 0 | |
917 | -3228180212899171456..-2767011611056432641: 0 | |
918 | -2767011611056432640..-2305843009213693825: 0 | |
919 | -2305843009213693824..-1844674407370955009: 0 | |
920 | -1844674407370955008..-1383505805528216193: 0 | |
921 | -1383505805528216192.. -922337203685477377: 0 | |
922 | -922337203685477376.. -461168601842738561: 0 | |
923 | -461168601842738560.. 255: ####################################################### 603 | |
924 | 256.. 461168601842739071: 0 | |
925 | 461168601842739072.. 922337203685477887: 0 | |
926 | 922337203685477888.. 1383505805528216703: 0 | |
927 | 1383505805528216704.. 1844674407370955519: 0 | |
928 | 1844674407370955520.. 2305843009213694335: 0 | |
929 | 2305843009213694336.. 2767011611056433151: 0 | |
930 | 2767011611056433152.. 3228180212899171967: 0 | |
931 | 3228180212899171968.. 3689348814741910783: 0 | |
932 | 3689348814741910784.. 4150517416584649599: 0 | |
933 | 4150517416584649600.. 4611686018427387903: ################# 189 | |
934 | ================================================================================ | |
935 | 1 warning(s) | |
936 | failure (27 tests failed, 1 tests errored, ran 67 tests) | |
937 | random seed: 153870556 | |
938 | ||
939 | +++ Stats for int_dist_empty_bucket ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
940 | ||
941 | stats dist: | |
942 | num: 1000, avg: -55083208105414400.00, stddev: 1847115855773139200.00, median 9, min -4590718933436425025, max 4611686018427387903 | |
943 | -4590718933436425025..-4130598685843234370: ## 26 | |
944 | -4130598685843234369..-3670478438250043714: # 13 | |
945 | -3670478438250043713..-3210358190656853058: ### 37 | |
946 | -3210358190656853057..-2750237943063662402: ### 30 | |
947 | -2750237943063662401..-2290117695470471746: ## 27 | |
948 | -2290117695470471745..-1829997447877281090: ## 24 | |
949 | -1829997447877281089..-1369877200284090434: ## 27 | |
950 | -1369877200284090433.. -909756952690899778: ## 27 | |
951 | -909756952690899777.. -449636705097709122: ## 21 | |
952 | -449636705097709121.. 10483542495481534: ####################################################### 531 | |
953 | 10483542495481535.. 470603790088672190: ## 21 | |
954 | 470603790088672191.. 930724037681862846: ## 27 | |
955 | 930724037681862847.. 1390844285275053502: ## 24 | |
956 | 1390844285275053503.. 1850964532868244158: ## 25 | |
957 | 1850964532868244159.. 2311084780461434814: ## 28 | |
958 | 2311084780461434815.. 2771205028054625470: ## 23 | |
959 | 2771205028054625471.. 3231325275647816126: ## 23 | |
960 | 3231325275647816127.. 3691445523241006782: ## 25 | |
961 | 3691445523241006783.. 4151565770834197438: # 17 | |
962 | 4151565770834197439.. 4611686018427387903: ## 24 | |
963 | ================================================================================ | |
964 | success (ran 1 tests) |
0 | random seed: 1234 | |
1 | 2724675603984413065 | |
2 | 1362337801992206533 | |
3 | 681168900996103267 | |
4 | 340584450498051634 | |
5 | 170292225249025817 | |
6 | 85146112624512909 | |
7 | 42573056312256455 | |
8 | 21286528156128228 | |
9 | 10643264078064114 | |
10 | 5321632039032057 | |
11 | 2660816019516029 | |
12 | 1330408009758015 | |
13 | 665204004879008 | |
14 | 332602002439504 | |
15 | 166301001219752 | |
16 | 83150500609876 | |
17 | 41575250304938 | |
18 | 20787625152469 | |
19 | 10393812576235 | |
20 | 5196906288118 | |
21 | 2598453144059 | |
22 | 1299226572030 | |
23 | 649613286015 | |
24 | 324806643008 | |
25 | 162403321504 | |
26 | 81201660752 | |
27 | 40600830376 | |
28 | 20300415188 | |
29 | 10150207594 | |
30 | 5075103797 | |
31 | 2537551899 | |
32 | 1268775950 | |
33 | 634387975 | |
34 | 317193988 | |
35 | 158596994 | |
36 | 79298497 | |
37 | 39649249 | |
38 | 19824625 | |
39 | 9912313 | |
40 | 4956157 | |
41 | 2478079 | |
42 | 1239040 | |
43 | 619520 | |
44 | 309760 | |
45 | 154880 | |
46 | 77440 | |
47 | 38720 | |
48 | 19360 | |
49 | 9680 | |
50 | 4840 | |
51 | 2420 | |
52 | 1210 | |
53 | 605 | |
54 | 303 | |
55 | 152 | |
56 | 76 | |
57 | 38 | |
58 | 19 | |
59 | 10 | |
60 | 5 | |
61 | 3 | |
62 | 2 | |
63 | 1 | |
64 | 0 | |
65 | [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] | |
66 | [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] | |
67 | [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] | |
68 | [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] | |
69 | [4; 4; 0; 60; 8; 9; 7; 44; 5; 1; 2; 9; 74; 7; 7] | |
70 | [5; 1; 2; 9; 74; 7; 7] | |
71 | [74; 7; 7] | |
72 | [7] | |
73 | [] | |
74 | [4] | |
75 | [] | |
76 | [2] | |
77 | [] | |
78 | [1] | |
79 | [] | |
80 | [0] | |
81 | [] | |
82 | [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] | |
83 | [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] | |
84 | [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] | |
85 | [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] | |
86 | [4; 4; 0; 60; 8; 9; 7; 44; 5; 1; 2; 9; 74; 7; 7] | |
87 | [5; 1; 2; 9; 74; 7; 7] | |
88 | [74; 7; 7] | |
89 | [7] | |
90 | [74] | |
91 | [7; 7] | |
92 | [7] | |
93 | [7] | |
94 | [4; 7] | |
95 | [6; 7] | |
96 | [6; 7] | |
97 | [7; 4] | |
98 | [7; 6] | |
99 | [7; 6] | |
100 | ||
101 | --- Failure -------------------------------------------------------------------- | |
102 | ||
103 | Test should_fail_sort_id failed (18 shrink steps): | |
104 | ||
105 | [1; 0] | |
106 | ||
107 | === Error ====================================================================== | |
108 | ||
109 | Test should_error_raise_exn errored on (63 shrink steps): | |
110 | ||
111 | 0 | |
112 | ||
113 | exception Dune__exe__QCheck_expect_test.Overall.Error | |
114 | ||
115 | ||
116 | +++ Collect ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
117 | ||
118 | Collect results for test collect_results: | |
119 | ||
120 | 4: 20 cases | |
121 | 3: 25 cases | |
122 | 2: 17 cases | |
123 | 1: 18 cases | |
124 | 0: 20 cases | |
125 | ||
126 | +++ Stats for with_stats ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
127 | ||
128 | stats mod4: | |
129 | num: 100, avg: 1.68, stddev: 1.09, median 2, min 0, max 3 | |
130 | 0: ############################## 17 | |
131 | 1: ################################################### 29 | |
132 | 2: ######################################## 23 | |
133 | 3: ####################################################### 31 | |
134 | ||
135 | stats num: | |
136 | num: 100, avg: 66.84, stddev: 31.94, median 65, min 2, max 120 | |
137 | 2.. 7: ################## 3 | |
138 | 8.. 13: ################## 3 | |
139 | 14.. 19: 0 | |
140 | 20.. 25: ########################################## 7 | |
141 | 26.. 31: ######################## 4 | |
142 | 32.. 37: ######################## 4 | |
143 | 38.. 43: ################## 3 | |
144 | 44.. 49: ################################################ 8 | |
145 | 50.. 55: #################################### 6 | |
146 | 56.. 61: #################################### 6 | |
147 | 62.. 67: ####################################################### 9 | |
148 | 68.. 73: ########################################## 7 | |
149 | 74.. 79: ######################## 4 | |
150 | 80.. 85: ################## 3 | |
151 | 86.. 91: ############ 2 | |
152 | 92.. 97: ########################################## 7 | |
153 | 98..103: #################################### 6 | |
154 | 104..109: #################################### 6 | |
155 | 110..115: ####################################################### 9 | |
156 | 116..121: ################## 3 | |
157 | ||
158 | !!! Warning !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
159 | ||
160 | Warning for test WARN_unlikely_precond: | |
161 | ||
162 | WARNING: only 0.5% tests (of 2000) passed precondition for "WARN_unlikely_precond" | |
163 | ||
164 | NOTE: it is likely that the precondition is too strong, or that the generator is buggy. | |
165 | ||
166 | --- Failure -------------------------------------------------------------------- | |
167 | ||
168 | Test FAIL_unlikely_precond failed: | |
169 | ||
170 | ERROR: only 0.5% tests (of 2000) passed precondition for "FAIL_unlikely_precond" | |
171 | ||
172 | NOTE: it is likely that the precondition is too strong, or that the generator is buggy. | |
173 | ||
174 | ||
175 | --- Failure -------------------------------------------------------------------- | |
176 | ||
177 | Test char never produces '\255' failed (0 shrink steps): | |
178 | ||
179 | '\255' | |
180 | ||
181 | --- Failure -------------------------------------------------------------------- | |
182 | ||
183 | Test big bound issue59 failed (52 shrink steps): | |
184 | ||
185 | 209609 | |
186 | ||
187 | --- Failure -------------------------------------------------------------------- | |
188 | ||
189 | Test long_shrink failed (149 shrink steps): | |
190 | ||
191 | ([0], [-1]) | |
192 | ||
193 | --- Failure -------------------------------------------------------------------- | |
194 | ||
195 | Test ints arent 0 mod 3 failed (84 shrink steps): | |
196 | ||
197 | -21 | |
198 | ||
199 | --- Failure -------------------------------------------------------------------- | |
200 | ||
201 | Test ints are 0 failed (62 shrink steps): | |
202 | ||
203 | 1 | |
204 | ||
205 | --- Failure -------------------------------------------------------------------- | |
206 | ||
207 | Test ints < 209609 failed (52 shrink steps): | |
208 | ||
209 | 209609 | |
210 | ||
211 | --- Failure -------------------------------------------------------------------- | |
212 | ||
213 | Test nat < 5001 failed (6 shrink steps): | |
214 | ||
215 | 5001 | |
216 | ||
217 | --- Failure -------------------------------------------------------------------- | |
218 | ||
219 | Test char is never produces 'abcdef' failed (0 shrink steps): | |
220 | ||
221 | 'd' | |
222 | ||
223 | --- Failure -------------------------------------------------------------------- | |
224 | ||
225 | Test strings are empty failed (249 shrink steps): | |
226 | ||
227 | "\177" | |
228 | ||
229 | --- Failure -------------------------------------------------------------------- | |
230 | ||
231 | Test string never has a \000 char failed (25 shrink steps): | |
232 | ||
233 | "\000" | |
234 | ||
235 | --- Failure -------------------------------------------------------------------- | |
236 | ||
237 | Test string never has a \255 char failed (249 shrink steps): | |
238 | ||
239 | "\255" | |
240 | ||
241 | --- Failure -------------------------------------------------------------------- | |
242 | ||
243 | Test lists are empty failed (11 shrink steps): | |
244 | ||
245 | [0] | |
246 | ||
247 | --- Failure -------------------------------------------------------------------- | |
248 | ||
249 | Test lists shorter than 10 failed (50 shrink steps): | |
250 | ||
251 | [0; 0; 0; 0; 0; 0; 0; 0; 0; 0] | |
252 | ||
253 | --- Failure -------------------------------------------------------------------- | |
254 | ||
255 | Test lists shorter than 432 failed (1696 shrink steps): | |
256 | ||
257 | [...] list length: 432 | |
258 | ||
259 | --- Failure -------------------------------------------------------------------- | |
260 | ||
261 | Test lists shorter than 4332 failed (13 shrink steps): | |
262 | ||
263 | [...] list length: 4332 | |
264 | ||
265 | --- Failure -------------------------------------------------------------------- | |
266 | ||
267 | Test lists equal to duplication failed (20 shrink steps): | |
268 | ||
269 | [0] | |
270 | ||
271 | --- Failure -------------------------------------------------------------------- | |
272 | ||
273 | Test lists have unique elems failed (7 shrink steps): | |
274 | ||
275 | [7; 7] | |
276 | ||
277 | --- Failure -------------------------------------------------------------------- | |
278 | ||
279 | Test fail_pred_map_commute failed (127 shrink steps): | |
280 | ||
281 | ([3], {_ -> 0}, {3 -> false; _ -> true}) | |
282 | ||
283 | --- Failure -------------------------------------------------------------------- | |
284 | ||
285 | Test fail_pred_strings failed (1 shrink steps): | |
286 | ||
287 | {some random string -> true; _ -> false} | |
288 | ||
289 | --- Failure -------------------------------------------------------------------- | |
290 | ||
291 | Test fold_left fold_right failed (25 shrink steps): | |
292 | ||
293 | (0, [1], {(1, 0) -> 1; _ -> 0}) | |
294 | ||
295 | +++ Messages ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
296 | ||
297 | Messages for test fold_left fold_right: | |
298 | ||
299 | l=[1], fold_left=1, fold_right=0 | |
300 | ||
301 | ||
302 | --- Failure -------------------------------------------------------------------- | |
303 | ||
304 | Test fold_left fold_right uncurried failed (111 shrink steps): | |
305 | ||
306 | ({(5, 7) -> 0; _ -> 7}, 0, [5; 0]) | |
307 | ||
308 | --- Failure -------------------------------------------------------------------- | |
309 | ||
310 | Test fold_left fold_right uncurried fun last failed (26 shrink steps): | |
311 | ||
312 | (0, [1], {(0, 1) -> 1; _ -> 0}) | |
313 | ||
314 | --- Failure -------------------------------------------------------------------- | |
315 | ||
316 | Test false fold, fun first failed (40 shrink steps): | |
317 | ||
318 | ({_ -> ""}, "z", [], [0]) | |
319 | ||
320 | --- Failure -------------------------------------------------------------------- | |
321 | ||
322 | Test FAIL_#99_1 failed: | |
323 | ||
324 | ERROR: uncaught exception in generator for test FAIL_#99_1 after 100 steps: | |
325 | Exception: QCheck.No_example_found("<example>") | |
326 | Backtrace: | |
327 | ||
328 | +++ Collect ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
329 | ||
330 | Collect results for test bool dist: | |
331 | ||
332 | true: 250134 cases | |
333 | false: 249866 cases | |
334 | ||
335 | +++ Stats for char code dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
336 | ||
337 | stats char code: | |
338 | num: 500000, avg: 127.42, stddev: 73.92, median 127, min 0, max 255 | |
339 | 0.. 12: ###################################################### 25509 | |
340 | 13.. 25: ###################################################### 25398 | |
341 | 26.. 38: ###################################################### 25293 | |
342 | 39.. 51: ###################################################### 25448 | |
343 | 52.. 64: ###################################################### 25392 | |
344 | 65.. 77: ####################################################### 25660 | |
345 | 78.. 90: ###################################################### 25462 | |
346 | 91..103: ###################################################### 25331 | |
347 | 104..116: ##################################################### 25129 | |
348 | 117..129: ###################################################### 25351 | |
349 | 130..142: ###################################################### 25492 | |
350 | 143..155: ###################################################### 25370 | |
351 | 156..168: ###################################################### 25658 | |
352 | 169..181: ###################################################### 25400 | |
353 | 182..194: ##################################################### 25167 | |
354 | 195..207: ###################################################### 25338 | |
355 | 208..220: ##################################################### 25181 | |
356 | 221..233: ##################################################### 25145 | |
357 | 234..246: ###################################################### 25567 | |
358 | 247..259: ##################################### 17709 | |
359 | ||
360 | +++ Stats for tree's depth ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
361 | ||
362 | stats depth: | |
363 | num: 1000, avg: 3.74, stddev: 3.28, median 3, min 1, max 15 | |
364 | 1: ####################################################### 377 | |
365 | 2: ################ 113 | |
366 | 3: ############ 87 | |
367 | 4: ################# 123 | |
368 | 5: ########### 81 | |
369 | 6: #### 33 | |
370 | 7: ##### 40 | |
371 | 8: ##### 39 | |
372 | 9: # 9 | |
373 | 10: ### 25 | |
374 | 11: ####### 49 | |
375 | 12: 4 | |
376 | 13: # 9 | |
377 | 14: # 7 | |
378 | 15: 4 | |
379 | ||
380 | +++ Stats for range_subset_spec ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
381 | ||
382 | stats dist: | |
383 | num: 5000, avg: 9.97, stddev: 6.08, median 10, min 0, max 20 | |
384 | 0: ################################################# 246 | |
385 | 1: ################################################ 244 | |
386 | 2: ################################################ 240 | |
387 | 3: ################################################ 243 | |
388 | 4: ############################################## 232 | |
389 | 5: ############################################## 230 | |
390 | 6: ############################################### 239 | |
391 | 7: ############################################### 235 | |
392 | 8: ####################################################### 274 | |
393 | 9: ############################################## 233 | |
394 | 10: ########################################## 212 | |
395 | 11: ############################################## 231 | |
396 | 12: ############################################### 239 | |
397 | 13: ############################################# 226 | |
398 | 14: ############################################# 225 | |
399 | 15: ################################################### 256 | |
400 | 16: ################################################ 240 | |
401 | 17: ############################################# 229 | |
402 | 18: ################################################ 243 | |
403 | 19: ################################################## 253 | |
404 | 20: ############################################## 230 | |
405 | ||
406 | +++ Stats for string_size len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
407 | ||
408 | stats len: | |
409 | num: 5000, avg: 7.49, stddev: 1.70, median 7, min 5, max 10 | |
410 | 5: ##################################################### 837 | |
411 | 6: ##################################################### 826 | |
412 | 7: ###################################################### 843 | |
413 | 8: ####################################################### 855 | |
414 | 9: #################################################### 813 | |
415 | 10: ##################################################### 826 | |
416 | ||
417 | +++ Stats for string len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
418 | ||
419 | stats len: | |
420 | num: 5000, avg: 384.53, stddev: 1330.61, median 9, min 0, max 9969 | |
421 | 0.. 498: ####################################################### 4246 | |
422 | 499.. 997: ###### 518 | |
423 | 998..1496: 21 | |
424 | 1497..1995: 10 | |
425 | 1996..2494: 11 | |
426 | 2495..2993: 10 | |
427 | 2994..3492: 13 | |
428 | 3493..3991: 13 | |
429 | 3992..4490: 5 | |
430 | 4491..4989: 10 | |
431 | 4990..5488: 19 | |
432 | 5489..5987: 9 | |
433 | 5988..6486: 10 | |
434 | 6487..6985: 12 | |
435 | 6986..7484: 17 | |
436 | 7485..7983: 16 | |
437 | 7984..8482: 16 | |
438 | 8483..8981: 16 | |
439 | 8982..9480: 16 | |
440 | 9481..9979: 12 | |
441 | ||
442 | +++ Stats for string_of len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
443 | ||
444 | stats len: | |
445 | num: 5000, avg: 363.14, stddev: 1245.80, median 9, min 0, max 9986 | |
446 | 0.. 499: ####################################################### 4270 | |
447 | 500.. 999: ###### 493 | |
448 | 1000.. 1499: 16 | |
449 | 1500.. 1999: 11 | |
450 | 2000.. 2499: 15 | |
451 | 2500.. 2999: 17 | |
452 | 3000.. 3499: 11 | |
453 | 3500.. 3999: 19 | |
454 | 4000.. 4499: 14 | |
455 | 4500.. 4999: 10 | |
456 | 5000.. 5499: 16 | |
457 | 5500.. 5999: 11 | |
458 | 6000.. 6499: 15 | |
459 | 6500.. 6999: 13 | |
460 | 7000.. 7499: 12 | |
461 | 7500.. 7999: 16 | |
462 | 8000.. 8499: 11 | |
463 | 8500.. 8999: 4 | |
464 | 9000.. 9499: 13 | |
465 | 9500.. 9999: 13 | |
466 | ||
467 | +++ Stats for printable_string len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
468 | ||
469 | stats len: | |
470 | num: 5000, avg: 384.53, stddev: 1330.61, median 9, min 0, max 9969 | |
471 | 0.. 498: ####################################################### 4246 | |
472 | 499.. 997: ###### 518 | |
473 | 998..1496: 21 | |
474 | 1497..1995: 10 | |
475 | 1996..2494: 11 | |
476 | 2495..2993: 10 | |
477 | 2994..3492: 13 | |
478 | 3493..3991: 13 | |
479 | 3992..4490: 5 | |
480 | 4491..4989: 10 | |
481 | 4990..5488: 19 | |
482 | 5489..5987: 9 | |
483 | 5988..6486: 10 | |
484 | 6487..6985: 12 | |
485 | 6986..7484: 17 | |
486 | 7485..7983: 16 | |
487 | 7984..8482: 16 | |
488 | 8483..8981: 16 | |
489 | 8982..9480: 16 | |
490 | 9481..9979: 12 | |
491 | ||
492 | +++ Stats for small_string len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
493 | ||
494 | stats len: | |
495 | num: 5000, avg: 15.57, stddev: 24.36, median 6, min 0, max 99 | |
496 | 0.. 4: #################################################### 1925 | |
497 | 5.. 9: ####################################################### 2005 | |
498 | 10.. 14: # 52 | |
499 | 15.. 19: # 50 | |
500 | 20.. 24: # 55 | |
501 | 25.. 29: # 56 | |
502 | 30.. 34: # 55 | |
503 | 35.. 39: # 49 | |
504 | 40.. 44: # 65 | |
505 | 45.. 49: # 65 | |
506 | 50.. 54: # 55 | |
507 | 55.. 59: # 68 | |
508 | 60.. 64: # 61 | |
509 | 65.. 69: # 65 | |
510 | 70.. 74: # 57 | |
511 | 75.. 79: # 66 | |
512 | 80.. 84: # 65 | |
513 | 85.. 89: # 64 | |
514 | 90.. 94: # 60 | |
515 | 95.. 99: # 62 | |
516 | ||
517 | +++ Stats for list len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
518 | ||
519 | stats len: | |
520 | num: 5000, avg: 400.16, stddev: 1371.90, median 9, min 0, max 9987 | |
521 | 0.. 499: ####################################################### 4246 | |
522 | 500.. 999: ###### 502 | |
523 | 1000.. 1499: 13 | |
524 | 1500.. 1999: 10 | |
525 | 2000.. 2499: 14 | |
526 | 2500.. 2999: 14 | |
527 | 3000.. 3499: 20 | |
528 | 3500.. 3999: 7 | |
529 | 4000.. 4499: 13 | |
530 | 4500.. 4999: 16 | |
531 | 5000.. 5499: 12 | |
532 | 5500.. 5999: 15 | |
533 | 6000.. 6499: 15 | |
534 | 6500.. 6999: 13 | |
535 | 7000.. 7499: 16 | |
536 | 7500.. 7999: 12 | |
537 | 8000.. 8499: 11 | |
538 | 8500.. 8999: 16 | |
539 | 9000.. 9499: 15 | |
540 | 9500.. 9999: 20 | |
541 | ||
542 | +++ Stats for small_list len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
543 | ||
544 | stats len: | |
545 | num: 5000, avg: 16.14, stddev: 24.86, median 6, min 0, max 99 | |
546 | 0.. 4: ###################################################### 1923 | |
547 | 5.. 9: ####################################################### 1936 | |
548 | 10.. 14: # 61 | |
549 | 15.. 19: # 59 | |
550 | 20.. 24: # 62 | |
551 | 25.. 29: # 70 | |
552 | 30.. 34: # 61 | |
553 | 35.. 39: # 64 | |
554 | 40.. 44: # 64 | |
555 | 45.. 49: # 56 | |
556 | 50.. 54: # 65 | |
557 | 55.. 59: # 55 | |
558 | 60.. 64: # 60 | |
559 | 65.. 69: # 62 | |
560 | 70.. 74: # 57 | |
561 | 75.. 79: # 69 | |
562 | 80.. 84: ## 73 | |
563 | 85.. 89: # 67 | |
564 | 90.. 94: # 62 | |
565 | 95.. 99: ## 74 | |
566 | ||
567 | +++ Stats for list_of_size len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
568 | ||
569 | stats len: | |
570 | num: 5000, avg: 7.49, stddev: 1.71, median 8, min 5, max 10 | |
571 | 5: ####################################################### 867 | |
572 | 6: ################################################### 813 | |
573 | 7: ################################################### 815 | |
574 | 8: #################################################### 833 | |
575 | 9: ###################################################### 857 | |
576 | 10: ################################################### 815 | |
577 | ||
578 | +++ Stats for list_repeat len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
579 | ||
580 | stats len: | |
581 | num: 5000, avg: 42.00, stddev: 0.00, median 42, min 42, max 42 | |
582 | 42: ####################################################### 5000 | |
583 | ||
584 | +++ Stats for array len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
585 | ||
586 | stats len: | |
587 | num: 5000, avg: 400.16, stddev: 1371.90, median 9, min 0, max 9987 | |
588 | 0.. 499: ####################################################### 4246 | |
589 | 500.. 999: ###### 502 | |
590 | 1000.. 1499: 13 | |
591 | 1500.. 1999: 10 | |
592 | 2000.. 2499: 14 | |
593 | 2500.. 2999: 14 | |
594 | 3000.. 3499: 20 | |
595 | 3500.. 3999: 7 | |
596 | 4000.. 4499: 13 | |
597 | 4500.. 4999: 16 | |
598 | 5000.. 5499: 12 | |
599 | 5500.. 5999: 15 | |
600 | 6000.. 6499: 15 | |
601 | 6500.. 6999: 13 | |
602 | 7000.. 7499: 16 | |
603 | 7500.. 7999: 12 | |
604 | 8000.. 8499: 11 | |
605 | 8500.. 8999: 16 | |
606 | 9000.. 9499: 15 | |
607 | 9500.. 9999: 20 | |
608 | ||
609 | +++ Stats for small_array len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
610 | ||
611 | stats len: | |
612 | num: 5000, avg: 16.14, stddev: 24.86, median 6, min 0, max 99 | |
613 | 0.. 4: ###################################################### 1923 | |
614 | 5.. 9: ####################################################### 1936 | |
615 | 10.. 14: # 61 | |
616 | 15.. 19: # 59 | |
617 | 20.. 24: # 62 | |
618 | 25.. 29: # 70 | |
619 | 30.. 34: # 61 | |
620 | 35.. 39: # 64 | |
621 | 40.. 44: # 64 | |
622 | 45.. 49: # 56 | |
623 | 50.. 54: # 65 | |
624 | 55.. 59: # 55 | |
625 | 60.. 64: # 60 | |
626 | 65.. 69: # 62 | |
627 | 70.. 74: # 57 | |
628 | 75.. 79: # 69 | |
629 | 80.. 84: ## 73 | |
630 | 85.. 89: # 67 | |
631 | 90.. 94: # 62 | |
632 | 95.. 99: ## 74 | |
633 | ||
634 | +++ Stats for array_of_size len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
635 | ||
636 | stats len: | |
637 | num: 5000, avg: 7.49, stddev: 1.71, median 8, min 5, max 10 | |
638 | 5: ####################################################### 867 | |
639 | 6: ################################################### 813 | |
640 | 7: ################################################### 815 | |
641 | 8: #################################################### 833 | |
642 | 9: ###################################################### 857 | |
643 | 10: ################################################### 815 | |
644 | ||
645 | +++ Stats for array_repeat len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
646 | ||
647 | stats len: | |
648 | num: 5000, avg: 42.00, stddev: 0.00, median 42, min 42, max 42 | |
649 | 42: ####################################################### 5000 | |
650 | ||
651 | +++ Stats for int_stats_neg ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
652 | ||
653 | stats dist: | |
654 | num: 5000, avg: 0.17, stddev: 29.68, median 0, min -99, max 99 | |
655 | -99..-90: # 65 | |
656 | -89..-80: # 63 | |
657 | -79..-70: # 64 | |
658 | -69..-60: # 58 | |
659 | -59..-50: # 67 | |
660 | -49..-40: # 72 | |
661 | -39..-30: # 61 | |
662 | -29..-20: # 61 | |
663 | -19..-10: # 67 | |
664 | -9.. 0: ####################################################### 2076 | |
665 | 1.. 10: ############################################## 1764 | |
666 | 11.. 20: # 66 | |
667 | 21.. 30: # 64 | |
668 | 31.. 40: # 64 | |
669 | 41.. 50: # 67 | |
670 | 51.. 60: # 60 | |
671 | 61.. 70: # 75 | |
672 | 71.. 80: # 60 | |
673 | 81.. 90: # 60 | |
674 | 91..100: # 66 | |
675 | ||
676 | +++ Stats for small_signed_int dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
677 | ||
678 | stats dist: | |
679 | num: 1000, avg: 0.90, stddev: 28.23, median 0, min -99, max 99 | |
680 | -99..-90: # 12 | |
681 | -89..-80: # 11 | |
682 | -79..-70: # 9 | |
683 | -69..-60: 6 | |
684 | -59..-50: # 11 | |
685 | -49..-40: # 13 | |
686 | -39..-30: # 9 | |
687 | -29..-20: # 13 | |
688 | -19..-10: 8 | |
689 | -9.. 0: ####################################################### 453 | |
690 | 1.. 10: ######################################### 340 | |
691 | 11.. 20: # 15 | |
692 | 21.. 30: # 11 | |
693 | 31.. 40: # 12 | |
694 | 41.. 50: # 13 | |
695 | 51.. 60: # 13 | |
696 | 61.. 70: # 16 | |
697 | 71.. 80: # 9 | |
698 | 81.. 90: # 16 | |
699 | 91..100: # 10 | |
700 | ||
701 | +++ Stats for small_nat dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
702 | ||
703 | stats dist: | |
704 | num: 1000, avg: 15.11, stddev: 23.27, median 6, min 0, max 99 | |
705 | 0.. 4: #################################################### 377 | |
706 | 5.. 9: ####################################################### 392 | |
707 | 10.. 14: ## 20 | |
708 | 15.. 19: ## 15 | |
709 | 20.. 24: # 11 | |
710 | 25.. 29: ## 17 | |
711 | 30.. 34: ## 19 | |
712 | 35.. 39: ## 17 | |
713 | 40.. 44: # 10 | |
714 | 45.. 49: # 9 | |
715 | 50.. 54: # 8 | |
716 | 55.. 59: # 9 | |
717 | 60.. 64: ## 15 | |
718 | 65.. 69: # 10 | |
719 | 70.. 74: # 13 | |
720 | 75.. 79: ## 19 | |
721 | 80.. 84: # 11 | |
722 | 85.. 89: # 13 | |
723 | 90.. 94: 5 | |
724 | 95.. 99: # 10 | |
725 | ||
726 | +++ Stats for nat dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
727 | ||
728 | stats dist: | |
729 | num: 1000, avg: 363.02, stddev: 1215.04, median 9, min 0, max 9476 | |
730 | 0.. 473: ####################################################### 847 | |
731 | 474.. 947: ###### 95 | |
732 | 948..1421: 14 | |
733 | 1422..1895: 3 | |
734 | 1896..2369: 0 | |
735 | 2370..2843: 3 | |
736 | 2844..3317: 2 | |
737 | 3318..3791: 3 | |
738 | 3792..4265: 2 | |
739 | 4266..4739: 4 | |
740 | 4740..5213: 3 | |
741 | 5214..5687: 4 | |
742 | 5688..6161: 3 | |
743 | 6162..6635: 4 | |
744 | 6636..7109: 1 | |
745 | 7110..7583: 4 | |
746 | 7584..8057: 2 | |
747 | 8058..8531: 1 | |
748 | 8532..9005: 1 | |
749 | 9006..9479: 4 | |
750 | ||
751 | +++ Stats for int_range (-43643) 435434 dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
752 | ||
753 | stats dist: | |
754 | num: 1000, avg: 195335.64, stddev: 136803.99, median 195583, min -43624, max 435210 | |
755 | -43624..-19683: ############################################ 52 | |
756 | -19682.. 4259: ######################################## 47 | |
757 | 4260.. 28201: ############################## 36 | |
758 | 28202.. 52143: ############################################ 52 | |
759 | 52144.. 76085: ########################################## 50 | |
760 | 76086..100027: ####################################################### 64 | |
761 | 100028..123969: ############################################### 55 | |
762 | 123970..147911: ######################################## 47 | |
763 | 147912..171853: ############################################## 54 | |
764 | 171854..195795: #################################### 43 | |
765 | 195796..219737: ############################################## 54 | |
766 | 219738..243679: ########################################### 51 | |
767 | 243680..267621: ################################################ 57 | |
768 | 267622..291563: ########################################## 49 | |
769 | 291564..315505: #################################### 42 | |
770 | 315506..339447: ###################################### 45 | |
771 | 339448..363389: ################################################ 57 | |
772 | 363390..387331: ###################################### 45 | |
773 | 387332..411273: ########################################## 49 | |
774 | 411274..435215: ########################################### 51 | |
775 | ||
776 | +++ Stats for int_range (-40000) 40000 dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
777 | ||
778 | stats dist: | |
779 | num: 1000, avg: -173.78, stddev: 23042.92, median 180, min -39859, max 39942 | |
780 | -39859..-35869: ############################################# 56 | |
781 | -35868..-31878: ################################### 43 | |
782 | -31877..-27887: ################################################# 60 | |
783 | -27886..-23896: ##################################### 46 | |
784 | -23895..-19905: ######################################## 49 | |
785 | -19904..-15914: #################################### 45 | |
786 | -15913..-11923: ############################################ 54 | |
787 | -11922.. -7932: ############################################### 58 | |
788 | -7931.. -3941: ######################################### 51 | |
789 | -3940.. 50: ############################ 35 | |
790 | 51.. 4041: ####################################### 48 | |
791 | 4042.. 8032: ########################################## 52 | |
792 | 8033.. 12023: ######################################### 51 | |
793 | 12024.. 16014: ########################################### 53 | |
794 | 16015.. 20005: ############################################ 54 | |
795 | 20006.. 23996: ################################## 42 | |
796 | 23997.. 27987: ####################################################### 67 | |
797 | 27988.. 31978: ################################ 40 | |
798 | 31979.. 35969: ######################################### 51 | |
799 | 35970.. 39960: #################################### 45 | |
800 | ||
801 | +++ Stats for int_range (-4) 4 dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
802 | ||
803 | stats dist: | |
804 | num: 1000, avg: 0.02, stddev: 2.55, median 0, min -4, max 4 | |
805 | -4: ############################################ 99 | |
806 | -3: ##################################################### 118 | |
807 | -2: ################################################## 111 | |
808 | -1: ################################################## 113 | |
809 | 0: ################################################## 113 | |
810 | 1: ##################################################### 118 | |
811 | 2: ############################################# 102 | |
812 | 3: ####################################################### 122 | |
813 | 4: ############################################## 104 | |
814 | ||
815 | +++ Stats for int_range (-4) 17 dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
816 | ||
817 | stats dist: | |
818 | num: 1000, avg: 6.67, stddev: 6.39, median 7, min -4, max 17 | |
819 | -4..-3: ############################################# 90 | |
820 | -2..-1: ############################################# 91 | |
821 | 0.. 1: ########################################## 84 | |
822 | 2.. 3: ############################################## 92 | |
823 | 4.. 5: ########################################### 87 | |
824 | 6.. 7: ########################################### 86 | |
825 | 8.. 9: ############################################ 89 | |
826 | 10..11: ########################################### 87 | |
827 | 12..13: ####################################################### 110 | |
828 | 14..15: ############################################# 91 | |
829 | 16..17: ############################################## 93 | |
830 | 18..19: 0 | |
831 | 20..21: 0 | |
832 | 22..23: 0 | |
833 | 24..25: 0 | |
834 | 26..27: 0 | |
835 | 28..29: 0 | |
836 | 30..31: 0 | |
837 | 32..33: 0 | |
838 | 34..35: 0 | |
839 | ||
840 | +++ Stats for int dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
841 | ||
842 | stats dist: | |
843 | num: 100000, avg: 2541076923587387.50, stddev: 2660730801206827008.00, median 158655268318060, min -4611522359435274428, max 4611540922436307689 | |
844 | -4611522359435274428..-4150369195341695293: ##################################################### 4976 | |
845 | -4150369195341695292..-3689216031248116157: ##################################################### 4963 | |
846 | -3689216031248116156..-3228062867154537021: ###################################################### 5038 | |
847 | -3228062867154537020..-2766909703060957885: ##################################################### 4979 | |
848 | -2766909703060957884..-2305756538967378749: ##################################################### 5001 | |
849 | -2305756538967378748..-1844603374873799613: ##################################################### 4982 | |
850 | -1844603374873799612..-1383450210780220477: ##################################################### 5025 | |
851 | -1383450210780220476.. -922297046686641341: #################################################### 4901 | |
852 | -922297046686641340.. -461143882593062205: ####################################################### 5126 | |
853 | -461143882593062204.. 9281500516931: ##################################################### 5008 | |
854 | 9281500516932.. 461162445594096067: ###################################################### 5041 | |
855 | 461162445594096068.. 922315609687675203: ##################################################### 5001 | |
856 | 922315609687675204.. 1383468773781254339: ##################################################### 4986 | |
857 | 1383468773781254340.. 1844621937874833475: ##################################################### 4949 | |
858 | 1844621937874833476.. 2305775101968412611: ##################################################### 5025 | |
859 | 2305775101968412612.. 2766928266061991747: ##################################################### 5022 | |
860 | 2766928266061991748.. 3228081430155570883: ##################################################### 4958 | |
861 | 3228081430155570884.. 3689234594249150019: ##################################################### 4998 | |
862 | 3689234594249150020.. 4150387758342729155: ##################################################### 4982 | |
863 | 4150387758342729156.. 4611540922436308291: ###################################################### 5039 | |
864 | ||
865 | +++ Stats for oneof int dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
866 | ||
867 | stats dist: | |
868 | num: 1000, avg: 4611686018427388.00, stddev: 2905870896563567616.00, median 0, min -4611686018427387904, max 4611686018427387903 | |
869 | -4611686018427387904..-4150517416584649089: ################## 208 | |
870 | -4150517416584649088..-3689348814741910273: 0 | |
871 | -3689348814741910272..-3228180212899171457: 0 | |
872 | -3228180212899171456..-2767011611056432641: 0 | |
873 | -2767011611056432640..-2305843009213693825: 0 | |
874 | -2305843009213693824..-1844674407370955009: 0 | |
875 | -1844674407370955008..-1383505805528216193: 0 | |
876 | -1383505805528216192.. -922337203685477377: 0 | |
877 | -922337203685477376.. -461168601842738561: 0 | |
878 | -461168601842738560.. 255: ####################################################### 603 | |
879 | 256.. 461168601842739071: 0 | |
880 | 461168601842739072.. 922337203685477887: 0 | |
881 | 922337203685477888.. 1383505805528216703: 0 | |
882 | 1383505805528216704.. 1844674407370955519: 0 | |
883 | 1844674407370955520.. 2305843009213694335: 0 | |
884 | 2305843009213694336.. 2767011611056433151: 0 | |
885 | 2767011611056433152.. 3228180212899171967: 0 | |
886 | 3228180212899171968.. 3689348814741910783: 0 | |
887 | 3689348814741910784.. 4150517416584649599: 0 | |
888 | 4150517416584649600.. 4611686018427387903: ################# 189 | |
889 | ================================================================================ | |
890 | 1 warning(s) | |
891 | failure (26 tests failed, 1 tests errored, ran 73 tests) | |
892 | random seed: 153870556 | |
893 | ||
894 | +++ Stats for int_dist_empty_bucket ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
895 | ||
896 | stats dist: | |
897 | num: 1000, avg: -55083208105414400.00, stddev: 1847115855773139200.00, median 9, min -4590718933436425025, max 4611686018427387903 | |
898 | -4590718933436425025..-4130598685843234370: ## 26 | |
899 | -4130598685843234369..-3670478438250043714: # 13 | |
900 | -3670478438250043713..-3210358190656853058: ### 37 | |
901 | -3210358190656853057..-2750237943063662402: ### 30 | |
902 | -2750237943063662401..-2290117695470471746: ## 27 | |
903 | -2290117695470471745..-1829997447877281090: ## 24 | |
904 | -1829997447877281089..-1369877200284090434: ## 27 | |
905 | -1369877200284090433.. -909756952690899778: ## 27 | |
906 | -909756952690899777.. -449636705097709122: ## 21 | |
907 | -449636705097709121.. 10483542495481534: ####################################################### 531 | |
908 | 10483542495481535.. 470603790088672190: ## 21 | |
909 | 470603790088672191.. 930724037681862846: ## 27 | |
910 | 930724037681862847.. 1390844285275053502: ## 24 | |
911 | 1390844285275053503.. 1850964532868244158: ## 25 | |
912 | 1850964532868244159.. 2311084780461434814: ## 28 | |
913 | 2311084780461434815.. 2771205028054625470: ## 23 | |
914 | 2771205028054625471.. 3231325275647816126: ## 23 | |
915 | 3231325275647816127.. 3691445523241006782: ## 25 | |
916 | 3691445523241006783.. 4151565770834197438: # 17 | |
917 | 4151565770834197439.. 4611686018427387903: ## 24 | |
918 | ================================================================================ | |
919 | success (ran 1 tests) |
0 | open QCheck2 | |
1 | ||
2 | (** For timing and summing run times *) | |
3 | let time f () = | |
4 | let start_time = Sys.time () in | |
5 | let res = f () in | |
6 | let end_time = Sys.time () in | |
7 | (end_time -. start_time,res) | |
8 | ||
9 | let sum_timing_pairs times = | |
10 | let sum_timings = List.fold_left (+.) 0.0 in | |
11 | let t1,t2 = List.split times in | |
12 | sum_timings t1,sum_timings t2 | |
13 | ||
14 | let get_name (Test.Test cell) = Test.get_name cell | |
15 | ||
16 | ||
17 | (** Runners for single tests, test pairs, and test pair lists *) | |
18 | ||
19 | (* run a single test with the given seed *) | |
20 | let run_timed_test seed cell = | |
21 | let open TestResult in | |
22 | let rand = Random.State.make [| seed |] in | |
23 | (* For total attempts, count occ. of 'Shrinking' in "event protocol": | |
24 | Shrunk 0 - Shrinking 0.1 - Shrinking 0.2 - Shrunk 1 - Shrinking 1.1 - Shrinking 1.2 *) | |
25 | let shr_attempts = ref 0 in | |
26 | let handler _ _ e = match e with | |
27 | | Test.Shrinking (_,_,_) -> incr shr_attempts | _ -> () in | |
28 | let dur,res = time (fun () -> QCheck.Test.check_cell ~rand ~handler cell) () in | |
29 | let name = Test.get_name cell in | |
30 | let res_str,shr_c,_msg = match get_state res with | |
31 | | Success -> failwith (Printf.sprintf "Test %s returned unexpected Success" name) | |
32 | | Error {exn;_} -> failwith (Printf.sprintf "Test %s returned unexpected Error %s" name (Printexc.to_string exn)) | |
33 | | Failed_other {msg} -> failwith (Printf.sprintf "Test %s returned unexpected Failed_other %s" name msg) | |
34 | | Failed {instances} -> "fail",(List.hd instances).shrink_steps, "Failed" (* expected *) in | |
35 | (dur,res_str,shr_c,!shr_attempts) | |
36 | ||
37 | (* run a pair of corresponding tests with the given seed *) | |
38 | let run_timed_test_pair seed (Test.Test c1, Test.Test c2) = | |
39 | let (dur1,res_str1,shr_c1,shr_att1) = run_timed_test seed c1 in | |
40 | let (dur2,res_str2,shr_c2,shr_att2) = run_timed_test seed c2 in | |
41 | if res_str1 <> res_str2 | |
42 | then failwith (Printf.sprintf "benchmark %s gave different errors: %s and %s" (Test.get_name c1) res_str1 res_str2) | |
43 | else (res_str1,(dur1,shr_c1,shr_att1),(dur2,shr_c2,shr_att2)) | |
44 | ||
45 | let non_repeatable_tests = ["big bound issue59";"ints < 209609"] | |
46 | ||
47 | (* run a list of corresponding test pairs over the given seed list *) | |
48 | (* and print the benchmark result to channel [ch] *) | |
49 | let run_timing ch seeds testpairs = | |
50 | let fprintf = Printf.fprintf in | |
51 | let multiple_runs = List.length seeds > 1 in | |
52 | (* print iteration header - name (48 chars) *) | |
53 | Printf.fprintf ch "%-48s" ""; | |
54 | List.iter (fun seed -> fprintf ch " iteration seed %-7i %!" seed) seeds; | |
55 | if multiple_runs then fprintf ch " total\n%!" else print_newline (); | |
56 | (* print column header - name + 38 chars per iteration *) | |
57 | fprintf ch "%-48s" "Shrink test name"; | |
58 | List.iter (fun _ -> | |
59 | fprintf ch " %-6s%-10s %!" "Q1/s" "#succ/#att"; | |
60 | fprintf ch " %-6s%-10s %!" "Q2/s" "#succ/#att") seeds; | |
61 | if multiple_runs then fprintf ch " %6s %6s" "Q1/s" "Q2/s"; | |
62 | fprintf ch "\n%!"; | |
63 | (* print separator *) | |
64 | fprintf ch "%s%!" (String.make 48 '-'); | |
65 | List.iter (fun _ -> fprintf ch "%s%!" (String.make 38 '-')) seeds; | |
66 | if multiple_runs then fprintf ch "%s%!" (String.make 16 '-'); | |
67 | fprintf ch "\n%!"; | |
68 | (* print timings for each test_pair and seed *) | |
69 | let times = | |
70 | List.map | |
71 | (fun ((test1,_test2) as test_pair) -> | |
72 | let name = get_name test1 in | |
73 | let max_len = 48 in | |
74 | fprintf ch "%-48s%!" (if String.length name<max_len then name else String.sub name 0 max_len); | |
75 | if multiple_runs && List.mem name non_repeatable_tests | |
76 | then | |
77 | begin | |
78 | fprintf ch " - skipped as generator is stateful, making it non-repeatable\n%!"; | |
79 | (0.0,0.0) | |
80 | end | |
81 | else | |
82 | let times = | |
83 | List.map (fun seed -> | |
84 | let _res_str,(dur1,shr_cnt1,shr_att1),(dur2,shr_cnt2,shr_att2) = run_timed_test_pair seed test_pair in | |
85 | fprintf ch " %6.3f %4i/%-6i%!" dur1 shr_cnt1 shr_att1; | |
86 | fprintf ch " %6.3f %4i/%-6i%!" dur2 shr_cnt2 shr_att2; | |
87 | (dur1,dur2) | |
88 | ) seeds in | |
89 | let t1_sum,t2_sum = sum_timing_pairs times in | |
90 | if multiple_runs then fprintf ch " %6.3f %6.3f%!" t1_sum t2_sum; | |
91 | fprintf ch "\n%!"; | |
92 | (t1_sum,t2_sum)) | |
93 | testpairs in | |
94 | let t1_sum,t2_sum = sum_timing_pairs times in | |
95 | fprintf ch "%s%!" (String.make (48 + 38*List.length seeds) ' '); | |
96 | fprintf ch " %6.3f %6.3f\n%!" t1_sum t2_sum | |
97 | ||
98 | (* merge two corresponding lists of tests *) | |
99 | let rec merge_and_validate xs ys = match xs,ys with | |
100 | | [],[] -> [] | |
101 | | [],_ -> failwith "QCheck2_tests.Shrink has more tests than QCheck_tests.Shrink" | |
102 | | _,[] -> failwith "QCheck_tests.Shrink has more tests than QCheck2_tests.Shrink" | |
103 | | t1::xs,t2::ys -> | |
104 | if get_name t1 = get_name t2 | |
105 | then (t1,t2) :: merge_and_validate xs ys | |
106 | else | |
107 | let msg = Printf.sprintf "Found \"%s\" and \"%s\". Are QCheck_tests.Shrink and QCheck2_tests.Shrink not in the same order?" (get_name t1) (get_name t2) in | |
108 | failwith msg | |
109 | ||
110 | let seeds = [1234;(*4321;*)8743;(*9876;*)6789; | |
111 | (*2143*) (* ouch: seed 2143 causes test "lists equal to duplication" to segfault *) | |
112 | ] | |
113 | let () = | |
114 | let ch = open_out "shrink_bench.log" in | |
115 | try | |
116 | merge_and_validate | |
117 | QCheck_tests.(Shrink.tests@Function.tests) | |
118 | QCheck2_tests.(Shrink.tests@Function.tests) | |
119 | |> run_timing ch seeds; | |
120 | close_out ch | |
121 | with e -> | |
122 | close_out ch; | |
123 | raise e |
0 | open QCheck2 | |
1 | ||
2 | module Shrink = struct | |
3 | let test_int_towards () = | |
4 | Alcotest.(check' (list int)) | |
5 | ~msg:"int_towards 0 100" | |
6 | ~actual:(Shrink.int_towards 0 100 |> List.of_seq) | |
7 | ~expected:[0; 50; 75; 88; 94; 97; 99]; | |
8 | Alcotest.(check' (list int)) | |
9 | ~msg:"int_towards 500 1000" | |
10 | ~actual:(Shrink.int_towards 500 1000 |> List.of_seq) | |
11 | ~expected:[500; 750; 875; 938; 969; 985; 993; 997; 999]; | |
12 | Alcotest.(check' (list int)) | |
13 | ~msg:"int_towards (-50) (-26)" | |
14 | ~actual:(Shrink.int_towards (-50) (-26) |> List.of_seq) | |
15 | ~expected:[-50; -38; -32; -29; -28; -27] | |
16 | ||
17 | let test_int32_towards () = | |
18 | Alcotest.(check' (list int32)) | |
19 | ~msg:"int32_towards 0l 100l" | |
20 | ~actual:(Shrink.int32_towards 0l 100l |> List.of_seq) | |
21 | ~expected:[0l; 50l; 75l; 88l; 94l; 97l; 99l]; | |
22 | Alcotest.(check' (list int32)) | |
23 | ~msg:"int32_towards 500l 1000l" | |
24 | ~actual:(Shrink.int32_towards 500l 1000l |> List.of_seq) | |
25 | ~expected:[500l; 750l; 875l; 938l; 969l; 985l; 993l; 997l; 999l]; | |
26 | Alcotest.(check' (list int32)) | |
27 | ~msg:"int32_towards (-50l) (-26l)" | |
28 | ~actual:(Shrink.int32_towards (-50l) (-26l) |> List.of_seq) | |
29 | ~expected:[-50l; -38l; -32l; -29l; -28l; -27l] | |
30 | ||
31 | let test_int64_towards () = | |
32 | Alcotest.(check' (list int64)) | |
33 | ~msg:"int64_towards 0L 100L" | |
34 | ~actual:(Shrink.int64_towards 0L 100L |> List.of_seq) | |
35 | ~expected:[0L; 50L; 75L; 88L; 94L; 97L; 99L]; | |
36 | Alcotest.(check' (list int64)) | |
37 | ~msg:"int64_towards 500L 1000L" | |
38 | ~actual:(Shrink.int64_towards 500L 1000L |> List.of_seq) | |
39 | ~expected:[500L; 750L; 875L; 938L; 969L; 985L; 993L; 997L; 999L]; | |
40 | Alcotest.(check' (list int64)) | |
41 | ~msg:"int64_towards (-50L) (-26L)" | |
42 | ~actual:(Shrink.int64_towards (-50L) (-26L) |> List.of_seq) | |
43 | ~expected:[-50L; -38L; -32L; -29L; -28L; -27L] | |
44 | ||
45 | let test_float_towards () = | |
46 | Alcotest.(check' (list (float 0.0001))) | |
47 | ~msg:"float_towards 0. 100." | |
48 | ~actual:(Shrink.float_towards 0. 100. |> List.of_seq) | |
49 | ~expected:[0.; 50.; 75.; 87.5; 93.75; 96.875; 98.4375; 99.2188; 99.6094; 99.8047; 99.9023; 99.9512; 99.9756; 99.9878; 99.9939]; | |
50 | Alcotest.(check' (list (float 0.001))) | |
51 | ~msg:"float_towards 500. 1000." | |
52 | ~actual:(Shrink.float_towards 500. 1000. |> List.of_seq) | |
53 | ~expected:[500.; 750.; 875.; 937.5; 968.75; 984.375; 992.188; 996.094; 998.047; 999.023; 999.512; 999.756; 999.878; 999.939; 999.969]; | |
54 | Alcotest.(check' (list (float 0.0001))) | |
55 | ~msg:"float_towards (-50.) (-26.)" | |
56 | ~actual:(Shrink.float_towards (-50.) (-26.) |> List.of_seq) | |
57 | ~expected:[-50.; -38.; -32.; -29.; -27.5; -26.75; -26.375; -26.1875; -26.0938; -26.0469; -26.0234; -26.0117; -26.0059; -26.0029; -26.0015] | |
58 | ||
59 | let tests = ("Shrink", Alcotest.[ | |
60 | test_case "int_towards" `Quick test_int_towards; | |
61 | test_case "int32_towards" `Quick test_int32_towards; | |
62 | test_case "int64_towards" `Quick test_int64_towards; | |
63 | test_case "float_towards" `Quick test_float_towards | |
64 | ]) | |
65 | end | |
66 | ||
67 | module Gen = struct | |
68 | let test_gen_opt ~ratio = | |
69 | let opt_int = Gen.opt ?ratio Gen.int in | |
70 | let nb = ref 0 in | |
71 | for _i = 0 to 1000 do | |
72 | Gen.generate1 opt_int |> function None -> () | Some _ -> nb := !nb + 1 | |
73 | done; | |
74 | !nb | |
75 | ||
76 | let test_gen_opt_default () = | |
77 | let nb = test_gen_opt ~ratio:None in | |
78 | let b = nb > 800 && nb < 900 in | |
79 | Alcotest.(check bool) "Gen.opt produces around 85% of Some" b true | |
80 | ||
81 | let test_gen_opt_custom () = | |
82 | let nb = test_gen_opt ~ratio:(Some 0.5) in | |
83 | let b = nb > 450 && nb < 550 in | |
84 | Alcotest.(check bool) "Gen.opt produces around 50% of Some" b true | |
85 | ||
86 | let tests = | |
87 | ("Gen", Alcotest.[ | |
88 | test_case "opt with default ratio" `Quick test_gen_opt_default; | |
89 | test_case "opt with custom ratio" `Quick test_gen_opt_custom; | |
90 | ]) | |
91 | end | |
92 | ||
93 | module Test = struct | |
94 | let test_count_n ?count expected = | |
95 | let t = QCheck2.(Test.make ?count Gen.int (fun _ -> true)) in | |
96 | let msg = Printf.sprintf "QCheck2.Test.make ~count:%s |> get_count = %d" | |
97 | (Option.fold ~none:"None" ~some:string_of_int count) expected | |
98 | in | |
99 | Alcotest.(check int) msg expected (QCheck2.Test.test_get_count t) | |
100 | ||
101 | let test_count_10 () = test_count_n ~count:10 10 | |
102 | ||
103 | let test_count_0 () = test_count_n ~count:0 0 | |
104 | ||
105 | let test_count_default () = test_count_n 100 | |
106 | ||
107 | let test_count_env () = | |
108 | let () = Unix.putenv "QCHECK_COUNT" "5" in | |
109 | let t = QCheck2.(Test.make Gen.int (fun _ -> true)) in | |
110 | let actual = QCheck2.Test.test_get_count t in | |
111 | Alcotest.(check int) "default count is from QCHECK_COUNT" 5 actual | |
112 | ||
113 | let tests = | |
114 | ("Test", Alcotest.[ | |
115 | test_case "make with custom count" `Quick test_count_10; | |
116 | test_case "make with custom count" `Quick test_count_0; | |
117 | test_case "make with default count" `Quick test_count_default; | |
118 | test_case "make with env count" `Quick test_count_env; | |
119 | ]) | |
120 | end | |
121 | ||
122 | module String = struct | |
123 | ||
124 | let test_string_shrinking () = | |
125 | let shrink_result = QCheck2.(find_example_gen ~f:(fun s -> s <> s ^ s) Gen.string) in | |
126 | Alcotest.(check string) "Shrinking a non-empty string shrinks to \"a\"" "a" shrink_result | |
127 | ||
128 | let tests = ("String", Alcotest.[test_case "shrinking" `Quick test_string_shrinking]) | |
129 | end | |
130 | ||
131 | let () = | |
132 | Alcotest.run "QCheck" | |
133 | [ | |
134 | Shrink.tests; | |
135 | Gen.tests; | |
136 | Test.tests; | |
137 | String.tests | |
138 | ] |
0 | (tests | |
1 | (package ppx_deriving_qcheck) | |
2 | (names | |
3 | test_textual | |
4 | test_primitives | |
5 | test_qualified_names | |
6 | test_recursive | |
7 | test_tuple | |
8 | test_variants | |
9 | test_record) | |
10 | (libraries qcheck-alcotest ppxlib ppx_deriving_qcheck qcheck) | |
11 | (preprocess (pps ppxlib.metaquot ppx_deriving_qcheck))) |
0 | open QCheck | |
1 | ||
2 | (** {1. Helpers} *) | |
3 | ||
4 | let seed = [| 42 |] | |
5 | ||
6 | let generate gen = Gen.generate ~n:20 ~rand:(Random.State.make seed) gen | |
7 | ||
8 | (** [test_compare msg eq gen_ref gen_cand] will generate with the same seed | |
9 | [gen_ref] and [gen_cand], and test with Alcotest that both generators | |
10 | generates the same values. *) | |
11 | let test_compare ~msg ~eq gen_ref gen_candidate = | |
12 | let expected = generate gen_ref in | |
13 | let actual = generate gen_candidate in | |
14 | Alcotest.(check (list eq)) msg expected actual |
0 | open QCheck | |
1 | open Helpers | |
2 | ||
3 | (** {1. Test primitives derivation} *) | |
4 | ||
5 | (** {2. Tests} *) | |
6 | ||
7 | type int' = int [@@deriving qcheck] | |
8 | ||
9 | let test_int () = | |
10 | test_compare ~msg:"Gen.int <=> deriving int" ~eq:Alcotest.int Gen.int gen_int' | |
11 | ||
12 | type unit' = unit [@@deriving qcheck] | |
13 | ||
14 | (* Pretty useless though, but, meh *) | |
15 | let test_unit () = | |
16 | test_compare ~msg:"Gen.unit <=> deriving unit" ~eq:Alcotest.unit Gen.unit gen_unit' | |
17 | ||
18 | type string' = string [@@deriving qcheck] | |
19 | ||
20 | let test_string () = | |
21 | test_compare ~msg:"Gen.string <=> deriving string" ~eq:Alcotest.string Gen.string gen_string' | |
22 | ||
23 | type char' = char [@@deriving qcheck] | |
24 | ||
25 | let test_char () = | |
26 | test_compare ~msg:"Gen.char <=> deriving char" ~eq:Alcotest.char Gen.char gen_char' | |
27 | ||
28 | type bool' = bool [@@deriving qcheck] | |
29 | ||
30 | let test_bool () = | |
31 | test_compare ~msg:"Gen.bool <=> deriving bool" ~eq:Alcotest.bool Gen.bool gen_bool' | |
32 | ||
33 | type float' = float [@@deriving qcheck] | |
34 | ||
35 | let test_float () = | |
36 | test_compare ~msg:"Gen.float <=> deriving float" ~eq:(Alcotest.float 0.) Gen.float gen_float' | |
37 | ||
38 | type int32' = int32 [@@deriving qcheck] | |
39 | ||
40 | let test_int32 () = | |
41 | test_compare ~msg:"Gen.int32 <=> deriving int32" ~eq:Alcotest.int32 Gen.ui32 gen_int32' | |
42 | ||
43 | type int64' = int64 [@@deriving qcheck] | |
44 | ||
45 | let test_int64 () = | |
46 | test_compare ~msg:"Gen.int64 <=> deriving int64" ~eq:Alcotest.int64 Gen.ui64 gen_int64' | |
47 | ||
48 | type 'a option' = 'a option [@@deriving qcheck] | |
49 | ||
50 | let test_option () = | |
51 | let zero = Gen.pure 0 in | |
52 | test_compare ~msg:"Gen.option <=> deriving option" | |
53 | ~eq:Alcotest.(option int) | |
54 | (Gen.option zero) (gen_option' zero) | |
55 | ||
56 | type 'a array' = 'a array [@@deriving qcheck] | |
57 | ||
58 | let test_array () = | |
59 | let zero = Gen.pure 0 in | |
60 | test_compare ~msg:"Gen.array <=> deriving array" | |
61 | ~eq:Alcotest.(array int) | |
62 | (Gen.array zero) (gen_array' zero) | |
63 | ||
64 | type 'a list' = 'a list [@@deriving qcheck] | |
65 | ||
66 | let test_list () = | |
67 | let zero = Gen.pure 0 in | |
68 | test_compare ~msg:"Gen.list <=> deriving list" | |
69 | ~eq:Alcotest.(list int) | |
70 | (Gen.list zero) (gen_list' zero) | |
71 | ||
72 | (** {2. Execute tests} *) | |
73 | ||
74 | let () = Alcotest.run "Test_Primitives" | |
75 | [("Primitives", | |
76 | Alcotest.[ | |
77 | test_case "test_int" `Quick test_int; | |
78 | test_case "test_unit" `Quick test_unit; | |
79 | test_case "test_string" `Quick test_string; | |
80 | test_case "test_char" `Quick test_char; | |
81 | test_case "test_bool" `Quick test_bool; | |
82 | test_case "test_float" `Quick test_float; | |
83 | test_case "test_int32" `Quick test_int32; | |
84 | test_case "test_int64" `Quick test_int64; | |
85 | test_case "test_option" `Quick test_option; | |
86 | test_case "test_array" `Quick test_array; | |
87 | test_case "test_list" `Quick test_list; | |
88 | ])] |
0 | open QCheck | |
1 | open Helpers | |
2 | ||
3 | module type S = sig | |
4 | type t = int | |
5 | ||
6 | val gen : int QCheck.Gen.t | |
7 | end | |
8 | ||
9 | module Q : S = struct | |
10 | type t = int [@@deriving qcheck] | |
11 | end | |
12 | ||
13 | module F (X : S) = struct | |
14 | type t = X.t [@@deriving qcheck] | |
15 | end | |
16 | ||
17 | module G = F (Q) | |
18 | ||
19 | type t = Q.t [@@deriving qcheck] | |
20 | ||
21 | type u = G.t [@@deriving qcheck] | |
22 | ||
23 | let test_module () = | |
24 | test_compare ~msg:"Gen.int <=> deriving Q.t" ~eq:Alcotest.int Gen.int gen | |
25 | ||
26 | let test_functor () = | |
27 | test_compare ~msg:"Gen.int <=> deriving F.t" ~eq:Alcotest.int Gen.int gen_u | |
28 | ||
29 | (** {2. Execute tests} *) | |
30 | ||
31 | let () = Alcotest.run "Test_Qualified_names" | |
32 | [("Qualified names", | |
33 | Alcotest.[ | |
34 | test_case "test_module" `Quick test_module; | |
35 | test_case "test_functor" `Quick test_functor | |
36 | ])] |
0 | open QCheck | |
1 | open Helpers | |
2 | ||
3 | type env = { | |
4 | rec_types : string list; | |
5 | curr_types : string list; | |
6 | curr_type : string | |
7 | } | |
8 | [@@deriving qcheck] | |
9 | ||
10 | let pp_env fmt {rec_types; curr_types; curr_type} = | |
11 | let open Format in | |
12 | fprintf fmt {|{ | |
13 | rec_types = [%a]; | |
14 | curr_types = [%a]; | |
15 | curr_type = [%s]; | |
16 | }|} | |
17 | (pp_print_list pp_print_string) rec_types | |
18 | (pp_print_list pp_print_string) curr_types | |
19 | curr_type | |
20 | ||
21 | let eq_env = Alcotest.of_pp pp_env | |
22 | ||
23 | let gen_env_ref = | |
24 | let open Gen in | |
25 | map3 (fun rec_types curr_types curr_type -> | |
26 | { rec_types; curr_types; curr_type }) | |
27 | (list string) (list string) string | |
28 | ||
29 | let test_env () = | |
30 | test_compare ~msg:"gen_env ref <=> deriving env" | |
31 | ~eq:eq_env gen_env_ref gen_env | |
32 | ||
33 | type color = Color of { red : float; green : float; blue : float } | |
34 | [@@deriving qcheck] | |
35 | ||
36 | let pp_color fmt (Color {red; green; blue}) = | |
37 | let open Format in | |
38 | fprintf fmt {|Color { | |
39 | red = %a; | |
40 | green = %a; | |
41 | blue = %a; | |
42 | }|} | |
43 | pp_print_float red | |
44 | pp_print_float green | |
45 | pp_print_float blue | |
46 | ||
47 | let eq_color = Alcotest.of_pp pp_color | |
48 | ||
49 | let gen_color_ref = | |
50 | let open Gen in | |
51 | map3 (fun red green blue -> Color {red; green; blue}) float float float | |
52 | ||
53 | let test_color () = | |
54 | test_compare ~msg:"gen_color ref <=> deriving color" | |
55 | ~eq:eq_color gen_color_ref gen_color | |
56 | ||
57 | (** {2. Execute tests} *) | |
58 | ||
59 | let () = Alcotest.run "Test_Record" | |
60 | [("Record", | |
61 | Alcotest.[ | |
62 | test_case "test_env" `Quick test_env; | |
63 | test_case "test_color" `Quick test_color; | |
64 | ])] |
0 | open QCheck | |
1 | open Helpers | |
2 | ||
3 | type 'a tree = Leaf | Node of 'a * 'a tree * 'a tree | |
4 | [@@deriving qcheck] | |
5 | ||
6 | let rec pp_tree pp fmt x = | |
7 | let open Format in | |
8 | match x with | |
9 | | Leaf -> | |
10 | fprintf fmt "Leaf" | |
11 | | Node (x, l, r) -> | |
12 | fprintf fmt "Node (%a, %a, %a)" | |
13 | pp x | |
14 | (pp_tree pp) l | |
15 | (pp_tree pp) r | |
16 | ||
17 | let eq_tree pp = Alcotest.of_pp (pp_tree pp) | |
18 | ||
19 | let gen_tree_ref gen = | |
20 | let open Gen in | |
21 | sized @@ fix (fun self -> | |
22 | function | |
23 | | 0 -> pure Leaf | |
24 | | n -> | |
25 | oneof [ | |
26 | pure Leaf; | |
27 | map3 (fun x l r -> Node (x,l,r)) gen (self (n/2)) (self (n/2)); | |
28 | ]) | |
29 | ||
30 | let gen_tree_candidate = gen_tree | |
31 | ||
32 | let test_tree_ref () = | |
33 | let gen = Gen.int in | |
34 | test_compare ~msg:"gen tree <=> derivation tree" | |
35 | ~eq:(eq_tree Format.pp_print_int) | |
36 | (gen_tree_ref gen) (gen_tree gen) | |
37 | ||
38 | let test_leaf = | |
39 | Test.make | |
40 | ~name:"gen_tree_sized 0 = Node (_, Leaf, Leaf)" | |
41 | (make (gen_tree_sized Gen.int 0)) | |
42 | (function | |
43 | | Leaf -> true | |
44 | | Node (_, Leaf, Leaf) -> true | |
45 | | _ -> false) | |
46 | |> | |
47 | QCheck_alcotest.to_alcotest | |
48 | ||
49 | (* A slight error has been found here: | |
50 | If the type is named `list` then `'a list` will be derived with the | |
51 | QCheck generator `list` instead of the `gen_list_sized`. | |
52 | ||
53 | This could lead to a design choice: | |
54 | - do we allow overriding primitive types? | |
55 | - do we prioritize `Env.curr_types` over primitive types? | |
56 | *) | |
57 | type 'a my_list = Cons of 'a * 'a my_list | Nil | |
58 | [@@deriving qcheck] | |
59 | ||
60 | let rec length = function | |
61 | | Nil -> 0 | |
62 | | Cons (_, xs) -> 1 + length xs | |
63 | ||
64 | let test_length = | |
65 | Test.make | |
66 | ~name:"gen_list_sized n >>= fun l -> length l <= n" | |
67 | small_int | |
68 | (fun n -> | |
69 | let l = Gen.(generate1 (gen_my_list_sized Gen.int n)) in | |
70 | length l <= n) | |
71 | |> | |
72 | QCheck_alcotest.to_alcotest | |
73 | ||
74 | let () = Alcotest.run "Test_Recursive" | |
75 | [("Recursive", | |
76 | Alcotest.[ | |
77 | test_case "test_tree_ref" `Quick test_tree_ref; | |
78 | test_leaf | |
79 | ])] |
0 | (** Module test for ppx_deriving_qcheck *) | |
1 | open Ppxlib | |
2 | ||
3 | (** Primitive types tests *) | |
4 | let loc = Location.none | |
5 | ||
6 | let f = Ppx_deriving_qcheck.derive_gen ~loc | |
7 | ||
8 | let f' xs = List.map f xs |> List.concat | |
9 | ||
10 | let extract stri = | |
11 | match stri.pstr_desc with Pstr_type (x, y) -> (x, y) | _ -> assert false | |
12 | ||
13 | let extract' xs = List.map extract xs | |
14 | ||
15 | let check_eq ~expected ~actual name = | |
16 | let f = Ppxlib.Pprintast.string_of_structure in | |
17 | Alcotest.(check string) name (f expected) (f actual) | |
18 | ||
19 | let test_int () = | |
20 | let expected = [ [%stri let gen = QCheck.Gen.int] ] in | |
21 | ||
22 | let actual = f @@ extract [%stri type t = int] in | |
23 | ||
24 | check_eq ~expected ~actual "deriving int" | |
25 | ||
26 | let test_float () = | |
27 | let expected = [ [%stri let gen = QCheck.Gen.float] ] in | |
28 | let actual = f @@ extract [%stri type t = float] in | |
29 | ||
30 | check_eq ~expected ~actual "deriving float" | |
31 | ||
32 | let test_char () = | |
33 | let expected = [ [%stri let gen = QCheck.Gen.char] ] in | |
34 | let actual = f @@ extract [%stri type t = char] in | |
35 | ||
36 | check_eq ~expected ~actual "deriving char" | |
37 | ||
38 | let test_string () = | |
39 | let expected = [ [%stri let gen = QCheck.Gen.string] ] in | |
40 | let actual = f @@ extract [%stri type t = string] in | |
41 | ||
42 | check_eq ~expected ~actual "deriving string" | |
43 | ||
44 | let test_unit () = | |
45 | let expected = [ [%stri let gen = QCheck.Gen.unit] ] in | |
46 | let actual = f @@ extract [%stri type t = unit] in | |
47 | ||
48 | check_eq ~expected ~actual "deriving unit" | |
49 | ||
50 | let test_bool () = | |
51 | let expected = [ [%stri let gen = QCheck.Gen.bool] ] in | |
52 | let actual = f @@ extract [%stri type t = bool] in | |
53 | ||
54 | check_eq ~expected ~actual "deriving bool" | |
55 | ||
56 | let test_int32 () = | |
57 | let expected = [ [%stri let gen = QCheck.Gen.ui32] ] in | |
58 | let actual = f @@ extract [%stri type t = int32] in | |
59 | ||
60 | check_eq ~expected ~actual "deriving int32" | |
61 | ||
62 | let test_int32' () = | |
63 | let expected = [ [%stri let gen = QCheck.Gen.ui32] ] in | |
64 | let actual = f @@ extract [%stri type t = Int32.t] in | |
65 | ||
66 | check_eq ~expected ~actual "deriving int32'" | |
67 | ||
68 | let test_int64 () = | |
69 | let expected = [ [%stri let gen = QCheck.Gen.ui64] ] in | |
70 | let actual = f @@ extract [%stri type t = int64] in | |
71 | ||
72 | check_eq ~expected ~actual "deriving int64" | |
73 | ||
74 | let test_int64' () = | |
75 | let expected = [ [%stri let gen = QCheck.Gen.ui64] ] in | |
76 | let actual = f @@ extract [%stri type t = Int64.t] in | |
77 | ||
78 | check_eq ~expected ~actual "deriving int64'" | |
79 | ||
80 | (* let test_bytes () = | |
81 | * let expected = | |
82 | * [ | |
83 | * [%stri | |
84 | * let gen = | |
85 | * QCheck.map | |
86 | * (fun n -> Bytes.create n) | |
87 | * QCheck.(0 -- Sys.max_string_length)]; | |
88 | * ] | |
89 | * in | |
90 | * let actual = f @@ extract [%stri type t = Bytes.t ] in | |
91 | * | |
92 | * check_eq ~expected ~actual "deriving int64" *) | |
93 | ||
94 | let test_tuple () = | |
95 | let actual = | |
96 | f' | |
97 | @@ extract' | |
98 | [ | |
99 | [%stri type t = int * int]; | |
100 | [%stri type t = int * int * int]; | |
101 | [%stri type t = int * int * int * int]; | |
102 | [%stri type t = int * int * int * int * int]; | |
103 | [%stri type t = int * int * int * int * int * int]; | |
104 | ] | |
105 | in | |
106 | let expected = | |
107 | [ | |
108 | [%stri | |
109 | let gen = | |
110 | QCheck.Gen.map | |
111 | (fun (gen0, gen1) -> (gen0, gen1)) | |
112 | (QCheck.Gen.pair QCheck.Gen.int QCheck.Gen.int)]; | |
113 | [%stri | |
114 | let gen = | |
115 | QCheck.Gen.map | |
116 | (fun (gen0, gen1, gen2) -> (gen0, gen1, gen2)) | |
117 | (QCheck.Gen.triple QCheck.Gen.int QCheck.Gen.int QCheck.Gen.int)]; | |
118 | [%stri | |
119 | let gen = | |
120 | QCheck.Gen.map | |
121 | (fun (gen0, gen1, gen2, gen3) -> (gen0, gen1, gen2, gen3)) | |
122 | (QCheck.Gen.quad | |
123 | QCheck.Gen.int | |
124 | QCheck.Gen.int | |
125 | QCheck.Gen.int | |
126 | QCheck.Gen.int)]; | |
127 | [%stri | |
128 | let gen = | |
129 | QCheck.Gen.map | |
130 | (fun ((gen0, gen1), (gen2, gen3, gen4)) -> | |
131 | (gen0, gen1, gen2, gen3, gen4)) | |
132 | (QCheck.Gen.pair | |
133 | (QCheck.Gen.pair QCheck.Gen.int QCheck.Gen.int) | |
134 | (QCheck.Gen.triple QCheck.Gen.int QCheck.Gen.int QCheck.Gen.int))]; | |
135 | [%stri | |
136 | let gen = | |
137 | QCheck.Gen.map | |
138 | (fun ((gen0, gen1, gen2), (gen3, gen4, gen5)) -> | |
139 | (gen0, gen1, gen2, gen3, gen4, gen5)) | |
140 | (QCheck.Gen.pair | |
141 | (QCheck.Gen.triple QCheck.Gen.int QCheck.Gen.int QCheck.Gen.int) | |
142 | (QCheck.Gen.triple QCheck.Gen.int QCheck.Gen.int QCheck.Gen.int))]; | |
143 | ] | |
144 | in | |
145 | ||
146 | check_eq ~expected ~actual "deriving tuples" | |
147 | ||
148 | let test_option () = | |
149 | let expected = [ [%stri let gen = QCheck.Gen.option QCheck.Gen.int] ] in | |
150 | let actual = f' @@ extract' [ [%stri type t = int option] ] in | |
151 | check_eq ~expected ~actual "deriving option" | |
152 | ||
153 | let test_array () = | |
154 | let expected = [ [%stri let gen = QCheck.Gen.array QCheck.Gen.int] ] in | |
155 | let actual = f' @@ extract' [ [%stri type t = int array] ] in | |
156 | check_eq ~expected ~actual "deriving option" | |
157 | ||
158 | let test_list () = | |
159 | let expected = [ [%stri let gen = QCheck.Gen.list QCheck.Gen.string] ] in | |
160 | ||
161 | let actual = f' @@ extract' [ [%stri type t = string list] ] in | |
162 | check_eq ~expected ~actual "deriving list" | |
163 | ||
164 | let test_alpha () = | |
165 | let expected = | |
166 | [ | |
167 | [%stri let gen gen_a = gen_a]; | |
168 | [%stri let gen gen_a = QCheck.Gen.list gen_a]; | |
169 | [%stri let gen gen_a = QCheck.Gen.map (fun gen0 -> A gen0) gen_a]; | |
170 | [%stri | |
171 | let gen gen_a gen_b = | |
172 | QCheck.Gen.map | |
173 | (fun (gen0, gen1) -> A (gen0, gen1)) | |
174 | (QCheck.Gen.pair gen_a gen_b)]; | |
175 | [%stri | |
176 | let gen gen_left gen_right = | |
177 | QCheck.Gen.map | |
178 | (fun (gen0, gen1) -> (gen0, gen1)) | |
179 | (QCheck.Gen.pair gen_left gen_right)]; | |
180 | [%stri | |
181 | let gen_int_tree = gen_tree QCheck.Gen.int | |
182 | ] | |
183 | ] | |
184 | in | |
185 | let actual = | |
186 | f' | |
187 | @@ extract' | |
188 | [ | |
189 | [%stri type 'a t = 'a]; | |
190 | [%stri type 'a t = 'a list]; | |
191 | [%stri type 'a t = A of 'a]; | |
192 | [%stri type ('a, 'b) t = A of 'a * 'b]; | |
193 | [%stri type ('left, 'right) t = 'left * 'right]; | |
194 | [%stri type int_tree = int tree] | |
195 | ] | |
196 | in | |
197 | check_eq ~expected ~actual "deriving alpha" | |
198 | ||
199 | let test_equal () = | |
200 | let expected = | |
201 | [ | |
202 | [%stri | |
203 | let gen = | |
204 | QCheck.Gen.frequency | |
205 | [ | |
206 | (1, QCheck.Gen.pure A); | |
207 | (1, QCheck.Gen.pure B); | |
208 | (1, QCheck.Gen.pure C); | |
209 | ]]; | |
210 | [%stri | |
211 | let gen_t' = | |
212 | QCheck.Gen.frequency | |
213 | [ | |
214 | (1, QCheck.Gen.pure A); | |
215 | (1, QCheck.Gen.pure B); | |
216 | (1, QCheck.Gen.pure C); | |
217 | ]]; | |
218 | ] | |
219 | in | |
220 | let actual = | |
221 | f' | |
222 | @@ extract' | |
223 | [ [%stri type t = A | B | C]; [%stri type t' = t = A | B | C] ] | |
224 | in | |
225 | check_eq ~expected ~actual "deriving equal" | |
226 | ||
227 | let test_dependencies () = | |
228 | let expected = | |
229 | [ | |
230 | [%stri | |
231 | let gen = | |
232 | QCheck.Gen.frequency | |
233 | [ | |
234 | (1, QCheck.Gen.map (fun gen0 -> Int gen0) SomeModule.gen); | |
235 | ( 1, | |
236 | QCheck.Gen.map | |
237 | (fun gen0 -> Float gen0) | |
238 | SomeModule.SomeOtherModule.gen ); | |
239 | ]]; | |
240 | [%stri let gen = gen_something]; | |
241 | ] | |
242 | in | |
243 | let actual = | |
244 | f' | |
245 | @@ extract' | |
246 | [ | |
247 | [%stri | |
248 | type t = | |
249 | | Int of SomeModule.t | |
250 | | Float of SomeModule.SomeOtherModule.t]; | |
251 | [%stri type t = (Something.t[@gen gen_something])]; | |
252 | ] | |
253 | in | |
254 | ||
255 | check_eq ~expected ~actual "deriving dependencies" | |
256 | ||
257 | let test_konstr () = | |
258 | let expected = | |
259 | [ | |
260 | [%stri let gen = QCheck.Gen.map (fun gen0 -> A gen0) QCheck.Gen.int]; | |
261 | [%stri | |
262 | let gen = | |
263 | QCheck.Gen.frequency | |
264 | [ | |
265 | (1, QCheck.Gen.map (fun gen0 -> B gen0) QCheck.Gen.int); | |
266 | (1, QCheck.Gen.map (fun gen0 -> C gen0) QCheck.Gen.int); | |
267 | ]]; | |
268 | [%stri | |
269 | let gen = | |
270 | QCheck.Gen.frequency | |
271 | [ | |
272 | (1, QCheck.Gen.map (fun gen0 -> X gen0) gen_t1); | |
273 | (1, QCheck.Gen.map (fun gen0 -> Y gen0) gen_t2); | |
274 | (1, QCheck.Gen.map (fun gen0 -> Z gen0) QCheck.Gen.string); | |
275 | ]]; | |
276 | [%stri | |
277 | let gen = | |
278 | QCheck.Gen.frequency | |
279 | [ (1, QCheck.Gen.pure Left); (1, QCheck.Gen.pure Right) ]]; | |
280 | [%stri | |
281 | let gen = | |
282 | QCheck.Gen.frequency | |
283 | [ | |
284 | (1, QCheck.Gen.map (fun gen0 -> Simple gen0) QCheck.Gen.int); | |
285 | ( 1, | |
286 | QCheck.Gen.map | |
287 | (fun (gen0, gen1) -> Double (gen0, gen1)) | |
288 | (QCheck.Gen.pair QCheck.Gen.int QCheck.Gen.int) ); | |
289 | ( 1, | |
290 | QCheck.Gen.map | |
291 | (fun (gen0, gen1, gen2) -> Triple (gen0, gen1, gen2)) | |
292 | (QCheck.Gen.triple | |
293 | QCheck.Gen.int | |
294 | QCheck.Gen.int | |
295 | QCheck.Gen.int) ); | |
296 | ]]; | |
297 | ] | |
298 | in | |
299 | let actual = | |
300 | f' | |
301 | @@ extract' | |
302 | [ | |
303 | [%stri type t = A of int]; | |
304 | [%stri type t = B of int | C of int]; | |
305 | [%stri type t = X of t1 | Y of t2 | Z of string]; | |
306 | [%stri type t = Left | Right]; | |
307 | [%stri | |
308 | type t = | |
309 | | Simple of int | |
310 | | Double of int * int | |
311 | | Triple of int * int * int]; | |
312 | ] | |
313 | in | |
314 | check_eq ~expected ~actual "deriving constructors" | |
315 | ||
316 | let test_record () = | |
317 | let expected = | |
318 | [ | |
319 | [%stri | |
320 | let gen = | |
321 | QCheck.Gen.map | |
322 | (fun (gen0, gen1) -> { a = gen0; b = gen1 }) | |
323 | (QCheck.Gen.pair QCheck.Gen.int QCheck.Gen.string)]; | |
324 | [%stri | |
325 | let gen = | |
326 | QCheck.Gen.map | |
327 | (fun (gen0, gen1) -> { a = gen0; b = gen1 }) | |
328 | (QCheck.Gen.pair QCheck.Gen.int QCheck.Gen.string)]; | |
329 | [%stri | |
330 | let gen = | |
331 | QCheck.Gen.frequency | |
332 | [ | |
333 | (1, QCheck.Gen.map (fun gen0 -> A gen0) gen_t'); | |
334 | ( 1, | |
335 | QCheck.Gen.map | |
336 | (fun (gen0, gen1) -> B { left = gen0; right = gen1 }) | |
337 | (QCheck.Gen.pair QCheck.Gen.int QCheck.Gen.int) ); | |
338 | ]]; | |
339 | ] | |
340 | in | |
341 | let actual = | |
342 | f' | |
343 | @@ extract' | |
344 | [ | |
345 | [%stri type t = { a : int; b : string }]; | |
346 | [%stri type t = { mutable a : int; mutable b : string }]; | |
347 | [%stri type t = A of t' | B of { left : int; right : int }]; | |
348 | ] | |
349 | in | |
350 | check_eq ~expected ~actual "deriving record" | |
351 | ||
352 | let test_variant () = | |
353 | let expected = | |
354 | [ | |
355 | [%stri | |
356 | let gen = | |
357 | (QCheck.Gen.frequency | |
358 | [ | |
359 | (1, QCheck.Gen.pure `A); | |
360 | (1, QCheck.Gen.map (fun gen0 -> `B gen0) QCheck.Gen.int); | |
361 | (1, QCheck.Gen.map (fun gen0 -> `C gen0) QCheck.Gen.string); | |
362 | ] | |
363 | : t QCheck.Gen.t)]; | |
364 | [%stri | |
365 | let gen_t' = | |
366 | (QCheck.Gen.frequency [ (1, QCheck.Gen.pure `B); (1, gen) ] | |
367 | : t' QCheck.Gen.t)]; | |
368 | ] | |
369 | in | |
370 | let actual = | |
371 | f' | |
372 | @@ extract' | |
373 | [ | |
374 | [%stri type t = [ `A | `B of int | `C of string ]]; | |
375 | [%stri type t' = [ `B | t ]]; | |
376 | ] | |
377 | in | |
378 | check_eq ~expected ~actual "deriving variant" | |
379 | ||
380 | let test_tree () = | |
381 | let expected = | |
382 | [ | |
383 | [%stri | |
384 | let rec gen_tree_sized gen_a n = | |
385 | match n with | |
386 | | 0 -> QCheck.Gen.pure Leaf | |
387 | | _ -> | |
388 | QCheck.Gen.frequency | |
389 | [ | |
390 | (1, QCheck.Gen.pure Leaf); | |
391 | ( 1, | |
392 | QCheck.Gen.map | |
393 | (fun (gen0, gen1, gen2) -> Node (gen0, gen1, gen2)) | |
394 | (QCheck.Gen.triple | |
395 | gen_a | |
396 | ((gen_tree_sized gen_a) (n / 2)) | |
397 | ((gen_tree_sized gen_a) (n / 2))) ); | |
398 | ] | |
399 | ]; | |
400 | [%stri | |
401 | let gen_tree gen_a = QCheck.Gen.sized @@ (gen_tree_sized gen_a) | |
402 | ]; | |
403 | ] | |
404 | in | |
405 | let actual = | |
406 | f | |
407 | @@ extract [%stri type 'a tree = Leaf | Node of 'a * 'a tree * 'a tree]; | |
408 | in | |
409 | check_eq ~expected ~actual "deriving tree" | |
410 | ||
411 | let test_expr () = | |
412 | let expected = | |
413 | [ | |
414 | [%stri | |
415 | let rec gen_expr_sized n = | |
416 | match n with | |
417 | | 0 -> QCheck.Gen.map (fun gen0 -> Value gen0) QCheck.Gen.int | |
418 | | _ -> | |
419 | QCheck.Gen.frequency | |
420 | [ | |
421 | ( 1, | |
422 | QCheck.Gen.map (fun gen0 -> Value gen0) QCheck.Gen.int | |
423 | ); | |
424 | ( 1, | |
425 | QCheck.Gen.map | |
426 | (fun (gen0, gen1, gen2) -> If (gen0, gen1, gen2)) | |
427 | (QCheck.Gen.triple | |
428 | (gen_expr_sized (n / 2)) | |
429 | (gen_expr_sized (n / 2)) | |
430 | (gen_expr_sized (n / 2))) ); | |
431 | ( 1, | |
432 | QCheck.Gen.map | |
433 | (fun (gen0, gen1) -> Eq (gen0, gen1)) | |
434 | (QCheck.Gen.pair (gen_expr_sized (n / 2)) (gen_expr_sized (n / 2))) ); | |
435 | ( 1, | |
436 | QCheck.Gen.map | |
437 | (fun (gen0, gen1) -> Lt (gen0, gen1)) | |
438 | (QCheck.Gen.pair (gen_expr_sized (n / 2)) (gen_expr_sized (n / 2))) ); | |
439 | ] | |
440 | ]; | |
441 | [%stri | |
442 | let gen_expr = QCheck.Gen.sized @@ gen_expr_sized | |
443 | ] | |
444 | ] | |
445 | in | |
446 | let actual = | |
447 | f @@ extract | |
448 | [%stri | |
449 | type expr = | |
450 | | Value of int | |
451 | | If of expr * expr * expr | |
452 | | Eq of expr * expr | |
453 | | Lt of expr * expr] | |
454 | in | |
455 | check_eq ~expected ~actual "deriving expr" | |
456 | ||
457 | let test_forest () = | |
458 | let expected = | |
459 | [ | |
460 | [%stri | |
461 | let rec gen_tree_sized gen_a n = | |
462 | QCheck.Gen.map | |
463 | (fun gen0 -> Node gen0) | |
464 | (QCheck.Gen.map | |
465 | (fun (gen0, gen1) -> (gen0, gen1)) | |
466 | (QCheck.Gen.pair gen_a ((gen_forest_sized gen_a) (n / 2)))) | |
467 | ||
468 | and gen_forest_sized gen_a n = | |
469 | match n with | |
470 | | 0 -> QCheck.Gen.pure Nil | |
471 | | _ -> | |
472 | QCheck.Gen.frequency | |
473 | [ | |
474 | (1, QCheck.Gen.pure Nil); | |
475 | ( 1, | |
476 | QCheck.Gen.map | |
477 | (fun gen0 -> Cons gen0) | |
478 | (QCheck.Gen.map | |
479 | (fun (gen0, gen1) -> (gen0, gen1)) | |
480 | (QCheck.Gen.pair | |
481 | ((gen_tree_sized gen_a) (n / 2)) | |
482 | ((gen_forest_sized gen_a) (n / 2)))) ); | |
483 | ] | |
484 | ]; | |
485 | [%stri let gen_tree gen_a = QCheck.Gen.sized @@ (gen_tree_sized gen_a)]; | |
486 | [%stri let gen_forest gen_a = QCheck.Gen.sized @@ (gen_forest_sized gen_a)]; | |
487 | ] | |
488 | in | |
489 | let actual = | |
490 | f | |
491 | @@ extract | |
492 | [%stri | |
493 | type 'a tree = Node of ('a * 'a forest) | |
494 | ||
495 | and 'a forest = Nil | Cons of ('a tree * 'a forest)] | |
496 | in | |
497 | check_eq ~expected ~actual "deriving forest" | |
498 | ||
499 | let test_fun_primitives () = | |
500 | let expected = | |
501 | [ | |
502 | [%stri | |
503 | let gen = | |
504 | QCheck.fun_nary | |
505 | QCheck.Tuple.( | |
506 | QCheck.Observable.int @-> QCheck.Observable.int @-> o_nil) | |
507 | (QCheck.make QCheck.Gen.string) | |
508 | |> QCheck.gen]; | |
509 | [%stri | |
510 | let gen = | |
511 | QCheck.fun_nary | |
512 | QCheck.Tuple.( | |
513 | QCheck.Observable.float @-> QCheck.Observable.float @-> o_nil) | |
514 | (QCheck.make QCheck.Gen.string) | |
515 | |> QCheck.gen]; | |
516 | [%stri | |
517 | let gen = | |
518 | QCheck.fun_nary | |
519 | QCheck.Tuple.( | |
520 | QCheck.Observable.string @-> QCheck.Observable.string @-> o_nil) | |
521 | (QCheck.make QCheck.Gen.string) | |
522 | |> QCheck.gen]; | |
523 | [%stri | |
524 | let gen = | |
525 | QCheck.fun_nary | |
526 | QCheck.Tuple.( | |
527 | QCheck.Observable.bool @-> QCheck.Observable.bool @-> o_nil) | |
528 | (QCheck.make QCheck.Gen.string) | |
529 | |> QCheck.gen]; | |
530 | [%stri | |
531 | let gen = | |
532 | QCheck.fun_nary | |
533 | QCheck.Tuple.( | |
534 | QCheck.Observable.char @-> QCheck.Observable.char @-> o_nil) | |
535 | (QCheck.make QCheck.Gen.string) | |
536 | |> QCheck.gen]; | |
537 | [%stri | |
538 | let gen = | |
539 | QCheck.fun_nary | |
540 | QCheck.Tuple.(QCheck.Observable.unit @-> o_nil) | |
541 | (QCheck.make QCheck.Gen.string) | |
542 | |> QCheck.gen]; | |
543 | ] | |
544 | in | |
545 | ||
546 | let actual = | |
547 | f' | |
548 | @@ extract' | |
549 | [ | |
550 | [%stri type t = int -> int -> string]; | |
551 | [%stri type t = float -> float -> string]; | |
552 | [%stri type t = string -> string -> string]; | |
553 | [%stri type t = bool -> bool -> string]; | |
554 | [%stri type t = char -> char -> string]; | |
555 | [%stri type t = unit -> string]; | |
556 | ] | |
557 | in | |
558 | check_eq ~expected ~actual "deriving fun primitives" | |
559 | ||
560 | let test_fun_n () = | |
561 | let expected = | |
562 | [ | |
563 | [%stri | |
564 | let gen = | |
565 | QCheck.fun_nary | |
566 | QCheck.Tuple.( | |
567 | QCheck.Observable.bool @-> QCheck.Observable.int | |
568 | @-> QCheck.Observable.float @-> QCheck.Observable.string | |
569 | @-> QCheck.Observable.char @-> o_nil) | |
570 | (QCheck.make QCheck.Gen.unit) | |
571 | |> QCheck.gen]; | |
572 | ] | |
573 | in | |
574 | let actual = | |
575 | f @@ extract [%stri type t = bool -> int -> float -> string -> char -> unit] | |
576 | in | |
577 | check_eq ~expected ~actual "deriving fun n" | |
578 | ||
579 | let test_fun_option () = | |
580 | let expected = | |
581 | [ | |
582 | [%stri | |
583 | let gen = | |
584 | QCheck.fun_nary | |
585 | QCheck.Tuple.( | |
586 | QCheck.Observable.option QCheck.Observable.int @-> o_nil) | |
587 | (QCheck.make QCheck.Gen.unit) | |
588 | |> QCheck.gen]; | |
589 | ] | |
590 | in | |
591 | let actual = f @@ extract [%stri type t = int option -> unit] in | |
592 | check_eq ~expected ~actual "deriving fun option" | |
593 | ||
594 | let test_fun_list () = | |
595 | let expected = | |
596 | [ | |
597 | [%stri | |
598 | let gen = | |
599 | QCheck.fun_nary | |
600 | QCheck.Tuple.( | |
601 | QCheck.Observable.list QCheck.Observable.int @-> o_nil) | |
602 | (QCheck.make QCheck.Gen.unit) | |
603 | |> QCheck.gen]; | |
604 | ] | |
605 | in | |
606 | let actual = f @@ extract [%stri type t = int list -> unit] in | |
607 | check_eq ~expected ~actual "deriving fun list" | |
608 | ||
609 | let test_fun_array () = | |
610 | let expected = | |
611 | [ | |
612 | [%stri | |
613 | let gen = | |
614 | QCheck.fun_nary | |
615 | QCheck.Tuple.( | |
616 | QCheck.Observable.array QCheck.Observable.int @-> o_nil) | |
617 | (QCheck.make QCheck.Gen.unit) | |
618 | |> QCheck.gen]; | |
619 | ] | |
620 | in | |
621 | let actual = f @@ extract [%stri type t = int array -> unit] in | |
622 | check_eq ~expected ~actual "deriving fun array" | |
623 | ||
624 | let test_fun_tuple () = | |
625 | let expected = | |
626 | [ | |
627 | [%stri | |
628 | let gen = | |
629 | QCheck.fun_nary | |
630 | QCheck.Tuple.( | |
631 | QCheck.Observable.pair QCheck.Observable.int QCheck.Observable.int | |
632 | @-> o_nil) | |
633 | (QCheck.make QCheck.Gen.unit) | |
634 | |> QCheck.gen]; | |
635 | [%stri | |
636 | let gen = | |
637 | QCheck.fun_nary | |
638 | QCheck.Tuple.( | |
639 | QCheck.Observable.triple | |
640 | QCheck.Observable.int | |
641 | QCheck.Observable.int | |
642 | QCheck.Observable.int | |
643 | @-> o_nil) | |
644 | (QCheck.make QCheck.Gen.unit) | |
645 | |> QCheck.gen]; | |
646 | [%stri | |
647 | let gen = | |
648 | QCheck.fun_nary | |
649 | QCheck.Tuple.( | |
650 | QCheck.Observable.quad | |
651 | QCheck.Observable.int | |
652 | QCheck.Observable.int | |
653 | QCheck.Observable.int | |
654 | QCheck.Observable.int | |
655 | @-> o_nil) | |
656 | (QCheck.make QCheck.Gen.unit) | |
657 | |> QCheck.gen]; | |
658 | ] | |
659 | in | |
660 | let actual = | |
661 | f' | |
662 | @@ extract' | |
663 | [ | |
664 | [%stri type t = int * int -> unit]; | |
665 | [%stri type t = int * int * int -> unit]; | |
666 | [%stri type t = int * int * int * int -> unit]; | |
667 | ] | |
668 | in | |
669 | check_eq ~expected ~actual "deriving fun tuple" | |
670 | ||
671 | let test_weight_konstrs () = | |
672 | let expected = | |
673 | [ | |
674 | [%stri | |
675 | let gen = | |
676 | QCheck.Gen.frequency | |
677 | [ | |
678 | (5, QCheck.Gen.pure A); | |
679 | (6, QCheck.Gen.pure B); | |
680 | (1, QCheck.Gen.pure C); | |
681 | ]]; | |
682 | ] | |
683 | in | |
684 | let actual = | |
685 | f @@ extract [%stri type t = A [@weight 5] | B [@weight 6] | C] | |
686 | in | |
687 | check_eq ~expected ~actual "deriving weight konstrs" | |
688 | ||
689 | (* Regression test: https://github.com/c-cube/qcheck/issues/187 *) | |
690 | let test_recursive_poly_variant () = | |
691 | let expected = | |
692 | [ | |
693 | [%stri | |
694 | let rec gen_tree_sized gen_a n = | |
695 | (match n with | |
696 | | 0 -> QCheck.Gen.map (fun gen0 -> `Leaf gen0) gen_a | |
697 | | _ -> | |
698 | QCheck.Gen.frequency | |
699 | [ | |
700 | ( 1, | |
701 | QCheck.Gen.map (fun gen0 -> `Leaf gen0) gen_a | |
702 | ); | |
703 | ( 1, | |
704 | QCheck.Gen.map | |
705 | (fun gen0 -> `Node gen0) | |
706 | (QCheck.Gen.map | |
707 | (fun (gen0, gen1) -> (gen0, gen1)) | |
708 | (QCheck.Gen.pair | |
709 | ((gen_tree_sized gen_a) (n / 2)) | |
710 | ((gen_tree_sized gen_a) (n / 2)))) | |
711 | ); | |
712 | ] | |
713 | : tree QCheck.Gen.t)]; | |
714 | [%stri | |
715 | let gen_tree gen_a = QCheck.Gen.sized @@ (gen_tree_sized gen_a) | |
716 | ] | |
717 | ] | |
718 | in | |
719 | let actual = | |
720 | f @@ extract [%stri type 'a tree = [ `Leaf of 'a | `Node of 'a tree * 'a tree ]] | |
721 | in | |
722 | check_eq ~expected ~actual "deriving recursive polymorphic variants" | |
723 | ||
724 | (* Regression test: https://github.com/c-cube/qcheck/issues/213 *) | |
725 | let test_unused_variable () = | |
726 | let expected = | |
727 | [ | |
728 | [%stri | |
729 | let rec gen_c_sized n = | |
730 | match n with | |
731 | | 0 -> QCheck.Gen.pure A | |
732 | | _ -> | |
733 | QCheck.Gen.frequency | |
734 | [(1, (QCheck.Gen.pure A)); | |
735 | (1, (QCheck.Gen.map (fun gen0 -> B gen0) gen_myint))] | |
736 | and gen_myint = QCheck.Gen.nat | |
737 | ]; | |
738 | [%stri | |
739 | let gen_c = QCheck.Gen.sized @@ gen_c_sized | |
740 | ]; | |
741 | [%stri | |
742 | let rec gen_c_sized _n = | |
743 | QCheck.Gen.frequency | |
744 | [(1, (QCheck.Gen.map (fun gen0 -> A gen0) gen_myint)); | |
745 | (1, (QCheck.Gen.map (fun gen0 -> B gen0) gen_myint))] | |
746 | and gen_myint = QCheck.Gen.nat | |
747 | ]; | |
748 | [%stri | |
749 | let gen_c = QCheck.Gen.sized @@ gen_c_sized | |
750 | ]; | |
751 | ] | |
752 | in | |
753 | let actual = | |
754 | f' @@ extract' [ | |
755 | [%stri | |
756 | type c = | |
757 | | A | |
758 | | B of myint | |
759 | and myint = int [@gen QCheck.Gen.nat] ]; | |
760 | [%stri | |
761 | type c = | |
762 | | A of myint | |
763 | | B of myint | |
764 | and myint = int [@gen QCheck.Gen.nat] ]; | |
765 | ] | |
766 | in | |
767 | check_eq ~expected ~actual "deriving variant with unused fuel parameter" | |
768 | ||
769 | ||
770 | let () = | |
771 | Alcotest.( | |
772 | run | |
773 | "ppx_deriving_qcheck tests" | |
774 | [ | |
775 | ( "deriving generator good", | |
776 | [ | |
777 | test_case "deriving int" `Quick test_int; | |
778 | test_case "deriving float" `Quick test_float; | |
779 | test_case "deriving char" `Quick test_char; | |
780 | test_case "deriving string" `Quick test_string; | |
781 | test_case "deriving unit" `Quick test_unit; | |
782 | test_case "deriving bool" `Quick test_bool; | |
783 | test_case "deriving int32" `Quick test_int32; | |
784 | test_case "deriving int32'" `Quick test_int32'; | |
785 | test_case "deriving int64" `Quick test_int64; | |
786 | test_case "deriving int64'" `Quick test_int64'; | |
787 | (* test_case "deriving bytes" `Quick test_bytes; *) | |
788 | test_case "deriving tuple" `Quick test_tuple; | |
789 | test_case "deriving option" `Quick test_option; | |
790 | test_case "deriving array" `Quick test_array; | |
791 | test_case "deriving list" `Quick test_list; | |
792 | test_case "deriving constructors" `Quick test_konstr; | |
793 | test_case "deriving dependencies" `Quick test_dependencies; | |
794 | test_case "deriving record" `Quick test_record; | |
795 | test_case "deriving equal" `Quick test_equal; | |
796 | test_case "deriving tree like" `Quick test_tree; | |
797 | test_case "deriving expr like" `Quick test_expr; | |
798 | test_case "deriving alpha" `Quick test_alpha; | |
799 | test_case "deriving variant" `Quick test_variant; | |
800 | test_case "deriving weight constructors" `Quick test_weight_konstrs; | |
801 | test_case "deriving forest" `Quick test_forest; | |
802 | test_case "deriving fun primitives" `Quick test_fun_primitives; | |
803 | test_case "deriving fun option" `Quick test_fun_option; | |
804 | test_case "deriving fun array" `Quick test_fun_array; | |
805 | test_case "deriving fun list" `Quick test_fun_list; | |
806 | test_case "deriving fun n" `Quick test_fun_n; | |
807 | test_case "deriving fun tuple" `Quick test_fun_tuple; | |
808 | test_case | |
809 | "deriving rec poly variants" | |
810 | `Quick | |
811 | test_recursive_poly_variant; | |
812 | test_case | |
813 | "deriving variant with unused fuel parameter" | |
814 | `Quick | |
815 | test_unused_variable; | |
816 | ] ); | |
817 | ]) |
0 | open QCheck | |
1 | ||
2 | type a = char [@gen QCheck.Gen.pure 'a'] | |
3 | [@@deriving qcheck] | |
4 | ||
5 | type b = char [@gen QCheck.Gen.pure 'b'] | |
6 | [@@deriving qcheck] | |
7 | ||
8 | type c = char [@gen QCheck.Gen.pure 'c'] | |
9 | [@@deriving qcheck] | |
10 | ||
11 | type d = char [@gen QCheck.Gen.pure 'd'] | |
12 | [@@deriving qcheck] | |
13 | ||
14 | type e = char [@gen QCheck.Gen.pure 'e'] | |
15 | [@@deriving qcheck] | |
16 | ||
17 | type f = char [@gen QCheck.Gen.pure 'f'] | |
18 | [@@deriving qcheck] | |
19 | ||
20 | type g = char [@gen QCheck.Gen.pure 'g'] | |
21 | [@@deriving qcheck] | |
22 | ||
23 | type h = char [@gen QCheck.Gen.pure 'h'] | |
24 | [@@deriving qcheck] | |
25 | ||
26 | type i = char [@gen QCheck.Gen.pure 'i'] | |
27 | [@@deriving qcheck] | |
28 | ||
29 | type tup2 = a * b | |
30 | [@@deriving qcheck] | |
31 | ||
32 | type tup3 = a * b * c | |
33 | [@@deriving qcheck] | |
34 | ||
35 | type tup4 = a * b * c * d | |
36 | [@@deriving qcheck] | |
37 | ||
38 | type tup5 = a * b * c * d * e | |
39 | [@@deriving qcheck] | |
40 | ||
41 | type tup6 = a * b * c * d * e * f | |
42 | [@@deriving qcheck] | |
43 | ||
44 | type tup7 = a * b * c * d * e * f * g | |
45 | [@@deriving qcheck] | |
46 | ||
47 | type tup8 = a * b * c * d * e * f * g * h | |
48 | [@@deriving qcheck] | |
49 | ||
50 | let test_tup2 = | |
51 | Test.make ~count:10 | |
52 | ~name:"forall x in ('a', 'b'): x = ('a', 'b')" | |
53 | (make gen_tup2) | |
54 | (fun x -> x = ('a', 'b')) | |
55 | ||
56 | let test_tup3 = | |
57 | Test.make ~count:10 | |
58 | ~name:"forall x in ('a', 'b', 'c'): x = ('a', 'b', 'c')" | |
59 | (make gen_tup3) | |
60 | (fun x -> x = ('a', 'b', 'c')) | |
61 | ||
62 | let test_tup4 = | |
63 | Test.make ~count:10 | |
64 | ~name:"forall x in ('a', 'b', 'c', 'd'): x = ('a', 'b', 'c', 'd')" | |
65 | (make gen_tup4) | |
66 | (fun x -> x = ('a', 'b', 'c', 'd')) | |
67 | ||
68 | let test_tup5 = | |
69 | Test.make ~count:10 | |
70 | ~name:"forall x in ('a', 'b', 'c', 'd', 'e'): x = ('a', 'b', 'c', 'd', 'e')" | |
71 | (make gen_tup5) | |
72 | (fun x -> x = ('a', 'b', 'c', 'd', 'e')) | |
73 | ||
74 | let test_tup6 = | |
75 | Test.make ~count:10 | |
76 | ~name:"forall x in ('a', 'b', 'c', 'd', 'e', 'f'): x = ('a', 'b', 'c', 'd', 'e', 'f')" | |
77 | (make gen_tup6) | |
78 | (fun x -> x = ('a', 'b', 'c', 'd', 'e', 'f')) | |
79 | ||
80 | let test_tup7 = | |
81 | Test.make ~count:10 | |
82 | ~name:"forall x in ('a', 'b', 'c', 'd', 'e', 'f', 'g'): x = ('a', 'b', 'c', 'd', 'e', 'f', 'g')" | |
83 | (make gen_tup7) | |
84 | (fun x -> x = ('a', 'b', 'c', 'd', 'e', 'f', 'g')) | |
85 | ||
86 | let test_tup8 = | |
87 | Test.make ~count:10 | |
88 | ~name:"forall x in ('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'): x = ('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h')" | |
89 | (make gen_tup8) | |
90 | (fun x -> x = ('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h')) | |
91 | ||
92 | let tests = [ | |
93 | test_tup2; | |
94 | test_tup3; | |
95 | test_tup4; | |
96 | test_tup5; | |
97 | test_tup6; | |
98 | test_tup7; | |
99 | test_tup8; | |
100 | ] | |
101 | ||
102 | let tests = List.map (QCheck_alcotest.to_alcotest) tests | |
103 | ||
104 | (** {2. Execute tests} *) | |
105 | let () = Alcotest.run "Test_Tuple" [("Tuple", tests)] |
0 | open QCheck | |
1 | open Helpers | |
2 | ||
3 | (** {1. Test variants and polymorphic variants derivation} *) | |
4 | ||
5 | (** {2. Variants} *) | |
6 | ||
7 | type colors = Red | Green | Blue [@@deriving qcheck] | |
8 | ||
9 | let pp_colors fmt x = | |
10 | let open Format in | |
11 | match x with | |
12 | | Red -> fprintf fmt "Red" | |
13 | | Green -> fprintf fmt "Green" | |
14 | | Blue -> fprintf fmt "Blue" | |
15 | ||
16 | let eq_colors = Alcotest.of_pp pp_colors | |
17 | ||
18 | let gen = Gen.oneofl [Red; Green; Blue] | |
19 | ||
20 | let test_variants () = | |
21 | test_compare ~msg:"Gen.oneofl <=> deriving variants" ~eq:eq_colors gen gen_colors | |
22 | ||
23 | type poly_colors = [`Red | `Green | `Blue] [@@deriving qcheck] | |
24 | ||
25 | let pp_poly_colors fmt x = | |
26 | let open Format in | |
27 | match x with | |
28 | | `Red -> fprintf fmt "`Red" | |
29 | | `Green -> fprintf fmt "`Green" | |
30 | | `Blue -> fprintf fmt "`Blue" | |
31 | ||
32 | let eq_poly_colors = Alcotest.of_pp pp_poly_colors | |
33 | ||
34 | let gen_poly : poly_colors Gen.t = Gen.oneofl [`Red; `Green; `Blue] | |
35 | ||
36 | let test_poly_variants () = | |
37 | test_compare ~msg:"Gen.oneofl <=> deriving variants" | |
38 | ~eq:eq_poly_colors gen_poly gen_poly_colors | |
39 | ||
40 | (** {2. Tests weight} *) | |
41 | ||
42 | type letters = | |
43 | | A [@weight 0] | |
44 | | B | |
45 | [@@deriving qcheck] | |
46 | ||
47 | let test_weight = | |
48 | Test.make ~name:"gen_letters always produces B" | |
49 | (make gen_letters) | |
50 | (function | |
51 | | A -> false | |
52 | | B -> true) | |
53 | |> | |
54 | QCheck_alcotest.to_alcotest | |
55 | ||
56 | type poly_letters = [ | |
57 | | `A [@weight 0] | |
58 | | `B | |
59 | ] | |
60 | [@@deriving qcheck] | |
61 | ||
62 | let test_weight_poly = | |
63 | Test.make ~name:"gen_poly_letters always produces B" | |
64 | (make gen_poly_letters) | |
65 | (function | |
66 | | `A -> false | |
67 | | `B -> true) | |
68 | |> | |
69 | QCheck_alcotest.to_alcotest | |
70 | ||
71 | (** {2. Execute tests} *) | |
72 | ||
73 | let () = Alcotest.run "Test_Variant" | |
74 | [("Variants", | |
75 | Alcotest.[ | |
76 | test_case "test_variants" `Quick test_variants; | |
77 | test_case "test_poly_variants" `Quick test_poly_variants; | |
78 | test_weight; | |
79 | test_weight_poly | |
80 | ])] |