pax_global_header00006660000000000000000000000064147741674420014532gustar00rootroot0000000000000052 comment=2a28b88c389fc311831c475087e59ab89b732d52 qcheck-0.25/000077500000000000000000000000001477416744200127165ustar00rootroot00000000000000qcheck-0.25/.github/000077500000000000000000000000001477416744200142565ustar00rootroot00000000000000qcheck-0.25/.github/dependabot.yml000066400000000000000000000001661477416744200171110ustar00rootroot00000000000000version: 2 updates: - package-ecosystem: "github-actions" directory: "/" schedule: interval: "weekly" qcheck-0.25/.github/workflows/000077500000000000000000000000001477416744200163135ustar00rootroot00000000000000qcheck-0.25/.github/workflows/check-asciidoc.yml000066400000000000000000000005161477416744200216710ustar00rootroot00000000000000name: build on: push: branches: - main pull_request: branches: - main jobs: run: name: Check asciidoc runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - run: | sudo apt-get update -y sudo apt-get install -y asciidoc-base - run: asciidoc README.adoc qcheck-0.25/.github/workflows/gh-pages.yml000066400000000000000000000016511477416744200205340ustar00rootroot00000000000000name: github pages on: push: branches: - master # Set a branch name to trigger deployment jobs: deploy: runs-on: ubuntu-latest steps: - uses: actions/checkout@main - name: Cache opam id: cache-opam uses: actions/cache@v4 with: path: ~/.opam key: opam-ubuntu-latest-4.12.0 - uses: avsm/setup-ocaml@v3 with: ocaml-version: '4.12.0' - name: Pin run: opam pin -n . - name: Depext run: opam depext -yt qcheck-ounit qcheck-core qcheck - name: Deps run: opam install -d . --deps-only - name: Build run: opam exec -- dune build @doc - name: Deploy uses: peaceiris/actions-gh-pages@v4 with: github_token: ${{ secrets.GITHUB_TOKEN }} publish_dir: ./_build/default/_doc/_html/ destination_dir: dev enable_jekyll: true qcheck-0.25/.github/workflows/main.yml000066400000000000000000000040041477416744200177600ustar00rootroot00000000000000name: build on: push: branches: - main pull_request: branches: - main jobs: run: name: Build strategy: fail-fast: false matrix: os: - macos-latest - ubuntu-latest - windows-latest ocaml-compiler: - "4.08" - "4.12" - "4.14" - "5.0" - "5.2" - "5.3" exclude: - os: macos-latest ocaml-compiler: "4.08" - os: windows-latest ocaml-compiler: "4.08" - os: windows-latest ocaml-compiler: "4.12" runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 - uses: ocaml/setup-ocaml@v3 with: ocaml-compiler: ${{ matrix.ocaml-compiler }} - run: opam update -y - run: opam install . --deps-only --with-test - run: opam exec -- dune build - run: opam exec -- dune runtest i386: strategy: fail-fast: false matrix: container-image: - ocaml/opam:debian-12-ocaml-4.14 - ocaml/opam:debian-12-ocaml-5.3 runs-on: ubuntu-latest container: image: ${{ matrix.container-image }} options: --platform linux/i386 steps: # GitHub insists on HOME=/github/home which clashes with the opam image setup - name: Setup, init, and update opam run: | sudo cp /usr/bin/opam-2.3 /usr/bin/opam cd /home/opam && HOME=/home/opam opam init -y git -C /home/opam/opam-repository pull origin master && HOME=/home/opam opam update -y - name: Checkout repository # See https://github.com/actions/checkout/issues/334 uses: actions/checkout@v1 - name: Setup repo and install dependencies run: | sudo chown -R opam:opam . HOME=/home/opam opam install . --deps-only --with-test - name: Build run: HOME=/home/opam opam exec -- dune build - name: Run the testsuite run: HOME=/home/opam opam exec -- dune runtest qcheck-0.25/.gitignore000066400000000000000000000001421477416744200147030ustar00rootroot00000000000000.*.swp .*.swo _build *.native .session TAGS *.docdir man *.install *.tar.gz *.byte .merlin _opam/ qcheck-0.25/.gitmodules000066400000000000000000000001241477416744200150700ustar00rootroot00000000000000[submodule "check-fun"] path = check-fun url = https://github.com/jmid/qcheck-fun qcheck-0.25/.header000066400000000000000000000002231477416744200141440ustar00rootroot00000000000000(* QCheck: Random testing for OCaml copyright (c) 2013-2017, Guillaume Bury, Simon Cruanes, Vincent Hugot, Jan Midtgaard all rights reserved. *) qcheck-0.25/.travis.yml000066400000000000000000000010671477416744200150330ustar00rootroot00000000000000language: c install: wget https://raw.githubusercontent.com/ocaml/ocaml-ci-scripts/master/.travis-docker.sh script: bash -ex .travis-docker.sh services: - docker env: global: - PINS="qcheck:. qcheck-core:. qcheck-ounit:. qcheck-alcotest:." - DISTRO="ubuntu-16.04" - PACKAGE="qcheck" - DEPOPTS="ounit alcotest" matrix: # OCAML_VERSION is used by https://github.com/ocaml/ocaml-ci-scripts/blob/master/README-travis.md - OCAML_VERSION="4.08" - OCAML_VERSION="4.09" - OCAML_VERSION="4.10" - OCAML_VERSION="4.11" - OCAML_VERSION="4.12" qcheck-0.25/AUTHORS000066400000000000000000000003211477416744200137620ustar00rootroot00000000000000Simon Cruanes Rudi Grinberg Jacques-Pascal Deplaix Jan Midtgaard Valentin Chaboche qcheck-0.25/CHANGELOG.md000066400000000000000000000350241477416744200145330ustar00rootroot00000000000000# Changes ## NEXT RELEASE - Restore `Test.make`'s `max_fail` parameter which was accidentally broken in 0.18 - Adjust `stats` computation of average and standard deviation to limit precision loss, print both using scientific notation, and workaround MinGW float printing to also pass expect tests - Fix dune snippets missing a language specifier in README.adoc causing `asciidoc` to error - Add a note to `QCheck{,2.Gen}.small_int_corners` and `QCheck{,2}.Gen.graft_corners` about internal state, and fix a range of documentation reference warnings - Reorganize and polish the `README`, rewrite it to use `qcheck-core`, and add a `QCheck2` integrated shrinking example - Document `QCHECK_MSG_INTERVAL` introduced in 0.20 - Add `QCheck{,2}.Gen.map{4,5}` combinators - [ppx_deriving_qcheck] Support `ppxlib.0.36.0` based on the OCaml 5.2 AST ## 0.24 - [qcheck-alcotest] Add an optional `speed_level` parameter to `to_alcotest` - Adjust the `QCheck2.Gen.list` shrinker to produce minimal counterexamples at size 3 too - Replace the `QCheck2` OCaml 4 `Random.State.split` hack with a faster one - Improve the `QCheck2.Gen.list` shrinker heuristic and utilize the improved shrinker in other `QCheck2` `{list,array,bytes,string,function}*` shrinkers - Use `split` and `copy` in `Random.State` underlying `QCheck2` to avoid non-deterministic shrinking behaviour - Add missing documentation strings for `QCheck.{Print,Iter,Shrink,Gen}` and `QCheck2.Gen`. - Add `result` combinators to `QCheck`, `QCheck.{Gen,Print,Shrink,Observable}`, and `QCheck2.{Gen,Print,Observable}`. - Add missing combinators `QCheck{,2}.Print.int{32,64}`, `QCheck.Gen.int{32,64}`, `QCheck{,2}.Observable.int{32,64}`, and deprecate `QCheck.Gen.{ui32,ui64}` - Document `dune` usage in README ## 0.23 - Quote and escape in `Print.string` and `Print.char` in the `QCheck` module, mirroring the `QCheck2.Print` module's behaviour. Also quote and escape `Print.bytes` in both `QCheck` and `QCheck2`. - Clean-up `QCheck` and `QCheck2` documentation pages - Add `exponential` generator to `QCheck`, `QCheck.Gen`, and `QCheck2.Gen` - Add `Shrink.bool` and use it in `QCheck.bool` - Remove unread `fun_gen` field from `QCheck2`'s `fun_repr_tbl` type thereby silencing a compiler warning ## 0.22 - Remove `QCheck2.TestResult.get_instances` as retaining previous test inputs cause memory leaks - Make `QCheck2.state.res` immutable, silencing a compilation warning ## 0.21.3 - Drop the dependency on `base-bytes` as it is provided in all supported versions of the OCaml compiler ## 0.21.2 - Reintroduce the `Shrink.list_spine` fix by catching `Invalid_argument` and falling back on an address comparison. - Fix #273 by lowering `ppx_deriving_qcheck`'s `qcheck` dependency to `qcheck-core` ## 0.21.1 - Roll back the `Shrink.list_spine` fix, as it was utilizing polymorphic equality that can raise an exception on function comparison. ## 0.21 - make `Test.check_result`, `Test.check_cell_exn`, and `Test.check_exn` honor test polarity by raising `Test_unexpected_success` when a negative test (expected to have a counter example), unexpectedly succeeds. - fix issue with `ppx_deriving_qcheck` deriving a generator with unbound `gen` for recursive types [#269](https://github.com/c-cube/qcheck/issues/269) and a related issue when deriving a generator for a record type - fix #241 causing `QCheck.Shrink.int*` to emit duplicates, also affecting `QCheck.Shrink.{char,string}` - fix a cornercase where `Shrink.list_spine` would emit duplicates ## 0.20 - add several new `bytes` combinators: - `{QCheck,QCheck2}.Gen.{bytes_size,bytes,bytes_of,bytes_printable,bytes_small,bytes_small_of}` - `QCheck.{Print,Shrink,Observable}.bytes` - `QCheck2.{Print,Shrink}.bytes` - `QCheck.{bytes_gen_of_size,bytes_of,bytes,bytes_small,bytes_small_of,bytes_of_size,bytes_printable}` - add new `string` combinators and aliases: - `{QCheck,QCheck2}.Gen.{string_small,string_small_of}` - `QCheck.{string_small,string_small_of,string_of,string_printable,string_printable_of_size,string_small_printable,string_numeral,string_numeral_of_size}` - (`QCheck2.small_string` character generator argument is no more optional - reverted again due to backwards incompatibility) - add an optional argument with conservative default to `Shrink.string` - 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) - add `QCheck2.Gen.set_shrink` to modify the generator's shrinker - add `QCheck2.Gen.no_shrink` to build a generator with no shrinking - add an environment variable `QCHECK_MSG_INTERVAL` to control `QCheck_base_runner.time_between_msg` - fix unknown option error message referring to `qtest` ## 0.19.1 - fix: allow `~count` in `Test.make` to be 0 - fix: allow `~long_factor` in `Test.make` to be 0 ## 0.19 - use `Float.equal` for comparing `float`s in the `Observable` module underlying function generators. - add optional `debug_shrink` parameters in alcotest interface and expose default `debug_shrinking_choices` in test runners - add missing `?handler` parameter to `Test.check_cell_exn` - remove `--no-buffer` option on `dune runtest` to avoid garbling the test output - add an option `retries` parameter to `Test.make` et al. for checking a property repeatedly while shrinking. This can be useful when testing non-deterministic code. [#212](https://github.com/c-cube/qcheck/pull/212) - add `tup2` to `tup9` for generators - add `Test.make_neg` for negative property-based tests, that are expected not to satisfy the tested property. - rename `Gen.opt` to `Gen.option` but keep the old binding for compatibility. - add additional expect and unit tests and refactor expect test suite - fix function generation affecting reproducability [#236](https://github.com/c-cube/qcheck/issues/236) - add a shrinker performance benchmark [#177](https://github.com/c-cube/qcheck/pull/177) - fix distribution of `QCheck2.printable` which would omit certain characters - shrinker changes - recursive list shrinker with better complexity - string shrinker reuses improved list shrinker and adds char shrinking - function shrinker now shrinks default entry first and benefits from list shrinker improvements - replacing the linear-time char shrinker with a faster one reusing the bisecting int shrinker algorithm - add `Shrink.char_numeral` and `Shrink.char_printable` - add shrinking for `char arbitrary`s `char`, `printable_char`, and `numeral_char` - documentation updates: - clarify upper bound inclusion in `Gen.int_bound` and `Gen.int_range` - clarify `printable_char` and `Gen.printable` distributions - add missing `string_gen_of_size` and `small_printable_string` documentation - document `QCheck_alcotest.to_alcotest` - fix documented size distribution for `arbitrary` generators `string_gen`, `string`, `printable_string`, `numeral_string`, `list`, and `array` - fix exception documentation for `check_result`, `check_cell_exn`, and `check_exn` - fix documentation for the distribution of `Gen.printable` and `printable_char` - fix documentation for the shrinking behaviour of `QCheck2.printable` - add environment variable `QCHECK_LONG_FACTOR` similar to `QCHECK_COUNT` [#220](https://github.com/c-cube/qcheck/pull/220) - make test suite run on 32-bit architectures ## 0.18.1 - fix `Gen.{nat,pos}_split{2,}` - fix stack overflow in #156 ## 0.18 This releases marks the addition of `QCheck2`, a module where generation and shrinking are better integrated. See [#109](https://github.com/c-cube/qcheck/pull/109) and [#116](https://github.com/c-cube/qcheck/pull/116). This API is still experimental. The normal `QCheck` module is still there and hasn't changed much. deprecations and breakges: - make `QCheck.Test_result.t` abstract and add missing getters - deprecate `QCheck.oneof` - deprecate `Gen.string_readable` in favor of `Gen.(string_of char)` or the new `Gen.string_printable` - require at least OCaml 4.08 other changes: - unsigned int32 and int64 - rename `small_int_corners` - add `?ratio` to `opt`, to modify random distribution of options ## 0.17 - new function: `Gen.delay` - install printer for an internal exception - fix(runner): use random state independently for each test - Fixes distribution and `min_int` issues - doc: point to @jmid 's website ## 0.16 - fix(runner): detect more failures in the runner - fix: catch exceptions in generators and log them. (#99) - test: add test for #99 - fix doc ## 0.15 - fix: in main runner, remove reset line in more places if `colors=false` - fix: invalid arg in `int_range` when a<0 - fix(runner): do not use ansi code for random seed if `colors=false` - feat: on `>=4.08`, provide let operators ## 0.14 - modify `int_range` to make it accept ranges bigger than `max_int`. - less newline-verbose stats - add `int{32,64}` shrinkers to arbitrary gens - add `int{32,int64}` shrinkers - move to ounit2 for `QCheck_ounit` ## 0.13 - make counter private - Add debug shrinking log - fix: small fix related to stdlib/pervasives - feat: add flatten combinators in `gen` ## 0.12 - fix singleton list shrinking - feat: add `Gen.char_range` and `Gen.(<$>)` (credit @spewspews) ## 0.11 - Add `QCheck.Gen.{string_of,string_readable}` - fix `int_bound` bound inclusiveness problem - change implementation of `int_bound` to generate values using `Random.State.int` for `bound < 2^30` - add weighted shuffled lists generator - add `float_range` to generate a floating-point number in the given range (inclusive) - add `float_bound_inclusive` and `float_bound_exclusive` to generate floating-point numbers between 0 and a given bound ## 0.10 - `Shrink`: decompose Shrink.list into Shrink.list_spine and Shrink.list_elems - `Gen.fix` has a more general and useful type - update README to include `Rely` section (qcheck now available for reason-native!) - Fix stat printing - speed-up list shrinker - Better int shrinking - core: modify proba distributions again, add `big_nat` - feat: add `small_array`, modify distributions - print number of warnings in runner's summary - refactor: modify type of results to make them more accurate - feat: warn/fail if too many tests passed only b/c precondition failed ## 0.9 - add `qcheck-ounit` sublibrary - use environment variables to configure `qcheck-alcotest` tests - alcotest backend for qcheck - make `qcheck.ounit` tests verbose by default - make `qcheck` is a compatibility library, depends on `qcheck-core` - split lib into `qcheck` and `qcheck.ounit` - add `TestResult.is_success` helper - give access to list of instances in test results - allow setting `time_between_msg` in runner - chore: remove submodule - chore: add travis support - doc: explanations about qcheck.ounit runners - doc: update readme ## 0.8 - migrate to jbuilder - fix warnings - add some useful functions - update oasis files (close #48) - update copyright header (closes #47) ## 0.7 - switch to BSD license, make it more explicit (close #43) - improve multi-line message printing in ounit (closes #46) - fix complexity of `add_stat` - allow negative entries in statistics (see #40) - add a way for tests to report messages to the user (see #39) - add `QCheck.Shrink.int_aggressive` and make default int shrinker faster - shrinker for `map_keep_input` - add `QCheck.set_gen`, missing for some reason - more compact verbose output (see #33) - better handling of dynamic progress line - Add colors to checkmarks in verbose mode - improve statistics display for runner - recover exception of shrunk input - print status line before the solving starts ## 0.6 - add `find_example` and `find_example_gen` to synthesize values from properties (see #31) - add `QCheck.gen` for accessing the random generator easily - colorful runners, with `--no-colors` to disable them - add more generator (for corner cases) - better generation of random functions (see #8), using `Observable` and an efficient internal representation using heterogeneous tuples, printing, and shrinking. deprecate old hacks. - add statistics gathering and display (see #30) - better printing of Tuple - improve `Shrink.{array,list}` (see #32) - Change asserts to raise `Invalid_arg` (following the doc), and update doc - Change `Gen.{int_bount,int_range}` to support up to 2^62 ## 0.5.3.1 - fix regression in runner output (print results of `collect`) - update the `@since` tags ## 0.5.3 - missing char in `Gen.char` (close #23) - add `test` and `doc` to opam - add `small_list` generator - add `~long_factor` to tests and runner, for long tests - add more examples in readme, better doc for runners - improved reporting when running qcheck tests - add `Test.get_count` on test cells ## 0.5.2 - Add cli option for backtraces in `QCheck_runner` - Add test case for raising exception - Better handling of backtraces - All tests now have a name - Add step function called on each instance in a test - make `small_int` a deprecated alias to `small_nat` - add `small_signed_int` - remove some warnings - use safe-string, and fix related bug - Add long tests options to `QCheck_runner` - Add `length` specification for `to_ounit2_test` - Added paragraph in README about long tests ## 0.5.1 - document exceptions - add `small_nat`, change `small_int` semantics (close #10) - add `QCheck.assume_fail` - add `QCheck.assume`; explain preconditions a bit (close #9) - Polish documentation - Added quad support uniformly ## 0.5 - merge back from `qtest`: big changes in API, shrinking, use `'a arbitrary` type that combines printer, generator, shrinker, etc. (see git log) - merlin file - reorganize sources, `_oasis`, `.merlin`, etc. ## 0.4 - bugfix in `fix_fuel` - if verbose enabled, print each test case - add `QCheck.run_main` - `QCheck_ounit.~::` - add `(>:::)` - add `qcheck_ounit ml{lib,dylib}` - trivial ounit integration - make `test_cell.name` optional - `Arbitrary.fix_fuel(_gen)`: add a recursive case - `Arbitrary.fix_fuel_gen`, similar to `fix_fuel` but threading a state bottom-up to make choices depend on the path - `Arbitrary.fail_fix` to fail in a fixpoint - helper cases for `Arbitrary.fix_fuel` ## 0.3 - get rid of submodule `generator` - `Arbitrary.fix_fuel`, to generate complex recursive structures - new combinators (infix map, applicative funs, shuffle) - remove generator/Generator, and a deprecation warning - output of printers of lists/arrays now parsable by ocaml toplevel ## 0.2 - integrate Gabriel Scherer's `Generator` into `QCheck` - add `|||` - add `Prop.raises` - print the faulty instance in case of error (if a printer is available) - some combinators for `QCheck.Arbitrary` - `QCheck.mk_test` takes more arguments ## 0.1 - oasis based build system - source files qcheck-0.25/LICENSE000066400000000000000000000024711477416744200137270ustar00rootroot00000000000000copyright (c) 2013-2017, Guillaume Bury, Simon Cruanes, Vincent Hugot, Jan Midtgaard All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. qcheck-0.25/Makefile000066400000000000000000000020671477416744200143630ustar00rootroot00000000000000 all: build test build: @dune build @install test: @dune runtest --force clean: @dune clean doc: @dune build @doc example-test: @dune exec example/ounit/QCheck_test.exe example-ounit-test: @dune exec example/ounit/QCheck_ounit_test.exe example-runner: @dune exec example/QCheck_runner_test.exe -- -v --debug-shrink=log.tmp example-alcotest: @dune exec example/alcotest/QCheck_alcotest_test.exe VERSION=$(shell awk '/^version:/ {print $$2}' qcheck.opam) update_next_tag: @echo "update version to $(VERSION)..." sed -i "s/NEXT_VERSION/$(VERSION)/g" `find src -name '*.ml' -or -name '*.mli'` sed -i "s/NEXT_RELEASE/$(VERSION)/g" `find src -name '*.ml' -or -name '*.mli'` release: update_next_tag @echo "release version $(VERSION)..." git tag -f $(VERSION) ; git push origin :$(VERSION) ; git push origin $(VERSION) opam publish https://github.com/c-cube/qcheck/archive/$(VERSION).tar.gz @echo "review the release, then type 'opam publish submit qcheck.$(VERSION)/'" watch: @dune build @all -w .PHONY: benchs test examples update_next_tag watch release qcheck-0.25/README.adoc000066400000000000000000000362221477416744200145100ustar00rootroot00000000000000= QCheck :toc: macro :toclevels: 4 :source-highlighter: pygments QuickCheck inspired property-based testing for OCaml. image::https://github.com/c-cube/qcheck/actions/workflows/main.yml/badge.svg[alt="build", link=https://github.com/c-cube/qcheck/actions/workflows/main.yml] == Overview `QCheck` consists of a collection of `opam` packages and extensions: - `qcheck-core` - provides the core property-based testing API and depends only on `unix` and `dune`. - `qcheck-ounit` - provides an integration layer for https://github.com/gildor478/ounit[`OUnit`] - `qcheck-alcotest` - provides an integration layer for https://github.com/mirage/alcotest[`alcotest`] - `qcheck` - provides a compatibility API with older versions of `qcheck`, using both `qcheck-core` and `qcheck-ounit`. - `ppx_deriving_qcheck` - provides a preprocessor to automatically derive generators In addition, the https://github.com/ocaml-multicore/multicoretests[`multicoretests`] repository offers - `qcheck-stm` - for running sequential and parallel model-based tests - `qcheck-lin` - for testing an API for sequential consistency - `qcheck-multicoretests-util` - a small library of utility extensions, such as properties with time outs To construct advanced random generators, the following libraries might also be of interest: - https://gitlab.inria.fr/fpottier/feat/[`feat`] - a library for functional enumeration and sampling of algebraic data types - https://github.com/gasche/random-generator/[`random-generator`] - a library experimenting with APIs for random generation Earlier `qcheck` spent some time in https://github.com/vincent-hugot/iTeML[qtest], but was since made standalone again. == Documentation The documentation for the 5 opam packages https://c-cube.github.io/qcheck/[is available here]. The section <> below offer a brief introduction to the library. These examples are based on an earlier https://cedeela.fr/quickcheck-for-ocaml[blog post by Simon] that also discusses some design choices; however, be warned that the API changed since then, so the blog post code will not work as is. Jan's http://janmidtgaard.dk/quickcheck/index.html[course material on FP and property-based testing] also offers an introduction to QCheck. The OCaml textbook from Cornell University also contains https://cs3110.github.io/textbook/chapters/correctness/randomized.html[a chapter about property-based testing with QCheck]. == Build and Install You can install QCheck via `opam`: $ opam install qcheck-core This provides a minimal installation without needless dependencies. Install the bigger `qcheck` package instead for compatibility with qcheck.0.8 and before: $ opam install qcheck To build the library from source $ make Normally, for contributors, `opam pin https://github.com/c-cube/qcheck` will pin the 5 opam packages from this repository. == License The code is now released under the BSD license. [[examples]] == An Introduction to the Library First, let's see a few tests. Let's open a toplevel (e.g. utop) and type the following to load QCheck: [source,OCaml] ---- #require "qcheck-core";; ---- NOTE: alternatively, it is now possible to locally do: `dune utop src` to load `qcheck`. === List Reverse is Involutive We write a random test for checking that `List.rev (List.rev l) = l` for any list `l`: [source,OCaml] ---- let test = QCheck.Test.make ~count:1000 ~name:"list_rev_is_involutive" QCheck.(list small_nat) (fun l -> List.rev (List.rev l) = l);; (* we can check right now the property... *) QCheck.Test.check_exn test;; ---- In the above example, we applied the combinator `list` to the random generator `small_nat` (ints between 0 and 100), to create a new generator of lists of random integers. These builtin generators come with printers and shrinkers which are handy for outputting and minimizing a counterexample when a test fails. Consider the buggy property `List.rev l = l`: [source,OCaml] ---- let test = QCheck.Test.make ~count:1000 ~name:"my_buggy_test" QCheck.(list small_nat) (fun l -> List.rev l = l);; ---- When we run this test we are presented with a counterexample: [source,OCaml] ---- # QCheck.Test.check_exn test;; Exception: test `my_buggy_test` failed on ≥ 1 cases: [0; 1] (after 11 shrink steps) ---- In this case QCheck found the minimal counterexample `[0;1]` to the property `List.rev l = l` and it spent 11 steps shrinking it. Now, let's run the buggy test with a decent runner that will print the results nicely (the exact output will change at each run, because of the random seed): ---- # #require "qcheck-core.runner";; # QCheck_base_runner.run_tests [test];; random seed: 452768242 --- Failure -------------------------------------------------------------------- Test my_buggy_test failed (14 shrink steps): [0; 1] ================================================================================ failure (1 tests failed, 0 tests errored, ran 1 tests) - : int = 1 ---- For an even nicer output `QCheck_base_runner.run_tests` also accepts an optional parameter `~verbose:true`. === Mirrors and Trees `QCheck` provides many useful combinators to write generators, especially for recursive types, algebraic types, and tuples. Let's see how to generate random trees: [source,OCaml] ---- type tree = Leaf of int | Node of tree * tree let leaf x = Leaf x let node x y = Node (x,y) let tree_gen = QCheck.Gen.(sized @@ fix (fun self n -> match n with | 0 -> map leaf nat | n -> frequency [1, map leaf nat; 2, map2 node (self (n/2)) (self (n/2))] ));; (* generate a few trees, just to check what they look like: *) QCheck.Gen.generate ~n:20 tree_gen;; let arbitrary_tree = let open QCheck.Iter in let rec print_tree = function | Leaf i -> "Leaf " ^ (string_of_int i) | Node (a,b) -> "Node (" ^ (print_tree a) ^ "," ^ (print_tree b) ^ ")" in let rec shrink_tree = function | Leaf i -> QCheck.Shrink.int i >|= leaf | Node (a,b) -> of_list [a;b] <+> (shrink_tree a >|= fun a' -> node a' b) <+> (shrink_tree b >|= fun b' -> node a b') in QCheck.make tree_gen ~print:print_tree ~shrink:shrink_tree;; ---- Here we write a generator of random trees, `tree_gen`, using the `fix` combinator. `fix` is *sized* (it is a function from `int` to a random generator; in particular for size 0 it returns only leaves). The `sized` combinator first generates a random size, and then applies its argument to this size. Other combinators include monadic abstraction, lifting functions, generation of lists, arrays, and a choice function. Then, we define `arbitrary_tree`, a `tree QCheck.arbitrary` value, which contains everything needed for testing on trees: - a random generator (mandatory), weighted with `frequency` to increase the chance of generating deep trees - a printer (optional), very useful for printing counterexamples - a *shrinker* (optional), very useful for trying to reduce big counterexamples to small counterexamples that are usually more easy to understand. The above shrinker strategy is to - reduce the integer leaves, and - substitute an internal `Node` with either of its subtrees or by splicing in a recursively shrunk subtree. A range of combinators in `QCheck.Shrink` and `QCheck.Iter` are available for building shrinking functions. We can write a failing test using this generator to see the printer and shrinker in action: [source,OCaml] ---- let rec mirror_tree (t:tree) : tree = match t with | Leaf _ -> t | Node (a,b) -> node (mirror_tree b) (mirror_tree a);; let test_buggy = QCheck.Test.make ~name:"buggy_mirror" ~count:200 arbitrary_tree (fun t -> t = mirror_tree t);; QCheck_base_runner.run_tests [test_buggy];; ---- This test fails with: [source,OCaml] ---- --- Failure -------------------------------------------------------------------- Test mirror_buggy failed (6 shrink steps): Node (Leaf 0,Leaf 1) ================================================================================ failure (1 tests failed, 0 tests errored, ran 1 tests) - : int = 1 ---- With the (new found) understanding that mirroring a tree changes its structure, we can formulate another property that involves sequentializing its elements in a traversal: [source,OCaml] ---- let tree_infix (t:tree): int list = let rec aux acc t = match t with | Leaf i -> i :: acc | Node (a,b) -> aux (aux acc b) a in aux [] t;; let test_mirror = QCheck.Test.make ~name:"mirror_tree" ~count:200 arbitrary_tree (fun t -> List.rev (tree_infix t) = tree_infix (mirror_tree t));; QCheck_base_runner.run_tests [test_mirror];; ---- === Integrated shrinking with `QCheck2` You may have noticed the `shrink_tree` function above to reduce tree counterexamples. With the newer `QCheck2` module, this is not needed as shrinking is built into its generators. For example, we can rewrite the above tree generator to `QCheck2` by just changing the `QCheck` occurrences to `QCheck2`: [source,OCaml] ---- type tree = Leaf of int | Node of tree * tree let leaf x = Leaf x let node x y = Node (x,y) let tree_gen = QCheck2.Gen.(sized @@ fix (fun self n -> match n with | 0 -> map leaf nat | n -> frequency [1, map leaf nat; 2, map2 node (self (n/2)) (self (n/2))] ));; (* generate a few trees with QCheck2, just to check what they look like: *) QCheck2.Gen.generate ~n:20 tree_gen;; ---- `QCheck2.Test.make` has a slightly different API than `QCheck.Test.make`, in that it accepts an optional `~print` argument and consumes generators directly built with `QCheck2.Gen`: [source,OCaml] ---- let rec print_tree = function | Leaf i -> "Leaf " ^ (string_of_int i) | Node (a,b) -> "Node (" ^ (print_tree a) ^ "," ^ (print_tree b) ^ ")";; let rec mirror_tree (t:tree) : tree = match t with | Leaf _ -> t | Node (a,b) -> node (mirror_tree b) (mirror_tree a);; let test_buggy = QCheck2.Test.make ~name:"buggy_mirror" ~count:200 ~print:print_tree tree_gen (fun t -> t = mirror_tree t);; QCheck_base_runner.run_tests [test_buggy];; ---- === Preconditions The functions `QCheck.assume` and `QCheck.(==>)` can be used for tests with preconditions. For instance, `List.hd l :: List.tl l = l` only holds for non-empty lists. Without the precondition, the property is false and will even raise an exception in some cases. [source,OCaml] ---- let test_hd_tl = QCheck.(Test.make (list int) (fun l -> assume (l <> []); l = List.hd l :: List.tl l));; QCheck_base_runner.run_tests [test_hd_tl];; ---- By including a precondition QCheck will only run a property on input satisfying `assume`'s condition, potentially generating extra test inputs. === Long tests It is often useful to have two version of a testsuite: a short one that runs reasonably fast (so that it is effectively run each time a project is built), and a long one that might be more exhaustive (but whose running time makes it impossible to run at each build). To that end, each test has a 'long' version. In the long version of a test, the number of tests to run is multiplied by the `~long_factor` argument of `QCheck.Test.make`. === Runners The module `QCheck_base_runner` defines several functions to run tests. The easiest one is probably `run_tests`, but if you write your tests in a separate executable you can also use `run_tests_main` which parses command line arguments and exits with `0` in case of success, or an error number otherwise. The module `QCheck_runner` from the `qcheck` opam package is similar, and includes compatibility with `OUnit`. === Integration within OUnit https://github.com/gildor478/ounit[OUnit] is a popular unit-testing framework for OCaml. QCheck provides a sub-library `qcheck-ounit` with some helpers, in `QCheck_ounit`, to convert its random tests into OUnit tests that can be part of a wider test-suite. [source,OCaml] ---- let passing = QCheck.Test.make ~count:1000 ~name:"list_rev_is_involutive" QCheck.(list small_nat) (fun l -> List.rev (List.rev l) = l);; let failing = QCheck.Test.make ~count:10 ~name:"fail_sort_id" QCheck.(list small_nat) (fun l -> l = List.sort compare l);; let _ = let open OUnit in run_test_tt_main ("tests" >::: List.map QCheck_ounit.to_ounit_test [passing; failing]) ---- === Integration within alcotest https://github.com/mirage/alcotest/[Alcotest] is a simple and colorful test framework for OCaml. QCheck now provides a sub-library `qcheck-alcotest` to easily integrate into an alcotest test suite: [source,OCaml] ---- let passing = QCheck.Test.make ~count:1000 ~name:"list_rev_is_involutive" QCheck.(list small_int) (fun l -> List.rev (List.rev l) = l);; let failing = QCheck.Test.make ~count:10 ~name:"fail_sort_id" QCheck.(list small_int) (fun l -> l = List.sort compare l);; let () = let suite = List.map QCheck_alcotest.to_alcotest [ passing; failing] in Alcotest.run "my test" [ "suite", suite ] ---- === Integration within Rely https://reason-native.com/docs/rely/[Rely] is a Jest-inspire native reason testing framework. @reason-native/qcheck-rely is available via NPM and provides matchers for the easy use of qCheck within Rely. [source, Reason] ---- open TestFramework; open QCheckRely; let {describe} = extendDescribe(QCheckRely.Matchers.matchers); describe("qcheck-rely", ({test}) => { test("passing test", ({expect}) => { let passing = QCheck.Test.make( ~count=1000, ~name="list_rev_is_involutive", QCheck.(list(small_int)), l => List.rev(List.rev(l)) == l ); expect.ext.qCheckTest(passing); (); }); test("failing test", ({expect}) => { let failing = QCheck.Test.make( ~count=10, ~name="fail_sort_id", QCheck.(list(small_int)), l => l == List.sort(compare, l) ); expect.ext.qCheckTest(failing); (); }); }); ---- === Deriving generators The `ppx_deriving_qcheck` opam package provides a ppx_deriver to derive QCheck generators from a type declaration: [source,OCaml] ---- type tree = Leaf of int | Node of tree * tree [@@deriving qcheck] ---- See the according https://github.com/c-cube/qcheck/tree/master/src/ppx_deriving_qcheck/[README] for more information and examples. === Usage from dune We can use the buggy test from above using the `qcheck-core` opam package: [source,OCaml] ---- (* test.ml *) let test = QCheck.Test.make ~count:1000 ~name:"my_buggy_test" QCheck.(list small_nat) (fun l -> List.rev l = l) let _ = QCheck_base_runner.run_tests_main [test] ---- with the following `dune` file (note the `qcheck-core.runner` sub-package): [source,lisp] ---- (test (name test) (modules test) (libraries qcheck-core qcheck-core.runner) ) ---- and run it with `dune exec ./test.exe` or `dune runtest`. We recommend using the `qcheck-core` package as it has a minimal set of dependencies and also avoids problems with using `(implicit_transitive_deps false)` in dune. To instead use the `qcheck` opam package and its included `QCheck_runner`: [source,OCaml] ---- (* test.ml *) let test = QCheck.Test.make ~count:1000 ~name:"my_buggy_test" QCheck.(list small_nat) (fun l -> List.rev l = l) let _ = QCheck_runner.run_tests_main [test] ---- with the following `dune` file: [source,lisp] ---- (test (name test) (modules test) (libraries qcheck) ) ---- qcheck-0.25/doc/000077500000000000000000000000001477416744200134635ustar00rootroot00000000000000qcheck-0.25/doc/qcheck-core/000077500000000000000000000000001477416744200156475ustar00rootroot00000000000000qcheck-0.25/doc/qcheck-core/dune000066400000000000000000000000741477416744200165260ustar00rootroot00000000000000(documentation (package qcheck-core) (mld_files index)) qcheck-0.25/doc/qcheck-core/index.mld000066400000000000000000000022201477416744200174500ustar00rootroot00000000000000{0 qcheck-core} The [qcheck-core] opam package contains two libraries: - The [qcheck-core] library for defining property-based tests - The [qcheck-core.runner] library for running property-based tests {1 The [qcheck-core] library} The [qcheck-core] library exposes two toplevel modules: - {!QCheck} is the initial property-based-testing module and - {!QCheck2} is a newer property-based-testing module supporting integrated shrinking Of the two, {!QCheck} is the most battle-tested module. {!QCheck2} on the other hand offers integrated shrinking, thus removing the need for having to hand-write shrinkers. {!QCheck} tests can be ported to {!QCheck2} by following the {{!QCheck2.migration_qcheck2}migration guide}. Please file an issue if you encounter problems using either of the two modules. {1 The [qcheck-core.runner] library} The entry point of the [qcheck-core.runner] library is the {!QCheck_base_runner} module. One can run a list of property-based tests by calling either - {!QCheck_base_runner.run_tests}, which accepts a number of optional arguments, or - {!QCheck_base_runner.run_tests_main}, which can be controlled via command-line arguments qcheck-0.25/doc/qcheck/000077500000000000000000000000001477416744200147215ustar00rootroot00000000000000qcheck-0.25/doc/qcheck/dune000066400000000000000000000000671477416744200156020ustar00rootroot00000000000000(documentation (package qcheck) (mld_files index)) qcheck-0.25/doc/qcheck/index.mld000066400000000000000000000006511477416744200165300ustar00rootroot00000000000000 {1 QCheck compatibility package} This library is there to ensure compatibility with QCheck 0.8 and earlier. It has a unique module {!QCheck_runner} that merges the custom runners from [qcheck-core.runner] ({!QCheck_base_runner}) and the OUnit runners from [qcheck-ounit] ({!QCheck_ounit}) into a single module. By depending on [qcheck-core], this library also brings {!QCheck} in scope, so it can be used transparently. qcheck-0.25/dune-project000066400000000000000000000000361477416744200152370ustar00rootroot00000000000000(lang dune 2.2) (name qcheck) qcheck-0.25/example/000077500000000000000000000000001477416744200143515ustar00rootroot00000000000000qcheck-0.25/example/QCheck_runner_test.expected.ocaml4.32000066400000000000000000000450301477416744200232650ustar00rootroot00000000000000random seed: 1234 --- Failure -------------------------------------------------------------------- Test should_fail_sort_id failed (13 shrink steps): [1; 0] === Error ====================================================================== Test should_error_raise_exn errored on (31 shrink steps): 0 exception Dune__exe__QCheck_runner_test.Error +++ Collect ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Collect results for test collect_results: 4: 20 cases 3: 25 cases 2: 17 cases 1: 18 cases 0: 20 cases +++ Stats for with_stats ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats mod4: num: 100, avg: 1.68, stddev: 1.09, median 2, min 0, max 3 0: ############################## 17 1: ################################################### 29 2: ######################################## 23 3: ####################################################### 31 stats num: num: 100, avg: 66.84, stddev: 31.94, median 65, min 2, max 120 2.. 7: ################## 3 8.. 13: ################## 3 14.. 19: 0 20.. 25: ########################################## 7 26.. 31: ######################## 4 32.. 37: ######################## 4 38.. 43: ################## 3 44.. 49: ################################################ 8 50.. 55: #################################### 6 56.. 61: #################################### 6 62.. 67: ####################################################### 9 68.. 73: ########################################## 7 74.. 79: ######################## 4 80.. 85: ################## 3 86.. 91: ############ 2 92.. 97: ########################################## 7 98..103: #################################### 6 104..109: #################################### 6 110..115: ####################################################### 9 116..121: ################## 3 --- Failure -------------------------------------------------------------------- Test neg test unexpected success failed: Negative test neg test unexpected success succeeded but was expected to fail === Error ====================================================================== Test neg fail with error errored on (7 shrink steps): 0 exception Dune__exe__QCheck_runner_test.Error --- Failure -------------------------------------------------------------------- Test FAIL_pred_map_commute failed (48 shrink steps): ([1], {_ -> 0}, {1 -> true; _ -> false}) --- Failure -------------------------------------------------------------------- Test FAIL_fun2_pred_strings failed (2 shrink steps): {"some random string" -> true; _ -> false} --- Failure -------------------------------------------------------------------- Test fold_left fold_right failed (34 shrink steps): (0, [1], {(1, 0) -> 1; _ -> 0}) +++ Messages ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Messages for test fold_left fold_right: l=[1], fold_left=1, fold_right=0 --- Failure -------------------------------------------------------------------- Test fold_left fold_right uncurried failed (44 shrink steps): ({(0, 7) -> 1; _ -> 0}, 0, [7]) --- Failure -------------------------------------------------------------------- Test long_shrink failed (87 shrink steps): ([0], [-1]) --- Failure -------------------------------------------------------------------- Test mod3_should_fail failed (34 shrink steps): -21 +++ Stats for stats_neg ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 5000, avg: 0.17, stddev: 29.68, median 0, min -99, max 99 -99..-90: # 65 -89..-80: # 63 -79..-70: # 64 -69..-60: # 58 -59..-50: # 67 -49..-40: # 72 -39..-30: # 61 -29..-20: # 61 -19..-10: # 67 -9.. 0: ####################################################### 2076 1.. 10: ############################################## 1764 11.. 20: # 66 21.. 30: # 64 31.. 40: # 64 41.. 50: # 67 51.. 60: # 60 61.. 70: # 75 71.. 80: # 60 81.. 90: # 60 91..100: # 66 !!! Warning !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Warning for test WARN_unlikely_precond: WARNING: only 0.6% tests (of 2000) passed precondition for "WARN_unlikely_precond" NOTE: it is likely that the precondition is too strong, or that the generator is buggy. --- Failure -------------------------------------------------------------------- Test FAIL_unlikely_precond failed: ERROR: only 0.6% tests (of 2000) passed precondition for "FAIL_unlikely_precond" NOTE: it is likely that the precondition is too strong, or that the generator is buggy. --- Failure -------------------------------------------------------------------- Test FAIL_#99_1 failed: ERROR: uncaught exception in generator for test FAIL_#99_1 after 100 steps: Exception: QCheck.No_example_found("") Backtrace: +++ Stats for stat_display_test_1 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 0.90, stddev: 28.23, median 0, min -99, max 99 -99..-90: # 12 -89..-80: # 11 -79..-70: # 9 -69..-60: 6 -59..-50: # 11 -49..-40: # 13 -39..-30: # 9 -29..-20: # 13 -19..-10: 8 -9.. 0: ####################################################### 453 1.. 10: ######################################### 340 11.. 20: # 15 21.. 30: # 11 31.. 40: # 12 41.. 50: # 13 51.. 60: # 13 61.. 70: # 16 71.. 80: # 9 81.. 90: # 16 91..100: # 10 +++ Stats for stat_display_test_2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 15.11, stddev: 23.27, median 6, min 0, max 99 0.. 4: #################################################### 377 5.. 9: ####################################################### 392 10.. 14: ## 20 15.. 19: ## 15 20.. 24: # 11 25.. 29: ## 17 30.. 34: ## 19 35.. 39: ## 17 40.. 44: # 10 45.. 49: # 9 50.. 54: # 8 55.. 59: # 9 60.. 64: ## 15 65.. 69: # 10 70.. 74: # 13 75.. 79: ## 19 80.. 84: # 11 85.. 89: # 13 90.. 94: 5 95.. 99: # 10 +++ Stats for stat_display_test_3 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 195335.64, stddev: 136803.99, median 195583, min -43624, max 435210 -43624..-19683: ############################################ 52 -19682.. 4259: ######################################## 47 4260.. 28201: ############################## 36 28202.. 52143: ############################################ 52 52144.. 76085: ########################################## 50 76086..100027: ####################################################### 64 100028..123969: ############################################### 55 123970..147911: ######################################## 47 147912..171853: ############################################## 54 171854..195795: #################################### 43 195796..219737: ############################################## 54 219738..243679: ########################################### 51 243680..267621: ################################################ 57 267622..291563: ########################################## 49 291564..315505: #################################### 42 315506..339447: ###################################### 45 339448..363389: ################################################ 57 363390..387331: ###################################### 45 387332..411273: ########################################## 49 411274..435215: ########################################### 51 +++ Stats for stat_display_test_4 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: -173.78, stddev: 23042.92, median 180, min -39859, max 39942 -39859..-35869: ############################################# 56 -35868..-31878: ################################### 43 -31877..-27887: ################################################# 60 -27886..-23896: ##################################### 46 -23895..-19905: ######################################## 49 -19904..-15914: #################################### 45 -15913..-11923: ############################################ 54 -11922.. -7932: ############################################### 58 -7931.. -3941: ######################################### 51 -3940.. 50: ############################ 35 51.. 4041: ####################################### 48 4042.. 8032: ########################################## 52 8033.. 12023: ######################################### 51 12024.. 16014: ########################################### 53 16015.. 20005: ############################################ 54 20006.. 23996: ################################## 42 23997.. 27987: ####################################################### 67 27988.. 31978: ################################ 40 31979.. 35969: ######################################### 51 35970.. 39960: #################################### 45 +++ Stats for stat_display_test_5 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 0.02, stddev: 2.55, median 0, min -4, max 4 -4: ############################################ 99 -3: ##################################################### 118 -2: ################################################## 111 -1: ################################################## 113 0: ################################################## 113 1: ##################################################### 118 2: ############################################# 102 3: ####################################################### 122 4: ############################################## 104 +++ Stats for stat_display_test_6 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 6.67, stddev: 6.39, median 7, min -4, max 17 -4..-3: ############################################# 90 -2..-1: ############################################# 91 0.. 1: ########################################## 84 2.. 3: ############################################## 92 4.. 5: ########################################### 87 6.. 7: ########################################### 86 8.. 9: ############################################ 89 10..11: ########################################### 87 12..13: ####################################################### 110 14..15: ############################################# 91 16..17: ############################################## 93 18..19: 0 20..21: 0 22..23: 0 24..25: 0 26..27: 0 28..29: 0 30..31: 0 32..33: 0 34..35: 0 +++ Stats for stat_display_test_7 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 100000, avg: 336840.90, stddev: 6.193e+8, median 895228, min -1073728193, max 1073739280 -1073728193.. -966354820: ##################################################### 5009 -966354819.. -858981446: #################################################### 5004 -858981445.. -751608072: #################################################### 4917 -751608071.. -644234698: ##################################################### 5028 -644234697.. -536861324: #################################################### 4962 -536861323.. -429487950: ##################################################### 5039 -429487949.. -322114576: #################################################### 4927 -322114575.. -214741202: ##################################################### 5054 -214741201.. -107367828: ##################################################### 5065 -107367827.. 5546: #################################################### 4954 5547.. 107378920: #################################################### 4943 107378921.. 214752294: ################################################### 4900 214752295.. 322125668: ###################################################### 5126 322125669.. 429499042: ####################################################### 5198 429499043.. 536872416: #################################################### 4988 536872417.. 644245790: #################################################### 4940 644245791.. 751619164: #################################################### 5002 751619165.. 858992538: #################################################### 4928 858992539.. 966365912: ##################################################### 5070 966365913.. 1073739286: #################################################### 4946 ================================================================================ 1 warning(s) failure (10 tests failed, 2 tests errored, ran 28 tests) qcheck-0.25/example/QCheck_runner_test.expected.ocaml4.64000066400000000000000000000456351477416744200233050ustar00rootroot00000000000000random seed: 1234 --- Failure -------------------------------------------------------------------- Test should_fail_sort_id failed (13 shrink steps): [1; 0] === Error ====================================================================== Test should_error_raise_exn errored on (63 shrink steps): 0 exception Dune__exe__QCheck_runner_test.Error +++ Collect ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Collect results for test collect_results: 4: 20 cases 3: 25 cases 2: 17 cases 1: 18 cases 0: 20 cases +++ Stats for with_stats ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats mod4: num: 100, avg: 1.68, stddev: 1.09, median 2, min 0, max 3 0: ############################## 17 1: ################################################### 29 2: ######################################## 23 3: ####################################################### 31 stats num: num: 100, avg: 66.84, stddev: 31.94, median 65, min 2, max 120 2.. 7: ################## 3 8.. 13: ################## 3 14.. 19: 0 20.. 25: ########################################## 7 26.. 31: ######################## 4 32.. 37: ######################## 4 38.. 43: ################## 3 44.. 49: ################################################ 8 50.. 55: #################################### 6 56.. 61: #################################### 6 62.. 67: ####################################################### 9 68.. 73: ########################################## 7 74.. 79: ######################## 4 80.. 85: ################## 3 86.. 91: ############ 2 92.. 97: ########################################## 7 98..103: #################################### 6 104..109: #################################### 6 110..115: ####################################################### 9 116..121: ################## 3 --- Failure -------------------------------------------------------------------- Test neg test unexpected success failed: Negative test neg test unexpected success succeeded but was expected to fail === Error ====================================================================== Test neg fail with error errored on (7 shrink steps): 0 exception Dune__exe__QCheck_runner_test.Error --- Failure -------------------------------------------------------------------- Test FAIL_pred_map_commute failed (77 shrink steps): ([1], {_ -> 0}, {1 -> true; _ -> false}) --- Failure -------------------------------------------------------------------- Test FAIL_fun2_pred_strings failed (2 shrink steps): {"some random string" -> true; _ -> false} --- Failure -------------------------------------------------------------------- Test fold_left fold_right failed (34 shrink steps): (0, [1], {(1, 0) -> 1; _ -> 0}) +++ Messages ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Messages for test fold_left fold_right: l=[1], fold_left=1, fold_right=0 --- Failure -------------------------------------------------------------------- Test fold_left fold_right uncurried failed (44 shrink steps): ({(0, 7) -> 1; _ -> 0}, 0, [7]) --- Failure -------------------------------------------------------------------- Test long_shrink failed (149 shrink steps): ([0], [-1]) --- Failure -------------------------------------------------------------------- Test mod3_should_fail failed (84 shrink steps): -21 +++ Stats for stats_neg ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 5000, avg: 0.17, stddev: 29.68, median 0, min -99, max 99 -99..-90: # 65 -89..-80: # 63 -79..-70: # 64 -69..-60: # 58 -59..-50: # 67 -49..-40: # 72 -39..-30: # 61 -29..-20: # 61 -19..-10: # 67 -9.. 0: ####################################################### 2076 1.. 10: ############################################## 1764 11.. 20: # 66 21.. 30: # 64 31.. 40: # 64 41.. 50: # 67 51.. 60: # 60 61.. 70: # 75 71.. 80: # 60 81.. 90: # 60 91..100: # 66 !!! Warning !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Warning for test WARN_unlikely_precond: WARNING: only 0.5% tests (of 2000) passed precondition for "WARN_unlikely_precond" NOTE: it is likely that the precondition is too strong, or that the generator is buggy. --- Failure -------------------------------------------------------------------- Test FAIL_unlikely_precond failed: ERROR: only 0.5% tests (of 2000) passed precondition for "FAIL_unlikely_precond" NOTE: it is likely that the precondition is too strong, or that the generator is buggy. --- Failure -------------------------------------------------------------------- Test FAIL_#99_1 failed: ERROR: uncaught exception in generator for test FAIL_#99_1 after 100 steps: Exception: QCheck.No_example_found("") Backtrace: +++ Stats for stat_display_test_1 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 0.90, stddev: 28.23, median 0, min -99, max 99 -99..-90: # 12 -89..-80: # 11 -79..-70: # 9 -69..-60: 6 -59..-50: # 11 -49..-40: # 13 -39..-30: # 9 -29..-20: # 13 -19..-10: 8 -9.. 0: ####################################################### 453 1.. 10: ######################################### 340 11.. 20: # 15 21.. 30: # 11 31.. 40: # 12 41.. 50: # 13 51.. 60: # 13 61.. 70: # 16 71.. 80: # 9 81.. 90: # 16 91..100: # 10 +++ Stats for stat_display_test_2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 15.11, stddev: 23.27, median 6, min 0, max 99 0.. 4: #################################################### 377 5.. 9: ####################################################### 392 10.. 14: ## 20 15.. 19: ## 15 20.. 24: # 11 25.. 29: ## 17 30.. 34: ## 19 35.. 39: ## 17 40.. 44: # 10 45.. 49: # 9 50.. 54: # 8 55.. 59: # 9 60.. 64: ## 15 65.. 69: # 10 70.. 74: # 13 75.. 79: ## 19 80.. 84: # 11 85.. 89: # 13 90.. 94: 5 95.. 99: # 10 +++ Stats for stat_display_test_3 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 195335.64, stddev: 136803.99, median 195583, min -43624, max 435210 -43624..-19683: ############################################ 52 -19682.. 4259: ######################################## 47 4260.. 28201: ############################## 36 28202.. 52143: ############################################ 52 52144.. 76085: ########################################## 50 76086..100027: ####################################################### 64 100028..123969: ############################################### 55 123970..147911: ######################################## 47 147912..171853: ############################################## 54 171854..195795: #################################### 43 195796..219737: ############################################## 54 219738..243679: ########################################### 51 243680..267621: ################################################ 57 267622..291563: ########################################## 49 291564..315505: #################################### 42 315506..339447: ###################################### 45 339448..363389: ################################################ 57 363390..387331: ###################################### 45 387332..411273: ########################################## 49 411274..435215: ########################################### 51 +++ Stats for stat_display_test_4 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: -173.78, stddev: 23042.92, median 180, min -39859, max 39942 -39859..-35869: ############################################# 56 -35868..-31878: ################################### 43 -31877..-27887: ################################################# 60 -27886..-23896: ##################################### 46 -23895..-19905: ######################################## 49 -19904..-15914: #################################### 45 -15913..-11923: ############################################ 54 -11922.. -7932: ############################################### 58 -7931.. -3941: ######################################### 51 -3940.. 50: ############################ 35 51.. 4041: ####################################### 48 4042.. 8032: ########################################## 52 8033.. 12023: ######################################### 51 12024.. 16014: ########################################### 53 16015.. 20005: ############################################ 54 20006.. 23996: ################################## 42 23997.. 27987: ####################################################### 67 27988.. 31978: ################################ 40 31979.. 35969: ######################################### 51 35970.. 39960: #################################### 45 +++ Stats for stat_display_test_5 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 0.02, stddev: 2.55, median 0, min -4, max 4 -4: ############################################ 99 -3: ##################################################### 118 -2: ################################################## 111 -1: ################################################## 113 0: ################################################## 113 1: ##################################################### 118 2: ############################################# 102 3: ####################################################### 122 4: ############################################## 104 +++ Stats for stat_display_test_6 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 6.67, stddev: 6.39, median 7, min -4, max 17 -4..-3: ############################################# 90 -2..-1: ############################################# 91 0.. 1: ########################################## 84 2.. 3: ############################################## 92 4.. 5: ########################################### 87 6.. 7: ########################################### 86 8.. 9: ############################################ 89 10..11: ########################################### 87 12..13: ####################################################### 110 14..15: ############################################# 91 16..17: ############################################## 93 18..19: 0 20..21: 0 22..23: 0 24..25: 0 26..27: 0 28..29: 0 30..31: 0 32..33: 0 34..35: 0 +++ Stats for stat_display_test_7 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 100000, avg: 2.541e+15, stddev: 2.661e+18, median 158655268318060, min -4611522359435274428, max 4611540922436307689 -4611522359435274428..-4150369195341695293: ##################################################### 4976 -4150369195341695292..-3689216031248116157: ##################################################### 4963 -3689216031248116156..-3228062867154537021: ###################################################### 5038 -3228062867154537020..-2766909703060957885: ##################################################### 4979 -2766909703060957884..-2305756538967378749: ##################################################### 5001 -2305756538967378748..-1844603374873799613: ##################################################### 4982 -1844603374873799612..-1383450210780220477: ##################################################### 5025 -1383450210780220476.. -922297046686641341: #################################################### 4901 -922297046686641340.. -461143882593062205: ####################################################### 5126 -461143882593062204.. 9281500516931: ##################################################### 5008 9281500516932.. 461162445594096067: ###################################################### 5041 461162445594096068.. 922315609687675203: ##################################################### 5001 922315609687675204.. 1383468773781254339: ##################################################### 4986 1383468773781254340.. 1844621937874833475: ##################################################### 4949 1844621937874833476.. 2305775101968412611: ##################################################### 5025 2305775101968412612.. 2766928266061991747: ##################################################### 5022 2766928266061991748.. 3228081430155570883: ##################################################### 4958 3228081430155570884.. 3689234594249150019: ##################################################### 4998 3689234594249150020.. 4150387758342729155: ##################################################### 4982 4150387758342729156.. 4611540922436308291: ###################################################### 5039 ================================================================================ 1 warning(s) failure (10 tests failed, 2 tests errored, ran 28 tests) qcheck-0.25/example/QCheck_runner_test.expected.ocaml5.32000066400000000000000000000450371477416744200232750ustar00rootroot00000000000000random seed: 1234 --- Failure -------------------------------------------------------------------- Test should_fail_sort_id failed (10 shrink steps): [1; 0] === Error ====================================================================== Test should_error_raise_exn errored on (30 shrink steps): 0 exception Dune__exe__QCheck_runner_test.Error +++ Collect ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Collect results for test collect_results: 4: 24 cases 3: 20 cases 2: 18 cases 1: 21 cases 0: 17 cases +++ Stats for with_stats ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats mod4: num: 100, avg: 1.56, stddev: 1.18, median 2, min 0, max 3 0: ################################################# 27 1: #################################### 20 2: ########################################## 23 3: ####################################################### 30 stats num: num: 100, avg: 62.24, stddev: 33.15, median 62, min 2, max 120 2.. 7: ######### 2 8.. 13: ################################ 7 14.. 19: ########################### 6 20.. 25: ############# 3 26.. 31: ###################### 5 32.. 37: ################## 4 38.. 43: ############# 3 44.. 49: ################################ 7 50.. 55: ################################ 7 56.. 61: ###################### 5 62.. 67: #################################### 8 68.. 73: ######### 2 74.. 79: ###################### 5 80.. 85: ######### 2 86.. 91: ####################################################### 12 92.. 97: ###################### 5 98..103: ################## 4 104..109: ################## 4 110..115: ############# 3 116..121: ########################### 6 --- Failure -------------------------------------------------------------------- Test neg test unexpected success failed: Negative test neg test unexpected success succeeded but was expected to fail === Error ====================================================================== Test neg fail with error errored on (7 shrink steps): 0 exception Dune__exe__QCheck_runner_test.Error --- Failure -------------------------------------------------------------------- Test FAIL_pred_map_commute failed (47 shrink steps): ([1], {_ -> 0}, {1 -> true; _ -> false}) --- Failure -------------------------------------------------------------------- Test FAIL_fun2_pred_strings failed (2 shrink steps): {"some random string" -> true; _ -> false} --- Failure -------------------------------------------------------------------- Test fold_left fold_right failed (21 shrink steps): (0, [1], {(0, 1) -> 1; _ -> 0}) +++ Messages ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Messages for test fold_left fold_right: l=[1], fold_left=0, fold_right=1 --- Failure -------------------------------------------------------------------- Test fold_left fold_right uncurried failed (41 shrink steps): ({(0, 4) -> 1; _ -> 0}, 0, [4]) --- Failure -------------------------------------------------------------------- Test long_shrink failed (86 shrink steps): ([0], [-1]) --- Failure -------------------------------------------------------------------- Test mod3_should_fail failed (26 shrink steps): 2061 +++ Stats for stats_neg ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 5000, avg: 0.43, stddev: 28.63, median 0, min -99, max 99 -99..-90: # 45 -89..-80: # 57 -79..-70: # 68 -69..-60: # 58 -59..-50: # 76 -49..-40: # 67 -39..-30: # 52 -29..-20: # 54 -19..-10: # 47 -9.. 0: ####################################################### 2205 1.. 10: ########################################## 1697 11.. 20: # 57 21.. 30: # 70 31.. 40: # 60 41.. 50: # 66 51.. 60: # 75 61.. 70: # 68 71.. 80: # 63 81.. 90: # 66 91..100: # 49 !!! Warning !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Warning for test WARN_unlikely_precond: WARNING: only 0.5% tests (of 2000) passed precondition for "WARN_unlikely_precond" NOTE: it is likely that the precondition is too strong, or that the generator is buggy. --- Failure -------------------------------------------------------------------- Test FAIL_unlikely_precond failed: ERROR: only 0.5% tests (of 2000) passed precondition for "FAIL_unlikely_precond" NOTE: it is likely that the precondition is too strong, or that the generator is buggy. --- Failure -------------------------------------------------------------------- Test FAIL_#99_1 failed: ERROR: uncaught exception in generator for test FAIL_#99_1 after 100 steps: Exception: QCheck.No_example_found("") Backtrace: +++ Stats for stat_display_test_1 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 0.86, stddev: 29.11, median 0, min -97, max 99 -97..-88: # 12 -87..-78: # 12 -77..-68: # 13 -67..-58: # 12 -57..-48: # 9 -47..-38: ## 17 -37..-28: # 13 -27..-18: # 8 -17.. -8: ######### 76 -7.. 2: ####################################################### 437 3.. 12: ################################## 276 13.. 22: ## 16 23.. 32: # 11 33.. 42: ## 16 43.. 52: # 9 53.. 62: # 12 63.. 72: # 14 73.. 82: # 12 83.. 92: # 13 93..102: # 12 +++ Stats for stat_display_test_2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 15.86, stddev: 24.57, median 6, min 0, max 99 0.. 4: ###################################################### 387 5.. 9: ####################################################### 390 10.. 14: # 11 15.. 19: # 8 20.. 24: # 11 25.. 29: ## 15 30.. 34: # 9 35.. 39: # 11 40.. 44: # 11 45.. 49: ## 19 50.. 54: # 10 55.. 59: ## 19 60.. 64: # 9 65.. 69: # 9 70.. 74: ## 19 75.. 79: # 13 80.. 84: # 11 85.. 89: ## 16 90.. 94: # 9 95.. 99: # 13 +++ Stats for stat_display_test_3 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 193479.13, stddev: 136696.70, median 189823, min -43164, max 434961 -43164..-19258: ################################### 42 -19257.. 4649: ############################################## 56 4650.. 28556: ############################################# 55 28557.. 52463: ############################################### 57 52464.. 76370: ######################################### 50 76371..100277: ############################# 35 100278..124184: ############################################### 57 124185..148091: #################################### 44 148092..171998: ############################################## 56 171999..195905: ####################################################### 66 195906..219812: ########################################### 52 219813..243719: ######################################## 49 243720..267626: ################################ 39 267627..291533: ##################################### 45 291534..315440: ##################################### 45 315441..339347: ################################################# 59 339348..363254: ################################################## 60 363255..387161: ################################# 40 387162..411068: ########################################## 51 411069..434975: ################################### 42 +++ Stats for stat_display_test_4 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: -591.06, stddev: 23026.79, median -911, min -39911, max 39959 -39911..-35918: ####################################### 45 -35917..-31924: #################################################### 59 -31923..-27930: ########################################### 49 -27929..-23936: ########################################## 48 -23935..-19942: ####################################################### 62 -19941..-15948: ############################################# 51 -15947..-11954: ######################################### 47 -11953.. -7960: ################################################# 56 -7959.. -3966: ################################### 40 -3965.. 28: ################################################### 58 29.. 4022: ########################################### 49 4023.. 8016: ############################################### 53 8017.. 12010: ############################################ 50 12011.. 16004: ################################### 40 16005.. 19998: ####################################### 44 19999.. 23992: ####################################################### 62 23993.. 27986: ##################################### 42 27987.. 31980: ######################################### 47 31981.. 35974: ########################################## 48 35975.. 39968: ############################################ 50 +++ Stats for stat_display_test_5 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: -0.12, stddev: 2.52, median 0, min -4, max 4 -4: ########################################## 116 -3: ###################################### 103 -2: ############################################## 125 -1: ########################################## 115 0: ####################################### 106 1: ####################################################### 149 2: ################################# 92 3: ################################# 92 4: ##################################### 102 +++ Stats for stat_display_test_6 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 6.42, stddev: 6.43, median 6, min -4, max 17 -4..-3: ########################################### 89 -2..-1: ################################################# 101 0.. 1: ############################################## 95 2.. 3: ########################################### 89 4.. 5: ############################################## 95 6.. 7: ##################################### 78 8.. 9: ####################################### 81 10..11: ######################################## 84 12..13: ####################################################### 113 14..15: ######################################## 84 16..17: ############################################ 91 18..19: 0 20..21: 0 22..23: 0 24..25: 0 26..27: 0 28..29: 0 30..31: 0 32..33: 0 34..35: 0 +++ Stats for stat_display_test_7 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 100000, avg: -2481754.31, stddev: 6.184e+8, median -5669677, min -1073719962, max 1073717275 -1073719962.. -966348101: ##################################################### 4978 -966348100.. -858976239: ##################################################### 5008 -858976238.. -751604377: #################################################### 4907 -751604376.. -644232515: ###################################################### 5037 -644232514.. -536860653: ###################################################### 5069 -536860652.. -429488791: ###################################################### 5052 -429488790.. -322116929: ###################################################### 5035 -322116928.. -214745067: ####################################################### 5128 -214745066.. -107373205: ##################################################### 5017 -107373204.. -1343: ##################################################### 5021 -1342.. 107370519: ##################################################### 5010 107370520.. 214742381: ##################################################### 4964 214742382.. 322114243: ##################################################### 4957 322114244.. 429486105: ##################################################### 4994 429486106.. 536857967: ##################################################### 5025 536857968.. 644229829: ###################################################### 5047 644229830.. 751601691: ##################################################### 4988 751601692.. 858973553: #################################################### 4924 858973554.. 966345415: #################################################### 4852 966345416.. 1073717277: ##################################################### 4987 ================================================================================ 1 warning(s) failure (10 tests failed, 2 tests errored, ran 28 tests) qcheck-0.25/example/QCheck_runner_test.expected.ocaml5.64000066400000000000000000000456431477416744200233050ustar00rootroot00000000000000random seed: 1234 --- Failure -------------------------------------------------------------------- Test should_fail_sort_id failed (10 shrink steps): [1; 0] === Error ====================================================================== Test should_error_raise_exn errored on (62 shrink steps): 0 exception Dune__exe__QCheck_runner_test.Error +++ Collect ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Collect results for test collect_results: 4: 24 cases 3: 20 cases 2: 18 cases 1: 21 cases 0: 17 cases +++ Stats for with_stats ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats mod4: num: 100, avg: 1.56, stddev: 1.18, median 2, min 0, max 3 0: ################################################# 27 1: #################################### 20 2: ########################################## 23 3: ####################################################### 30 stats num: num: 100, avg: 62.24, stddev: 33.15, median 62, min 2, max 120 2.. 7: ######### 2 8.. 13: ################################ 7 14.. 19: ########################### 6 20.. 25: ############# 3 26.. 31: ###################### 5 32.. 37: ################## 4 38.. 43: ############# 3 44.. 49: ################################ 7 50.. 55: ################################ 7 56.. 61: ###################### 5 62.. 67: #################################### 8 68.. 73: ######### 2 74.. 79: ###################### 5 80.. 85: ######### 2 86.. 91: ####################################################### 12 92.. 97: ###################### 5 98..103: ################## 4 104..109: ################## 4 110..115: ############# 3 116..121: ########################### 6 --- Failure -------------------------------------------------------------------- Test neg test unexpected success failed: Negative test neg test unexpected success succeeded but was expected to fail === Error ====================================================================== Test neg fail with error errored on (7 shrink steps): 0 exception Dune__exe__QCheck_runner_test.Error --- Failure -------------------------------------------------------------------- Test FAIL_pred_map_commute failed (89 shrink steps): ([1], {_ -> 0}, {0 -> true; _ -> false}) --- Failure -------------------------------------------------------------------- Test FAIL_fun2_pred_strings failed (2 shrink steps): {"some random string" -> true; _ -> false} --- Failure -------------------------------------------------------------------- Test fold_left fold_right failed (21 shrink steps): (0, [1], {(0, 1) -> 1; _ -> 0}) +++ Messages ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Messages for test fold_left fold_right: l=[1], fold_left=0, fold_right=1 --- Failure -------------------------------------------------------------------- Test fold_left fold_right uncurried failed (41 shrink steps): ({(0, 4) -> 1; _ -> 0}, 0, [4]) --- Failure -------------------------------------------------------------------- Test long_shrink failed (149 shrink steps): ([0], [1]) --- Failure -------------------------------------------------------------------- Test mod3_should_fail failed (75 shrink steps): 4161 +++ Stats for stats_neg ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 5000, avg: 0.43, stddev: 28.63, median 0, min -99, max 99 -99..-90: # 45 -89..-80: # 57 -79..-70: # 68 -69..-60: # 58 -59..-50: # 76 -49..-40: # 67 -39..-30: # 52 -29..-20: # 54 -19..-10: # 47 -9.. 0: ####################################################### 2205 1.. 10: ########################################## 1697 11.. 20: # 57 21.. 30: # 70 31.. 40: # 60 41.. 50: # 66 51.. 60: # 75 61.. 70: # 68 71.. 80: # 63 81.. 90: # 66 91..100: # 49 !!! Warning !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Warning for test WARN_unlikely_precond: WARNING: only 0.8% tests (of 2000) passed precondition for "WARN_unlikely_precond" NOTE: it is likely that the precondition is too strong, or that the generator is buggy. --- Failure -------------------------------------------------------------------- Test FAIL_unlikely_precond failed: ERROR: only 0.8% tests (of 2000) passed precondition for "FAIL_unlikely_precond" NOTE: it is likely that the precondition is too strong, or that the generator is buggy. --- Failure -------------------------------------------------------------------- Test FAIL_#99_1 failed: ERROR: uncaught exception in generator for test FAIL_#99_1 after 100 steps: Exception: QCheck.No_example_found("") Backtrace: +++ Stats for stat_display_test_1 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 0.86, stddev: 29.11, median 0, min -97, max 99 -97..-88: # 12 -87..-78: # 12 -77..-68: # 13 -67..-58: # 12 -57..-48: # 9 -47..-38: ## 17 -37..-28: # 13 -27..-18: # 8 -17.. -8: ######### 76 -7.. 2: ####################################################### 437 3.. 12: ################################## 276 13.. 22: ## 16 23.. 32: # 11 33.. 42: ## 16 43.. 52: # 9 53.. 62: # 12 63.. 72: # 14 73.. 82: # 12 83.. 92: # 13 93..102: # 12 +++ Stats for stat_display_test_2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 15.86, stddev: 24.57, median 6, min 0, max 99 0.. 4: ###################################################### 387 5.. 9: ####################################################### 390 10.. 14: # 11 15.. 19: # 8 20.. 24: # 11 25.. 29: ## 15 30.. 34: # 9 35.. 39: # 11 40.. 44: # 11 45.. 49: ## 19 50.. 54: # 10 55.. 59: ## 19 60.. 64: # 9 65.. 69: # 9 70.. 74: ## 19 75.. 79: # 13 80.. 84: # 11 85.. 89: ## 16 90.. 94: # 9 95.. 99: # 13 +++ Stats for stat_display_test_3 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 193479.13, stddev: 136696.70, median 189823, min -43164, max 434961 -43164..-19258: ################################### 42 -19257.. 4649: ############################################## 56 4650.. 28556: ############################################# 55 28557.. 52463: ############################################### 57 52464.. 76370: ######################################### 50 76371..100277: ############################# 35 100278..124184: ############################################### 57 124185..148091: #################################### 44 148092..171998: ############################################## 56 171999..195905: ####################################################### 66 195906..219812: ########################################### 52 219813..243719: ######################################## 49 243720..267626: ################################ 39 267627..291533: ##################################### 45 291534..315440: ##################################### 45 315441..339347: ################################################# 59 339348..363254: ################################################## 60 363255..387161: ################################# 40 387162..411068: ########################################## 51 411069..434975: ################################### 42 +++ Stats for stat_display_test_4 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: -591.06, stddev: 23026.79, median -911, min -39911, max 39959 -39911..-35918: ####################################### 45 -35917..-31924: #################################################### 59 -31923..-27930: ########################################### 49 -27929..-23936: ########################################## 48 -23935..-19942: ####################################################### 62 -19941..-15948: ############################################# 51 -15947..-11954: ######################################### 47 -11953.. -7960: ################################################# 56 -7959.. -3966: ################################### 40 -3965.. 28: ################################################### 58 29.. 4022: ########################################### 49 4023.. 8016: ############################################### 53 8017.. 12010: ############################################ 50 12011.. 16004: ################################### 40 16005.. 19998: ####################################### 44 19999.. 23992: ####################################################### 62 23993.. 27986: ##################################### 42 27987.. 31980: ######################################### 47 31981.. 35974: ########################################## 48 35975.. 39968: ############################################ 50 +++ Stats for stat_display_test_5 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: -0.12, stddev: 2.52, median 0, min -4, max 4 -4: ########################################## 116 -3: ###################################### 103 -2: ############################################## 125 -1: ########################################## 115 0: ####################################### 106 1: ####################################################### 149 2: ################################# 92 3: ################################# 92 4: ##################################### 102 +++ Stats for stat_display_test_6 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 6.42, stddev: 6.43, median 6, min -4, max 17 -4..-3: ########################################### 89 -2..-1: ################################################# 101 0.. 1: ############################################## 95 2.. 3: ########################################### 89 4.. 5: ############################################## 95 6.. 7: ##################################### 78 8.. 9: ####################################### 81 10..11: ######################################## 84 12..13: ####################################################### 113 14..15: ######################################## 84 16..17: ############################################ 91 18..19: 0 20..21: 0 22..23: 0 24..25: 0 26..27: 0 28..29: 0 30..31: 0 32..33: 0 34..35: 0 +++ Stats for stat_display_test_7 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 100000, avg: -7.216e+15, stddev: 2.666e+18, median -16620417636667326, min -4611371852367564818, max 4611613630315464842 -4611371852367564818..-4150222578233413331: ##################################################### 5003 -4150222578233413330..-3689073304099261843: ####################################################### 5106 -3689073304099261842..-3227924029965110355: ###################################################### 5052 -3227924029965110354..-2766774755830958867: ###################################################### 5017 -2766774755830958866..-2305625481696807379: #################################################### 4852 -2305625481696807378..-1844476207562655891: ###################################################### 5016 -1844476207562655890..-1383326933428504403: ###################################################### 5083 -1383326933428504402.. -922177659294352915: ##################################################### 4986 -922177659294352914.. -461028385160201427: ###################################################### 5042 -461028385160201426.. 120888973950061: ###################################################### 5017 120888973950062.. 461270163108101549: ##################################################### 4977 461270163108101550.. 922419437242253037: ##################################################### 5000 922419437242253038.. 1383568711376404525: ###################################################### 5022 1383568711376404526.. 1844717985510556013: #################################################### 4896 1844717985510556014.. 2305867259644707501: #################################################### 4884 2305867259644707502.. 2767016533778858989: ##################################################### 4981 2767016533778858990.. 3228165807913010477: ###################################################### 5026 3228165807913010478.. 3689315082047161965: ###################################################### 5016 3689315082047161966.. 4150464356181313453: ###################################################### 5021 4150464356181313454.. 4611613630315464941: ##################################################### 5003 ================================================================================ 1 warning(s) failure (10 tests failed, 2 tests errored, ran 28 tests) qcheck-0.25/example/QCheck_runner_test.ml000066400000000000000000000141741477416744200205000ustar00rootroot00000000000000 let passing = QCheck.Test.make ~count:100 ~long_factor:100 ~name:"list_rev_is_involutive" QCheck.(list small_int) (fun l -> List.rev (List.rev l) = l);; let failing = QCheck.Test.make ~count:10 ~name:"should_fail_sort_id" QCheck.(small_list small_int) (fun l -> l = List.sort compare l);; exception Error let error = QCheck.Test.make ~count:10 ~name:"should_error_raise_exn" QCheck.int (fun _ -> raise Error) let collect = QCheck.Test.make ~count:100 ~long_factor:100 ~name:"collect_results" QCheck.(make ~collect:string_of_int (Gen.int_bound 4)) (fun _ -> true) let stats = QCheck.Test.make ~count:100 ~long_factor:100 ~name:"with_stats" QCheck.(make (Gen.int_bound 120) ~stats:[ "mod4", (fun i->i mod 4); "num", (fun i->i); ] ) (fun _ -> true) let neg_test_failing_as_expected = QCheck.Test.make_neg ~name:"neg test pass (failing as expected)" QCheck.small_int (fun i -> i mod 2 = 0) let neg_test_unexpected_success = QCheck.Test.make_neg ~name:"neg test unexpected success" QCheck.small_int (fun i -> i + i = i * 2) let neg_test_error = QCheck.Test.make_neg ~name:"neg fail with error" QCheck.small_int (fun _i -> raise Error) let fun1 = QCheck.Test.make ~count:100 ~long_factor:100 ~name:"FAIL_pred_map_commute" QCheck.(triple (small_list small_int) (fun1 Observable.int int) (fun1 Observable.int bool)) (fun (l,QCheck.Fun (_,f), QCheck.Fun (_,p)) -> List.filter p (List.map f l) = List.map f (List.filter p l)) let fun2 = QCheck.Test.make ~count:100 ~name:"FAIL_fun2_pred_strings" QCheck.(fun1 Observable.string bool) (fun (QCheck.Fun (_,p)) -> not (p "some random string") || p "some other string") let bad_assume_warn = QCheck.Test.make ~count:2_000 ~name:"WARN_unlikely_precond" QCheck.int (fun x -> QCheck.assume (x mod 100 = 1); true) let bad_assume_fail = QCheck.Test.make ~count:2_000 ~if_assumptions_fail:(`Fatal, 0.1) ~name:"FAIL_unlikely_precond" QCheck.int (fun x -> QCheck.assume (x mod 100 = 1); true) let int_gen = QCheck.small_nat (* int *) (* Another example (false) property *) let prop_foldleft_foldright = let open QCheck in Test.make ~name:"fold_left fold_right" ~count:1000 ~long_factor:20 (triple int_gen (list int_gen) (fun2 Observable.int Observable.int int_gen)) (fun (z,xs,f) -> let l1 = List.fold_right (Fn.apply f) xs z in let l2 = List.fold_left (Fn.apply f) z xs in if l1=l2 then true else QCheck.Test.fail_reportf "l=%s, fold_left=%s, fold_right=%s@." (QCheck.Print.(list int) xs) (QCheck.Print.int l1) (QCheck.Print.int l2) ) (* Another example (false) property *) let prop_foldleft_foldright_uncurry = let open QCheck in Test.make ~name:"fold_left fold_right uncurried" ~count:1000 ~long_factor:20 (triple (fun1 Observable.(pair int int) int_gen) int_gen (list int_gen)) (fun (f,z,xs) -> List.fold_right (fun x y -> Fn.apply f (x,y)) xs z = List.fold_left (fun x y -> Fn.apply f (x,y)) z xs) let long_shrink = let open QCheck in let listgen = list_of_size (Gen.int_range 1000 10000) int in Test.make ~name:"long_shrink" (pair listgen listgen) (fun (xs,ys) -> List.rev (xs@ys) = (List.rev xs)@(List.rev ys)) let find_ex = let open QCheck in Test.make ~name:"find_example" (2--50) (fun n -> let st = Random.State.make [| 0 |] in let f m = n < m && m < 2 * n in try let m = find_example_gen ~rand:st ~count:100_000 ~f Gen.(0 -- 1000) in f m with No_example_found _ -> false) let find_ex_uncaught_issue_99 : _ list = let open QCheck in let t1 = let rs = make (find_example ~count:10 ~f:(fun _ -> false) Gen.int) in Test.make ~name:"FAIL_#99_1" rs (fun _ -> true) in let t2 = Test.make ~name:"should_succeed_#99_2" ~count:10 int (fun i -> i <= max_int) in [t1;t2] (* test shrinking on integers *) let shrink_int = QCheck.Test.make ~count:1000 ~name:"mod3_should_fail" QCheck.int (fun i -> i mod 3 <> 0);; let stats_negs = QCheck.(Test.make ~count:5_000 ~name:"stats_neg" (add_stat ("dist",fun x -> x) small_signed_int)) (fun _ -> true) type tree = Leaf of int | Node of tree * tree let leaf x = Leaf x let node x y = Node (x,y) let gen_tree = QCheck.Gen.(sized @@ fix (fun self n -> match n with | 0 -> map leaf nat | n -> frequency [1, map leaf nat; 2, map2 node (self (n/2)) (self (n/2))] )) let rec rev_tree = function | Node (x, y) -> Node (rev_tree y, rev_tree x) | Leaf x -> Leaf x let passing_tree_rev = QCheck.Test.make ~count:1000 ~name:"tree_rev_is_involutive" QCheck.(make gen_tree) (fun tree -> rev_tree (rev_tree tree) = tree) let stats_tests = let open QCheck in [ Test.make ~name:"stat_display_test_1" ~count:1000 (add_stat ("dist",fun x -> x) small_signed_int) (fun _ -> true); Test.make ~name:"stat_display_test_2" ~count:1000 (add_stat ("dist",fun x -> x) small_nat) (fun _ -> true); Test.make ~name:"stat_display_test_3" ~count:1000 (add_stat ("dist",fun x -> x) (int_range (-43643) 435434)) (fun _ -> true); Test.make ~name:"stat_display_test_4" ~count:1000 (add_stat ("dist",fun x -> x) (int_range (-40000) 40000)) (fun _ -> true); Test.make ~name:"stat_display_test_5" ~count:1000 (add_stat ("dist",fun x -> x) (int_range (-4) 4)) (fun _ -> true); Test.make ~name:"stat_display_test_6" ~count:1000 (add_stat ("dist",fun x -> x) (int_range (-4) 17)) (fun _ -> true); Test.make ~name:"stat_display_test_7" ~count:100000 (add_stat ("dist",fun x -> x) int) (fun _ -> true); ] let () = QCheck_runner.run_tests_main ([ passing; failing; error; collect; stats; neg_test_failing_as_expected; neg_test_unexpected_success; neg_test_error; fun1; fun2; prop_foldleft_foldright; prop_foldleft_foldright_uncurry; long_shrink; find_ex; shrink_int; stats_negs; bad_assume_warn; bad_assume_fail; passing_tree_rev; ] @ find_ex_uncaught_issue_99 @ stats_tests) qcheck-0.25/example/alcotest/000077500000000000000000000000001477416744200161675ustar00rootroot00000000000000qcheck-0.25/example/alcotest/QCheck_alcotest_test.expected.ocaml4.32000066400000000000000000000157311477416744200254150ustar00rootroot00000000000000qcheck random seed: 1234 Testing `my test'. [OK] suite 0 list_rev_is_involutive. [FAIL] suite 1 fail_sort_id. [FAIL] suite 2 error_raise_exn. [OK] suite 3 neg test pass (failing as expected). [FAIL] suite 4 neg test unexpected success. [FAIL] suite 5 neg fail with error. [FAIL] suite 6 fail_check_err_message. [OK] suite 7 tree_rev_is_involutive. [FAIL] shrinking 0 debug_shrink. ┌──────────────────────────────────────────────────────────────────────────────┐ │ [FAIL] suite 1 fail_sort_id. │ └──────────────────────────────────────────────────────────────────────────────┘ test `fail_sort_id` failed on ≥ 1 cases: [1; 0] (after 11 shrink steps) [exception] test `fail_sort_id` failed on ≥ 1 cases: [1; 0] (after 11 shrink steps) ────────────────────────────────────────────────────────────────────────────── ┌──────────────────────────────────────────────────────────────────────────────┐ │ [FAIL] suite 2 error_raise_exn. │ └──────────────────────────────────────────────────────────────────────────────┘ test `error_raise_exn` raised exception `Error` on `0 (after 31 shrink steps)` [exception] test `error_raise_exn` raised exception `Error` on `0 (after 31 shrink steps)` ────────────────────────────────────────────────────────────────────────────── ┌──────────────────────────────────────────────────────────────────────────────┐ │ [FAIL] suite 4 neg test unexpected success. │ └──────────────────────────────────────────────────────────────────────────────┘ negative test 'neg test unexpected success' succeeded unexpectedly [exception] negative test `neg test unexpected success` succeeded unexpectedly ────────────────────────────────────────────────────────────────────────────── ┌──────────────────────────────────────────────────────────────────────────────┐ │ [FAIL] suite 5 neg fail with error. │ └──────────────────────────────────────────────────────────────────────────────┘ test `neg fail with error` raised exception `Error` on `0 (after 7 shrink steps)` [exception] test `neg fail with error` raised exception `Error` on `0 (after 7 shrink steps)` ────────────────────────────────────────────────────────────────────────────── ┌──────────────────────────────────────────────────────────────────────────────┐ │ [FAIL] suite 6 fail_check_err_message. │ └──────────────────────────────────────────────────────────────────────────────┘ test `fail_check_err_message` failed on ≥ 1 cases: 0 (after 7 shrink steps) this will always fail [exception] test `fail_check_err_message` failed on ≥ 1 cases: 0 (after 7 shrink steps) this will always fail ────────────────────────────────────────────────────────────────────────────── ┌──────────────────────────────────────────────────────────────────────────────┐ │ [FAIL] shrinking 0 debug_shrink. │ └──────────────────────────────────────────────────────────────────────────────┘ ~~~ Shrink ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Test debug_shrink successfully shrunk counter example (step 0) to: (3, 1) ~~~ Shrink ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Test debug_shrink successfully shrunk counter example (step 1) to: (2, 1) ~~~ Shrink ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Test debug_shrink successfully shrunk counter example (step 2) to: (2, 0) ~~~ Shrink ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Test debug_shrink successfully shrunk counter example (step 3) to: (1, 0) law debug_shrink: 2 relevant cases (2 total) test `debug_shrink` failed on ≥ 1 cases: (1, 0) (after 3 shrink steps) [exception] test `debug_shrink` failed on ≥ 1 cases: (1, 0) (after 3 shrink steps) ────────────────────────────────────────────────────────────────────────────── 6 failures! 9 tests run. qcheck-0.25/example/alcotest/QCheck_alcotest_test.expected.ocaml4.64000066400000000000000000000157311477416744200254220ustar00rootroot00000000000000qcheck random seed: 1234 Testing `my test'. [OK] suite 0 list_rev_is_involutive. [FAIL] suite 1 fail_sort_id. [FAIL] suite 2 error_raise_exn. [OK] suite 3 neg test pass (failing as expected). [FAIL] suite 4 neg test unexpected success. [FAIL] suite 5 neg fail with error. [FAIL] suite 6 fail_check_err_message. [OK] suite 7 tree_rev_is_involutive. [FAIL] shrinking 0 debug_shrink. ┌──────────────────────────────────────────────────────────────────────────────┐ │ [FAIL] suite 1 fail_sort_id. │ └──────────────────────────────────────────────────────────────────────────────┘ test `fail_sort_id` failed on ≥ 1 cases: [1; 0] (after 11 shrink steps) [exception] test `fail_sort_id` failed on ≥ 1 cases: [1; 0] (after 11 shrink steps) ────────────────────────────────────────────────────────────────────────────── ┌──────────────────────────────────────────────────────────────────────────────┐ │ [FAIL] suite 2 error_raise_exn. │ └──────────────────────────────────────────────────────────────────────────────┘ test `error_raise_exn` raised exception `Error` on `0 (after 63 shrink steps)` [exception] test `error_raise_exn` raised exception `Error` on `0 (after 63 shrink steps)` ────────────────────────────────────────────────────────────────────────────── ┌──────────────────────────────────────────────────────────────────────────────┐ │ [FAIL] suite 4 neg test unexpected success. │ └──────────────────────────────────────────────────────────────────────────────┘ negative test 'neg test unexpected success' succeeded unexpectedly [exception] negative test `neg test unexpected success` succeeded unexpectedly ────────────────────────────────────────────────────────────────────────────── ┌──────────────────────────────────────────────────────────────────────────────┐ │ [FAIL] suite 5 neg fail with error. │ └──────────────────────────────────────────────────────────────────────────────┘ test `neg fail with error` raised exception `Error` on `0 (after 7 shrink steps)` [exception] test `neg fail with error` raised exception `Error` on `0 (after 7 shrink steps)` ────────────────────────────────────────────────────────────────────────────── ┌──────────────────────────────────────────────────────────────────────────────┐ │ [FAIL] suite 6 fail_check_err_message. │ └──────────────────────────────────────────────────────────────────────────────┘ test `fail_check_err_message` failed on ≥ 1 cases: 0 (after 7 shrink steps) this will always fail [exception] test `fail_check_err_message` failed on ≥ 1 cases: 0 (after 7 shrink steps) this will always fail ────────────────────────────────────────────────────────────────────────────── ┌──────────────────────────────────────────────────────────────────────────────┐ │ [FAIL] shrinking 0 debug_shrink. │ └──────────────────────────────────────────────────────────────────────────────┘ ~~~ Shrink ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Test debug_shrink successfully shrunk counter example (step 0) to: (3, 1) ~~~ Shrink ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Test debug_shrink successfully shrunk counter example (step 1) to: (2, 1) ~~~ Shrink ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Test debug_shrink successfully shrunk counter example (step 2) to: (2, 0) ~~~ Shrink ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Test debug_shrink successfully shrunk counter example (step 3) to: (1, 0) law debug_shrink: 2 relevant cases (2 total) test `debug_shrink` failed on ≥ 1 cases: (1, 0) (after 3 shrink steps) [exception] test `debug_shrink` failed on ≥ 1 cases: (1, 0) (after 3 shrink steps) ────────────────────────────────────────────────────────────────────────────── 6 failures! 9 tests run. qcheck-0.25/example/alcotest/QCheck_alcotest_test.expected.ocaml5.32000066400000000000000000000161641477416744200254170ustar00rootroot00000000000000qcheck random seed: 1234 Testing `my test'. [OK] suite 0 list_rev_is_involutive. [FAIL] suite 1 fail_sort_id. [FAIL] suite 2 error_raise_exn. [OK] suite 3 neg test pass (failing as expected). [FAIL] suite 4 neg test unexpected success. [FAIL] suite 5 neg fail with error. [FAIL] suite 6 fail_check_err_message. [OK] suite 7 tree_rev_is_involutive. [FAIL] shrinking 0 debug_shrink. ┌──────────────────────────────────────────────────────────────────────────────┐ │ [FAIL] suite 1 fail_sort_id. │ └──────────────────────────────────────────────────────────────────────────────┘ test `fail_sort_id` failed on ≥ 1 cases: [1; 0] (after 16 shrink steps) [exception] test `fail_sort_id` failed on ≥ 1 cases: [1; 0] (after 16 shrink steps) ────────────────────────────────────────────────────────────────────────────── ┌──────────────────────────────────────────────────────────────────────────────┐ │ [FAIL] suite 2 error_raise_exn. │ └──────────────────────────────────────────────────────────────────────────────┘ test `error_raise_exn` raised exception `Error` on `0 (after 30 shrink steps)` [exception] test `error_raise_exn` raised exception `Error` on `0 (after 30 shrink steps)` ────────────────────────────────────────────────────────────────────────────── ┌──────────────────────────────────────────────────────────────────────────────┐ │ [FAIL] suite 4 neg test unexpected success. │ └──────────────────────────────────────────────────────────────────────────────┘ negative test 'neg test unexpected success' succeeded unexpectedly [exception] negative test `neg test unexpected success` succeeded unexpectedly ────────────────────────────────────────────────────────────────────────────── ┌──────────────────────────────────────────────────────────────────────────────┐ │ [FAIL] suite 5 neg fail with error. │ └──────────────────────────────────────────────────────────────────────────────┘ test `neg fail with error` raised exception `Error` on `0 (after 7 shrink steps)` [exception] test `neg fail with error` raised exception `Error` on `0 (after 7 shrink steps)` ────────────────────────────────────────────────────────────────────────────── ┌──────────────────────────────────────────────────────────────────────────────┐ │ [FAIL] suite 6 fail_check_err_message. │ └──────────────────────────────────────────────────────────────────────────────┘ test `fail_check_err_message` failed on ≥ 1 cases: 0 (after 7 shrink steps) this will always fail [exception] test `fail_check_err_message` failed on ≥ 1 cases: 0 (after 7 shrink steps) this will always fail ────────────────────────────────────────────────────────────────────────────── ┌──────────────────────────────────────────────────────────────────────────────┐ │ [FAIL] shrinking 0 debug_shrink. │ └──────────────────────────────────────────────────────────────────────────────┘ ~~~ Shrink ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Test debug_shrink successfully shrunk counter example (step 0) to: (2, 3) ~~~ Shrink ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Test debug_shrink successfully shrunk counter example (step 1) to: (1, 3) ~~~ Shrink ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Test debug_shrink successfully shrunk counter example (step 2) to: (0, 3) ~~~ Shrink ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Test debug_shrink successfully shrunk counter example (step 3) to: (0, 2) ~~~ Shrink ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Test debug_shrink successfully shrunk counter example (step 4) to: (0, 1) law debug_shrink: 1 relevant cases (1 total) test `debug_shrink` failed on ≥ 1 cases: (0, 1) (after 4 shrink steps) [exception] test `debug_shrink` failed on ≥ 1 cases: (0, 1) (after 4 shrink steps) ────────────────────────────────────────────────────────────────────────────── 6 failures! 9 tests run. qcheck-0.25/example/alcotest/QCheck_alcotest_test.expected.ocaml5.64000066400000000000000000000161641477416744200254240ustar00rootroot00000000000000qcheck random seed: 1234 Testing `my test'. [OK] suite 0 list_rev_is_involutive. [FAIL] suite 1 fail_sort_id. [FAIL] suite 2 error_raise_exn. [OK] suite 3 neg test pass (failing as expected). [FAIL] suite 4 neg test unexpected success. [FAIL] suite 5 neg fail with error. [FAIL] suite 6 fail_check_err_message. [OK] suite 7 tree_rev_is_involutive. [FAIL] shrinking 0 debug_shrink. ┌──────────────────────────────────────────────────────────────────────────────┐ │ [FAIL] suite 1 fail_sort_id. │ └──────────────────────────────────────────────────────────────────────────────┘ test `fail_sort_id` failed on ≥ 1 cases: [1; 0] (after 16 shrink steps) [exception] test `fail_sort_id` failed on ≥ 1 cases: [1; 0] (after 16 shrink steps) ────────────────────────────────────────────────────────────────────────────── ┌──────────────────────────────────────────────────────────────────────────────┐ │ [FAIL] suite 2 error_raise_exn. │ └──────────────────────────────────────────────────────────────────────────────┘ test `error_raise_exn` raised exception `Error` on `0 (after 62 shrink steps)` [exception] test `error_raise_exn` raised exception `Error` on `0 (after 62 shrink steps)` ────────────────────────────────────────────────────────────────────────────── ┌──────────────────────────────────────────────────────────────────────────────┐ │ [FAIL] suite 4 neg test unexpected success. │ └──────────────────────────────────────────────────────────────────────────────┘ negative test 'neg test unexpected success' succeeded unexpectedly [exception] negative test `neg test unexpected success` succeeded unexpectedly ────────────────────────────────────────────────────────────────────────────── ┌──────────────────────────────────────────────────────────────────────────────┐ │ [FAIL] suite 5 neg fail with error. │ └──────────────────────────────────────────────────────────────────────────────┘ test `neg fail with error` raised exception `Error` on `0 (after 7 shrink steps)` [exception] test `neg fail with error` raised exception `Error` on `0 (after 7 shrink steps)` ────────────────────────────────────────────────────────────────────────────── ┌──────────────────────────────────────────────────────────────────────────────┐ │ [FAIL] suite 6 fail_check_err_message. │ └──────────────────────────────────────────────────────────────────────────────┘ test `fail_check_err_message` failed on ≥ 1 cases: 0 (after 7 shrink steps) this will always fail [exception] test `fail_check_err_message` failed on ≥ 1 cases: 0 (after 7 shrink steps) this will always fail ────────────────────────────────────────────────────────────────────────────── ┌──────────────────────────────────────────────────────────────────────────────┐ │ [FAIL] shrinking 0 debug_shrink. │ └──────────────────────────────────────────────────────────────────────────────┘ ~~~ Shrink ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Test debug_shrink successfully shrunk counter example (step 0) to: (2, 3) ~~~ Shrink ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Test debug_shrink successfully shrunk counter example (step 1) to: (1, 3) ~~~ Shrink ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Test debug_shrink successfully shrunk counter example (step 2) to: (0, 3) ~~~ Shrink ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Test debug_shrink successfully shrunk counter example (step 3) to: (0, 2) ~~~ Shrink ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Test debug_shrink successfully shrunk counter example (step 4) to: (0, 1) law debug_shrink: 1 relevant cases (1 total) test `debug_shrink` failed on ≥ 1 cases: (0, 1) (after 4 shrink steps) [exception] test `debug_shrink` failed on ≥ 1 cases: (0, 1) (after 4 shrink steps) ────────────────────────────────────────────────────────────────────────────── 6 failures! 9 tests run. qcheck-0.25/example/alcotest/QCheck_alcotest_test.ml000066400000000000000000000042761477416744200226250ustar00rootroot00000000000000let passing = QCheck.Test.make ~count:1000 ~name:"list_rev_is_involutive" QCheck.(list small_int) (fun l -> List.rev (List.rev l) = l);; let failing = QCheck.Test.make ~count:10 ~name:"fail_sort_id" QCheck.(list small_int) (fun l -> l = List.sort compare l);; exception Error let error = QCheck.Test.make ~count:10 ~name:"error_raise_exn" QCheck.int (fun _ -> raise Error) let neg_test_failing_as_expected = QCheck.Test.make_neg ~name:"neg test pass (failing as expected)" QCheck.small_int (fun i -> i mod 2 = 0) let neg_test_unexpected_success = QCheck.Test.make_neg ~name:"neg test unexpected success" QCheck.small_int (fun i -> i + i = i * 2) let neg_test_error = QCheck.Test.make_neg ~name:"neg fail with error" QCheck.small_int (fun _i -> raise Error) let simple_qcheck = QCheck.Test.make ~name:"fail_check_err_message" ~count: 100 QCheck.small_int (fun _ -> QCheck.Test.fail_reportf "@[this@ will@ always@ fail@]") type tree = Leaf of int | Node of tree * tree let leaf x = Leaf x let node x y = Node (x,y) let gen_tree = QCheck.Gen.(sized @@ fix (fun self n -> match n with | 0 -> map leaf nat | n -> frequency [1, map leaf nat; 2, map2 node (self (n/2)) (self (n/2))] )) let rec rev_tree = function | Node (x, y) -> Node (rev_tree y, rev_tree x) | Leaf x -> Leaf x let passing_tree_rev = QCheck.Test.make ~count:1000 ~name:"tree_rev_is_involutive" QCheck.(make gen_tree) (fun tree -> rev_tree (rev_tree tree) = tree) let debug_shrink = QCheck.Test.make ~count:10 ~name:"debug_shrink" (* we use a very constrained test to have a smaller shrinking tree *) QCheck.(pair (1 -- 3) (1 -- 3)) (fun (a, b) -> a = b);; let () = Printexc.record_backtrace true; let module A = Alcotest in let suite = List.map QCheck_alcotest.to_alcotest [ passing; failing; error; neg_test_failing_as_expected; neg_test_unexpected_success; neg_test_error; simple_qcheck; passing_tree_rev ] in A.run ~show_errors:true "my test" [ "suite", suite; "shrinking", [ QCheck_alcotest.to_alcotest ~verbose:true ~debug_shrink:(Some stdout) debug_shrink ]; ]; qcheck-0.25/example/alcotest/dune000066400000000000000000000023451477416744200170510ustar00rootroot00000000000000(rule (enabled_if (and (= %{arch_sixtyfour} true) (>= %{ocaml_version} 5))) (action (copy QCheck_alcotest_test.expected.ocaml5.64 QCheck_alcotest_test.expected))) (rule (enabled_if (and (= %{arch_sixtyfour} false) (>= %{ocaml_version} 5))) (action (copy QCheck_alcotest_test.expected.ocaml5.32 QCheck_alcotest_test.expected))) (rule (enabled_if (and (= %{arch_sixtyfour} true) (< %{ocaml_version} 5))) (action (copy QCheck_alcotest_test.expected.ocaml4.64 QCheck_alcotest_test.expected))) (rule (enabled_if (and (= %{arch_sixtyfour} false) (< %{ocaml_version} 5))) (action (copy QCheck_alcotest_test.expected.ocaml4.32 QCheck_alcotest_test.expected))) (executable (name QCheck_alcotest_test) (libraries qcheck-core qcheck-alcotest alcotest)) (rule (targets QCheck_alcotest_test.output) (deps ./QCheck_alcotest_test.exe) (enabled_if (= %{os_type} "Unix")) (action (with-accepted-exit-codes 1 (setenv CI false ; Don't run tests as if Alcotest was run in CI (setenv QCHECK_SEED 1234 (with-stdout-to %{targets} (run ./run_alcotest.sh --color=never))))))) (rule (alias runtest) (package qcheck-alcotest) (enabled_if (= %{os_type} "Unix")) (action (diff QCheck_alcotest_test.expected QCheck_alcotest_test.output))) qcheck-0.25/example/alcotest/run_alcotest.sh000077500000000000000000000007031477416744200212300ustar00rootroot00000000000000#!/usr/bin/env sh # custom script to run qcheck-alcotest and filter non reproducible parts OUT=`./QCheck_alcotest_test.exe $@` CODE=$? # remove non deterministic output echo "$OUT" | grep -v 'This run has ID' \ | grep -v 'Full test results in' \ | grep -v 'Logs saved to' \ | grep -v 'Raised at ' \ | grep -v 'Called from ' \ | sed 's/! in .*s\./!/' \ | sed 's/`.*.Error`/`Error`/g' \ | sed 's/[ \t]*$//g' \ | tr -s "\n" exit $CODE qcheck-0.25/example/dune000066400000000000000000000016301477416744200152270ustar00rootroot00000000000000(rule (enabled_if (and (= %{arch_sixtyfour} true) (>= %{ocaml_version} 5))) (action (copy QCheck_runner_test.expected.ocaml5.64 QCheck_runner_test.expected))) (rule (enabled_if (and (= %{arch_sixtyfour} false) (>= %{ocaml_version} 5))) (action (copy QCheck_runner_test.expected.ocaml5.32 QCheck_runner_test.expected))) (rule (enabled_if (and (= %{arch_sixtyfour} true) (< %{ocaml_version} 5))) (action (copy QCheck_runner_test.expected.ocaml4.64 QCheck_runner_test.expected))) (rule (enabled_if (and (= %{arch_sixtyfour} false) (< %{ocaml_version} 5))) (action (copy QCheck_runner_test.expected.ocaml4.32 QCheck_runner_test.expected))) ;; implicitly compared against QCheck_runner_test.expected (test (enabled_if (= %{os_type} "Unix")) (name QCheck_runner_test) (modules QCheck_runner_test) (package qcheck) (libraries qcheck) (action (with-accepted-exit-codes 1 (run ./%{test} --no-colors -s 1234)))) qcheck-0.25/example/ounit/000077500000000000000000000000001477416744200155075ustar00rootroot00000000000000qcheck-0.25/example/ounit/QCheck_ounit_test.expected.ocaml4.32000066400000000000000000000035121477416744200242470ustar00rootroot00000000000000.FE.FEF. ============================================================================== Error: tests:5:neg fail with error. Error: tests:5:neg fail with error (in the log). test `neg fail with error` raised exception `Dune__exe__QCheck_ounit_test.Error` on `0 (after 7 shrink steps)` ------------------------------------------------------------------------------ ============================================================================== Error: tests:2:error_raise_exn. Error: tests:2:error_raise_exn (in the log). test `error_raise_exn` raised exception `Dune__exe__QCheck_ounit_test.Error` on `0 (after 31 shrink steps)` ------------------------------------------------------------------------------ ============================================================================== Error: tests:6:fail_check_err_message. Error: tests:6:fail_check_err_message (in the log). test `fail_check_err_message` failed on ≥ 1 cases: 0 (after 7 shrink steps) this will always fail ------------------------------------------------------------------------------ ============================================================================== Error: tests:4:neg test unexpected success. Error: tests:4:neg test unexpected success (in the log). negative test 'neg test unexpected success' succeeded unexpectedly ------------------------------------------------------------------------------ ============================================================================== Error: tests:1:fail_sort_id. Error: tests:1:fail_sort_id (in the log). test `fail_sort_id` failed on ≥ 1 cases: [1; 0] (after 11 shrink steps) ------------------------------------------------------------------------------ Ran: 8 tests in: seconds. FAILED: Cases: 8 Tried: 8 Errors: 2 Failures: 3 Skip: 0 Todo: 0 Timeouts: 0. qcheck-0.25/example/ounit/QCheck_ounit_test.expected.ocaml4.64000066400000000000000000000035121477416744200242540ustar00rootroot00000000000000.FE.FEF. ============================================================================== Error: tests:5:neg fail with error. Error: tests:5:neg fail with error (in the log). test `neg fail with error` raised exception `Dune__exe__QCheck_ounit_test.Error` on `0 (after 7 shrink steps)` ------------------------------------------------------------------------------ ============================================================================== Error: tests:2:error_raise_exn. Error: tests:2:error_raise_exn (in the log). test `error_raise_exn` raised exception `Dune__exe__QCheck_ounit_test.Error` on `0 (after 63 shrink steps)` ------------------------------------------------------------------------------ ============================================================================== Error: tests:6:fail_check_err_message. Error: tests:6:fail_check_err_message (in the log). test `fail_check_err_message` failed on ≥ 1 cases: 0 (after 7 shrink steps) this will always fail ------------------------------------------------------------------------------ ============================================================================== Error: tests:4:neg test unexpected success. Error: tests:4:neg test unexpected success (in the log). negative test 'neg test unexpected success' succeeded unexpectedly ------------------------------------------------------------------------------ ============================================================================== Error: tests:1:fail_sort_id. Error: tests:1:fail_sort_id (in the log). test `fail_sort_id` failed on ≥ 1 cases: [1; 0] (after 11 shrink steps) ------------------------------------------------------------------------------ Ran: 8 tests in: seconds. FAILED: Cases: 8 Tried: 8 Errors: 2 Failures: 3 Skip: 0 Todo: 0 Timeouts: 0. qcheck-0.25/example/ounit/QCheck_ounit_test.expected.ocaml5.32000066400000000000000000000035121477416744200242500ustar00rootroot00000000000000.FE.FEF. ============================================================================== Error: tests:5:neg fail with error. Error: tests:5:neg fail with error (in the log). test `neg fail with error` raised exception `Dune__exe__QCheck_ounit_test.Error` on `0 (after 7 shrink steps)` ------------------------------------------------------------------------------ ============================================================================== Error: tests:2:error_raise_exn. Error: tests:2:error_raise_exn (in the log). test `error_raise_exn` raised exception `Dune__exe__QCheck_ounit_test.Error` on `0 (after 30 shrink steps)` ------------------------------------------------------------------------------ ============================================================================== Error: tests:6:fail_check_err_message. Error: tests:6:fail_check_err_message (in the log). test `fail_check_err_message` failed on ≥ 1 cases: 0 (after 7 shrink steps) this will always fail ------------------------------------------------------------------------------ ============================================================================== Error: tests:4:neg test unexpected success. Error: tests:4:neg test unexpected success (in the log). negative test 'neg test unexpected success' succeeded unexpectedly ------------------------------------------------------------------------------ ============================================================================== Error: tests:1:fail_sort_id. Error: tests:1:fail_sort_id (in the log). test `fail_sort_id` failed on ≥ 1 cases: [1; 0] (after 16 shrink steps) ------------------------------------------------------------------------------ Ran: 8 tests in: seconds. FAILED: Cases: 8 Tried: 8 Errors: 2 Failures: 3 Skip: 0 Todo: 0 Timeouts: 0. qcheck-0.25/example/ounit/QCheck_ounit_test.expected.ocaml5.64000066400000000000000000000035121477416744200242550ustar00rootroot00000000000000.FE.FEF. ============================================================================== Error: tests:5:neg fail with error. Error: tests:5:neg fail with error (in the log). test `neg fail with error` raised exception `Dune__exe__QCheck_ounit_test.Error` on `0 (after 7 shrink steps)` ------------------------------------------------------------------------------ ============================================================================== Error: tests:2:error_raise_exn. Error: tests:2:error_raise_exn (in the log). test `error_raise_exn` raised exception `Dune__exe__QCheck_ounit_test.Error` on `0 (after 62 shrink steps)` ------------------------------------------------------------------------------ ============================================================================== Error: tests:6:fail_check_err_message. Error: tests:6:fail_check_err_message (in the log). test `fail_check_err_message` failed on ≥ 1 cases: 0 (after 7 shrink steps) this will always fail ------------------------------------------------------------------------------ ============================================================================== Error: tests:4:neg test unexpected success. Error: tests:4:neg test unexpected success (in the log). negative test 'neg test unexpected success' succeeded unexpectedly ------------------------------------------------------------------------------ ============================================================================== Error: tests:1:fail_sort_id. Error: tests:1:fail_sort_id (in the log). test `fail_sort_id` failed on ≥ 1 cases: [1; 0] (after 16 shrink steps) ------------------------------------------------------------------------------ Ran: 8 tests in: seconds. FAILED: Cases: 8 Tried: 8 Errors: 2 Failures: 3 Skip: 0 Todo: 0 Timeouts: 0. qcheck-0.25/example/ounit/QCheck_ounit_test.ml000066400000000000000000000036071477416744200214620ustar00rootroot00000000000000(* Tests to check integration with the 'OUnit2.test' interface *) let passing = QCheck.Test.make ~count:1000 ~name:"list_rev_is_involutive" QCheck.(list small_int) (fun l -> List.rev (List.rev l) = l);; let failing = QCheck.Test.make ~count:10 ~name:"fail_sort_id" QCheck.(list small_int) (fun l -> l = List.sort compare l);; exception Error let error = QCheck.Test.make ~count:10 ~name:"error_raise_exn" QCheck.int (fun _ -> raise Error) let simple_qcheck = QCheck.Test.make ~name:"fail_check_err_message" ~count: 100 QCheck.small_int (fun _ -> QCheck.Test.fail_reportf "@[this@ will@ always@ fail@]") let neg_test_failing_as_expected = QCheck.Test.make_neg ~name:"neg test pass (failing as expected)" QCheck.small_int (fun i -> i mod 2 = 0) let neg_test_unexpected_success = QCheck.Test.make_neg ~name:"neg test unexpected success" QCheck.small_int (fun i -> i + i = i * 2) let neg_test_error = QCheck.Test.make_neg ~name:"neg fail with error" QCheck.small_int (fun _i -> raise Error) type tree = Leaf of int | Node of tree * tree let leaf x = Leaf x let node x y = Node (x,y) let gen_tree = QCheck.Gen.(sized @@ fix (fun self n -> match n with | 0 -> map leaf nat | n -> frequency [1, map leaf nat; 2, map2 node (self (n/2)) (self (n/2))] )) let rec rev_tree = function | Node (x, y) -> Node (rev_tree y, rev_tree x) | Leaf x -> Leaf x let passing_tree_rev = QCheck.Test.make ~count:1000 ~name:"tree_rev_is_involutive" QCheck.(make gen_tree) (fun tree -> rev_tree (rev_tree tree) = tree) let () = Printexc.record_backtrace true; let open OUnit2 in run_test_tt_main ("tests" >::: List.map QCheck_ounit.to_ounit2_test [passing; failing; error; neg_test_failing_as_expected; neg_test_unexpected_success; neg_test_error; simple_qcheck; passing_tree_rev]) qcheck-0.25/example/ounit/QCheck_test.ml000066400000000000000000000030111477416744200202310ustar00rootroot00000000000000(* Tests to check integration with the 'OUnit.test' interface *) let (|>) x f = f x module Q = QCheck let passing = Q.Test.make ~count:1000 ~long_factor:2 ~name:"list_rev_is_involutive" Q.(list small_int) (fun l -> List.rev (List.rev l) = l);; let failing = Q.Test.make ~count:10 ~name:"should_fail_sort_id" Q.(small_list small_int) (fun l -> l = List.sort compare l);; exception Error let error = Q.Test.make ~count:10 ~name:"should_error_raise_exn" Q.int (fun _ -> raise Error) let neg_test_failing_as_expected = Q.Test.make_neg ~name:"neg test pass (failing as expected)" QCheck.small_int (fun i -> i mod 2 = 0) let neg_test_unexpected_success = Q.Test.make_neg ~name:"neg test unexpected success" QCheck.small_int (fun i -> i + i = i * 2) let neg_test_error = Q.Test.make_neg ~name:"neg fail with error" QCheck.small_int (fun _i -> raise Error) open OUnit let regression_23 = "issue_23" >:: (fun () -> let l = Q.Gen.(generate ~n:100_000 char) in OUnit.assert_bool "must contain '\255'" (List.exists (fun c->c = '\255') l) ) let regressions = [ regression_23 ] let others = [ passing; failing; error; neg_test_failing_as_expected; neg_test_unexpected_success; neg_test_error; ] |> List.map (fun t -> QCheck_ounit.to_ounit_test t) let suite = "tests" >::: (regressions @ others) let () = try exit (QCheck_ounit.run suite) with Arg.Bad msg -> print_endline msg; exit 1 | Arg.Help msg -> print_endline msg; exit 0 qcheck-0.25/example/ounit/dune000066400000000000000000000021371477416744200163700ustar00rootroot00000000000000(executables (names QCheck_ounit_test QCheck_test) (libraries ounit2 qcheck-ounit)) (rule (enabled_if (and (= %{arch_sixtyfour} true) (>= %{ocaml_version} 5))) (action (copy QCheck_ounit_test.expected.ocaml5.64 QCheck_ounit_test.expected))) (rule (enabled_if (and (= %{arch_sixtyfour} false) (>= %{ocaml_version} 5))) (action (copy QCheck_ounit_test.expected.ocaml5.32 QCheck_ounit_test.expected))) (rule (enabled_if (and (= %{arch_sixtyfour} true) (< %{ocaml_version} 5))) (action (copy QCheck_ounit_test.expected.ocaml4.64 QCheck_ounit_test.expected))) (rule (enabled_if (and (= %{arch_sixtyfour} false) (< %{ocaml_version} 5))) (action (copy QCheck_ounit_test.expected.ocaml4.32 QCheck_ounit_test.expected))) (rule (targets QCheck_ounit_test.output) (deps ./QCheck_ounit_test.exe) (enabled_if (= %{os_type} "Unix")) (action (with-accepted-exit-codes 1 (with-stdout-to %{targets} (run ./run_ounit.sh -runner=sequential -seed 1234))))) (rule (alias runtest) (package qcheck-ounit) (enabled_if (= %{os_type} "Unix")) (action (diff QCheck_ounit_test.expected QCheck_ounit_test.output))) qcheck-0.25/example/ounit/run_ounit.sh000077500000000000000000000005461477416744200200750ustar00rootroot00000000000000#!/usr/bin/env sh # custom script to run qcheck-ounit and filter non reproducible parts OUT=`./QCheck_ounit_test.exe $@` CODE=$? # remove non deterministic output echo "$OUT" \ | grep -v 'File .*, line .*' \ | grep -v 'Called from ' \ | grep -v 'Raised at ' \ | grep -v '(in the code)' \ | sed 's/in: .*seconds/in: seconds/' exit $CODE qcheck-0.25/ppx_deriving_qcheck.opam000066400000000000000000000014351477416744200176130ustar00rootroot00000000000000opam-version: "2.0" name: "ppx_deriving_qcheck" version: "0.7" license: "BSD-2-Clause" synopsis: "PPX Deriver for QCheck" maintainer: "valentin.chb@gmail.com" author: [ "the qcheck contributors" ] depends: [ "dune" {>= "2.8.0"} "ocaml" {>= "4.08.0"} "qcheck-core" {>= "0.24"} "ppxlib" {>= "0.36.0"} "ppx_deriving" {>= "6.1.0"} "odoc" {with-doc} "alcotest" {with-test & >= "1.4.0" } "qcheck-alcotest" {with-test & >= "0.24"} ] build: [ ["dune" "build" "-p" name "-j" jobs] ["dune" "build" "@doc" "-p" name "-j" jobs] {with-doc} ["dune" "runtest" "-p" name "-j" jobs] {with-test} ] homepage: "https://github.com/c-cube/qcheck/" bug-reports: "https://github.com/c-cube/qcheck/-/issues" dev-repo: "git+https://github.com/c-cube/qcheck.git" x-maintenance-intent: ["(latest)"] qcheck-0.25/qcheck-alcotest.opam000066400000000000000000000014121477416744200166440ustar00rootroot00000000000000opam-version: "2.0" maintainer: "simon.cruanes.2007@m4x.org" author: [ "the qcheck contributors" ] homepage: "https://github.com/c-cube/qcheck/" license: "BSD-2-Clause" synopsis: "Alcotest backend for qcheck" doc: ["http://c-cube.github.io/qcheck/"] version: "0.25" tags: [ "test" "quickcheck" "qcheck" "alcotest" ] build: [ ["dune" "build" "-p" name "-j" jobs] ["dune" "build" "@doc" "-p" name "-j" jobs] {with-doc} ["dune" "runtest" "-p" name "-j" jobs] {with-test} ] depends: [ "dune" { >= "2.8.0" } "base-unix" "qcheck-core" { = version } "alcotest" {>= "1.2.0"} "odoc" {with-doc} "ocaml" {>= "4.08.0"} ] dev-repo: "git+https://github.com/c-cube/qcheck.git" bug-reports: "https://github.com/c-cube/qcheck/issues" x-maintenance-intent: ["(latest)"] qcheck-0.25/qcheck-core.opam000066400000000000000000000014121477416744200157560ustar00rootroot00000000000000opam-version: "2.0" maintainer: "simon.cruanes.2007@m4x.org" author: [ "the qcheck contributors" ] homepage: "https://github.com/c-cube/qcheck/" license: "BSD-2-Clause" synopsis: "Core qcheck library" doc: ["http://c-cube.github.io/qcheck/"] version: "0.25" tags: [ "test" "property" "quickcheck" ] build: [ ["dune" "build" "-p" name "-j" jobs] ["dune" "build" "@doc" "-p" name "-j" jobs] {with-doc} ["dune" "runtest" "-p" name "-j" jobs] {with-test} ] depends: [ "dune" { >= "2.8.0" } "base-unix" "alcotest" {with-test & >= "1.2.0"} "odoc" {with-doc} "ocaml" {>= "4.08.0"} ] dev-repo: "git+https://github.com/c-cube/qcheck.git" x-maintenance-intent: ["(latest)"] bug-reports: "https://github.com/c-cube/qcheck/issues" conflicts: [ "ounit" { < "2.0" } ] qcheck-0.25/qcheck-ounit.opam000066400000000000000000000013541477416744200161710ustar00rootroot00000000000000opam-version: "2.0" maintainer: "simon.cruanes.2007@m4x.org" author: [ "the qcheck contributors" ] license: "BSD-2-Clause" homepage: "https://github.com/c-cube/qcheck/" doc: ["http://c-cube.github.io/qcheck/"] synopsis: "OUnit backend for qcheck" version: "0.25" tags: [ "qcheck" "quickcheck" "ounit" ] build: [ ["dune" "build" "-p" name "-j" jobs] ["dune" "build" "@doc" "-p" name "-j" jobs] {with-doc} ["dune" "runtest" "-p" name "-j" jobs] {with-test} ] depends: [ "dune" { >= "2.8.0" } "base-unix" "qcheck-core" { = version } "ounit2" "odoc" {with-doc} "ocaml" {>= "4.08.0"} ] dev-repo: "git+https://github.com/c-cube/qcheck.git" x-maintenance-intent: ["(latest)"] bug-reports: "https://github.com/c-cube/qcheck/issues" qcheck-0.25/qcheck.opam000066400000000000000000000015241477416744200150340ustar00rootroot00000000000000opam-version: "2.0" maintainer: "simon.cruanes.2007@m4x.org" author: [ "the qcheck contributors" ] synopsis: "Compatibility package for qcheck" homepage: "https://github.com/c-cube/qcheck/" license: "BSD-2-Clause" doc: ["http://c-cube.github.io/qcheck/"] version: "0.25" tags: [ "test" "property" "quickcheck" ] build: [ ["dune" "build" "-p" name "-j" jobs] ["dune" "build" "@doc" "-p" name "-j" jobs] {with-doc} ["dune" "runtest" "-p" name "-j" jobs] {with-test} ] depends: [ "dune" { >= "2.8.0" } "base-unix" "qcheck-core" { = version } "qcheck-ounit" { = version } "alcotest" {with-test & >= "1.2.0"} "odoc" {with-doc} "ocaml" {>= "4.08.0"} ] dev-repo: "git+https://github.com/c-cube/qcheck.git" x-maintenance-intent: ["(latest)"] bug-reports: "https://github.com/c-cube/qcheck/issues" conflicts: [ "ounit" { < "2.0" } ] qcheck-0.25/src/000077500000000000000000000000001477416744200135055ustar00rootroot00000000000000qcheck-0.25/src/QCheck_runner.ml000066400000000000000000000000611477416744200165630ustar00rootroot00000000000000 include QCheck_base_runner include QCheck_ounit qcheck-0.25/src/alcotest/000077500000000000000000000000001477416744200153235ustar00rootroot00000000000000qcheck-0.25/src/alcotest/QCheck_alcotest.ml000066400000000000000000000030121477416744200207050ustar00rootroot00000000000000 module Q = QCheck2 module T = QCheck2.Test module Raw = QCheck_base_runner.Raw let seed_ = lazy ( let s = try int_of_string @@ Sys.getenv "QCHECK_SEED" with _ -> Random.self_init(); Random.int 1_000_000_000 in Printf.printf "qcheck random seed: %d\n%!" s; s ) let default_rand () = (* random seed, for repeatability of tests *) Random.State.make [| Lazy.force seed_ |] let verbose_ = lazy ( match Sys.getenv "QCHECK_VERBOSE" with | "1" | "true" -> true | _ -> false | exception Not_found -> false ) let long_ = lazy ( match Sys.getenv "QCHECK_LONG" with | "1" | "true" -> true | _ -> false | exception Not_found -> false ) let to_alcotest ?(colors=false) ?(verbose=Lazy.force verbose_) ?(long=Lazy.force long_) ?(debug_shrink = None) ?debug_shrink_list ?(speed_level = `Slow) ?(rand=default_rand()) (t:T.t) = let T.Test cell = t in let handler name cell r = match r, debug_shrink with | QCheck2.Test.Shrunk (step, x), Some out -> let go = match debug_shrink_list with | None -> true | Some test_list -> List.mem name test_list in if not go then () else QCheck_base_runner.debug_shrinking_choices ~colors ~out ~name cell ~step x | _ -> () in let print = Raw.print_std in let name = T.get_name cell in let run () = let call = Raw.callback ~colors ~verbose ~print_res:true ~print in T.check_cell_exn ~long ~call ~handler ~rand cell in ((name, speed_level, run) : unit Alcotest.test_case) qcheck-0.25/src/alcotest/QCheck_alcotest.mli000066400000000000000000000023711477416744200210650ustar00rootroot00000000000000 (** {1 Alcotest backend for QCheck} We use environment variables for controlling QCheck here, since alcotest doesn't seem to provide a lot of flexibility. - [QCHECK_VERBOSE] if "1" or "true", will make tests verbose - [QCHECK_SEED] if an integer, will fix the seed - [QCHECK_LONG] is present, will trigger long tests @since 0.9 *) val to_alcotest : ?colors:bool -> ?verbose:bool -> ?long:bool -> ?debug_shrink:(out_channel option) -> ?debug_shrink_list:(string list) -> ?speed_level:Alcotest.speed_level -> ?rand:Random.State.t -> QCheck2.Test.t -> unit Alcotest.test_case (** Convert a qcheck test into an alcotest test. The optional [speed_level] is [`Slow] by default, meaning Alcotest can skip such a test when the [-q] flag is passed. Passing [`Quick] instead means the test is always run. In addition to [speed_level] and the environment variables mentioned above, you can control the behavior of QCheck tests using optional parameters that behave in the same way as the parameters of {!QCheck_base_runner.run_tests}. @since 0.9 @since 0.9 parameters [verbose], [long], [rand] @since 0.19 parameters [colors], [debug_shrink], [debug_shrink_list] @since 0.24 parameter [speed_level] *) qcheck-0.25/src/alcotest/dune000066400000000000000000000003241477416744200162000ustar00rootroot00000000000000 (library (name qcheck_alcotest) (public_name qcheck-alcotest) (wrapped false) (libraries unix qcheck-core qcheck-core.runner alcotest) (flags :standard -w +a-4-42-44-48-50-58-32-60@8 -safe-string) ) qcheck-0.25/src/core/000077500000000000000000000000001477416744200144355ustar00rootroot00000000000000qcheck-0.25/src/core/QCheck.ml000066400000000000000000001662511477416744200161400ustar00rootroot00000000000000(* QCheck: Random testing for OCaml copyright (c) 2013-2017, Guillaume Bury, Simon Cruanes, Vincent Hugot, Jan Midtgaard all rights reserved. *) (** {1 Quickcheck inspired property-based testing} *) let poly_compare=compare module RS = struct (* Poor man's splitter for version < 5.0 *) (* This definition is shadowed by the [include] on OCaml >=5.0 *) (* For the record, this is a hack: Seeding a child RNG based on the output of a parent RNG does not create an independent RNG. As an added bonus, performance is bad. *) let split rs = let bits = Random.State.bits rs in let rs' = Random.State.make [|bits|] in rs' include Random.State (* This is how OCaml 5.0 splits: *) (* Split a new PRNG off the given PRNG *) (* let split s = let i1 = bits64 s in let i2 = bits64 s in let i3 = bits64 s in let i4 = bits64 s in mk i1 i2 i3 i4 *) end let (|>) x f = f x let rec foldn ~f ~init:acc i = if i = 0 then acc else foldn ~f ~init:(f acc i) (i-1) let _is_some = function Some _ -> true | None -> false let _opt_map_or ~d ~f = function | None -> d | Some x -> f x let _opt_or a b = match a with | None -> b | Some x -> x let _opt_map ~f = function | None -> None | Some x -> Some (f x) let _opt_map_2 ~f a b = match a, b with | Some x, Some y -> Some (f x y) | _ -> None let _opt_map_3 ~f a b c = match a, b, c with | Some x, Some y, Some z -> Some (f x y z) | _ -> None let _opt_map_4 ~f a b c d = match a, b, c, d with | Some x, Some y, Some z, Some w -> Some (f x y z w) | _ -> None let _opt_map_5 ~f a b c d e = match a, b, c, d, e with | Some x, Some y, Some z, Some u, Some v -> Some (f x y z u v) | _ -> None let _opt_map_6 ~f a b c d e g = match a, b, c, d, e, g with | Some a, Some b, Some c, Some d, Some e, Some g -> Some (f a b c d e g) | _ -> None let _opt_map_7 ~f a b c d e g h = match a, b, c, d, e, g, h with | Some a, Some b, Some c, Some d, Some e, Some g, Some h -> Some (f a b c d e g h) | _ -> None let _opt_map_8 ~f a b c d e g h i = match a, b, c, d, e, g, h, i with | Some a, Some b, Some c, Some d, Some e, Some g, Some h, Some i -> Some (f a b c d e g h i) | _ -> None 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 | Some a, Some b, Some c, Some d, Some e, Some g, Some h, Some i, Some j -> Some (f a b c d e g h i j) | _ -> None let _opt_sum a b = match a, b with | Some _, _ -> a | None, _ -> b let sum_int = List.fold_left (+) 0 (* Included for backwards compatibility, pre 4.13 *) let string_fold_right f s acc = let len = String.length s in let rec loop i acc = if i<0 then acc else loop (i-1) (f s.[i] acc) in loop (len-1) acc exception No_example_found of string (* raised if an example failed to be found *) let assume = QCheck2.assume let assume_fail = QCheck2.assume_fail let (==>) = QCheck2.(==>) module Gen = struct type 'a t = RS.t -> 'a type 'a sized = int -> Random.State.t -> 'a let return x _st = x let pure = return let (>>=) gen f st = f (gen st) st let (<*>) f x st = f st (x st) let map f x st = f (x st) let map2 f x y st = f (x st) (y st) let map3 f x y z st = f (x st) (y st) (z st) let map4 f x y z v st = f (x st) (y st) (z st) (v st) let map5 f x y z v w st = f (x st) (y st) (z st) (v st) (w st) let map_keep_input f gen st = let x = gen st in x, f x let (>|=) x f st = f (x st) let (<$>) f x st = f (x st) let oneof l st = List.nth l (Random.State.int st (List.length l)) st let oneofl xs st = List.nth xs (Random.State.int st (List.length xs)) let oneofa xs st = Array.get xs (Random.State.int st (Array.length xs)) let frequencyl l st = let sums = sum_int (List.map fst l) in let i = Random.State.int st sums in let rec aux acc = function | ((x,g)::xs) -> if i < acc+x then g else aux (acc+x) xs | _ -> failwith "frequency" in aux 0 l let frequencya a = frequencyl (Array.to_list a) let frequency l st = frequencyl l st st let small_nat st = let p = RS.float st 1. in if p < 0.75 then RS.int st 10 else RS.int st 100 (* natural number generator *) let nat st = let p = RS.float st 1. in if p < 0.5 then RS.int st 10 else if p < 0.75 then RS.int st 100 else if p < 0.95 then RS.int st 1_000 else RS.int st 10_000 let big_nat st = let p = RS.float st 1. in if p < 0.75 then nat st else RS.int st 1_000_000 let unit _st = () let bool st = RS.bool st let float st = exp (RS.float st 15. *. (if RS.float st 1. < 0.5 then 1. else -1.)) *. (if RS.float st 1. < 0.5 then 1. else -1.) let pfloat st = abs_float (float st) let nfloat st = -.(pfloat st) let float_bound_inclusive bound st = RS.float st bound let float_bound_exclusive bound st = match bound with | 0. -> raise (Invalid_argument "Gen.float_bound_exclusive") | b_pos when bound > 0. -> RS.float st (b_pos -. epsilon_float) | b_neg -> RS.float st (b_neg +. epsilon_float) let float_range low high = if high < low || high -. low > max_float then invalid_arg "Gen.float_range"; fun st -> low +. (float_bound_inclusive (high -. low) st) let (--.) = float_range let exponential mean = if Float.is_nan mean then invalid_arg "Gen.exponential"; let unit_gen = float_bound_inclusive 1.0 in map (fun p -> -. mean *. (log p)) unit_gen (* See https://en.wikipedia.org/wiki/Relationships_among_probability_distributions *) let neg_int st = -(nat st) let option ?(ratio = 0.85) f st = let p = RS.float st 1. in if p < (1.0 -. ratio) then None else Some (f st) let opt = option let result ?(ratio = 0.75) vg eg st = let p = RS.float st 1. in if p < (1.0 -. ratio) then Error (eg st) else Ok (vg st) (* Uniform random int generator *) let pint = if Sys.word_size = 32 then fun st -> RS.bits st else (* word size = 64 *) fun st -> (* Technically we could write [3] but this is clearer *) let two_bits_mask = 0b11 in (* Top 2 bits *) let left = ((RS.bits st land two_bits_mask) lsl 60) in (* Middle 30 bits *) let middle = (RS.bits st lsl 30) in (* Bottom 30 bits *) let right = RS.bits st in left lor middle lor right let int st = if RS.bool st then - (pint st) - 1 else pint st let int_bound n = if n < 0 then invalid_arg "Gen.int_bound"; if n <= (1 lsl 30) - 2 then fun st -> Random.State.int st (n + 1) else fun st -> let r = pint st in r mod (n + 1) let int_range a b = if b < a then invalid_arg "Gen.int_range"; if a >= 0 || b < 0 then ( (* range smaller than max_int *) assert (b-a >= 0); fun st -> a + (int_bound (b-a) st) ) else ( (* range potentially bigger than max_int: we split on 0 and choose the itv wrt to their size ratio *) fun st -> let f_a = float_of_int a in let ratio = (-.f_a) /. (1. +. float_of_int b -. f_a) in if Random.State.float st 1. <= ratio then - (int_bound (- (a+1)) st) - 1 else int_bound b st ) let (--) = int_range (* NOTE: we keep this alias to not break code that uses [small_int] for sizes of strings, arrays, etc. *) let small_int = small_nat let small_signed_int st = if bool st then small_nat st else - (small_nat st) let char_range a b = map Char.chr (Char.code a -- Char.code b) let random_binary_string st length = (* 0b011101... *) let s = Bytes.create (length + 2) in Bytes.set s 0 '0'; Bytes.set s 1 'b'; for i = 0 to length - 1 do Bytes.set s (i+2) (if RS.bool st then '0' else '1') done; Bytes.unsafe_to_string s let int32 st = Int32.of_string (random_binary_string st 32) let int64 st = Int64.of_string (random_binary_string st 64) let ui32 = int32 let ui64 = int64 let list_size size gen st = foldn ~f:(fun acc _ -> (gen st)::acc) ~init:[] (size st) let list gen st = list_size nat gen st let list_repeat n g = list_size (return n) g let array_size size gen st = Array.init (size st) (fun _ -> gen st) let array gen st = array_size nat gen st let array_repeat n g = array_size (return n) g let flatten_l l st = List.map (fun f->f st) l let flatten_a a st = Array.map (fun f->f st) a let flatten_opt o st = match o with | None -> None | Some f -> Some (f st) let flatten_res r st = match r with | Ok f -> Ok (f st) | Error e -> Error e let shuffle_a a st = for i = Array.length a-1 downto 1 do let j = Random.State.int st (i+1) in let tmp = a.(i) in a.(i) <- a.(j); a.(j) <- tmp; done let shuffle_l l st = let a = Array.of_list l in shuffle_a a st; Array.to_list a let shuffle_w_l l st = let sample (w, v) = let fl_w = float_of_int w in (float_bound_inclusive 1. st ** (1. /. fl_w), v) in let samples = List.rev_map sample l in List.sort (fun (w1, _) (w2, _) -> poly_compare w1 w2) samples |> List.rev_map snd let range_subset ~size low high st = let range_size = high - low + 1 in if not (0 <= size && size <= range_size) then invalid_arg "Gen.range_subset"; (* The algorithm below is attributed to Floyd, see for example https://eyalsch.wordpress.com/2010/04/01/random-sample/ https://math.stackexchange.com/questions/178690 Note: the code is easier to read when drawing from [0..range_size-1] rather than [low..high]. We draw in [0..bound], and shift the results by adding [low] when writing them to the result array. *) let module ISet = Set.Make(Int) in let s = ref ISet.empty in for i = range_size - size to range_size - 1 do let pos = int_range 0 i st in let choice = if ISet.mem pos !s then i else pos in s := ISet.add choice !s; done; let arr = Array.make size 0 in let idx = ref 0 in ISet.iter (fun choice -> arr.(!idx) <- low + choice; incr idx) !s; arr let array_subset size arr st = range_subset ~size 0 (Array.length arr - 1) st |> Array.map (fun i -> arr.(i)) let pair g1 g2 st = (g1 st, g2 st) let triple g1 g2 g3 st = (g1 st, g2 st, g3 st) let quad g1 g2 g3 g4 st = (g1 st, g2 st, g3 st, g4 st) let char st = char_of_int (RS.int st 256) let tup2 = pair let tup3 = triple let tup4 = quad let tup5 (g1 : 'a t) (g2 : 'b t) (g3 : 'c t) (g4 : 'd t) (g5 : 'e t) : ('a * 'b * 'c * 'd * 'e) t = (fun a b c d e -> (a, b, c, d, e)) <$> g1 <*> g2 <*> g3 <*> g4 <*> g5 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 = (fun a b c d e f -> (a, b, c, d, e, f)) <$> g1 <*> g2 <*> g3 <*> g4 <*> g5 <*> g6 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 = (fun a b c d e f g -> (a, b, c, d, e, f, g)) <$> g1 <*> g2 <*> g3 <*> g4 <*> g5 <*> g6 <*> g7 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 = (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 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 = (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 let printable_chars = let l = 126-32+1 in let s = Bytes.create l in for i = 0 to l-2 do Bytes.set s i (char_of_int (32+i)) done; Bytes.set s (l-1) '\n'; Bytes.unsafe_to_string s let printable st = printable_chars.[RS.int st (String.length printable_chars)] let numeral st = char_of_int (48 + RS.int st 10) let bytes_size ?(gen = char) size st = let s = Bytes.create (size st) in for i = 0 to Bytes.length s - 1 do Bytes.set s i (gen st) done; s let string_size ?(gen = char) size st = let s = bytes_size ~gen size st in Bytes.unsafe_to_string s let bytes ?gen st = bytes_size ?gen nat st let string ?gen st = string_size ?gen nat st let bytes_of gen = bytes_size ~gen nat let string_of gen = string_size ~gen nat let bytes_printable = bytes_size ~gen:printable nat let string_printable = string_size ~gen:printable nat let string_readable = string_printable let bytes_small st = bytes_size small_nat st let bytes_small_of gen st = bytes_size ~gen small_nat st let small_string ?gen st = string_size ?gen small_nat st let small_list gen = list_size small_nat gen let small_array gen = array_size small_nat gen let string_small st = string_size small_nat st let string_small_of gen st = string_size ~gen small_nat st let join g st = (g st) st (* corner cases *) let graft_corners gen corners () = let cors = ref corners in fun st -> match !cors with [] -> gen st | e::l -> cors := l; e let int_pos_corners = [0;1;2;max_int] let int_corners = int_pos_corners @ [min_int] let nng_corners () = graft_corners nat int_pos_corners () (* sized, fix *) let sized_size s f st = f (s st) st let sized f = sized_size nat f let fix f = let rec f' n st = f f' n st in f' (* nat splitting *) let pos_split2 n st = if (n < 2) then invalid_arg "pos_split2"; let n1 = int_range 1 (n - 1) st in (n1, n - n1) let nat_split2 n st = if (n < 0) then invalid_arg "nat_split2"; let n1 = int_range 0 n st in (n1, n - n1) let pos_split ~size:k n st = if (n < 0) then invalid_arg "pos_split"; if 0 = k && 0 = n then [||] else begin if not (0 < k && k <= n) then invalid_arg "pos_split"; (* To split n into n{0}+n{1}+..+n{k-1}, we draw distinct "boundaries" b{-1}..b{k-1}, with b{-1}=0 and b{k-1} = n and the k-1 intermediate boundaries b{0}..b{k-2} chosen randomly distinct in [1;n-1]. Then each n{i} is defined as b{i}-b{i-1}. *) let b = range_subset ~size:(k-1) 1 (n - 1) st in if k = 1 then [|n|] else Array.init k (fun i -> if i = 0 then b.(0) else if i = k-1 then n - b.(i-1) else b.(i) - b.(i-1) ) end let nat_split ~size:k n st = if not (0 <= k && 0 <= n) then invalid_arg "nat_split"; pos_split ~size:k (n+k) st |> Array.map (fun v -> v - 1) let generate ?(rand=Random.State.make_self_init()) ~n g = list_repeat n g rand let generate1 ?(rand=Random.State.make_self_init()) g = g rand let delay f st = f () st let (let+) = (>|=) let (and+) = pair let (let*) = (>>=) let (and*) = pair end module Print = struct type 'a t = 'a -> string let unit _ = "()" let int = string_of_int let int32 i = Int32.to_string i ^ "l" let int64 i = Int64.to_string i ^ "L" let bool = string_of_bool let float = string_of_float let string s = Printf.sprintf "%S" s let bytes b = string (Bytes.to_string b) let char c = Printf.sprintf "%C" c let option f = function | None -> "None" | Some x -> "Some (" ^ f x ^ ")" let result vp ep = function | Error e -> "Error (" ^ ep e ^ ")" | Ok v -> "Ok (" ^ vp v ^ ")" let pair a b (x,y) = Printf.sprintf "(%s, %s)" (a x) (b y) let triple a b c (x,y,z) = Printf.sprintf "(%s, %s, %s)" (a x) (b y) (c z) let quad a b c d (x,y,z,w) = Printf.sprintf "(%s, %s, %s, %s)" (a x) (b y) (c z) (d w) let default = fun _ -> "" let tup2 p_a p_b (a, b) = Printf.sprintf "(%s, %s)" (p_a a) (p_b b) let tup2_opt p_a p_b (a, b) = let p_a = Option.value ~default p_a in let p_b = Option.value ~default p_b in tup2 p_a p_b (a, b) let tup3 p_a p_b (p_c) (a, b, c) = Printf.sprintf "(%s, %s, %s)" (p_a a) (p_b b) (p_c c) let tup3_opt p_a p_b p_c (a, b, c) = let p_a = Option.value ~default p_a in let p_b = Option.value ~default p_b in let p_c = Option.value ~default p_c in tup3 p_a p_b p_c (a, b, c) let tup4 p_a p_b p_c p_d (a, b, c, d) = Printf.sprintf "(%s, %s, %s, %s)" (p_a a) (p_b b) (p_c c) (p_d d) let tup4_opt p_a p_b p_c p_d (a, b, c, d) = let p_a = Option.value ~default p_a in let p_b = Option.value ~default p_b in let p_c = Option.value ~default p_c in let p_d = Option.value ~default p_d in tup4 p_a p_b p_c p_d (a, b, c, d) let tup5 p_a p_b p_c p_d p_e (a, b, c, d, e) = Printf.sprintf "(%s, %s, %s, %s, %s)" (p_a a) (p_b b) (p_c c) (p_d d) (p_e e) let tup5_opt p_a p_b p_c p_d p_e (a, b, c, d, e) = let p_a = Option.value ~default p_a in let p_b = Option.value ~default p_b in let p_c = Option.value ~default p_c in let p_d = Option.value ~default p_d in let p_e = Option.value ~default p_e in tup5 p_a p_b p_c p_d p_e (a, b, c, d, e) let tup6 p_a p_b p_c p_d p_e p_f (a, b, c, d, e, f) = Printf.sprintf "(%s, %s, %s, %s, %s, %s)" (p_a a) (p_b b) (p_c c) (p_d d) (p_e e) (p_f f) let tup6_opt p_a p_b p_c p_d p_e p_f (a, b, c, d, e, f) = let p_a = Option.value ~default p_a in let p_b = Option.value ~default p_b in let p_c = Option.value ~default p_c in let p_d = Option.value ~default p_d in let p_e = Option.value ~default p_e in let p_f = Option.value ~default p_f in tup6 p_a p_b p_c p_d p_e p_f (a, b, c, d, e, f) let tup7 p_a p_b p_c p_d p_e p_f p_g (a, b, c, d, e, f, g) = Printf.sprintf "(%s, %s, %s, %s, %s, %s, %s)" (p_a a) (p_b b) (p_c c) (p_d d) (p_e e) (p_f f) (p_g g) let tup7_opt p_a p_b p_c p_d p_e p_f p_g (a, b, c, d, e, f, g) = let p_a = Option.value ~default p_a in let p_b = Option.value ~default p_b in let p_c = Option.value ~default p_c in let p_d = Option.value ~default p_d in let p_e = Option.value ~default p_e in let p_f = Option.value ~default p_f in let p_g = Option.value ~default p_g in tup7 p_a p_b p_c p_d p_e p_f p_g (a, b, c, d, e, f, g) 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) = Printf.sprintf "(%s, %s, %s, %s, %s, %s, %s, %s)" (p_a a) (p_b b) (p_c c) (p_d d) (p_e e) (p_f f) (p_g g) (p_h h) 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) = let p_a = Option.value ~default p_a in let p_b = Option.value ~default p_b in let p_c = Option.value ~default p_c in let p_d = Option.value ~default p_d in let p_e = Option.value ~default p_e in let p_f = Option.value ~default p_f in let p_g = Option.value ~default p_g in let p_h = Option.value ~default p_h in 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) 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) = Printf.sprintf "(%s, %s, %s, %s, %s, %s, %s, %s, %s)" (p_a a) (p_b b) (p_c c) (p_d d) (p_e e) (p_f f) (p_g g) (p_h h) (p_i i) 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) = let p_a = Option.value ~default p_a in let p_b = Option.value ~default p_b in let p_c = Option.value ~default p_c in let p_d = Option.value ~default p_d in let p_e = Option.value ~default p_e in let p_f = Option.value ~default p_f in let p_g = Option.value ~default p_g in let p_h = Option.value ~default p_h in let p_i = Option.value ~default p_i in 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) let list pp l = let b = Buffer.create 25 in Buffer.add_char b '['; List.iteri (fun i x -> if i > 0 then Buffer.add_string b "; "; Buffer.add_string b (pp x)) l; Buffer.add_char b ']'; Buffer.contents b let array pp a = let b = Buffer.create 25 in Buffer.add_string b "[|"; Array.iteri (fun i x -> if i > 0 then Buffer.add_string b "; "; Buffer.add_string b (pp x)) a; Buffer.add_string b "|]"; Buffer.contents b let comap f p x = p (f x) end module Iter = struct type 'a t = ('a -> unit) -> unit let empty _ = () let return x yield = yield x let (<*>) a b yield = a (fun f -> b (fun x -> yield (f x))) let (>>=) a f yield = a (fun x -> f x yield) let map f a yield = a (fun x -> yield (f x)) let map2 f a b yield = a (fun x -> b (fun y -> yield (f x y))) let (>|=) a f = map f a let append a b yield = a yield; b yield let append_l l yield = List.iter (fun s->s yield) l let flatten s yield = s (fun sub -> sub yield) let filter f s yield = s (fun x -> if f x then yield x) let (<+>) = append let of_list l yield = List.iter yield l let of_array a yield = Array.iter yield a let pair a b yield = a (fun x -> b(fun y -> yield (x,y))) let triple a b c yield = a (fun x -> b (fun y -> c (fun z -> yield (x,y,z)))) let quad a b c d yield = a (fun x -> b (fun y -> c (fun z -> d (fun w -> yield (x,y,z,w))))) exception IterExit let find_map p iter = let r = ref None in (try iter (fun x -> match p x with Some _ as y -> r := y; raise IterExit | None -> ()) with IterExit -> () ); !r let find p iter = find_map (fun x->if p x then Some x else None) iter let (let+) = (>|=) let (and+) = pair let (let*) = (>>=) let (and*) = pair end module Shrink = struct type 'a t = 'a -> 'a Iter.t let nil _ = Iter.empty let unit = nil let bool b = if b then Iter.return false else Iter.empty (* balanced shrinker for integers (non-exhaustive) *) let int x yield = let y = ref x in (* try some divisors *) while !y < -2 || !y >2 do y := !y / 2; yield (x - !y); done; (* fast path *) if x = 1 || (x>0 && !y <> 1) then yield (x-1); if x = -1 || (x<0 && !y <> -1) then yield (x+1); () let int32 x yield = let open Int32 in let y = ref x in (* try some divisors *) while !y < -2l || !y > 2l do y := div !y 2l; yield (sub x !y); done; (* fast path *) if x = 1l || (x>0l && !y <> 1l) then yield (pred x); if x = -1l || (x<0l && !y <> -1l) then yield (succ x); () let int64 x yield = let open Int64 in let y = ref x in (* try some divisors *) while !y < -2L || !y > 2L do y := div !y 2L; yield (sub x !y); done; (* fast path *) if x = 1L || (x>0L && !y <> 1L) then yield (pred x); if x = -1L || (x<0L && !y <> -1L) then yield (succ x); () (* aggressive shrinker for integers, get from 0 to x, by dichotomy or just enumerating smaller values *) let int_aggressive x yield = let y = ref x in while !y < -2 || !y >2 do y := !y / 2; yield (x - !y); done; (* fast path *) if x>0 then for i=x-1 downto 0 do yield i done; if x<0 then for i=x+1 to 0 do yield i done let filter f shrink x = Iter.filter f (shrink x) let char_generic target c = if c = target then Iter.empty else let c_code = Char.code c in let target_code = Char.code target in Iter.map (fun diff -> Char.chr (target_code + diff)) (int (c_code - target_code)) let char = char_generic 'a' let char_numeral = char_generic '0' let char_printable = function | '\n' -> char '~' (* treat '\n' (10) as '~' (126) to ensure a non-trivial, printable output *) | c -> char c let option s x = match x with | None -> Iter.empty | Some x -> Iter.(return None <+> map (fun y->Some y) (s x)) let result vs es x = match x with | Error e -> Iter.map (fun e -> Error e) (es e) | Ok v -> Iter.map (fun v -> Ok v) (vs v) let array ?shrink a yield = let n = Array.length a in let chunk_size = ref n in while !chunk_size > 0 do for i=0 to n - !chunk_size do (* remove elements in [i .. i+!chunk_size] *) let a' = Array.init (n - !chunk_size) (fun j -> if j< i then a.(j) else a.(j + !chunk_size)) in yield a' done; chunk_size := !chunk_size / 2; done; match shrink with | None -> () | Some f -> (* try to shrink each element of the array *) for i = 0 to Array.length a - 1 do f a.(i) (fun x -> let b = Array.copy a in b.(i) <- x; yield b ) done let rec list_spine l yield = let rec split l len acc = match len,l with | _,[] | 0,_ -> List.rev acc, l | _,x::xs -> split xs (len-1) (x::acc) in match l with | [] -> () | [_] -> yield [] | [x;y] -> yield []; yield [x]; if (try x <> y with Invalid_argument _ -> x != y) then yield [y] | _::_ -> let len = List.length l in let xs,ys = split l ((1 + len) / 2) [] in yield xs; list_spine xs (fun xs' -> yield (xs'@ys)) let list_elems shrink l yield = (* try to shrink each element of the list *) let rec elem_loop rev_prefix suffix = match suffix with | [] -> () | x::xs -> shrink x (fun x' -> yield (List.rev_append rev_prefix (x'::xs))); elem_loop (x::rev_prefix) xs in elem_loop [] l let list ?shrink l yield = list_spine l yield; match shrink with | None -> () | Some shrink -> list_elems shrink l yield let string ?(shrink = char) s yield = let buf = Buffer.create 42 in list ~shrink (string_fold_right (fun c acc -> c::acc) s []) (fun cs -> List.iter (fun c -> Buffer.add_char buf c) cs; let s = Buffer.contents buf in Buffer.clear buf; yield s) let bytes ?(shrink = char) b = Iter.map Bytes.of_string (string ~shrink (Bytes.to_string b)) let pair a b (x,y) yield = a x (fun x' -> yield (x',y)); b y (fun y' -> yield (x,y')) let triple a b c (x,y,z) yield = a x (fun x' -> yield (x',y,z)); b y (fun y' -> yield (x,y',z)); c z (fun z' -> yield (x,y,z')) let quad a b c d (x,y,z,w) yield = a x (fun x' -> yield (x',y,z,w)); b y (fun y' -> yield (x,y',z,w)); c z (fun z' -> yield (x,y,z',w)); d w (fun w' -> yield (x,y,z,w')) let default = nil let tup2 = pair let tup2_opt a b = let a = Option.value ~default a in let b = Option.value ~default b in tup2 a b let tup3 = triple let tup3_opt a b c = let a = Option.value ~default a in let b = Option.value ~default b in let c = Option.value ~default c in tup3 a b c let tup4 = quad let tup4_opt a b c d = let a = Option.value ~default a in let b = Option.value ~default b in let c = Option.value ~default c in let d = Option.value ~default d in tup4 a b c d let tup5 a b c d e (a', b', c', d', e') yield = a a' (fun x -> yield (x,b',c',d',e')); b b' (fun x -> yield (a',x,c',d',e')); c c' (fun x -> yield (a',b',x,d',e')); d d' (fun x -> yield (a',b',c',x,e')); e e' (fun x -> yield (a',b',c',d',x)) let tup5_opt a b c d e = let a = Option.value ~default a in let b = Option.value ~default b in let c = Option.value ~default c in let d = Option.value ~default d in let e = Option.value ~default e in tup5 a b c d e let tup6 a b c d e f (a', b', c', d', e', f') yield = a a' (fun x -> yield (x,b',c',d',e',f')); b b' (fun x -> yield (a',x,c',d',e',f')); c c' (fun x -> yield (a',b',x,d',e',f')); d d' (fun x -> yield (a',b',c',x,e',f')); e e' (fun x -> yield (a',b',c',d',x,f')); f f' (fun x -> yield (a',b',c',d',e',x)) let tup6_opt a b c d e f = let a = Option.value ~default a in let b = Option.value ~default b in let c = Option.value ~default c in let d = Option.value ~default d in let e = Option.value ~default e in let f = Option.value ~default f in tup6 a b c d e f let tup7 a b c d e f g (a', b', c', d', e', f', g') yield = a a' (fun x -> yield (x,b',c',d',e',f',g')); b b' (fun x -> yield (a',x,c',d',e',f',g')); c c' (fun x -> yield (a',b',x,d',e',f',g')); d d' (fun x -> yield (a',b',c',x,e',f',g')); e e' (fun x -> yield (a',b',c',d',x,f',g')); f f' (fun x -> yield (a',b',c',d',e',x,g')); g g' (fun x -> yield (a',b',c',d',e',f',x)) let tup7_opt a b c d e f g = let a = Option.value ~default a in let b = Option.value ~default b in let c = Option.value ~default c in let d = Option.value ~default d in let e = Option.value ~default e in let f = Option.value ~default f in let g = Option.value ~default g in tup7 a b c d e f g let tup8 a b c d e f g h (a', b', c', d', e', f', g', h') yield = a a' (fun x -> yield (x,b',c',d',e',f',g',h')); b b' (fun x -> yield (a',x,c',d',e',f',g',h')); c c' (fun x -> yield (a',b',x,d',e',f',g',h')); d d' (fun x -> yield (a',b',c',x,e',f',g',h')); e e' (fun x -> yield (a',b',c',d',x,f',g',h')); f f' (fun x -> yield (a',b',c',d',e',x,g',h')); g g' (fun x -> yield (a',b',c',d',e',f',x,h')); h h' (fun x -> yield (a',b',c',d',e',f',g',x)) let tup8_opt a b c d e f g h = let a = Option.value ~default a in let b = Option.value ~default b in let c = Option.value ~default c in let d = Option.value ~default d in let e = Option.value ~default e in let f = Option.value ~default f in let g = Option.value ~default g in let h = Option.value ~default h in tup8 a b c d e f g h let tup9 a b c d e f g h i (a', b', c', d', e', f', g', h', i') yield = a a' (fun x -> yield (x,b',c',d',e',f',g',h',i')); b b' (fun x -> yield (a',x,c',d',e',f',g',h',i')); c c' (fun x -> yield (a',b',x,d',e',f',g',h',i')); d d' (fun x -> yield (a',b',c',x,e',f',g',h',i')); e e' (fun x -> yield (a',b',c',d',x,f',g',h',i')); f f' (fun x -> yield (a',b',c',d',e',x,g',h',i')); g g' (fun x -> yield (a',b',c',d',e',f',x,h',i')); h h' (fun x -> yield (a',b',c',d',e',f',g',x,i')); i i' (fun x -> yield (a',b',c',d',e',f',g',h',x)) let tup9_opt a b c d e f g h i = let a = Option.value ~default a in let b = Option.value ~default b in let c = Option.value ~default c in let d = Option.value ~default d in let e = Option.value ~default e in let f = Option.value ~default f in let g = Option.value ~default g in let h = Option.value ~default h in let i = Option.value ~default i in tup9 a b c d e f g h i end (** {2 Observe Values} *) module Observable = struct (** An observable is a (random) predicate on ['a] *) type -'a t = { print: 'a Print.t; eq: ('a -> 'a -> bool); hash: ('a -> int); } let hash o x = o.hash x let equal o x y = o.eq x y let print o x = o.print x let make ?(eq=(=)) ?(hash=Hashtbl.hash) print = {print; eq; hash; } module H = struct let combine a b = Hashtbl.seeded_hash a b let combine_f f s x = Hashtbl.seeded_hash s (f x) let int i = i land max_int let int32 (i:int32) = Hashtbl.hash i let int64 (i:int64) = Hashtbl.hash i let bool b = if b then 1 else 2 let char x = Char.code x let bytes (x:bytes) = Hashtbl.hash x let string (x:string) = Hashtbl.hash x let opt f = function | None -> 42 | Some x -> combine 43 (f x) let result vh eh = function | Error e -> combine 17 (eh e) | Ok v -> combine 19 (vh v) let list f l = List.fold_left (combine_f f) 0x42 l let array f l = Array.fold_left (combine_f f) 0x42 l let pair f g (x,y) = combine (f x) (g y) end module Eq = struct type 'a t = 'a -> 'a -> bool let int : int t = (=) let int32 : int32 t = (=) let int64 : int64 t = (=) let bytes : bytes t = (=) let string : string t = (=) let bool : bool t = (=) let float = Float.equal let unit () () = true let char : char t = (=) let rec list f l1 l2 = match l1, l2 with | [], [] -> true | [], _ | _, [] -> false | x1::l1', x2::l2' -> f x1 x2 && list f l1' l2' let array eq a b = let rec aux i = if i = Array.length a then true else eq a.(i) b.(i) && aux (i+1) in Array.length a = Array.length b && aux 0 let option f o1 o2 = match o1, o2 with | None, None -> true | Some _, None | None, Some _ -> false | Some x, Some y -> f x y let result ok error r1 r2 = Result.equal ~ok ~error r1 r2 let pair f g (x1,y1)(x2,y2) = f x1 x2 && g y1 y2 end let unit : unit t = make ~hash:(fun _ -> 1) ~eq:Eq.unit Print.unit let bool : bool t = make ~hash:H.bool ~eq:Eq.bool Print.bool let int : int t = make ~hash:H.int ~eq:Eq.int Print.int let int32 : int32 t = make ~hash:H.int32 ~eq:Eq.int32 Print.int32 let int64 : int64 t = make ~hash:H.int64 ~eq:Eq.int64 Print.int64 let float : float t = make ~eq:Eq.float Print.float let bytes = make ~hash:H.bytes ~eq:Eq.bytes Print.bytes let string = make ~hash:H.string ~eq:Eq.string Print.string let char = make ~hash:H.char ~eq:Eq.char Print.char let option p = make ~hash:(H.opt p.hash) ~eq:(Eq.option p.eq) (Print.option p.print) let result op rp = make ~hash:(H.result op.hash rp.hash) ~eq:(Eq.result op.eq rp.eq) (Print.result op.print rp.print) let array p = make ~hash:(H.array p.hash) ~eq:(Eq.array p.eq) (Print.array p.print) let list p = make ~hash:(H.list p.hash) ~eq:(Eq.list p.eq) (Print.list p.print) let map f p = make ~hash:(fun x -> p.hash (f x)) ~eq:(fun x y -> p.eq (f x)(f y)) (fun x -> p.print (f x)) let pair a b = make ~hash:(H.pair a.hash b.hash) ~eq:(Eq.pair a.eq b.eq) (Print.pair a.print b.print) let triple a b c = map (fun (x,y,z) -> x,(y,z)) (pair a (pair b c)) let quad a b c d = map (fun (x,y,z,u) -> x,(y,z,u)) (pair a (triple b c d)) end type 'a stat = string * ('a -> int) (** A statistic on a distribution of values of type ['a] *) type 'a arbitrary = { gen: 'a Gen.t; print: ('a Print.t) option; (** print values *) small: ('a -> int) option; (** size of example *) shrink: ('a Shrink.t) option; (** shrink to smaller examples *) collect: ('a -> string) option; (** map value to tag, and group by tag *) stats: 'a stat list; (** statistics to collect and print *) } let make ?print ?small ?shrink ?collect ?(stats=[]) gen = { gen; print; small; shrink; collect; stats; } let set_small f o = {o with small=Some f} let set_print f o = {o with print=Some f} let set_shrink f o = {o with shrink=Some f} let set_collect f o = {o with collect=Some f} let set_stats s o = {o with stats=s} let add_stat s o = {o with stats=s :: o.stats} let set_gen g o = {o with gen=g} let add_shrink_invariant f o = match o.shrink with | None -> o | Some shr -> {o with shrink=Some (Shrink.filter f shr)} let get_gen o = o.gen let gen = get_gen let get_print o = o.print let small1 _ = 1 let make_scalar ?print ?collect gen = make ~shrink:Shrink.nil ~small:small1 ?print ?collect gen let make_int ?collect gen = make ~shrink:Shrink.int ~small:small1 ~print:Print.int ?collect gen let adapt_ o gen = make ?print:o.print ?small:o.small ?shrink:o.shrink ?collect:o.collect gen let choose l = match l with | [] -> raise (Invalid_argument "quickcheck.choose") | l -> let a = Array.of_list l in adapt_ a.(0) (fun st -> let arb = a.(RS.int st (Array.length a)) in arb.gen st) let unit : unit arbitrary = make ~small:small1 ~shrink:Shrink.nil ~print:Print.unit Gen.unit let bool = make ~small:small1 ~shrink:Shrink.bool ~print:Print.bool Gen.bool let float = make_scalar ~print:Print.float Gen.float let pos_float = make_scalar ~print:Print.float Gen.pfloat let neg_float = make_scalar ~print:Print.float Gen.nfloat let float_bound_inclusive bound = make_scalar ~print:Print.float (Gen.float_bound_inclusive bound) let float_bound_exclusive bound = make_scalar ~print:Print.float (Gen.float_bound_exclusive bound) let float_range low high = make_scalar ~print:Print.float (Gen.float_range low high) let exponential mean = make_scalar ~print:Print.float (Gen.exponential mean) let int = make_int Gen.int let int_bound n = make_int (Gen.int_bound n) let int_range a b = make_int (Gen.int_range a b) let (--) = int_range let pos_int = make_int Gen.pint let small_int = make_int Gen.small_int let small_nat = make_int Gen.small_nat let small_signed_int = make_int Gen.small_signed_int let small_int_corners () = make_int (Gen.nng_corners ()) let neg_int = make_int Gen.neg_int let int32 = make ~print:Print.int32 ~small:small1 ~shrink:Shrink.int32 Gen.int32 let int64 = make ~print:Print.int64 ~small:small1 ~shrink:Shrink.int64 Gen.int64 let small_char target c = abs ((Char.code c) - (Char.code target)) let char = make ~print:Print.char ~small:(small_char 'a') ~shrink:Shrink.char Gen.char let printable_char = make ~print:Print.char ~small:(small_char 'a') ~shrink:Shrink.char_printable Gen.printable let numeral_char = make ~print:Print.char ~small:(small_char '0') ~shrink:Shrink.char_numeral Gen.numeral let bytes_gen_of_size size gen = make ~shrink:Shrink.bytes ~small:Bytes.length ~print:Print.bytes (Gen.bytes_size ~gen size) let bytes_of gen = make ~shrink:Shrink.bytes ~small:Bytes.length ~print:Print.bytes (Gen.bytes ~gen) let bytes = bytes_of Gen.char let bytes_of_size size = bytes_gen_of_size size Gen.char let bytes_small = bytes_gen_of_size Gen.small_nat Gen.char let bytes_small_of gen = bytes_gen_of_size Gen.small_nat gen let bytes_printable = make ~shrink:(Shrink.bytes ~shrink:Shrink.char_printable) ~small:Bytes.length ~print:Print.bytes (Gen.bytes ~gen:Gen.printable) let string_gen_of_size size gen = make ~shrink:Shrink.string ~small:String.length ~print:Print.string (Gen.string_size ~gen size) let string_of gen = make ~shrink:Shrink.string ~small:String.length ~print:Print.string (Gen.string ~gen) let string = string_of Gen.char let string_of_size size = string_gen_of_size size Gen.char let string_small = string_gen_of_size Gen.small_nat Gen.char let string_small_of gen = string_gen_of_size Gen.small_nat gen let small_string = string_small let string_gen = string_of let printable_string = make ~shrink:(Shrink.string ~shrink:Shrink.char_printable) ~small:String.length ~print:Print.string (Gen.string ~gen:Gen.printable) let printable_string_of_size size = make ~shrink:(Shrink.string ~shrink:Shrink.char_printable) ~small:String.length ~print:Print.string (Gen.string_size ~gen:Gen.printable size) let small_printable_string = make ~shrink:(Shrink.string ~shrink:Shrink.char_printable) ~small:String.length ~print:Print.string (Gen.string_size ~gen:Gen.printable Gen.small_nat) let numeral_string = make ~shrink:(Shrink.string ~shrink:Shrink.char_numeral) ~small:String.length ~print:Print.string (Gen.string ~gen:Gen.numeral) let numeral_string_of_size size = make ~shrink:(Shrink.string ~shrink:Shrink.char_numeral) ~small:String.length ~print:Print.string (Gen.string_size ~gen:Gen.numeral size) let string_printable = printable_string let string_printable_of_size = printable_string_of_size let string_small_printable = small_printable_string let string_numeral = numeral_string let string_numeral_of_size = numeral_string_of_size let list_sum_ f l = List.fold_left (fun acc x-> f x+acc) 0 l let mk_list a gen = (* small sums sub-sizes if present, otherwise just length *) let small = _opt_map_or a.small ~f:list_sum_ ~d:List.length in let print = _opt_map a.print ~f:Print.list in make ~small ~shrink:(Shrink.list ?shrink:a.shrink) ?print gen let list a = mk_list a (Gen.list a.gen) let list_of_size size a = mk_list a (Gen.list_size size a.gen) let small_list a = mk_list a (Gen.small_list a.gen) let array_sum_ f a = Array.fold_left (fun acc x -> f x+acc) 0 a let array a = let small = _opt_map_or ~d:Array.length ~f:array_sum_ a.small in make ~small ~shrink:(Shrink.array ?shrink:a.shrink) ?print:(_opt_map ~f:Print.array a.print) (Gen.array a.gen) let array_of_size size a = let small = _opt_map_or ~d:Array.length ~f:array_sum_ a.small in make ~small ~shrink:(Shrink.array ?shrink:a.shrink) ?print:(_opt_map ~f:Print.array a.print) (Gen.array_size size a.gen) let pair a b = make ?small:(_opt_map_2 ~f:(fun f g (x,y) -> f x+g y) a.small b.small) ?print:(_opt_map_2 ~f:Print.pair a.print b.print) ~shrink:(Shrink.pair (_opt_or a.shrink Shrink.nil) (_opt_or b.shrink Shrink.nil)) (Gen.pair a.gen b.gen) let triple a b c = make ?small:(_opt_map_3 ~f:(fun f g h (x,y,z) -> f x+g y+h z) a.small b.small c.small) ?print:(_opt_map_3 ~f:Print.triple a.print b.print c.print) ~shrink:(Shrink.triple (_opt_or a.shrink Shrink.nil) (_opt_or b.shrink Shrink.nil) (_opt_or c.shrink Shrink.nil)) (Gen.triple a.gen b.gen c.gen) let quad a b c d = make ?small:(_opt_map_4 ~f:(fun f g h i (x,y,z,w) -> f x+g y+h z+i w) a.small b.small c.small d.small) ?print:(_opt_map_4 ~f:Print.quad a.print b.print c.print d.print) ~shrink:(Shrink.quad (_opt_or a.shrink Shrink.nil) (_opt_or b.shrink Shrink.nil) (_opt_or c.shrink Shrink.nil) (_opt_or d.shrink Shrink.nil)) (Gen.quad a.gen b.gen c.gen d.gen) let tup2 a b= make ?small:(_opt_map_2 ~f:(fun a b (a', b') -> a a'+b b') a.small b.small) ~print:(Print.tup2_opt a.print b.print) ~shrink:(Shrink.pair (_opt_or a.shrink Shrink.nil) (_opt_or b.shrink Shrink.nil)) (Gen.tup2 a.gen b.gen) let tup3 a b c = make ?small:(_opt_map_3 ~f:(fun a b c (a', b', c') -> a a'+b b'+c c') a.small b.small c.small) ~print:(Print.tup3_opt a.print b.print c.print) ~shrink:(Shrink.tup3_opt a.shrink b.shrink c.shrink) (Gen.tup3 a.gen b.gen c.gen) let tup4 a b c d = make ?small:(_opt_map_4 ~f:(fun a b c d (a', b', c', d') -> a a'+b b'+c c'+d d') a.small b.small c.small d.small) ~print:(Print.tup4_opt a.print b.print c.print d.print) ~shrink:(Shrink.tup4_opt a.shrink b.shrink c.shrink d.shrink) (Gen.tup4 a.gen b.gen c.gen d.gen) let tup5 a b c d e = make ?small:(_opt_map_5 ~f:(fun a b c d e (a', b', c', d', e') -> a a'+b b'+c c'+d d'+e e') a.small b.small c.small d.small e.small) ~print:(Print.tup5_opt a.print b.print c.print d.print e.print) ~shrink:(Shrink.tup5_opt a.shrink b.shrink c.shrink d.shrink e.shrink) (Gen.tup5 a.gen b.gen c.gen d.gen e.gen) let tup6 a b c d e f = make ?small:(_opt_map_6 ~f:(fun a b c d e f (a', b', c', d', e', f') -> a a'+b b'+c c'+d d'+e e'+f f') a.small b.small c.small d.small e.small f.small) ~print:(Print.tup6_opt a.print b.print c.print d.print e.print f.print) ~shrink:(Shrink.tup6_opt a.shrink b.shrink c.shrink d.shrink e.shrink f.shrink) (Gen.tup6 a.gen b.gen c.gen d.gen e.gen f.gen) let tup7 a b c d e f g = make ?small:(_opt_map_7 ~f:(fun a b c d e f g (a', b', c', d', e', f', g') -> a a'+b b'+c c'+d d'+e e'+f f'+g g') a.small b.small c.small d.small e.small f.small g.small) ~print:(Print.tup7_opt a.print b.print c.print d.print e.print f.print g.print) ~shrink:(Shrink.tup7_opt a.shrink b.shrink c.shrink d.shrink e.shrink f.shrink g.shrink) (Gen.tup7 a.gen b.gen c.gen d.gen e.gen f.gen g.gen) let tup8 a b c d e f g h = make ?small:(_opt_map_8 ~f:(fun a b c d e f g h (a', b', c', d', e', f', g', h') -> a a'+b b'+c c'+d d'+e e'+f f'+g g'+h h') a.small b.small c.small d.small e.small f.small g.small h.small) ~print:(Print.tup8_opt a.print b.print c.print d.print e.print f.print g.print h.print) ~shrink:(Shrink.tup8_opt a.shrink b.shrink c.shrink d.shrink e.shrink f.shrink g.shrink h.shrink) (Gen.tup8 a.gen b.gen c.gen d.gen e.gen f.gen g.gen h.gen) let tup9 a b c d e f g h i = make ?small:(_opt_map_9 ~f:(fun a b c d e f g h i (a', b', c', d', e', f', g', h', i') -> a a'+b b'+c c'+d d'+e e'+f f'+g g'+h h'+i i') a.small b.small c.small d.small e.small f.small g.small h.small i.small) ~print:(Print.tup9_opt a.print b.print c.print d.print e.print f.print g.print h.print i.print) ~shrink:(Shrink.tup9_opt a.shrink b.shrink c.shrink d.shrink e.shrink f.shrink g.shrink h.shrink i.shrink) (Gen.tup9 a.gen b.gen c.gen d.gen e.gen f.gen g.gen h.gen i.gen) let option ?ratio a = let g = Gen.opt ?ratio a.gen and shrink = _opt_map a.shrink ~f:Shrink.option and small = _opt_map_or a.small ~d:(function None -> 0 | Some _ -> 1) ~f:(fun f o -> match o with None -> 0 | Some x -> f x) in make ~small ?shrink ?print:(_opt_map ~f:Print.option a.print) g let result ?ratio ok err = let g = Gen.result ?ratio ok.gen err.gen and shrink = _opt_map_2 ok.shrink err.shrink ~f:Shrink.result and small = match ok.small, err.small with | None, None -> (function Ok _ -> 0 | Error _ -> 1) | None, Some es -> (function Ok _ -> 0 | Error e -> es e) | Some os, None -> (function Ok o -> os o | Error _ -> 1) | Some os, Some es -> (function Ok o -> os o | Error e -> es e) in make ~small ?shrink:shrink ?print:(_opt_map_2 ~f:Print.result ok.print err.print) g let map ?rev f a = make ?print:(_opt_map_2 rev a.print ~f:(fun r p x -> p (r x))) ?small:(_opt_map_2 rev a.small ~f:(fun r s x -> s (r x))) ?shrink:(_opt_map_2 rev a.shrink ~f:(fun r g x -> Iter.(g (r x) >|= f))) ?collect:(_opt_map_2 rev a.collect ~f:(fun r f x -> f (r x))) (fun st -> f (a.gen st)) let fun1_unsafe : 'a arbitrary -> 'b arbitrary -> ('a -> 'b) arbitrary = fun a1 a2 -> let magic_object = Obj.magic (object end) in let gen : ('a -> 'b) Gen.t = fun st -> let h = Hashtbl.create 10 in fun x -> if x == magic_object then Obj.magic h else try Hashtbl.find h x with Not_found -> let b = a2.gen st in Hashtbl.add h x b; b in let pp : (('a -> 'b) -> string) option = _opt_map_2 a1.print a2.print ~f:(fun p1 p2 f -> let h : ('a, 'b) Hashtbl.t = Obj.magic (f magic_object) in let b = Buffer.create 20 in Hashtbl.iter (fun key value -> Printf.bprintf b "%s -> %s; " (p1 key) (p2 value)) h; "{" ^ Buffer.contents b ^ "}" ) in make ?print:pp gen let fun2_unsafe gp1 gp2 gp3 = fun1_unsafe gp1 (fun1_unsafe gp2 gp3) module Poly_tbl : sig type ('a, 'b) t val create: 'a Observable.t -> 'b arbitrary -> int -> ('a, 'b) t Gen.t val get : ('a, 'b) t -> 'a -> 'b option val size : ('b -> int) -> (_, 'b) t -> int val shrink1 : ('a, 'b) t Shrink.t val shrink2 : 'b Shrink.t -> ('a, 'b) t Shrink.t val print : (_,_) t Print.t end = struct type ('a, 'b) t = { get : 'a -> 'b option; p_size: ('b->int) -> int; p_shrink1: ('a, 'b) t Iter.t; p_shrink2: 'b Shrink.t -> ('a, 'b) t Iter.t; p_print: unit -> string; } let create (type k)(type v) k v size st : (k,v) t = let module T = Hashtbl.Make(struct type t = k let equal = k.Observable.eq let hash = k.Observable.hash end) in let tbl_to_list tbl = T.fold (fun k v l -> (k,v)::l) tbl [] and tbl_of_list l = let tbl = T.create (max (List.length l) 8) in List.iter (fun (k,v) -> T.add tbl k v) l; tbl in (* split random state to avoid later failed [get]s to side-effect the current [st] *) let st' = RS.split st in (* make a table @param extend if true, extend table on the fly *) let rec make ~extend tbl = { get=(fun x -> try Some (T.find tbl x) with Not_found -> if extend then ( let v = v.gen st' in T.add tbl x v; Some v ) else None); p_print=(fun () -> match v.print with | None -> "" | Some pp_v -> let b = Buffer.create 64 in T.iter (fun key value -> Printf.bprintf b "%s -> %s; " (k.Observable.print key) (pp_v value)) tbl; Buffer.contents b); p_shrink1=(fun yield -> Shrink.list_spine (tbl_to_list tbl) (fun l -> yield (make ~extend:false (tbl_of_list l))) ); p_shrink2=(fun shrink_val yield -> (* shrink bindings one by one *) T.iter (fun x y -> shrink_val y (fun y' -> let tbl' = T.copy tbl in T.replace tbl' x y'; yield (make ~extend:false tbl'))) tbl); p_size=(fun size_v -> T.fold (fun _ v n -> n + size_v v) tbl 0); } in make ~extend:true (T.create size) let get t x = t.get x let shrink1 t = t.p_shrink1 let shrink2 p t = t.p_shrink2 p let print t = t.p_print () let size p t = t.p_size p end (** Internal representation of functions *) type ('a, 'b) fun_repr_tbl = { fun_tbl: ('a, 'b) Poly_tbl.t; fun_arb: 'b arbitrary; fun_default: 'b; } type 'f fun_repr = | Fun_tbl : ('a, 'ret) fun_repr_tbl -> ('a -> 'ret) fun_repr | Fun_map : ('f1 -> 'f2) * 'f1 fun_repr -> 'f2 fun_repr type _ fun_ = | Fun : 'f fun_repr * 'f -> 'f fun_ (** Reifying functions *) module Fn = struct type 'a t = 'a fun_ let apply (Fun (_,f)) = f let make_ (r:_ fun_repr) : _ fun_ = let rec call : type f. f fun_repr -> f = fun r -> match r with | Fun_tbl r -> begin fun x -> match Poly_tbl.get r.fun_tbl x with | None -> r.fun_default | Some y -> y end | Fun_map (g, r') -> g (call r') in Fun (r, call r) let mk_repr tbl arb def = Fun_tbl { fun_tbl=tbl; fun_arb=arb; fun_default=def; } let map_repr f repr = Fun_map (f,repr) let map_fun f (Fun (repr,_)) = make_ (map_repr f repr) let shrink_rep (r: _ fun_repr): _ Iter.t = let open Iter in let rec aux : type f. f fun_repr Shrink.t = function | Fun_tbl {fun_arb=a; fun_tbl=tbl; fun_default=def} -> let sh_v = match a.shrink with None -> Shrink.nil | Some s->s in (sh_v def >|= fun def' -> mk_repr tbl a def') <+> (Poly_tbl.shrink1 tbl >|= fun tbl' -> mk_repr tbl' a def) <+> (Poly_tbl.shrink2 sh_v tbl >|= fun tbl' -> mk_repr tbl' a def) | Fun_map (g, r') -> aux r' >|= map_repr g in aux r let shrink (Fun (rep,_)) = let open Iter in shrink_rep rep >|= make_ let rec size_rep : type f. f fun_repr -> int = function | Fun_map (_, r') -> size_rep r' | Fun_tbl r -> let size_v x = match r.fun_arb.small with None -> 0 | Some f -> f x in Poly_tbl.size size_v r.fun_tbl + size_v r.fun_default let size (Fun (rep,_)) = size_rep rep let print_rep r = let buf = Buffer.create 32 in let rec aux : type f. Buffer.t -> f fun_repr -> unit = fun buf r -> match r with | Fun_map (_, r') -> aux buf r' | Fun_tbl r -> Buffer.add_string buf (Poly_tbl.print r.fun_tbl); Printf.bprintf buf "_ -> %s" (match r.fun_arb.print with | None -> "" | Some s -> s r.fun_default ); in Printf.bprintf buf "{"; aux buf r; Printf.bprintf buf "}"; Buffer.contents buf let print (Fun (rep,_)) = print_rep rep let gen_rep (a:_ Observable.t) (b:_ arbitrary): _ fun_repr Gen.t = fun st -> mk_repr (Poly_tbl.create a b 8 st) b (b.gen st) let gen a b = Gen.map make_ (gen_rep a b) end let fun1 o ret = make ~shrink:Fn.shrink ~print:Fn.print ~small:Fn.size (Fn.gen o ret) module Tuple = struct (** heterogeneous list (generic tuple) used to uncurry functions *) type 'a t = | Nil : unit t | Cons : 'a * 'b t -> ('a * 'b) t let nil = Nil let cons x tail = Cons (x,tail) type 'a obs = | O_nil : unit obs | O_cons : 'a Observable.t * 'b obs -> ('a * 'b) obs let o_nil = O_nil let o_cons x tail = O_cons (x,tail) let rec hash : type a. a obs -> a t -> int = fun o t -> match o, t with | O_nil, Nil -> 42 | O_cons (o,tail_o), Cons (x, tail) -> Observable.H.combine (Observable.hash o x) (hash tail_o tail) let rec equal : type a. a obs -> a t -> a t -> bool = fun o a b -> match o, a, b with | O_nil, Nil, Nil -> true | O_cons (o, tail_o), Cons (x1, tail1), Cons (x2,tail2) -> Observable.equal o x1 x2 && equal tail_o tail1 tail2 let print o tup = let rec aux : type a. a obs -> Buffer.t -> a t -> unit = fun o buf t -> match o, t with | O_nil, Nil -> Printf.bprintf buf "()" | O_cons (o, O_nil), Cons (x,Nil) -> Printf.bprintf buf "%s" (Observable.print o x) | O_cons (o, tail_o), Cons (x,tail) -> Printf.bprintf buf "%s, %a" (Observable.print o x) (aux tail_o) tail in let buf = Buffer.create 64 in Buffer.add_string buf "("; aux o buf tup; Buffer.add_string buf ")"; Buffer.contents buf let observable (o:'a obs) : 'a t Observable.t = Observable.make ~eq:(equal o) ~hash:(hash o) (print o) let gen (o:'a obs) (ret:'b arbitrary) : ('a t -> 'b) fun_ Gen.t = Fn.gen (observable o) ret module Infix = struct let (@::) x tail = cons x tail let (@->) o tail = o_cons o tail end include Infix end let fun_nary (o:_ Tuple.obs) ret : _ arbitrary = make ~shrink:Fn.shrink ~print:Fn.print ~small:Fn.size (Tuple.gen o ret) let fun2 o1 o2 ret = let open Tuple in map ~rev:(Fn.map_fun (fun g (Cons (x, Cons (y,Nil))) -> g x y)) (Fn.map_fun (fun g x y -> g (x @:: y @:: nil))) (fun_nary (o1 @-> o2 @-> o_nil) ret) let fun3 o1 o2 o3 ret = let open Tuple in map ~rev:(Fn.map_fun (fun g (Cons (x, Cons (y, Cons (z,Nil)))) -> g x y z)) (Fn.map_fun (fun g x y z -> g (x @:: y @:: z @:: nil))) (fun_nary (o1 @-> o2 @-> o3 @-> o_nil) ret) let fun4 o1 o2 o3 o4 ret = let open Tuple in map ~rev:(Fn.map_fun (fun g (Cons (x, Cons (y, Cons (z,Cons (w,Nil))))) -> g x y z w)) (Fn.map_fun (fun g x y z w -> g (x @:: y @:: z @:: w @:: nil))) (fun_nary (o1 @-> o2 @-> o3 @-> o4 @-> o_nil) ret) (* Generator combinators *) (** given a list, returns generator that picks at random from list *) let oneofl ?print ?collect xs = make ?print ?collect (Gen.oneofl xs) let oneofa ?print ?collect xs = make ?print ?collect (Gen.oneofa xs) (** Given a list of generators, returns generator that randomly uses one of the generators from the list *) let oneof l = let gens = List.map (fun a->a.gen) l in let first = List.hd l in let print = first.print and small = first.small and collect = first.collect and shrink = first.shrink in make ?print ?small ?collect ?shrink (Gen.oneof gens) (** Generator that always returns given value *) let always ?print x = let gen _st = x in make ?print gen (** like oneof, but with weights *) let frequency ?print ?small ?shrink ?collect l = let first = snd (List.hd l) in let small = _opt_sum small first.small in let print = _opt_sum print first.print in let shrink = _opt_sum shrink first.shrink in let collect = _opt_sum collect first.collect in let gens = List.map (fun (x,y) -> x, y.gen) l in make ?print ?small ?shrink ?collect (Gen.frequency gens) (** Given list of [(frequency,value)] pairs, returns value with probability proportional to given frequency *) let frequencyl ?print ?small l = make ?print ?small (Gen.frequencyl l) let frequencya ?print ?small l = make ?print ?small (Gen.frequencya l) let map_same_type f a = adapt_ a (fun st -> f (a.gen st)) let map_keep_input ?print ?small f a = make ?print:(match print, a.print with | Some f1, Some f2 -> Some (Print.pair f2 f1) | Some f, None -> Some (Print.comap snd f) | None, Some f -> Some (Print.comap fst f) | None, None -> None) ?small:(match small, a.small with | Some f, _ -> Some (fun (_,y) -> f y) | None, Some f -> Some (fun (x,_) -> f x) | None, None -> None) ?shrink:(match a.shrink with | None -> None | Some s -> let s' (x,_) = Iter.map (fun x->x, f x) (s x) in Some s') Gen.(map_keep_input f a.gen) module TestResult = struct type 'a counter_ex = 'a QCheck2.TestResult.counter_ex = { instance: 'a; (** The counter-example(s) *) shrink_steps: int; (** How many shrinking steps for this counterex *) msg_l: string list; (** messages. @since 0.7 *) } type 'a failed_state = 'a counter_ex list (** Result state. changed in 0.10 (move to inline records) *) type 'a state = 'a QCheck2.TestResult.state = | Success | Failed of { instances: 'a failed_state; (** Failed instance(s) *) } | Failed_other of {msg: string} | Error of { instance: 'a counter_ex; exn: exn; backtrace: string; } (** Error, backtrace, and instance that triggered it *) (* result returned by running a test *) type 'a t = 'a QCheck2.TestResult.t let get_count = QCheck2.TestResult.get_count let get_count_gen = QCheck2.TestResult.get_count_gen let get_state = QCheck2.TestResult.get_state let stats = QCheck2.TestResult.stats let collect = QCheck2.TestResult.collect let warnings = QCheck2.TestResult.warnings let is_success = QCheck2.TestResult.is_success end module Test = struct type res = QCheck2.Test.res = | Success | Failure | FalseAssumption | Error of exn * string type 'a event = 'a QCheck2.Test.event = | Generating | Collecting of 'a | Testing of 'a | Shrunk of int * 'a | Shrinking of int * int * 'a type 'a cell = 'a QCheck2.Test.cell type 'a handler = 'a QCheck2.Test.handler type 'a step = 'a QCheck2.Test.step type 'a callback = 'a QCheck2.Test.callback type t = QCheck2.Test.t include QCheck2.Test_exceptions let print_instance = QCheck2.Test.print_instance let print_c_ex = QCheck2.Test.print_c_ex let print_error = QCheck2.Test.print_error let print_fail = QCheck2.Test.print_fail let print_fail_other = QCheck2.Test.print_fail_other let print_test_fail = QCheck2.Test.print_test_fail let print_test_error = QCheck2.Test.print_test_error let set_name = QCheck2.Test.set_name let get_law = QCheck2.Test.get_law let get_name = QCheck2.Test.get_name let get_count = QCheck2.Test.get_count let get_long_factor = QCheck2.Test.get_long_factor let make_cell ?if_assumptions_fail ?count ?long_factor ?negative ?max_gen ?max_fail ?small:_removed_in_qcheck_2 ?retries ?name arb law = let {gen; shrink; print; collect; stats; _} = arb in 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 let make' ?if_assumptions_fail ?count ?long_factor ?max_gen ?max_fail ?small ?retries ?name ~negative arb law = QCheck2.Test.Test (make_cell ?if_assumptions_fail ?count ?long_factor ?max_gen ?max_fail ?small ?retries ?name ~negative arb law) let make = make' ~negative:false let make_neg = make' ~negative:true let fail_report = QCheck2.Test.fail_report let fail_reportf = QCheck2.Test.fail_reportf let check_cell_exn = QCheck2.Test.check_cell_exn let check_exn = QCheck2.Test.check_exn let check_cell = QCheck2.Test.check_cell end let find_example ?(name="") ?count ~f g : _ Gen.t = (* the random generator of examples satisfying [f]. To do that we test the property [fun x -> not (f x)]; any counter-example *) let gen st = let cell = let arb = make g in Test.make_cell ~max_fail:1 ?count arb (fun x -> not (f x)) in let res = QCheck2.Test.check_cell ~rand:st cell in begin match QCheck2.TestResult.get_state res with | QCheck2.TestResult.Success -> raise (No_example_found name) | QCheck2.TestResult.Error _ -> raise (No_example_found name) | QCheck2.TestResult.Failed {instances=[]} -> assert false | QCheck2.TestResult.Failed {instances=failed::_} -> (* found counter-example! *) failed.QCheck2.TestResult.instance | QCheck2.TestResult.Failed_other {msg=_} -> raise (No_example_found name) end in gen let find_example_gen ?rand ?name ?count ~f g = let g = find_example ?name ?count ~f g in Gen.generate1 ?rand g qcheck-0.25/src/core/QCheck.mli000066400000000000000000002030131477416744200162750ustar00rootroot00000000000000(* QCheck: Random testing for OCaml copyright (c) 2013-2017, Guillaume Bury, Simon Cruanes, Vincent Hugot, Jan Midtgaard, Julien Debon, Valentin Chaboche all rights reserved. *) (** {1 Quickcheck inspired property-based testing} *) (** {1 Introduction} The library takes inspiration from Haskell's QuickCheck library. The rough idea is that the programmer describes invariants that values of a certain type need to satisfy ("properties"), as functions from this type to [bool]. The programmer also needs to describe how to generate random values of the type, so that the property is tried and checked on a number of random instances. This explains the organization of this module: - {{!section:arbitrary}The ['a arbitrary] record type} describes how to generate random values, shrink them (reduce counter-examples to a minimum), print them, etc. It is the generator type expected by {!Test.make}. - Auxiliary modules such as {!Gen}, {!Print}, and {!Shrink} can be used along with {!make} to build custom generators. - {!Test} is used to describe a single test, that is, a property of type ['a -> bool] combined with an ['a arbitrary] that is used to generate the test cases for this property. Optional parameters allow to specify the random generator state, number of instances to generate and test, etc. {1 Examples} - List.rev is involutive: {[ let test = QCheck.(Test.make ~count:1000 (list int) (fun l -> List.rev (List.rev l) = l));; QCheck.Test.check_exn test;; ]} - Not all lists are sorted (false property that will fail. The 15 smallest counter-example lists will be printed): {[ let test = QCheck.( Test.make ~count:10_000 ~max_fail:3 (list small_nat) (fun l -> l = List.sort compare l));; QCheck.Test.check_exn test;; ]} - generate 20 random trees using {! Gen.fix} : {[ type tree = Leaf of int | Node of tree * tree let leaf x = Leaf x let node x y = Node (x,y) let g = QCheck.Gen.(sized @@ fix (fun self n -> match n with | 0 -> map leaf nat | n -> frequency [1, map leaf nat; 2, map2 node (self (n/2)) (self (n/2))] )) Gen.generate ~n:20 g;; ]} More complex and powerful combinators can be found in Gabriel Scherer's {{:https://github.com/gasche/random-generator}[Generator]} module. Its documentation can be found {{:http://gasche.github.io/random-generator/doc/Generator.html } here}. *) (** {1 Assumptions} *) val (==>) : bool -> bool -> bool (** [b1 ==> b2] is the logical implication [b1 => b2] ie [not b1 || b2] (except that it is strict and will interact better with {!Test.check_exn} and the likes, because they will know the precondition was not satisfied.). {b WARNING}: this function should only be used in a property (see {!Test.make}), because it raises a special exception in case of failure of the first argument, to distinguish between failed test and failed precondition. Because of OCaml's evaluation order, both [b1] and [b2] are always evaluated; if [b2] should only be evaluated when [b1] holds, see {!assume}. *) val assume : bool -> unit (** [assume cond] checks the precondition [cond], and does nothing if [cond=true]. If [cond=false], it interrupts the current test. {b WARNING} This function, like {!(==>)}, should only be used in a test, not outside. Example: {[ Test.make (list int) (fun l -> assume (l <> []); List.hd l :: List.tl l = l) ]} @since 0.5.1 *) val assume_fail : unit -> 'a (** [assume_fail ()] is like [assume false], but can take any type since we know it always fails (like [assert false]). This is useful to ignore some branches in [if] or [match]. Example: {[ Test.make (list int) (function | [] -> assume_fail () | _::_ as l -> List.hd l :: List.tl l = l) ]} @since 0.5.1 *) (** {1 Generate Random Values} *) module Gen : sig (** The [Gen] module offers combinators to build custom generators. Unlike the {{!section:arbitrary}the ['a arbitrary] record type}, which comes with printers, shrinkers, etc. {!Gen.t} represents a type for generation only. *) type 'a t = Random.State.t -> 'a (** A random generator for values of type 'a. *) type 'a sized = int -> Random.State.t -> 'a (** Random generator with a size bound. *) val return : 'a -> 'a t (** Create a constant generator. *) val pure : 'a -> 'a t (** Synonym for {!return} @since 0.8 *) val (>>=) : 'a t -> ('a -> 'b t) -> 'b t (** Monadic bind for writing dependent generators. First generates an ['a] and then passes it to the given function, to generate a ['b]. *) val (<*>) : ('a -> 'b) t -> 'a t -> 'b t (** Infix operator for composing a function generator and an argument generator into a result generator. *) val map : ('a -> 'b) -> 'a t -> 'b t (** [map f g] transforms a generator [g] by applying [f] to each generated element. *) val map2 : ('a -> 'b -> 'c) -> 'a t -> 'b t -> 'c t (** [map2 f g1 g2] transforms two generators [g1] and [g2] by applying [f] to each pair of generated elements. *) val map3 : ('a -> 'b -> 'c -> 'd) -> 'a t -> 'b t -> 'c t -> 'd t (** [map3 f g1 g2 g3] transforms three generators [g1], [g2], and [g3] by applying [f] to each triple of generated elements. *) val map4 : ('a -> 'b -> 'c -> 'd -> 'e) -> 'a t -> 'b t -> 'c t -> 'd t -> 'e t (** [map4 f g1 g2 g3 g4] transforms four generators [g1], [g2], [g3], and [g4] by applying [f] to each quadruple of generated elements. @since 0.25 *) val map5 : ('a -> 'b -> 'c -> 'd -> 'e -> 'f) -> 'a t -> 'b t -> 'c t -> 'd t -> 'e t -> 'f t (** [map5 f g1 g2 g3 g4 g5] transforms five generators [g1], [g2], [g3], [g4], and [g5] by applying [f] to each quintuple of generated elements. @since 0.25 *) val map_keep_input : ('a -> 'b) -> 'a t -> ('a * 'b) t (** [map_keep_input f g] transforms a generator [g] by applying [f] to each generated element. Returns both the generated element from [g] and the output from [f]. *) val (>|=) : 'a t -> ('a -> 'b) -> 'b t (** An infix synonym for {!map}. *) val (<$>) : ('a -> 'b) -> 'a t -> 'b t (** An infix synonym for {!map} @since 0.13 *) val oneof : 'a t list -> 'a t (** Constructs a generator that selects among a given list of generators. @raise Invalid_argument or Failure if list is empty *) val oneofl : 'a list -> 'a t (** Constructs a generator that selects among a given list of values. @raise Invalid_argument or Failure if list is empty *) val oneofa : 'a array -> 'a t (** Constructs a generator that selects among a given array of values. @raise Invalid_argument or Failure if list is empty *) val frequency : (int * 'a t) list -> 'a t (** Constructs a generator that selects among a given list of generators. Each of the given generators are chosen based on a positive integer weight. *) val frequencyl : (int * 'a) list -> 'a t (** Constructs a generator that selects among a given list of values. Each of the given values are chosen based on a positive integer weight. *) val frequencya : (int * 'a) array -> 'a t (** Constructs a generator that selects among a given array of values. Each of the array entries are chosen based on a positive integer weight. *) val shuffle_a : 'a array -> unit t (** Shuffles the array in place. *) val shuffle_l : 'a list -> 'a list t (** Creates a generator of shuffled lists. *) val shuffle_w_l : (int * 'a) list -> 'a list t (** Creates a generator of weighted shuffled lists. A given list is shuffled on each generation according to the weights of its elements. An element with a larger weight is more likely to be at the front of the list than an element with a smaller weight. If we want to pick random elements from the (head of) list but need to prioritize some elements over others, this generator can be useful. Example: given a weighted list [[1, "one"; 5, "five"; 10, "ten"]], the generator is more likely to generate [["ten"; "five"; "one"]] or [["five"; "ten"; "one"]] than [["one"; "ten"; "five"]] because "ten" and "five" have larger weights than "one". @since 0.11 *) val range_subset : size:int -> int -> int -> int array t (** [range_subset ~size:k low high] generates an array of length [k] of sorted distinct integers in the range [low..high] (included). Complexity O(k log k), drawing [k] random integers. @raise Invalid_argument outside the valid region [0 <= k <= high-low+1]. @since 0.18 *) val array_subset : int -> 'a array -> 'a array t (** [array_subset k arr] generates a sub-array of [k] elements at distinct positions in the input array [arr], in the same order. Complexity O(k log k), drawing [k] random integers. @raise Invalid_argument outside the valid region [0 <= size <= Array.length arr]. @since 0.18 *) (** {3 Primitive generators} *) val unit : unit t (** The unit generator. *) val bool : bool t (** The boolean generator. *) val float : float t (** Generates floating point numbers. *) val pfloat : float t (** Generates positive floating point numbers (0. included). *) val nfloat : float t (** Generates negative floating point numbers. (-0. included) *) val float_bound_inclusive : float -> float t (** [float_bound_inclusive bound] returns a random floating-point number between 0 and [bound] (inclusive). If [bound] is negative, the result is negative or zero. If [bound] is 0, the result is 0. @since 0.11 *) val float_bound_exclusive : float -> float t (** [float_bound_exclusive bound] returns a random floating-point number between 0 and [bound] (exclusive). If [bound] is negative, the result is negative or zero. @raise Invalid_argument if [bound] is zero. @since 0.11 *) val float_range : float -> float -> float t (** [float_range low high] generates floating-point numbers within [low] and [high] (inclusive) @raise Invalid_argument if [high < low] or if the range is larger than [max_float]. @since 0.11 *) val (--.) : float -> float -> float t (** Synonym for [float_range] @since 0.11 *) val exponential : float -> float t (** [exponential m] generates floating-point numbers following an exponential distribution with a mean of [m]. @raise Invalid_argument if [m] is NaN. @since 0.23 *) val nat : int t (** Generates small natural numbers. *) val big_nat : int t (** Generates natural numbers, possibly large. @since 0.10 *) val neg_int : int t (** Generates non-strictly negative integers (0 included). *) val pint : int t (** Generates non-strictly positive integers uniformly (0 included). *) val int : int t (** Generates integers uniformly. *) val small_nat : int t (** Small integers (< 100) @since 0.5.1 *) val small_int : int t (** Small UNSIGNED integers, for retrocompatibility. @deprecated use {!small_nat}. *) val small_signed_int : int t (** Small SIGNED integers, based on {!small_nat}. @since 0.5.2 *) val int_bound : int -> int t (** Uniform integer generator producing integers between [0] and [bound] (inclusive). For [bound < 2^{30} - 1] uses [Random.State.int] for integer generation. @raise Invalid_argument if the argument is negative. *) val int_range : int -> int -> int t (** Uniform integer generator producing integers within [low,high] (inclusive). @raise Invalid_argument if [low > high]. *) val graft_corners : 'a t -> 'a list -> unit -> 'a t (** [graft_corners gen l ()] makes a new generator that enumerates the corner cases in [l] and then behaves like [g]. Note that [graft_corners gen l ()] is stateful, meaning that once the elements of [l] have been emitted, subsequent calls will not reproduce them. It is therefore recommended that separate tests each use a fresh generator. @since 0.6 *) val int_pos_corners : int list (** Non-negative corner cases for int. @since 0.6 *) val int_corners : int list (** All corner cases for int. @since 0.6 *) val (--) : int -> int -> int t (** Synonym for {!int_range}. *) val int32 : int32 t (** Generates [int32] values uniformly. @since 0.24 *) val int64 : int64 t (** Generates [int64] values uniformly. @since 0.24 *) val ui32 : int32 t (** Generates [int32] values. @deprecated use {!val:int32} instead, the name is wrong, values {i are} signed. *) val ui64 : int64 t (** Generates [int64] values. @deprecated use {!val:int64} instead, the name is wrong, values {i are} signed. *) val list : 'a t -> 'a list t (** Builds a list generator from an element generator. List size is generated by {!nat}. *) val list_size : int t -> 'a t -> 'a list t (** Builds a list generator from a (non-negative) size generator and an element generator. *) val list_repeat : int -> 'a t -> 'a list t (** [list_repeat i g] builds a list generator from exactly [i] elements generated by [g]. *) val array : 'a t -> 'a array t (** Builds an array generator from an element generator. Array size is generated by {!nat}. *) val array_size : int t -> 'a t -> 'a array t (** Builds an array generator from a (non-negative) size generator and an element generator. *) val array_repeat : int -> 'a t -> 'a array t (** [array_repeat i g] builds an array generator from exactly [i] elements generated by [g]. *) val option : ?ratio:float -> 'a t -> 'a option t (** An option generator, with optional ratio. @param ratio a float between [0.] and [1.] indicating the probability of a sample to be [Some _] rather than [None]. @since 0.19 (renamed from [opt]) *) val opt : ?ratio:float -> 'a t -> 'a option t (** [opt] is an alias of {!val:option} for backward compatibility. @since 0.18 ([?ratio] parameter) *) val result : ?ratio:float -> 'a t -> 'e t -> ('a, 'e) result t (** A result generator, with optional ratio. @param ratio a float between [0.] and [1.] indicating the probability of a sample to be [Ok _] rather than [Error _]. @since 0.24 *) val char : char t (** Generates characters upto character code 255. *) val printable : char t (** Generates printable ascii characters - either '\n' or in the range 32 to 126, inclusive *) val numeral : char t (** Generates numeral characters. *) val char_range : char -> char -> char t (** Generates chars between the two bounds, inclusive. Example: [char_range 'a' 'z'] for all lower case ascii letters. @since 0.13 *) val bytes_size : ?gen:char t -> int t -> bytes t (** Builds a bytes generator from a (non-negative) size generator. Accepts an optional character generator (the default is {!char}). @since 0.20 *) val bytes : ?gen:char t -> bytes t (** Builds a bytes generator. Bytes size is generated by {!nat}. Accepts an optional character generator (the default is {!char}). See also {!bytes_of} and {!bytes_printable} for versions without optional parameters. @since 0.20 *) val bytes_of : char t -> bytes t (** Builds a bytes generator using the given character generator. @since 0.20 *) val bytes_printable : bytes t (** Generator using the {!printable} character generator. @since 0.20 *) val bytes_small : bytes t (** Builds a bytes generator using the {!char} character generator, length is {!small_nat} @since 0.20 *) val bytes_small_of : char t -> bytes t (** Builds a bytes generator using the given character generator, length is {!small_nat}. @since 0.20 *) val string_size : ?gen:char t -> int t -> string t (** Builds a string generator from a (non-negative) size generator. Accepts an optional character generator (the default is {!char}). *) val string : ?gen:char t -> string t (** Builds a string generator. String size is generated by {!nat}. Accepts an optional character generator (the default is {!char}). See also {!string_of} and {!string_readable} for versions without optional parameters. *) val string_of : char t -> string t (** Builds a string generator using the given character generator. @since 0.11 *) val string_readable : string t (** Builds a string generator using the {!printable} character generator. @since 0.11 @deprecated use {!string_printable} *) [@@deprecated "see string_printable"] val string_printable : string t (** Builds a string generator using the {!printable} character generator. @since 0.18 *) val small_string : ?gen:char t -> string t (** Builds a string generator, length is {!small_nat} Accepts an optional character generator (the default is {!char}). *) val string_small : string t (** Builds a string generator using the {!char} character generator, length is {!small_nat} @since 0.20 *) val string_small_of : char t -> string t (** Builds a string generator using the given character generator, length is {!small_nat}. @since 0.20 *) val small_list : 'a t -> 'a list t (** Generates lists of small size (see {!small_nat}). @since 0.5.3 *) val flatten_l : 'a t list -> 'a list t (** Generate a list of elements from individual generators @since 0.13 *) val flatten_a : 'a t array -> 'a array t (** Generate an array of elements from individual generators @since 0.13 *) val flatten_opt : 'a t option -> 'a option t (** Generate an option from an optional generator @since 0.13 *) val flatten_res : ('a t, 'e) result -> ('a,'e) result t (** Generate a result from [Ok g], an error from [Error e] @since 0.13 *) val small_array : 'a t -> 'a array t (** Generates arrays of small size (see {!small_nat}). @since 0.10 *) (** {3 Tuple generators} Create tuple generators by composing individual element generators. For example, [Gen.(tup3 int char bool)] creates a [(int * char * bool)] triple generator by composing the [int], [char], and [bool] generators. *) val pair : 'a t -> 'b t -> ('a * 'b) t (** Generates pairs. *) val triple : 'a t -> 'b t -> 'c t -> ('a * 'b * 'c) t (** Generates triples. *) val quad : 'a t -> 'b t -> 'c t -> 'd t -> ('a * 'b * 'c * 'd) t (** Generates quadruples. @since 0.5.1 *) val tup2 : 'a t -> 'b t -> ('a * 'b) t (** Combines two generators into a 2-tuple generator. *) val tup3 : 'a t -> 'b t -> 'c t -> ('a * 'b * 'c) t (** Combines three generators into a 3-tuple generator. *) val tup4 : 'a t -> 'b t -> 'c t -> 'd t -> ('a * 'b * 'c * 'd) t (** Combines four generators into a 4-tuple generator. *) val tup5 : 'a t -> 'b t -> 'c t -> 'd t -> 'e t -> ('a * 'b * 'c * 'd * 'e) t (** Combines five generators into a 5-tuple generator. *) val tup6 : 'a t -> 'b t -> 'c t -> 'd t -> 'e t -> 'f t -> ('a * 'b * 'c * 'd * 'e * 'f) t (** Combines six generators into a 6-tuple generator. *) val tup7 : 'a t -> 'b t -> 'c t -> 'd t -> 'e t -> 'f t -> 'g t -> ('a * 'b * 'c * 'd * 'e * 'f * 'g) t (** Combines seven generators into a 7-tuple generator. *) 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 (** Combines eight generators into an 8-tuple generator. *) 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 (** Combines nine generators into a 9-tuple generator. *) val join : 'a t t -> 'a t (** Collapses a generator of generators to simply a generator. @since 0.5 *) val sized : 'a sized -> 'a t (** Creates a generator from a size-bounded generator by first generating a size using {!nat} and passing the result to the size-bounded generator. *) val sized_size : int t -> 'a sized -> 'a t (** Creates a generator from a size-bounded generator by first generating a size using the integer generator and passing the result to the size-bounded generator. @since 0.5 *) val fix : (('a -> 'b t) -> ('a -> 'b t)) -> 'a -> 'b t (** Parametrized fixpoint combinator for generating recursive values. The fixpoint is parametrized over an arbitrary state ('a), and the fixpoint computation may change the value of this state in the recursive calls. In particular, this can be used for size-bounded generators ('a is int). The passed size-parameter should decrease to ensure termination. *) (** Example: {[ type tree = Leaf of int | Node of tree * tree let leaf x = Leaf x let node x y = Node (x,y) let g = QCheck.Gen.(sized @@ fix (fun self n -> match n with | 0 -> map leaf nat | n -> frequency [1, map leaf nat; 2, map2 node (self (n/2)) (self (n/2))] )) ]} *) val nat_split2 : int -> (int * int) t (** [nat_split2 n] generates pairs [(n1, n2)] of natural numbers with [n1 + n2 = n]. This is useful to split sizes to combine sized generators. @since 0.18 *) val pos_split2 : int -> (int * int) t (** [pos_split2 n] generates pairs [(n1, n2)] of strictly positive (nonzero) natural numbers with [n1 + n2 = n]. @raise Invalid_argument unless [n >= 2]. This is useful to split sizes to combine sized generators. @since 0.18 *) val nat_split : size:int -> int -> int array t (** [nat_split ~size:k n] generates [k]-sized arrays [n1,n2,..nk] of natural numbers in [[0;n]] with [n1 + n2 + ... + nk = n]. This is useful to split sizes to combine sized generators. Complexity O(k log k). @since 0.18 *) val pos_split : size:int -> int -> int array t (** [pos_split ~size:k n] generates [k]-sized arrays [n1,n2,..nk] of strictly positive (non-zero) natural numbers with [n1 + n2 + ... + nk = n]. This is useful to split sizes to combine sized generators. Complexity O(k log k). @raise Invalid_argument unless [0 < k <= n] or [0 = k = n]. @since 0.18 *) val delay : (unit -> 'a t) -> 'a t (** Delay execution of some code until the generator is actually called. This can be used to manually implement recursion or control flow in a generator. @since 0.17 *) val ( let+ ) : 'a t -> ('a -> 'b) -> 'b t (** {{: https://ocaml.org/manual/bindingops.html} Binding operator} alias for {!map}. *) val ( and+ ) : 'a t -> 'b t -> ('a * 'b) t (** {{: https://ocaml.org/manual/bindingops.html} Binding operator} alias for {!pair}. *) val ( let* ) : 'a t -> ('a -> 'b t) -> 'b t (** {{: https://ocaml.org/manual/bindingops.html} Binding operator} alias for {!(>>=)}. *) val ( and* ) : 'a t -> 'b t -> ('a * 'b) t (** {{: https://ocaml.org/manual/bindingops.html} Binding operator} alias for {!pair}. *) (** {3 Debug generators} These functions should not be used in tests: they are provided for convenience to debug/investigate what values a generator produces. *) val generate : ?rand:Random.State.t -> n:int -> 'a t -> 'a list (** [generate ~n g] generates [n] instances of [g]. *) val generate1 : ?rand:Random.State.t -> 'a t -> 'a (** [generate1 g] generates one instance of [g]. *) end (** {1 Printing Values} *) module Print : sig (** The [Print] module offers combinators for printing generated values. *) type 'a t = 'a -> string (** Printer for values of type ['a]. *) val unit : unit t (** [unit] is a printer of unit. @since 0.6 *) val int : int t (** Integer printer. *) val int32 : int32 t (** 32-bit integer printer. @since 0.24 *) val int64 : int64 t (** 64-bit integer printer. @since 0.24 *) val bool : bool t (** Boolean printer. *) val float : float t (** Floating point number printer. *) val char : char t (** Character printer. *) val bytes : bytes t (** Bytes printer. @since 0.20 *) val string : string t (** String printer. *) val option : 'a t -> 'a option t (** Option printer. *) val result : 'a t -> 'e t -> ('a, 'e) result t (** Result printer. @since 0.24 *) val pair : 'a t -> 'b t -> ('a*'b) t (** Pair printer. Expects printers for each component. *) val triple : 'a t -> 'b t -> 'c t -> ('a*'b*'c) t (** Triple (3-tuple) printer. Expects printers for each component. *) val quad : 'a t -> 'b t -> 'c t -> 'd t -> ('a*'b*'c*'d) t (** Quadruple (4-tuple) printer. Expects printers for each component. *) val list : 'a t -> 'a list t (** List printer. Expects a printer for the list element type. *) val array : 'a t -> 'a array t (** Array printer. Expects a printer for the array entry type. *) val comap : ('a -> 'b) -> 'b t -> 'a t (** [comap f p] maps [p], a printer of type ['b], to a printer of type ['a] by first converting a printed value using [f : 'a -> 'b]. *) val tup2 : 'a t -> 'b t -> ('a * 'b) t (** 2-tuple printer. Expects printers for each component. *) val tup3 : 'a t -> 'b t -> 'c t -> ('a * 'b * 'c) t (** 3-tuple printer. Expects printers for each component. *) val tup4 : 'a t -> 'b t -> 'c t -> 'd t -> ('a * 'b * 'c * 'd) t (** 4-tuple printer. Expects printers for each component. *) val tup5 : 'a t -> 'b t -> 'c t -> 'd t -> 'e t -> ('a * 'b * 'c * 'd * 'e) t (** 5-tuple printer. Expects printers for each component. *) val tup6 : 'a t -> 'b t -> 'c t -> 'd t -> 'e t -> 'f t -> ('a * 'b * 'c * 'd * 'e * 'f) t (** 6-tuple printer. Expects printers for each component. *) val tup7 : 'a t -> 'b t -> 'c t -> 'd t -> 'e t -> 'f t -> 'g t -> ('a * 'b * 'c * 'd * 'e * 'f * 'g) t (** 7-tuple printer. Expects printers for each component. *) 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 (** 8-tuple printer. Expects printers for each component. *) 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 (** 9-tuple printer. Expects printers for each component. *) end (** {1 Shrinking Values} Shrinking is used to reduce the size of a counter-example. It tries to make the counter-example smaller, e.g., by decreasing an integer, or removing elements of a list, until the property to test holds again; it then returns the smallest value that still made the test fail. Shrinking is defined as a type {!Shrink.t} that takes an argument to shrink and produces an iterator of type {!Iter.t} of shrinking candidates. *) (** {2 Iterators} *) module Iter : sig (** [Iter] is compatible with the library "sequence". An iterator [i] is simply a function that accepts another function [f] (of type ['a -> unit]) and calls [f] on a sequence of elements [f x1; f x2; ...; f xn]. *) type 'a t = ('a -> unit) -> unit (** The type of iterators, underlying {!Shrink.t}. *) val empty : 'a t (** The empty iterator *) val return : 'a -> 'a t (** The constant iterator *) val (<*>) : ('a -> 'b) t -> 'a t -> 'b t (** Applicative operator for iterators, combining a function iterator and an argument iterator into a result generator. *) val (>>=) : 'a t -> ('a -> 'b t) -> 'b t (** Monadic bind operator for iterators. [i >>= f] passes each element of [i] to [f], iterating over each element of [f]'s resulting iterators. *) val map : ('a -> 'b) -> 'a t -> 'b t (** [map f i] returns an iterator of elements from [i], each of which have been applied to [f]. *) val map2 : ('a -> 'b -> 'c) -> 'a t -> 'b t -> 'c t (** [map f i j] returns an iterator of elements from [i] and [j], which have been applied to [f]. *) val (>|=) : 'a t -> ('a -> 'b) -> 'b t (** An infix synonym for {!map}. *) val append : 'a t -> 'a t -> 'a t (** [append a b] first iterates over [a]'s elements and then over [b]'s. *) val (<+>) : 'a t -> 'a t -> 'a t (** Synonym for {!append}. *) val of_list : 'a list -> 'a t (** [of_list xs] builds an iterator over the list elements of [xs]. *) val of_array : 'a array -> 'a t (** [of_array xs] builds an iterator over the array elements of [xs]. *) val pair : 'a t -> 'b t -> ('a * 'b) t (** [pair a b] iterates over pairs [(x,y)] with [x] coming from [a] and [y] coming from [b]. *) val triple : 'a t -> 'b t -> 'c t -> ('a * 'b * 'c) t (** [triple a b c] iterates over triples [(x,y,z)] with [x] coming from [a], [y] coming from [b], and [z] coming from [c]. *) val quad : 'a t -> 'b t -> 'c t -> 'd t -> ('a * 'b * 'c * 'd) t (** [quad a b c d] iterates over quadruples [(x,y,z,w)] with [x] coming from [a], [y] coming from [b], [z] coming from [c], and [w] coming from [d]. *) val find : ('a -> bool) -> 'a t -> 'a option (** [find p i] maps over the iterator [i], returning [Some _] when the predicate [p] is [true] and [None] otherwise. *) val filter : ('a -> bool) -> 'a t -> 'a t (** [filter p i] returns an iterator of elements from [i] satisfying [p]. *) val append_l : 'a t list -> 'a t (** Appends a list of iterators into a single iterator. @since 0.8 *) val flatten : 'a t t -> 'a t (** Flattens an iterator of iterators into a single iterator. @since 0.8 *) val ( let+ ) : 'a t -> ('a -> 'b) -> 'b t (** {{: https://ocaml.org/manual/bindingops.html} Binding operator} alias for {!map}. *) val ( and+ ) : 'a t -> 'b t -> ('a * 'b) t (** {{: https://ocaml.org/manual/bindingops.html} Binding operator} alias for {!pair}. *) val ( let* ) : 'a t -> ('a -> 'b t) -> 'b t (** {{: https://ocaml.org/manual/bindingops.html} Binding operator} alias for {!(>>=)}. *) val ( and* ) : 'a t -> 'b t -> ('a * 'b) t (** {{: https://ocaml.org/manual/bindingops.html} Binding operator} alias for {!pair}. *) end (** {2 Shrinkers} *) module Shrink : sig (** The [Shrink] module contains combinators to build up composite shrinkers for user-defined types Warning: A hand-written shrinker returning its own argument, will cause QCheck's shrinking phase to loop infinitely. *) type 'a t = 'a -> 'a Iter.t (** Given a counter-example, return an iterator on smaller versions of the counter-example. *) val nil : 'a t (** No shrink *) val unit : unit t (** unit shrinker. Does not produce any shrinking candidates. @since 0.6 *) val bool : bool t (** bool shrinker. Shrinks towards [false]. @since 0.23 *) val char : char t (** char shrinker. Shrinks towards ['a']. @since 0.6 *) val char_numeral : char t (** char digit shrinker. Shrinks towards ['0']. @since 0.19 *) val char_printable : char t (** Printable char shrinker. Shrinks towards ['a'] like [!char]. The output is also a printable character. @since 0.19 *) val int : int t (** int shrinker. Shrinks towards [0]. *) val int32 : int32 t (** int32 shrinker. Shrinks towards [0l]. @since 0.14 *) val int64 : int64 t (** int64 shrinker. Shrinks towards [0L]. @since 0.14 *) val option : 'a t -> 'a option t (** option shrinker. Shrinks towards [None]. [option shk] reduces [Some v] values using [shk] to reduce [v]. *) val result : 'a t -> 'e t -> ('a, 'e) result t (** result shrinker. [result ashk eshk] reduces [Ok a] values using [ashk] and [Error e] values using [eshk]. @since 0.24 *) val bytes : ?shrink:(char t) -> bytes t (** bytes shrinker. Shrinks towards shorter byte strings. @param shrink an optional [char] shrinker. @since 0.20 *) val string : ?shrink:(char t) -> string t (** string shrinker. Shrinks towards [""]. @param shrink an optional [char] shrinker. *) val filter : ('a -> bool) -> 'a t -> 'a t (** [filter f shrink] shrinks values the same as [shrink], but only keep smaller values that satisfy [f]. This way it's easy to preserve invariants that are enforced by generators, when shrinking values @since 0.8 *) val int_aggressive : int t (** Shrink integers by trying all smaller integers (can take a lot of time!) @since 0.7 *) val list : ?shrink:'a t -> 'a list t (** Try to shrink lists by removing one or more elements. @param shrink if provided, will be used to also try to reduce the elements of the list themselves (e.g. in an [int list] one can try to decrease the integers). *) val list_spine : 'a list t (** Try to shrink lists by removing one or more elements. @since 0.10 *) val list_elems : 'a t -> 'a list t (** Shrinks the elements of a list, without changing the list size. @since 0.10 *) val array : ?shrink:'a t -> 'a array t (** Shrink an array. @param shrink see {!list} *) val pair : 'a t -> 'b t -> ('a * 'b) t (** [pair a b] uses [a] to shrink the first element of tuples, then tries to shrink the second element using [b]. It is often better, when generating tuples, to put the "simplest" element first (atomic type rather than list, etc.) because it will be shrunk earlier. In particular, putting functions last might help. *) val triple : 'a t -> 'b t -> 'c t -> ('a * 'b * 'c) t (** Similar to {!pair} *) val quad : 'a t -> 'b t -> 'c t -> 'd t -> ('a * 'b * 'c * 'd) t (** Similar to {!pair} *) val tup2 : 'a t -> 'b t -> ('a * 'b) t (** [tup2 a b] uses [a] to shrink the first element of tuples, then tries to shrink the second element using [b]. It is often better, when generating tuples, to put the "simplest" element first (atomic type rather than list, etc.) because it will be shrunk earlier. In particular, putting functions last might help. *) val tup3 : 'a t -> 'b t -> 'c t -> ('a * 'b * 'c) t (** Similar to {!tup2} *) val tup4 : 'a t -> 'b t -> 'c t -> 'd t -> ('a * 'b * 'c * 'd) t (** Similar to {!tup2} *) val tup5 : 'a t -> 'b t -> 'c t -> 'd t -> 'e t -> ('a * 'b * 'c * 'd * 'e) t (** Similar to {!tup2} *) val tup6 : 'a t -> 'b t -> 'c t -> 'd t -> 'e t -> 'f t -> ('a * 'b * 'c * 'd * 'e * 'f) t (** Similar to {!tup2} *) val tup7 : 'a t -> 'b t -> 'c t -> 'd t -> 'e t -> 'f t -> 'g t -> ('a * 'b * 'c * 'd * 'e * 'f * 'g) t (** Similar to {!tup2} *) 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 (** Similar to {!tup2} *) 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 (** Similar to {!tup2} *) end (** {1 Arbitrary} A value of type ['a arbitrary] glues together a random generator, and optional functions for shrinking, printing, computing the size, etc. It is the "normal" way of describing how to generate values of a given type, to be then used in tests (see {!Test}). *) type 'a stat = string * ('a -> int) (** A statistic on a distribution of values of type ['a]. The function {b MUST} return a positive integer. *) type 'a arbitrary = private { gen: 'a Gen.t; print: ('a Print.t) option; (** print values *) small: ('a -> int) option; (** size of example *) shrink: ('a Shrink.t) option; (** shrink to smaller examples *) collect: ('a -> string) option; (** map value to tag, and group by tag *) stats: 'a stat list; (** statistics to collect and print *) } (** A value of type ['a arbitrary] is an object with a method for generating random values of type ['a], and additional methods to compute the size of values, print them, and possibly shrink them into smaller counter-examples. {b NOTE} the collect field is unstable and might be removed, or moved into {!Test}. Made private since 0.8 *) val make : ?print:'a Print.t -> ?small:('a -> int) -> ?shrink:'a Shrink.t -> ?collect:('a -> string) -> ?stats:'a stat list -> 'a Gen.t -> 'a arbitrary (** Builder for arbitrary. Default is to only have a generator, but other arguments can be added. @param print printer for values (counter-examples) @param collect for statistics @param shrink to shrink counter-examples *) (** {2 Adjusting arbitrary generators } There is a range to [get] and [set] fields on an arbitrary record type. *) val set_print : 'a Print.t -> 'a arbitrary -> 'a arbitrary val set_small : ('a -> int) -> 'a arbitrary -> 'a arbitrary val set_shrink : 'a Shrink.t -> 'a arbitrary -> 'a arbitrary val set_collect : ('a -> string) -> 'a arbitrary -> 'a arbitrary val set_stats : 'a stat list -> 'a arbitrary -> 'a arbitrary (** @since 0.6 *) val add_shrink_invariant : ('a -> bool) -> 'a arbitrary -> 'a arbitrary (** Update shrinker by only keeping smaller values satisfying the given invariant. @since 0.8 *) val set_gen : 'a Gen.t -> 'a arbitrary -> 'a arbitrary (** Change the generator @since 0.7 *) val add_stat : 'a stat -> 'a arbitrary -> 'a arbitrary (** Add a statistic to the arbitrary instance. @since 0.6 *) val gen : 'a arbitrary -> 'a Gen.t (** Access the underlying random generator of this arbitrary object. @since 0.6 *) val get_gen : 'a arbitrary -> 'a Gen.t (** Access the underlying random generator of this arbitrary object. @since 0.6 *) val get_print : 'a arbitrary -> 'a Print.t option (** {2 Primitive combinators for arbitrary} *) val unit : unit arbitrary (** Always generates [()], obviously. *) val bool : bool arbitrary (** Uniform boolean generator. *) val float : float arbitrary (** Generates regular floats (no nan and no infinities). *) (* FIXME: does not generate nan nor infinity I think. *) val pos_float : float arbitrary (** Positive float generator (no nan and no infinities). *) val neg_float : float arbitrary (** Negative float generator (no nan and no infinities). *) val float_bound_inclusive : float -> float arbitrary (** [float_bound_inclusive n] is uniform between [0] and [n] included. If [bound] is negative, the result is negative or zero. If [bound] is 0, the result is 0. @since 0.11 *) val float_bound_exclusive : float -> float arbitrary (** [float_bound_exclusive n] is uniform between [0] included and [n] excluded. If [bound] is negative, the result is negative or zero. @raise Invalid_argument if [bound] is zero. @since 0.11 *) val float_range : float -> float -> float arbitrary (** [float_range low high] is uniform between [low] included and [high] included. @raise Invalid_argument if [low > high] or if the range is larger than [max_float]. @since 0.11 *) val exponential : float -> float arbitrary (** [exponential m] generates floating-point numbers following an exponential distribution with a mean of [m]. @raise Invalid_argument if [m] is NaN. @since 0.23 *) val int : int arbitrary (** Int generator. Uniformly distributed. *) val int_bound : int -> int arbitrary (** [int_bound n] is uniform between [0] and [n] included. *) val int_range : int -> int -> int arbitrary (** [int_range a b] is uniform between [a] and [b] included. [b] must be larger than [a]. *) val small_nat : int arbitrary (** Small unsigned integers. @since 0.5.1 *) val small_int : int arbitrary (** Small unsigned integers. See {!Gen.small_int}. @deprecated use {!small_signed_int}. *) val small_signed_int : int arbitrary (** Small signed integers. @since 0.5.2 *) val (--) : int -> int -> int arbitrary (** Synonym for {!int_range}. *) val int32 : int32 arbitrary (** Int32 generator. Uniformly distributed. *) val int64 : int64 arbitrary (** Int64 generator. Uniformly distributed. *) val pos_int : int arbitrary (** Positive int generator (0 included). Uniformly distributed. See {!Gen.pint} *) val small_int_corners : unit -> int arbitrary (** As [small_int], but each newly created generator starts with a list of corner cases before falling back on random generation. Note that [small_int_corners ()] is stateful, meaning that once the list of corner cases has been emitted, subsequent calls will not reproduce them. As a consequence, in the following example, the first test fails with a counter example, whereas the second rerun does not: {[ let gen = QCheck.small_int_corners () let t = QCheck.Test.make ~name:"never max_int" gen (fun i -> i <> max_int) let _ = QCheck_base_runner.run_tests ~verbose:true [t;t] ]} *) val neg_int : int arbitrary (** Negative int generator (0 included, see {!Gen.neg_int}). The distribution is similar to that of [small_int], not of [pos_int]. *) val char : char arbitrary (** Uniformly distributed on all the chars (not just ascii or valid latin-1). *) val printable_char : char arbitrary (** Uniformly distributed over a subset of printable ascii chars. Ascii character codes 32 to 126, inclusive - or ['\n'] with code 10. *) val numeral_char : char arbitrary (** Uniformly distributed over ['0'..'9']. *) val bytes_gen_of_size : int Gen.t -> char Gen.t -> bytes arbitrary (** Builds a bytes generator from a (non-negative) size generator and a character generator. @since 0.20 *) val bytes_of : char Gen.t -> bytes arbitrary (** Generates bytes with a distribution of length of {!Gen.nat}. @since 0.20 *) val bytes : bytes arbitrary (** Generates bytes with a distribution of length of {!Gen.nat} and distribution of characters of [char]. @since 0.20 *) val bytes_small : bytes arbitrary (** Same as {!bytes} but with a small length (ie {!Gen.small_nat} ). @since 0.20 *) val bytes_small_of : char Gen.t -> bytes arbitrary (** Same as {!bytes_of} but with a small length (ie {!Gen.small_nat} ). @since 0.20 *) val bytes_of_size : int Gen.t -> bytes arbitrary (** Generates bytes with distribution of characters of [char]. @since 0.20 *) val bytes_printable : bytes arbitrary (** Generates bytes with a distribution of length of {!Gen.nat} and distribution of characters of [printable_char]. @since 0.20 *) val string_gen_of_size : int Gen.t -> char Gen.t -> string arbitrary (** Builds a string generator from a (non-negative) size generator and a character generator. *) val string_gen : char Gen.t -> string arbitrary (** Generates strings with a distribution of length of {!Gen.nat}. *) val string_of : char Gen.t -> string arbitrary (** Synonym for {!string_gen} added for convenience. @since 0.20 *) val string : string arbitrary (** Generates strings with a distribution of length of {!Gen.nat} and distribution of characters of [char]. *) val small_string : string arbitrary (** Same as {!string} but with a small length (ie {!Gen.small_nat} ). *) val string_small : string arbitrary (** Synonym for [small_string] added for convenience. @since 0.20 *) val string_small_of : char Gen.t -> string arbitrary (** Same as {!string_of} but with a small length (ie {!Gen.small_nat} ). @since 0.20 *) val small_list : 'a arbitrary -> 'a list arbitrary (** Generates lists of small size (see {!Gen.small_nat}). @since 0.5.3 *) val string_of_size : int Gen.t -> string arbitrary (** Generates strings with distribution of characters of [char]. *) val printable_string : string arbitrary (** Generates strings with a distribution of length of {!Gen.nat} and distribution of characters of [printable_char]. *) val string_printable : string arbitrary (** Synonym for [printable_string] added for convenience. @since 0.20 *) val printable_string_of_size : int Gen.t -> string arbitrary (** Generates strings with distribution of characters of [printable_char]. *) val string_printable_of_size : int Gen.t -> string arbitrary (** Synonym for [printable_string_of_size] added for convenience. @since 0.20 *) val small_printable_string : string arbitrary (** Generates strings with a length of [small_nat] and distribution of characters of [printable_char]. *) val string_small_printable : string arbitrary (** Synonym for [small_printable_string] added for convenience. @since 0.20 *) val numeral_string : string arbitrary (** Generates strings with a distribution of length of {!Gen.nat} and distribution of characters of [numeral_char]. *) val string_numeral : string arbitrary (** Synonym for [numeral_string] added for convenience. @since 0.20 *) val numeral_string_of_size : int Gen.t -> string arbitrary (** Generates strings with a distribution of characters of [numeral_char]. *) val string_numeral_of_size : int Gen.t -> string arbitrary (** Synonym for [numeral_string_of_size] added for convenience. @since 0.20 *) val list : 'a arbitrary -> 'a list arbitrary (** Generates lists with length generated by {!Gen.nat}. *) val list_of_size : int Gen.t -> 'a arbitrary -> 'a list arbitrary (** Generates lists with length from the given distribution. *) val array : 'a arbitrary -> 'a array arbitrary (** Generates arrays with length generated by {!Gen.nat}. *) val array_of_size : int Gen.t -> 'a arbitrary -> 'a array arbitrary (** Generates arrays with length from the given distribution. *) val option : ?ratio:float -> 'a arbitrary -> 'a option arbitrary (** Choose between returning Some random value with optional ratio, or None. *) val result : ?ratio:float -> 'a arbitrary -> 'e arbitrary -> ('a, 'e) result arbitrary (** [result ~ratio okgen errgen] generates [Ok v] with [v] coming from [okgen] or [Error e] with [e] coming from [errgen], depending on [ratio]. The latter is a float between [0.] and [1.] indicating the probability of a sample to be [Ok _] rather than [Error _]. @since 0.24 *) (** {2 Tuples of arbitrary generators} These shrink on [gen1], then [gen2], then ... *) val pair : 'a arbitrary -> 'b arbitrary -> ('a * 'b) arbitrary (** Combines two generators into a generator of pairs. Order of elements can matter (w.r.t shrinking, see {!Shrink.pair}) *) val triple : 'a arbitrary -> 'b arbitrary -> 'c arbitrary -> ('a * 'b * 'c) arbitrary (** Combines three generators into a generator of 3-tuples. Order matters for shrinking, see {!Shrink.pair} and the likes *) val quad : 'a arbitrary -> 'b arbitrary -> 'c arbitrary -> 'd arbitrary -> ('a * 'b * 'c * 'd) arbitrary (** Combines four generators into a generator of 4-tuples. Order matters for shrinking, see {!Shrink.pair} and the likes *) val tup2 : 'a arbitrary -> 'b arbitrary -> ('a * 'b) arbitrary (** Combines two generators into a 2-tuple generator. Order of elements can matter (w.r.t shrinking, see {!Shrink.tup2}) Prints as many elements as available printers *) val tup3 : 'a arbitrary -> 'b arbitrary -> 'c arbitrary -> ('a * 'b * 'c) arbitrary (** Combines three generators into a 3-tuple generator. Order of elements can matter (w.r.t shrinking, see {!Shrink.tup2}) Prints as many elements as available printers *) val tup4 : 'a arbitrary -> 'b arbitrary -> 'c arbitrary -> 'd arbitrary -> ('a * 'b * 'c * 'd) arbitrary (** Combines four generators into a 4-tuple generator. Order of elements can matter (w.r.t shrinking, see {!Shrink.tup2}) Prints as many elements as available printers *) val tup5 : 'a arbitrary -> 'b arbitrary -> 'c arbitrary -> 'd arbitrary -> 'e arbitrary -> ('a * 'b * 'c * 'd * 'e) arbitrary (** Combines five generators into a 5-tuple generator. Order of elements can matter (w.r.t shrinking, see {!Shrink.tup2}) Prints as many elements as available printers *) val tup6 : 'a arbitrary -> 'b arbitrary -> 'c arbitrary -> 'd arbitrary -> 'e arbitrary -> 'f arbitrary -> ('a * 'b * 'c * 'd * 'e * 'f) arbitrary (** Combines six generators into a 6-tuple generator. Order of elements can matter (w.r.t shrinking, see {!Shrink.tup2}) Prints as many elements as available printers *) val tup7 : 'a arbitrary -> 'b arbitrary -> 'c arbitrary -> 'd arbitrary -> 'e arbitrary -> 'f arbitrary -> 'g arbitrary -> ('a * 'b * 'c * 'd * 'e * 'f * 'g) arbitrary (** Combines seven generators into a 7-tuple generator. Order of elements can matter (w.r.t shrinking, see {!Shrink.tup2}) Prints as many elements as available printers *) val tup8 : 'a arbitrary -> 'b arbitrary -> 'c arbitrary -> 'd arbitrary -> 'e arbitrary -> 'f arbitrary -> 'g arbitrary -> 'h arbitrary -> ('a * 'b * 'c * 'd * 'e * 'f * 'g * 'h) arbitrary (** Combines eight generators into a 8-tuple generator. Order of elements can matter (w.r.t shrinking, see {!Shrink.tup2}) Prints as many elements as available printers *) val tup9 : 'a arbitrary -> 'b arbitrary -> 'c arbitrary -> 'd arbitrary -> 'e arbitrary -> 'f arbitrary -> 'g arbitrary -> 'h arbitrary -> 'i arbitrary -> ('a * 'b * 'c * 'd * 'e * 'f * 'g * 'h * 'i) arbitrary (** Combines nine generators into a 9-tuple generator. Order of elements can matter (w.r.t shrinking, see {!Shrink.tup2}) Prints as many elements as available printers *) (** {2 Combinatoric arbitrary combinators } *) val choose : 'a arbitrary list -> 'a arbitrary (** Choose among the given list of generators. The list must not be empty; if it is [Invalid_argument] is raised. *) val oneofl : ?print:'a Print.t -> ?collect:('a -> string) -> 'a list -> 'a arbitrary (** Pick an element randomly in the list. *) val oneofa : ?print:'a Print.t -> ?collect:('a -> string) -> 'a array -> 'a arbitrary (** Pick an element randomly in the array. *) val oneof : 'a arbitrary list -> 'a arbitrary (** Pick a generator among the list, randomly. @deprecated this function is badly specified and will not use shrinkers appropriately. Consider using {!Gen.oneof} and then {!make} to build a well behaved arbitrary instance. *) val always : ?print:'a Print.t -> 'a -> 'a arbitrary (** Always return the same element. *) val frequency : ?print:'a Print.t -> ?small:('a -> int) -> ?shrink:'a Shrink.t -> ?collect:('a -> string) -> (int * 'a arbitrary) list -> 'a arbitrary (** Similar to {!oneof} but with frequencies. *) val frequencyl : ?print:'a Print.t -> ?small:('a -> int) -> (int * 'a) list -> 'a arbitrary (** Same as {!oneofl}, but each element is paired with its frequency in the probability distribution (the higher, the more likely). *) val frequencya : ?print:'a Print.t -> ?small:('a -> int) -> (int * 'a) array -> 'a arbitrary (** Same as {!frequencyl}, but with an array. *) val map : ?rev:('b -> 'a) -> ('a -> 'b) -> 'a arbitrary -> 'b arbitrary (** [map f a] returns a new arbitrary instance that generates values using [a#gen] and then transforms them through [f]. @param rev if provided, maps values back to type ['a] so that the printer, shrinker, etc. of [a] can be used. We assume [f] is monotonic in this case (that is, smaller inputs are transformed into smaller outputs). *) val map_same_type : ('a -> 'a) -> 'a arbitrary -> 'a arbitrary (** Specialization of [map] when the transformation preserves the type, which makes shrinker, printer, etc. still relevant. *) val map_keep_input : ?print:'b Print.t -> ?small:('b -> int) -> ('a -> 'b) -> 'a arbitrary -> ('a * 'b) arbitrary (** [map_keep_input f a] generates random values from [a], and maps them into values of type ['b] using the function [f], but it also keeps the original value. For shrinking, it is assumed that [f] is monotonic and that smaller input values will map into smaller values. @param print optional printer for the [f]'s output. *) (** {1 Tests} A test is a universal property of type [foo -> bool] for some type [foo], with an object of type [foo arbitrary] used to generate, print, etc. values of type [foo]. The main features of this module are: - {!Test.make} to build a test, - {!Test.make_neg} to build a negative test that is expected not to satisfy the tested property, - {!Test.check_exn} to run a single test with a simple runner. 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. For more serious testing, it is recommended to create a testsuite and use a full-fledged runner: - {!QCheck_base_runner} is a QCheck-only runner (useful if you don't have or don't need another test framework) - {!QCheck_alcotest} interfaces to the Alcotest framework - {!QCheck_ounit} interfaces to the to OUnit framework *) (** {2 Test Results } *) module TestResult : sig (** Module to represent the result of running a test *) type 'a counter_ex = 'a QCheck2.TestResult.counter_ex = { instance: 'a; (** The counter-example(s) *) shrink_steps: int; (** How many shrinking steps for this counterex *) msg_l: string list; (** messages. @since 0.7 *) } type 'a failed_state = 'a counter_ex list (** Result state. changed in 0.10 (move to inline records, add Fail_other) *) type 'a state = 'a QCheck2.TestResult.state = | Success | Failed of { instances: 'a failed_state; (** Failed instance(s) *) } | Failed_other of {msg: string} | Error of { instance: 'a counter_ex; exn: exn; backtrace: string; } (** Error, backtrace, and instance that triggered it *) (* result returned by running a test *) type 'a t = 'a QCheck2.TestResult.t val get_count : _ t -> int (** Get the count of a cell. @since 0.5.3 *) val get_count_gen : _ t -> int val get_state : 'a t -> 'a state val collect : _ t -> (string,int) Hashtbl.t option (** Obtain statistics @since 0.6 *) val stats : 'a t -> ('a stat * (int,int) Hashtbl.t) list (** Obtain statistics @since 0.6 *) val warnings : _ t -> string list (** Obtain list of warnings @since 0.10 *) val is_success : _ t -> bool (** Returns true iff the state if [Success] @since 0.9 *) end (** {2 Defining Tests } *) (** Module related to individual tests. Since 0.18 most of it moved to {!QCheck2}, and the type ['a cell] was made a private implementation detail. *) module Test : sig type res = QCheck2.Test.res = | Success | Failure | FalseAssumption | Error of exn * string type 'a event = 'a QCheck2.Test.event = | Generating | Collecting of 'a | Testing of 'a | Shrunk of int * 'a | Shrinking of int * int * 'a type 'a cell = 'a QCheck2.Test.cell type 'a handler = 'a QCheck2.Test.handler type 'a step = 'a QCheck2.Test.step type 'a callback = 'a QCheck2.Test.callback type t = QCheck2.Test.t val fail_report : string -> 'a (** Fail the test with some additional message that will be reported. @since 0.7 *) val fail_reportf : ('a, Format.formatter, unit, 'b) format4 -> 'a (** Format version of {!fail_report} @since 0.7 *) val make_cell : ?if_assumptions_fail:([`Fatal | `Warning] * float) -> ?count:int -> ?long_factor:int -> ?negative:bool -> ?max_gen:int -> ?max_fail:int -> ?small:('a -> int) -> ?retries:int -> ?name:string -> 'a arbitrary -> ('a -> bool) -> 'a cell (** [make_cell arb prop] builds a test that checks property [prop] on instances of the generator [arb]. @param name the name of the test. @param count number of test cases to run, counting only the test cases which satisfy preconditions. @param retries number of times to retry the tested property while shrinking. @param long_factor the factor by which to multiply count, max_gen and max_fail when running a long test (default: 1). @param negative whether the test is expected not to satisfy the tested property. @param max_gen maximum number of times the generation function is called in total to replace inputs that do not satisfy preconditions (should be >= count). @param max_fail maximum number of failures before we stop generating inputs. This is useful if shrinking takes too much time. @param small kept for compatibility reasons; if provided, replaces the field [arbitrary.small]. If there is no shrinking function but there is a [small] function, only the smallest failures will be printed. @param if_assumptions_fail the minimum fraction of tests that must satisfy the precondition for a success to be considered valid. The fraction should be between 0. and 1. A warning will be emitted otherwise if the flag is [`Warning], the test will be a failure if the flag is [`Fatal]. (since 0.10) *) val get_law : 'a cell -> ('a -> bool) (** @deprecated use {!QCheck2.Test.get_law} instead *) val get_name : _ cell -> string (** @deprecated use {!QCheck2.Test.get_name} instead *) val set_name : _ cell -> string -> unit (** @deprecated use {!QCheck2.Test.set_name} instead *) val get_count : _ cell -> int (** Get the count of a cell. @deprecated use {!QCheck2.Test.get_count} instead @since 0.5.3 *) val get_long_factor : _ cell -> int (** Get the long factor of a cell. @deprecated use {!QCheck2.Test.get_long_factor} instead @since 0.5.3 *) val make : ?if_assumptions_fail:([`Fatal | `Warning] * float) -> ?count:int -> ?long_factor:int -> ?max_gen:int -> ?max_fail:int -> ?small:('a -> int) -> ?retries:int -> ?name:string -> 'a arbitrary -> ('a -> bool) -> t (** [make arb prop] builds a test that checks property [prop] on instances of the generator [arb]. See {!make_cell} for a description of the parameters. *) val make_neg : ?if_assumptions_fail:([`Fatal | `Warning] * float) -> ?count:int -> ?long_factor:int -> ?max_gen:int -> ?max_fail:int -> ?small:('a -> int) -> ?retries:int -> ?name:string -> 'a arbitrary -> ('a -> bool) -> t (** [make_neg arb prop] builds a test that checks property [prop] on instances of the generator [arb]. The test is considered negative, meaning that it is expected not to satisfy the tested property. This information is recorded in an underlying test [cell] entry and interpreted suitably by test runners. See {!make_cell} for a description of the parameters. *) include module type of QCheck2.Test_exceptions val print_instance : 'a cell -> 'a -> string val print_c_ex : 'a cell -> 'a TestResult.counter_ex -> string val print_fail : 'a cell -> string -> 'a TestResult.counter_ex list -> string val print_fail_other : string -> msg:string -> string val print_error : ?st:string -> 'a cell -> string -> 'a TestResult.counter_ex * exn -> string val print_test_fail : string -> string list -> string val print_test_error : string -> string -> exn -> string -> string val check_cell : ?long:bool -> ?call:'a callback -> ?step:'a step -> ?handler:'a handler -> ?rand:Random.State.t -> 'a cell -> 'a TestResult.t (** See {!QCheck2.Test.check_cell}. *) val check_cell_exn : ?long:bool -> ?call:'a callback -> ?step:'a step -> ?handler:'a handler -> ?rand:Random.State.t -> 'a cell -> unit (** See {!QCheck2.Test.check_cell_exn}. *) val check_exn : ?long:bool -> ?rand:Random.State.t -> t -> unit (** See {!QCheck2.Test.check_exn}. *) end (** {2 Sub-tests} *) (** The infrastructure used to find counter-examples to properties can also be used to find data satisfying a predicate, {i within a property being tested}. See {:https://github.com/c-cube/qcheck/issues/31} *) exception No_example_found of string val find_example : ?name:string -> ?count:int -> f:('a -> bool) -> 'a Gen.t -> 'a Gen.t (** [find_example ~f gen] uses [gen] to generate some values of type ['a], and checks them against [f]. If such a value is found, it is returned. Otherwise an exception is raised. {b NOTE} this should only be used from within a property in {!Test.make}. @param count number of attempts. @param name description of the example to find (used in the exception). @param f the property that the example must satisfy. @raise No_example_found if no example is found within [count] tries. @since 0.6 *) val find_example_gen : ?rand:Random.State.t -> ?name:string -> ?count:int -> f:('a -> bool) -> 'a Gen.t -> 'a (** Toplevel version of {!find_example}. [find_example_gen ~f arb ~n] is roughly the same as [Gen.generate1 (find_example ~f arb |> gen)]. @param rand the random state to use to generate inputs. @raise No_example_found if no example was found within [count] tries. @since 0.6 *) (** {1 Generating Functions} The [QCheck] module supports generation of pure function values. The implementation is inspired from {:https://blogs.janestreet.com/quickcheck-for-core/} and {{:https://dl.acm.org/doi/abs/10.1145/2364506.2364516}Koen Claessen's "Shrinking and Showing Functions"}. Generated function arguments are of type {!Observable.t} and function results are of type {{!section:arbitrary}[arbitrary]}. Underneath the hood, generated function values have a table-based representation. They therefore need to be applied in a special way, e.g., with {!Fn.apply}. *) (** {2 Observing arguments} *) module Observable : sig (** Observables are usable as arguments for random functions. The random function will observe its arguments in a way that is determined from the observable instance. @since 0.6 *) (** An observable for ['a], packing a printer and other things. *) type -'a t val equal : 'a t -> 'a -> 'a -> bool val hash : 'a t -> 'a -> int val print : 'a t -> 'a Print.t val unit : unit t val bool : bool t val int : int t val int32 : int32 t (** @since 0.24 *) val int64 : int64 t (** @since 0.24 *) val float : float t val string : string t val bytes : bytes t (** @since 0.20 *) val char : char t val make : ?eq:('a -> 'a -> bool) -> ?hash:('a -> int) -> 'a Print.t -> 'a t val map : ('a -> 'b) -> 'b t -> 'a t val option : 'a t -> 'a option t val result : 'a t -> 'e t -> ('a, 'e) result t (** @since 0.24 *) val list : 'a t -> 'a list t val array : 'a t -> 'a array t val pair : 'a t -> 'b t -> ('a * 'b) t val triple : 'a t -> 'b t -> 'c t -> ('a * 'b * 'c) t val quad : 'a t -> 'b t -> 'c t -> 'd t -> ('a * 'b * 'c * 'd) t end (** {2 Deprecated function generator combinators } *) val fun1_unsafe : 'a arbitrary -> 'b arbitrary -> ('a -> 'b) arbitrary (** Generator of functions of arity 1. The functions are always pure and total functions: - when given the same argument (as decided by Stdlib.(=)), it returns the same value - it never does side effects, like printing or never raise exceptions etc. The functions generated are really printable. renamed from {!fun1} since 0.6 @deprecated use {!fun_} instead. @since 0.6 *) val fun2_unsafe : 'a arbitrary -> 'b arbitrary -> 'c arbitrary -> ('a -> 'b -> 'c) arbitrary (** Generator of functions of arity 2. The remark about [fun1] also apply here. renamed from {!fun2} since 0.6 @deprecated use {!fun_} instead since 0.6 *) type _ fun_repr (** Internal data for functions. A ['f fun_] is a function of type ['f], fundamentally. *) (** A function packed with the data required to print/shrink it. See {!Fn} to see how to apply, print, etc. such a function. One can also directly pattern match on it to obtain the executable function. For example: {[ QCheck.Test.make QCheck.(pair (fun1 Observable.int bool) (small_list int)) (fun (Fun (_,f), l) -> l=(List.rev_map f l |> List.rev l)) ]} *) type _ fun_ = | Fun : 'f fun_repr * 'f -> 'f fun_ module Fn : sig (** A utility module of helpers for printing, shrinking, and applying generated function values. @since 0.6 *) type 'a t = 'a fun_ val print : _ t Print.t val shrink : _ t Shrink.t val apply : 'f t -> 'f end (** {2 Defining function generators } *) val fun1 : 'a Observable.t -> 'b arbitrary -> ('a -> 'b) fun_ arbitrary (** [fun1 o ret] makes random functions that take an argument observable via [o] and map to random values generated from [ret]. To write functions with multiple arguments, it's better to use {!Tuple} or {!Observable.pair} rather than applying {!fun_} several times (shrinking will be faster). @since 0.6 *) val fun2 : 'a Observable.t -> 'b Observable.t -> 'c arbitrary -> ('a -> 'b -> 'c) fun_ arbitrary (** @since 0.6 *) val fun3 : 'a Observable.t -> 'b Observable.t -> 'c Observable.t -> 'd arbitrary -> ('a -> 'b -> 'c -> 'd) fun_ arbitrary (** @since 0.6 *) val fun4 : 'a Observable.t -> 'b Observable.t -> 'c Observable.t -> 'd Observable.t -> 'e arbitrary -> ('a -> 'b -> 'c -> 'd -> 'e) fun_ arbitrary (** @since 0.6 *) (** {2 Tuples of observables } To circumvent the arity boundaries of {!fun1}, ..., {!fun4}, one can instead define uncurried functions, instead accepting a tuple argument. A resulting function then needs to be applied with {!fun_nary}. *) module Tuple : sig (** Heterogeneous tuple, used to pass any number of arguments to a function. *) type 'a t = | Nil : unit t | Cons : 'a * 'b t -> ('a * 'b) t val nil : unit t val cons : 'a -> 'b t -> ('a * 'b) t (** How to observe a {{!t}['a t]} *) type 'a obs val o_nil : unit obs val o_cons : 'a Observable.t -> 'b obs -> ('a * 'b) obs module Infix : sig val (@::) : 'a -> 'b t -> ('a * 'b) t (** Alias to {!cons}. *) val (@->) : 'a Observable.t -> 'b obs -> ('a * 'b) obs (** Alias to {!o_cons}. *) end include module type of Infix val observable : 'a obs -> 'a t Observable.t end val fun_nary : 'a Tuple.obs -> 'b arbitrary -> ('a Tuple.t -> 'b) fun_ arbitrary (** [fun_nary] makes random n-ary functions. Example: {[ let module O = Observable in fun_nary Tuple.(O.int @-> O.float @-> O.string @-> o_nil) bool ]} @since 0.6 *) qcheck-0.25/src/core/QCheck2.ml000066400000000000000000002304561477416744200162210ustar00rootroot00000000000000(* QCheck: Random testing for OCaml copyright (c) 2013-2017, Guillaume Bury, Simon Cruanes, Vincent Hugot, Jan Midtgaard, Julien Debon, Valentin Chaboche all rights reserved. *) (** {1 Quickcheck inspired property-based testing} *) let poly_compare=compare module RS = struct (* Poor man's splitter for version < 5.0 *) (* This definition is shadowed by the [include] on OCaml >=5.0 *) (* For the record, this is a hack: Seeding a child RNG based on the output of a parent RNG does not create an independent RNG. *) (* copy of 4.14 Random.State.t to create a record of the right shape *) type rs = { st : int array; mutable idx : int } [@@warning "-69"] let split rs : Random.State.t = let rs' = { st = Array.init 55 (fun _i -> Random.State.bits rs); idx = 0 } in for i = 0 to 54 do rs'.st.(i) <- (rs'.st.(i) lxor rs'.st.((i+1) mod 55)) land 0x3FFFFFFF; done; Obj.magic rs' (* sorry! *) include Random.State (* This is how OCaml 5.0 splits: *) (* Split a new PRNG off the given PRNG *) (* let split s = let i1 = bits64 s in let i2 = bits64 s in let i3 = bits64 s in let i4 = bits64 s in mk i1 i2 i3 i4 *) end let rec foldn ~f ~init:acc i = if i = 0 then acc else foldn ~f ~init:(f acc i) (i-1) let _opt_map_2 ~f a b = match a, b with | Some x, Some y -> Some (f x y) | _ -> None let _opt_map_3 ~f a b c = match a, b, c with | Some x, Some y, Some z -> Some (f x y z) | _ -> None let _opt_map_4 ~f a b c d = match a, b, c, d with | Some x, Some y, Some z, Some w -> Some (f x y z w) | _ -> None let _opt_sum a b = match a, b with | Some _, _ -> a | None, _ -> b let sum_int = List.fold_left (+) 0 let rec list_split l len acc = match len,l with | _,[] | 0,_ -> List.rev acc, l | _,x::xs -> list_split xs (len-1) (x::acc) exception Failed_precondition (* raised if precondition is false *) exception No_example_found of string (* raised if an example failed to be found *) let assume b = if not b then raise Failed_precondition let assume_fail () = raise Failed_precondition let (==>) b1 b2 = if b1 then b2 else raise Failed_precondition (** Enhancement of Stdlib [Seq] to backport some recent functions, and add a few useful others. *) module Seq = struct include Seq (* The following functions are copied from https://github.com/ocaml/ocaml/blob/trunk/stdlib/seq.ml to support older OCaml versions. *) let rec unfold f u () = match f u with | None -> Nil | Some (x, u') -> Cons (x, unfold f u') let rec append seq1 seq2 () = match seq1() with | Nil -> seq2() | Cons (x, next) -> Cons (x, append next seq2) let cons x next () = Cons (x, next) let rec force_drop n xs = match xs() with | Nil -> Nil | Cons (_, xs) -> let n = n - 1 in if n = 0 then xs() else force_drop n xs let drop n xs = if n < 0 then invalid_arg "Seq.drop" else if n = 0 then xs else fun () -> force_drop n xs (* End of copy of old functions. *) let is_empty (seq : _ t) : bool = match seq () with | Nil -> true | _ -> false (** Take at most [n] values. *) let rec take (n : int) (seq : _ t) : _ t = fun () -> match (n, seq ()) with | (0, _) | (_, Nil) -> Nil | (n, Cons (a, rest)) -> Cons (a, take (n - 1) rest) let hd (l : 'a t) : 'a option = match l () with | Nil -> None | Cons (hd, _) -> Some hd (** Useful to improve [Seq] code perf when chaining functions *) let apply (l : 'a t) : 'a node = l () end module Shrink = struct module type Number = sig type t val equal : t -> t -> bool val div : t -> t -> t val add : t -> t -> t val sub : t -> t -> t val of_int : int -> t end let number_towards (type a) (module Number : Number with type t = a) ~(destination : a) (x : a) : a Seq.t = fun () -> Seq.unfold (fun current_shrink -> if Number.equal current_shrink x then None else ( (* Halve the operands before subtracting them so they don't overflow. Consider [number_towards min_int max_int] *) let half_diff = Number.sub (Number.div x (Number.of_int 2)) (Number.div current_shrink (Number.of_int 2)) in if half_diff = Number.of_int 0 (* [current_shrink] is the last valid shrink candidate, put [x] as next step to make sure we stop *) then Some (current_shrink, x) else Some (current_shrink, Number.add current_shrink half_diff) )) destination () let int_towards destination x = fun () -> let module Int : Number with type t = int = struct include Int let of_int = Fun.id end in number_towards (module Int) ~destination x () let int32_towards destination x = fun () -> number_towards (module Int32) ~destination x () let int64_towards destination x = fun () -> number_towards (module Int64) ~destination x () (** Arbitrarily limit to 15 elements as dividing a [float] by 2 doesn't converge quickly towards the destination. *) let float_towards destination x = fun () -> number_towards (module Float) ~destination x |> Seq.take 15 |> Seq.apply let int_aggressive_towards (destination : int) (n : int) : int Seq.t = fun () -> Seq.unfold (fun current -> if current = n then None else if current < n then let next = succ current in Some (next, next) else let next = pred current in Some (next, next) ) destination () let int_aggressive n = fun () -> int_aggressive_towards 0 n () end module Tree = struct type 'a t = Tree of 'a * ('a t) Seq.t let root (Tree (root, _) : 'a t) : 'a = root let children (Tree (_, children) : 'a t) : ('a t) Seq.t = children let rec pp ?(depth : int option) (inner_pp : Format.formatter -> 'a -> unit) (ppf : Format.formatter) (t : 'a t) : unit = let Tree (x, xs) = t in let wrapper_box ppf inner = Format.fprintf ppf "@[Tree(@,%a@]@,)" inner () in let inner ppf () = Format.fprintf ppf "@[Node(@,%a@]@,),@ @[Shrinks(" inner_pp x; if Option.fold depth ~none:false ~some:(fun depth -> depth <= 0) then ( Format.fprintf ppf "@])") else if Seq.is_empty xs then Format.fprintf ppf "@])" else ( Format.fprintf ppf "@,%a@]@,)" (Format.pp_print_list ~pp_sep:(fun ppf () -> Format.fprintf ppf ",@ ") (pp ?depth:(Option.map pred depth) inner_pp)) (List.of_seq xs); ) in wrapper_box ppf inner let rec map (f : 'a -> 'b) (a : 'a t) : 'b t = let Tree (x, xs) = a in let y = f x in let ys = fun () -> Seq.map (fun smaller_x -> map f smaller_x) xs () in Tree (y, ys) (** Note that parameter order is reversed. *) let (>|=) a f = map f a let rec ap (f : ('a -> 'b) t) (a : 'a t) : 'b t = let Tree (x0, xs) = a in let Tree (f0, fs) = f in let y = f0 x0 in let ys = fun () -> Seq.append (Seq.map (fun f' -> ap f' a) fs) (Seq.map (fun x' -> ap f x') xs) () in Tree (y, ys) let (<*>) = ap let liftA2 (f : 'a -> 'b -> 'c) (a : 'a t) (b : 'b t) : 'c t = (a >|= f) <*> b let rec bind (a : 'a t) (f : 'a -> 'b t) : 'b t = let Tree (x, xs) = a in let Tree (y, ys_of_x) = f x in let ys_of_xs = fun () -> Seq.map (fun smaller_x -> bind smaller_x f) xs () in let ys = fun () -> Seq.append ys_of_xs ys_of_x () in Tree (y, ys) let (>>=) = bind let pure x = Tree (x, Seq.empty) let rec make_primitive (shrink : 'a -> 'a Seq.t) (x : 'a) : 'a t = let shrink_trees = fun () -> shrink x |> Seq.map (make_primitive shrink) |> Seq.apply in Tree (x, shrink_trees) let rec opt (a : 'a t) : 'a option t = let Tree (x, xs) = a in let shrinks = fun () -> Seq.cons (pure None) (Seq.map opt xs) () in Tree (Some x, shrinks) let rec sequence_list (l : 'a t list) : 'a list t = match l with | [] -> pure [] | hd :: tl -> liftA2 List.cons hd (sequence_list tl) let rec add_shrink_invariant (p : 'a -> bool) (a : 'a t) : 'a t = let Tree (x, xs) = a in let xs' = fun () -> Seq.filter_map (fun (Tree (x', _) as t) -> if p x' then Some (add_shrink_invariant p t) else None) xs () in Tree (x, xs') (** [applicative_take n trees] returns a tree of lists with at most the [n] first elements of the input list. *) let rec applicative_take (n : int) (l : 'a t list) : 'a list t = match (n, l) with | (0, _) | (_, []) -> pure [] | (n, (tree :: trees)) -> liftA2 List.cons tree (applicative_take (pred n) trees) (** [drop_one l []] returns all versions of [l] with one element removed, for example [drop_one [1;2;3] [] = [ [2;3]; [1;3]; [1;2] ]] *) let rec drop_one (l : 'a list) (rev_prefix : 'a list) : 'a list list = match l with | [] -> [] | x::xs -> (List.rev rev_prefix @ xs) :: drop_one xs (x::rev_prefix) let rec build_list_shrink_tree (l : 'a t list) : 'a list t Seq.t = match l with | [] -> Seq.empty | _::_ -> fun () -> let len = List.length l in if len < 4 then let candidates = drop_one l [] in List.fold_right (* try dropping each element in turn, starting with the list head *) (fun cand acc -> Seq.cons (Tree (List.map root cand, build_list_shrink_tree cand)) acc) candidates (fun () -> children (sequence_list l) ()) () (* otherwise, reduce element(s) *) else let xs,ys = list_split l ((1 + len) / 2) [] in let xs_roots = List.map root xs in let ys_roots = List.map root ys in (* Try reducing a list [1;2;3;4] in halves: [1;2] and [3;4] *) Seq.cons (Tree (xs_roots, build_list_shrink_tree xs)) (Seq.cons (Tree (ys_roots, build_list_shrink_tree ys)) (fun () -> (* Try dropping an element from either half: [2;3;4] and [1;2;4] *) let rest = List.tl l in let rest_roots = List.map root rest in (Seq.cons (Tree (rest_roots, build_list_shrink_tree rest)) (Seq.cons (Tree (xs_roots@(List.tl ys_roots), build_list_shrink_tree (xs@(List.tl ys)))) (fun () -> children (sequence_list l) ()))) (* at bottom: reduce elements *) () )) () end module Gen = struct type 'a t = RS.t -> 'a Tree.t type 'a sized = int -> RS.t -> 'a Tree.t let map f x = fun st -> Tree.map f (x st) (** Note that parameter order is reversed. *) let (>|=) x f = map f x let (<$>) = map let pure (a : 'a) : 'a t = fun _ -> Tree.pure a let ap (f : ('a -> 'b) t) (x : 'a t) : 'b t = fun st -> let st' = RS.split st in let ftree = f st in let xtree = x st' in Tree.ap ftree xtree let (<*>) = ap let liftA2 (f : 'a -> 'b -> 'c) (a : 'a t) (b : 'b t) : 'c t = (a >|= f) <*> b let liftA3 (f : 'a -> 'b -> 'c -> 'd) (a : 'a t) (b : 'b t) (c : 'c t) : 'd t = (a >|= f) <*> b <*> c let liftA4 (f : 'a -> 'b -> 'c -> 'd -> 'e) (a : 'a t) (b : 'b t) (c : 'c t) (d : 'd t) : 'e t = (a >|= f) <*> b <*> c <*> d let liftA5 (f : 'a -> 'b -> 'c -> 'd -> 'e -> 'f) (a : 'a t) (b : 'b t) (c : 'c t) (d : 'd t) (e : 'e t) : 'f t = (a >|= f) <*> b <*> c <*> d <*> e let map2 = liftA2 let map3 = liftA3 let map4 = liftA4 let map5 = liftA5 let return = pure let bind (gen : 'a t) (f : 'a -> ('b t)) : 'b t = fun st -> let st' = RS.split st in let gentree = gen st in Tree.bind gentree (fun a -> f a (RS.copy st')) let (>>=) = bind let sequence_list (l : 'a t list) : 'a list t = fun st -> List.map (fun gen -> gen st) l |> Tree.sequence_list let make_primitive ~(gen : RS.t -> 'a) ~(shrink : 'a -> 'a Seq.t) : 'a t = fun st -> Tree.make_primitive shrink (gen st) let parse_origin (loc : string) (pp : Format.formatter -> 'a -> unit) ~(origin : 'a) ~(low : 'a) ~(high : 'a) : 'a = if origin < low then invalid_arg Format.(asprintf "%s: origin value %a is lower than low value %a" loc pp origin pp low) else if origin > high then invalid_arg Format.(asprintf "%s: origin value %a is greater than high value %a" loc pp origin pp high) else origin let small_nat : int t = fun st -> let p = RS.float st 1. in let x = if p < 0.75 then RS.int st 10 else RS.int st 100 in let shrink a = fun () -> Shrink.int_towards 0 a () in Tree.make_primitive shrink x (** Natural number generator *) let nat : int t = fun st -> let p = RS.float st 1. in let x = if p < 0.5 then RS.int st 10 else if p < 0.75 then RS.int st 100 else if p < 0.95 then RS.int st 1_000 else RS.int st 10_000 in let shrink a = fun () -> Shrink.int_towards 0 a () in Tree.make_primitive shrink x let big_nat : int t = fun st -> let p = RS.float st 1. in if p < 0.75 then nat st else let shrink a = fun () -> Shrink.int_towards 0 a () in Tree.make_primitive shrink (RS.int st 1_000_000) let unit : unit t = fun _st -> Tree.pure () let bool : bool t = fun st -> let false_gen = Tree.pure false in if RS.bool st then Tree.Tree (true, Seq.return false_gen) else false_gen let float : float t = fun st -> let x = exp (RS.float st 15. *. (if RS.bool st then 1. else -1.)) *. (if RS.bool st then 1. else -1.) in let shrink a = fun () -> Shrink.float_towards 0. a () in Tree.make_primitive shrink x let pfloat : float t = float >|= abs_float let nfloat : float t = pfloat >|= Float.neg let float_bound_inclusive ?(origin : float = 0.) (bound : float) : float t = fun st -> let (low, high) = Float.min_max_num 0. bound in let shrink a = fun () -> let origin = parse_origin "Gen.float_bound_inclusive" Format.pp_print_float ~origin ~low ~high in Shrink.float_towards origin a () in let x = RS.float st bound in Tree.make_primitive shrink x let float_bound_exclusive ?(origin : float = 0.) (bound : float) : float t = if bound = 0. then invalid_arg "Gen.float_bound_exclusive"; fun st -> let (low, high) = Float.min_max_num 0. bound in let shrink a = fun () -> let origin = parse_origin "Gen.float_bound_exclusive" Format.pp_print_float ~origin ~low ~high in Shrink.float_towards origin a () in let bound = if bound > 0. then bound -. epsilon_float else bound +. epsilon_float in let x = RS.float st bound in Tree.make_primitive shrink x let pick_origin_within_range ~low ~high ~goal = if low > goal then low else if high < goal then high else goal let float_range ?(origin : float option) (low : float) (high : float) : float t = if high < low then invalid_arg "Gen.float_range: high < low" else if high -. low > max_float then invalid_arg "Gen.float_range: high -. low > max_float"; let origin = parse_origin "Gen.float_range" Format.pp_print_float ~origin:(Option.value ~default:(pick_origin_within_range ~low ~high ~goal:0.) origin) ~low ~high in (float_bound_inclusive ~origin (high -. low)) >|= (fun x -> low +. x) let (--.) low high = float_range ?origin:None low high let exponential (mean : float) = if Float.is_nan mean then invalid_arg "Gen.exponential"; let unit_gen = float_bound_inclusive 1.0 in map (fun p -> -. mean *. (log p)) unit_gen (* See https://en.wikipedia.org/wiki/Relationships_among_probability_distributions *) let neg_int : int t = nat >|= Int.neg (** [option gen] shrinks towards [None] then towards shrinks of [gen]. *) let option ?(ratio : float = 0.85) (gen : 'a t) : 'a option t = fun st -> let p = RS.float st 1. in if p < (1. -. ratio) then Tree.pure None else Tree.opt (gen st) (** [opt] is an alias of {!val:option} for backward compatibility. *) let opt = option let result ?(ratio : float = 0.75) (ok_gen : 'a t) (err_gen : 'e t) : ('a, 'e) result t = fun st -> let p = RS.float st 1. in if p < (1. -. ratio) then Tree.map (fun e -> Error e) (err_gen st) else Tree.map (fun o -> Ok o) (ok_gen st) (* Uniform positive random int generator. We can't use {!RS.int} because the upper bound must be positive and is excluded, so {!Int.max_int} would never be reached. We have to manipulate bits directly. Note that the leftmost bit is used for negative numbers, so it must be [0]. {!RS.bits} only generates 30 bits, which is exactly enough on 32-bits architectures (i.e. {!Sys.int_size} = 31, i.e. 30 bits for positive numbers) but not on 64-bits ones. That's why for 64-bits, 3 30-bits segments are generated and shifted to craft a 62-bits number (i.e. {!Sys.int_size} = 63). The leftmost segment is masked to keep only the last 2 bits. The current implementation hard-codes 30/32/62/64 values, but technically we should rely on {!Sys.int_size} to find the number of bits. Note that we could also further generalize this function to merge it with [random_binary_string]. Technically this function is a special case of [random_binary_string] where the size is {!Sys.int_size}. *) let pint_raw : RS.t -> int = if Sys.word_size = 32 then fun st -> RS.bits st else (* word size = 64 *) fun st -> (* Technically we could write [3] but this is clearer *) let two_bits_mask = 0b11 in (* Top 2 bits *) let left = ((RS.bits st land two_bits_mask) lsl 60) in (* Middle 30 bits *) let middle = (RS.bits st lsl 30) in (* Bottom 30 bits *) let right = RS.bits st in left lor middle lor right let pint ?(origin : int = 0) : int t = fun st -> let x = pint_raw st in let shrink a = fun () -> let origin = parse_origin "Gen.pint" Format.pp_print_int ~origin ~low:0 ~high:max_int in Shrink.int_towards origin a () in Tree.make_primitive shrink x let number_towards = Shrink.number_towards let int_towards = Shrink.int_towards let int64_towards = Shrink.int64_towards let int32_towards = Shrink.int32_towards let float_towards = Shrink.float_towards let int : int t = bool >>= fun b -> if b then pint ~origin:0 >|= (fun n -> - n - 1) else pint ~origin:0 let int_bound (n : int) : int t = if n < 0 then invalid_arg "Gen.int_bound"; fun st -> if n <= (1 lsl 30) - 2 then Tree.make_primitive (fun a () -> Shrink.int_towards 0 a ()) (RS.int st (n + 1)) else Tree.map (fun r -> r mod (n + 1)) (pint st) (** To support ranges wider than [Int.max_int], the general idea is to find the center, and generate a random half-difference number as well as whether we add or subtract that number from the center. *) let int_range ?(origin : int option) (low : int) (high : int) : int t = if high < low then invalid_arg "Gen.int_range: high < low"; fun st -> let Tree.Tree(n, _shrinks) = if low >= 0 || high < 0 then ( (* range smaller than max_int *) Tree.map (fun n -> low + n) (int_bound (high - low) st) ) else ( (* range potentially bigger than max_int: we split on 0 and choose the interval with regard to their size ratio *) let f_low = float_of_int low in let f_high = float_of_int high in let ratio = (-.f_low) /. (1. +. f_high -. f_low) in if RS.float st 1. <= ratio then Tree.map (fun n -> -n - 1) (int_bound (- (low + 1)) st) else int_bound high st ) in let shrink a = fun () -> let origin = match origin with | None -> pick_origin_within_range ~low ~high ~goal:0 | Some origin -> if origin < low then invalid_arg "Gen.int_range: origin < low" else if origin > high then invalid_arg "Gen.int_range: origin > high" else origin in Shrink.int_towards origin a () in Tree.make_primitive shrink n let (--) low high = int_range ?origin:None low high let oneof (l : 'a t list) : 'a t = int_bound (List.length l - 1) >>= List.nth l let oneofl (l : 'a list) : 'a t = int_bound (List.length l - 1) >|= List.nth l let oneofa (a : 'a array) : 'a t = int_bound (Array.length a - 1) >|= Array.get a (* NOTE: we keep this alias to not break code that uses [small_int] for sizes of strings, arrays, etc. *) let small_int = small_nat let small_signed_int : int t = fun st -> if RS.bool st then small_nat st else (small_nat >|= Int.neg) st (** Shrink towards the first element of the list *) let frequency (l : (int * 'a t) list) : 'a t = if l = [] then failwith "QCheck2.frequency called with an empty list"; let sums = sum_int (List.map fst l) in if sums < 1 then failwith "QCheck2.frequency called with weight sum < 1"; int_bound (sums - 1) >>= fun i -> let rec aux acc = function | ((x, g) :: xs) -> if i < acc + x then g else aux (acc + x) xs | _ -> assert false in aux 0 l let frequencyl (l : (int * 'a) list) : 'a t = List.map (fun (weight, value) -> (weight, pure value)) l |> frequency let frequencya a = frequencyl (Array.to_list a) let char_range ?(origin : char option) (a : char) (b : char) : char t = (int_range ~origin:(Char.code (Option.value ~default:a origin)) (Char.code a) (Char.code b)) >|= Char.chr let random_binary_string (length : int) (st : RS.t) : string = (* 0b011101... *) let s = Bytes.create (length + 2) in Bytes.set s 0 '0'; Bytes.set s 1 'b'; for i = 0 to length - 1 do Bytes.set s (i+2) (if RS.bool st then '0' else '1') done; Bytes.unsafe_to_string s let int32 : int32 t = fun st -> let x = random_binary_string 32 st |> Int32.of_string in let shrink a = fun () -> Shrink.int32_towards 0l a () in Tree.make_primitive shrink x let ui32 : int32 t = map Int32.abs int32 let int64 : int64 t = fun st -> let x = random_binary_string 64 st |> Int64.of_string in let shrink a = fun () -> Shrink.int64_towards 0L a () in Tree.make_primitive shrink x let ui64 : int64 t = map Int64.abs int64 (* A tail-recursive implementation over Tree.t *) let list_size (size : int t) (gen : 'a t) : 'a list t = fun st -> let st' = RS.split st in Tree.bind (size st) @@ fun size -> let st' = RS.copy st' in (* start each loop from same Random.State to recreate same element (prefix) *) let rec loop n acc = (* phase 1: build a list of element trees, tail recursively *) if n <= 0 (* phase 2: build a list shrink Tree of element trees, tail recursively *) then List.fold_left (fun acc t -> Tree.liftA2 List.cons t acc) (Tree.pure []) acc else (loop [@tailcall]) (n - 1) ((gen st')::acc) in loop size [] (** [list_ignore_size_tree] is a helper applying its own size shrinking heuristic, and thus using only the root of [size]'s output shrink [Tree]. *) let list_ignore_size_tree (size : int t) (gen : 'a t) : 'a list t = fun st -> let st' = RS.split st in let size = Tree.root (size st) in let st' = RS.copy st' in (* start each loop from same Random.State to recreate same element (prefix) *) let rec loop n acc = (* phase 1: build a list of element trees, tail recursively *) if n <= 0 (* phase 2: build a list shrink Tree of element trees, tail recursively *) then let l = List.rev acc in Tree.Tree (List.map Tree.root l, Tree.build_list_shrink_tree l) else (loop [@tailcall]) (n - 1) ((gen st')::acc) in loop size [] let list (gen : 'a t) : 'a list t = list_ignore_size_tree nat gen let list_repeat (n : int) (gen : 'a t) : 'a list t = list_size (pure n) gen let array_size (size : int t) (gen : 'a t) : 'a array t = (list_size size gen) >|= Array.of_list let array (gen : 'a t) : 'a array t = list gen >|= Array.of_list let array_repeat (n : int) (gen : 'a t) : 'a array t = list_repeat n gen >|= Array.of_list let rec flatten_l (l : 'a t list) : 'a list t = match l with | [] -> pure [] | gen :: gens -> liftA2 List.cons gen (flatten_l gens) let flatten_a (a : 'a t array) : 'a array t = Array.to_list a |> flatten_l >|= Array.of_list let flatten_opt (o : 'a t option) : 'a option t = match o with | None -> pure None | Some gen -> option gen let flatten_res (res : ('a t, 'e) result) : ('a, 'e) result t = match res with | Ok gen -> gen >|= Result.ok | Error e -> pure (Error e) let shuffle_a (a : 'a array) : 'a array t = fun st -> let a = Array.copy a in for i = Array.length a - 1 downto 1 do let j = RS.int st (i + 1) in let tmp = a.(i) in a.(i) <- a.(j); a.(j) <- tmp; done; Tree.pure a let shuffle_l (l : 'a list) : 'a list t = Array.of_list l |> shuffle_a >|= Array.to_list let shuffle_w_l (l : ((int * 'a) list)) : 'a list t = fun st -> let sample (w, v) = let Tree.Tree (p, _) = float_bound_inclusive 1. st in let fl_w = float_of_int w in (p ** (1. /. fl_w), v) in let samples = List.rev_map sample l in samples |> List.sort (fun (w1, _) (w2, _) -> poly_compare w1 w2) |> List.rev_map snd |> Tree.pure let pair (g1 : 'a t) (g2 : 'b t) : ('a * 'b) t = liftA2 (fun a b -> (a, b)) g1 g2 let triple (g1 : 'a t) (g2 : 'b t) (g3 : 'c t) : ('a * 'b * 'c) t = (fun a b c -> (a, b, c)) <$> g1 <*> g2 <*> g3 let quad (g1 : 'a t) (g2 : 'b t) (g3 : 'c t) (g4 : 'd t) : ('a * 'b * 'c * 'd) t = (fun a b c d -> (a, b, c, d)) <$> g1 <*> g2 <*> g3 <*> g4 let tup2 = pair let tup3 = triple let tup4 = quad let tup5 (g1 : 'a t) (g2 : 'b t) (g3 : 'c t) (g4 : 'd t) (g5 : 'e t) : ('a * 'b * 'c * 'd * 'e) t = (fun a b c d e -> (a, b, c, d, e)) <$> g1 <*> g2 <*> g3 <*> g4 <*> g5 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 = (fun a b c d e f -> (a, b, c, d, e, f)) <$> g1 <*> g2 <*> g3 <*> g4 <*> g5 <*> g6 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 = (fun a b c d e f g -> (a, b, c, d, e, f, g)) <$> g1 <*> g2 <*> g3 <*> g4 <*> g5 <*> g6 <*> g7 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 = (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 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 = (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 (** 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. *) let char : char t = fun st -> let c = RS.int st 256 in let shrink a = fun () -> Shrink.int_towards (int_of_char 'a') a |> Seq.apply in Tree.map char_of_int (Tree.make_primitive shrink c) (** The first characters are the usual lower case alphabetical letters to help shrinking. *) let printable_chars : char list = (* Left and right inclusive *) let range min max = List.init (max - min + 1) (fun i -> char_of_int (i + min)) in let a = 97 in let z = 122 in let lower_alphabet = range a z in (* ' ' *) let first_printable_char = 32 in let before_lower_alphabet = range first_printable_char (a - 1) in (* '~' *) let last_printable_char = 126 in let after_lower_alphabet = range (z + 1) last_printable_char in let newline = ['\n'] in (* Put alphabet first for shrinking *) List.flatten [lower_alphabet; before_lower_alphabet; after_lower_alphabet; newline] let printable : char t = int_range ~origin:0 0 (List.length printable_chars - 1) >|= List.nth printable_chars let numeral : char t = let zero = 48 in let nine = 57 in int_range ~origin:zero zero nine >|= char_of_int let bytes_size ?(gen = char) (size : int t) : bytes t = fun st -> let open Tree in let st' = RS.split st in size st >>= fun size -> (* Adding char shrinks to a mutable list is expensive: ~20-30% cost increase *) (* Adding char shrinks to a mutable lazy list is less expensive: ~15% cost increase *) let st' = RS.copy st' in (* start char generation from same Random.State to recreate same char prefix (when size shrinking) *) let char_trees_rev = ref [] in let bytes = Bytes.init size (fun _ -> let char_tree = gen st' in char_trees_rev := char_tree :: !char_trees_rev ; (* Performance: return the root right now, the heavy processing of shrinks can wait until/if there is a need to shrink *) root char_tree) in let shrink = fun () -> let char_trees = List.rev !char_trees_rev in let char_list_tree = sequence_list char_trees in let bytes_tree = char_list_tree >|= (fun char_list -> let bytes = Bytes.create size in List.iteri (Bytes.set bytes) char_list ; bytes) in (* Technically [bytes_tree] is the whole tree, but for perf reasons we eagerly created the root above *) children bytes_tree () in Tree (bytes, shrink) let string_size ?(gen = char) (size : int t) : string t = bytes_size ~gen size >|= Bytes.unsafe_to_string let bytes_of_char_list cs = let b = Buffer.create (List.length cs) in List.iter (fun c -> Buffer.add_char b c) cs; let bytes = Buffer.to_bytes b in Buffer.clear b; bytes let bytes : bytes t = list char >|= bytes_of_char_list let bytes_of gen = list gen >|= bytes_of_char_list let bytes_printable = list printable >|= bytes_of_char_list let bytes_small = list_ignore_size_tree small_nat char >|= bytes_of_char_list let bytes_small_of gen = list_ignore_size_tree small_nat gen >|= bytes_of_char_list let string_of_char_list cs = let b = Buffer.create (List.length cs) in List.iter (fun c -> Buffer.add_char b c) cs; let str = Buffer.contents b in Buffer.clear b; str let string : string t = list char >|= string_of_char_list let string_of gen = list gen >|= string_of_char_list let string_printable = list printable >|= string_of_char_list let string_small = list_ignore_size_tree small_nat char >|= string_of_char_list let string_small_of gen = list_ignore_size_tree small_nat gen >|= string_of_char_list let small_string ?(gen=char) = string_small_of gen let small_list gen = list_ignore_size_tree small_nat gen let small_array gen = list_ignore_size_tree small_nat gen >|= Array.of_list let join (gen : 'a t t) : 'a t = gen >>= Fun.id (* corner cases *) let graft_corners (gen : 'a t) (corners : 'a list) () : 'a t = let cors = ref corners in fun st -> match !cors with [] -> gen st | e::l -> cors := l; Tree.pure e let int_pos_corners = [0; 1; 2; max_int] let int_corners = int_pos_corners @ [min_int] let small_int_corners () : int t = graft_corners nat int_pos_corners () (* sized, fix *) let sized_size (size : int t) (gen : 'a sized) : 'a t = size >>= gen let sized (gen : 'a sized) : 'a t = sized_size nat gen let fix f = let rec f' n st = f f' n st in f' let generate ?(rand=RS.make_self_init()) ~(n : int) (gen : 'a t) : 'a list = list_repeat n gen rand |> Tree.root let generate1 ?(rand=RS.make_self_init()) (gen : 'a t) : 'a = gen rand |> Tree.root let generate_tree ?(rand=RS.make_self_init()) (gen : 'a t) : 'a Tree.t = gen rand let delay (f : unit -> 'a t) : 'a t = fun st -> f () st let add_shrink_invariant (p : 'a -> bool) (gen : 'a t) : 'a t = fun st -> gen st |> Tree.add_shrink_invariant p let set_shrink shrink gen = make_primitive ~gen:(fun st -> gen st |> Tree.root) ~shrink let no_shrink (gen: 'a t) : 'a t = set_shrink (fun _ -> Seq.empty) gen let (let+) = (>|=) let (and+) = pair let (let*) = (>>=) let (and*) = pair end module Print = struct type 'a t = 'a -> string let unit _ = "()" let int = string_of_int let int32 i = Int32.to_string i ^ "l" let int64 i = Int64.to_string i ^ "L" let bool = string_of_bool let float = string_of_float let string s = Printf.sprintf "%S" s let bytes b = string (Bytes.to_string b) let char c = Printf.sprintf "%C" c let option f = function | None -> "None" | Some x -> "Some (" ^ f x ^ ")" let result vp ep = function | Error e -> "Error (" ^ ep e ^ ")" | Ok v -> "Ok (" ^ vp v ^ ")" let pair a b (x,y) = Printf.sprintf "(%s, %s)" (a x) (b y) let triple a b c (x,y,z) = Printf.sprintf "(%s, %s, %s)" (a x) (b y) (c z) let quad a b c d (x,y,z,w) = Printf.sprintf "(%s, %s, %s, %s)" (a x) (b y) (c z) (d w) let list pp l = let b = Buffer.create 25 in Buffer.add_char b '['; List.iteri (fun i x -> if i > 0 then Buffer.add_string b "; "; Buffer.add_string b (pp x)) l; Buffer.add_char b ']'; Buffer.contents b let array pp a = let b = Buffer.create 25 in Buffer.add_string b "[|"; Array.iteri (fun i x -> if i > 0 then Buffer.add_string b "; "; Buffer.add_string b (pp x)) a; Buffer.add_string b "|]"; Buffer.contents b let contramap f p x = p (f x) let comap = contramap let default = fun _ -> "" let tup2 p_a p_b (a, b) = Printf.sprintf "(%s, %s)" (p_a a) (p_b b) let tup2_opt p_a p_b (a, b) = let p_a = Option.value ~default p_a in let p_b = Option.value ~default p_b in tup2 p_a p_b (a, b) let tup3 p_a p_b (p_c) (a, b, c) = Printf.sprintf "(%s, %s, %s)" (p_a a) (p_b b) (p_c c) let tup3_opt p_a p_b p_c (a, b, c) = let p_a = Option.value ~default p_a in let p_b = Option.value ~default p_b in let p_c = Option.value ~default p_c in tup3 p_a p_b p_c (a, b, c) let tup4 p_a p_b p_c p_d (a, b, c, d) = Printf.sprintf "(%s, %s, %s, %s)" (p_a a) (p_b b) (p_c c) (p_d d) let tup4_opt p_a p_b p_c p_d (a, b, c, d) = let p_a = Option.value ~default p_a in let p_b = Option.value ~default p_b in let p_c = Option.value ~default p_c in let p_d = Option.value ~default p_d in tup4 p_a p_b p_c p_d (a, b, c, d) let tup5 p_a p_b p_c p_d p_e (a, b, c, d, e) = Printf.sprintf "(%s, %s, %s, %s, %s)" (p_a a) (p_b b) (p_c c) (p_d d) (p_e e) let tup5_opt p_a p_b p_c p_d p_e (a, b, c, d, e) = let p_a = Option.value ~default p_a in let p_b = Option.value ~default p_b in let p_c = Option.value ~default p_c in let p_d = Option.value ~default p_d in let p_e = Option.value ~default p_e in tup5 p_a p_b p_c p_d p_e (a, b, c, d, e) let tup6 p_a p_b p_c p_d p_e p_f (a, b, c, d, e, f) = Printf.sprintf "(%s, %s, %s, %s, %s, %s)" (p_a a) (p_b b) (p_c c) (p_d d) (p_e e) (p_f f) let tup6_opt p_a p_b p_c p_d p_e p_f (a, b, c, d, e, f) = let p_a = Option.value ~default p_a in let p_b = Option.value ~default p_b in let p_c = Option.value ~default p_c in let p_d = Option.value ~default p_d in let p_e = Option.value ~default p_e in let p_f = Option.value ~default p_f in tup6 p_a p_b p_c p_d p_e p_f (a, b, c, d, e, f) let tup7 p_a p_b p_c p_d p_e p_f p_g (a, b, c, d, e, f, g) = Printf.sprintf "(%s, %s, %s, %s, %s, %s, %s)" (p_a a) (p_b b) (p_c c) (p_d d) (p_e e) (p_f f) (p_g g) let tup7_opt p_a p_b p_c p_d p_e p_f p_g (a, b, c, d, e, f, g) = let p_a = Option.value ~default p_a in let p_b = Option.value ~default p_b in let p_c = Option.value ~default p_c in let p_d = Option.value ~default p_d in let p_e = Option.value ~default p_e in let p_f = Option.value ~default p_f in let p_g = Option.value ~default p_g in tup7 p_a p_b p_c p_d p_e p_f p_g (a, b, c, d, e, f, g) 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) = Printf.sprintf "(%s, %s, %s, %s, %s, %s, %s, %s)" (p_a a) (p_b b) (p_c c) (p_d d) (p_e e) (p_f f) (p_g g) (p_h h) 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) = let p_a = Option.value ~default p_a in let p_b = Option.value ~default p_b in let p_c = Option.value ~default p_c in let p_d = Option.value ~default p_d in let p_e = Option.value ~default p_e in let p_f = Option.value ~default p_f in let p_g = Option.value ~default p_g in let p_h = Option.value ~default p_h in 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) 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) = Printf.sprintf "(%s, %s, %s, %s, %s, %s, %s, %s, %s)" (p_a a) (p_b b) (p_c c) (p_d d) (p_e e) (p_f f) (p_g g) (p_h h) (p_i i) 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) = let p_a = Option.value ~default p_a in let p_b = Option.value ~default p_b in let p_c = Option.value ~default p_c in let p_d = Option.value ~default p_d in let p_e = Option.value ~default p_e in let p_f = Option.value ~default p_f in let p_g = Option.value ~default p_g in let p_h = Option.value ~default p_h in let p_i = Option.value ~default p_i in 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) end (** {2 Observe Values} *) module Observable = struct (** An observable is a (random) predicate on ['a] *) type -'a t = { print: 'a Print.t; eq: ('a -> 'a -> bool); hash: ('a -> int); } let hash o x = o.hash x let equal o x y = o.eq x y let print o x = o.print x let make ?(eq=(=)) ?(hash=Hashtbl.hash) print = {print; eq; hash; } module H = struct let combine a b = Hashtbl.seeded_hash a b let combine_f f s x = Hashtbl.seeded_hash s (f x) let int i = i land max_int let int32 (i:int32) = Hashtbl.hash i let int64 (i:int64) = Hashtbl.hash i let bool b = if b then 1 else 2 let char x = Char.code x let bytes (x:bytes) = Hashtbl.hash x let string (x:string) = Hashtbl.hash x let option f = function | None -> 42 | Some x -> combine 43 (f x) let result vh eh = function | Error e -> combine 17 (eh e) | Ok v -> combine 19 (vh v) let list f l = List.fold_left (combine_f f) 0x42 l let array f l = Array.fold_left (combine_f f) 0x42 l let pair f g (x,y) = combine (f x) (g y) end module Eq = struct type 'a t = 'a -> 'a -> bool let int : int t = (=) let int32 : int32 t = (=) let int64 : int64 t = (=) let bytes : bytes t = (=) let string : string t = (=) let bool : bool t = (=) let float = Float.equal let unit () () = true let char : char t = (=) let rec list f l1 l2 = match l1, l2 with | [], [] -> true | [], _ | _, [] -> false | x1::l1', x2::l2' -> f x1 x2 && list f l1' l2' let array eq a b = let rec aux i = if i = Array.length a then true else eq a.(i) b.(i) && aux (i+1) in Array.length a = Array.length b && aux 0 let option f o1 o2 = match o1, o2 with | None, None -> true | Some _, None | None, Some _ -> false | Some x, Some y -> f x y let result ok error r1 r2 = Result.equal ~ok ~error r1 r2 let pair f g (x1,y1)(x2,y2) = f x1 x2 && g y1 y2 end let unit : unit t = make ~hash:(fun _ -> 1) ~eq:Eq.unit Print.unit let bool : bool t = make ~hash:H.bool ~eq:Eq.bool Print.bool let int : int t = make ~hash:H.int ~eq:Eq.int Print.int let int32 : int32 t = make ~hash:H.int32 ~eq:Eq.int32 Print.int32 let int64 : int64 t = make ~hash:H.int64 ~eq:Eq.int64 Print.int64 let float : float t = make ~eq:Eq.float Print.float let bytes = make ~hash:H.bytes ~eq:Eq.bytes Print.bytes let string = make ~hash:H.string ~eq:Eq.string Print.string let char = make ~hash:H.char ~eq:Eq.char Print.char let option p = make ~hash:(H.option p.hash) ~eq:(Eq.option p.eq) (Print.option p.print) let result op rp = make ~hash:(H.result op.hash rp.hash) ~eq:(Eq.result op.eq rp.eq) (Print.result op.print rp.print) let array p = make ~hash:(H.array p.hash) ~eq:(Eq.array p.eq) (Print.array p.print) let list p = make ~hash:(H.list p.hash) ~eq:(Eq.list p.eq) (Print.list p.print) let contramap f p = make ~hash:(fun x -> p.hash (f x)) ~eq:(fun x y -> p.eq (f x)(f y)) (fun x -> p.print (f x)) let map = contramap let pair a b = make ~hash:(H.pair a.hash b.hash) ~eq:(Eq.pair a.eq b.eq) (Print.pair a.print b.print) let triple a b c = contramap (fun (x,y,z) -> x,(y,z)) (pair a (pair b c)) let quad a b c d = contramap (fun (x,y,z,u) -> x,(y,z,u)) (pair a (triple b c d)) end type 'a stat = string * ('a -> int) (** A statistic on a distribution of values of type ['a] *) (** Internal module taking care of storing generated function bindings. In essence, a generated function of type ['a -> 'b] is a map (table) where keys are input values of type ['a] and values are output values of type ['b], plus a default value of type ['b]. This module provides the "map of input/output" part. *) module Poly_tbl : sig type ('key, 'value) t val create: 'key Observable.t -> ?v_print:'value Print.t -> 'value Gen.t -> int -> ('key, 'value) t Gen.t val get : ('key, 'value) t -> 'key -> 'value option val size : ('value -> int) -> ('key, 'value) t -> int val print : ('key, 'value) t Print.t end = struct type ('key, 'value) t = { get : 'key -> 'value option; (** Don't be fooled by its name and signature: this function mutates the table during test execution by adding entries (key is the value on which the function is applied in the test, and the value is generated on the fly). *) p_size: ('value -> int) -> int; p_print: unit -> string; p_tree_bindings_rev : ('key * 'value Tree.t) list ref; } let create (type k) (type v) (k_obs : k Observable.t) ?(v_print: v Print.t option) (v_gen : v Gen.t) (size : int) : (k, v) t Gen.t = fun st -> let module T = Hashtbl.Make(struct type t = k let equal = k_obs.Observable.eq let hash = k_obs.Observable.hash end) in (* split random state to avoid later failed [get]s to side-effect the current [st] *) let st' = RS.split st in (* make a table @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). *) let make ~extend tbl = let initial_tree_bindings_rev = T.to_seq tbl |> List.of_seq |> List.rev_map (fun (k, v) -> k, Tree.pure v) in let p_tree_bindings_rev = ref initial_tree_bindings_rev in let get = (fun key -> try Some (T.find tbl key) with Not_found -> if extend then ( (* Generate a new value and "record" the binding for potential future display/shrinking *) let value_tree = v_gen st' in p_tree_bindings_rev := (key, value_tree) :: !p_tree_bindings_rev; let v = Tree.root value_tree in T.add tbl key v; Some v ) else None) in let p_print = (fun () -> let pp_v = Option.value ~default:(fun _ -> "") v_print in let b = Buffer.create 64 in let to_b = Format.formatter_of_buffer b in T.iter (fun key value -> Format.fprintf to_b "%s -> %s; " (k_obs.Observable.print key) (pp_v value)) tbl; Format.pp_print_flush to_b (); Buffer.contents b) in let p_size=(fun size_v -> T.fold (fun _ v n -> n + size_v v) tbl 0) in {get; p_print; p_size; p_tree_bindings_rev} in let root_tbl = T.create size in (* During initial running of the test, record bindings, hence [~extend:true]. *) let root = make ~extend:true root_tbl in (* Build the (lazy!) shrink tree of tables here *) let shrinks : (k, v) t Tree.t Seq.t = fun () -> (* This only gets evaluated *after* the test was run for [tbl], meaning it is correctly populated with bindings recorded during the test already *) let current_bindings : (k * v Tree.t) list = List.rev !(root.p_tree_bindings_rev) in let current_tree_bindings : (k * v) Tree.t list = List.map (fun (k, tree) -> Tree.map (fun v -> (k, v)) tree) current_bindings in let shrunk_bindings_tree_seq : (k * v) list Tree.t Seq.t = Tree.build_list_shrink_tree current_tree_bindings in (* During shrinking, we don't want to record/add bindings, so [~extend:false]. *) let shrunk_poly_tbl_tree_seq : (k, v) t Tree.t Seq.t = Seq.map (fun t -> Tree.map (fun bindings -> List.to_seq bindings |> T.of_seq |> make ~extend:false) t) shrunk_bindings_tree_seq in (* [shrunk_poly_tbl_tree_seq] is a bit misleading: its head *should* be the same as [root] but because of the required laziness induced by the mutation of bindings, we don't use it, only graft its tail to the original [root]. *) Seq.drop 1 shrunk_poly_tbl_tree_seq () in Tree.Tree (root, shrinks) let get t x = t.get x let print t = t.p_print () let size p t = t.p_size p end (** Internal representation of functions, used for shrinking and printing (in case of error). *) type ('a, 'b) fun_repr_tbl = { fun_tbl: ('a, 'b) Poly_tbl.t; (** Input-output bindings *) fun_print: 'b Print.t option; (** How to print output values *) fun_default: 'b; (** Default value for all inputs not explicitly mapped in {!fun_tbl} *) } type 'f fun_repr = | Fun_tbl : ('a, 'ret) fun_repr_tbl -> ('a -> 'ret) fun_repr (** Input-output list of bindings *) | Fun_map : ('f1 -> 'f2) * 'f1 fun_repr -> 'f2 fun_repr (** Mapped from another function (typically used for currying) *) (** A QCheck function, as in Koen Claessen's paper "Shrinking and showing functions". Such a function is a pair of the function representation (used for shrinking and printing the function) and a "real" function, which can be seen as an input-output map + a default value for all other inputs. - Test developers will only use the "real" function inside their tests (and ignore the function representation). - During shrinking/printing, QCheck will ignore the "real" function and only use its representation. *) type 'f fun_ = Fun of 'f fun_repr * 'f (** Reifying functions *) module Fn = struct let apply (Fun (_repr, real_function)) = real_function (** [function_of_repr repr] creates the "real" function (that will be used in tests) from its representation. *) let rec function_of_repr : type f. f fun_repr -> f = function | Fun_tbl {fun_tbl; fun_default; _} -> (fun x -> match Poly_tbl.get fun_tbl x with | None -> fun_default | Some y -> y) | Fun_map (g, sub_repr) -> g (function_of_repr sub_repr) let make_ (r : 'a fun_repr) : 'a fun_ = Fun (r, function_of_repr r) let mk_repr tbl ?print def = Fun_tbl { fun_tbl=tbl; fun_print=print; fun_default=def; } let map_repr f repr = Fun_map (f, repr) let map_fun f (Fun (repr, _real_function)) = make_ (map_repr f repr) (** [print_rep repr] returns a string representation of [repr]. *) let print_repr r = let buf = Buffer.create 32 in let rec aux : type f. Buffer.t -> f fun_repr -> unit = fun buf r -> match r with | Fun_map (_, sub_repr) -> aux buf sub_repr | Fun_tbl r -> Buffer.add_string buf (Poly_tbl.print r.fun_tbl); Printf.bprintf buf "_ -> %s" (match r.fun_print with | None -> "" | Some print -> print r.fun_default); in Printf.bprintf buf "{"; aux buf r; Printf.bprintf buf "}"; Buffer.contents buf let print (Fun (repr, _real_function)) = print_repr repr (** [gen_rep obs gen] creates a function generator. Input values are observed with [obs] and output values are generated with [gen]. *) let gen_rep (obs : 'a Observable.t) ?(print : 'b Print.t option) (gen : 'b Gen.t) : ('a -> 'b) fun_repr Gen.t = Gen.liftA2 (fun default_value poly_tbl -> mk_repr poly_tbl ?print default_value) gen (Poly_tbl.create ?v_print:print obs gen 8) let gen (obs : 'a Observable.t) ?(print : 'b Print.t option) (gen : 'b Gen.t) : ('a -> 'b) fun_ Gen.t = Gen.map make_ (gen_rep obs gen ?print) end let fun1 obs ?print gen = Fn.gen obs ?print gen module Tuple = struct (** heterogeneous list (generic tuple) used to uncurry functions *) type 'a t = | Nil : unit t | Cons : 'a * 'b t -> ('a * 'b) t let nil = Nil let cons x tail = Cons (x,tail) type 'a obs = | O_nil : unit obs | O_cons : 'a Observable.t * 'b obs -> ('a * 'b) obs let o_nil = O_nil let o_cons x tail = O_cons (x,tail) let rec hash : type a. a obs -> a t -> int = fun o t -> match o, t with | O_nil, Nil -> 42 | O_cons (o,tail_o), Cons (x, tail) -> Observable.H.combine (Observable.hash o x) (hash tail_o tail) let rec equal : type a. a obs -> a t -> a t -> bool = fun o a b -> match o, a, b with | O_nil, Nil, Nil -> true | O_cons (o, tail_o), Cons (x1, tail1), Cons (x2,tail2) -> Observable.equal o x1 x2 && equal tail_o tail1 tail2 let print o tup = let rec aux : type a. a obs -> Buffer.t -> a t -> unit = fun o buf t -> match o, t with | O_nil, Nil -> Printf.bprintf buf "()" | O_cons (o, O_nil), Cons (x,Nil) -> Printf.bprintf buf "%s" (Observable.print o x) | O_cons (o, tail_o), Cons (x,tail) -> Printf.bprintf buf "%s, %a" (Observable.print o x) (aux tail_o) tail in let buf = Buffer.create 64 in Buffer.add_string buf "("; aux o buf tup; Buffer.add_string buf ")"; Buffer.contents buf let observable (o:'a obs) : 'a t Observable.t = Observable.make ~eq:(equal o) ~hash:(hash o) (print o) let gen (o:'a obs) ?(print:'b Print.t option) (ret:'b Gen.t) : ('a t -> 'b) fun_ Gen.t = Fn.gen (observable o) ?print ret module Infix = struct let (@::) x tail = cons x tail let (@->) o tail = o_cons o tail end include Infix end let fun_nary (o:_ Tuple.obs) ?print ret : _ Gen.t = Tuple.gen o ?print ret let fun2 o1 o2 ?print ret = Gen.map (Fn.map_fun (fun g x y -> g Tuple.(x @:: y @:: nil))) (fun_nary Tuple.(o1 @-> o2 @-> o_nil) ?print ret) let fun3 o1 o2 o3 ?print ret = Gen.map (Fn.map_fun (fun g x y z -> g Tuple.(x @:: y @:: z @:: nil))) (fun_nary Tuple.(o1 @-> o2 @-> o3 @-> o_nil) ?print ret) let fun4 o1 o2 o3 o4 ?print ret = Gen.map (Fn.map_fun (fun g x y z w -> g Tuple.(x @:: y @:: z @:: w @:: nil))) (fun_nary Tuple.(o1 @-> o2 @-> o3 @-> o4 @-> o_nil) ?print ret) module TestResult = struct type 'a counter_ex = { instance: 'a; (** The counter-example(s) *) shrink_steps: int; (** How many shrinking steps for this counterex *) msg_l: string list; (** messages. @since 0.7 *) } (** Result state. changed in 0.10 (move to inline records) *) type 'a state = | Success | Failed of { instances: 'a counter_ex list; (** Failed instance(s) *) } | Failed_other of {msg: string} | Error of { instance: 'a counter_ex; exn: exn; backtrace: string; } (** Error, backtrace, and instance that triggered it *) (* result returned by running a test *) type 'a t = { mutable state : 'a state; mutable count: int; (* number of tests *) mutable count_gen: int; (* number of generated cases *) collect_tbl: (string, int) Hashtbl.t lazy_t; stats_tbl: ('a stat * (int, int) Hashtbl.t) list; mutable warnings: string list; } let get_state {state; _} = state let get_count {count; _} = count let get_count_gen {count_gen; _} = count_gen (* indicate failure on the given [instance] *) let fail ~msg_l ~steps:shrink_steps res instance = let c_ex = {instance; shrink_steps; msg_l; } in match res.state with | Success -> res.state <- Failed {instances=[ c_ex ]} | Error _ | Failed_other _ -> () | Failed {instances=[]} -> assert false | Failed {instances=l} -> res.state <- Failed {instances=c_ex :: l} let error ~msg_l ~steps res instance exn backtrace = res.state <- Error {instance={instance; shrink_steps=steps; msg_l; }; exn; backtrace} let get_collect r = if Lazy.is_val r.collect_tbl then Some (Lazy.force r.collect_tbl) else None let collect = get_collect let get_stats r = r.stats_tbl let stats = get_stats let get_warnings r = r.warnings let warnings = get_warnings let is_success r = match r.state with | Success -> true | Failed _ | Error _ | Failed_other _ -> false let is_failed r = match r.state with | Failed _ -> true | Success | Error _ | Failed_other _ -> false end module Test_exceptions = struct exception Test_fail of string * string list exception Test_error of string * string * exn * string exception Test_unexpected_success of string end module Test = struct type 'a cell = { count : int; (* number of tests to do *) long_factor : int; (* multiplicative factor for long test count *) positive : bool; (* indicates whether test is considered positive or negative *) max_gen : int; (* max number of instances to generate (>= count) *) max_fail : int; (* max number of failures *) retries : int; (* max number of retries during shrinking *) law : 'a -> bool; (* the law to check *) gen : 'a Gen.t; (* how to generate/shrink instances *) print : 'a Print.t option; (* how to print values *) collect : ('a -> string) option; (* collect values by tag, useful to display distribution of generated *) stats : 'a stat list; (* distribution of values of type 'a *) qcheck1_shrink : ('a -> ('a -> unit) -> unit) option; (* QCheck1-backward-compatible shrinking *) if_assumptions_fail: [`Fatal | `Warning] * float; mutable name : string; (* name of the law *) } type t = | Test : 'a cell -> t let get_name {name; _} = name let set_name c name = c.name <- name let get_law {law; _} = law let get_gen {gen; _} = gen let get_print_opt {print; _} = print let get_collect_opt {collect; _} = collect let get_stats {stats; _} = stats let get_count {count; _ } = count let get_long_factor {long_factor; _} = long_factor let get_positive {positive; _} = positive let default_count = 100 let default_long_factor = 1 let global_nonnegative_var default env_var var = let var = match (var, Sys.getenv_opt env_var) with | (Some x, _) -> x | (_, Some x) -> int_of_string x | (None, None) -> default in if var < 0 then invalid_arg (env_var ^ " must be >= 0 but value is " ^ string_of_int var) else var let global_count count = global_nonnegative_var default_count "QCHECK_COUNT" count let global_long_factor long_factor = global_nonnegative_var default_long_factor "QCHECK_LONG_FACTOR" long_factor let fresh_name = let r = ref 0 in (fun () -> incr r; Printf.sprintf "anon_test_%d" !r) let default_if_assumptions_fail = `Warning, 0.05 let make_cell ?(if_assumptions_fail=default_if_assumptions_fail) ?(count) ?long_factor ?(negative=false) ?max_gen ?(max_fail=1) ?(retries=1) ?(name=fresh_name()) ?print ?collect ?(stats=[]) gen law = let count = global_count count in let long_factor = global_long_factor long_factor in let positive = not negative in let max_gen = match max_gen with None -> count + 200 | Some x->x in { law; gen; collect; print; stats; max_gen; max_fail; retries; name; count; long_factor; positive; if_assumptions_fail; qcheck1_shrink = None; } let make_cell_from_QCheck1 ?(if_assumptions_fail=default_if_assumptions_fail) ?(count) ?long_factor ?(negative=false) ?max_gen ?(max_fail=1) ?(retries=1) ?(name=fresh_name()) ~gen ?shrink ?print ?collect ~stats law = let count = global_count count in let long_factor = global_long_factor long_factor in let positive = not negative in (* Make a "fake" QCheck2 arbitrary with no shrinking *) let fake_gen = Gen.make_primitive ~gen ~shrink:(fun _ -> Seq.empty) in let max_gen = match max_gen with None -> count + 200 | Some x->x in { law; gen = fake_gen; print; collect; stats; max_gen; max_fail; retries; name; count; long_factor; positive; if_assumptions_fail; qcheck1_shrink = shrink; } let make' ?if_assumptions_fail ?count ?long_factor ?max_gen ?max_fail ?retries ?name ?print ?collect ?stats ~negative arb law = Test (make_cell ?if_assumptions_fail ?count ?long_factor ?max_gen ?max_fail ?retries ?name ?print ?collect ?stats ~negative arb law) let make = make' ~negative:false let make_neg = make' ~negative:true let test_get_count (Test cell) = get_count cell let test_get_long_factor (Test cell) = get_long_factor cell (** {6 Running the test} *) module R = TestResult (* Result of an instance run *) type res = | Success | Failure | FalseAssumption | Error of exn * string (* Step function, called after each instance test *) type 'a step = string -> 'a cell -> 'a -> res -> unit let step_nil_ _ _ _ _ = () (* Events of a test *) type 'a event = | Generating | Collecting of 'a | Testing of 'a | Shrunk of int * 'a | Shrinking of int * int * 'a type 'a handler = string -> 'a cell -> 'a event -> unit let handler_nil_ _ _ _ = () (* state required by {!check} to execute *) type 'a state = { test: 'a cell; step: 'a step; handler : 'a handler; rand: RS.t; res: 'a TestResult.t; mutable cur_count: int; (** number of iterations remaining to do *) mutable cur_max_gen: int; (** maximum number of generations allowed *) mutable cur_max_fail: int; (** maximum number of counter-examples allowed *) } let is_done state = state.cur_count <= 0 || state.cur_max_gen <= 0 let decr_count state = state.res.R.count <- state.res.R.count + 1; state.cur_count <- state.cur_count - 1 let new_input_tree state = state.res.R.count_gen <- state.res.R.count_gen + 1; state.cur_max_gen <- state.cur_max_gen - 1; state.test.gen state.rand (* statistics on inputs *) let collect st i = match st.test.collect with | None -> () | Some f -> let key = f i in let (lazy tbl) = st.res.R.collect_tbl in let n = try Hashtbl.find tbl key with Not_found -> 0 in Hashtbl.replace tbl key (n+1) let update_stats st i = List.iter (fun ((_,f), tbl) -> let key = f i in let n = try Hashtbl.find tbl key with Not_found -> 0 in Hashtbl.replace tbl key (n+1)) st.res.R.stats_tbl type res_or_exn = | Shrink_fail | Shrink_exn of exn (* triggered by user to fail with a message *) exception User_fail of string let fail_report m = raise (User_fail m) let fail_reportf m = let buf = Buffer.create 64 in Format.kfprintf (fun out -> Format.fprintf out "@?"; fail_report (Buffer.contents buf)) (Format.formatter_of_buffer buf) m type 'a run_res = | Run_ok | Run_fail of string list (* run_law is a helper function for testing a property [law] on a generated input [x]. When passed a ~retries number n>1, the tested property is checked n times for each shrunk input candidate. The default value is 1, thus causing no change in behaviour. Retrying a property can be useful when testing non-deterministic code with QCheck, e.g., for multicore execution. The idea is described in 'Testing a Database for Race Conditions with QuickCheck' Hughes and Bolinder, Erlang 2011, Sec.6: "As we explained in section 4, we ensure that tests fail when races are present simply by repeating each test a large number of times, and by running on a dual core machine. We obtained the minimal failing cases in the previous section by repeating each test 100 times during shrinking: thus we stopped shrinking a test case only when all of its candidate shrinkings passed 100 tests in a row." *) let run_law ~retries law x = let rec loop i = match law x with | false -> Run_fail [] | true -> if i<=1 then Run_ok else loop (i-1) in try loop retries with User_fail msg -> Run_fail [msg] (* QCheck1-compatibility code *) exception Iter_exit let iter_find_map p iter = let r = ref None in (try iter (fun x -> match p x with Some _ as y -> r := y; raise Iter_exit | None -> ()) with Iter_exit -> () ); !r (* try to shrink counter-ex [i] into a smaller one. Returns shrinked value and number of steps *) let shrink st (i_tree : 'a Tree.t) (r : res_or_exn) m : 'a * res_or_exn * string list * int = let is_err = match r with | Shrink_exn _ -> true | _ -> false in let rec shrink_ st i_tree r m ~steps = let Tree.Tree (i, shrinks) = i_tree in st.handler st.test.name st.test (Shrunk (steps, i)); let count = ref 0 in let i' = match st.test.qcheck1_shrink with | Some f -> (* QCheck1-compatibility, copied almost verbatim from QCheck.ml old code *) iter_find_map (fun x -> (* let Tree.Tree (x, _) = x_tree in *) try incr count; st.handler st.test.name st.test (Shrinking (steps, !count, x)); begin match run_law ~retries:st.test.retries st.test.law x with | Run_fail m when not is_err -> Some (Tree.pure x, Shrink_fail, m) | _ -> None end with | Failed_precondition | No_example_found _ -> None | e when is_err -> Some (Tree.pure x, Shrink_exn e, []) (* fail test (by error) *) ) (f i) | None -> (* QCheck2 (or QCheck1 with a shrinkless tree): use the shrink tree *) Seq.filter_map (fun x_tree -> let Tree.Tree (x, _) = x_tree in try incr count; st.handler st.test.name st.test (Shrinking (steps, !count, x)); begin match run_law ~retries:st.test.retries st.test.law x with | Run_fail m when not is_err -> Some (x_tree, Shrink_fail, m) | _ -> None end with | Failed_precondition | No_example_found _ -> None | e when is_err -> Some (x_tree, Shrink_exn e, []) (* fail test (by error) *) ) shrinks |> Seq.hd in match i' with | None -> i, r, m, steps | Some (i_tree',r',m') -> shrink_ st i_tree' r' m' ~steps:(steps + 1) (* shrink further *) in shrink_ ~steps:0 st i_tree r m type 'a check_result = | CR_continue | CR_yield of 'a TestResult.t (* test raised [e] on [input]; try to shrink then fail *) let handle_exn state input e bt : _ check_result = (* first, shrink TODO: shall we shrink differently (i.e. expected only an error)? *) let input, r, msg_l, steps = shrink state input (Shrink_exn e) [] in (* recover exception of shrunk input *) let e = match r with | Shrink_fail -> e | Shrink_exn e' -> e' in state.step state.test.name state.test input (Error (e, bt)); R.error state.res ~steps ~msg_l input e bt; CR_yield state.res (* test failed on [input], which means the law is wrong. Continue if we should. *) let handle_fail state input msg_l : _ check_result = (* first, shrink *) let input, _, msg_l, steps = shrink state input Shrink_fail msg_l in (* fail *) decr_count state; state.step state.test.name state.test input Failure; state.cur_max_fail <- state.cur_max_fail - 1; R.fail state.res ~steps ~msg_l input; if state.cur_max_fail > 0 then CR_continue else CR_yield state.res (* [check_state state] applies [state.test] repeatedly ([iter] times) on output of [test.rand], and if [state.test] ever returns false, then the input that caused the failure is returned in [Failed]. If [func input] raises [Failed_precondition] then the input is discarded, unless max_gen is 0. *) let rec check_state state : _ R.t = if is_done state then state.res else ( state.handler state.test.name state.test Generating; match new_input_tree state with | i_tree -> check_state_input state i_tree | exception e -> (* turn it into an error *) let bt = Printexc.get_backtrace() in let msg = Printf.sprintf "ERROR: uncaught exception in generator for test %s after %d steps:\nException: %s\nBacktrace: %s" state.test.name state.test.count (Printexc.to_string e) bt in state.res.R.state <- R.Failed_other {msg}; state.res ) and check_state_input state input_tree = let Tree.Tree (input, _) = input_tree in state.handler state.test.name state.test (Collecting input); collect state input; update_stats state input; let res = try state.handler state.test.name state.test (Testing input); begin match run_law ~retries:1 state.test.law input with | Run_ok -> (* one test ok *) decr_count state; state.step state.test.name state.test input Success; CR_continue | Run_fail msg_l -> handle_fail state input_tree msg_l end with | Failed_precondition | No_example_found _ -> state.step state.test.name state.test input FalseAssumption; CR_continue | e -> let bt = Printexc.get_backtrace () in handle_exn state input_tree e bt in match res with | CR_continue -> check_state state | CR_yield x -> x type 'a callback = string -> 'a cell -> 'a TestResult.t -> unit let callback_nil_ : _ callback = fun _ _ _ -> () (* check that there are sufficiently many tests which passed, to avoid the case where they all passed by failed precondition *) let check_if_assumptions target_count cell res : unit = let percentage_of_count = float_of_int res.R.count /. float_of_int target_count in let assm_flag, assm_frac = cell.if_assumptions_fail in if R.is_success res && percentage_of_count < assm_frac then ( let msg = format_of_string "%s: \ only %.1f%% tests (of %d) passed precondition for %S\n\n\ NOTE: it is likely that the precondition is too strong, or that \ the generator is buggy.\n%!" in match assm_flag with | `Warning -> let msg = Printf.sprintf msg "WARNING" (percentage_of_count *. 100.) cell.count cell.name in res.R.warnings <- msg :: res.R.warnings | `Fatal -> (* turn it into an error *) let msg = Printf.sprintf msg "ERROR" (percentage_of_count *. 100.) cell.count cell.name in res.R.state <- R.Failed_other {msg} ) (* main checking function *) let check_cell ?(long=false) ?(call=callback_nil_) ?(step=step_nil_) ?(handler=handler_nil_) ?(rand=RS.make [| 0 |]) cell = let factor = if long then cell.long_factor else 1 in let target_count = factor*cell.count in let state = { test=cell; rand; step; handler; cur_count=target_count; cur_max_gen=factor*cell.max_gen; cur_max_fail=factor*cell.max_fail; res = {R. state=R.Success; count=0; count_gen=0; collect_tbl=lazy (Hashtbl.create 10); warnings=[]; stats_tbl= List.map (fun stat -> stat, Hashtbl.create 10) cell.stats; }; } in let res = check_state state in check_if_assumptions target_count cell res; call cell.name cell res; res include Test_exceptions (* print instance using [arb] *) let print_instance arb i = match arb.print with | None -> "" | Some pp -> pp i let print_c_ex arb c : string = let buf = Buffer.create 64 in begin if c.R.shrink_steps > 0 then Printf.bprintf buf "%s (after %d shrink steps)" (print_instance arb c.R.instance) c.R.shrink_steps else Buffer.add_string buf (print_instance arb c.R.instance) end; List.iter (fun msg -> Buffer.add_char buf '\n'; Buffer.add_string buf msg; Buffer.add_char buf '\n') c.R.msg_l; Buffer.contents buf let pp_print_test_fail name out l = let rec pp_list out = function | [] -> () | [x] -> Format.fprintf out "%s@," x | x :: y -> Format.fprintf out "%s@,%a" x pp_list y in Format.fprintf out "@[test `%s`@ failed on ≥ %d cases:@ @[%a@]@]" name (List.length l) pp_list l let asprintf fmt = let buf = Buffer.create 128 in let out = Format.formatter_of_buffer buf in Format.kfprintf (fun _ -> Buffer.contents buf) out fmt let print_test_fail name l = asprintf "@[%a@]@?" (pp_print_test_fail name) l let print_unexpected_success name = Format.sprintf "@[negative test `%s`@ succeeded unexpectedly@]" name let print_test_error name i e stack = Format.sprintf "@[test `%s`@ raised exception `%s`@ on `%s`@,%s@]" name (Printexc.to_string e) i stack let print_collect c = let out = Buffer.create 64 in Hashtbl.iter (fun case num -> Printf.bprintf out "%s: %d cases\n" case num) c; Buffer.contents out let stat_max_lines = 20 (* maximum number of lines for a histogram *) let print_stat ((name,_), tbl) = let neg_avg_summands = ref [] in let pos_avg_summands = ref [] in let num = ref 0 in let min_idx, max_idx = Hashtbl.fold (fun i res (m1,m2) -> let avg_summand = float_of_int (i * res) in if avg_summand < 0. then neg_avg_summands := avg_summand::!neg_avg_summands else pos_avg_summands := avg_summand::!pos_avg_summands; num := !num + res; min i m1, max i m2) tbl (max_int,min_int) in (* compute average, summing positive/negative separately by order of magnitude *) let neg_avg_sums = List.sort Float.compare !neg_avg_summands |> fun xs -> List.fold_right (+.) xs 0. in let pos_avg_sums = List.sort Float.compare !pos_avg_summands |> List.fold_left (+.) 0. in let avg = ref (neg_avg_sums +. pos_avg_sums) in if !num > 0 then ( avg := !avg /. float_of_int !num ); (* compute std-dev: sqroot of sum of squared distance-to-average https://en.wikipedia.org/wiki/Standard_deviation *) let stddev = Hashtbl.fold (fun i res acc -> float_of_int res *. ((float_of_int i -. !avg) ** 2.) :: acc) tbl [] |> List.sort Float.compare (* add summands in increasing order to preserve precision *) |> List.fold_left (+.) 0. |> (fun s -> if !num>0 then s /. float_of_int !num else s) |> sqrt in (* compute median *) let median = ref 0 in let median_num = ref 0 in (* how many values have we seen yet? once >= !n/2 we set median *) (Hashtbl.fold (fun i cnt acc -> (i,cnt)::acc) tbl []) |> List.sort (fun (i,_) (j,_) -> poly_compare i j) |> List.iter (fun (i,cnt) -> if !median_num < !num/2 then ( median_num := !median_num + cnt; (* just went above median! *) if !median_num >= !num/2 then median := i)); (* group by buckets, if there are too many entries: *) (* first compute histogram and bucket size *) let min_idx64, max_idx64 = Int64.(of_int min_idx, of_int max_idx) in let hist_size, bucket_size = let sample_width = Int64.sub max_idx64 min_idx64 in if sample_width > Int64.of_int stat_max_lines then stat_max_lines, int_of_float (ceil (Int64.to_float sample_width /. float_of_int stat_max_lines)) else max_idx-min_idx, 1 in let hist_size = if Int64.(add min_idx64 (mul (of_int bucket_size) (of_int hist_size))) <= max_idx64 then 1+hist_size else hist_size in (* accumulate bucket counts *) let max_val = ref 0 in (* max value after grouping by buckets *) let bucket_count = Array.init hist_size (fun _ -> 0) in Hashtbl.iter (fun j count -> let bucket = Int64.(to_int (div (sub (of_int j) min_idx64) (of_int bucket_size))) in let new_count = bucket_count.(bucket) + count in bucket_count.(bucket) <- new_count; max_val := max !max_val new_count) tbl; (* print entries of the table, sorted by increasing index *) let out = Buffer.create 128 in (* Windows workaround to avoid annoying exponent zero such as "1.859e+018" *) let cut_exp_zero s = match String.split_on_char '+' s with | [signif;exponent] -> Printf.sprintf "%s+%i" signif (int_of_string exponent) | _ -> failwith "cut_exp_zero failed to parse scientific notation " ^ s in let fmt_float f = if f > 1e7 || f < -1e7 then cut_exp_zero (Printf.sprintf "%.3e" f) else Printf.sprintf "%.2f" f in Printf.bprintf out "stats %s:\n" name; Printf.bprintf out " num: %d, avg: %s, stddev: %s, median %d, min %d, max %d\n" !num (fmt_float !avg) (fmt_float stddev) !median min_idx max_idx; let indwidth = let str_width i = String.length (Printf.sprintf "%d" i) in List.map str_width [min_idx; max_idx; min_idx + bucket_size * hist_size] |> List.fold_left max min_int in let labwidth = if bucket_size=1 then indwidth else 2+2*indwidth in for i = 0 to hist_size - 1 do let i' = min_idx + i * bucket_size in let blabel = if bucket_size=1 then Printf.sprintf "%*d" indwidth i' else let bucket_bound = i'+bucket_size-1 in Printf.sprintf "%*d..%*d" indwidth i' indwidth (if bucket_bound < i' then max_int else bucket_bound) in let bcount = bucket_count.(i) in (* NOTE: keep in sync *) let bar_len = bcount * 55 / !max_val in Printf.bprintf out " %*s: %-56s %10d\n" labwidth blabel (String.make bar_len '#') bcount done; Buffer.contents out let () = Printexc.register_printer (function | Test_fail (name,l) -> Some (print_test_fail name l) | Test_error (name,i,e,st) -> Some (print_test_error name i e st) | Test_unexpected_success name -> Some (print_unexpected_success name) | User_fail s -> Some ("qcheck: user fail:\n" ^ s) | _ -> None) let print_fail arb name l = print_test_fail name (List.map (print_c_ex arb) l) let print_fail_other name ~msg = print_test_fail name [msg] let print_expected_failure cell c_exs = match c_exs with | [] -> Format.sprintf "negative test `%s` failed as expected\n" (get_name cell) | c_ex::_ -> Format.sprintf "negative test `%s` failed as expected on: %s\n" (get_name cell) (print_c_ex cell c_ex) let print_error ?(st="") arb name (i,e) = print_test_error name (print_c_ex arb i) e st let check_result cell res = match res.R.state, cell.positive with | R.Success, true -> () | R.Success, false -> raise (Test_unexpected_success cell.name) | R.Error {instance; exn; backtrace}, _ -> raise (Test_error (cell.name, print_c_ex cell instance, exn, backtrace)) | R.Failed {instances=l}, true -> let l = List.map (print_c_ex cell) l in raise (Test_fail (cell.name, l)) | R.Failed _, false -> () | R.Failed_other {msg}, _ -> raise (Test_fail (cell.name, [msg])) let check_cell_exn ?long ?call ?step ?handler ?rand cell = let res = check_cell ?long ?call ?step ?handler ?rand cell in check_result cell res let check_exn ?long ?rand (Test cell) = check_cell_exn ?long ?rand cell end let find_example ?(name : string = "") ?(count : int option) ~(f : 'a -> bool) (gen : 'a Gen.t) : 'a Gen.t = (* the random generator of examples satisfying [f]. To do that we test the property [fun x -> not (f x)]; any counter-example *) let gen st = let cell = Test.make_cell ~max_fail:1 ?count gen (fun x -> not (f x)) in let res = Test.check_cell ~rand:st cell in begin match res.TestResult.state with | TestResult.Success -> raise (No_example_found name) | TestResult.Error _ -> raise (No_example_found name) | TestResult.Failed {instances=[]} -> assert false | TestResult.Failed {instances=failed::_} -> (* found counter-example! *) Tree.pure failed.TestResult.instance | TestResult.Failed_other {msg=_} -> raise (No_example_found name) end in gen let find_example_gen ?(rand : RS.t option) ?(name : string option) ?(count : int option) ~(f : 'a -> bool) (gen : 'a Gen.t) : 'a = let g = find_example ?name ?count ~f gen in Gen.generate1 ?rand g qcheck-0.25/src/core/QCheck2.mli000066400000000000000000002167331477416744200163740ustar00rootroot00000000000000(* QCheck: Random testing for OCaml copyright (c) 2013-2017, Guillaume Bury, Simon Cruanes, Vincent Hugot, Jan Midtgaard, Julien Debon, Valentin Chaboche all rights reserved. *) (* Keep the following title alone in its documentation block as it is specially treated by Odoc: it doesn't appear in the Contents menu on the left. The next documentation block with all the actual content will appear. *) (** {1 QuickCheck-inspired property-based testing} *) (** {1 Introduction} This library takes inspiration from Haskell's QuickCheck library. The rough idea is that the programmer describes invariants that values of a certain type need to satisfy ("properties"), as functions from this type to [bool]. The programmer also needs to describe how to generate random values of the type, so that the property is tried and checked on a number of random instances. This explains the organization of this module: - {!Gen} is used to describe how to generate random values. Auxiliary module {!Print} can be used along with {!Test.make} to build one's own generator instances. - {!Test} is used to describe a single test, that is, a property of type ['a -> bool] combined with an ['a Gen.t] that is used to generate the test cases for this property. Optional parameters allow to specify the random generator state, number of instances to generate and test, etc. 💡 If you are migrating from QCheck, check the {{!section:migration_qcheck2} migration guide} below. {1 Examples} - "[List.rev] is involutive" (the test passes so [check_exn] returns [()]): {[ let test = QCheck2.(Test.make ~count:1000 ~print:Print.(list int) Gen.(list int) (fun l -> List.rev (List.rev l) = l));; QCheck2.Test.check_exn test;; ]} - "All lists are sorted" (false property that will fail): {ul {- QCheck tests this property on random lists and finds a counter-example} {- QCheck then looks for the smallest counter-example possible (here [[1; 0]]) to help you find the problem (called "shrinking")} } {[ let test = QCheck2.( Test.make ~name:"All lists are sorted" ~count:10_000 ~print:Print.(list int) Gen.(list small_nat) (fun l -> l = List.sort compare l));; QCheck2.Test.check_exn test;; Exception: test `All lists are sorted` failed on ≥ 1 cases: [1; 0] (after 5 shrink steps) ]} - Generate 20 random trees using {! Gen.fix} : {[ type tree = Leaf of int | Node of tree * tree let leaf x = Leaf x let node x y = Node (x,y) let tree_gen = QCheck2.Gen.(sized @@ fix (fun self n -> match n with | 0 -> map leaf nat | n -> frequency [1, map leaf nat; 2, map2 node (self (n/2)) (self (n/2))] ));; QCheck2.Gen.generate ~n:20 tree_gen;; ]} @since 0.18 *) (** {1 Generators, printers, and shrinkers in QCheck2 } The {!Gen} module offers combinators to build compositive generators for complex data types. To print counter-examples, {!Test.make} accepts a [print] function, turning a test-case into a [string] for printing on the console. The {!Print} module offers combinators to build such printers. The {!Tree} module defines the lazy tree type underlying integrated shrinking. The {!Shrink} module contains utility functions for defining shrinkers. *) (** A tree represents a generated value and its successive shrunk values. *) module Tree : sig (** Conceptually a pseudo-randomly generated value is packaged with its shrunk values. This coupling - called "integrated shrinking" - in a single type has a major benefit: most generators get shrinking "for free" by composing from smaller generators, and shrinking does not break invariants (e.g. shrinks of a positive number are always positive). *) type 'a t (** A tree of random generated values, where the root contains the value used for the test, and the sub-trees contain shrunk values (as trees, to be able to shrink several times a value) used if the test fails. *) val root : 'a t -> 'a (** [root tree] returns the root value of the tree of generated values [t]. *) val children : 'a t -> 'a t Seq.t (** [children tree] returns the direct sub-trees of the tree of generated values [t]. *) val pp : ?depth : int -> (Format.formatter -> 'a -> unit) -> Format.formatter -> 'a t -> unit (** [pp ?depth pp_a ppf tree] pretty-prints the tree of generated values [tree] using the pretty-print formatter [ppf]. Values of type ['a] will be printed using the given pretty-printer [pp_a]. As a tree [t] can be potentially huge when fully evaluated, you can control the maximum depth the printer goes with [depth]. - [None] means "everything" - [0] means "only the root" - [1] means "the root and its direct shrinks" - [2] means "the root, its direct shrinks, and the shrinks of its shrinks" - etc. *) end (** A generator is responsible for generating pseudo-random values and provide shrinks (smaller values) when a test fails. *) module Gen : sig (** This module provides some of the most important features of QCheck: - {{!section:primitive_generators} primitive generators} - {{!section:composing_generators} generator compositions} *) type 'a t (** A random generator for values of type ['a]. *) type 'a sized = int -> 'a t (** Random generator with a size bound. *) (** {3:primitive_generators Primitive generators} *) val unit : unit t (** The unit generator. Does not shrink. *) val bool : bool t (** The boolean generator. Shrinks towards [false]. *) val int : int t (** Generates integers uniformly. Shrinks towards [0]. *) val pint : ?origin : int -> int t (** Generates non-strictly positive integers uniformly ([0] included). Shrinks towards [origin] if specified, otherwise towards [0]. *) val small_nat : int t (** Small positive integers (< [100], [0] included). Non-uniform: smaller numbers are more likely than bigger numbers. Shrinks towards [0]. @since 0.5.1 *) val nat : int t (** Generates natural numbers (< [10_000]). Non-uniform: smaller numbers are more likely than bigger numbers. Shrinks towards [0]. *) val big_nat : int t (** Generates natural numbers, possibly large (< [1_000_000]). Non-uniform: smaller numbers are more likely than bigger numbers. Shrinks towards [0]. @since 0.10 *) val neg_int : int t (** Generates non-strictly negative integers ([0] included). Non-uniform: smaller numbers (in absolute value) are more likely than bigger numbers. Shrinks towards [0]. *) val small_int : int t (** Small UNSIGNED integers, for retrocompatibility. Shrinks towards [0]. @deprecated use {!small_nat}. *) val small_signed_int : int t (** Small SIGNED integers, based on {!small_nat}. Non-uniform: smaller numbers (in absolute value) are more likely than bigger numbers. Shrinks towards [0]. @since 0.5.2 *) val small_int_corners : unit -> int t (** As {!small_int}, but each newly created generator starts with a list of corner cases before falling back on random generation. Note that [small_int_corners ()] is stateful, meaning that once the list of corner cases has been emitted, subsequent calls will not reproduce them. As a consequence, in the following example, the first test fails with a counter example, whereas the second rerun does not: {[ let gen = QCheck2.Gen.small_int_corners () let t = QCheck2.Test.make ~name:"never max_int" gen (fun i -> i <> max_int) let _ = QCheck_base_runner.run_tests ~verbose:true [t;t] ]} *) val int32 : int32 t (** Generates uniform {!int32} values. Shrinks towards [0l]. *) val ui32 : int32 t (** Generates {!int32} values. Shrinks towards [0l]. @deprecated use {!val:int32} instead, the name is wrong, values {i are} signed. *) val int64 : int64 t (** Generates uniform {!int64} values. Shrinks towards [0L]. *) val ui64 : int64 t (** Generates {!int64} values. Shrinks towards [0L]. @deprecated use {!val:int64} instead, the name is wrong, values {i are} signed. *) val float : float t (** Generates floating point numbers. Shrinks towards [0.]. *) val pfloat : float t (** Generates positive floating point numbers ([0.] included). Shrinks towards [0.]. *) val nfloat : float t (** Generates negative floating point numbers. ([-0.] included). Shrinks towards [-0.]. *) val char : char t (** Generates characters in the [0..255] range. Shrinks towards ['a']. *) val printable : char t (** Generates printable characters. The exhaustive list of character codes is: - [32] to [126], inclusive - ['\n'] Shrinks towards ['a'] or lower character codes. *) val numeral : char t (** Generates numeral characters ['0'..'9']. Shrinks towards ['0']. *) val bytes_size : ?gen:char t -> int t -> bytes t (** Builds a bytes generator from a (non-negative) size generator. Accepts an optional character generator (the default is {!char}). Shrinks on the number of characters first, then on the characters. @since 0.20 *) val bytes : bytes t (** Bytes generator using the {!char} character generator. Bytes size is generated by {!nat}. See also {!bytes_of} and {!bytes_printable} for versions with custom char generator. Shrinks on the number of characters first, then on the characters. @since 0.20 *) val bytes_of : char t -> bytes t (** Builds a bytes generator using the given character generator. Shrinks on the number of characters first, then on the characters. @since 0.20 *) val bytes_printable : bytes t (** Generator using the {!printable} character generator. Shrinks on the number of characters first, then on the characters. @since 0.20 *) val bytes_small : bytes t (** Builds a bytes generator using the {!char} character generator, length is {!small_nat}. Shrinks on the number of characters first, then on the characters. @since 0.20 *) val bytes_small_of : char t -> bytes t (** Builds a bytes generator using the given character generator, length is {!small_nat}. Shrinks on the number of characters first, then on the characters. @since 0.20 *) val string_size : ?gen:char t -> int t -> string t (** Builds a string generator from a (non-negative) size generator. Accepts an optional character generator (the default is {!char}). Shrinks on the number of characters first, then on the characters. *) val string : string t (** Builds a string generator. String size is generated by {!nat}. The default character generator is {!char}. See also {!string_of} and {!string_printable} for versions with custom char generator. Shrinks on the number of characters first, then on the characters. *) val string_of : char t -> string t (** Builds a string generator using the given character generator. Shrinks on the number of characters first, then on the characters. @since 0.11 *) val string_printable : string t (** Builds a string generator using the {!printable} character generator. Shrinks on the number of characters first, then on the characters. @since 0.11 *) val string_small : string t (** Builds a string generator using the {!char} characher generator, length is {!small_nat}. Shrinks on the number of characters first, then on the characters. @since 0.20 *) val string_small_of : char t -> string t (** Builds a string generator using the given characher generator, length is {!small_nat}. Shrinks on the number of characters first, then on the characters. @since 0.20 *) val small_string : ?gen:char t -> string t (** Builds a string generator, length is {!small_nat}. Accepts an optional character generator (the default is {!char}). Shrinks on the number of characters first, then on the characters. This function is kept for backward compatibility: The optional argument is in fact a mandatory [option], see c-cube/qcheck#162. Use {!string_small} instead. *) val pure : 'a -> 'a t (** [pure a] creates a generator that always returns [a]. Does not shrink. @since 0.8 *) val return : 'a -> 'a t (** Synonym for {!pure} *) val make_primitive : gen : (Random.State.t -> 'a) -> shrink : ('a -> 'a Seq.t) -> 'a t (** [make_primitive ~gen ~shrink] creates a generator from a function [gen] that creates a random value (this function must only use the given [Random.State.t] for randomness) and a function [shrink] that, given a value [a], returns a lazy list of "smaller" values (used when a test fails). This lower-level function is meant to build generators for "primitive" types that can neither be built with other primitive generators nor through composition, or to have more control on the shrinking steps. [shrink] must obey the following rules (for your own definition of "small"): - [shrink a = Seq.empty] when [a] is the smallest possible value - [shrink a] must return values strictly smaller than [a], ideally from smallest to largest (for faster shrinking) - [let rec loop a = match shrink a () with | Nil -> () | Cons (smaller_a, _) -> loop smaller_a] must end for all values [a] of type ['a] (i.e. there must not be an infinite number of shrinking steps). ⚠️ This is an unstable API as it partially exposes the implementation. In particular, the type of [Random.State.t] may very well change in a future version, e.g. if QCheck switches to another randomness library. *) val add_shrink_invariant : ('a -> bool) -> 'a t -> 'a t (** [add_shrink_invariant f gen] returns a generator similar to [gen] except all shrinks satisfy [f]. This way it's easy to preserve invariants that are enforced by generators, when shrinking values @since 0.8 @deprecated is this function still useful? I feel like it is either useless (invariants should already be part of the shrinking logic, not be added later) or a special, incomplete case of {!Gen.t} being an Alternative (not implemented yet). For now we keep it and wait for users feedback (hence deprecation to raise attention). *) val set_shrink : ('a -> 'a Seq.t) -> 'a t -> 'a t (** [set_shrink shrink gen] sets the shrinker to [shrink] for [gen]. *) val no_shrink : 'a t -> 'a t (** [no_shrink gen] returns a generator using [gen] but with shrinking disabled *) (** {3 Ranges} *) val int_bound : int -> int t (** Uniform integer generator producing integers within [0..bound]. Shrinks towards [0]. @raise Invalid_argument if the argument is negative. *) val int_range : ?origin:int -> int -> int -> int t (** [int_range ?origin low high] is an uniform integer generator producing integers within [low..high] (inclusive). Shrinks towards [origin] if specified, otherwise towards [0] (but always stays within the range). Examples: - [int_range ~origin:6 (-5) 15] will shrink towards [6] - [int_range (-5) 15] will shrink towards [0] - [int_range 8 20] will shrink towards [8] (closest to [0] within range) - [int_range (-20) (-8)] will shrink towards [-8] (closest to [0] within range) @raise Invalid_argument if any of the following holds: - [low > high] - [origin < low] - [origin > high] *) val (--) : int -> int -> int t (** [a -- b] is an alias for [int_range a b]. See {!int_range} for more information. *) val float_bound_inclusive : ?origin : float -> float -> float t (** [float_bound_inclusive ?origin bound] returns a random floating-point number between [0.] and [bound] (inclusive). If [bound] is negative, the result is negative or zero. If [bound] is [0.], the result is [0.]. Shrinks towards [origin] if given, otherwise towards [0.]. @since 0.11 *) val float_bound_exclusive : ?origin : float -> float -> float t (** [float_bound_exclusive origin bound] returns a random floating-point number between [0.] and [bound] (exclusive). If [bound] is negative, the result is negative or zero. Shrinks towards [origin] if given, otherwise towards [0.]. @raise Invalid_argument if [bound] is [0.]. @since 0.11 *) val float_range : ?origin : float -> float -> float -> float t (** [float_range ?origin low high] generates floating-point numbers within [low] and [high] (inclusive). Shrinks towards [origin] if specified, otherwise towards [0.] (but always stays within the range). Examples: - [float_range ~origin:6.2 (-5.8) 15.1] will shrink towards [6.2] - [float_range (-5.8) 15.1] will shrink towards [0.] - [float_range 8.5 20.1] will shrink towards [8.5] (closest to [0.] within range) - [float_range (-20.1) (-8.5)] will shrink towards [-8.5] (closest to [0.] within range) @raise Invalid_argument if any of the following holds: - [low > high] - [high -. low > max_float] - [origin < low] - [origin > high] @since 0.11 *) val (--.) : float -> float -> float t (** [a --. b] is an alias for [float_range ~origin:a a b]. See {!float_range} for more information. @since 0.11 *) val exponential : float -> float t (** [exponential m] generates floating-point numbers following an exponential distribution with a mean of [m]. @raise Invalid_argument if [m] is NaN. @since 0.23 *) val char_range : ?origin:char -> char -> char -> char t (** [char_range ?origin low high] generates chars between [low] and [high], inclusive. Example: [char_range 'a' 'z'] for all lower case ASCII letters. Shrinks towards [origin] if specified, otherwise towards [low]. @raise Invalid_argument if [low > high]. @since 0.13 *) (** {3 Choosing elements} *) val oneof : 'a t list -> 'a t (** [oneof l] constructs a generator that selects among the given list of generators [l]. Shrinks towards the first generator of the list. @raise Invalid_argument or Failure if [l] is empty *) val oneofl : 'a list -> 'a t (** [oneofl l] constructs a generator that selects among the given list of values [l]. Shrinks towards the first element of the list. @raise Invalid_argument or Failure if [l] is empty *) val oneofa : 'a array -> 'a t (** [oneofa a] constructs a generator that selects among the given array of values [a]. Shrinks towards the first element of the array. @raise Invalid_argument or Failure if [l] is empty *) val frequency : (int * 'a t) list -> 'a t (** Constructs a generator that selects among a given list of generators. Each of the given generators are chosen based on a positive integer weight. Shrinks towards the first element of the list. *) val frequencyl : (int * 'a) list -> 'a t (** Constructs a generator that selects among a given list of values. Each of the given values are chosen based on a positive integer weight. Shrinks towards the first element of the list. *) val frequencya : (int * 'a) array -> 'a t (** Constructs a generator that selects among a given array of values. Each of the array entries are chosen based on a positive integer weight. Shrinks towards the first element of the array. *) (** {3 Shuffling elements} *) val shuffle_a : 'a array -> 'a array t (** Returns a copy of the array with its elements shuffled. *) val shuffle_l : 'a list -> 'a list t (** Creates a generator of shuffled lists. *) val shuffle_w_l : (int * 'a) list -> 'a list t (** Creates a generator of weighted shuffled lists. A given list is shuffled on each generation according to the weights of its elements. An element with a larger weight is more likely to be at the front of the list than an element with a smaller weight. If we want to pick random elements from the (head of) list but need to prioritize some elements over others, this generator can be useful. Example: given a weighted list [[1, "one"; 5, "five"; 10, "ten"]], the generator is more likely to generate [["ten"; "five"; "one"]] or [["five"; "ten"; "one"]] than [["one"; "ten"; "five"]] because "ten" and "five" have larger weights than "one". @since 0.11 *) (** {3 Corner cases} *) val graft_corners : 'a t -> 'a list -> unit -> 'a t (** [graft_corners gen l ()] makes a new generator that enumerates the corner cases in [l] and then behaves like [g]. Does not shrink if the test fails on a grafted value. Shrinks towards [gen] otherwise. Note that [graft_corners gen l ()] is stateful, meaning that once the elements of [l] have been emitted, subsequent calls will not reproduce them. It is therefore recommended that separate tests each use a fresh generator. @since 0.6 *) val int_pos_corners : int list (** Non-negative corner cases for int. @since 0.6 *) val int_corners : int list (** All corner cases for int. @since 0.6 *) (** {3 Lists, arrays and options} *) val list : 'a t -> 'a list t (** Builds a list generator from an element generator. List size is generated by {!nat}. Shrinks on the number of elements first, then on elements. *) val small_list : 'a t -> 'a list t (** Generates lists of small size (see {!small_nat}). Shrinks on the number of elements first, then on elements. @since 0.5.3 *) val list_size : int t -> 'a t -> 'a list t (** Builds a list generator from a (non-negative) size generator and an element generator. Shrinks on the number of elements first, then on elements. *) val list_repeat : int -> 'a t -> 'a list t (** [list_repeat i g] builds a list generator from exactly [i] elements generated by [g]. Shrinks on elements only. *) val array : 'a t -> 'a array t (** Builds an array generator from an element generator. Array size is generated by {!nat}. Shrinks on the number of elements first, then on elements. *) val array_size : int t -> 'a t -> 'a array t (** Builds an array generator from a (non-negative) size generator and an element generator. Shrinks on the number of elements first, then on elements. *) val small_array : 'a t -> 'a array t (** Generates arrays of small size (see {!small_nat}). Shrinks on the number of elements first, then on elements. @since 0.10 *) val array_repeat : int -> 'a t -> 'a array t (** [array_repeat i g] builds an array generator from exactly [i] elements generated by [g]. Shrinks on elements only. *) val option : ?ratio:float -> 'a t -> 'a option t (** [option gen] is an [option] generator that uses [gen] when generating [Some] values. Shrinks towards [None] then towards shrinks of [gen]. @param ratio a float between [0.] and [1.] indicating the probability of a sample to be [Some _] rather than [None] (value is [0.85]). @since 0.19 (renamed from [opt]) *) val opt : ?ratio:float -> 'a t -> 'a option t (** [opt] is an alias of {!val:option} for backward compatibility. *) val result : ?ratio:float -> 'a t -> 'e t -> ('a, 'e) result t (** [result ~ratio okgen errgen] generates [Ok v] with [v] coming from [okgen] or [Error e] with [e] coming from [errgen], depending on [ratio]. @param ratio a float between [0.] and [1.] indicating the probability of a sample to be [Ok _] rather than [Error _]. @since 0.24 *) (** {3 Combining generators} *) val pair : 'a t -> 'b t -> ('a * 'b) t (** [pair gen1 gen2] generates pairs. Shrinks on [gen1] and then [gen2]. *) val triple : 'a t -> 'b t -> 'c t -> ('a * 'b * 'c) t (** [triple gen1 gen2 gen3] generates triples. Shrinks on [gen1], then [gen2] and then [gen3]. *) val quad : 'a t -> 'b t -> 'c t -> 'd t -> ('a * 'b * 'c * 'd) t (** [quad gen1 gen2 gen3 gen4] generates quadruples. Shrinks on [gen1], then [gen2], then [gen3] and then [gen4]. @since 0.5.1 *) (** {3 Tuple of generators} *) (** {4 Shrinks on [gen1], then [gen2], then ... } *) val tup2 : 'a t -> 'b t -> ('a * 'b) t (** Combines two generators into a 2-tuple generator. *) val tup3 : 'a t -> 'b t -> 'c t -> ('a * 'b * 'c) t (** Combines three generators into a 3-tuple generator. *) val tup4 : 'a t -> 'b t -> 'c t -> 'd t -> ('a * 'b * 'c * 'd) t (** Combines four generators into a 4-tuple generator. *) val tup5 : 'a t -> 'b t -> 'c t -> 'd t -> 'e t -> ('a * 'b * 'c * 'd * 'e) t (** Combines five generators into a 5-tuple generator. *) val tup6 : 'a t -> 'b t -> 'c t -> 'd t -> 'e t -> 'f t -> ('a * 'b * 'c * 'd * 'e * 'f) t (** Combines six generators into a 6-tuple generator. *) val tup7 : 'a t -> 'b t -> 'c t -> 'd t -> 'e t -> 'f t -> 'g t -> ('a * 'b * 'c * 'd * 'e * 'f * 'g) t (** Combines seven generators into a 7-tuple generator. *) 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 (** Combines eight generators into an 8-tuple generator. *) 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 (** Combines nine generators into a 9-tuple generator. *) (** {3 Convert a structure of generator to a generator of structure} *) val flatten_l : 'a t list -> 'a list t (** Generate a list of elements from individual generators. Shrinks on the elements of the list, in the list order. @since 0.13 *) val flatten_a : 'a t array -> 'a array t (** Generate an array of elements from individual generators. Shrinks on the elements of the array, in the array order. @since 0.13 *) val flatten_opt : 'a t option -> 'a option t (** Generate an option from an optional generator. Shrinks towards [None] then shrinks on the value. @since 0.13 *) val flatten_res : ('a t, 'e) result -> ('a,'e) result t (** Generate a result from [Ok gen], an error from [Error e]. Shrinks on [gen] if [Ok gen]. Does not shrink if [Error e]. @since 0.13 *) val join : 'a t t -> 'a t (** Collapses a generator of generators to a generator. Shrinks on the generated generators. @since 0.5 *) (** {3 Influencing the size of generated values} *) val sized : 'a sized -> 'a t (** Creates a generator from a size-bounded generator by first generating a size using {!nat} and passing the result to the size-bounded generator. Shrinks on the size first, then on the generator. *) val sized_size : int t -> 'a sized -> 'a t (** Creates a generator from a size-bounded generator by first generating a size using the integer generator and passing the result to the size-bounded generator. Shrinks on the size first, then on the generator. @since 0.5 *) (** {3 Recursive data structures} *) val fix : (('a -> 'b t) -> 'a -> 'b t) -> 'a -> 'b t (** Parametrized fixpoint combinator for generating recursive values. The fixpoint is parametrized over an generator state ['a], and the fixpoint computation may change the value of this state in the recursive calls. In particular, this can be used for size-bounded generators (with ['a] as [int]). The passed size-parameter should decrease to ensure termination. *) (** Example: {[ type tree = Leaf of int | Node of tree * tree let leaf x = Leaf x let node x y = Node (x,y) let g = QCheck.Gen.(sized @@ fix (fun self n -> match n with | 0 -> map leaf nat | n -> frequency [1, map leaf nat; 2, map2 node (self (n/2)) (self (n/2))] )) ]} [fix f] shrinks on the generators returned by [f]. *) val delay : (unit -> 'a t) -> 'a t (** Delay execution of some code until the generator is actually called. This can be used to manually implement recursion or control flow in a generator. @since 0.17 *) (** {2:composing_generators Composing generators} QCheck generators compose well: it means one can easily craft generators for new values or types from existing generators. Part of the following documentation is greatly inspired by Gabriel Scherer's excellent {{:http://gasche.github.io/random-generator/doc/Generator.html } Generator} module documentation. {3 Functor} [Gen.t] is a functor (in the Haskell sense of "mappable"): it has a [map] function to transform a generator of ['a] into a generator of ['b], given a simple function ['a -> 'b]. {[ let even_gen : int Gen.t = Gen.map (fun n -> n * 2) Gen.int let odd_gen : int Gen.t = Gen.map (fun n -> n * 2 + 1) Gen.int let lower_case_string_gen : string Gen.t = Gen.map String.lowercase Gen.string_printable type foo = Foo of string * int let foo_gen : foo Gen.t = Gen.map (fun (s, n) -> Foo (s, n)) Gen.(pair string_printable int) ]} {3 Applicative} [Gen.t] is applicative: it has a [map2] function to apply a function of 2 (or more) arguments to 2 (or more) generators. Another equivalent way to look at it is that it has an [ap] function to apply a generator of functions to a generator of values. While at first sight this may look almost useless, it actually permits a nice syntax (using the operator alias [<*>]) for functions of any number of arguments. {[ (* Notice that this looks suspiciously like the [foo] example above: this is no coincidence! [pair] is a special case of [map2] where the function wraps arguments in a tuple. *) type foo = Foo of string * int let foo_gen : foo Gen.t = Gen.map2 (fun s n -> Foo (s, n)) Gen.string_printable Gen.int let string_prefixed_with_keyword_gen : string Gen.t = Gen.map2 (fun prefix s -> prefix ^ s) (Gen.oneofl ["foo"; "bar"; "baz"]) Gen.string_printable ]} Applicatives are useful when you need several random values to build a new generator, {b and the values are unrelated}. A good rule of thumb is: if the values could be generated in parallel, then you can use an applicative function to combine those generators. Note that while [map2], [map3], [map4], and [map5] are provided, you can use functions with more than 5 arguments (this is where the [<*>] operator alias shines): {[ val complex_function : bool -> string -> int -> string -> int64 -> some_big_type (* Verbose version, using map3 and ap to mimic map5 *) let big_type_gen : some_big_type Gen.t = Gen.( ap ( ap ( map3 complex_function bool string_printable int) string_printable) int64) (* Sleeker syntax, using operators aliases for map and ap *) let big_type_gen : some_big_type Gen.t = Gen.( complex_function <$> bool <*> string_printable <*> int <*> string_printable <*> int64) ]} {3 Monad} [Gen.t] is a monad: it has a [bind] function to return a {b generator} (not a value) based on {b another generated value}. As an example, imagine you want to create a generator of [(int, string) result] that is an [Ok] 90% of the time and an [Error] 10% of the time. You can generate a number between 0 and 9 and return a generator of [int] (wrapped in an [Ok] using [map]) if the generated number is lower than 9, otherwise return a generator of [string] (wrapped in an [Error] using [map]): {[ let int_string_result : (int, string) result Gen.t = Gen.( bind (int_range 0 9) (fun n -> if n < 9 then map Result.ok int else map Result.error string_printable)) (* Alternative syntax with operators *) let int_string_result : (int, string) result Gen.t = Gen.( int_range 0 9 >>= fun n -> if n < 9 then int >|= Result.ok else string_printable >|= Result.error) (* Another allternative syntax with OCaml 4.08+ binding operators *) let int_string_result : (int, string) result Gen.t = Gen.( let* n = int_range 0 9 in if n < 9 then int >|= Result.ok else string_printable >|= Result.error) ]} Note that this particular use case can be simplified by using [frequency]: {[ let int_string_result : (int, string) result Gen.t = Gen.( frequency [ (9, int >|= Result.ok); (1, string_printable >|= Result.error) ]) ]} *) val map : ('a -> 'b) -> 'a t -> 'b t (** [map f gen] transforms a generator [gen] by applying [f] to each generated element. Shrinks towards the shrinks of [gen] with [f] applied to them. *) val (>|=) : 'a t -> ('a -> 'b) -> 'b t (** An infix synonym for {!map}. Note the order of arguments is reversed (usually more convenient for composing). *) val (<$>) : ('a -> 'b) -> 'a t -> 'b t (** An infix synonym for {!map} @since 0.13 *) val map2 : ('a -> 'b -> 'c) -> 'a t -> 'b t -> 'c t (** [map2 f gen1 gen2] transforms two generators [gen1] and [gen2] by applying [f] to each pair of generated elements. Shrinks on [gen1] and then [gen2]. *) val map3 : ('a -> 'b -> 'c -> 'd) -> 'a t -> 'b t -> 'c t -> 'd t (** [map3 f gen1 gen2 gen3] transforms three generators [gen1], [gen2], and [gen3] by applying [f] to each triple of generated elements. Shrinks on [gen1], then [gen2], and then [gen3]. *) val map4 : ('a -> 'b -> 'c -> 'd -> 'e) -> 'a t -> 'b t -> 'c t -> 'd t -> 'e t (** [map4 f gen1 gen2 gen3 gen4] transforms four generators [gen1], [gen2], [gen3], and [gen4] by applying [f] to each quadruple of generated elements. Shrinks on [gen1], then [gen2], [gen3], and then [gen4]. @since 0.25 *) val map5 : ('a -> 'b -> 'c -> 'd -> 'e -> 'f) -> 'a t -> 'b t -> 'c t -> 'd t -> 'e t -> 'f t (** [map5 f gen1 gen2 gen3 gen4 gen5] transforms five generators [gen1], [gen2], [gen3], [gen4], and [gen5] by applying [f] to each quintuple of generated elements. Shrinks on [gen1], then [gen2], [gen3], [gen4], and then [gen5]. @since 0.25 *) val ap : ('a -> 'b) t -> 'a t -> 'b t (** [ap fgen gen] composes a function generator and an argument generator into a result generator. Shrinks on [fgen] and then [gen]. *) val (<*>) : ('a -> 'b) t -> 'a t -> 'b t (** Synonym for {!ap} *) val bind : 'a t -> ('a -> 'b t) -> 'b t (** [bind gen f] first generates a value of type ['a] with [gen] and then passes it to [f] to generate a value of type ['b]. This is typically useful when a generator depends on the value generated by another generator. Shrinks on [gen] and then on the resulting generator. *) val (>>=) : 'a t -> ('a -> 'b t) -> 'b t (** Synonym for {!bind} *) val ( let+ ) : 'a t -> ('a -> 'b) -> 'b t (** {{: https://ocaml.org/manual/bindingops.html} Binding operator} alias for {!map}. Example: {[ let+ n = int_range 0 10 in string_of_int n (* is equivalent to *) map (fun n -> string_of_int n) (int_range 0 10) ]} *) val ( and+ ) : 'a t -> 'b t -> ('a * 'b) t (** {{: https://ocaml.org/manual/bindingops.html} Binding operator} alias for {!pair}. Example: {[ let+ n = int_range 0 10 and+ b = bool in if b then string_of_int n else "Not a number" (* is equivalent to *) map (fun (n, b) -> if b then string_of_int n else "Not a number") (pair (int_range 0 10) bool) ]} *) val ( let* ) : 'a t -> ('a -> 'b t) -> 'b t (** {{: https://ocaml.org/manual/bindingops.html} Binding operator} alias for {!bind}. Example: {[ let* n = int_range 0 9 in if n < 9 then int >|= Result.ok else string_printable >|= Result.error (* is equivalent to *) bind (int_range 0 9) (fun n -> if n < 9 then map Result.ok int else map Result.error string_printable) ]} *) val ( and* ) : 'a t -> 'b t -> ('a * 'b) t (** {{: https://ocaml.org/manual/bindingops.html} Binding operator} alias for {!pair}. Example: {[ let* n = int_range 0 9 and* b = bool in if n < 9 then int >|= Result.ok else if b then pure (Error "Some specific error") else string_printable >|= Result.error (* is equivalent to *) bind (pair (int_range 0 9) bool) (fun (n, b) -> if n < 9 then map Result.ok int else if b then pure (Error "Some specific error") else map Result.error string_printable) ]} *) (** {2 Debug generators} These functions should not be used in tests: they are provided for convenience to debug/investigate what values and shrinks a generator produces. *) val generate : ?rand:Random.State.t -> n:int -> 'a t -> 'a list (** [generate ~n gen] generates [n] values using [gen] (shrinks are discarded). *) val generate1 : ?rand:Random.State.t -> 'a t -> 'a (** [generate1 gen] generates one instance of [gen] (shrinks are discarded). *) val generate_tree : ?rand:Random.State.t -> 'a t -> 'a Tree.t (** [generate_tree ?rand gen] generates a random value and its shrinks using [gen]. *) end (** Printing functions and helpers, used to print generated values on test failures. *) module Print : sig type 'a t = 'a -> string (** Printer for values of type ['a]. *) val unit : unit t (** [unit] is a printer of unit. @since 0.6 *) val int : int t (** [int] is a printer of integers. *) val int32 : int32 t (** [int32] is a printer of 32-bit integers. @since 0.24 *) val int64 : int64 t (** [int64] is a printer of 64-bit integers. @since 0.24 *) val bool : bool t (** [bool] is a printer of boolean. *) val float : float t (** [float] is a printer of float. *) val char : char t (** [char] is a printer of character. *) val bytes : bytes t (** [bytes] is a printer of bytes. @since 0.20 *) val string : string t (** [string] is a printer of string. *) val option : 'a t -> 'a option t (** [option p] is a printer of ['a option], using [p] if it is a [Some]. *) val result : 'a t -> 'e t -> ('a, 'e) result t (** [result okp errp] is a printer of [('a,'e) result], using [okp] for printing [Ok _] and [errp] for printing [Error _]. @since 0.24 *) val pair : 'a t -> 'b t -> ('a*'b) t (** [pair p1 p2] is a printer of pair. *) val triple : 'a t -> 'b t -> 'c t -> ('a*'b*'c) t (** [triple p1 p2 p3] is a printer of triple. *) val quad : 'a t -> 'b t -> 'c t -> 'd t -> ('a*'b*'c*'d) t (** [quad p1 p2 p3 p4] is a printer of quadruple. *) val list : 'a t -> 'a list t (** [list p] is a printer of list, using [p] for each element. *) val array : 'a t -> 'a array t (** [array p] is a printer of array, using [p] for each element. *) val contramap : ('b -> 'a) -> 'a t -> 'b t (** [contramap f p] transforms printer [p] into another using [f]. Note the reverse order of types in [f] which may be conter-intuitive: indeed a function that {i prints} values of type ['b] can be obtained by transforming a value of type ['b] to ['a] using [f], and then by {i printing} this value of type ['a] using [p]. *) val comap : ('b -> 'a) -> 'a t -> 'b t (** @deprecated use {!contramap} instead. *) val tup2 : 'a t -> 'b t -> ('a * 'b) t (** 2-tuple printer. Expects printers for each component. *) val tup3 : 'a t -> 'b t -> 'c t -> ('a * 'b * 'c) t (** 3-tuple printer. Expects printers for each component. *) val tup4 : 'a t -> 'b t -> 'c t -> 'd t -> ('a * 'b * 'c * 'd) t (** 4-tuple printer. Expects printers for each component. *) val tup5 : 'a t -> 'b t -> 'c t -> 'd t -> 'e t -> ('a * 'b * 'c * 'd * 'e) t (** 5-tuple printer. Expects printers for each component. *) val tup6 : 'a t -> 'b t -> 'c t -> 'd t -> 'e t -> 'f t -> ('a * 'b * 'c * 'd * 'e * 'f) t (** 6-tuple printer. Expects printers for each component. *) val tup7 : 'a t -> 'b t -> 'c t -> 'd t -> 'e t -> 'f t -> 'g t -> ('a * 'b * 'c * 'd * 'e * 'f * 'g) t (** 7-tuple printer. Expects printers for each component. *) 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 (** 8-tuple printer. Expects printers for each component. *) 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 (** 9-tuple printer. Expects printers for each component. *) end (** Shrinking helper functions. *) module Shrink : sig (** Shrinking is used to reduce the size of a counter-example. It tries to make the counter-example smaller by decreasing it, or removing elements, until the property to test holds again; then it returns the smallest value that still made the test fail. This is meant to help developers find a simpler counter-example to ease investigation and find more easily the root cause (be it in the tested code or in the test). This module exposes helper functions that one can reuse in combination with {!Gen.make_primitive} to craft custom primitive generators (not by composing other generators). The vast majority of use cases will probably not need this module. *) (** Util module representing a number type, used for ad hoc polymorphism of some functions like {!number_towards}. *) module type Number = sig type t val equal : t -> t -> bool val div : t -> t -> t val add : t -> t -> t val sub : t -> t -> t val of_int : int -> t end val number_towards : (module Number with type t = 'a) -> destination : 'a -> 'a -> 'a Seq.t (** Shrink a number by edging towards a destination. The destination is always the first value for optimal shrinking. {[ let int64_towards_list destination x = List.of_seq @@ Gen.number_towards (module Int64) ~destination x in assert (int64_towards_list 0L 100L = [0L; 50L; 75L; 88L; 94L; 97L; 99L]); assert (int64_towards_list 500L 1000L = [500L; 750L; 875L; 938L; 969L; 985L; 993L; 997L; 999L]); assert (int64_towards_list (-50L) (-26L) = [-50L; -38L; -32L; -29L; -28L; -27L]) ]} This generic function is exposed to let users reuse this shrinking technique for their custom number types. More specialized, convenient functions are provided below, e.g. {!int_towards}. *) val int_towards : int -> int -> int Seq.t (** {!number_towards} specialized to [int]. *) val int32_towards : int32 -> int32 -> int32 Seq.t (** {!number_towards} specialized to [int32]. *) val int64_towards : int64 -> int64 -> int64 Seq.t (** {!number_towards} specialized to [int64]. *) val float_towards : float -> float -> float Seq.t (** {!number_towards} specialized to [float]. There are various ways to shrink a float: - try removing floating digits, i.e. towards integer values - try to get as close as possible to the destination, no matter the number of digits - a mix of both This implementation, as it relies on the generic {!number_towards} function, tries to get as close as possible to the destination, e.g. the last value of [Gen.float_towards 50 100] may be [99.9969482421875] (or a similar value). *) val int_aggressive_towards : int -> int -> int Seq.t (** [int_agressive_towards destination n] gives all integers from [destination] to [n] (excluded). {b Be careful about time and memory} as the resulting list can be huge *) val int_aggressive : int -> int Seq.t (** @deprecated Use [int_aggressive_towards 0] instead. @since 0.7 *) end (** {1 Generating Functions} The [QCheck2] module supports generation of pure function values. The implementation is inspired from {:https://blogs.janestreet.com/quickcheck-for-core/} and {{:https://dl.acm.org/doi/abs/10.1145/2364506.2364516}Koen Claessen's "Shrinking and Showing Functions"}. Generated function arguments are of type {!Observable.t} and function results are of type {!Gen.t}. Underneath the hood, generated function values have a table-based representation. They therefore need to be applied in a special way, e.g., with {!Fn.apply}. *) (** An observable is a random function {i argument}. *) module Observable : sig (** While random functions don't need to generate {i values} of their arguments, they need the abilities to: - compare, using [equal] and [hash], so that the same argument always returns the same generated value - [print], in order to print the function implementation (bindings) in case of test failure Inspired by: - Jane Street {{: https://blogs.janestreet.com/quickcheck-for-core/} Quickcheck for Core} blog post - Koen Claessen's {{: https://www.youtube.com/watch?v=CH8UQJiv9Q4} Shrinking and Showing functions} paper @since 0.6 *) type -'a t (** An observable of ['a], packing a printer and other things. *) val make : ?eq:('a -> 'a -> bool) -> ?hash:('a -> int) -> 'a Print.t -> 'a t (** [make ?eq ?hash print] creates an observable of ['a]. If [eq] is [None], uses the standard polymorphic [(=)] function. If [hash] is [None], uses a default hashing function. *) val equal : 'a t -> 'a -> 'a -> bool (** [equal o] returns the equality function of [o]. *) val hash : 'a t -> 'a -> int (** [hash o] returns the hashing function of [o]. *) val print : 'a t -> 'a Print.t (** [print o] returns the printing function of [o]. *) val unit : unit t (** [unit] is an observable of [unit]. *) val bool : bool t (** [bool] is an observable of [bool]. *) val int : int t (** [int] is an observable of [int]. *) val int32 : int32 t (** [int32] is an observable of [int32]. @since 0.24 *) val int64 : int64 t (** [int64] is an observable of [int64]. @since 0.24 *) val float : float t (** [float] is an observable of [float]. *) val bytes : bytes t (** [bytes] is an observable of [bytes]. @since 0.20 *) val string : string t (** [string] is an observable of [string]. *) val char : char t (** [char] is an observable of [char]. *) val contramap : ('b -> 'a) -> 'a t -> 'b t (** [contramap f o] maps the function [f] on observable [o]. Note the reverse order of types in [f] which may be conter-intuitive: indeed a function that {i consumes} values of type ['b] can be obtained by transforming a value of type ['b] to ['a] using [f], and then by {i consuming} this value of type ['a] using [o]. *) val map : ('b -> 'a) -> 'a t -> 'b t (** @deprecated use {!contramap} instead. *) val option : 'a t -> 'a option t (** [option o] wraps the observable [o] of ['a] into an observable of ['a option]. *) val result : 'a t -> 'e t -> ('a, 'e) result t (** [result ok_o err_o] creates an [('a, 'e) result] observable out of two observables [ok_o] and [err_o]. @since 0.24 *) val list : 'a t -> 'a list t (** [list o] wraps the observable [o] of ['a] into an observable of ['a list]. *) val array : 'a t -> 'a array t (** [array o] wraps the observable [o] of ['a] into an observable of ['a array]. *) val pair : 'a t -> 'b t -> ('a * 'b) t (** [pair o1 o2] is an observable of pairs of [('a * 'b)]. *) val triple : 'a t -> 'b t -> 'c t -> ('a * 'b * 'c) t (** [triple o1 o2 o3] is an observable of triples of [('a * 'b * 'c)]. *) val quad : 'a t -> 'b t -> 'c t -> 'd t -> ('a * 'b * 'c * 'd) t (** [quad o1 o2 o3 o4] is an observable of quadruples of [('a * 'b * 'c * 'd)]. *) end (** Utils on combining function arguments. *) module Tuple : sig (** Heterogeneous tuple, used to pass any number of arguments to a function. *) type 'a t = | Nil : unit t | Cons : 'a * 'b t -> ('a * 'b) t val nil : unit t (** [nil] is {!Nil}. *) val cons : 'a -> 'b t -> ('a * 'b) t (** [cons] is {!Cons}. *) type 'a obs (** How to observe a {!t}. See {!module:Observable} for more information on what "observe" means in the QCheck. *) val o_nil : unit obs (** [o_nil] is the {!obs} equivalent of {!nil}. *) val o_cons : 'a Observable.t -> 'b obs -> ('a * 'b) obs (** [o_cons] is the {!obs} equivalent of {!cons}. *) val observable : 'a obs -> 'a t Observable.t (** [observable obs] returns the underlying observable of [obs]. *) (** Infix {!module:Tuple} operators for convenience. *) module Infix : sig val (@::) : 'a -> 'b t -> ('a * 'b) t (** Alias for {!cons}. *) val (@->) : 'a Observable.t -> 'b obs -> ('a * 'b) obs (** Alias for {!o_cons}. *) end include module type of Infix end type 'f fun_repr (** Used by QCheck to shrink and print generated functions of type ['f] in case of test failure. You cannot and should not use it yourself. See {!fun_} for more information. *) (** A function packed with the data required to print/shrink it. The idiomatic way to use any [fun_] Gen.t is to directly pattern match on it to obtain the executable function. For example (note the [Fun (_, f)] part): {[ QCheck2.(Test.make Gen.(pair (fun1 Observable.int bool) (small_list int)) (fun (Fun (_, f), l) -> l = (List.rev_map f l |> List.rev l)) ]} In this example [f] is a generated function of type [int -> bool]. The ignored part [_] of [Fun (_, f)] is useless to you, but is used by QCheck during shrinking/printing in case of test failure. See also {!Fn} for utils to print and apply such a function. *) type 'f fun_ = Fun of 'f fun_repr * 'f val fun1 : 'a Observable.t -> ?print:('b Print.t) -> 'b Gen.t -> ('a -> 'b) fun_ Gen.t (** [fun1 obs gen] generates random functions that take an argument observable via [obs] and map to random values generated with [gen]. To write functions with multiple arguments, it's better to use {!Tuple} or {!Observable.pair} rather than applying {!fun_} several times (shrinking will be faster). @since 0.6 *) val fun2 : 'a Observable.t -> 'b Observable.t -> ?print:'c Print.t -> 'c Gen.t -> ('a -> 'b -> 'c) fun_ Gen.t (** Specialized version of {!fun_nary} for functions of 2 arguments, for convenience. @since 0.6 *) val fun3 : 'a Observable.t -> 'b Observable.t -> 'c Observable.t -> ?print:'d Print.t -> 'd Gen.t -> ('a -> 'b -> 'c -> 'd) fun_ Gen.t (** Specialized version of {!fun_nary} for functions of 3 arguments, for convenience. @since 0.6 *) val fun4 : 'a Observable.t -> 'b Observable.t -> 'c Observable.t -> 'd Observable.t -> ?print:'e Print.t -> 'e Gen.t -> ('a -> 'b -> 'c -> 'd -> 'e) fun_ Gen.t (** Specialized version of {!fun_nary} for functions of 4 arguments, for convenience. @since 0.6 *) val fun_nary : 'a Tuple.obs -> ?print:('b Print.t) -> 'b Gen.t -> ('a Tuple.t -> 'b) fun_ Gen.t (** [fun_nary tuple_obs gen] generates random n-ary functions. Arguments are observed using [tuple_obs] and return values are generated using [gen]. Example (the property is wrong as a random function may return [false], this is for the sake of demonstrating the syntax): {[ let module O = Observable in Test.make (fun_nary Tuple.(O.int @-> O.float @-> O.string @-> o_nil) bool) (fun (Fun (_, f)) -> f Tuple.(42 @:: 17.98 @:: "foobar" @:: nil)) ]} Note that this particular example can be simplified using {!fun3} directly: {[ let module O = Observable in Test.make (fun3 O.int O.float O.string bool) (fun (Fun (_, f)) -> f 42 17.98 "foobar") ]} @since 0.6 *) module Fn : sig (** A utility module of helpers for printing, shrinking, and applying generated function values. @since 0.6 *) val print : 'f fun_ Print.t (** [print f] prints the implementation of generated function [f]. The implementation always contains a default case, represented as [_]. Note that printing a function {i before} it was called in the test may not print the full implementation. *) val apply : 'f fun_ -> 'f (** [apply f] returns the underlying function to be used in tests. This is an alias for deconstructing as documented in {!fun_}. *) end (** {1 Assumptions} *) val assume : bool -> unit (** [assume cond] checks the precondition [cond], and does nothing if [cond=true]. If [cond=false], it interrupts the current test (but the test will not be failed). ⚠️ This function must only be used in a test, not outside. Example: {[ Test.make (list int) (fun l -> assume (l <> []); List.hd l :: List.tl l = l) ]} @since 0.5.1 *) val (==>) : bool -> bool -> bool (** [b1 ==> b2] is the logical implication [b1 => b2] ie [not b1 || b2] (except that it is strict and will interact better with {!Test.check_exn} and the likes, because they will know the precondition was not satisfied.). ⚠️ This function should only be used in a property (see {!Test.make}), because it raises a special exception in case of failure of the first argument, to distinguish between failed test and failed precondition. Because of OCaml's evaluation order, both [b1] and [b2] are always evaluated; if [b2] should only be evaluated when [b1] holds, see {!assume}. *) val assume_fail : unit -> 'a (** [assume_fail ()] is like [assume false], but can take any type since we know it always fails (like [assert false]). This is useful to ignore some branches in [if] or [match]. Example: {[ Test.make (list int) (function | [] -> assume_fail () | _::_ as l -> List.hd l :: List.tl l = l) ]} @since 0.5.1 *) (** {1 Tests} A test is a universal property of type [foo -> bool] for some type [foo], with an object of type [foo Gen.t] used to generate values of type [foo]. See {!Test.make} to build a test, and {!Test.check_exn} to run one test simply. For more serious testing, it is better to create a testsuite and use {!QCheck_runner}. *) type 'a stat = string * ('a -> int) (** A statistic on a distribution of values of type ['a]. The function {b MUST} return a positive integer. *) (** Result of running a test *) module TestResult : sig type 'a counter_ex = { instance: 'a; (** The counter-example *) shrink_steps: int; (** How many shrinking steps for this counter-example *) msg_l: string list; (** Messages of the test. Currently only populated by {!Test.fail_report} and {!Test.fail_reportf}. @since 0.7 *) } (** A counter-example when a test fails. *) (** Result state. changed in 0.10 (move to inline records, add Fail_other) *) type 'a state = | Success (** If the test passed. *) | Failed of { instances: 'a counter_ex list; (** Failed instance(s) *) } (** If the test failed "normally", i.e. a test returned [false]. *) | Failed_other of {msg: string} (** If the test failed for an unusual reason: - an exception was raised by a generator - too many assumptions failed and [Test.if_assumptions_fail] was set to [`Fatal] *) | Error of { instance: 'a counter_ex; (** Instance that triggered the exception in the test *) exn: exn; (** The raised exception *) backtrace: string; (** A best-effort backtrace of the exception *) } (** If the test failed "exceptionally" (an exception was raised by the test). *) (* Result returned by running a test. *) type 'a t val get_state : 'a t -> 'a state (** [get_state t] returns the final state after a test execution. *) val get_count : _ t -> int (** [get_count t] returns the number of tests executed. *) val get_count_gen : _ t -> int (** [get_count_gen t] returns the number of generated cases. *) val get_collect : _ t -> (string,int) Hashtbl.t option (** [get_collect t] returns the repartition of generated values. @since 0.18 *) val get_stats : 'a t -> ('a stat * (int,int) Hashtbl.t) list (** [get_stats t] returns the statistics captured by the test. @since 0.18 *) val get_warnings : _ t -> string list (** [get_warnings t] returns the list of warnings emitted during the test. @since 0.18 *) val is_success : _ t -> bool (** Returns true iff the state is [Success] @since 0.9 *) val is_failed : _ t -> bool (** Returns true iff the state is [Failed _] *) val stats : 'a t -> ('a stat * (int,int) Hashtbl.t) list (** Obtain statistics @since 0.6 @deprecated use {!get_stats} instead *) val warnings : _ t -> string list (** Obtain list of warnings @since 0.10 @deprecated use {!get_warnings} instead *) val collect : _ t -> (string,int) Hashtbl.t option (** Obtain statistics @since 0.6 @deprecated use {!get_collect} instead *) end module Test_exceptions : sig exception Test_fail of string * string list (** Exception raised when a test failed, with the list of counter-examples. [Test_fail (name, l)] means test [name] failed on elements of [l]. *) exception Test_error of string * string * exn * string (** Exception raised when a test raised an exception [e], with the sample that triggered the exception. [Test_error (name, i, e, st)] means [name] failed on [i] with exception [e], and [st] is the stacktrace (if enabled) or an empty string. *) exception Test_unexpected_success of string (** Exception raised when a negative test failed. [Test_unexpected_success name] means test [name] failed to find an expected counter example. *) end (** A test is a pair of a generator and a property that all generated values must satisfy. *) module Test : sig (** The main features of this module are: - {!make} to create a test - {!make_neg} to create a negative test that is expected not to satisfy the tested property - {!check_exn} to run a single test with a simple runner. 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. 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 QCheck tests to your favorite test framework: - {!QCheck_base_runner} for a QCheck-only runner (useful if you don't have or don't need another test framework) - {!QCheck_alcotest} to convert to Alcotest framework - {!QCheck_ounit} to convert to OUnit framework *) type 'a cell (** A single property test on a value of type ['a]. A {!Test.t} wraps a [cell] and hides its type parameter. *) val make_cell : ?if_assumptions_fail:([`Fatal | `Warning] * float) -> ?count:int -> ?long_factor:int -> ?negative:bool -> ?max_gen:int -> ?max_fail:int -> ?retries:int -> ?name:string -> ?print:'a Print.t -> ?collect:('a -> string) -> ?stats:('a stat list) -> 'a Gen.t -> ('a -> bool) -> 'a cell (** [make_cell gen prop] builds a test that checks property [prop] on instances of the generator [gen]. @param name the name of the test. @param count number of test cases to run, counting only the test cases which satisfy preconditions. @param long_factor the factor by which to multiply count, max_gen and max_fail when running a long test (default: 1). @param negative whether the test is expected not to satisfy the tested property. @param max_gen maximum number of times the generation function is called in total to replace inputs that do not satisfy preconditions (should be >= count). @param max_fail maximum number of failures before we stop generating inputs. This is useful if shrinking takes too much time. @param retries number of times to retry the tested property while shrinking. @param if_assumptions_fail the minimum fraction of tests that must satisfy the precondition for a success to be considered valid. The fraction should be between 0. and 1. A warning will be emitted otherwise if the flag is [`Warning], the test will be a failure if the flag is [`Fatal]. (since 0.10) @param print used in {!Print} to display generated values failing the [prop] @param collect (* collect values by tag, useful to display distribution of generated *) @param stats on a distribution of values of type 'a *) val make_cell_from_QCheck1 : ?if_assumptions_fail:([`Fatal | `Warning] * float) -> ?count:int -> ?long_factor:int -> ?negative:bool -> ?max_gen:int -> ?max_fail:int -> ?retries:int -> ?name:string -> gen:(Random.State.t -> 'a) -> ?shrink:('a -> ('a -> unit) -> unit) -> ?print:('a -> string) -> ?collect:('a -> string) -> stats:'a stat list -> ('a -> bool) -> 'a cell (** ⚠️ Do not use, this is exposed for internal reasons only. ⚠️ @deprecated Migrate to QCheck2 and use {!make_cell} instead. *) val get_law : 'a cell -> ('a -> bool) val get_name : _ cell -> string val get_gen : 'a cell -> 'a Gen.t val get_print_opt : 'a cell -> ('a Print.t) option val get_collect_opt : 'a cell -> ('a -> string) option val get_stats : 'a cell -> ('a stat list) val set_name : _ cell -> string -> unit val get_count : _ cell -> int (** Get the count of a cell. @since 0.5.3 *) val get_long_factor : _ cell -> int (** Get the long factor of a cell. @since 0.5.3 *) val get_positive : _ cell -> bool (** Get the expected mode of a cell: positive indicates expected to satisfy the tested property, negative indicates expected not to satisfy the tested property. *) type t = Test : 'a cell -> t (** Same as ['a cell], but masking the type parameter. This allows to put tests on different types in the same list of tests. *) val make : ?if_assumptions_fail:([`Fatal | `Warning] * float) -> ?count:int -> ?long_factor:int -> ?max_gen:int -> ?max_fail:int -> ?retries:int -> ?name:string -> ?print:('a Print.t) -> ?collect:('a -> string) -> ?stats:('a stat list) -> 'a Gen.t -> ('a -> bool) -> t (** [make gen prop] builds a test that checks property [prop] on instances of the generator [gen]. See {!make_cell} for a description of the parameters. *) val make_neg : ?if_assumptions_fail:([`Fatal | `Warning] * float) -> ?count:int -> ?long_factor:int -> ?max_gen:int -> ?max_fail:int -> ?retries:int -> ?name:string -> ?print:('a Print.t) -> ?collect:('a -> string) -> ?stats:('a stat list) -> 'a Gen.t -> ('a -> bool) -> t (** [make_neg gen prop] builds a test that checks property [prop] on instances of the generator [gen]. The test is considered negative, meaning that it is expected not to satisfy the tested property. This information is recorded in an underlying test [cell] entry and interpreted suitably by test runners. See {!make_cell} for a description of the parameters. *) val test_get_count : t -> int val test_get_long_factor : t -> int val fail_report : string -> 'a (** Fail the test with some additional message that will be reported. @since 0.7 *) val fail_reportf : ('a, Format.formatter, unit, 'b) format4 -> 'a (** Format version of {!fail_report}. Example: {[ Test.fail_reportf "Value N = %i should be greater than M = %i for Foo = %a" n m pp_foo foo ]} @since 0.7 *) (** {3 Running the test} *) include module type of Test_exceptions val print_instance : 'a cell -> 'a -> string val print_c_ex : 'a cell -> 'a TestResult.counter_ex -> string val print_fail : 'a cell -> string -> 'a TestResult.counter_ex list -> string val print_fail_other : string -> msg:string -> string val print_expected_failure : 'a cell -> 'a TestResult.counter_ex list -> string val print_error : ?st:string -> 'a cell -> string -> 'a TestResult.counter_ex * exn -> string val print_test_fail : string -> string list -> string val print_test_error : string -> string -> exn -> string -> string val print_collect : (string,int) Hashtbl.t -> string (** Print "collect" results. @since 0.6 *) val print_stat : ('a stat * (int,int) Hashtbl.t) -> string (** Print statistics. @since 0.6 *) val check_result : 'a cell -> 'a TestResult.t -> unit (** For a positive test [check_result cell res] checks that [res] is [Ok _], and returns unit. For a negative test [check_result cell res] checks that [res] is [Failed _], and returns unit. Otherwise, it raises some exception. @raise Test_fail if the test is positive and [res = Failed _] @raise Test_unexpected_success if the test is negative and [res = Ok _] @raise Test_error if [res = Error _] *) type res = | Success | Failure | FalseAssumption | Error of exn * string type 'a event = | Generating | Collecting of 'a | Testing of 'a | Shrunk of int * 'a | Shrinking of int * int * 'a type 'a handler = string -> 'a cell -> 'a event -> unit (** Handler executed after each event during testing of an instance. *) type 'a step = string -> 'a cell -> 'a -> res -> unit (** Callback executed after each instance of a test has been run. The callback is given the instance tested, and the current results of the test. *) type 'a callback = string -> 'a cell -> 'a TestResult.t -> unit (** Callback executed after each test has been run. [f name cell res] means test [cell], named [name], gave [res]. *) val check_cell : ?long:bool -> ?call:'a callback -> ?step:'a step -> ?handler:'a handler -> ?rand:Random.State.t -> 'a cell -> 'a TestResult.t (** [check_cell ~long ~rand test] generates up to [count] random values of type ['a] using [Gen.t] and the random state [st]. The predicate [law] is called on them and if it returns [false] or raises an exception then we have a counter-example for the [law]. Note: [check_cell] ignores a test's polarity, acting as described above regardless of whether the tested cell is a positive or negative test. @param long if [true] then multiply the number of instances to generate by the cell's long_factor. @param call function called on each test case, with the result. @param step function called on each instance of the test case, with the result. @return the result of the test. *) val check_cell_exn : ?long:bool -> ?call:'a callback -> ?step:'a step -> ?handler:'a handler -> ?rand:Random.State.t -> 'a cell -> unit (** Same as {!check_cell} but calls {!check_result} on the result. [check_cell test] honors test polarity and thus expects positive tests to succeed without finding a counterexample and expects negative tests to fail by finding one. @raise Test_fail if the test is positive and [res = Failed _] @raise Test_unexpected_success if the test is negative and [res = Success _] @raise Test_error if [res = Error _] *) val check_exn : ?long:bool -> ?rand:Random.State.t -> t -> unit (** Checks the property against some test cases, and calls {!check_result}, which might raise an exception in case of failure. [check_exn test] honors test polarity and thus expects positive tests to succeed without finding a counterexample and expects negative tests to fail by finding one. @raise Test_fail if the test is positive and [res = Failed _] @raise Test_unexpected_success if the test is negative and [res = Success _] @raise Test_error if [res = Error _] *) end (** {2 Sub-tests} *) (** The infrastructure used to find counter-examples to properties can also be used to find data satisfying a predicate, {i within a property being tested}. See https://github.com/c-cube/qcheck/issues/31 *) exception No_example_found of string (** Raised by {!find_example} and {!find_example_gen} if no example was found. *) val find_example : ?name:string -> ?count:int -> f:('a -> bool) -> 'a Gen.t -> 'a Gen.t (** [find_example ~f gen] uses [gen] to generate some values of type ['a], and checks them against [f]. If such a value is found, it is returned. Otherwise an exception is raised. ⚠️ This should only be used from within a property in {!Test.make}. @param name Description of the example to find (used in test results/errors). @param count Number of attempts. @param f The property that the generated values must satisfy. @raise No_example_found If no example is found within [count] tries. @since 0.6 *) val find_example_gen : ?rand:Random.State.t -> ?name:string -> ?count:int -> f:('a -> bool) -> 'a Gen.t -> 'a (** Toplevel version of {!find_example}. [find_example_gen ~f gen] is roughly the same as [Gen.generate1 @@ find_example ~f gen]. @param rand the random state to use to generate inputs. @raise No_example_found if no example was found within [count] tries. @since 0.6 *) (** {1:migration_qcheck2 Migration to QCheck2} QCheck2 is a major release and as such, there are (as few as possible) breaking changes, as well as functional changes you should be aware of. The QCheck2 shrinkers haven't been battle tested as much as the QCheck ones, and furthermore implement different reduction algorithms. Please report if you encounter any issues porting tests from QCheck to QCheck2. {2 Minimal changes} Most of your QCheck (v1) code should be able to compile and run the first time you upgrade your QCheck version to a QCheck2-compatible version. However you may need to do the following minimal changes: - {!QCheck.Test.make} return type was changed to {!QCheck2.Test.t} to be able to run both QCheck and QCheck2 tests together. This is transparent if you used type inference, but if you explicitly used {!QCheck.Test.t} you will need to change it to {!QCheck2.Test.t}. {2 Recommended changes} Now you want to actually start using the QCheck2 features (most importantly: free shrinking!). To get started, change all your {!QCheck} references to {!QCheck2} and follow the compiler errors. Below are the most common situations you may encounter: - as shrinking is now integrated, several function arguments like [~shrink] or [~rev] have been removed: you can remove such reverse functions, they will no longer be necessary. - accessor functions like {!val:QCheck.gen} have been renamed to consistent names like {!Test.get_gen}. - {!QCheck.map_keep_input} has been removed: you can use {!Gen.map} directly. - {!Gen.t} is no longer public, it is now abstract: it is recommended to use {{!section:Gen.composing_generators} generator composition} to make generators. {!Gen.make_primitive} was added to create generators with finer control (in particular of shrinking). *) qcheck-0.25/src/core/dune000066400000000000000000000002441477416744200153130ustar00rootroot00000000000000 (library (name qcheck_core) (public_name qcheck-core) (wrapped false) (libraries unix) (flags :standard -w +a-4-42-44-48-50-58-32-60@8 -safe-string) ) qcheck-0.25/src/dune000066400000000000000000000003071477416744200143630ustar00rootroot00000000000000(library (name qcheck) (public_name qcheck) (wrapped false) (modules QCheck_runner) (synopsis "compatibility library for qcheck") (libraries qcheck-core qcheck-core.runner qcheck-ounit)) qcheck-0.25/src/ounit/000077500000000000000000000000001477416744200146435ustar00rootroot00000000000000qcheck-0.25/src/ounit/QCheck_ounit.ml000066400000000000000000000162001477416744200175500ustar00rootroot00000000000000 open OUnit open QCheck_base_runner let ps = Printf.printf "%s" let va = Printf.sprintf let pf = Printf.printf let not_success = function RSuccess _ -> false | _ -> true let result_path = function | RSuccess path | RError (path, _) | RFailure (path, _) | RSkip (path, _) | RTodo (path, _) -> path let result_msg = function | RSuccess _ -> "Success" | RError (_, msg) | RFailure (_, msg) | RSkip (_, msg) | RTodo (_, msg) -> msg let result_flavour = function | RError _ -> `Red, "Error" | RFailure _ -> `Red, "Failure" | RSuccess _ -> `Green, "Success" | RSkip _ -> `Blue, "Skip" | RTodo _ -> `Yellow, "Todo" let string_of_path path = let path = List.filter (function Label _ -> true | _ -> false) path in String.concat ">" (List.rev_map string_of_node path) let separator1 = "\027[K" ^ (String.make 79 '\\') let separator2 = String.make 79 '/' let print_result_list ~colors = List.iter (fun result -> let c, res = result_flavour result in pf "%s\n%a: %s\n\n%s\n%s\n" separator1 (Color.pp_str_c ~colors c) res (string_of_path (result_path result)) (result_msg result) separator2) let conf_seed = OUnit2.Conf.make_int "seed" ~-1 "set random seed" let conf_verbose = OUnit2.Conf.make_bool "qcheck_verbose" true "enable verbose QCheck tests" let conf_long = OUnit2.Conf.make_bool "qcheck_long" false "enable long QCheck tests" let default_rand () = (* random seed, for repeatability of tests *) Random.State.make [| 89809344; 994326685; 290180182 |] let to_ounit2_test ?(rand =default_rand()) (QCheck2.Test.Test cell) = let module T = QCheck2.Test in let name = T.get_name cell in let open OUnit2 in name >: test_case ~length:OUnitTest.Long (fun ctxt -> let rand = match conf_seed ctxt with | -1 -> Random.State.copy rand | s -> (* user provided random seed *) Random.State.make [| s |] in let verbose = conf_verbose ctxt in let long = conf_long ctxt in let print = { Raw. info = (fun fmt -> logf ctxt `Info fmt); fail = (fun fmt -> Printf.ksprintf assert_failure fmt); err = (fun fmt -> logf ctxt `Error fmt); } in T.check_cell_exn cell ~long ~rand ~call:(Raw.callback ~colors:false ~verbose ~print_res:true ~print)) let to_ounit2_test_list ?rand lst = List.rev (List.rev_map (to_ounit2_test ?rand) lst) (* to convert a test to a [OUnit.test], we register a callback that will possibly print errors and counter-examples *) let to_ounit_test_cell ?(verbose=verbose()) ?(long=long_tests()) ?(rand=random_state()) cell = let module T = QCheck2.Test in let name = T.get_name cell in let run () = try T.check_cell_exn cell ~long ~rand ~call:(Raw.callback ~colors:false ~verbose ~print_res:verbose ~print:Raw.print_std); true with T.Test_fail _ -> false in name >:: (fun () -> assert_bool name (run ())) let to_ounit_test ?verbose ?long ?rand (QCheck2.Test.Test c) = to_ounit_test_cell ?verbose ?long ?rand c let (>:::) name l = name >::: (List.map (fun t -> to_ounit_test t) l) (* Function which runs the given function and returns the running time of the function, and the original result in a tuple *) let time_fun f x y = let begin_time = Unix.gettimeofday () in let res = f x y in (* evaluate this first *) Unix.gettimeofday () -. begin_time, res let run ?(argv=Sys.argv) test = let cli_args = Raw.parse_cli ~full_options:true argv in let colors = cli_args.Raw.cli_colors in (* print in colors *) let pp_color = Color.pp_str_c ~bold:true ~colors in let _counter = ref (0,0,0) in (* Success, Failure, Other *) let total_tests = test_case_count test in (* list of (test, execution time) *) let exec_times = ref [] in let update = function | RSuccess _ -> let (s,f,o) = !_counter in _counter := (succ s,f,o) | RFailure _ -> let (s,f,o) = !_counter in _counter := (s,succ f,o) | _ -> let (s,f,o) = !_counter in _counter := (s,f, succ o) in (* time each test *) let start = ref 0. and stop = ref 0. in (* display test as it starts and ends *) let display_test ?(ended=false) p = let (s,f,o) = !_counter in let cartouche = va " [%d%s%s / %d] " s (if f=0 then "" else va "+%d" f) (if o=0 then "" else va " %d!" o) total_tests and path = string_of_path p in let end_marker = if cli_args.Raw.cli_print_list then ( (* print a single line *) if ended then va " (after %.2fs)\n" (!stop -. !start) else "\n" ) else ( ps Color.reset_line; if ended then " *" else "" ) in let line = cartouche ^ path ^ end_marker in let remaining = 79 - String.length line in let cover = if remaining > 0 && not cli_args.Raw.cli_print_list then String.make remaining ' ' else "" in pf "%s%s%!" line cover; in let hdl_event = function | EStart p -> start := Unix.gettimeofday(); display_test p | EEnd p -> stop := Unix.gettimeofday(); display_test p ~ended:true; let exec_time = !stop -. !start in exec_times := (p, exec_time) :: !exec_times | EResult result -> update result in ps "Running tests..."; let running_time, results = time_fun perform_test hdl_event test in let (_s, f, o) = !_counter in let failures = List.filter not_success results in (* assert (List.length failures = f);*) ps Color.reset_line; print_result_list ~colors failures; assert (List.length results = total_tests); pf "Ran: %d tests in: %.2f seconds.%s\n" total_tests running_time (String.make 40 ' '); (* XXX: suboptimal, but should work fine *) if cli_args.Raw.cli_slow_test > 0 then ( pf "Display the %d slowest tests:\n" cli_args.Raw.cli_slow_test; let l = !exec_times in let l = List.sort (fun (_,t1)(_,t2) -> compare t2 t1) l in List.iteri (fun i (p,t) -> if i 0 then ( pf "%a SOME TESTS ARE NEITHER SUCCESSES NOR FAILURES!\n" (pp_color `Yellow) "WARNING!"; ); if failures <> [] then ( pf "%a\n" (pp_color `Red) "FAILURE"; ); (* create a meaningful return code for the process running the tests *) match f, o with | 0, 0 -> 0 | _ -> 1 (* TAP-compatible test runner, in case we want to use a test harness *) let run_tap test = let test_number = ref 0 in let handle_event = function | EStart _ | EEnd _ -> incr test_number | EResult (RSuccess p) -> pf "ok %d - %s\n%!" !test_number (string_of_path p) | EResult (RFailure (p,m)) -> pf "not ok %d - %s # %s\n%!" !test_number (string_of_path p) m | EResult (RError (p,m)) -> pf "not ok %d - %s # ERROR:%s\n%!" !test_number (string_of_path p) m | EResult (RSkip (p,m)) -> pf "not ok %d - %s # skip %s\n%!" !test_number (string_of_path p) m | EResult (RTodo (p,m)) -> pf "not ok %d - %s # todo %s\n%!" !test_number (string_of_path p) m in let total_tests = test_case_count test in pf "TAP version 13\n1..%d\n" total_tests; perform_test handle_event test qcheck-0.25/src/ounit/QCheck_ounit.mli000066400000000000000000000060571477416744200177320ustar00rootroot00000000000000 (** {1 Conversion of tests to OUnit Tests} @since 0.9 *) val to_ounit_test : ?verbose:bool -> ?long:bool -> ?rand:Random.State.t -> QCheck2.Test.t -> OUnit.test (** [to_ounit_test ~rand t] wraps [t] into a OUnit test @param verbose used to print information on stdout (default: [verbose()]) @param rand the random generator to use (default: [random_state ()]) *) val to_ounit_test_cell : ?verbose:bool -> ?long:bool -> ?rand:Random.State.t -> _ QCheck2.Test.cell -> OUnit.test (** Same as {!to_ounit_test} but with a polymorphic test cell *) val (>:::) : string -> QCheck2.Test.t list -> OUnit.test (** Same as [OUnit.(>:::)] but with a list of QCheck2 tests *) val to_ounit2_test : ?rand:Random.State.t -> QCheck2.Test.t -> OUnit2.test (** [to_ounit2_test ?rand t] wraps [t] into a OUnit2 test @param rand the random generator to use (default: a static seed for reproducibility), can be overridden with "-seed" on the command-line *) val to_ounit2_test_list : ?rand:Random.State.t -> QCheck2.Test.t list -> OUnit2.test list (** [to_ounit2_test_list ?rand t] like [to_ounit2_test] but for a list of tests *) (** {2 OUnit runners} QCheck provides some custom runners for OUnit tests. - {!run} is used by {{: https://github.com/vincent-hugot/qtest} qtest}. - {!run_tap} should be compatible with {{: https://en.wikipedia.org/wiki/Test_Anything_Protocol} TAP}. Note that {!OUnit.run_test_tt} or {!OUnit.run_test_tt_main} can be used as well, in particular when QCheck tests are mixed with normal unit tests. For OUnit2 you can use {!OUnit2.run_test_tt_main}. *) val run : ?argv:string array -> OUnit.test -> int (** [run test] runs the test, and returns an error code that is [0] if all tests passed, [1] otherwise. This is the default runner used by the comment-to-test generator. @param argv the command line arguments to parse parameters from (default [Sys.argv]) @raise Arg.Bad in case [argv] contains unknown arguments @raise Arg.Help in case [argv] contains "--help" This test runner displays execution in a compact way, making it good for suites that have lots of tests. Output example: {v random seed: 101121210 random seed: 101121210 \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ Error: tests>error_raise_exn test `error_raise_exn` raised exception `QCheck_ounit_test.Error` on `0 (after 62 shrink steps)` Raised at file "example/QCheck_ounit_test.ml", line 19, characters 20-25 Called from file "src/QCheck.ml", line 846, characters 13-33 /////////////////////////////////////////////////////////////////////////////// \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ Failure: tests>fail_sort_id fail_sort_id /////////////////////////////////////////////////////////////////////////////// Ran: 4 tests in: 0.74 seconds. WARNING! SOME TESTS ARE NEITHER SUCCESSES NOR FAILURES! v} *) val run_tap : OUnit.test -> OUnit.test_results (** TAP-compatible test runner, in case we want to use a test harness. It prints one line per test. *) qcheck-0.25/src/ounit/dune000066400000000000000000000003141477416744200155170ustar00rootroot00000000000000 (library (name qcheck_ounit) (public_name qcheck-ounit) (wrapped false) (libraries unix qcheck-core qcheck-core.runner ounit2) (flags :standard -w +a-4-42-44-48-50-58-32-60@8 -safe-string) ) qcheck-0.25/src/ppx_deriving_qcheck/000077500000000000000000000000001477416744200175215ustar00rootroot00000000000000qcheck-0.25/src/ppx_deriving_qcheck/QCheck_generators.ml000066400000000000000000000141671477416744200234530ustar00rootroot00000000000000open Ppxlib (** This module contains all generators from QCheck used to derive a type declaration *) (** {2 Version} *) type version = [`QCheck | `QCheck2] let to_module : version -> string = function | `QCheck -> "QCheck" | `QCheck2 -> "QCheck2" let with_prefix loc version prefix x = let (module A) = Ast_builder.make loc in A.Located.mk @@ Ldot (Ldot (Lident (to_module version), prefix), x) |> A.pexp_ident let with_prefix_gen loc version x = with_prefix loc version "Gen" x let with_prefix_obs loc version x = with_prefix loc version "Observable" x let apply1 loc f a = [%expr [%e f] [%e a]] let apply2 loc f a b = [%expr [%e f] [%e a] [%e b]] let apply3 loc f a b c = [%expr [%e f] [%e a] [%e b] [%e c]] let apply4 loc f a b c d = [%expr [%e f] [%e a] [%e b] [%e c] [%e d]] (** {2 Type} *) let ty version = Ldot (Ldot (Lident (to_module version), "Gen"), "t") (** {2 Primitive generators} *) let unit loc version = with_prefix_gen loc version "unit" let int loc version = with_prefix_gen loc version "int" let string loc version = with_prefix_gen loc version "string" let char loc version = with_prefix_gen loc version "char" let bool loc version = with_prefix_gen loc version "bool" let float loc version = with_prefix_gen loc version "float" let int32 loc version = with_prefix_gen loc version "ui32" let int64 loc version = with_prefix_gen loc version "ui64" let option ~loc ~version e = let gen = with_prefix_gen loc version "option" in apply1 loc gen e let list ~loc ~version e = let gen = with_prefix_gen loc version "list" in apply1 loc gen e let array ~loc ~version e = let gen = with_prefix_gen loc version "array" in apply1 loc gen e (** {2 Generator combinators} *) let pure ~loc ~version e = let gen = with_prefix_gen loc version "pure" in apply1 loc gen e let frequency ~loc ~version l = match l with | [%expr [([%e? _], [%e? x])]] -> x | _ -> let gen = with_prefix_gen loc version "frequency" in apply1 loc gen l let map ~loc ~version pat expr gen = let f = with_prefix_gen loc version "map" in apply2 loc f [%expr fun [%p pat] -> [%e expr]] gen let pair ~loc ~version a b = let gen = with_prefix_gen loc version "pair" in apply2 loc gen a b let triple ~loc ~version a b c = let gen = with_prefix_gen loc version "triple" in apply3 loc gen a b c let quad ~loc ~version a b c d = let gen = with_prefix_gen loc version "quad" in apply4 loc gen a b c d let sized ~loc ~version e = let gen = with_prefix_gen loc version "sized" in apply1 loc gen e let fix ~loc ~version e = let gen = with_prefix_gen loc version "fix" in apply1 loc gen e (** Observable generators *) module Observable = struct (** {2 Primitive generators} *) let unit loc version = with_prefix_obs loc version "unit" let int loc version = with_prefix_obs loc version "int" let string loc version = with_prefix_obs loc version "string" let char loc version = with_prefix_obs loc version "char" let bool loc version = with_prefix_obs loc version "bool" let float loc version = with_prefix_obs loc version "float" let int32 loc version = with_prefix_obs loc version "int32" let int64 loc version = with_prefix_obs loc version "int64" let option ~loc ~version e = let obs = with_prefix_obs loc version "option" in apply1 loc obs e let list ~loc ~version e = let obs = with_prefix_obs loc version "list" in apply1 loc obs e let array ~loc ~version e = let obs = with_prefix_obs loc version "array" in apply1 loc obs e (** {2 Observable combinators} *) let pair ~loc ~version a b = let obs = with_prefix_obs loc version "pair" in apply2 loc obs a b let triple ~loc ~version a b c = let obs = with_prefix_obs loc version "triple" in apply3 loc obs a b c let quad ~loc ~version a b c d = let obs = with_prefix_obs loc version "quad" in apply4 loc obs a b c d let fun_nary ~loc ~version left right gen = match version with | `QCheck -> let arb = [%expr QCheck.make [%e gen]] in [%expr QCheck.fun_nary QCheck.Tuple.([%e left] @-> [%e right]) [%e arb] |> QCheck.gen] | `QCheck2 -> [%expr QCheck2.fun_nary QCheck2.Tuple.([%e left] @-> [%e right]) [%e gen]] end module Make (Version : sig val version : version end) = struct let version = Version.version let ty = ty version let unit loc = unit loc version let int loc = int loc version let string loc = string loc version let char loc = char loc version let bool loc = bool loc version let float loc = float loc version let int32 loc = int32 loc version let int64 loc = int64 loc version let option ~loc = option ~loc ~version let list ~loc = list ~loc ~version let array ~loc = array ~loc ~version let pure ~loc x = pure ~loc ~version x let frequency ~loc l = frequency ~loc ~version l let map ~loc pat expr gen = map ~loc ~version pat expr gen let pair ~loc a b = pair ~loc ~version a b let triple ~loc a b c = triple ~loc ~version a b c let quad ~loc a b c d = quad ~loc ~version a b c d let sized ~loc e = sized ~loc ~version e let fix ~loc e = fix ~loc ~version e module Observable = struct let unit loc = Observable.unit loc version let int loc = Observable.int loc version let string loc = Observable.string loc version let char loc = Observable.char loc version let bool loc = Observable.bool loc version let float loc = Observable.float loc version let int32 loc = Observable.int32 loc version let int64 loc = Observable.int64 loc version let option ~loc e = Observable.option ~loc ~version e let list ~loc e = Observable.list ~loc ~version e let array ~loc e = Observable.array ~loc ~version e let pair ~loc a b = Observable.pair ~loc ~version a b let triple ~loc a b c = Observable.triple ~loc ~version a b c let quad ~loc a b c d = Observable.quad ~loc ~version a b c d let fun_nary ~loc left right gen = Observable.fun_nary ~loc ~version left right gen end end module QCheck = Make (struct let version = `QCheck end) module QCheck2 = Make (struct let version = `QCheck2 end) module type S = module type of QCheck let make version = (module Make (struct let version = version end) : S) qcheck-0.25/src/ppx_deriving_qcheck/README.md000066400000000000000000000147371477416744200210140ustar00rootroot00000000000000# ppx_deriving_qcheck ## Generator Derive `QCheck.Gen.t` from a type declaration ```ocaml type tree = Leaf of int | Node of tree * tree [@@deriving qcheck] let rec rev tree = match tree with | Leaf _ -> tree | Node (left, right) -> Node (rev right, rev left) let test = QCheck.Test.make ~name:"tree -> rev (rev tree) = tree" (QCheck.make gen_tree) (fun tree -> rev (rev tree) = tree) ``` For `type tree` we derive two generators: - `val gen_tree : tree Gen.t` and - `val gen_tree_sized : int -> tree Gen.t` For non-recursive types the latter is however not derived. For types with the name `t` (i.e. `type t = ...`) which is a common idiom in OCaml code, the deriver omits the name from the derived generators, thus producing `val gen : t Gen.t` and optionally `val gen_sized : int -> t Gen.t`. ### Overwrite generator If you wan't to specify your own `generator` for any type you can add an attribute to the type: ```ocaml type t = (int : [@gen QCheck.Gen.(0 -- 10)]) [@@deriving qcheck] (* produces ==> *) let gen : t QCheck.Gen.t = QCheck.Gen.(0 -- 10) ``` This attribute has 2 advantages: * Use your own generator for a specific type (see above) * There is no generator available for the type ```ocaml type my_foo = | Foo of my_other_type | Bar of bool [@@deriving qcheck] ^^^^^^^^^^^^^^^^ Error: Unbound value gen_my_other_type (* Possible fix *) let gen_my_other_type = (* add your implementation here *) type my_foo = | Foo of my_other_type [@gen gen_my_other_type] | Bar of bool [@@deriving qcheck] ``` ## How to use Add to your OCaml libraries with dune ```ocaml ... (preprocess (pps ppx_deriving_qcheck))) ... ``` ## Supported types ### Primitive types * Unit ```ocaml type t = unit [@@deriving qcheck] (* ==> *) let gen = QCheck.Gen.unit ``` * Bool ```ocaml type t = bool [@@deriving qcheck] (* ==> *) let gen = QCheck.Gen.bool ``` * Integer ```ocaml type t = int [@@deriving qcheck] (* ==> *) let gen = QCheck.Gen.int ``` * Float ```ocaml type t = float [@@deriving qcheck] (* ==> *) let gen = QCheck.Gen.float ``` * String ```ocaml type t = string [@@deriving qcheck] (* ==> *) let gen = QCheck.Gen.string ``` * Char ```ocaml type t = char [@@deriving qcheck] (* ==> *) let gen = QCheck.Gen.char ``` * Option ```ocaml type 'a t = 'a option [@@deriving qcheck] (* ==> *) let gen gen_a = QCheck.Gen.option gen_a ``` * List ```ocaml type 'a t = 'a list [@@deriving qcheck] (* ==> *) let gen gen_a = QCheck.Gen.list gen_a ``` * Array ```ocaml type 'a t = 'a array [@@deriving qcheck] (* ==> *) let gen gen_a = QCheck.Gen.array gen_a ``` ### Tuples of size `n` * n = 2 ```ocaml type t = int * int [@@deriving qcheck] (* ==> *) let gen = QCheck.Gen.pair QCheck.Gen.int QCheck.Gen.int ``` * n = 3 ```ocaml type t = int * int * int [@@deriving qcheck] (* ==> *) let gen = QCheck.Gen.triple QCheck.Gen.int QCheck.Gen.int QCheck.Gen.int ``` * n = 4 ```ocaml type t = int * int * int * int [@@deriving qcheck] (* ==> *) let gen = QCheck.Gen.quad QCheck.Gen.int QCheck.Gen.int QCheck.Gen.int QCheck.Gen.int ``` * n > 4, tuples are split between pairs, for instance n = 8 ```ocaml type t = int * int * int * int * int * int * int * int [@@deriving qcheck] (* ==> *) let gen = QCheck.Gen.pair (QCheck.Gen.quad QCheck.Gen.int QCheck.Gen.int QCheck.Gen.int QCheck.Gen.int) (QCheck.Gen.quad QCheck.Gen.int QCheck.Gen.int QCheck.Gen.int QCheck.Gen.int) ``` ## Records ```ocaml type service = { service_name : string; port : int; protocol : string; } [@@deriving qcheck] (* ==> *) let gen_service = QCheck.Gen.map (fun (gen0, gen1, gen2) -> { service_name = gen0; port = gen1; protocol = gen2 }) (QCheck.Gen.triple QCheck.Gen.string QCheck.Gen.int QCheck.Gen.string) ``` ## Variants * Variants ```ocaml type color = Red | Blue | Green [@@deriving qcheck] (* ==> *) let gen_color = QCheck.Gen.frequency [(1, (QCheck.Gen.pure Red)); (1, (QCheck.Gen.pure Blue)); (1, (QCheck.Gen.pure Green))] ``` * Polymorphic variants ```ocaml type color = [ `Red | `Blue | `Green ] [@@deriving qcheck] (* ==> *) let gen_color = (QCheck.Gen.frequency [(1, (QCheck.Gen.pure `Red)); (1, (QCheck.Gen.pure `Blue)); (1, (QCheck.Gen.pure `Green))] : color QCheck.Gen.t) ``` ## Recursive variants * Recursive variants ```ocaml type tree = Leaf of int | Node of tree * tree [@@deriving qcheck] (* ==> *) let rec gen_tree_sized n = match n with | 0 -> QCheck.Gen.map (fun gen0 -> Leaf gen0) QCheck.Gen.int | n -> QCheck.Gen.frequency [(1, (QCheck.Gen.map (fun gen0 -> Leaf gen0) QCheck.Gen.int)); (1, (QCheck.Gen.map (fun (gen0, gen1) -> Node (gen0, gen1)) (QCheck.Gen.pair (self (n / 2)) (self (n / 2)))))])) let gen_tree = QCheck.Gen.sized @@ gen_tree_sized ``` * Recursive polymorphic variants ```ocaml type tree = [ `Leaf of int | `Node of tree * tree ] [@@deriving qcheck] (* ==> *) let gen_tree = (QCheck.Gen.sized @@ QCheck.Gen.fix (fun self -> function | 0 -> QCheck.Gen.frequency [ ( 1, QCheck.Gen.map (fun gen0 -> `Leaf gen0) QCheck.Gen.int); ] | n -> QCheck.Gen.frequency [ ( 1, QCheck.Gen.map (fun gen0 -> `Leaf gen0) QCheck.Gen.int); ( 1, QCheck.Gen.map (fun gen0 -> `Node gen0) (QCheck.Gen.map (fun (gen0, gen1) -> (gen0, gen1)) (QCheck.Gen.pair (self (n / 2)) (self (n / 2))))) ]) : tree QCheck.Gen.t) ``` ## Mutual recursive types ```ocaml type tree = Node of (int * forest) and forest = Nil | Cons of (tree * forest) [@@deriving qcheck] (* ==> *) let rec gen_tree () = QCheck.Gen.frequency [(1, (QCheck.Gen.map (fun gen0 -> Node gen0) (QCheck.Gen.map (fun (gen0, gen1) -> (gen0, gen1)) (QCheck.Gen.pair QCheck.Gen.int (gen_forest ())))))] and gen_forest () = QCheck.Gen.sized @@ (QCheck.Gen.fix (fun self -> function | 0 -> QCheck.Gen.frequency [(1, (QCheck.Gen.pure Nil))] | n -> QCheck.Gen.frequency [(1, (QCheck.Gen.pure Nil)); (1, (QCheck.Gen.map (fun gen0 -> Cons gen0) (QCheck.Gen.map (fun (gen0, gen1) -> (gen0, gen1)) (QCheck.Gen.pair (gen_tree ()) (self (n / 2))))))])) let gen_tree = gen_tree () let gen_forest = gen_forest () ``` ## Unsupported types ### GADT Deriving a GADT currently produces an ill-typed generator. ### Let us know If you encounter a unsupported type (that should be), please let us know by creating an issue. qcheck-0.25/src/ppx_deriving_qcheck/args.ml000066400000000000000000000011221477416744200210030ustar00rootroot00000000000000open Ppxlib (** [curry_args args body] adds parameter to [body] e.g.: curry_args [gen_a; gen_b] () => fun gen_a -> fun gen_b -> () *) let rec curry_args ~loc args body = match args with | [] -> body | x :: xs -> [%expr fun [%p x] -> [%e curry_args ~loc xs body]] (** [apply_args args body] applies parameters to [body] e.g.: apply_args [gen_a; gen_b] f => f gen_a gen_b *) let apply_args ~loc args body = let rec aux acc = function | [] -> acc | [arg] -> [%expr [%e acc] [%e arg]] | arg :: args -> aux [%expr [%e acc] [%e arg]] args in aux body args qcheck-0.25/src/ppx_deriving_qcheck/attributes.ml000066400000000000000000000010641477416744200222420ustar00rootroot00000000000000open Ppxlib (** [find_first_attribute xs name] returns the first attribute found in [xs] named [name] *) let find_attribute_opt xs name = List.find_opt (fun attribute -> attribute.attr_name.txt = name) xs let get_expr_payload x = match x.attr_payload with | PStr [ { pstr_desc = Pstr_eval (e, _); _ } ] -> Some [%expr [%e e]] | _ -> None let gen ct = Option.fold ~none:None ~some:get_expr_payload @@ find_attribute_opt ct.ptyp_attributes "gen" let weight xs = Option.fold ~none:None ~some:get_expr_payload @@ find_attribute_opt xs "weight" qcheck-0.25/src/ppx_deriving_qcheck/attributes.mli000066400000000000000000000013111477416744200224060ustar00rootroot00000000000000open Ppxlib (** This file handles every attributes to be found in a core_type definition *) val gen : core_type -> expression option (** [gen loc ct] look for an attribute "gen" in [ct] example: {[ type t = | A of int | B of (int [@gen QCheck.int32]) ]} It allows the user to specify which generator he wants for a specific type. Returns the generator as an expression and returns None if no attribute is present *) val weight : attributes -> expression option (** [weight loc ct] look for an attribute "weight" in [ct] example: {[ type t = | A [@weight 5] | B [@weight 6] | C ]} It allows the user to specify the weight of a type case. *) qcheck-0.25/src/ppx_deriving_qcheck/dune000066400000000000000000000002721477416744200204000ustar00rootroot00000000000000(library (name ppx_deriving_qcheck) (public_name ppx_deriving_qcheck) (libraries ppxlib) (preprocess (pps ppxlib.metaquot)) (ppx_runtime_libraries qcheck-core) (kind ppx_deriver)) qcheck-0.25/src/ppx_deriving_qcheck/ppx_deriving_qcheck.ml000066400000000000000000000503011477416744200240660ustar00rootroot00000000000000open Ppxlib module G = QCheck_generators module O = G.Observable (** {1. ppx_deriving_qcheck} *) (** ppx_deriving_qcheck is a ppx deriver for QCheck generators. It does a traversal map on type declarations annoted with [QCheck]. Example: {[ module Tree : sig type t val gen_sized : int -> t QCheck.Gen.t val gen : t QCheck.Gen.t val arb_sized : int -> t QCheck.arbitrary val arb : t QCheck.arbitrary end = struct type t = Leaf | Node of int * t * t [@@deriving qcheck] end ]} *) (** {2. Misc. helpers} *) (** [name s] produces the generator name based on [s] *) let name ?(sized = false) s = let prefix = "gen" in (match s with "t" -> prefix | s -> prefix ^ "_" ^ s) ^ (if sized then "_sized" else "") (** [pat ~loc s] creates a pattern for a generator based on {!name}. *) let pat ~loc ?sized s = let (module A) = Ast_builder.make loc in let s = name ?sized s in A.pvar s (** [name_gen_to_arb name] creates the arb name based on the generator [name] *) let name_gen_to_arb = function | "gen" -> "arb" | name -> let n = String.length name in let suffix = String.sub name 3 (n - 3) in "arb" ^ suffix (** [pattern_name pat] tries to find the [pattern] name. *) let pattern_name pat : string = let loc = pat.ppat_loc in match pat.ppat_desc with | Ppat_var var -> var.txt | _ -> Ppxlib.Location.raise_errorf ~loc "Could not extract name from this pattern" (** [args_and_body expr] extracts the args used in [expr] with the actual body using these args. *) let rec args_and_body expr : (string list * expression) = match expr.pexp_desc with | Pexp_function (fargs, _constraint, Pfunction_body expr) -> let (args, body) = args_and_body expr in let pats = List.filter_map (function | { pparam_desc = Pparam_val (Nolabel, _, p); _ } -> Some (pattern_name p) | _ -> None ) fargs in (pats @ args, body) | _ -> ([], expr) (** {2. Recursive generators} *) (** Recursive generators must be treated separatly: {[ type 'a list = Cons of 'a * 'a list | Nil ]} becomes: {[ let rec gen_list_sized gen_a n = match n with | 0 -> pure Nil | n -> map2 (fun x xs -> Cons (x, xs) gen_a (gen_list_sized gen_a (n/2)) let gen_list_sized gen_a = sized @@ (gen_list_sized gen_a) ]} In the basic derivation {[ 'a list ]} would be translated to {[gen_list]}. However, we want the generator to call itsef. *) module Env = struct (** [env] contains: - the list of recursive types during the derivation - the list of types to derive (i.e. mutual types) - the current type to derive It also contains the current version of QCheck we derive *) type env = { version : [`QCheck | `QCheck2]; rec_types : string list; curr_types : string list; curr_type : string; } let is_rec env x = List.mem x env.rec_types let get_version env = env.version end let rec longident_to_str = function | Lident s -> s | Ldot (lg, s) -> Printf.sprintf "%s.%s" (longident_to_str lg) s | Lapply (lg1, lg2) -> Printf.sprintf "%s %s" (longident_to_str lg1) (longident_to_str lg2) let rec is_rec_typ env = function | { ptyp_desc = Ptyp_constr ({ txt = x; _ }, args); _ } -> List.exists (fun typ_name -> longident_to_str x = typ_name) env.Env.curr_types || List.exists (is_rec_typ env) args | { ptyp_desc = Ptyp_tuple xs; _ } -> List.exists (is_rec_typ env) xs | { ptyp_desc = Ptyp_variant (rws, _, _); _ } -> List.exists (is_rec_row_field env) rws | _ -> false and is_rec_row_field env rw = match rw.prf_desc with | Rtag (lab, _, cts) -> List.exists (fun typ_name -> lab.txt = typ_name) env.Env.curr_types || List.exists (is_rec_typ env) cts | Rinherit ct -> is_rec_typ env ct let is_rec_constr_decl env cd = match cd.pcd_args with | Pcstr_tuple cts -> List.exists (is_rec_typ env) cts | Pcstr_record ldcls -> List.exists (fun ldcl -> is_rec_typ env ldcl.pld_type) ldcls (** [is_rec_type_decl env typ] looks for elements of [env.curr_types] recursively in [typ]. *) let is_rec_type_decl env typ = let in_type_kind = match typ.ptype_kind with | Ptype_variant cstrs -> List.exists (is_rec_constr_decl env) cstrs | _ -> false in let in_manifest = match typ.ptype_manifest with | Some x -> is_rec_typ env x | None -> false in in_type_kind || in_manifest (** is_n_used looks for `n` (size indication) in an expression. For instance: {[ type foo = A of bar | B of bar and bar = Any [@@deriving qcheck] let rec gen_sized_foo n = let open QCheck.Gen in frequency [ (map (fun x -> A x) gen_bar); (map (fun x -> B x) gen_bar); ] and gen_bar = p let open QCheck.Gen in pure Any ]} The type [foo] is recursive because it has a dependency to [bar] but does not use the fuel as there is no "leaves" for this type. We begin by looking for occurences of variables `n`, iff we did not find any occurences, we replace `n` by `_n` in the generator's parameters. Thus, avoiding an unused variable. *) exception N_is_used class is_n_used (expr : expression) = object(self) inherit Ast_traverse.map as super method! expression expr = match expr with | [%expr n ] -> raise N_is_used | _ -> super#expression expr method go () = match self#expression expr |> ignore with | exception N_is_used -> true | () -> false end let is_n_used expr = (new is_n_used expr)#go () (** {2. Generator constructors} *) (** [gen_longident lg args] creates a generator using [lg]. The longident can either be a: - Lident s: We transform to gen_s (or gen if s = "t") - Ldot (lg, s): We transform to qualified generator (e.g. B.gen) *) let gen_longident ~loc ~env lg args = let (module A) = Ast_builder.make loc in match lg with | Lident s -> if Env.is_rec env s then name ~sized:true s |> A.evar |> Args.apply_args ~loc args |> Args.apply_args ~loc [ [%expr (n / 2)] ] else name s |> A.evar |> Args.apply_args ~loc args | Ldot (lg, s) -> A.(pexp_ident (Located.mk @@ Ldot (lg, name s))) |> Args.apply_args ~loc args | Lapply (_, _) -> raise (Invalid_argument "gen received an Lapply") (** [gen_sized typ_name is_rec to_gen xs] uses [is_rec] to determine recursive nodes in [xs]. If no recursive node is found, the type is _not_ recursive, we build a generator using frequency. However, if recursive nodes are found, we build a tree like generator using {!gen_sized}. The function is generalized for variants and polymorphic variants: {[ type t = Leaf | Node of int * t * t (* or *) type t = [`Leaf | `Node of int * t * t] ]} Therefore, [is_rec] and [to_gen] are different for variants and polymorphic variants. *) let gen_sized ~loc ~env (is_rec : 'a -> bool) (to_gen : 'a -> expression) (xs : 'a list) = let (module A) = Ast_builder.make loc in let (module G) = G.make (Env.get_version env) in let leaves = List.filter (fun x -> not (is_rec x)) xs |> List.map to_gen in let nodes = List.filter is_rec xs in if List.length nodes = 0 then G.frequency ~loc (A.elist leaves) else if List.length leaves = 0 then let nodes = List.map to_gen nodes in G.frequency ~loc (A.elist nodes) else let nodes = List.map to_gen nodes in let leaves = A.elist leaves |> G.frequency ~loc and nodes = A.elist (leaves @ nodes) |> G.frequency ~loc in [%expr match n with | 0 -> [%e leaves] | _ -> [%e nodes] ] (** [gen_tuple ~loc ?f tys] transforms list of type [tys] into a tuple generator. [f] can be used to transform tuples, for instance: {[ type t = Foo of int * int ]} Without [f]: {[ let gen = QCheck.Gen.(map (fun (x, y) -> (x, y)) (pair int int)) ]} With [f], building Foo: {[ let gen = QCheck.Gen.(map (fun (x, y) -> Foo (x, y)) (pair int int)) ]} *) let gen_tuple ~loc ~env ?(f = fun x -> x) tys = let tuple = Tuple.from_list tys in let gen = Tuple.to_gen ~loc ~version:(Env.get_version env) tuple in let expr = Tuple.to_expr ~loc tuple |> f in let pat = Tuple.to_pat ~loc tuple in G.map ~loc ~version:(Env.get_version env) pat expr gen (** [gen_record loc gens ?f label_decls] transforms [gens] and [label_decls] to a record generator. Similarly to {!gen_tuple}, we can use [f] to transform records, for instance: {[ type t = Foo of { left : int; right : int } ]} Without [f]: {[ let gen = QCheck.Gen.(map (fun (x, y) -> {left = x; right = y}) (pair int int)) ]} With [f], building Foo: {[ let gen = QCheck.Gen.(map (fun (x, y) -> Foo {left = x; right = y}) (pair int int)) ]} *) let gen_record ~loc ~env ~gens ?(f = fun x -> x) xs = let (module A) = Ast_builder.make loc in let tuple = Tuple.from_list gens in let gen = Tuple.to_gen ~loc ~version:(Env.get_version env) tuple in let pat = Tuple.to_pat ~loc tuple in (* TODO: this should be handled in {!Tuple} *) let gens = List.mapi (fun i _ -> let s = Printf.sprintf "gen%d" i in A.evar s) gens in let fields = List.map2 (fun { pld_name; _ } value -> (A.Located.mk @@ Lident pld_name.txt, value)) xs gens in let expr = A.pexp_record fields None |> f in G.map ~loc ~version:(Env.get_version env) pat expr gen (** {2. Core derivation} *) (** [gen_from_type typ] performs the AST traversal and derivation to qcheck generators *) let rec gen_from_type ~loc ~env typ = let (module G) = G.make (Env.get_version env) in Option.value (Attributes.gen typ) ~default: (match typ with | [%type: unit] -> G.unit loc | [%type: int] -> G.int loc | [%type: string] | [%type: String.t] -> G.string loc | [%type: char] -> G.char loc | [%type: bool] -> G.bool loc | [%type: float] -> G.float loc | [%type: int32] | [%type: Int32.t] -> G.int32 loc | [%type: int64] | [%type: Int64.t] -> G.int64 loc | [%type: [%t? typ] option] -> G.option ~loc (gen_from_type ~loc ~env typ) | [%type: [%t? typ] list] -> G.list ~loc (gen_from_type ~loc ~env typ) | [%type: [%t? typ] array] -> G.array ~loc (gen_from_type ~loc ~env typ) | { ptyp_desc = Ptyp_tuple typs; _ } -> let tys = List.map (gen_from_type ~loc ~env) typs in gen_tuple ~loc ~env tys | { ptyp_desc = Ptyp_constr ({ txt = ty; _ }, args); _ } -> let args = List.map (gen_from_type ~loc ~env) args in gen_longident ~loc ~env ty args | { ptyp_desc = Ptyp_var s; _ } -> gen_longident ~loc ~env (Lident s) [] | { ptyp_desc = Ptyp_variant (rws, _, _); _ } -> gen_from_variant ~loc ~env rws | { ptyp_desc = Ptyp_arrow (_, left, right); _ } -> gen_from_arrow ~loc ~env left right | _ -> Ppxlib.Location.raise_errorf ~loc "This type is not supported in ppx_deriving_qcheck") and gen_from_constr ~loc ~env { pcd_name; pcd_args; pcd_attributes; _ } = let (module A) = Ast_builder.make loc in let constr_decl = A.constructor_declaration ~name:pcd_name ~args:pcd_args ~res:None in let mk_constr expr = A.econstruct constr_decl (Some expr) in let weight = Attributes.weight pcd_attributes in let gen = match pcd_args with | Pcstr_tuple [] | Pcstr_record [] -> G.pure ~loc ~version:(Env.get_version env) @@ A.econstruct constr_decl None | Pcstr_tuple xs -> let tys = List.map (gen_from_type ~loc ~env) xs in gen_tuple ~loc ~env ~f:mk_constr tys | Pcstr_record xs -> let tys = List.map (fun x -> gen_from_type ~loc ~env x.pld_type) xs in gen_record ~loc ~env ~f:mk_constr ~gens:tys xs in A.pexp_tuple [ Option.value ~default:[%expr 1] weight; gen ] and gen_from_variant ~loc ~env rws = let (module A) = Ast_builder.make loc in let (module G) = G.make (Env.get_version env) in let is_rec = is_rec_row_field env in let to_gen (row : row_field) : expression = let w = Attributes.weight row.prf_attributes |> Option.value ~default:[%expr 1] in let gen = match row.prf_desc with | Rinherit typ -> gen_from_type ~loc ~env typ | Rtag (label, _, []) -> G.pure ~loc @@ A.pexp_variant label.txt None | Rtag (label, _, typs) -> let f expr = A.pexp_variant label.txt (Some expr) in gen_tuple ~loc ~env ~f (List.map (gen_from_type ~loc ~env) typs) in [%expr [%e w], [%e gen]] in let gen = gen_sized ~loc ~env is_rec to_gen rws in let typ_t = A.ptyp_constr (A.Located.mk @@ Lident env.curr_type) [] in let typ_gen = A.Located.mk G.ty in let typ = A.ptyp_constr typ_gen [ typ_t ] in [%expr ([%e gen] : [%t typ])] and gen_from_arrow ~loc ~env left right = let (module Gen) = G.make (Env.get_version env) in let open Gen.Observable in let rec observable = function | [%type: unit] -> unit loc | [%type: bool] -> bool loc | [%type: int] -> int loc | [%type: float] -> float loc | [%type: string] -> string loc | [%type: char] -> char loc | [%type: [%t? typ] option] -> option ~loc (observable typ) | [%type: [%t? typ] array] -> array ~loc (observable typ) | [%type: [%t? typ] list] -> list ~loc (observable typ) | { ptyp_desc = Ptyp_tuple xs; _ } -> let obs = List.map observable xs in Tuple.from_list obs |> Tuple.to_obs ~version:(Env.get_version env) ~loc | { ptyp_loc = loc; _ } -> Ppxlib.Location.raise_errorf ~loc "This type is not supported in ppx_deriving_qcheck" in let rec aux = function | { ptyp_desc = Ptyp_arrow (_, x, xs); _ } -> let res, xs = aux xs in let obs = observable x in (res, [%expr [%e obs] @-> [%e xs]]) | x -> (gen_from_type ~loc ~env x, [%expr o_nil]) in let gen, right = aux right in let left = observable left in fun_nary ~loc left right gen (** [gen_from_type_declaration loc td] creates a generator from the type declaration. It returns either `Recursive or `Normal. - `Normal of expression: The derived generator is not recursive, we return only the generator. - `Recursive of expression * expression The derived generator was recursive (i.e. val gen : n -> t Gen.t), we return the sized generator version, and a normal generator using this last with [Gen.sized]. *) let gen_from_type_declaration ~loc ~env td = let (module A) = Ast_builder.make loc in let ty = env.Env.curr_type in let is_rec = Env.is_rec env ty in let args = List.map (fun (typ, _) -> match typ.ptyp_desc with | Ptyp_var s -> (pat ~loc s, name s |> A.evar) | _ -> assert false) td.ptype_params in let (args_pat, args_expr) = List.split args in let gen = match td.ptype_kind with | Ptype_variant xs -> let is_rec cd = is_rec_constr_decl env cd in gen_sized ~loc ~env is_rec (gen_from_constr ~loc ~env) xs | Ptype_record xs -> let gens = List.map (fun x -> gen_from_type ~loc ~env x.pld_type) xs in gen_record ~loc ~env ~gens xs | _ -> let typ = Option.get td.ptype_manifest in gen_from_type ~loc ~env typ in let pat_gen = pat ~loc ty in if not is_rec then let gen = Args.curry_args ~loc args_pat gen in `Normal [%stri let [%p pat_gen] = [%e gen]] else let args = if is_n_used gen then args_pat @ [A.pvar "n"] else args_pat @ [A.pvar "_n"] in let gen = Args.curry_args ~loc args gen in let pat_gen_sized = pat ~loc ~sized:true ty in let gen_sized = name ~sized:true ty |> A.evar in let gen_normal = Args.curry_args ~loc args_pat (G.sized ~loc ~version:(Env.get_version env) (Args.apply_args ~loc args_expr gen_sized)) in `Recursive ( [%stri let rec [%p pat_gen_sized] = [%e gen]], [%stri let [%p pat_gen] = [%e gen_normal]] ) let mutually_recursive_gens ~loc gens = let (module A) = Ast_builder.make loc in let to_mutualize_gens = List.map (function | `Recursive (x, _) -> x | `Normal x -> x) gens in let normal_gens = List.filter_map (function | `Recursive (_, x) -> Some x | `Normal _ -> None) gens in let gens = List.map (function | [%stri let [%p? pat] = [%e? expr]] | [%stri let rec [%p? pat] = [%e? expr]] -> A.value_binding ~pat ~expr | _ -> assert false) to_mutualize_gens in let mutual_gens = A.pstr_value Recursive gens in mutual_gens :: normal_gens (** [derive_gens ~version ~loc xs] creates generators for type declaration in [xs]. The generators can either be [QCheck.Gen.t] or [QCheck2.Gen.t] based on [version]. *) let derive_gens ~version ~loc (xs : rec_flag * type_declaration list) : structure = let add_if_rec env typ x = if is_rec_type_decl env typ then Env.{ env with rec_types = x :: env.rec_types} else env in match xs with | (_, [ x ]) -> let typ_name = x.ptype_name.txt in let env = Env.{ curr_type = typ_name; rec_types = []; curr_types = [typ_name]; version } in let env = add_if_rec env x typ_name in (match gen_from_type_declaration ~loc ~env x with | `Recursive (gen_sized, gen) -> [gen_sized; gen] | `Normal gen -> [gen]) | _, xs -> let typ_names = List.map (fun x -> x.ptype_name.txt) xs in let env = Env.{ curr_type = ""; rec_types = typ_names; curr_types = typ_names; version } in let gens = List.map (fun x -> let env = { env with curr_type = x.ptype_name.txt }in gen_from_type_declaration ~loc ~env x) xs in mutually_recursive_gens ~loc gens (** [derive_arb gen] creates an arbitrary declaration based on [gen]. We call QCheck.make on the derived generator.. It fetches the generator name and its parameters. e.g. {[ type 'a list = Cons of 'a * 'a list | Nil [@@deriving qcheck] (* produces => *) let rec gen_list_sized gen_a = match n with | ... let gen_list_gen_a = QCheck.Gen.sized @@ (gen_list_sized gen_a) let arb_list_sized gen_a = QCheck.make @@ (gen_list_sized gen_a) let arb_list gen_a = QCheck.make @@ (gen_list gen_a) ]} *) let derive_arb gen = let loc = gen.pstr_loc in let (module A) = Ast_builder.make loc in let (args, body, gen_name) = match gen with | [%stri let [%p? pat] = [%e? body]] | [%stri let rec [%p? pat] = [%e? body]] -> let (args, body) = args_and_body body in let gen_name = pattern_name pat in (args, body, gen_name) | _ -> assert false in let args_pat = List.map A.pvar args in let args_expr = List.map A.evar args in let arb_pat = A.pvar (name_gen_to_arb gen_name) in let body = match body with | [%expr QCheck.sized @@ [%e? _]] -> A.evar gen_name |> Args.apply_args ~loc args_expr |> fun e -> [%expr QCheck.make @@ [%e e]] | _ -> A.evar gen_name |> Args.apply_args ~loc args_expr in let body = Args.curry_args ~loc args_pat [%expr QCheck.make @@ [%e body]] in [%stri let [%p arb_pat] = [%e body]] let derive_arbs ~loc xs = let gens = derive_gens ~loc ~version:`QCheck xs in (* When generators are mutual, they are nested in a {[ let rec gen = ... and gen .. ]}, we want an arbitrary for each generator, so, we flatten them in a list. *) let flatten_gens = List.fold_right (fun gen acc -> match gen.pstr_desc with | Pstr_value (_, vbs) -> List.map (fun vb -> [%stri let [%p vb.pvb_pat] = [%e vb.pvb_expr]]) vbs @ acc | _ -> gen :: acc ) gens [] in gens @ List.map derive_arb flatten_gens (** {2. Ppxlib machinery} *) let create_gens version ~ctxt (decls : rec_flag * type_declaration list) : structure = let loc = Expansion_context.Deriver.derived_item_loc ctxt in derive_gens ~version ~loc decls let create_arbs ~ctxt (decls : rec_flag * type_declaration list) : structure = let loc = Expansion_context.Deriver.derived_item_loc ctxt in derive_arbs ~loc decls let gen_expander_qcheck = Deriving.Generator.V2.make_noarg create_arbs let gen_expander_qcheck2 = Deriving.Generator.V2.make_noarg (create_gens `QCheck2) let _ = Deriving.add "qcheck" ~str_type_decl:gen_expander_qcheck let _ = Deriving.add "qcheck2" ~str_type_decl:gen_expander_qcheck2 qcheck-0.25/src/ppx_deriving_qcheck/ppx_deriving_qcheck.mli000066400000000000000000000010211477416744200242320ustar00rootroot00000000000000open Ppxlib val derive_gens : version:[`QCheck | `QCheck2] -> loc:location -> rec_flag * type_declaration list -> structure (** [derive_gens ~version ~loc xs] creates generators for type declaration in [xs]. The generators can either be [QCheck.Gen.t] or [QCheck2.Gen.t] based on [version]. *) val derive_arbs : loc:location -> rec_flag * type_declaration list -> structure (** [derive_arbs ~loc xs] creates generators for type declaration in [xs] and use these lasts to build [QCheck.arbitrary]. *) qcheck-0.25/src/ppx_deriving_qcheck/tuple.ml000066400000000000000000000070361477416744200212120ustar00rootroot00000000000000open Ppxlib module G = QCheck_generators module O = G.Observable (** {1 Tuple } *) (** This module implements nested tuples based on QCheck tuples generators (or observables): - [Gen.pair] - [Gen.triple] - [Gen.quad] It can be used to nest large tuples in a generator. - e.g. {[ type t = int * int * int ]} Lets say QCheck does not have combinator to generate a triple. One has to write: {[ let gen = QCheck.Gen.(map (fun ((x, y), z) -> (x, y, z) (pair (pair int int) int)) ]} We copy this nesting mechanism with this module. *) type 'a t = | Pair of 'a t * 'a t | Triple of 'a * 'a * 'a | Quad of 'a * 'a * 'a * 'a | Elem of 'a (** [from_list l] builds an {!'a t}, if len of [l] is greater than 4, the list is split into a [Pair] of generators. *) let rec from_list = function | [ a; b; c; d ] -> Quad (a, b, c, d) | [ a; b; c ] -> Triple (a, b, c) | [ a; b ] -> Pair (Elem a, Elem b) | [ a ] -> Elem a | l -> let n = List.length l / 2 in let i = ref 0 in let l1 = List.filter (fun _ -> let x = !i in i := x + 1; x < n) l in i := 0; let l2 = List.filter (fun _ -> let x = !i in i := x + 1; x >= n) l in Pair (from_list l1, from_list l2) let rec to_list = function | Quad (a, b, c, d) -> [ a; b; c; d ] | Triple (a, b, c) -> [ a; b; c ] | Pair (a, b) -> to_list a @ to_list b | Elem a -> [ a ] (** [to_expr ~loc t] creates a tuple expression based on [t]. [t] is transformed to a list, and each element from the list becomes a variable referencing a generator. - e.g. to_expr (Pair (_, _)) => (gen0, gen1) *) let to_expr ~loc t = let l = to_list t in let (module A) = Ast_builder.make loc in List.mapi (fun i _ -> let s = Printf.sprintf "gen%d" i in A.evar s) l |> A.pexp_tuple (** [nest pair triple quad t] creates a generator expression for [t] using - [pair] to combine Pair (_, _) - [triple] to combine Triple (_, _, ) - [quad] to combine Quad (_, _, _, _) *) let rec nest ~pair ~triple ~quad = function | Quad (a, b, c, d) -> quad a b c d | Triple (a, b, c) -> triple a b c | Pair (a, b) -> pair (nest ~pair ~triple ~quad a) (nest ~pair ~triple ~quad b) | Elem a -> a (** [to_gen t] creates a Gen.t with generators' combinators *) let to_gen ~loc ~version t = nest ~pair:(G.pair ~loc ~version) ~triple:(G.triple ~loc ~version) ~quad:(G.quad ~loc ~version) t (** [to_obs t] creates a Obs.t with obsersvables' combinators *) let to_obs ~loc ~version t = nest ~pair:(O.pair ~loc ~version) ~triple:(O.triple ~loc ~version) ~quad:(O.quad ~loc ~version) t let to_pat ~loc t = let fresh_id = let id = ref 0 in fun () -> let x = !id in let () = id := x + 1 in Printf.sprintf "gen%d" x in let (module A) = Ast_builder.make loc in let rec aux = function | Quad (_, _, _, _) -> let a = A.pvar @@ fresh_id () in let b = A.pvar @@ fresh_id () in let c = A.pvar @@ fresh_id () in let d = A.pvar @@ fresh_id () in [%pat? [%p a], [%p b], [%p c], [%p d]] | Triple (_, _, _) -> let a = A.pvar @@ fresh_id () in let b = A.pvar @@ fresh_id () in let c = A.pvar @@ fresh_id () in [%pat? [%p a], [%p b], [%p c]] | Pair (a, b) -> let a = aux a in let b = aux b in [%pat? [%p a], [%p b]] | Elem _ -> A.pvar @@ fresh_id () in aux t qcheck-0.25/src/runner/000077500000000000000000000000001477416744200150165ustar00rootroot00000000000000qcheck-0.25/src/runner/QCheck_base_runner.ml000066400000000000000000000407061477416744200211000ustar00rootroot00000000000000(* QCheck: Random testing for OCaml copyright (c) 2013-2017, Guillaume Bury, Simon Cruanes, Vincent Hugot, Jan Midtgaard all rights reserved. *) module Color = struct let fpf = Printf.fprintf type color = [ `Red | `Yellow | `Green | `Blue | `Normal | `Cyan ] let int_of_color_ : color -> int = function | `Normal -> 0 | `Red -> 1 | `Green -> 2 | `Yellow -> 3 | `Blue -> 4 | `Cyan -> 6 (* same as [pp], but in color [c] *) let in_color c pp out x = let n = int_of_color_ c in fpf out "\x1b[3%dm" n; pp out x; fpf out "\x1b[0m" (* same as [pp], but in bold color [c] *) let in_bold_color c pp out x = let n = int_of_color_ c in fpf out "\x1b[3%d;1m" n; pp out x; fpf out "\x1b[0m" let reset_line = "\x1b[2K\r" let pp_str_c ?(bold=true) ~colors c out s = if colors then if bold then in_bold_color c output_string out s else in_color c output_string out s else output_string out s end let seed = ref ~-1 let st = ref None let set_seed_ ~colors s = seed := s; if colors then Printf.printf "%srandom seed: %d\n%!" Color.reset_line s else Printf.printf "random seed: %d\n%!" s; let state = Random.State.make [| s |] in st := Some state; state (* time of last printed message. Useful for rate limiting in verbose mode *) let last_msg = ref 0. let time_between_msg = let env_var = "QCHECK_MSG_INTERVAL" in let default_interval = 0.1 in let interval = match Sys.getenv_opt env_var with | None -> default_interval | Some f -> match float_of_string_opt f with | None -> invalid_arg (env_var ^ " must be a float") | Some i -> i in if interval < 0. then invalid_arg (env_var ^ " must be >= 0 but value is " ^ string_of_float interval); ref interval let get_time_between_msg () = !time_between_msg let set_time_between_msg f = time_between_msg := f let set_seed s = ignore (set_seed_ ~colors:false s) let setup_random_state_ ~colors () = let s = if !seed = ~-1 then ( Random.self_init (); (* make new, truly random seed *) Random.int (1 lsl 29); ) else !seed in set_seed_ ~colors s (* initialize random generator from seed (if any) *) let random_state_ ~colors () = match !st with | Some st -> st | None -> setup_random_state_ ~colors () let random_state() = random_state_ ~colors:false () let verbose, set_verbose = let r = ref false in (fun () -> !r), (fun b -> r := b) let long_tests, set_long_tests = let r = ref false in (fun () -> !r), (fun b -> r := b) let debug_shrink, set_debug_shrink = let r = ref None in (fun () -> !r), (fun s -> r := Some (open_out s)) let debug_shrink_list, set_debug_shrink_list = let r = ref [] in (fun () -> !r), (fun b -> r := b :: !r) module Raw = struct type ('b,'c) printer = { info: 'a. ('a,'b,'c,unit) format4 -> 'a; fail: 'a. ('a,'b,'c,unit) format4 -> 'a; err: 'a. ('a,'b,'c,unit) format4 -> 'a; } type cli_args = { cli_verbose : bool; cli_long_tests : bool; cli_print_list : bool; cli_rand : Random.State.t; cli_slow_test : int; (* how many slow tests to display? *) cli_colors: bool; cli_debug_shrink : out_channel option; cli_debug_shrink_list : string list; } (* main callback for individual tests @param verbose if true, print statistics and details @param print_res if true, print the result on [out] *) let callback ~colors ~verbose ~print_res ~print name cell result = let module R = QCheck2.TestResult in let module T = QCheck2.Test in let reset_line = if colors then Color.reset_line else "\n" in if verbose then ( print.info "%slaw %s: %d relevant cases (%d total)\n" reset_line name (R.get_count result) (R.get_count_gen result); begin match QCheck2.TestResult.collect result with | None -> () | Some tbl -> print_string (QCheck2.Test.print_collect tbl) end; ); if print_res then ( (* even if [not verbose], print errors *) match R.get_state result with | R.Success -> if not (T.get_positive cell) then print.fail "%snegative test '%s' succeeded unexpectedly\n" reset_line name; | R.Failed {instances=l} -> if T.get_positive cell then print.fail "%s%s\n" reset_line (T.print_fail cell name l) else print.info "%s%s\n" reset_line (T.print_expected_failure cell l) | R.Failed_other {msg} -> print.fail "%s%s\n" reset_line (T.print_fail_other name ~msg); | R.Error {instance; exn; backtrace} -> print.err "%s%s\n" reset_line (T.print_error ~st:backtrace cell name (instance,exn)); ) let print_std = { info = Printf.printf; fail = Printf.printf; err = Printf.printf } let parse_cli ~full_options argv = let print_list = ref false in let set_verbose () = set_verbose true in let set_long_tests () = set_long_tests true in let set_backtraces () = Printexc.record_backtrace true in let set_list () = print_list := true in let colors = ref true in let slow = ref 0 in let options = Arg.align ( [ "-v", Arg.Unit set_verbose, " " ; "--verbose", Arg.Unit set_verbose, " enable verbose tests" ; "--colors", Arg.Set colors, " colored output" ; "--no-colors", Arg.Clear colors, " disable colored output" ] @ (if full_options then [ "-l", Arg.Unit set_list, " " ; "--list", Arg.Unit set_list, " print list of tests (2 lines each)" ; "--slow", Arg.Set_int slow, " print the slowest tests" ] else [] ) @ [ "-s", Arg.Set_int seed, " " ; "--seed", Arg.Set_int seed, " set random seed (to repeat tests)" ; "--long", Arg.Unit set_long_tests, " run long tests" ; "-bt", Arg.Unit set_backtraces, " enable backtraces" ; "--debug-shrink", Arg.String set_debug_shrink, " enable shrinking debug to " ; "--debug-shrink-list", Arg.String set_debug_shrink_list, " filter test to debug shrinking on" ] ) in Arg.parse_argv argv options (fun _ ->()) "run QCheck test suite"; let cli_rand = setup_random_state_ ~colors:!colors () in { cli_verbose=verbose(); cli_long_tests=long_tests(); cli_rand; cli_print_list= !print_list; cli_slow_test= !slow; cli_colors= !colors; cli_debug_shrink = debug_shrink(); cli_debug_shrink_list = debug_shrink_list(); } end open Raw (* Counter for a test's instances *) type counter = { start : float; expected : int; mutable gen : int; mutable passed : int; mutable failed : int; mutable errored : int; } type res = | Res : 'a QCheck2.Test.cell * 'a QCheck2.TestResult.t -> res type handler = { handler : 'a. 'a QCheck2.Test.handler; } type handler_gen = colors:bool -> debug_shrink:(out_channel option) -> debug_shrink_list:(string list) -> size:int -> out:out_channel -> verbose:bool -> counter -> handler let pp_counter ~size out c = let t = Unix.gettimeofday () -. c.start in Printf.fprintf out "%*d %*d %*d %*d / %*d %7.1fs" size c.gen size c.errored size c.failed size c.passed size c.expected t let debug_shrinking_counter_example cell out x = match QCheck2.Test.get_print_opt cell with | None -> Printf.fprintf out "" | Some print -> Printf.fprintf out "%s" (print x) let debug_shrinking_choices ~colors ~out ~name cell ~step x = Printf.fprintf out "\n~~~ %a %s\n\n" (Color.pp_str_c ~colors `Cyan) "Shrink" (String.make 69 '~'); Printf.fprintf out "Test %s successfully shrunk counter example (step %d) to:\n\n%a\n%!" name step (debug_shrinking_counter_example cell) x let default_handler ~colors ~debug_shrink ~debug_shrink_list ~size ~out ~verbose c = let handler name cell r = let st = function | QCheck2.Test.Generating -> "generating" | QCheck2.Test.Collecting _ -> "collecting" | QCheck2.Test.Testing _ -> " testing" | QCheck2.Test.Shrunk (i, _) -> Printf.sprintf "shrinking: %4d" i | QCheck2.Test.Shrinking (i, j, _) -> Printf.sprintf "shrinking: %4d.%04d" i j in (* debug shrinking choices *) begin match r with | QCheck2.Test.Shrunk (step, x) -> begin match debug_shrink with | None -> () | Some out -> let go = match debug_shrink_list with | [] -> true | test_list -> List.mem name test_list in if not go then () else debug_shrinking_choices ~colors ~out ~name cell ~step x end | _ -> () end; (* use timestamps for rate-limiting *) let now=Unix.gettimeofday() in if verbose && now -. !last_msg > get_time_between_msg () then ( last_msg := now; Printf.fprintf out "%s[ ] %a %s (%s)%!" (if colors then Color.reset_line else "\n") (pp_counter ~size) c name (st r) ) in { handler; } let step ~colors ~size ~out ~verbose c name _ _ r = let aux = function | QCheck2.Test.Success -> c.passed <- c.passed + 1 | QCheck2.Test.Failure -> c.failed <- c.failed + 1 | QCheck2.Test.FalseAssumption -> () | QCheck2.Test.Error _ -> c.errored <- c.errored + 1 in c.gen <- c.gen + 1; aux r; let now=Unix.gettimeofday() in if verbose && now -. !last_msg > get_time_between_msg () then ( last_msg := now; Printf.fprintf out "%s[ ] %a %s%!" (if colors then Color.reset_line else "\n") (pp_counter ~size) c name ) let callback ~size ~out ~verbose ~colors c name cell r = let pass = if QCheck2.Test.get_positive cell then QCheck2.TestResult.is_success r else QCheck2.TestResult.is_failed r in let color = if pass then `Green else `Red in if verbose then ( Printf.fprintf out "%s[%a] %a %s\n%!" (if colors then Color.reset_line else "\n") (Color.pp_str_c ~bold:true ~colors color) (if pass then "✓" else "✗") (pp_counter ~size) c name ) let print_inst cell x = match QCheck2.Test.get_print_opt cell with | Some f -> f x | None -> "" let expect long cell = let count = QCheck2.Test.get_count cell in if long then QCheck2.Test.get_long_factor cell * count else count let expect_size long cell = let rec aux n = if n < 10 then 1 else 1 + (aux (n / 10)) in aux (expect long cell) (* print user messages for a test *) let print_messages ~colors out cell l = if l<>[] then ( Printf.fprintf out "\n+++ %a %s\n\nMessages for test %s:\n\n%!" (Color.pp_str_c ~colors `Blue) "Messages" (String.make 68 '+') (QCheck2.Test.get_name cell); List.iter (Printf.fprintf out "%s\n%!") l ) let print_success ~colors out cell r = begin match QCheck2.TestResult.collect r with | None -> () | Some tbl -> Printf.fprintf out "\n+++ %a %s\n\nCollect results for test %s:\n\n%s%!" (Color.pp_str_c ~colors `Blue) "Collect" (String.make 68 '+') (QCheck2.Test.get_name cell) (QCheck2.Test.print_collect tbl) end; List.iter (fun msg -> Printf.fprintf out "\n!!! %a %s\n\nWarning for test %s:\n\n%s%!" (Color.pp_str_c ~colors `Yellow) "Warning" (String.make 68 '!') (QCheck2.Test.get_name cell) msg) (QCheck2.TestResult.warnings r); if QCheck2.TestResult.stats r <> [] then Printf.fprintf out "\n+++ %a %s\n%!" (Color.pp_str_c ~colors `Blue) ("Stats for " ^ QCheck2.Test.get_name cell) (String.make 56 '+'); List.iter (fun st -> Printf.fprintf out "\n%s%!" (QCheck2.Test.print_stat st)) (QCheck2.TestResult.stats r); () let print_fail ~colors out cell c_ex = Printf.fprintf out "\n--- %a %s\n\n" (Color.pp_str_c ~colors `Red) "Failure" (String.make 68 '-'); Printf.fprintf out "Test %s failed (%d shrink steps):\n\n%s\n%!" (QCheck2.Test.get_name cell) c_ex.QCheck2.TestResult.shrink_steps (print_inst cell c_ex.QCheck2.TestResult.instance); print_messages ~colors out cell c_ex.QCheck2.TestResult.msg_l let print_fail_other ~colors out cell msg = Printf.fprintf out "\n--- %a %s\n\n" (Color.pp_str_c ~colors `Red) "Failure" (String.make 68 '-'); Printf.fprintf out "Test %s failed:\n\n%s\n%!" (QCheck2.Test.get_name cell) msg let print_expected_failure ~colors out cell c_ex = Printf.fprintf out "\n--- %a %s\n\n" (Color.pp_str_c ~colors `Blue) "Info" (String.make 71 '-'); Printf.fprintf out "Negative test %s failed as expected (%d shrink steps):\n\n%s\n%!" (QCheck2.Test.get_name cell) c_ex.QCheck2.TestResult.shrink_steps (print_inst cell c_ex.QCheck2.TestResult.instance); print_messages ~colors out cell c_ex.QCheck2.TestResult.msg_l let print_error ~colors out cell c_ex exn bt = Printf.fprintf out "\n=== %a %s\n\n" (Color.pp_str_c ~colors `Red) "Error" (String.make 70 '='); Printf.fprintf out "Test %s errored on (%d shrink steps):\n\n%s\n\nexception %s\n%s\n%!" (QCheck2.Test.get_name cell) c_ex.QCheck2.TestResult.shrink_steps (print_inst cell c_ex.QCheck2.TestResult.instance) (Printexc.to_string exn) bt; print_messages ~colors out cell c_ex.QCheck2.TestResult.msg_l let run_tests ?(handler=default_handler) ?(colors=true) ?(verbose=verbose()) ?(long=long_tests()) ?(debug_shrink=debug_shrink()) ?(debug_shrink_list=debug_shrink_list()) ?(out=stdout) ?rand l = let rand = match rand with Some x -> x | None -> random_state_ ~colors () in let module T = QCheck2.Test in let module R = QCheck2.TestResult in let pp_color = Color.pp_str_c ~bold:true ~colors in let size = List.fold_left (fun acc (T.Test cell) -> max acc (expect_size long cell)) 4 l in if verbose then Printf.fprintf out "%*s %*s %*s %*s / %*s time test name\n%!" (size + 4) "generated" size "error" size "fail" size "pass" size "total"; let aux_map (T.Test cell) = let rand = Random.State.copy rand in let expected = expect long cell in let start = Unix.gettimeofday () in let c = { start; expected; gen = 0; passed = 0; failed = 0; errored = 0; } in if verbose then Printf.fprintf out "%s[ ] %a %s%!" (if colors then Color.reset_line else "") (pp_counter ~size) c (T.get_name cell); let r = QCheck2.Test.check_cell ~long ~rand ~handler:(handler ~colors ~debug_shrink ~debug_shrink_list ~size ~out ~verbose c).handler ~step:(step ~colors ~size ~out ~verbose c) ~call:(callback ~size ~out ~verbose ~colors c) cell in Res (cell, r) in let res = List.map aux_map l in let aux_fold (total, fail, error, warns) (Res (cell, r)) = let warns = warns + List.length (R.get_warnings r) in let acc = match R.get_state r, QCheck2.Test.get_positive cell with | R.Success, true -> print_success ~colors out cell r; (total + 1, fail, error, warns) | R.Success, false -> let msg = Printf.sprintf "Negative test %s succeeded but was expected to fail" (QCheck2.Test.get_name cell) in print_fail_other ~colors out cell msg; (total + 1, fail + 1, error, warns) | R.Failed {instances=l}, true -> List.iter (print_fail ~colors out cell) l; (total + 1, fail + 1, error, warns) | R.Failed {instances=l}, false -> if verbose then List.iter (print_expected_failure ~colors out cell) l; (total + 1, fail, error, warns) | R.Failed_other {msg}, _ -> (* Failed_other is also considered a failure *) print_fail_other ~colors out cell msg; (total + 1, fail + 1, error, warns) | R.Error {instance=c_ex; exn; backtrace=bt}, _ -> (* Error is always considered a failure *) print_error ~colors out cell c_ex exn bt; (total + 1, fail, error + 1, warns) in acc in let total, fail, error, warns = List.fold_left aux_fold (0, 0, 0,0) res in Printf.fprintf out "%s\n" (String.make 80 '='); if warns > 0 then Printf.fprintf out "%d warning(s)\n" warns; if fail = 0 && error = 0 then ( Printf.fprintf out "%a (ran %d tests)\n%!" (pp_color `Green) "success" total; 0 ) else ( Printf.fprintf out "%a (%d tests failed, %d tests errored, ran %d tests)\n%!" (pp_color `Red) "failure" fail error total; 1 ) let run_tests_main ?(argv=Sys.argv) l = try let cli_args = parse_cli ~full_options:false argv in exit (run_tests l ~colors:cli_args.cli_colors ~verbose:cli_args.cli_verbose ~long:cli_args.cli_long_tests ~out:stdout ~rand:cli_args.cli_rand) with | Arg.Bad msg -> print_endline msg; exit 1 | Arg.Help msg -> print_endline msg; exit 0 qcheck-0.25/src/runner/QCheck_base_runner.mli000066400000000000000000000166771477416744200212630ustar00rootroot00000000000000(* QCheck: Random testing for OCaml copyright (c) 2013-2017, Guillaume Bury, Simon Cruanes, Vincent Hugot, Jan Midtgaard all rights reserved. *) (** {1 Runners for Tests} Once you have built tests using {!QCheck.Test.make} or {!QCheck2.Test.make}, you need to run them. This module contains several {b runners}, which are designed to run every test and report the result. By default, you can use {!run_tests} in a test program as follows: {[ let testsuite = [ Test.make ...; Test.make ...; ] let () = let errcode = QCheck_base_runner.run_tests ~verbose:true testsuite in exit errcode ]} which will run the tests, and exit the program. The error code will be 0 if all tests pass, 1 otherwise. {!run_tests_main} can be used as a shortcut for that, also featuring command-line parsing (using [Arg]) to activate verbose mode and others. *) (** {2 State} *) val random_state : unit -> Random.State.t (** Access the current random state *) val verbose : unit -> bool (** Is the default mode verbose or quiet? *) val long_tests : unit -> bool (** Is the default mode to run long tests or nor? *) val set_seed : int -> unit (** Change the {!random_state} by creating a new one, initialized with the given seed. *) val set_verbose : bool -> unit (** Change the value of [verbose ()] *) val set_long_tests : bool -> unit (** Change the value of [long_tests ()] *) (** {2 Console message printing} In verbose mode, by default [QCheck_base_runner] prints frequent sub-second messages suitable for an interactive console test run. This behaviour can be changed by the environment variable [QCHECK_MSG_INTERVAL]. Intervals are given in seconds and can also be decimal numbers. For example, setting {[ QCHECK_MSG_INTERVAL=7.5 ]} will only print a console message every 7.5 seconds. This feature can be useful in a CI context, where updates are printed on consecutive lines and one may want to avoid overflowing the CI log files with too many lines. *) val get_time_between_msg : unit -> float (** Get the minimum time (in seconds) to wait between printing messages. @since 0.9 *) val set_time_between_msg : float -> unit (** Set the minimum time (in seconds) between messages. @since 0.9 *) (** {2 Event handlers} *) type counter = private { start : float; expected : int; mutable gen : int; mutable passed : int; mutable failed : int; mutable errored : int; } (** The type of counter used to keep tracks of the events received for a given test cell. *) type handler = { handler : 'a. 'a QCheck2.Test.handler; } (** A type to represent polymorphic-enough handlers for test cells. *) type handler_gen = colors:bool -> debug_shrink:(out_channel option) -> debug_shrink_list:(string list) -> size:int -> out:out_channel -> verbose:bool -> counter -> handler (** An alias type to a generator of handlers for test cells. *) val default_handler : handler_gen (** The default handler used. *) val debug_shrinking_choices: colors:bool -> out:out_channel -> name:string -> 'a QCheck2.Test.cell -> step:int -> 'a -> unit (** The function used by the default handler to debug shrinking choices. This can be useful to outside users trying to reproduce some of the base-runner behavior. @since 0.19 *) (** {2 Run a Suite of Tests and Get Results} *) val run_tests : ?handler:handler_gen -> ?colors:bool -> ?verbose:bool -> ?long:bool -> ?debug_shrink:(out_channel option) -> ?debug_shrink_list:(string list) -> ?out:out_channel -> ?rand:Random.State.t -> QCheck2.Test.t list -> int (** Run a suite of tests, and print its results. This is an heritage from the "qcheck" library. @return an error code, [0] if all tests passed, [1] otherwise. @param colors if true (default), colorful output @param verbose if true, prints more information about test cases (default: [false]) @param long if true, runs the long versions of the tests (default: [false]) @param debug_shrink [debug_shrink:(Some ch)] writes a log of successful shrink attempts to channel [ch], for example [~debug_shrink:(Some (open_out "mylog.txt"))]. Use together with a non-empty list in [~debug_shrink_list]. @param debug_shrink_list the test names to log successful shrink attempts for, for example [~debug_shrink_list:["list_rev_is_involutive"]]. Requires [~debug_shrink] to be [Some ch]. @param out print output to the provided channel (default: [stdout]) @param rand start the test runner in the provided RNG state *) val run_tests_main : ?argv:string array -> QCheck2.Test.t list -> 'a (** Can be used as the main function of a test file. Exits with a non-0 code if the tests fail. It refers to {!run_tests} for actually running tests after CLI options have been parsed. The available options are: - "--verbose" (or "-v") for activating verbose tests - "--seed " (or "-s ") for repeating a previous run by setting the random seed - "--long" for running the long versions of the tests Below is an example of the output of the [run_tests] and [run_tests_main] function: {v random seed: 438308050 generated error; fail; pass / total - time -- test name [✓] (1000) 0 ; 0 ; 1000 / 1000 -- 0.5s -- list_rev_is_involutive [✗] ( 1) 0 ; 1 ; 0 / 10 -- 0.0s -- should_fail_sort_id [✗] ( 1) 1 ; 0 ; 0 / 10 -- 0.0s -- should_error_raise_exn [✓] (1000) 0 ; 0 ; 1000 / 1000 -- 0.0s -- collect_results --- Failure -------------------------------------------------------------------- Test should_fail_sort_id failed (11 shrink steps): [1; 0] === Error ====================================================================== Test should_error_raise_exn errored on (62 shrink steps): 0 exception QCheck_runner_test.Error Raised at file "example/QCheck_runner_test.ml", line 20, characters 20-25 Called from file "src/QCheck.ml", line 839, characters 13-33 +++ Collect ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Collect results for test collect_results: 4: 207 cases 3: 190 cases 2: 219 cases 1: 196 cases 0: 188 cases ================================================================================ failure (1 tests failed, 1 tests errored, ran 4 tests) v} *) (** {2 Utils for colored output} *) module Color : sig type color = [ `Red | `Yellow | `Green | `Blue | `Normal | `Cyan ] val reset_line : string val pp_str_c : ?bold:bool -> colors:bool -> color -> out_channel -> string -> unit end (** {2 Internal Utils} We provide {b NO} stability guarantee for this module. Use at your own risks. *) module Raw : sig type ('b,'c) printer = { info: 'a. ('a,'b,'c,unit) format4 -> 'a; fail: 'a. ('a,'b,'c,unit) format4 -> 'a; err: 'a. ('a,'b,'c,unit) format4 -> 'a; } val print_std : (out_channel, unit) printer (* main callback for display *) val callback : colors:bool -> verbose:bool -> print_res:bool -> print:('a, 'b) printer -> string -> 'c QCheck2.Test.cell -> 'c QCheck2.TestResult.t -> unit type cli_args = { cli_verbose : bool; cli_long_tests : bool; cli_print_list : bool; cli_rand : Random.State.t; cli_slow_test : int; (* how many slow tests to display? *) cli_colors: bool; cli_debug_shrink : out_channel option; cli_debug_shrink_list : string list; } val parse_cli : full_options:bool -> string array -> cli_args end qcheck-0.25/src/runner/dune000066400000000000000000000002461477416744200156760ustar00rootroot00000000000000 (library (name qcheck_runner) (public_name qcheck-core.runner) (wrapped false) (libraries qcheck-core) (flags :standard -warn-error -a+8 -safe-string) ) qcheck-0.25/test/000077500000000000000000000000001477416744200136755ustar00rootroot00000000000000qcheck-0.25/test/core/000077500000000000000000000000001477416744200146255ustar00rootroot00000000000000qcheck-0.25/test/core/QCheck2_expect_test.expected.ocaml4.32000066400000000000000000003017671477416744200236160ustar00rootroot00000000000000random seed: 1234 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 (5,fun,0) (2,fun,16) (4,fun,1) (8,fun,7) (5,fun,1) (8,fun,4) (6,fun,3) (2,fun,3) (39,fun,5) (7,fun,1) (5,fun,0) (2,fun,16) (4,fun,1) (8,fun,7) (5,fun,1) (8,fun,4) (6,fun,3) (2,fun,3) (39,fun,5) (7,fun,1) (5,fun,0) (2,fun,16) (4,fun,1) (8,fun,7) (5,fun,1) (8,fun,4) (6,fun,3) (2,fun,3) (39,fun,5) (7,fun,1) (5,fun,0) (2,fun,16) (4,fun,1) (8,fun,7) (5,fun,1) (8,fun,4) (6,fun,3) (2,fun,3) (39,fun,5) (7,fun,1) (5,fun,0) (2,fun,16) (4,fun,1) (8,fun,7) (5,fun,1) (8,fun,4) (6,fun,3) (2,fun,3) (39,fun,5) (7,fun,1) (5,fun,0) (2,fun,16) (4,fun,1) (8,fun,7) (5,fun,1) (8,fun,4) (6,fun,3) (2,fun,3) (39,fun,5) (7,fun,1) (5,fun,0) (2,fun,16) (4,fun,1) (8,fun,7) (5,fun,1) (8,fun,4) (6,fun,3) (2,fun,3) (39,fun,5) (7,fun,1) (5,fun,0) (2,fun,16) (4,fun,1) (8,fun,7) (5,fun,1) (8,fun,4) (6,fun,3) (2,fun,3) (39,fun,5) (7,fun,1) 602816853 0 301408426 0 150704213 0 75352106 0 37676053 0 18838026 0 9419013 0 4709506 0 2354753 0 1177376 0 588688 0 294344 0 147172 0 73586 0 36793 0 18396 0 9198 0 4599 0 2299 0 1149 0 574 0 287 0 143 0 71 0 35 0 17 0 8 0 4 0 2 0 1 0 [0; 13; 4; 6; 14; 6; 47; 3; 4; 3; 6; 6; 9; 4; 3; 65; 2; 4; 55; 2; 4; 87; 9; 5; 35; 73; 9; 9; 2; 74; 5; 9; 10; 93; 2; 7; 1; 4; 6; 91; 8; 8; 2; 9; 47; 6; 26; 3; 60; 1; 0; 5; 26; 4; 28; 6; 0; 5; 88; 3; 7] [0; 13; 4; 6; 14; 6; 47; 3; 4; 3; 6; 6; 9; 4; 3; 65; 2; 4; 55; 2; 4; 87; 9; 5; 35; 73; 9; 9; 2; 74; 5] [0; 13; 4; 6; 14; 6; 47; 3; 4; 3; 6; 6; 9; 4; 3; 65] [0; 13; 4; 6; 14; 6; 47; 3] [0; 13; 4; 6] [0; 13] [13] [] [0] [0; 13; 4; 6; 14; 6; 47; 3; 4; 3; 6; 6; 9; 4; 3; 65; 2; 4; 55; 2; 4; 87; 9; 5; 35; 73; 9; 9; 2; 74; 5; 9; 10; 93; 2; 7; 1; 4; 6; 91; 8; 8; 2; 9; 47; 6; 26; 3; 60; 1; 0; 5; 26; 4; 28; 6; 0; 5; 88; 3; 7] [0; 13; 4; 6; 14; 6; 47; 3; 4; 3; 6; 6; 9; 4; 3; 65; 2; 4; 55; 2; 4; 87; 9; 5; 35; 73; 9; 9; 2; 74; 5] [0; 13; 4; 6; 14; 6; 47; 3; 4; 3; 6; 6; 9; 4; 3; 65] [0; 13; 4; 6; 14; 6; 47; 3] [0; 13; 4; 6] [14; 6; 47; 3] [13; 4; 6; 14; 6; 47; 3] [13; 4; 6; 14] [6; 47; 3] [4; 6; 14; 6; 47; 3] [4; 6; 14] [6; 47; 3] [6; 14; 6; 47; 3] [6; 14; 6] [14; 6] [6; 6] [6] [6] [0; 6] [3; 6] [5; 6] [6; 0] [6; 3] [6; 5] --- Failure -------------------------------------------------------------------- Test should_fail_sort_id failed (5 shrink steps): [1; 0] --- Failure -------------------------------------------------------------------- Test max_fail failed (3 shrink steps): [0; 1] --- Failure -------------------------------------------------------------------- Test max_fail failed (8 shrink steps): [0; 1] --- Failure -------------------------------------------------------------------- Test max_fail failed (8 shrink steps): [0; 1] === Error ====================================================================== Test should_error_raise_exn errored on (1 shrink steps): 0 exception QCheck2_tests.Overall.Error +++ Collect ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Collect results for test collect_results: 4: 20 cases 3: 25 cases 2: 17 cases 1: 18 cases 0: 20 cases +++ Stats for with_stats ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats mod4: num: 100, avg: 1.68, stddev: 1.09, median 2, min 0, max 3 0: ############################## 17 1: ################################################### 29 2: ######################################## 23 3: ####################################################### 31 stats num: num: 100, avg: 66.84, stddev: 31.94, median 65, min 2, max 120 2.. 7: ################## 3 8.. 13: ################## 3 14.. 19: 0 20.. 25: ########################################## 7 26.. 31: ######################## 4 32.. 37: ######################## 4 38.. 43: ################## 3 44.. 49: ################################################ 8 50.. 55: #################################### 6 56.. 61: #################################### 6 62.. 67: ####################################################### 9 68.. 73: ########################################## 7 74.. 79: ######################## 4 80.. 85: ################## 3 86.. 91: ############ 2 92.. 97: ########################################## 7 98..103: #################################### 6 104..109: #################################### 6 110..115: ####################################################### 9 116..121: ################## 3 --- Failure -------------------------------------------------------------------- Test with shrinking retries failed (0 shrink steps): 7 !!! Warning !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Warning for test WARN_unlikely_precond: WARNING: only 0.5% tests (of 2000) passed precondition for "WARN_unlikely_precond" NOTE: it is likely that the precondition is too strong, or that the generator is buggy. --- Failure -------------------------------------------------------------------- Test FAIL_unlikely_precond failed: ERROR: only 0.5% tests (of 2000) passed precondition for "FAIL_unlikely_precond" NOTE: it is likely that the precondition is too strong, or that the generator is buggy. --- Failure -------------------------------------------------------------------- Test FAIL_bad_gen failed: ERROR: uncaught exception in generator for test FAIL_bad_gen after 100 steps: Exception: Invalid_argument("Gen.int_bound") Backtrace: --- Failure -------------------------------------------------------------------- Test int double failed: Negative test int double succeeded but was expected to fail === Error ====================================================================== Test pos fail with error errored on (1 shrink steps): 0 exception QCheck2_tests.Overall.Error === Error ====================================================================== Test neg fail with error errored on (1 shrink steps): 0 exception QCheck2_tests.Overall.Error --- Failure -------------------------------------------------------------------- Test char never produces '\255' failed (0 shrink steps): '\255' --- Failure -------------------------------------------------------------------- Test big bound issue59 failed (0 shrink steps): 1073741823 --- Failure -------------------------------------------------------------------- Test long_shrink failed (3053 shrink steps): ([0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0], [0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 1]) --- Failure -------------------------------------------------------------------- Test ints arent 0 mod 3 failed (1 shrink steps): 0 --- Failure -------------------------------------------------------------------- Test ints are 0 failed (29 shrink steps): 1 --- Failure -------------------------------------------------------------------- Test int32s arent 0l rem 3l failed (1 shrink steps): 0l --- Failure -------------------------------------------------------------------- Test int32s are 0l failed (30 shrink steps): -1l --- Failure -------------------------------------------------------------------- Test int64s arent 0L rem 3L failed (1 shrink steps): 0L --- Failure -------------------------------------------------------------------- Test int64s are 0L failed (62 shrink steps): -1L --- Failure -------------------------------------------------------------------- Test ints < 209609 failed (0 shrink steps): 1073741823 --- Failure -------------------------------------------------------------------- Test nat < 5001 failed (7 shrink steps): 5001 --- Failure -------------------------------------------------------------------- Test char never produces 'abcdef' failed (1 shrink steps): 'a' --- Failure -------------------------------------------------------------------- Test printable never produces '!"#$%&' failed (1 shrink steps): '!' --- Failure -------------------------------------------------------------------- Test printable never produces less than '5 failed (1 shrink steps): '0' --- Failure -------------------------------------------------------------------- Test bytes are empty failed (7 shrink steps): "a" --- Failure -------------------------------------------------------------------- Test bytes never has a \000 char failed (13 shrink steps): "\000" --- Failure -------------------------------------------------------------------- Test bytes never has a \255 char failed (6 shrink steps): "\255" --- Failure -------------------------------------------------------------------- Test bytes have unique chars failed (13 shrink steps): "**" --- Failure -------------------------------------------------------------------- Test strings are empty failed (7 shrink steps): "a" --- Failure -------------------------------------------------------------------- Test string never has a \000 char failed (13 shrink steps): "\000" --- Failure -------------------------------------------------------------------- Test string never has a \255 char failed (6 shrink steps): "\255" --- Failure -------------------------------------------------------------------- Test strings have unique chars failed (13 shrink steps): "**" --- Failure -------------------------------------------------------------------- Test pairs have different components failed (0 shrink steps): (3, 3) --- Failure -------------------------------------------------------------------- Test pairs have same components failed (31 shrink steps): (0, 1) --- Failure -------------------------------------------------------------------- Test pairs have a zero component failed (58 shrink steps): (1, 1) --- Failure -------------------------------------------------------------------- Test pairs are (0,0) failed (31 shrink steps): (0, 1) --- Failure -------------------------------------------------------------------- Test pairs are ordered failed (39 shrink steps): (1, 0) --- Failure -------------------------------------------------------------------- Test pairs are ordered reversely failed (30 shrink steps): (0, 1) --- Failure -------------------------------------------------------------------- Test pairs sum to less than 128 failed (26 shrink steps): (0, 128) --- Failure -------------------------------------------------------------------- Test pairs lists rev concat failed (30 shrink steps): ([0], [1]) --- Failure -------------------------------------------------------------------- Test pairs lists no overlap failed (13 shrink steps): ([0], [0]) --- Failure -------------------------------------------------------------------- Test triples have pair-wise different components failed (2 shrink steps): (0, 0, 0) --- Failure -------------------------------------------------------------------- Test triples have same components failed (33 shrink steps): (0, 1, 0) --- Failure -------------------------------------------------------------------- Test triples are ordered failed (4 shrink steps): (0, 0, -1) --- Failure -------------------------------------------------------------------- Test triples are ordered reversely failed (61 shrink steps): (0, 0, 1) --- Failure -------------------------------------------------------------------- Test quadruples have pair-wise different components failed (3 shrink steps): (0, 0, 0, 0) --- Failure -------------------------------------------------------------------- Test quadruples have same components failed (61 shrink steps): (0, 1, 0, 1) --- Failure -------------------------------------------------------------------- Test quadruples are ordered failed (5 shrink steps): (0, 0, 0, -1) --- Failure -------------------------------------------------------------------- Test quadruples are ordered reversely failed (62 shrink steps): (0, 0, 0, 1) --- Failure -------------------------------------------------------------------- Test forall (a, b) in nat: a < b failed (1 shrink steps): (0, 0) --- Failure -------------------------------------------------------------------- Test forall (a, b, c) in nat: a < b < c failed (2 shrink steps): (0, 0, 0) --- Failure -------------------------------------------------------------------- Test forall (a, b, c, d) in nat: a < b < c < d failed (3 shrink steps): (0, 0, 0, 0) --- Failure -------------------------------------------------------------------- Test forall (a, b, c, d, e) in nat: a < b < c < d < e failed (4 shrink steps): (0, 0, 0, 0, 0) --- Failure -------------------------------------------------------------------- Test forall (a, b, c, d, e, f) in nat: a < b < c < d < e < f failed (5 shrink steps): (0, 0, 0, 0, 0, 0) --- Failure -------------------------------------------------------------------- Test forall (a, b, c, d, e, f, g) in nat: a < b < c < d < e < f < g failed (6 shrink steps): (0, 0, 0, 0, 0, 0, 0) --- Failure -------------------------------------------------------------------- Test forall (a, b, c, d, e, f, g, h) in nat: a < b < c < d < e < f < g < h failed (7 shrink steps): (0, 0, 0, 0, 0, 0, 0, 0) --- Failure -------------------------------------------------------------------- Test forall (a, b, c, d, e, f, g, h, i) in nat: a < b < c < d < e < f < g < h < i failed (8 shrink steps): (0, 0, 0, 0, 0, 0, 0, 0, 0) --- Failure -------------------------------------------------------------------- Test bind ordered pairs failed (1 shrink steps): (0, 0) --- Failure -------------------------------------------------------------------- Test bind list_size constant failed (12 shrink steps): (4, [0; 0; 0; 0]) --- Failure -------------------------------------------------------------------- Test lists are empty failed (7 shrink steps): [0] --- Failure -------------------------------------------------------------------- Test lists shorter than 10 failed (18 shrink steps): [0; 0; 0; 0; 0; 0; 0; 0; 0; 0] --- Failure -------------------------------------------------------------------- Test lists shorter than 432 failed (403 shrink steps): [...] list length: 432 --- Failure -------------------------------------------------------------------- Test lists shorter than 4332 failed (4022 shrink steps): [...] list length: 4332 --- Failure -------------------------------------------------------------------- Test lists have unique elems failed (8 shrink steps): [6; 6] --- Failure -------------------------------------------------------------------- Test int option are none failed (1 shrink steps): Some (0) --- Failure -------------------------------------------------------------------- Test int option are some 100 or more failed (1 shrink steps): None --- Failure -------------------------------------------------------------------- Test (int,string) result are Ok failed (4 shrink steps): Error ("") --- Failure -------------------------------------------------------------------- Test (int,string) result are Error failed (1 shrink steps): Ok (0) --- Failure -------------------------------------------------------------------- Test tree contains only 42 failed (1 shrink steps): Leaf 0 --- Failure -------------------------------------------------------------------- Test sum list = 0 failed (0 shrink steps): [0; 13; 4; 6; 14; 6; 47; 3; 4; 3; 6; 6; 9; 4; 3; 65; 2; 4; 55; 2; 4; 87; 9; 5; 35; 73; 9; 9; 2; 74; 5; 9; 10; 93; 2; 7; 1; 4; 6; 91; 8; 8; 2; 9; 47; 6; 26; 3; 60; 1; 0; 5; 26; 4; 28; 6; 0; 5; 88; 3; 7] --- Failure -------------------------------------------------------------------- Test fail_pred_map_commute_int failed (55 shrink steps): ([0], {0 -> 5; _ -> 0}, {5 -> true; _ -> false}) --- Failure -------------------------------------------------------------------- Test fail_pred_map_commute_int32 failed (57 shrink steps): ([0l], {0l -> -15l; _ -> 0l}, {-15l -> true; _ -> false}) --- Failure -------------------------------------------------------------------- Test fail_pred_map_commute_int64 failed (107 shrink steps): ([0L], {0L -> -71L; _ -> 0L}, {-71L -> true; _ -> false}) --- Failure -------------------------------------------------------------------- Test fail_pred_strings failed (1 shrink steps): {"some random string" -> true; _ -> false} --- Failure -------------------------------------------------------------------- Test fold_left fold_right failed (20 shrink steps): (0, [1], {(0, 1) -> 1; _ -> 0}) +++ Messages ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Messages for test fold_left fold_right: l=[1], fold_left=0, fold_right=1 --- Failure -------------------------------------------------------------------- Test fold_left fold_right uncurried failed (17 shrink steps): ({(9, 6) -> 0; (1, 5) -> 0; (4, 8) -> 0; (9, 8) -> 1; _ -> 0}, 8, [9]) --- Failure -------------------------------------------------------------------- Test fold_left fold_right uncurried fun last failed (48 shrink steps): (0, [0; 1], {(0, 0) -> 1; _ -> 0}) --- Failure -------------------------------------------------------------------- Test fold_left test, fun first failed (87 shrink steps): ({("\188Bt\000", 9) -> ""; ("8\252D", 2) -> ""; ("\241\223v\190~>", 6) -> "a"; ("\252R\2108,\226\019\006\t", 2) -> ""; ("\154\241\031\198W\176\ng\150\002\213\197\026\221z\019\151", 0) -> ""; ("1\015\255", 46) -> "a"; ("\177W\174", 8) -> ""; ("\0140WD\024%\195\145\176\200\023\185\138\247\193\172[+\237\186LT\158\208y|\223\231\192\012#\144c\016", 66) -> ""; ("Z}(:?\216", 4) -> ""; ("", 13) -> "a"; ("", 9) -> ""; ("\144\189\"\030E\183\024h\023", 8) -> ""; ("\147\172\209U\252\209\bM&\175m\005\250N[p\180\204jh\217$I\208\002H\168[F\174\145\190b\151w\174\177Ib|\022\149\224\140\250E\239\216g\249\137\246\252\229\192\136\249\131\182&\127\173\015\147H\240\201\166\163\163\239\196", 29) -> ""; ("B\012\251", 1) -> "a"; ("\140", 9) -> ""; ("@\131}\002uPha\151\245\224\240\148ad\191", 7) -> ""; _ -> ""}, "", [0; 13], [0]) --- Failure -------------------------------------------------------------------- Test FAIL_#99_1 failed: ERROR: uncaught exception in generator for test FAIL_#99_1 after 100 steps: Exception: QCheck2.No_example_found("") Backtrace: +++ Collect ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Collect results for test bool dist: true: 250134 cases false: 249866 cases +++ Stats for char code dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats char code: num: 500000, avg: 127.42, stddev: 73.92, median 127, min 0, max 255 0.. 12: ###################################################### 25509 13.. 25: ###################################################### 25398 26.. 38: ###################################################### 25293 39.. 51: ###################################################### 25448 52.. 64: ###################################################### 25392 65.. 77: ####################################################### 25660 78.. 90: ###################################################### 25462 91..103: ###################################################### 25331 104..116: ##################################################### 25129 117..129: ###################################################### 25351 130..142: ###################################################### 25492 143..155: ###################################################### 25370 156..168: ###################################################### 25658 169..181: ###################################################### 25400 182..194: ##################################################### 25167 195..207: ###################################################### 25338 208..220: ##################################################### 25181 221..233: ##################################################### 25145 234..246: ###################################################### 25567 247..259: ##################################### 17709 +++ Stats for printable char code dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats char code: num: 500000, avg: 78.26, stddev: 28.15, median 78, min 10, max 126 10.. 15: ######### 5149 16.. 21: 0 22.. 27: 0 28.. 33: ################## 10379 34.. 39: ###################################################### 31153 40.. 45: ###################################################### 31341 46.. 51: ###################################################### 31408 52.. 57: ####################################################### 31456 58.. 63: ###################################################### 31310 64.. 69: ###################################################### 31152 70.. 75: ###################################################### 31308 76.. 81: ###################################################### 31156 82.. 87: ###################################################### 31170 88.. 93: ###################################################### 31286 94.. 99: ###################################################### 31364 100..105: ###################################################### 31368 106..111: ###################################################### 31024 112..117: ###################################################### 31261 118..123: ###################################################### 31064 124..129: ########################### 15651 +++ Stats for numeral char code dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats char code: num: 500000, avg: 52.50, stddev: 2.87, median 52, min 48, max 57 48: ###################################################### 50260 49: ###################################################### 49590 50: ###################################################### 50170 51: ####################################################### 50270 52: ###################################################### 49805 53: ###################################################### 50161 54: ###################################################### 49919 55: ###################################################### 49971 56: ###################################################### 49980 57: ###################################################### 49874 +++ Stats for tree's depth ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats depth: num: 1000, avg: 3.97, stddev: 3.35, median 3, min 1, max 15 1: ####################################################### 356 2: ############## 91 3: ############### 98 4: ################### 129 5: ############ 78 6: #### 31 7: ####### 47 8: ######## 53 9: # 12 10: #### 27 11: ######## 55 12: 3 13: # 8 14: # 9 15: 3 +++ Stats for bytes_size len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 7.53, stddev: 1.71, median 8, min 5, max 10 5: #################################################### 814 6: #################################################### 809 7: ##################################################### 830 8: ###################################################### 845 9: ####################################################### 854 10: ###################################################### 848 +++ Stats for bytes len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 327.56, stddev: 1159.62, median 9, min 0, max 9916 0.. 495: ####################################################### 4285 496.. 991: ###### 509 992..1487: 21 1488..1983: 13 1984..2479: 13 2480..2975: 13 2976..3471: 10 3472..3967: 13 3968..4463: 10 4464..4959: 12 4960..5455: 7 5456..5951: 12 5952..6447: 11 6448..6943: 7 6944..7439: 9 7440..7935: 6 7936..8431: 16 8432..8927: 9 8928..9423: 13 9424..9919: 11 +++ Stats for bytes_of len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 327.56, stddev: 1159.62, median 9, min 0, max 9916 0.. 495: ####################################################### 4285 496.. 991: ###### 509 992..1487: 21 1488..1983: 13 1984..2479: 13 2480..2975: 13 2976..3471: 10 3472..3967: 13 3968..4463: 10 4464..4959: 12 4960..5455: 7 5456..5951: 12 5952..6447: 11 6448..6943: 7 6944..7439: 9 7440..7935: 6 7936..8431: 16 8432..8927: 9 8928..9423: 13 9424..9919: 11 +++ Stats for bytes_printable len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 327.56, stddev: 1159.62, median 9, min 0, max 9916 0.. 495: ####################################################### 4285 496.. 991: ###### 509 992..1487: 21 1488..1983: 13 1984..2479: 13 2480..2975: 13 2976..3471: 10 3472..3967: 13 3968..4463: 10 4464..4959: 12 4960..5455: 7 5456..5951: 12 5952..6447: 11 6448..6943: 7 6944..7439: 9 7440..7935: 6 7936..8431: 16 8432..8927: 9 8928..9423: 13 9424..9919: 11 +++ Stats for bytes_small len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 15.47, stddev: 24.03, median 6, min 0, max 99 0.. 4: ####################################################### 1958 5.. 9: ##################################################### 1914 10.. 14: # 64 15.. 19: ## 75 20.. 24: # 64 25.. 29: # 71 30.. 34: ## 74 35.. 39: # 60 40.. 44: # 61 45.. 49: # 57 50.. 54: # 62 55.. 59: # 58 60.. 64: # 63 65.. 69: # 46 70.. 74: # 67 75.. 79: # 62 80.. 84: # 57 85.. 89: # 67 90.. 94: # 66 95.. 99: # 54 +++ Stats for string_size len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 7.53, stddev: 1.71, median 8, min 5, max 10 5: #################################################### 814 6: #################################################### 809 7: ##################################################### 830 8: ###################################################### 845 9: ####################################################### 854 10: ###################################################### 848 +++ Stats for string len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 327.56, stddev: 1159.62, median 9, min 0, max 9916 0.. 495: ####################################################### 4285 496.. 991: ###### 509 992..1487: 21 1488..1983: 13 1984..2479: 13 2480..2975: 13 2976..3471: 10 3472..3967: 13 3968..4463: 10 4464..4959: 12 4960..5455: 7 5456..5951: 12 5952..6447: 11 6448..6943: 7 6944..7439: 9 7440..7935: 6 7936..8431: 16 8432..8927: 9 8928..9423: 13 9424..9919: 11 +++ Stats for string_of len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 327.56, stddev: 1159.62, median 9, min 0, max 9916 0.. 495: ####################################################### 4285 496.. 991: ###### 509 992..1487: 21 1488..1983: 13 1984..2479: 13 2480..2975: 13 2976..3471: 10 3472..3967: 13 3968..4463: 10 4464..4959: 12 4960..5455: 7 5456..5951: 12 5952..6447: 11 6448..6943: 7 6944..7439: 9 7440..7935: 6 7936..8431: 16 8432..8927: 9 8928..9423: 13 9424..9919: 11 +++ Stats for string_printable len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 327.56, stddev: 1159.62, median 9, min 0, max 9916 0.. 495: ####################################################### 4285 496.. 991: ###### 509 992..1487: 21 1488..1983: 13 1984..2479: 13 2480..2975: 13 2976..3471: 10 3472..3967: 13 3968..4463: 10 4464..4959: 12 4960..5455: 7 5456..5951: 12 5952..6447: 11 6448..6943: 7 6944..7439: 9 7440..7935: 6 7936..8431: 16 8432..8927: 9 8928..9423: 13 9424..9919: 11 +++ Stats for small_string len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 15.47, stddev: 24.03, median 6, min 0, max 99 0.. 4: ####################################################### 1958 5.. 9: ##################################################### 1914 10.. 14: # 64 15.. 19: ## 75 20.. 24: # 64 25.. 29: # 71 30.. 34: ## 74 35.. 39: # 60 40.. 44: # 61 45.. 49: # 57 50.. 54: # 62 55.. 59: # 58 60.. 64: # 63 65.. 69: # 46 70.. 74: # 67 75.. 79: # 62 80.. 84: # 57 85.. 89: # 67 90.. 94: # 66 95.. 99: # 54 +++ Stats for pair dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats pair sum: num: 500000, avg: 100.09, stddev: 41.23, median 100, min 0, max 200 0.. 9: ### 2599 10.. 19: ######## 7571 20.. 29: ############## 12587 30.. 39: #################### 17235 40.. 49: ########################## 22334 50.. 59: ############################### 27179 60.. 69: ##################################### 32092 70.. 79: ########################################### 37071 80.. 89: ################################################ 41592 90.. 99: ###################################################### 46677 100..109: ####################################################### 47155 110..119: ################################################# 42772 120..129: ########################################### 37679 130..139: ###################################### 32681 140..149: ################################ 27465 150..159: ########################## 23061 160..169: #################### 17923 170..179: ############### 12910 180..189: ######### 8135 190..199: ### 3233 200..209: 49 +++ Stats for triple dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats triple sum: num: 500000, avg: 149.91, stddev: 50.48, median 150, min 1, max 299 1.. 15: 404 16.. 30: ## 2212 31.. 45: ##### 5889 46.. 60: ########## 10700 61.. 75: ################# 17772 76.. 90: ######################### 26105 91..105: ################################### 36005 106..120: ############################################# 45660 121..135: ################################################### 52122 136..150: ####################################################### 55483 151..165: ###################################################### 54945 166..180: ################################################### 51868 181..195: ############################################ 45051 196..210: ################################## 35080 211..225: ######################### 25470 226..240: ################ 16973 241..255: ########## 10427 256..270: ##### 5344 271..285: ## 2133 286..300: 357 +++ Stats for quad dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats quad sum: num: 500000, avg: 199.94, stddev: 58.37, median 200, min 5, max 394 5.. 24: 105 25.. 44: 829 45.. 64: ## 2997 65.. 84: ###### 7402 85..104: ############ 14559 105..124: ##################### 25103 125..144: ################################ 38055 145..164: ########################################## 50469 165..184: ################################################## 60434 185..204: ####################################################### 65242 205..224: ##################################################### 63665 225..244: ############################################### 55764 245..264: ###################################### 45244 265..284: ########################## 31847 285..304: ################ 20092 305..324: ######### 11027 325..344: #### 5011 345..364: # 1794 365..384: 348 385..404: 13 +++ Stats for bind dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats ordered pair difference: num: 1000000, avg: 25.02, stddev: 22.38, median 19, min 0, max 100 0.. 4: ####################################################### 193818 5.. 9: #################################### 129891 10.. 14: ############################# 103378 15.. 19: ######################## 87043 20.. 24: ##################### 75202 25.. 29: ################## 64688 30.. 34: ################ 56523 35.. 39: ############# 49283 40.. 44: ############ 42859 45.. 49: ########## 37336 50.. 54: ######### 32591 55.. 59: ######## 28285 60.. 64: ###### 24255 65.. 69: ##### 20314 70.. 74: #### 16733 75.. 79: ### 13555 80.. 84: ## 10170 85.. 89: ## 7255 90.. 94: # 4729 95.. 99: 1992 100..104: 100 stats ordered pair sum: num: 1000000, avg: 75.04, stddev: 46.91, median 72, min 0, max 200 0.. 9: ####################################################### 70296 10.. 19: ##################################################### 68918 20.. 29: ##################################################### 68448 30.. 39: ##################################################### 68654 40.. 49: ##################################################### 68490 50.. 59: ##################################################### 68513 60.. 69: ##################################################### 68299 70.. 79: ##################################################### 68552 80.. 89: ##################################################### 68560 90.. 99: ###################################################### 69283 100..109: ################################################## 64173 110..119: ########################################### 55624 120..129: ##################################### 47381 130..139: ############################## 39552 140..149: ######################### 32856 150..159: #################### 26038 160..169: ############### 20035 170..179: ########### 14164 180..189: ###### 8568 190..199: ## 3515 200..209: 81 +++ Collect ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Collect results for test option dist: None : 1519 cases Some _: 8481 cases +++ Collect ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Collect results for test result dist: Error _: 2577 cases Ok _ : 7423 cases +++ Stats for list len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 327.56, stddev: 1159.62, median 9, min 0, max 9916 0.. 495: ####################################################### 4285 496.. 991: ###### 509 992..1487: 21 1488..1983: 13 1984..2479: 13 2480..2975: 13 2976..3471: 10 3472..3967: 13 3968..4463: 10 4464..4959: 12 4960..5455: 7 5456..5951: 12 5952..6447: 11 6448..6943: 7 6944..7439: 9 7440..7935: 6 7936..8431: 16 8432..8927: 9 8928..9423: 13 9424..9919: 11 +++ Stats for small_list len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 15.47, stddev: 24.03, median 6, min 0, max 99 0.. 4: ####################################################### 1958 5.. 9: ##################################################### 1914 10.. 14: # 64 15.. 19: ## 75 20.. 24: # 64 25.. 29: # 71 30.. 34: ## 74 35.. 39: # 60 40.. 44: # 61 45.. 49: # 57 50.. 54: # 62 55.. 59: # 58 60.. 64: # 63 65.. 69: # 46 70.. 74: # 67 75.. 79: # 62 80.. 84: # 57 85.. 89: # 67 90.. 94: # 66 95.. 99: # 54 +++ Stats for list_size len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 7.53, stddev: 1.71, median 8, min 5, max 10 5: #################################################### 814 6: #################################################### 809 7: ##################################################### 830 8: ###################################################### 845 9: ####################################################### 854 10: ###################################################### 848 +++ Stats for list_repeat len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 42.00, stddev: 0.00, median 42, min 42, max 42 42: ####################################################### 5000 +++ Stats for array len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 327.56, stddev: 1159.62, median 9, min 0, max 9916 0.. 495: ####################################################### 4285 496.. 991: ###### 509 992..1487: 21 1488..1983: 13 1984..2479: 13 2480..2975: 13 2976..3471: 10 3472..3967: 13 3968..4463: 10 4464..4959: 12 4960..5455: 7 5456..5951: 12 5952..6447: 11 6448..6943: 7 6944..7439: 9 7440..7935: 6 7936..8431: 16 8432..8927: 9 8928..9423: 13 9424..9919: 11 +++ Stats for small_array len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 15.47, stddev: 24.03, median 6, min 0, max 99 0.. 4: ####################################################### 1958 5.. 9: ##################################################### 1914 10.. 14: # 64 15.. 19: ## 75 20.. 24: # 64 25.. 29: # 71 30.. 34: ## 74 35.. 39: # 60 40.. 44: # 61 45.. 49: # 57 50.. 54: # 62 55.. 59: # 58 60.. 64: # 63 65.. 69: # 46 70.. 74: # 67 75.. 79: # 62 80.. 84: # 57 85.. 89: # 67 90.. 94: # 66 95.. 99: # 54 +++ Stats for array_size len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 7.53, stddev: 1.71, median 8, min 5, max 10 5: #################################################### 814 6: #################################################### 809 7: ##################################################### 830 8: ###################################################### 845 9: ####################################################### 854 10: ###################################################### 848 +++ Stats for array_repeat len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 42.00, stddev: 0.00, median 42, min 42, max 42 42: ####################################################### 5000 +++ Stats for int_stats_neg ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 5000, avg: 0.17, stddev: 29.68, median 0, min -99, max 99 -99..-90: # 65 -89..-80: # 63 -79..-70: # 64 -69..-60: # 58 -59..-50: # 67 -49..-40: # 72 -39..-30: # 61 -29..-20: # 61 -19..-10: # 67 -9.. 0: ####################################################### 2076 1.. 10: ############################################## 1764 11.. 20: # 66 21.. 30: # 64 31.. 40: # 64 41.. 50: # 67 51.. 60: # 60 61.. 70: # 75 71.. 80: # 60 81.. 90: # 60 91..100: # 66 +++ Stats for small_signed_int dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 0.90, stddev: 28.23, median 0, min -99, max 99 -99..-90: # 12 -89..-80: # 11 -79..-70: # 9 -69..-60: 6 -59..-50: # 11 -49..-40: # 13 -39..-30: # 9 -29..-20: # 13 -19..-10: 8 -9.. 0: ####################################################### 453 1.. 10: ######################################### 340 11.. 20: # 15 21.. 30: # 11 31.. 40: # 12 41.. 50: # 13 51.. 60: # 13 61.. 70: # 16 71.. 80: # 9 81.. 90: # 16 91..100: # 10 +++ Stats for small_nat dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 15.11, stddev: 23.27, median 6, min 0, max 99 0.. 4: #################################################### 377 5.. 9: ####################################################### 392 10.. 14: ## 20 15.. 19: ## 15 20.. 24: # 11 25.. 29: ## 17 30.. 34: ## 19 35.. 39: ## 17 40.. 44: # 10 45.. 49: # 9 50.. 54: # 8 55.. 59: # 9 60.. 64: ## 15 65.. 69: # 10 70.. 74: # 13 75.. 79: ## 19 80.. 84: # 11 85.. 89: # 13 90.. 94: 5 95.. 99: # 10 +++ Stats for nat dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 363.02, stddev: 1215.04, median 9, min 0, max 9476 0.. 473: ####################################################### 847 474.. 947: ###### 95 948..1421: 14 1422..1895: 3 1896..2369: 0 2370..2843: 3 2844..3317: 2 3318..3791: 3 3792..4265: 2 4266..4739: 4 4740..5213: 3 5214..5687: 4 5688..6161: 3 6162..6635: 4 6636..7109: 1 7110..7583: 4 7584..8057: 2 8058..8531: 1 8532..9005: 1 9006..9479: 4 +++ Stats for int_range (-43643) 435434 dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 195335.64, stddev: 136803.99, median 195583, min -43624, max 435210 -43624..-19683: ############################################ 52 -19682.. 4259: ######################################## 47 4260.. 28201: ############################## 36 28202.. 52143: ############################################ 52 52144.. 76085: ########################################## 50 76086..100027: ####################################################### 64 100028..123969: ############################################### 55 123970..147911: ######################################## 47 147912..171853: ############################################## 54 171854..195795: #################################### 43 195796..219737: ############################################## 54 219738..243679: ########################################### 51 243680..267621: ################################################ 57 267622..291563: ########################################## 49 291564..315505: #################################### 42 315506..339447: ###################################### 45 339448..363389: ################################################ 57 363390..387331: ###################################### 45 387332..411273: ########################################## 49 411274..435215: ########################################### 51 +++ Stats for int_range (-40000) 40000 dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: -173.78, stddev: 23042.92, median 180, min -39859, max 39942 -39859..-35869: ############################################# 56 -35868..-31878: ################################### 43 -31877..-27887: ################################################# 60 -27886..-23896: ##################################### 46 -23895..-19905: ######################################## 49 -19904..-15914: #################################### 45 -15913..-11923: ############################################ 54 -11922.. -7932: ############################################### 58 -7931.. -3941: ######################################### 51 -3940.. 50: ############################ 35 51.. 4041: ####################################### 48 4042.. 8032: ########################################## 52 8033.. 12023: ######################################### 51 12024.. 16014: ########################################### 53 16015.. 20005: ############################################ 54 20006.. 23996: ################################## 42 23997.. 27987: ####################################################### 67 27988.. 31978: ################################ 40 31979.. 35969: ######################################### 51 35970.. 39960: #################################### 45 +++ Stats for int_range (-4) 4 dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 0.02, stddev: 2.55, median 0, min -4, max 4 -4: ############################################ 99 -3: ##################################################### 118 -2: ################################################## 111 -1: ################################################## 113 0: ################################################## 113 1: ##################################################### 118 2: ############################################# 102 3: ####################################################### 122 4: ############################################## 104 +++ Stats for int_range (-4) 17 dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 6.67, stddev: 6.39, median 7, min -4, max 17 -4..-3: ############################################# 90 -2..-1: ############################################# 91 0.. 1: ########################################## 84 2.. 3: ############################################## 92 4.. 5: ########################################### 87 6.. 7: ########################################### 86 8.. 9: ############################################ 89 10..11: ########################################### 87 12..13: ####################################################### 110 14..15: ############################################# 91 16..17: ############################################## 93 18..19: 0 20..21: 0 22..23: 0 24..25: 0 26..27: 0 28..29: 0 30..31: 0 32..33: 0 34..35: 0 +++ Stats for int dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 100000, avg: -298652.90, stddev: 6.191e+8, median 419404, min -1073741519, max 1073728237 -1073741519.. -966368032: ##################################################### 4984 -966368031.. -858994544: ###################################################### 5025 -858994543.. -751621056: ###################################################### 5035 -751621055.. -644247568: #################################################### 4897 -644247567.. -536874080: ###################################################### 5025 -536874079.. -429500592: ##################################################### 4968 -429500591.. -322127104: ###################################################### 5029 -322127103.. -214753616: ##################################################### 5003 -214753615.. -107380128: ###################################################### 5022 -107380127.. -6640: ##################################################### 4987 -6639.. 107366848: ###################################################### 5062 107366849.. 214740336: ##################################################### 4954 214740337.. 322113824: ###################################################### 5062 322113825.. 429487312: #################################################### 4917 429487313.. 536860800: ###################################################### 5021 536860801.. 644234288: ####################################################### 5107 644234289.. 751607776: ###################################################### 5058 751607777.. 858981264: #################################################### 4918 858981265.. 966354752: ###################################################### 5026 966354753.. 1073728240: #################################################### 4900 +++ Stats for oneof int dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 1073741.63, stddev: 6.766e+8, median 0, min -1073741824, max 1073741823 -1073741824.. -966367642: ################## 208 -966367641.. -858993459: 0 -858993458.. -751619276: 0 -751619275.. -644245093: 0 -644245092.. -536870910: 0 -536870909.. -429496727: 0 -429496726.. -322122544: 0 -322122543.. -214748361: 0 -214748360.. -107374178: 0 -107374177.. 5: ####################################################### 603 6.. 107374188: 0 107374189.. 214748371: 0 214748372.. 322122554: 0 322122555.. 429496737: 0 429496738.. 536870920: 0 536870921.. 644245103: 0 644245104.. 751619286: 0 751619287.. 858993469: 0 858993470.. 966367652: 0 966367653.. 1073741823: ################# 189 +++ Stats for int32 lower dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 10000, avg: 32926.27, stddev: 18808.64, median 33297, min 0, max 65534 0.. 3276: ################################################ 481 3277.. 6553: ################################################## 497 6554.. 9830: ############################################### 469 9831..13107: #################################################### 515 13108..16384: ############################################### 470 16385..19661: ####################################################### 544 19662..22938: ################################################# 487 22939..26215: ################################################ 477 26216..29492: ################################################### 509 29493..32769: ############################################### 470 32770..36046: ################################################## 502 36047..39323: ##################################################### 530 39324..42600: ##################################################### 533 42601..45877: ##################################################### 525 45878..49154: ###################################################### 537 49155..52431: ################################################# 494 52432..55708: ############################################### 473 55709..58985: ################################################# 486 58986..62262: ################################################### 509 62263..65539: ################################################# 492 +++ Stats for int32 upper dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 10000, avg: 32678.65, stddev: 19067.06, median 32890, min 10, max 65523 10.. 3285: #################################################### 514 3286.. 6561: ################################################### 505 6562.. 9837: ####################################################### 541 9838..13113: ################################################# 491 13114..16389: ##################################################### 522 16390..19665: ################################################## 495 19666..22941: ############################################### 470 22942..26217: #################################################### 512 26218..29493: ############################################### 468 29494..32769: ############################################## 457 32770..36045: #################################################### 514 36046..39321: ############################################### 468 39322..42597: #################################################### 520 42598..45873: ################################################### 510 45874..49149: #################################################### 521 49150..52425: ############################################# 450 52426..55701: ##################################################### 526 55702..58977: ##################################################### 522 58978..62253: ################################################## 493 62254..65529: ################################################## 501 +++ Stats for int64 lower dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 10000, avg: 32767.87, stddev: 18950.16, median 33187, min 0, max 65532 0.. 3276: ################################################## 513 3277.. 6553: ################################################# 500 6554.. 9830: ################################################ 491 9831..13107: ################################################# 500 13108..16384: ################################################# 500 16385..19661: ################################################### 526 19662..22938: ################################################ 491 22939..26215: ############################################## 472 26216..29492: ################################################## 510 29493..32769: ########################################### 439 32770..36046: ################################################# 503 36047..39323: ################################################### 521 39324..42600: ################################################### 524 42601..45877: ############################################## 477 45878..49154: ####################################################### 560 49155..52431: ################################################# 506 52432..55708: ############################################### 482 55709..58985: ################################################ 492 58986..62262: ################################################ 496 62263..65539: ################################################ 497 +++ Stats for int64 lower-mid dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 10000, avg: 32779.13, stddev: 18897.20, median 32848, min 0, max 65535 0.. 3276: ############################################### 473 3277.. 6553: ################################################## 502 6554.. 9830: #################################################### 522 9831..13107: ################################################# 494 13108..16384: ##################################################### 535 16385..19661: ############################################### 471 19662..22938: ################################################# 495 22939..26215: #################################################### 522 26216..29492: ################################################ 489 29493..32769: ################################################ 487 32770..36046: ################################################# 493 36047..39323: ############################################### 476 39324..42600: ################################################# 494 42601..45877: ##################################################### 538 45878..49154: ####################################################### 550 49155..52431: ############################################### 479 52432..55708: ################################################### 513 55709..58985: ################################################ 487 58986..62262: ############################################### 470 62263..65539: ################################################### 510 +++ Stats for int64 upper-mid dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 10000, avg: 32833.01, stddev: 18869.35, median 32737, min 2, max 65534 2.. 3278: ################################################# 475 3279.. 6555: #################################################### 497 6556.. 9832: #################################################### 496 9833..13109: #################################################### 502 13110..16386: ###################################################### 514 16387..19663: ################################################### 492 19664..22940: #################################################### 501 22941..26217: ###################################################### 522 26218..29494: ##################################################### 505 29495..32771: #################################################### 502 32772..36048: ##################################################### 504 36049..39325: ###################################################### 519 39326..42602: ################################################# 469 42603..45879: ################################################### 493 45880..49156: ################################################### 491 49157..52433: #################################################### 498 52434..55710: #################################################### 495 55711..58987: ###################################################### 519 58988..62264: ####################################################### 523 62265..65541: ################################################## 483 +++ Stats for int64 upper dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 10000, avg: 32717.82, stddev: 19106.27, median 32768, min 2, max 65523 2.. 3278: ##################################################### 522 3279.. 6555: ###################################################### 530 6556.. 9832: #################################################### 510 9833..13109: ################################################# 484 13110..16386: ################################################# 488 16387..19663: ###################################################### 530 19664..22940: ################################################## 494 22941..26217: ################################################### 502 26218..29494: ################################################ 477 29495..32771: ############################################### 463 32772..36048: ############################################## 457 36049..39325: ################################################# 483 39326..42602: ##################################################### 521 42603..45879: #################################################### 519 45880..49156: ################################################# 485 49157..52433: ################################################ 476 52434..55710: #################################################### 510 55711..58987: ####################################################### 539 58988..62264: #################################################### 519 62265..65541: ################################################## 491 +++ Stats for exponential 10. dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 5000, avg: 9.56, stddev: 9.91, median 7, min 0, max 89 0.. 4: ####################################################### 1934 5.. 9: ################################## 1202 10.. 14: #################### 727 15.. 19: ############ 452 20.. 24: ######## 284 25.. 29: #### 164 30.. 34: ## 103 35.. 39: # 51 40.. 44: 26 45.. 49: 24 50.. 54: 15 55.. 59: 7 60.. 64: 3 65.. 69: 2 70.. 74: 2 75.. 79: 1 80.. 84: 1 85.. 89: 2 90.. 94: 0 95.. 99: 0 +++ Stats for exponential -10. dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 5000, avg: -9.56, stddev: 9.91, median -7, min -89, max 0 -89..-85: 2 -84..-80: 1 -79..-75: 1 -74..-70: 2 -69..-65: 2 -64..-60: 3 -59..-55: 7 -54..-50: 15 -49..-45: 24 -44..-40: 26 -39..-35: # 51 -34..-30: ## 103 -29..-25: #### 164 -24..-20: ######## 284 -19..-15: ############ 452 -14..-10: #################### 727 -9.. -5: ################################## 1202 -4.. 0: ####################################################### 1934 1.. 5: 0 6.. 10: 0 ================================================================================ 1 warning(s) failure (75 tests failed, 3 tests errored, ran 167 tests) random seed: 153870556 +++ Stats for int_dist_empty_bucket ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 2229293.51, stddev: 4.276e+8, median 9, min -1072726813, max 1073741823 -1072726813.. -965403382: ## 22 -965403381.. -858079950: ## 28 -858079949.. -750756518: # 17 -750756517.. -643433086: ### 32 -643433085.. -536109654: ## 22 -536109653.. -428786222: ## 25 -428786221.. -321462790: ## 20 -321462789.. -214139358: ## 23 -214139357.. -106815926: ## 26 -106815925.. 507506: ####################################################### 533 507507.. 107830938: ## 29 107830939.. 215154370: ## 25 215154371.. 322477802: ## 24 322477803.. 429801234: ## 25 429801235.. 537124666: ### 34 537124667.. 644448098: ## 20 644448099.. 751771530: ## 28 751771531.. 859094962: ## 23 859094963.. 966418394: ## 21 966418395.. 1073741823: ## 23 ================================================================================ success (ran 1 tests) qcheck-0.25/test/core/QCheck2_expect_test.expected.ocaml4.64000066400000000000000000003054341477416744200236160ustar00rootroot00000000000000random seed: 1234 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 (5,fun,0) (2,fun,16) (4,fun,1) (8,fun,7) (5,fun,1) (8,fun,4) (6,fun,3) (2,fun,3) (39,fun,5) (7,fun,1) (5,fun,0) (2,fun,16) (4,fun,1) (8,fun,7) (5,fun,1) (8,fun,4) (6,fun,3) (2,fun,3) (39,fun,5) (7,fun,1) (5,fun,0) (2,fun,16) (4,fun,1) (8,fun,7) (5,fun,1) (8,fun,4) (6,fun,3) (2,fun,3) (39,fun,5) (7,fun,1) (5,fun,0) (2,fun,16) (4,fun,1) (8,fun,7) (5,fun,1) (8,fun,4) (6,fun,3) (2,fun,3) (39,fun,5) (7,fun,1) (5,fun,0) (2,fun,16) (4,fun,1) (8,fun,7) (5,fun,1) (8,fun,4) (6,fun,3) (2,fun,3) (39,fun,5) (7,fun,1) (5,fun,0) (2,fun,16) (4,fun,1) (8,fun,7) (5,fun,1) (8,fun,4) (6,fun,3) (2,fun,3) (39,fun,5) (7,fun,1) (5,fun,0) (2,fun,16) (4,fun,1) (8,fun,7) (5,fun,1) (8,fun,4) (6,fun,3) (2,fun,3) (39,fun,5) (7,fun,1) (5,fun,0) (2,fun,16) (4,fun,1) (8,fun,7) (5,fun,1) (8,fun,4) (6,fun,3) (2,fun,3) (39,fun,5) (7,fun,1) 2007784939368327536 0 1003892469684163768 0 501946234842081884 0 250973117421040942 0 125486558710520471 0 62743279355260235 0 31371639677630117 0 15685819838815058 0 7842909919407529 0 3921454959703764 0 1960727479851882 0 980363739925941 0 490181869962970 0 245090934981485 0 122545467490742 0 61272733745371 0 30636366872685 0 15318183436342 0 7659091718171 0 3829545859085 0 1914772929542 0 957386464771 0 478693232385 0 239346616192 0 119673308096 0 59836654048 0 29918327024 0 14959163512 0 7479581756 0 3739790878 0 1869895439 0 934947719 0 467473859 0 233736929 0 116868464 0 58434232 0 29217116 0 14608558 0 7304279 0 3652139 0 1826069 0 913034 0 456517 0 228258 0 114129 0 57064 0 28532 0 14266 0 7133 0 3566 0 1783 0 891 0 445 0 222 0 111 0 55 0 27 0 13 0 6 0 3 0 1 0 [0; 13; 4; 6; 14; 6; 47; 3; 4; 3; 6; 6; 9; 4; 3; 65; 2; 4; 55; 2; 4; 87; 9; 5; 35; 73; 9; 9; 2; 74; 5; 9; 10; 93; 2; 7; 1; 4; 6; 91; 8; 8; 2; 9; 47; 6; 26; 3; 60; 1; 0; 5; 26; 4; 28; 6; 0; 5; 88; 3; 7] [0; 13; 4; 6; 14; 6; 47; 3; 4; 3; 6; 6; 9; 4; 3; 65; 2; 4; 55; 2; 4; 87; 9; 5; 35; 73; 9; 9; 2; 74; 5] [0; 13; 4; 6; 14; 6; 47; 3; 4; 3; 6; 6; 9; 4; 3; 65] [0; 13; 4; 6; 14; 6; 47; 3] [0; 13; 4; 6] [0; 13] [13] [] [0] [0; 13; 4; 6; 14; 6; 47; 3; 4; 3; 6; 6; 9; 4; 3; 65; 2; 4; 55; 2; 4; 87; 9; 5; 35; 73; 9; 9; 2; 74; 5; 9; 10; 93; 2; 7; 1; 4; 6; 91; 8; 8; 2; 9; 47; 6; 26; 3; 60; 1; 0; 5; 26; 4; 28; 6; 0; 5; 88; 3; 7] [0; 13; 4; 6; 14; 6; 47; 3; 4; 3; 6; 6; 9; 4; 3; 65; 2; 4; 55; 2; 4; 87; 9; 5; 35; 73; 9; 9; 2; 74; 5] [0; 13; 4; 6; 14; 6; 47; 3; 4; 3; 6; 6; 9; 4; 3; 65] [0; 13; 4; 6; 14; 6; 47; 3] [0; 13; 4; 6] [14; 6; 47; 3] [13; 4; 6; 14; 6; 47; 3] [13; 4; 6; 14] [6; 47; 3] [4; 6; 14; 6; 47; 3] [4; 6; 14] [6; 47; 3] [6; 14; 6; 47; 3] [6; 14; 6] [14; 6] [6; 6] [6] [6] [0; 6] [3; 6] [5; 6] [6; 0] [6; 3] [6; 5] --- Failure -------------------------------------------------------------------- Test should_fail_sort_id failed (5 shrink steps): [1; 0] --- Failure -------------------------------------------------------------------- Test max_fail failed (3 shrink steps): [0; 1] --- Failure -------------------------------------------------------------------- Test max_fail failed (8 shrink steps): [0; 1] --- Failure -------------------------------------------------------------------- Test max_fail failed (8 shrink steps): [0; 1] === Error ====================================================================== Test should_error_raise_exn errored on (1 shrink steps): 0 exception QCheck2_tests.Overall.Error +++ Collect ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Collect results for test collect_results: 4: 20 cases 3: 25 cases 2: 17 cases 1: 18 cases 0: 20 cases +++ Stats for with_stats ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats mod4: num: 100, avg: 1.68, stddev: 1.09, median 2, min 0, max 3 0: ############################## 17 1: ################################################### 29 2: ######################################## 23 3: ####################################################### 31 stats num: num: 100, avg: 66.84, stddev: 31.94, median 65, min 2, max 120 2.. 7: ################## 3 8.. 13: ################## 3 14.. 19: 0 20.. 25: ########################################## 7 26.. 31: ######################## 4 32.. 37: ######################## 4 38.. 43: ################## 3 44.. 49: ################################################ 8 50.. 55: #################################### 6 56.. 61: #################################### 6 62.. 67: ####################################################### 9 68.. 73: ########################################## 7 74.. 79: ######################## 4 80.. 85: ################## 3 86.. 91: ############ 2 92.. 97: ########################################## 7 98..103: #################################### 6 104..109: #################################### 6 110..115: ####################################################### 9 116..121: ################## 3 --- Failure -------------------------------------------------------------------- Test with shrinking retries failed (0 shrink steps): 7 !!! Warning !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Warning for test WARN_unlikely_precond: WARNING: only 0.3% tests (of 2000) passed precondition for "WARN_unlikely_precond" NOTE: it is likely that the precondition is too strong, or that the generator is buggy. --- Failure -------------------------------------------------------------------- Test FAIL_unlikely_precond failed: ERROR: only 0.3% tests (of 2000) passed precondition for "FAIL_unlikely_precond" NOTE: it is likely that the precondition is too strong, or that the generator is buggy. --- Failure -------------------------------------------------------------------- Test FAIL_bad_gen failed: ERROR: uncaught exception in generator for test FAIL_bad_gen after 100 steps: Exception: Invalid_argument("Gen.int_bound") Backtrace: --- Failure -------------------------------------------------------------------- Test int double failed: Negative test int double succeeded but was expected to fail === Error ====================================================================== Test pos fail with error errored on (1 shrink steps): 0 exception QCheck2_tests.Overall.Error === Error ====================================================================== Test neg fail with error errored on (1 shrink steps): 0 exception QCheck2_tests.Overall.Error --- Failure -------------------------------------------------------------------- Test char never produces '\255' failed (0 shrink steps): '\255' --- Failure -------------------------------------------------------------------- Test big bound issue59 failed (0 shrink steps): 4611686018427387903 --- Failure -------------------------------------------------------------------- Test long_shrink failed (3086 shrink steps): ([0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0], [0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 1]) --- Failure -------------------------------------------------------------------- Test ints arent 0 mod 3 failed (85 shrink steps): -141 --- Failure -------------------------------------------------------------------- Test ints are 0 failed (60 shrink steps): 1 --- Failure -------------------------------------------------------------------- Test int32s arent 0l rem 3l failed (1 shrink steps): 0l --- Failure -------------------------------------------------------------------- Test int32s are 0l failed (30 shrink steps): -1l --- Failure -------------------------------------------------------------------- Test int64s arent 0L rem 3L failed (1 shrink steps): 0L --- Failure -------------------------------------------------------------------- Test int64s are 0L failed (62 shrink steps): -1L --- Failure -------------------------------------------------------------------- Test ints < 209609 failed (0 shrink steps): 4611686018427387903 --- Failure -------------------------------------------------------------------- Test nat < 5001 failed (7 shrink steps): 5001 --- Failure -------------------------------------------------------------------- Test char never produces 'abcdef' failed (1 shrink steps): 'a' --- Failure -------------------------------------------------------------------- Test printable never produces '!"#$%&' failed (1 shrink steps): '!' --- Failure -------------------------------------------------------------------- Test printable never produces less than '5 failed (1 shrink steps): '0' --- Failure -------------------------------------------------------------------- Test bytes are empty failed (7 shrink steps): "a" --- Failure -------------------------------------------------------------------- Test bytes never has a \000 char failed (13 shrink steps): "\000" --- Failure -------------------------------------------------------------------- Test bytes never has a \255 char failed (6 shrink steps): "\255" --- Failure -------------------------------------------------------------------- Test bytes have unique chars failed (13 shrink steps): "**" --- Failure -------------------------------------------------------------------- Test strings are empty failed (7 shrink steps): "a" --- Failure -------------------------------------------------------------------- Test string never has a \000 char failed (13 shrink steps): "\000" --- Failure -------------------------------------------------------------------- Test string never has a \255 char failed (6 shrink steps): "\255" --- Failure -------------------------------------------------------------------- Test strings have unique chars failed (13 shrink steps): "**" --- Failure -------------------------------------------------------------------- Test pairs have different components failed (0 shrink steps): (3, 3) --- Failure -------------------------------------------------------------------- Test pairs have same components failed (63 shrink steps): (0, 1) --- Failure -------------------------------------------------------------------- Test pairs have a zero component failed (123 shrink steps): (1, 1) --- Failure -------------------------------------------------------------------- Test pairs are (0,0) failed (63 shrink steps): (0, 1) --- Failure -------------------------------------------------------------------- Test pairs are ordered failed (94 shrink steps): (1, 0) --- Failure -------------------------------------------------------------------- Test pairs are ordered reversely failed (62 shrink steps): (0, 1) --- Failure -------------------------------------------------------------------- Test pairs sum to less than 128 failed (58 shrink steps): (0, 128) --- Failure -------------------------------------------------------------------- Test pairs lists rev concat failed (66 shrink steps): ([0], [1]) --- Failure -------------------------------------------------------------------- Test pairs lists no overlap failed (13 shrink steps): ([0], [0]) --- Failure -------------------------------------------------------------------- Test triples have pair-wise different components failed (2 shrink steps): (0, 0, 0) --- Failure -------------------------------------------------------------------- Test triples have same components failed (65 shrink steps): (0, 1, 0) --- Failure -------------------------------------------------------------------- Test triples are ordered failed (4 shrink steps): (0, 0, -1) --- Failure -------------------------------------------------------------------- Test triples are ordered reversely failed (125 shrink steps): (0, 0, 1) --- Failure -------------------------------------------------------------------- Test quadruples have pair-wise different components failed (3 shrink steps): (0, 0, 0, 0) --- Failure -------------------------------------------------------------------- Test quadruples have same components failed (125 shrink steps): (0, 1, 0, 1) --- Failure -------------------------------------------------------------------- Test quadruples are ordered failed (5 shrink steps): (0, 0, 0, -1) --- Failure -------------------------------------------------------------------- Test quadruples are ordered reversely failed (126 shrink steps): (0, 0, 0, 1) --- Failure -------------------------------------------------------------------- Test forall (a, b) in nat: a < b failed (1 shrink steps): (0, 0) --- Failure -------------------------------------------------------------------- Test forall (a, b, c) in nat: a < b < c failed (2 shrink steps): (0, 0, 0) --- Failure -------------------------------------------------------------------- Test forall (a, b, c, d) in nat: a < b < c < d failed (3 shrink steps): (0, 0, 0, 0) --- Failure -------------------------------------------------------------------- Test forall (a, b, c, d, e) in nat: a < b < c < d < e failed (4 shrink steps): (0, 0, 0, 0, 0) --- Failure -------------------------------------------------------------------- Test forall (a, b, c, d, e, f) in nat: a < b < c < d < e < f failed (5 shrink steps): (0, 0, 0, 0, 0, 0) --- Failure -------------------------------------------------------------------- Test forall (a, b, c, d, e, f, g) in nat: a < b < c < d < e < f < g failed (6 shrink steps): (0, 0, 0, 0, 0, 0, 0) --- Failure -------------------------------------------------------------------- Test forall (a, b, c, d, e, f, g, h) in nat: a < b < c < d < e < f < g < h failed (7 shrink steps): (0, 0, 0, 0, 0, 0, 0, 0) --- Failure -------------------------------------------------------------------- Test forall (a, b, c, d, e, f, g, h, i) in nat: a < b < c < d < e < f < g < h < i failed (8 shrink steps): (0, 0, 0, 0, 0, 0, 0, 0, 0) --- Failure -------------------------------------------------------------------- Test bind ordered pairs failed (1 shrink steps): (0, 0) --- Failure -------------------------------------------------------------------- Test bind list_size constant failed (12 shrink steps): (4, [0; 0; 0; 0]) --- Failure -------------------------------------------------------------------- Test lists are empty failed (7 shrink steps): [0] --- Failure -------------------------------------------------------------------- Test lists shorter than 10 failed (18 shrink steps): [0; 0; 0; 0; 0; 0; 0; 0; 0; 0] --- Failure -------------------------------------------------------------------- Test lists shorter than 432 failed (403 shrink steps): [...] list length: 432 --- Failure -------------------------------------------------------------------- Test lists shorter than 4332 failed (4022 shrink steps): [...] list length: 4332 --- Failure -------------------------------------------------------------------- Test lists have unique elems failed (8 shrink steps): [6; 6] --- Failure -------------------------------------------------------------------- Test int option are none failed (1 shrink steps): Some (0) --- Failure -------------------------------------------------------------------- Test int option are some 100 or more failed (1 shrink steps): None --- Failure -------------------------------------------------------------------- Test (int,string) result are Ok failed (4 shrink steps): Error ("") --- Failure -------------------------------------------------------------------- Test (int,string) result are Error failed (1 shrink steps): Ok (0) --- Failure -------------------------------------------------------------------- Test tree contains only 42 failed (1 shrink steps): Leaf 0 --- Failure -------------------------------------------------------------------- Test sum list = 0 failed (0 shrink steps): [0; 13; 4; 6; 14; 6; 47; 3; 4; 3; 6; 6; 9; 4; 3; 65; 2; 4; 55; 2; 4; 87; 9; 5; 35; 73; 9; 9; 2; 74; 5; 9; 10; 93; 2; 7; 1; 4; 6; 91; 8; 8; 2; 9; 47; 6; 26; 3; 60; 1; 0; 5; 26; 4; 28; 6; 0; 5; 88; 3; 7] --- Failure -------------------------------------------------------------------- Test fail_pred_map_commute_int failed (107 shrink steps): ([0], {0 -> 29; _ -> 0}, {29 -> true; _ -> false}) --- Failure -------------------------------------------------------------------- Test fail_pred_map_commute_int32 failed (57 shrink steps): ([0l], {0l -> -15l; _ -> 0l}, {-15l -> true; _ -> false}) --- Failure -------------------------------------------------------------------- Test fail_pred_map_commute_int64 failed (107 shrink steps): ([0L], {0L -> -71L; _ -> 0L}, {-71L -> true; _ -> false}) --- Failure -------------------------------------------------------------------- Test fail_pred_strings failed (1 shrink steps): {"some random string" -> true; _ -> false} --- Failure -------------------------------------------------------------------- Test fold_left fold_right failed (20 shrink steps): (0, [1], {(0, 1) -> 1; _ -> 0}) +++ Messages ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Messages for test fold_left fold_right: l=[1], fold_left=0, fold_right=1 --- Failure -------------------------------------------------------------------- Test fold_left fold_right uncurried failed (17 shrink steps): ({(9, 6) -> 0; (1, 5) -> 0; (4, 8) -> 0; (9, 8) -> 1; _ -> 0}, 8, [9]) --- Failure -------------------------------------------------------------------- Test fold_left fold_right uncurried fun last failed (48 shrink steps): (0, [0; 1], {(0, 0) -> 1; _ -> 0}) --- Failure -------------------------------------------------------------------- Test fold_left test, fun first failed (87 shrink steps): ({("\188Bt\000", 9) -> ""; ("8\252D", 2) -> ""; ("\241\223v\190~>", 6) -> "a"; ("\252R\2108,\226\019\006\t", 2) -> ""; ("\154\241\031\198W\176\ng\150\002\213\197\026\221z\019\151", 0) -> ""; ("1\015\255", 46) -> "a"; ("\177W\174", 8) -> ""; ("\0140WD\024%\195\145\176\200\023\185\138\247\193\172[+\237\186LT\158\208y|\223\231\192\012#\144c\016", 66) -> ""; ("Z}(:?\216", 4) -> ""; ("", 13) -> "a"; ("", 9) -> ""; ("\144\189\"\030E\183\024h\023", 8) -> ""; ("\147\172\209U\252\209\bM&\175m\005\250N[p\180\204jh\217$I\208\002H\168[F\174\145\190b\151w\174\177Ib|\022\149\224\140\250E\239\216g\249\137\246\252\229\192\136\249\131\182&\127\173\015\147H\240\201\166\163\163\239\196", 29) -> ""; ("B\012\251", 1) -> "a"; ("\140", 9) -> ""; ("@\131}\002uPha\151\245\224\240\148ad\191", 7) -> ""; _ -> ""}, "", [0; 13], [0]) --- Failure -------------------------------------------------------------------- Test FAIL_#99_1 failed: ERROR: uncaught exception in generator for test FAIL_#99_1 after 100 steps: Exception: QCheck2.No_example_found("") Backtrace: +++ Collect ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Collect results for test bool dist: true: 250134 cases false: 249866 cases +++ Stats for char code dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats char code: num: 500000, avg: 127.42, stddev: 73.92, median 127, min 0, max 255 0.. 12: ###################################################### 25509 13.. 25: ###################################################### 25398 26.. 38: ###################################################### 25293 39.. 51: ###################################################### 25448 52.. 64: ###################################################### 25392 65.. 77: ####################################################### 25660 78.. 90: ###################################################### 25462 91..103: ###################################################### 25331 104..116: ##################################################### 25129 117..129: ###################################################### 25351 130..142: ###################################################### 25492 143..155: ###################################################### 25370 156..168: ###################################################### 25658 169..181: ###################################################### 25400 182..194: ##################################################### 25167 195..207: ###################################################### 25338 208..220: ##################################################### 25181 221..233: ##################################################### 25145 234..246: ###################################################### 25567 247..259: ##################################### 17709 +++ Stats for printable char code dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats char code: num: 500000, avg: 78.26, stddev: 28.15, median 78, min 10, max 126 10.. 15: ######### 5149 16.. 21: 0 22.. 27: 0 28.. 33: ################## 10379 34.. 39: ###################################################### 31153 40.. 45: ###################################################### 31341 46.. 51: ###################################################### 31408 52.. 57: ####################################################### 31456 58.. 63: ###################################################### 31310 64.. 69: ###################################################### 31152 70.. 75: ###################################################### 31308 76.. 81: ###################################################### 31156 82.. 87: ###################################################### 31170 88.. 93: ###################################################### 31286 94.. 99: ###################################################### 31364 100..105: ###################################################### 31368 106..111: ###################################################### 31024 112..117: ###################################################### 31261 118..123: ###################################################### 31064 124..129: ########################### 15651 +++ Stats for numeral char code dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats char code: num: 500000, avg: 52.50, stddev: 2.87, median 52, min 48, max 57 48: ###################################################### 50260 49: ###################################################### 49590 50: ###################################################### 50170 51: ####################################################### 50270 52: ###################################################### 49805 53: ###################################################### 50161 54: ###################################################### 49919 55: ###################################################### 49971 56: ###################################################### 49980 57: ###################################################### 49874 +++ Stats for tree's depth ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats depth: num: 1000, avg: 3.97, stddev: 3.35, median 3, min 1, max 15 1: ####################################################### 356 2: ############## 91 3: ############### 98 4: ################### 129 5: ############ 78 6: #### 31 7: ####### 47 8: ######## 53 9: # 12 10: #### 27 11: ######## 55 12: 3 13: # 8 14: # 9 15: 3 +++ Stats for bytes_size len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 7.53, stddev: 1.71, median 8, min 5, max 10 5: #################################################### 814 6: #################################################### 809 7: ##################################################### 830 8: ###################################################### 845 9: ####################################################### 854 10: ###################################################### 848 +++ Stats for bytes len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 327.56, stddev: 1159.62, median 9, min 0, max 9916 0.. 495: ####################################################### 4285 496.. 991: ###### 509 992..1487: 21 1488..1983: 13 1984..2479: 13 2480..2975: 13 2976..3471: 10 3472..3967: 13 3968..4463: 10 4464..4959: 12 4960..5455: 7 5456..5951: 12 5952..6447: 11 6448..6943: 7 6944..7439: 9 7440..7935: 6 7936..8431: 16 8432..8927: 9 8928..9423: 13 9424..9919: 11 +++ Stats for bytes_of len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 327.56, stddev: 1159.62, median 9, min 0, max 9916 0.. 495: ####################################################### 4285 496.. 991: ###### 509 992..1487: 21 1488..1983: 13 1984..2479: 13 2480..2975: 13 2976..3471: 10 3472..3967: 13 3968..4463: 10 4464..4959: 12 4960..5455: 7 5456..5951: 12 5952..6447: 11 6448..6943: 7 6944..7439: 9 7440..7935: 6 7936..8431: 16 8432..8927: 9 8928..9423: 13 9424..9919: 11 +++ Stats for bytes_printable len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 327.56, stddev: 1159.62, median 9, min 0, max 9916 0.. 495: ####################################################### 4285 496.. 991: ###### 509 992..1487: 21 1488..1983: 13 1984..2479: 13 2480..2975: 13 2976..3471: 10 3472..3967: 13 3968..4463: 10 4464..4959: 12 4960..5455: 7 5456..5951: 12 5952..6447: 11 6448..6943: 7 6944..7439: 9 7440..7935: 6 7936..8431: 16 8432..8927: 9 8928..9423: 13 9424..9919: 11 +++ Stats for bytes_small len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 15.47, stddev: 24.03, median 6, min 0, max 99 0.. 4: ####################################################### 1958 5.. 9: ##################################################### 1914 10.. 14: # 64 15.. 19: ## 75 20.. 24: # 64 25.. 29: # 71 30.. 34: ## 74 35.. 39: # 60 40.. 44: # 61 45.. 49: # 57 50.. 54: # 62 55.. 59: # 58 60.. 64: # 63 65.. 69: # 46 70.. 74: # 67 75.. 79: # 62 80.. 84: # 57 85.. 89: # 67 90.. 94: # 66 95.. 99: # 54 +++ Stats for string_size len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 7.53, stddev: 1.71, median 8, min 5, max 10 5: #################################################### 814 6: #################################################### 809 7: ##################################################### 830 8: ###################################################### 845 9: ####################################################### 854 10: ###################################################### 848 +++ Stats for string len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 327.56, stddev: 1159.62, median 9, min 0, max 9916 0.. 495: ####################################################### 4285 496.. 991: ###### 509 992..1487: 21 1488..1983: 13 1984..2479: 13 2480..2975: 13 2976..3471: 10 3472..3967: 13 3968..4463: 10 4464..4959: 12 4960..5455: 7 5456..5951: 12 5952..6447: 11 6448..6943: 7 6944..7439: 9 7440..7935: 6 7936..8431: 16 8432..8927: 9 8928..9423: 13 9424..9919: 11 +++ Stats for string_of len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 327.56, stddev: 1159.62, median 9, min 0, max 9916 0.. 495: ####################################################### 4285 496.. 991: ###### 509 992..1487: 21 1488..1983: 13 1984..2479: 13 2480..2975: 13 2976..3471: 10 3472..3967: 13 3968..4463: 10 4464..4959: 12 4960..5455: 7 5456..5951: 12 5952..6447: 11 6448..6943: 7 6944..7439: 9 7440..7935: 6 7936..8431: 16 8432..8927: 9 8928..9423: 13 9424..9919: 11 +++ Stats for string_printable len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 327.56, stddev: 1159.62, median 9, min 0, max 9916 0.. 495: ####################################################### 4285 496.. 991: ###### 509 992..1487: 21 1488..1983: 13 1984..2479: 13 2480..2975: 13 2976..3471: 10 3472..3967: 13 3968..4463: 10 4464..4959: 12 4960..5455: 7 5456..5951: 12 5952..6447: 11 6448..6943: 7 6944..7439: 9 7440..7935: 6 7936..8431: 16 8432..8927: 9 8928..9423: 13 9424..9919: 11 +++ Stats for small_string len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 15.47, stddev: 24.03, median 6, min 0, max 99 0.. 4: ####################################################### 1958 5.. 9: ##################################################### 1914 10.. 14: # 64 15.. 19: ## 75 20.. 24: # 64 25.. 29: # 71 30.. 34: ## 74 35.. 39: # 60 40.. 44: # 61 45.. 49: # 57 50.. 54: # 62 55.. 59: # 58 60.. 64: # 63 65.. 69: # 46 70.. 74: # 67 75.. 79: # 62 80.. 84: # 57 85.. 89: # 67 90.. 94: # 66 95.. 99: # 54 +++ Stats for pair dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats pair sum: num: 500000, avg: 100.09, stddev: 41.23, median 100, min 0, max 200 0.. 9: ### 2599 10.. 19: ######## 7571 20.. 29: ############## 12587 30.. 39: #################### 17235 40.. 49: ########################## 22334 50.. 59: ############################### 27179 60.. 69: ##################################### 32092 70.. 79: ########################################### 37071 80.. 89: ################################################ 41592 90.. 99: ###################################################### 46677 100..109: ####################################################### 47155 110..119: ################################################# 42772 120..129: ########################################### 37679 130..139: ###################################### 32681 140..149: ################################ 27465 150..159: ########################## 23061 160..169: #################### 17923 170..179: ############### 12910 180..189: ######### 8135 190..199: ### 3233 200..209: 49 +++ Stats for triple dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats triple sum: num: 500000, avg: 149.91, stddev: 50.48, median 150, min 1, max 299 1.. 15: 404 16.. 30: ## 2212 31.. 45: ##### 5889 46.. 60: ########## 10700 61.. 75: ################# 17772 76.. 90: ######################### 26105 91..105: ################################### 36005 106..120: ############################################# 45660 121..135: ################################################### 52122 136..150: ####################################################### 55483 151..165: ###################################################### 54945 166..180: ################################################### 51868 181..195: ############################################ 45051 196..210: ################################## 35080 211..225: ######################### 25470 226..240: ################ 16973 241..255: ########## 10427 256..270: ##### 5344 271..285: ## 2133 286..300: 357 +++ Stats for quad dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats quad sum: num: 500000, avg: 199.94, stddev: 58.37, median 200, min 5, max 394 5.. 24: 105 25.. 44: 829 45.. 64: ## 2997 65.. 84: ###### 7402 85..104: ############ 14559 105..124: ##################### 25103 125..144: ################################ 38055 145..164: ########################################## 50469 165..184: ################################################## 60434 185..204: ####################################################### 65242 205..224: ##################################################### 63665 225..244: ############################################### 55764 245..264: ###################################### 45244 265..284: ########################## 31847 285..304: ################ 20092 305..324: ######### 11027 325..344: #### 5011 345..364: # 1794 365..384: 348 385..404: 13 +++ Stats for bind dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats ordered pair difference: num: 1000000, avg: 25.02, stddev: 22.38, median 19, min 0, max 100 0.. 4: ####################################################### 193818 5.. 9: #################################### 129891 10.. 14: ############################# 103378 15.. 19: ######################## 87043 20.. 24: ##################### 75202 25.. 29: ################## 64688 30.. 34: ################ 56523 35.. 39: ############# 49283 40.. 44: ############ 42859 45.. 49: ########## 37336 50.. 54: ######### 32591 55.. 59: ######## 28285 60.. 64: ###### 24255 65.. 69: ##### 20314 70.. 74: #### 16733 75.. 79: ### 13555 80.. 84: ## 10170 85.. 89: ## 7255 90.. 94: # 4729 95.. 99: 1992 100..104: 100 stats ordered pair sum: num: 1000000, avg: 75.04, stddev: 46.91, median 72, min 0, max 200 0.. 9: ####################################################### 70296 10.. 19: ##################################################### 68918 20.. 29: ##################################################### 68448 30.. 39: ##################################################### 68654 40.. 49: ##################################################### 68490 50.. 59: ##################################################### 68513 60.. 69: ##################################################### 68299 70.. 79: ##################################################### 68552 80.. 89: ##################################################### 68560 90.. 99: ###################################################### 69283 100..109: ################################################## 64173 110..119: ########################################### 55624 120..129: ##################################### 47381 130..139: ############################## 39552 140..149: ######################### 32856 150..159: #################### 26038 160..169: ############### 20035 170..179: ########### 14164 180..189: ###### 8568 190..199: ## 3515 200..209: 81 +++ Collect ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Collect results for test option dist: None : 1519 cases Some _: 8481 cases +++ Collect ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Collect results for test result dist: Error _: 2577 cases Ok _ : 7423 cases +++ Stats for list len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 327.56, stddev: 1159.62, median 9, min 0, max 9916 0.. 495: ####################################################### 4285 496.. 991: ###### 509 992..1487: 21 1488..1983: 13 1984..2479: 13 2480..2975: 13 2976..3471: 10 3472..3967: 13 3968..4463: 10 4464..4959: 12 4960..5455: 7 5456..5951: 12 5952..6447: 11 6448..6943: 7 6944..7439: 9 7440..7935: 6 7936..8431: 16 8432..8927: 9 8928..9423: 13 9424..9919: 11 +++ Stats for small_list len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 15.47, stddev: 24.03, median 6, min 0, max 99 0.. 4: ####################################################### 1958 5.. 9: ##################################################### 1914 10.. 14: # 64 15.. 19: ## 75 20.. 24: # 64 25.. 29: # 71 30.. 34: ## 74 35.. 39: # 60 40.. 44: # 61 45.. 49: # 57 50.. 54: # 62 55.. 59: # 58 60.. 64: # 63 65.. 69: # 46 70.. 74: # 67 75.. 79: # 62 80.. 84: # 57 85.. 89: # 67 90.. 94: # 66 95.. 99: # 54 +++ Stats for list_size len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 7.53, stddev: 1.71, median 8, min 5, max 10 5: #################################################### 814 6: #################################################### 809 7: ##################################################### 830 8: ###################################################### 845 9: ####################################################### 854 10: ###################################################### 848 +++ Stats for list_repeat len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 42.00, stddev: 0.00, median 42, min 42, max 42 42: ####################################################### 5000 +++ Stats for array len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 327.56, stddev: 1159.62, median 9, min 0, max 9916 0.. 495: ####################################################### 4285 496.. 991: ###### 509 992..1487: 21 1488..1983: 13 1984..2479: 13 2480..2975: 13 2976..3471: 10 3472..3967: 13 3968..4463: 10 4464..4959: 12 4960..5455: 7 5456..5951: 12 5952..6447: 11 6448..6943: 7 6944..7439: 9 7440..7935: 6 7936..8431: 16 8432..8927: 9 8928..9423: 13 9424..9919: 11 +++ Stats for small_array len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 15.47, stddev: 24.03, median 6, min 0, max 99 0.. 4: ####################################################### 1958 5.. 9: ##################################################### 1914 10.. 14: # 64 15.. 19: ## 75 20.. 24: # 64 25.. 29: # 71 30.. 34: ## 74 35.. 39: # 60 40.. 44: # 61 45.. 49: # 57 50.. 54: # 62 55.. 59: # 58 60.. 64: # 63 65.. 69: # 46 70.. 74: # 67 75.. 79: # 62 80.. 84: # 57 85.. 89: # 67 90.. 94: # 66 95.. 99: # 54 +++ Stats for array_size len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 7.53, stddev: 1.71, median 8, min 5, max 10 5: #################################################### 814 6: #################################################### 809 7: ##################################################### 830 8: ###################################################### 845 9: ####################################################### 854 10: ###################################################### 848 +++ Stats for array_repeat len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 42.00, stddev: 0.00, median 42, min 42, max 42 42: ####################################################### 5000 +++ Stats for int_stats_neg ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 5000, avg: 0.17, stddev: 29.68, median 0, min -99, max 99 -99..-90: # 65 -89..-80: # 63 -79..-70: # 64 -69..-60: # 58 -59..-50: # 67 -49..-40: # 72 -39..-30: # 61 -29..-20: # 61 -19..-10: # 67 -9.. 0: ####################################################### 2076 1.. 10: ############################################## 1764 11.. 20: # 66 21.. 30: # 64 31.. 40: # 64 41.. 50: # 67 51.. 60: # 60 61.. 70: # 75 71.. 80: # 60 81.. 90: # 60 91..100: # 66 +++ Stats for small_signed_int dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 0.90, stddev: 28.23, median 0, min -99, max 99 -99..-90: # 12 -89..-80: # 11 -79..-70: # 9 -69..-60: 6 -59..-50: # 11 -49..-40: # 13 -39..-30: # 9 -29..-20: # 13 -19..-10: 8 -9.. 0: ####################################################### 453 1.. 10: ######################################### 340 11.. 20: # 15 21.. 30: # 11 31.. 40: # 12 41.. 50: # 13 51.. 60: # 13 61.. 70: # 16 71.. 80: # 9 81.. 90: # 16 91..100: # 10 +++ Stats for small_nat dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 15.11, stddev: 23.27, median 6, min 0, max 99 0.. 4: #################################################### 377 5.. 9: ####################################################### 392 10.. 14: ## 20 15.. 19: ## 15 20.. 24: # 11 25.. 29: ## 17 30.. 34: ## 19 35.. 39: ## 17 40.. 44: # 10 45.. 49: # 9 50.. 54: # 8 55.. 59: # 9 60.. 64: ## 15 65.. 69: # 10 70.. 74: # 13 75.. 79: ## 19 80.. 84: # 11 85.. 89: # 13 90.. 94: 5 95.. 99: # 10 +++ Stats for nat dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 363.02, stddev: 1215.04, median 9, min 0, max 9476 0.. 473: ####################################################### 847 474.. 947: ###### 95 948..1421: 14 1422..1895: 3 1896..2369: 0 2370..2843: 3 2844..3317: 2 3318..3791: 3 3792..4265: 2 4266..4739: 4 4740..5213: 3 5214..5687: 4 5688..6161: 3 6162..6635: 4 6636..7109: 1 7110..7583: 4 7584..8057: 2 8058..8531: 1 8532..9005: 1 9006..9479: 4 +++ Stats for int_range (-43643) 435434 dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 195335.64, stddev: 136803.99, median 195583, min -43624, max 435210 -43624..-19683: ############################################ 52 -19682.. 4259: ######################################## 47 4260.. 28201: ############################## 36 28202.. 52143: ############################################ 52 52144.. 76085: ########################################## 50 76086..100027: ####################################################### 64 100028..123969: ############################################### 55 123970..147911: ######################################## 47 147912..171853: ############################################## 54 171854..195795: #################################### 43 195796..219737: ############################################## 54 219738..243679: ########################################### 51 243680..267621: ################################################ 57 267622..291563: ########################################## 49 291564..315505: #################################### 42 315506..339447: ###################################### 45 339448..363389: ################################################ 57 363390..387331: ###################################### 45 387332..411273: ########################################## 49 411274..435215: ########################################### 51 +++ Stats for int_range (-40000) 40000 dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: -173.78, stddev: 23042.92, median 180, min -39859, max 39942 -39859..-35869: ############################################# 56 -35868..-31878: ################################### 43 -31877..-27887: ################################################# 60 -27886..-23896: ##################################### 46 -23895..-19905: ######################################## 49 -19904..-15914: #################################### 45 -15913..-11923: ############################################ 54 -11922.. -7932: ############################################### 58 -7931.. -3941: ######################################### 51 -3940.. 50: ############################ 35 51.. 4041: ####################################### 48 4042.. 8032: ########################################## 52 8033.. 12023: ######################################### 51 12024.. 16014: ########################################### 53 16015.. 20005: ############################################ 54 20006.. 23996: ################################## 42 23997.. 27987: ####################################################### 67 27988.. 31978: ################################ 40 31979.. 35969: ######################################### 51 35970.. 39960: #################################### 45 +++ Stats for int_range (-4) 4 dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 0.02, stddev: 2.55, median 0, min -4, max 4 -4: ############################################ 99 -3: ##################################################### 118 -2: ################################################## 111 -1: ################################################## 113 0: ################################################## 113 1: ##################################################### 118 2: ############################################# 102 3: ####################################################### 122 4: ############################################## 104 +++ Stats for int_range (-4) 17 dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 6.67, stddev: 6.39, median 7, min -4, max 17 -4..-3: ############################################# 90 -2..-1: ############################################# 91 0.. 1: ########################################## 84 2.. 3: ############################################## 92 4.. 5: ########################################### 87 6.. 7: ########################################### 86 8.. 9: ############################################ 89 10..11: ########################################### 87 12..13: ####################################################### 110 14..15: ############################################# 91 16..17: ############################################## 93 18..19: 0 20..21: 0 22..23: 0 24..25: 0 26..27: 0 28..29: 0 30..31: 0 32..33: 0 34..35: 0 +++ Stats for int dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 100000, avg: 6.740e+15, stddev: 2.655e+18, median 2435838602111153, min -4611682300221562449, max 4611492907363159042 -4611682300221562449..-4150523539842326354: #################################################### 4927 -4150523539842326353..-3689364779463090258: #################################################### 4923 -3689364779463090257..-3228206019083854162: #################################################### 4923 -3228206019083854161..-2767047258704618066: ##################################################### 4981 -2767047258704618065..-2305888498325381970: ##################################################### 5010 -2305888498325381969..-1844729737946145874: ##################################################### 5016 -1844729737946145873..-1383570977566909778: #################################################### 4929 -1383570977566909777.. -922412217187673682: ##################################################### 5045 -922412217187673681.. -461253456808437586: ###################################################### 5081 -461253456808437585.. -94696429201490: ####################################################### 5140 -94696429201489.. 461064063950034606: ###################################################### 5110 461064063950034607.. 922222824329270702: ##################################################### 4998 922222824329270703.. 1383381584708506798: ##################################################### 4996 1383381584708506799.. 1844540345087742894: #################################################### 4915 1844540345087742895.. 2305699105466978990: ##################################################### 5014 2305699105466978991.. 2766857865846215086: ###################################################### 5072 2766857865846215087.. 3228016626225451182: #################################################### 4913 3228016626225451183.. 3689175386604687278: ###################################################### 5063 3689175386604687279.. 4150334146983923374: #################################################### 4909 4150334146983923375.. 4611492907363159470: ##################################################### 5035 +++ Stats for oneof int dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 4.612e+15, stddev: 2.906e+18, median 0, min -4611686018427387904, max 4611686018427387903 -4611686018427387904..-4150517416584649089: ################## 208 -4150517416584649088..-3689348814741910273: 0 -3689348814741910272..-3228180212899171457: 0 -3228180212899171456..-2767011611056432641: 0 -2767011611056432640..-2305843009213693825: 0 -2305843009213693824..-1844674407370955009: 0 -1844674407370955008..-1383505805528216193: 0 -1383505805528216192.. -922337203685477377: 0 -922337203685477376.. -461168601842738561: 0 -461168601842738560.. 255: ####################################################### 603 256.. 461168601842739071: 0 461168601842739072.. 922337203685477887: 0 922337203685477888.. 1383505805528216703: 0 1383505805528216704.. 1844674407370955519: 0 1844674407370955520.. 2305843009213694335: 0 2305843009213694336.. 2767011611056433151: 0 2767011611056433152.. 3228180212899171967: 0 3228180212899171968.. 3689348814741910783: 0 3689348814741910784.. 4150517416584649599: 0 4150517416584649600.. 4611686018427387903: ################# 189 +++ Stats for int32 lower dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 10000, avg: 32926.27, stddev: 18808.64, median 33297, min 0, max 65534 0.. 3276: ################################################ 481 3277.. 6553: ################################################## 497 6554.. 9830: ############################################### 469 9831..13107: #################################################### 515 13108..16384: ############################################### 470 16385..19661: ####################################################### 544 19662..22938: ################################################# 487 22939..26215: ################################################ 477 26216..29492: ################################################### 509 29493..32769: ############################################### 470 32770..36046: ################################################## 502 36047..39323: ##################################################### 530 39324..42600: ##################################################### 533 42601..45877: ##################################################### 525 45878..49154: ###################################################### 537 49155..52431: ################################################# 494 52432..55708: ############################################### 473 55709..58985: ################################################# 486 58986..62262: ################################################### 509 62263..65539: ################################################# 492 +++ Stats for int32 upper dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 10000, avg: 32678.65, stddev: 19067.06, median 32890, min 10, max 65523 10.. 3285: #################################################### 514 3286.. 6561: ################################################### 505 6562.. 9837: ####################################################### 541 9838..13113: ################################################# 491 13114..16389: ##################################################### 522 16390..19665: ################################################## 495 19666..22941: ############################################### 470 22942..26217: #################################################### 512 26218..29493: ############################################### 468 29494..32769: ############################################## 457 32770..36045: #################################################### 514 36046..39321: ############################################### 468 39322..42597: #################################################### 520 42598..45873: ################################################### 510 45874..49149: #################################################### 521 49150..52425: ############################################# 450 52426..55701: ##################################################### 526 55702..58977: ##################################################### 522 58978..62253: ################################################## 493 62254..65529: ################################################## 501 +++ Stats for int64 lower dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 10000, avg: 32767.87, stddev: 18950.16, median 33187, min 0, max 65532 0.. 3276: ################################################## 513 3277.. 6553: ################################################# 500 6554.. 9830: ################################################ 491 9831..13107: ################################################# 500 13108..16384: ################################################# 500 16385..19661: ################################################### 526 19662..22938: ################################################ 491 22939..26215: ############################################## 472 26216..29492: ################################################## 510 29493..32769: ########################################### 439 32770..36046: ################################################# 503 36047..39323: ################################################### 521 39324..42600: ################################################### 524 42601..45877: ############################################## 477 45878..49154: ####################################################### 560 49155..52431: ################################################# 506 52432..55708: ############################################### 482 55709..58985: ################################################ 492 58986..62262: ################################################ 496 62263..65539: ################################################ 497 +++ Stats for int64 lower-mid dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 10000, avg: 32779.13, stddev: 18897.20, median 32848, min 0, max 65535 0.. 3276: ############################################### 473 3277.. 6553: ################################################## 502 6554.. 9830: #################################################### 522 9831..13107: ################################################# 494 13108..16384: ##################################################### 535 16385..19661: ############################################### 471 19662..22938: ################################################# 495 22939..26215: #################################################### 522 26216..29492: ################################################ 489 29493..32769: ################################################ 487 32770..36046: ################################################# 493 36047..39323: ############################################### 476 39324..42600: ################################################# 494 42601..45877: ##################################################### 538 45878..49154: ####################################################### 550 49155..52431: ############################################### 479 52432..55708: ################################################### 513 55709..58985: ################################################ 487 58986..62262: ############################################### 470 62263..65539: ################################################### 510 +++ Stats for int64 upper-mid dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 10000, avg: 32833.01, stddev: 18869.35, median 32737, min 2, max 65534 2.. 3278: ################################################# 475 3279.. 6555: #################################################### 497 6556.. 9832: #################################################### 496 9833..13109: #################################################### 502 13110..16386: ###################################################### 514 16387..19663: ################################################### 492 19664..22940: #################################################### 501 22941..26217: ###################################################### 522 26218..29494: ##################################################### 505 29495..32771: #################################################### 502 32772..36048: ##################################################### 504 36049..39325: ###################################################### 519 39326..42602: ################################################# 469 42603..45879: ################################################### 493 45880..49156: ################################################### 491 49157..52433: #################################################### 498 52434..55710: #################################################### 495 55711..58987: ###################################################### 519 58988..62264: ####################################################### 523 62265..65541: ################################################## 483 +++ Stats for int64 upper dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 10000, avg: 32717.82, stddev: 19106.27, median 32768, min 2, max 65523 2.. 3278: ##################################################### 522 3279.. 6555: ###################################################### 530 6556.. 9832: #################################################### 510 9833..13109: ################################################# 484 13110..16386: ################################################# 488 16387..19663: ###################################################### 530 19664..22940: ################################################## 494 22941..26217: ################################################### 502 26218..29494: ################################################ 477 29495..32771: ############################################### 463 32772..36048: ############################################## 457 36049..39325: ################################################# 483 39326..42602: ##################################################### 521 42603..45879: #################################################### 519 45880..49156: ################################################# 485 49157..52433: ################################################ 476 52434..55710: #################################################### 510 55711..58987: ####################################################### 539 58988..62264: #################################################### 519 62265..65541: ################################################## 491 +++ Stats for exponential 10. dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 5000, avg: 9.56, stddev: 9.91, median 7, min 0, max 89 0.. 4: ####################################################### 1934 5.. 9: ################################## 1202 10.. 14: #################### 727 15.. 19: ############ 452 20.. 24: ######## 284 25.. 29: #### 164 30.. 34: ## 103 35.. 39: # 51 40.. 44: 26 45.. 49: 24 50.. 54: 15 55.. 59: 7 60.. 64: 3 65.. 69: 2 70.. 74: 2 75.. 79: 1 80.. 84: 1 85.. 89: 2 90.. 94: 0 95.. 99: 0 +++ Stats for exponential -10. dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 5000, avg: -9.56, stddev: 9.91, median -7, min -89, max 0 -89..-85: 2 -84..-80: 1 -79..-75: 1 -74..-70: 2 -69..-65: 2 -64..-60: 3 -59..-55: 7 -54..-50: 15 -49..-45: 24 -44..-40: 26 -39..-35: # 51 -34..-30: ## 103 -29..-25: #### 164 -24..-20: ######## 284 -19..-15: ############ 452 -14..-10: #################### 727 -9.. -5: ################################## 1202 -4.. 0: ####################################################### 1934 1.. 5: 0 6.. 10: 0 ================================================================================ 1 warning(s) failure (75 tests failed, 3 tests errored, ran 167 tests) random seed: 153870556 +++ Stats for int_dist_empty_bucket ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 4.899e+16, stddev: 1.794e+18, median 9, min -4580864984167113344, max 4611686018427387903 -4580864984167113344..-4121237434037388289: ## 23 -4121237434037388288..-3661609883907663233: # 19 -3661609883907663232..-3201982333777938177: ## 28 -3201982333777938176..-2742354783648213121: ## 24 -2742354783648213120..-2282727233518488065: ## 20 -2282727233518488064..-1823099683388763009: # 17 -1823099683388763008..-1363472133259037953: ## 21 -1363472133259037952.. -903844583129312897: ## 23 -903844583129312896.. -444217032999587841: ## 27 -444217032999587840.. 15410517130137215: ####################################################### 546 15410517130137216.. 475038067259862271: ## 24 475038067259862272.. 934665617389587327: ## 25 934665617389587328.. 1394293167519312383: ## 27 1394293167519312384.. 1853920717649037439: ### 35 1853920717649037440.. 2313548267778762495: ## 27 2313548267778762496.. 2773175817908487551: ## 21 2773175817908487552.. 3232803368038212607: ## 29 3232803368038212608.. 3692430918167937663: ## 20 3692430918167937664.. 4152058468297662719: ## 22 4152058468297662720.. 4611686018427387775: ## 21 4611686018427387776.. 4611686018427387903: 1 ================================================================================ success (ran 1 tests) qcheck-0.25/test/core/QCheck2_expect_test.expected.ocaml5.32000066400000000000000000002763511477416744200236170ustar00rootroot00000000000000random seed: 1234 45 4 0 0 0 0 0 0 0 0 0 0 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 (8,fun,0) (4,fun,19) (5,fun,32) (54,fun,1) (6,fun,4) (2,fun,6) (2,fun,5) (77,fun,3) (6,fun,1) (1,fun,73) (8,fun,0) (4,fun,19) (5,fun,32) (54,fun,1) (6,fun,4) (2,fun,6) (2,fun,5) (77,fun,3) (6,fun,1) (1,fun,73) (8,fun,0) (4,fun,19) (5,fun,32) (54,fun,1) (6,fun,4) (2,fun,6) (2,fun,5) (77,fun,3) (6,fun,1) (1,fun,73) (8,fun,0) (4,fun,19) (5,fun,32) (54,fun,1) (6,fun,4) (2,fun,6) (2,fun,5) (77,fun,3) (6,fun,1) (1,fun,73) (8,fun,0) (4,fun,19) (5,fun,32) (54,fun,1) (6,fun,4) (2,fun,6) (2,fun,5) (77,fun,3) (6,fun,1) (1,fun,73) (8,fun,0) (4,fun,19) (5,fun,32) (54,fun,1) (6,fun,4) (2,fun,6) (2,fun,5) (77,fun,3) (6,fun,1) (1,fun,73) (8,fun,0) (4,fun,19) (5,fun,32) (54,fun,1) (6,fun,4) (2,fun,6) (2,fun,5) (77,fun,3) (6,fun,1) (1,fun,73) (8,fun,0) (4,fun,19) (5,fun,32) (54,fun,1) (6,fun,4) (2,fun,6) (2,fun,5) (77,fun,3) (6,fun,1) (1,fun,73) 744896613 0 372448306 0 186224153 0 93112076 0 46556038 0 23278019 0 11639009 0 5819504 0 2909752 0 1454876 0 727438 0 363719 0 181859 0 90929 0 45464 0 22732 0 11366 0 5683 0 2841 0 1420 0 710 0 355 0 177 0 88 0 44 0 22 0 11 0 5 0 2 0 1 0 [0; 1; 80; 0; 9; 2; 3] [0; 1; 80; 0] [0; 1] [1] [] [0] [0; 1; 80; 0; 9; 2; 3] [0; 1; 80; 0] [0; 1] [80; 0] [1; 80; 0] [0; 1; 0] [1; 0] [0; 0] [0] [0] --- Failure -------------------------------------------------------------------- Test should_fail_sort_id failed (8 shrink steps): [1; 0] --- Failure -------------------------------------------------------------------- Test max_fail failed (4 shrink steps): [0; 1] --- Failure -------------------------------------------------------------------- Test max_fail failed (8 shrink steps): [0; 1] --- Failure -------------------------------------------------------------------- Test max_fail failed (2 shrink steps): [0; 1] === Error ====================================================================== Test should_error_raise_exn errored on (1 shrink steps): 0 exception QCheck2_tests.Overall.Error +++ Collect ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Collect results for test collect_results: 4: 24 cases 3: 20 cases 2: 18 cases 1: 21 cases 0: 17 cases +++ Stats for with_stats ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats mod4: num: 100, avg: 1.56, stddev: 1.18, median 2, min 0, max 3 0: ################################################# 27 1: #################################### 20 2: ########################################## 23 3: ####################################################### 30 stats num: num: 100, avg: 62.24, stddev: 33.15, median 62, min 2, max 120 2.. 7: ######### 2 8.. 13: ################################ 7 14.. 19: ########################### 6 20.. 25: ############# 3 26.. 31: ###################### 5 32.. 37: ################## 4 38.. 43: ############# 3 44.. 49: ################################ 7 50.. 55: ################################ 7 56.. 61: ###################### 5 62.. 67: #################################### 8 68.. 73: ######### 2 74.. 79: ###################### 5 80.. 85: ######### 2 86.. 91: ####################################################### 12 92.. 97: ###################### 5 98..103: ################## 4 104..109: ################## 4 110..115: ############# 3 116..121: ########################### 6 --- Failure -------------------------------------------------------------------- Test with shrinking retries failed (0 shrink steps): 4 !!! Warning !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Warning for test WARN_unlikely_precond: WARNING: only 0.5% tests (of 2000) passed precondition for "WARN_unlikely_precond" NOTE: it is likely that the precondition is too strong, or that the generator is buggy. --- Failure -------------------------------------------------------------------- Test FAIL_unlikely_precond failed: ERROR: only 0.5% tests (of 2000) passed precondition for "FAIL_unlikely_precond" NOTE: it is likely that the precondition is too strong, or that the generator is buggy. --- Failure -------------------------------------------------------------------- Test FAIL_bad_gen failed: ERROR: uncaught exception in generator for test FAIL_bad_gen after 100 steps: Exception: Invalid_argument("Gen.int_bound") Backtrace: --- Failure -------------------------------------------------------------------- Test int double failed: Negative test int double succeeded but was expected to fail === Error ====================================================================== Test pos fail with error errored on (1 shrink steps): 0 exception QCheck2_tests.Overall.Error === Error ====================================================================== Test neg fail with error errored on (1 shrink steps): 0 exception QCheck2_tests.Overall.Error --- Failure -------------------------------------------------------------------- Test char never produces '\255' failed (0 shrink steps): '\255' --- Failure -------------------------------------------------------------------- Test big bound issue59 failed (0 shrink steps): 1073741823 --- Failure -------------------------------------------------------------------- Test long_shrink failed (3081 shrink steps): ([0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0], [0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 1]) --- Failure -------------------------------------------------------------------- Test ints arent 0 mod 3 failed (1 shrink steps): 0 --- Failure -------------------------------------------------------------------- Test ints are 0 failed (29 shrink steps): 1 --- Failure -------------------------------------------------------------------- Test int32s arent 0l rem 3l failed (1 shrink steps): 0l --- Failure -------------------------------------------------------------------- Test int32s are 0l failed (30 shrink steps): 1l --- Failure -------------------------------------------------------------------- Test int64s arent 0L rem 3L failed (1 shrink steps): 0L --- Failure -------------------------------------------------------------------- Test int64s are 0L failed (62 shrink steps): 1L --- Failure -------------------------------------------------------------------- Test ints < 209609 failed (0 shrink steps): 1073741823 --- Failure -------------------------------------------------------------------- Test nat < 5001 failed (6 shrink steps): 5001 --- Failure -------------------------------------------------------------------- Test char never produces 'abcdef' failed (1 shrink steps): 'a' --- Failure -------------------------------------------------------------------- Test printable never produces '!"#$%&' failed (1 shrink steps): '!' --- Failure -------------------------------------------------------------------- Test printable never produces less than '5 failed (0 shrink steps): '0' --- Failure -------------------------------------------------------------------- Test bytes are empty failed (4 shrink steps): "a" --- Failure -------------------------------------------------------------------- Test bytes never has a \000 char failed (6 shrink steps): "\000" --- Failure -------------------------------------------------------------------- Test bytes never has a \255 char failed (5 shrink steps): "\255" --- Failure -------------------------------------------------------------------- Test bytes have unique chars failed (27 shrink steps): "\253\253" --- Failure -------------------------------------------------------------------- Test strings are empty failed (4 shrink steps): "a" --- Failure -------------------------------------------------------------------- Test string never has a \000 char failed (6 shrink steps): "\000" --- Failure -------------------------------------------------------------------- Test string never has a \255 char failed (5 shrink steps): "\255" --- Failure -------------------------------------------------------------------- Test strings have unique chars failed (27 shrink steps): "\253\253" --- Failure -------------------------------------------------------------------- Test pairs have different components failed (0 shrink steps): (1, 1) --- Failure -------------------------------------------------------------------- Test pairs have same components failed (31 shrink steps): (0, 1) --- Failure -------------------------------------------------------------------- Test pairs have a zero component failed (58 shrink steps): (1, 1) --- Failure -------------------------------------------------------------------- Test pairs are (0,0) failed (31 shrink steps): (0, 1) --- Failure -------------------------------------------------------------------- Test pairs are ordered failed (38 shrink steps): (1, 0) --- Failure -------------------------------------------------------------------- Test pairs are ordered reversely failed (30 shrink steps): (0, 1) --- Failure -------------------------------------------------------------------- Test pairs sum to less than 128 failed (25 shrink steps): (0, 128) --- Failure -------------------------------------------------------------------- Test pairs lists rev concat failed (47 shrink steps): ([0], [1]) --- Failure -------------------------------------------------------------------- Test pairs lists no overlap failed (18 shrink steps): ([0], [0]) --- Failure -------------------------------------------------------------------- Test triples have pair-wise different components failed (3 shrink steps): (0, 0, 0) --- Failure -------------------------------------------------------------------- Test triples have same components failed (33 shrink steps): (0, 1, 0) --- Failure -------------------------------------------------------------------- Test triples are ordered failed (4 shrink steps): (0, 0, -1) --- Failure -------------------------------------------------------------------- Test triples are ordered reversely failed (62 shrink steps): (0, 0, 1) --- Failure -------------------------------------------------------------------- Test quadruples have pair-wise different components failed (4 shrink steps): (0, 0, 0, 0) --- Failure -------------------------------------------------------------------- Test quadruples have same components failed (63 shrink steps): (0, 1, 0, 1) --- Failure -------------------------------------------------------------------- Test quadruples are ordered failed (6 shrink steps): (0, 0, 0, -1) --- Failure -------------------------------------------------------------------- Test quadruples are ordered reversely failed (64 shrink steps): (0, 0, 0, 1) --- Failure -------------------------------------------------------------------- Test forall (a, b) in nat: a < b failed (1 shrink steps): (0, 0) --- Failure -------------------------------------------------------------------- Test forall (a, b, c) in nat: a < b < c failed (2 shrink steps): (0, 0, 0) --- Failure -------------------------------------------------------------------- Test forall (a, b, c, d) in nat: a < b < c < d failed (3 shrink steps): (0, 0, 0, 0) --- Failure -------------------------------------------------------------------- Test forall (a, b, c, d, e) in nat: a < b < c < d < e failed (3 shrink steps): (0, 0, 0, 0, 0) --- Failure -------------------------------------------------------------------- Test forall (a, b, c, d, e, f) in nat: a < b < c < d < e < f failed (4 shrink steps): (0, 0, 0, 0, 0, 0) --- Failure -------------------------------------------------------------------- Test forall (a, b, c, d, e, f, g) in nat: a < b < c < d < e < f < g failed (5 shrink steps): (0, 0, 0, 0, 0, 0, 0) --- Failure -------------------------------------------------------------------- Test forall (a, b, c, d, e, f, g, h) in nat: a < b < c < d < e < f < g < h failed (6 shrink steps): (0, 0, 0, 0, 0, 0, 0, 0) --- Failure -------------------------------------------------------------------- Test forall (a, b, c, d, e, f, g, h, i) in nat: a < b < c < d < e < f < g < h < i failed (7 shrink steps): (0, 0, 0, 0, 0, 0, 0, 0, 0) --- Failure -------------------------------------------------------------------- Test bind ordered pairs failed (1 shrink steps): (0, 0) --- Failure -------------------------------------------------------------------- Test bind list_size constant failed (12 shrink steps): (4, [0; 0; 0; 0]) --- Failure -------------------------------------------------------------------- Test lists are empty failed (4 shrink steps): [0] --- Failure -------------------------------------------------------------------- Test lists shorter than 10 failed (15 shrink steps): [0; 0; 0; 0; 0; 0; 0; 0; 0; 0] --- Failure -------------------------------------------------------------------- Test lists shorter than 432 failed (418 shrink steps): [...] list length: 432 --- Failure -------------------------------------------------------------------- Test lists shorter than 4332 failed (4005 shrink steps): [...] list length: 4332 --- Failure -------------------------------------------------------------------- Test lists have unique elems failed (3 shrink steps): [0; 0] --- Failure -------------------------------------------------------------------- Test int option are none failed (1 shrink steps): Some (0) --- Failure -------------------------------------------------------------------- Test int option are some 100 or more failed (0 shrink steps): None --- Failure -------------------------------------------------------------------- Test (int,string) result are Ok failed (5 shrink steps): Error ("") --- Failure -------------------------------------------------------------------- Test (int,string) result are Error failed (1 shrink steps): Ok (0) --- Failure -------------------------------------------------------------------- Test tree contains only 42 failed (1 shrink steps): Leaf 0 --- Failure -------------------------------------------------------------------- Test sum list = 0 failed (0 shrink steps): [0; 1; 80; 0; 9; 2; 3] --- Failure -------------------------------------------------------------------- Test fail_pred_map_commute_int failed (54 shrink steps): ([0], {0 -> 74; _ -> 0}, {74 -> true; _ -> false}) --- Failure -------------------------------------------------------------------- Test fail_pred_map_commute_int32 failed (53 shrink steps): ([0l], {0l -> 99l; _ -> 0l}, {99l -> true; _ -> false}) --- Failure -------------------------------------------------------------------- Test fail_pred_map_commute_int64 failed (109 shrink steps): ([0L], {0L -> 1L; _ -> 0L}, {1L -> true; _ -> false}) --- Failure -------------------------------------------------------------------- Test fail_pred_strings failed (1 shrink steps): {"some random string" -> true; _ -> false} --- Failure -------------------------------------------------------------------- Test fold_left fold_right failed (24 shrink steps): (0, [1], {(0, 1) -> 1; _ -> 0}) +++ Messages ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Messages for test fold_left fold_right: l=[1], fold_left=0, fold_right=1 --- Failure -------------------------------------------------------------------- Test fold_left fold_right uncurried failed (115 shrink steps): ({(6, 0) -> 1; _ -> 0}, 0, [6]) --- Failure -------------------------------------------------------------------- Test fold_left fold_right uncurried fun last failed (19 shrink steps): (0, [1], {(0, 1) -> 1; _ -> 0}) --- Failure -------------------------------------------------------------------- Test fold_left test, fun first failed (50 shrink steps): ({("", 5) -> "a"; _ -> ""}, "", [0; 5], [0]) --- Failure -------------------------------------------------------------------- Test FAIL_#99_1 failed: ERROR: uncaught exception in generator for test FAIL_#99_1 after 100 steps: Exception: QCheck2.No_example_found("") Backtrace: +++ Collect ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Collect results for test bool dist: true: 250511 cases false: 249489 cases +++ Stats for char code dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats char code: num: 500000, avg: 127.68, stddev: 73.87, median 128, min 0, max 255 0.. 12: ##################################################### 25272 13.. 25: ###################################################### 25326 26.. 38: ##################################################### 25194 39.. 51: ###################################################### 25359 52.. 64: ###################################################### 25338 65.. 77: ###################################################### 25349 78.. 90: ###################################################### 25397 91..103: ##################################################### 25243 104..116: ###################################################### 25420 117..129: ###################################################### 25438 130..142: ###################################################### 25346 143..155: ##################################################### 25177 156..168: ####################################################### 25755 169..181: ###################################################### 25408 182..194: ###################################################### 25633 195..207: ###################################################### 25613 208..220: ###################################################### 25459 221..233: ###################################################### 25322 234..246: ##################################################### 25229 247..259: ##################################### 17722 +++ Stats for printable char code dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats char code: num: 500000, avg: 78.23, stddev: 28.13, median 78, min 10, max 126 10.. 15: ######### 5167 16.. 21: 0 22.. 27: 0 28.. 33: ################## 10338 34.. 39: ###################################################### 31469 40.. 45: ###################################################### 30994 46.. 51: ###################################################### 31366 52.. 57: ###################################################### 31369 58.. 63: ####################################################### 31531 64.. 69: ###################################################### 31208 70.. 75: ###################################################### 31228 76.. 81: ###################################################### 31514 82.. 87: ###################################################### 31209 88.. 93: ###################################################### 31207 94.. 99: ###################################################### 31342 100..105: ###################################################### 31273 106..111: ###################################################### 31116 112..117: ###################################################### 31022 118..123: ##################################################### 30911 124..129: ########################### 15736 +++ Stats for numeral char code dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats char code: num: 500000, avg: 52.50, stddev: 2.87, median 53, min 48, max 57 48: ###################################################### 49848 49: ###################################################### 50118 50: ###################################################### 49837 51: ###################################################### 50252 52: ###################################################### 49765 53: ####################################################### 50369 54: ###################################################### 50270 55: ###################################################### 49885 56: ###################################################### 49821 57: ###################################################### 49835 +++ Stats for tree's depth ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats depth: num: 1000, avg: 3.90, stddev: 3.44, median 3, min 1, max 15 1: ####################################################### 376 2: ############## 98 3: ############ 84 4: #################### 139 5: ########## 71 6: ## 18 7: ####### 49 8: ####### 49 9: # 12 10: ### 25 11: ###### 43 12: 6 13: # 10 14: # 13 15: # 7 +++ Stats for bytes_size len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 7.52, stddev: 1.71, median 7, min 5, max 10 5: ################################################# 799 6: #################################################### 846 7: ###################################################### 874 8: ################################################### 824 9: ################################################ 774 10: ####################################################### 883 +++ Stats for bytes len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 373.39, stddev: 1294.83, median 9, min 0, max 9936 0.. 496: ####################################################### 4268 497.. 993: ###### 482 994..1490: 26 1491..1987: 14 1988..2484: 11 2485..2981: 12 2982..3478: 17 3479..3975: 16 3976..4472: 11 4473..4969: 7 4970..5466: 14 5467..5963: 10 5964..6460: 19 6461..6957: 17 6958..7454: 9 7455..7951: 12 7952..8448: 19 8449..8945: 7 8946..9442: 14 9443..9939: 15 +++ Stats for bytes_of len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 373.39, stddev: 1294.83, median 9, min 0, max 9936 0.. 496: ####################################################### 4268 497.. 993: ###### 482 994..1490: 26 1491..1987: 14 1988..2484: 11 2485..2981: 12 2982..3478: 17 3479..3975: 16 3976..4472: 11 4473..4969: 7 4970..5466: 14 5467..5963: 10 5964..6460: 19 6461..6957: 17 6958..7454: 9 7455..7951: 12 7952..8448: 19 8449..8945: 7 8946..9442: 14 9443..9939: 15 +++ Stats for bytes_printable len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 373.39, stddev: 1294.83, median 9, min 0, max 9936 0.. 496: ####################################################### 4268 497.. 993: ###### 482 994..1490: 26 1491..1987: 14 1988..2484: 11 2485..2981: 12 2982..3478: 17 3479..3975: 16 3976..4472: 11 4473..4969: 7 4970..5466: 14 5467..5963: 10 5964..6460: 19 6461..6957: 17 6958..7454: 9 7455..7951: 12 7952..8448: 19 8449..8945: 7 8946..9442: 14 9443..9939: 15 +++ Stats for bytes_small len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 15.50, stddev: 24.07, median 6, min 0, max 99 0.. 4: ##################################################### 1927 5.. 9: ####################################################### 1974 10.. 14: # 58 15.. 19: # 55 20.. 24: # 59 25.. 29: # 59 30.. 34: # 61 35.. 39: # 58 40.. 44: # 70 45.. 49: # 65 50.. 54: # 61 55.. 59: # 62 60.. 64: # 54 65.. 69: ## 81 70.. 74: # 62 75.. 79: # 58 80.. 84: # 67 85.. 89: # 55 90.. 94: # 59 95.. 99: # 55 +++ Stats for string_size len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 7.52, stddev: 1.71, median 7, min 5, max 10 5: ################################################# 799 6: #################################################### 846 7: ###################################################### 874 8: ################################################### 824 9: ################################################ 774 10: ####################################################### 883 +++ Stats for string len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 373.39, stddev: 1294.83, median 9, min 0, max 9936 0.. 496: ####################################################### 4268 497.. 993: ###### 482 994..1490: 26 1491..1987: 14 1988..2484: 11 2485..2981: 12 2982..3478: 17 3479..3975: 16 3976..4472: 11 4473..4969: 7 4970..5466: 14 5467..5963: 10 5964..6460: 19 6461..6957: 17 6958..7454: 9 7455..7951: 12 7952..8448: 19 8449..8945: 7 8946..9442: 14 9443..9939: 15 +++ Stats for string_of len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 373.39, stddev: 1294.83, median 9, min 0, max 9936 0.. 496: ####################################################### 4268 497.. 993: ###### 482 994..1490: 26 1491..1987: 14 1988..2484: 11 2485..2981: 12 2982..3478: 17 3479..3975: 16 3976..4472: 11 4473..4969: 7 4970..5466: 14 5467..5963: 10 5964..6460: 19 6461..6957: 17 6958..7454: 9 7455..7951: 12 7952..8448: 19 8449..8945: 7 8946..9442: 14 9443..9939: 15 +++ Stats for string_printable len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 373.39, stddev: 1294.83, median 9, min 0, max 9936 0.. 496: ####################################################### 4268 497.. 993: ###### 482 994..1490: 26 1491..1987: 14 1988..2484: 11 2485..2981: 12 2982..3478: 17 3479..3975: 16 3976..4472: 11 4473..4969: 7 4970..5466: 14 5467..5963: 10 5964..6460: 19 6461..6957: 17 6958..7454: 9 7455..7951: 12 7952..8448: 19 8449..8945: 7 8946..9442: 14 9443..9939: 15 +++ Stats for small_string len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 15.50, stddev: 24.07, median 6, min 0, max 99 0.. 4: ##################################################### 1927 5.. 9: ####################################################### 1974 10.. 14: # 58 15.. 19: # 55 20.. 24: # 59 25.. 29: # 59 30.. 34: # 61 35.. 39: # 58 40.. 44: # 70 45.. 49: # 65 50.. 54: # 61 55.. 59: # 62 60.. 64: # 54 65.. 69: ## 81 70.. 74: # 62 75.. 79: # 58 80.. 84: # 67 85.. 89: # 55 90.. 94: # 59 95.. 99: # 55 +++ Stats for pair dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats pair sum: num: 500000, avg: 100.10, stddev: 41.22, median 100, min 0, max 200 0.. 9: ### 2753 10.. 19: ######## 7572 20.. 29: ############## 12416 30.. 39: #################### 17234 40.. 49: ######################### 22216 50.. 59: ############################### 27110 60.. 69: ##################################### 32089 70.. 79: ########################################## 36885 80.. 89: ################################################ 41775 90.. 99: ###################################################### 46764 100..109: ####################################################### 47231 110..119: ################################################# 42910 120..129: ########################################### 37485 130..139: ###################################### 32673 140..149: ################################ 27901 150..159: ########################## 22900 160..169: #################### 17756 170..179: ############## 12867 180..189: ######### 8198 190..199: ### 3206 200..209: 59 +++ Stats for triple dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats triple sum: num: 500000, avg: 149.97, stddev: 50.47, median 150, min 2, max 300 2.. 16: 436 17.. 31: ## 2462 32.. 46: ###### 6168 47.. 61: ########### 11181 62.. 76: ################# 17966 77.. 91: ########################## 26835 92..106: #################################### 36662 107..121: ############################################# 46199 122..136: #################################################### 52565 137..151: ####################################################### 55318 152..166: ###################################################### 54923 167..181: ################################################## 51081 182..196: ############################################ 44563 197..211: ################################## 34853 212..226: ######################## 24865 227..241: ################ 16598 242..256: ######### 10006 257..271: ##### 5146 272..286: # 1935 287..301: 238 +++ Stats for quad dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats quad sum: num: 500000, avg: 200.11, stddev: 58.32, median 200, min 5, max 398 5.. 24: 93 25.. 44: 803 45.. 64: ## 2950 65.. 84: ###### 7307 85..104: ############ 14442 105..124: ##################### 25228 125..144: ################################ 37961 145..164: ########################################## 50311 165..184: ################################################## 60055 185..204: ####################################################### 65159 205..224: ##################################################### 63845 225..244: ############################################### 56537 245..264: ###################################### 45021 265..284: ########################### 32167 285..304: ################ 19919 305..324: ######### 10874 325..344: #### 5069 345..364: # 1849 365..384: 393 385..404: 17 +++ Stats for bind dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats ordered pair difference: num: 1000000, avg: 25.01, stddev: 22.36, median 19, min 0, max 100 0.. 4: ####################################################### 193620 5.. 9: #################################### 129807 10.. 14: ############################# 103875 15.. 19: ######################## 87161 20.. 24: ##################### 74588 25.. 29: ################## 64327 30.. 34: ################ 56519 35.. 39: ############## 49825 40.. 44: ############ 43263 45.. 49: ########## 37612 50.. 54: ######### 32623 55.. 59: ####### 28125 60.. 64: ###### 24206 65.. 69: ##### 20107 70.. 74: #### 16712 75.. 79: ### 13309 80.. 84: ## 10347 85.. 89: ## 7339 90.. 94: # 4591 95.. 99: 1957 100..104: 87 stats ordered pair sum: num: 1000000, avg: 75.09, stddev: 46.93, median 72, min 0, max 200 0.. 9: ####################################################### 70091 10.. 19: ##################################################### 68426 20.. 29: ##################################################### 68723 30.. 39: ##################################################### 68717 40.. 49: ##################################################### 68445 50.. 59: ##################################################### 68798 60.. 69: ##################################################### 68591 70.. 79: ##################################################### 68385 80.. 89: ##################################################### 68603 90.. 99: ##################################################### 68647 100..109: ################################################## 64063 110..119: ########################################### 55810 120..129: ##################################### 47218 130..139: ############################### 39763 140..149: ######################### 32908 150..159: #################### 26241 160..169: ############### 20137 170..179: ########### 14180 180..189: ###### 8622 190..199: ## 3523 200..209: 109 +++ Collect ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Collect results for test option dist: None : 1481 cases Some _: 8519 cases +++ Collect ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Collect results for test result dist: Error _: 2475 cases Ok _ : 7525 cases +++ Stats for list len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 373.39, stddev: 1294.83, median 9, min 0, max 9936 0.. 496: ####################################################### 4268 497.. 993: ###### 482 994..1490: 26 1491..1987: 14 1988..2484: 11 2485..2981: 12 2982..3478: 17 3479..3975: 16 3976..4472: 11 4473..4969: 7 4970..5466: 14 5467..5963: 10 5964..6460: 19 6461..6957: 17 6958..7454: 9 7455..7951: 12 7952..8448: 19 8449..8945: 7 8946..9442: 14 9443..9939: 15 +++ Stats for small_list len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 15.50, stddev: 24.07, median 6, min 0, max 99 0.. 4: ##################################################### 1927 5.. 9: ####################################################### 1974 10.. 14: # 58 15.. 19: # 55 20.. 24: # 59 25.. 29: # 59 30.. 34: # 61 35.. 39: # 58 40.. 44: # 70 45.. 49: # 65 50.. 54: # 61 55.. 59: # 62 60.. 64: # 54 65.. 69: ## 81 70.. 74: # 62 75.. 79: # 58 80.. 84: # 67 85.. 89: # 55 90.. 94: # 59 95.. 99: # 55 +++ Stats for list_size len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 7.52, stddev: 1.71, median 7, min 5, max 10 5: ################################################# 799 6: #################################################### 846 7: ###################################################### 874 8: ################################################### 824 9: ################################################ 774 10: ####################################################### 883 +++ Stats for list_repeat len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 42.00, stddev: 0.00, median 42, min 42, max 42 42: ####################################################### 5000 +++ Stats for array len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 373.39, stddev: 1294.83, median 9, min 0, max 9936 0.. 496: ####################################################### 4268 497.. 993: ###### 482 994..1490: 26 1491..1987: 14 1988..2484: 11 2485..2981: 12 2982..3478: 17 3479..3975: 16 3976..4472: 11 4473..4969: 7 4970..5466: 14 5467..5963: 10 5964..6460: 19 6461..6957: 17 6958..7454: 9 7455..7951: 12 7952..8448: 19 8449..8945: 7 8946..9442: 14 9443..9939: 15 +++ Stats for small_array len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 15.50, stddev: 24.07, median 6, min 0, max 99 0.. 4: ##################################################### 1927 5.. 9: ####################################################### 1974 10.. 14: # 58 15.. 19: # 55 20.. 24: # 59 25.. 29: # 59 30.. 34: # 61 35.. 39: # 58 40.. 44: # 70 45.. 49: # 65 50.. 54: # 61 55.. 59: # 62 60.. 64: # 54 65.. 69: ## 81 70.. 74: # 62 75.. 79: # 58 80.. 84: # 67 85.. 89: # 55 90.. 94: # 59 95.. 99: # 55 +++ Stats for array_size len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 7.52, stddev: 1.71, median 7, min 5, max 10 5: ################################################# 799 6: #################################################### 846 7: ###################################################### 874 8: ################################################### 824 9: ################################################ 774 10: ####################################################### 883 +++ Stats for array_repeat len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 42.00, stddev: 0.00, median 42, min 42, max 42 42: ####################################################### 5000 +++ Stats for int_stats_neg ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 5000, avg: 0.43, stddev: 28.63, median 0, min -99, max 99 -99..-90: # 45 -89..-80: # 57 -79..-70: # 68 -69..-60: # 58 -59..-50: # 76 -49..-40: # 67 -39..-30: # 52 -29..-20: # 54 -19..-10: # 47 -9.. 0: ####################################################### 2205 1.. 10: ########################################## 1697 11.. 20: # 57 21.. 30: # 70 31.. 40: # 60 41.. 50: # 66 51.. 60: # 75 61.. 70: # 68 71.. 80: # 63 81.. 90: # 66 91..100: # 49 +++ Stats for small_signed_int dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 0.86, stddev: 29.11, median 0, min -97, max 99 -97..-88: # 12 -87..-78: # 12 -77..-68: # 13 -67..-58: # 12 -57..-48: # 9 -47..-38: ## 17 -37..-28: # 13 -27..-18: # 8 -17.. -8: ######### 76 -7.. 2: ####################################################### 437 3.. 12: ################################## 276 13.. 22: ## 16 23.. 32: # 11 33.. 42: ## 16 43.. 52: # 9 53.. 62: # 12 63.. 72: # 14 73.. 82: # 12 83.. 92: # 13 93..102: # 12 +++ Stats for small_nat dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 15.86, stddev: 24.57, median 6, min 0, max 99 0.. 4: ###################################################### 387 5.. 9: ####################################################### 390 10.. 14: # 11 15.. 19: # 8 20.. 24: # 11 25.. 29: ## 15 30.. 34: # 9 35.. 39: # 11 40.. 44: # 11 45.. 49: ## 19 50.. 54: # 10 55.. 59: ## 19 60.. 64: # 9 65.. 69: # 9 70.. 74: ## 19 75.. 79: # 13 80.. 84: # 11 85.. 89: ## 16 90.. 94: # 9 95.. 99: # 13 +++ Stats for nat dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 382.03, stddev: 1290.55, median 9, min 0, max 9890 0.. 494: ####################################################### 850 495.. 989: ###### 93 990..1484: 8 1485..1979: 3 1980..2474: 7 2475..2969: 1 2970..3464: 3 3465..3959: 3 3960..4454: 3 4455..4949: 4 4950..5444: 3 5445..5939: 3 5940..6434: 3 6435..6929: 1 6930..7424: 2 7425..7919: 1 7920..8414: 1 8415..8909: 5 8910..9404: 3 9405..9899: 3 +++ Stats for int_range (-43643) 435434 dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 193479.13, stddev: 136696.70, median 189823, min -43164, max 434961 -43164..-19258: ################################### 42 -19257.. 4649: ############################################## 56 4650.. 28556: ############################################# 55 28557.. 52463: ############################################### 57 52464.. 76370: ######################################### 50 76371..100277: ############################# 35 100278..124184: ############################################### 57 124185..148091: #################################### 44 148092..171998: ############################################## 56 171999..195905: ####################################################### 66 195906..219812: ########################################### 52 219813..243719: ######################################## 49 243720..267626: ################################ 39 267627..291533: ##################################### 45 291534..315440: ##################################### 45 315441..339347: ################################################# 59 339348..363254: ################################################## 60 363255..387161: ################################# 40 387162..411068: ########################################## 51 411069..434975: ################################### 42 +++ Stats for int_range (-40000) 40000 dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: -591.06, stddev: 23026.79, median -911, min -39911, max 39959 -39911..-35918: ####################################### 45 -35917..-31924: #################################################### 59 -31923..-27930: ########################################### 49 -27929..-23936: ########################################## 48 -23935..-19942: ####################################################### 62 -19941..-15948: ############################################# 51 -15947..-11954: ######################################### 47 -11953.. -7960: ################################################# 56 -7959.. -3966: ################################### 40 -3965.. 28: ################################################### 58 29.. 4022: ########################################### 49 4023.. 8016: ############################################### 53 8017.. 12010: ############################################ 50 12011.. 16004: ################################### 40 16005.. 19998: ####################################### 44 19999.. 23992: ####################################################### 62 23993.. 27986: ##################################### 42 27987.. 31980: ######################################### 47 31981.. 35974: ########################################## 48 35975.. 39968: ############################################ 50 +++ Stats for int_range (-4) 4 dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: -0.12, stddev: 2.52, median 0, min -4, max 4 -4: ########################################## 116 -3: ###################################### 103 -2: ############################################## 125 -1: ########################################## 115 0: ####################################### 106 1: ####################################################### 149 2: ################################# 92 3: ################################# 92 4: ##################################### 102 +++ Stats for int_range (-4) 17 dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 6.42, stddev: 6.43, median 6, min -4, max 17 -4..-3: ########################################### 89 -2..-1: ################################################# 101 0.. 1: ############################################## 95 2.. 3: ########################################### 89 4.. 5: ############################################## 95 6.. 7: ##################################### 78 8.. 9: ####################################### 81 10..11: ######################################## 84 12..13: ####################################################### 113 14..15: ######################################## 84 16..17: ############################################ 91 18..19: 0 20..21: 0 22..23: 0 24..25: 0 26..27: 0 28..29: 0 30..31: 0 32..33: 0 34..35: 0 +++ Stats for int dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 100000, avg: 1375300.54, stddev: 6.201e+8, median -3852464, min -1073736753, max 1073733862 -1073736753.. -966363223: #################################################### 4972 -966363222.. -858989692: ##################################################### 5032 -858989691.. -751616161: #################################################### 4928 -751616160.. -644242630: #################################################### 4920 -644242629.. -536869099: ##################################################### 5037 -536869098.. -429495568: #################################################### 4964 -429495567.. -322122037: ##################################################### 5020 -322122036.. -214748506: ##################################################### 4995 -214748505.. -107374975: ####################################################### 5175 -107374974.. -1444: ###################################################### 5156 -1443.. 107372087: ################################################### 4824 107372088.. 214745618: ##################################################### 5043 214745619.. 322119149: #################################################### 4899 322119150.. 429492680: #################################################### 4959 429492681.. 536866211: #################################################### 4920 536866212.. 644239742: ##################################################### 5036 644239743.. 751613273: ##################################################### 5049 751613274.. 858986804: #################################################### 4913 858986805.. 966360335: ##################################################### 5040 966360336.. 1073733866: ###################################################### 5118 +++ Stats for oneof int dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 1073741.60, stddev: 6.731e+8, median 0, min -1073741824, max 1073741823 -1073741824.. -966367642: ################# 198 -966367641.. -858993459: 0 -858993458.. -751619276: 0 -751619275.. -644245093: 0 -644245092.. -536870910: 0 -536870909.. -429496727: 0 -429496726.. -322122544: 0 -322122543.. -214748361: 0 -214748360.. -107374178: 0 -107374177.. 5: ####################################################### 607 6.. 107374188: 0 107374189.. 214748371: 0 214748372.. 322122554: 0 322122555.. 429496737: 0 429496738.. 536870920: 0 536870921.. 644245103: 0 644245104.. 751619286: 0 751619287.. 858993469: 0 858993470.. 966367652: 0 966367653.. 1073741823: ################# 195 +++ Stats for int32 lower dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 10000, avg: 32719.66, stddev: 18976.66, median 32730, min 9, max 65532 9.. 3285: ################################################### 506 3286.. 6562: #################################################### 508 6563.. 9839: ################################################# 481 9840..13116: ################################################### 506 13117..16393: #################################################### 517 16394..19670: #################################################### 512 19671..22947: ################################################## 496 22948..26224: #################################################### 510 26225..29501: ################################################# 486 29502..32778: ################################################## 491 32779..36055: ################################################## 495 36056..39332: ################################################## 489 39333..42609: ################################################## 493 42610..45886: ####################################################### 537 45887..49163: ################################################## 497 49164..52440: ################################################# 479 52441..55717: ################################################## 493 55718..58994: ################################################## 494 58995..62271: ################################################# 481 62272..65548: ###################################################### 529 +++ Stats for int32 upper dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 10000, avg: 32555.02, stddev: 18918.49, median 32323, min 3, max 65534 3.. 3279: ###################################################### 547 3280.. 6556: ################################################ 482 6557.. 9833: ############################################### 473 9834..13110: ################################################## 509 13111..16387: ################################################## 507 16388..19664: ################################################## 507 19665..22941: ################################################ 482 22942..26218: ##################################################### 536 26219..29495: ####################################################### 550 29496..32772: ############################################## 468 32773..36049: #################################################### 528 36050..39326: ################################################ 488 39327..42603: ################################################ 483 42604..45880: ################################################ 489 45881..49157: ############################################# 450 49158..52434: ################################################ 483 52435..55711: ###################################################### 548 55712..58988: ################################################ 489 58989..62265: ################################################# 498 62266..65542: ################################################ 483 +++ Stats for int64 lower dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 10000, avg: 32452.50, stddev: 18981.40, median 32331, min 22, max 65532 22.. 3297: ##################################################### 533 3298.. 6573: ##################################################### 528 6574.. 9849: ################################################### 510 9850..13125: ################################################### 506 13126..16401: ################################################ 476 16402..19677: ################################################# 489 19678..22953: ####################################################### 543 22954..26229: ################################################# 486 26230..29505: ################################################## 501 29506..32781: ################################################## 501 32782..36057: ################################################### 505 36058..39333: ############################################## 463 39334..42609: ################################################## 498 42610..45885: #################################################### 517 45886..49161: ################################################### 510 49162..52437: ############################################### 471 52438..55713: ################################################## 497 55714..58989: ################################################## 494 58990..62265: ############################################# 454 62266..65541: #################################################### 518 +++ Stats for int64 lower-mid dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 10000, avg: 32748.75, stddev: 18818.12, median 32802, min 3, max 65533 3.. 3279: ################################################### 500 3280.. 6556: ################################################### 506 6557.. 9833: ############################################### 464 9834..13110: ################################################### 502 13111..16387: ################################################## 496 16388..19664: #################################################### 513 19665..22941: ################################################## 490 22942..26218: ####################################################### 538 26219..29495: ##################################################### 524 29496..32772: ############################################### 462 32773..36049: ################################################## 494 36050..39326: ##################################################### 523 39327..42603: ################################################### 504 42604..45880: ##################################################### 525 45881..49157: ################################################ 477 49158..52434: ################################################# 487 52435..55711: ##################################################### 527 55712..58988: #################################################### 509 58989..62265: ################################################ 470 62266..65542: ################################################# 489 +++ Stats for int64 upper-mid dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 10000, avg: 32869.52, stddev: 18881.85, median 33046, min 9, max 65529 9.. 3284: ################################################## 489 3285.. 6560: ################################################# 486 6561.. 9836: ################################################### 504 9837..13112: ################################################## 492 13113..16388: ###################################################### 528 16389..19664: ################################################## 494 19665..22940: ############################################### 461 22941..26216: ###################################################### 533 26217..29492: ################################################## 489 29493..32768: ################################################# 486 32769..36044: ################################################## 495 36045..39320: ##################################################### 518 39321..42596: ################################################### 504 42597..45872: ####################################################### 535 45873..49148: ################################################ 472 49149..52424: #################################################### 513 52425..55700: ################################################### 499 55701..58976: ##################################################### 517 58977..62252: #################################################### 508 62253..65528: ################################################ 476 65529..68804: 1 +++ Stats for int64 upper dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 10000, avg: 32499.47, stddev: 18881.21, median 32265, min 5, max 65534 5.. 3281: ###################################################### 547 3282.. 6558: ################################################ 484 6559.. 9835: ############################################# 460 9836..13112: ################################################## 505 13113..16389: ##################################################### 536 16390..19666: ################################################# 496 19667..22943: ################################################ 492 22944..26220: ################################################# 502 26221..29497: ##################################################### 540 29498..32774: ################################################## 508 32775..36051: ####################################################### 554 36052..39328: ################################################ 491 39329..42605: ################################################# 498 42606..45882: ############################################## 467 45883..49159: ############################################ 447 49160..52436: ############################################### 475 52437..55713: ################################################## 508 55714..58990: ################################################### 515 58991..62267: ################################################# 499 62268..65544: ############################################### 476 +++ Stats for exponential 10. dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 5000, avg: 9.45, stddev: 9.82, median 6, min 0, max 79 0.. 3: ####################################################### 1631 4.. 7: ##################################### 1109 8..11: ######################### 747 12..15: ################# 512 16..19: ########## 308 20..23: ######## 251 24..27: ##### 165 28..31: ## 85 32..35: ## 64 36..39: # 43 40..43: 25 44..47: 20 48..51: 20 52..55: 3 56..59: 8 60..63: 3 64..67: 1 68..71: 2 72..75: 2 76..79: 1 +++ Stats for exponential -10. dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 5000, avg: -9.45, stddev: 9.82, median -6, min -79, max 0 -79..-76: 1 -75..-72: 2 -71..-68: 2 -67..-64: 1 -63..-60: 3 -59..-56: 8 -55..-52: 3 -51..-48: 20 -47..-44: 20 -43..-40: 25 -39..-36: # 43 -35..-32: ## 64 -31..-28: ## 85 -27..-24: ##### 165 -23..-20: ######## 251 -19..-16: ########## 308 -15..-12: ################# 512 -11.. -8: ######################### 747 -7.. -4: ##################################### 1109 -3.. 0: ####################################################### 1631 ================================================================================ 1 warning(s) failure (75 tests failed, 3 tests errored, ran 167 tests) random seed: 153870556 +++ Stats for int_dist_empty_bucket ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 1.219e+7, stddev: 4.513e+8, median 10, min -1073230792, max 1073741823 -1073230792.. -965882162: ## 19 -965882161.. -858533531: ### 30 -858533530.. -751184900: ### 29 -751184899.. -643836269: ## 23 -643836268.. -536487638: ### 29 -536487637.. -429139007: ## 20 -429139006.. -321790376: ## 22 -321790375.. -214441745: ## 27 -214441744.. -107093114: ### 30 -107093113.. 255517: ####################################################### 512 255518.. 107604148: ## 20 107604149.. 214952779: ## 21 214952780.. 322301410: ### 28 322301411.. 429650041: ## 25 429650042.. 536998672: ## 26 536998673.. 644347303: ## 27 644347304.. 751695934: ### 30 751695935.. 859044565: ## 20 859044566.. 966393196: ### 34 966393197.. 1073741823: ### 28 ================================================================================ success (ran 1 tests) qcheck-0.25/test/core/QCheck2_expect_test.expected.ocaml5.64000066400000000000000000003017771477416744200236250ustar00rootroot00000000000000random seed: 1234 45 4 0 0 0 0 0 0 0 0 0 0 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 (8,fun,0) (4,fun,19) (5,fun,32) (54,fun,1) (6,fun,4) (2,fun,6) (2,fun,5) (77,fun,3) (6,fun,1) (1,fun,73) (8,fun,0) (4,fun,19) (5,fun,32) (54,fun,1) (6,fun,4) (2,fun,6) (2,fun,5) (77,fun,3) (6,fun,1) (1,fun,73) (8,fun,0) (4,fun,19) (5,fun,32) (54,fun,1) (6,fun,4) (2,fun,6) (2,fun,5) (77,fun,3) (6,fun,1) (1,fun,73) (8,fun,0) (4,fun,19) (5,fun,32) (54,fun,1) (6,fun,4) (2,fun,6) (2,fun,5) (77,fun,3) (6,fun,1) (1,fun,73) (8,fun,0) (4,fun,19) (5,fun,32) (54,fun,1) (6,fun,4) (2,fun,6) (2,fun,5) (77,fun,3) (6,fun,1) (1,fun,73) (8,fun,0) (4,fun,19) (5,fun,32) (54,fun,1) (6,fun,4) (2,fun,6) (2,fun,5) (77,fun,3) (6,fun,1) (1,fun,73) (8,fun,0) (4,fun,19) (5,fun,32) (54,fun,1) (6,fun,4) (2,fun,6) (2,fun,5) (77,fun,3) (6,fun,1) (1,fun,73) (8,fun,0) (4,fun,19) (5,fun,32) (54,fun,1) (6,fun,4) (2,fun,6) (2,fun,5) (77,fun,3) (6,fun,1) (1,fun,73) 1443152170069087821 0 721576085034543910 0 360788042517271955 0 180394021258635977 0 90197010629317988 0 45098505314658994 0 22549252657329497 0 11274626328664748 0 5637313164332374 0 2818656582166187 0 1409328291083093 0 704664145541546 0 352332072770773 0 176166036385386 0 88083018192693 0 44041509096346 0 22020754548173 0 11010377274086 0 5505188637043 0 2752594318521 0 1376297159260 0 688148579630 0 344074289815 0 172037144907 0 86018572453 0 43009286226 0 21504643113 0 10752321556 0 5376160778 0 2688080389 0 1344040194 0 672020097 0 336010048 0 168005024 0 84002512 0 42001256 0 21000628 0 10500314 0 5250157 0 2625078 0 1312539 0 656269 0 328134 0 164067 0 82033 0 41016 0 20508 0 10254 0 5127 0 2563 0 1281 0 640 0 320 0 160 0 80 0 40 0 20 0 10 0 5 0 2 0 1 0 [0; 1; 80; 0; 9; 2; 3] [0; 1; 80; 0] [0; 1] [1] [] [0] [0; 1; 80; 0; 9; 2; 3] [0; 1; 80; 0] [0; 1] [80; 0] [1; 80; 0] [0; 1; 0] [1; 0] [0; 0] [0] [0] --- Failure -------------------------------------------------------------------- Test should_fail_sort_id failed (8 shrink steps): [1; 0] --- Failure -------------------------------------------------------------------- Test max_fail failed (4 shrink steps): [0; 1] --- Failure -------------------------------------------------------------------- Test max_fail failed (8 shrink steps): [0; 1] --- Failure -------------------------------------------------------------------- Test max_fail failed (2 shrink steps): [0; 1] === Error ====================================================================== Test should_error_raise_exn errored on (1 shrink steps): 0 exception QCheck2_tests.Overall.Error +++ Collect ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Collect results for test collect_results: 4: 24 cases 3: 20 cases 2: 18 cases 1: 21 cases 0: 17 cases +++ Stats for with_stats ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats mod4: num: 100, avg: 1.56, stddev: 1.18, median 2, min 0, max 3 0: ################################################# 27 1: #################################### 20 2: ########################################## 23 3: ####################################################### 30 stats num: num: 100, avg: 62.24, stddev: 33.15, median 62, min 2, max 120 2.. 7: ######### 2 8.. 13: ################################ 7 14.. 19: ########################### 6 20.. 25: ############# 3 26.. 31: ###################### 5 32.. 37: ################## 4 38.. 43: ############# 3 44.. 49: ################################ 7 50.. 55: ################################ 7 56.. 61: ###################### 5 62.. 67: #################################### 8 68.. 73: ######### 2 74.. 79: ###################### 5 80.. 85: ######### 2 86.. 91: ####################################################### 12 92.. 97: ###################### 5 98..103: ################## 4 104..109: ################## 4 110..115: ############# 3 116..121: ########################### 6 --- Failure -------------------------------------------------------------------- Test with shrinking retries failed (0 shrink steps): 4 !!! Warning !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Warning for test WARN_unlikely_precond: WARNING: only 0.7% tests (of 2000) passed precondition for "WARN_unlikely_precond" NOTE: it is likely that the precondition is too strong, or that the generator is buggy. --- Failure -------------------------------------------------------------------- Test FAIL_unlikely_precond failed: ERROR: only 0.7% tests (of 2000) passed precondition for "FAIL_unlikely_precond" NOTE: it is likely that the precondition is too strong, or that the generator is buggy. --- Failure -------------------------------------------------------------------- Test FAIL_bad_gen failed: ERROR: uncaught exception in generator for test FAIL_bad_gen after 100 steps: Exception: Invalid_argument("Gen.int_bound") Backtrace: --- Failure -------------------------------------------------------------------- Test int double failed: Negative test int double succeeded but was expected to fail === Error ====================================================================== Test pos fail with error errored on (1 shrink steps): 0 exception QCheck2_tests.Overall.Error === Error ====================================================================== Test neg fail with error errored on (1 shrink steps): 0 exception QCheck2_tests.Overall.Error --- Failure -------------------------------------------------------------------- Test char never produces '\255' failed (0 shrink steps): '\255' --- Failure -------------------------------------------------------------------- Test big bound issue59 failed (0 shrink steps): 4611686018427387903 --- Failure -------------------------------------------------------------------- Test long_shrink failed (3113 shrink steps): ([0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0], [0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 1]) --- Failure -------------------------------------------------------------------- Test ints arent 0 mod 3 failed (1 shrink steps): 0 --- Failure -------------------------------------------------------------------- Test ints are 0 failed (60 shrink steps): 1 --- Failure -------------------------------------------------------------------- Test int32s arent 0l rem 3l failed (1 shrink steps): 0l --- Failure -------------------------------------------------------------------- Test int32s are 0l failed (30 shrink steps): 1l --- Failure -------------------------------------------------------------------- Test int64s arent 0L rem 3L failed (1 shrink steps): 0L --- Failure -------------------------------------------------------------------- Test int64s are 0L failed (62 shrink steps): 1L --- Failure -------------------------------------------------------------------- Test ints < 209609 failed (0 shrink steps): 4611686018427387903 --- Failure -------------------------------------------------------------------- Test nat < 5001 failed (6 shrink steps): 5001 --- Failure -------------------------------------------------------------------- Test char never produces 'abcdef' failed (1 shrink steps): 'a' --- Failure -------------------------------------------------------------------- Test printable never produces '!"#$%&' failed (1 shrink steps): '!' --- Failure -------------------------------------------------------------------- Test printable never produces less than '5 failed (0 shrink steps): '0' --- Failure -------------------------------------------------------------------- Test bytes are empty failed (4 shrink steps): "a" --- Failure -------------------------------------------------------------------- Test bytes never has a \000 char failed (6 shrink steps): "\000" --- Failure -------------------------------------------------------------------- Test bytes never has a \255 char failed (5 shrink steps): "\255" --- Failure -------------------------------------------------------------------- Test bytes have unique chars failed (27 shrink steps): "\253\253" --- Failure -------------------------------------------------------------------- Test strings are empty failed (4 shrink steps): "a" --- Failure -------------------------------------------------------------------- Test string never has a \000 char failed (6 shrink steps): "\000" --- Failure -------------------------------------------------------------------- Test string never has a \255 char failed (5 shrink steps): "\255" --- Failure -------------------------------------------------------------------- Test strings have unique chars failed (27 shrink steps): "\253\253" --- Failure -------------------------------------------------------------------- Test pairs have different components failed (0 shrink steps): (1, 1) --- Failure -------------------------------------------------------------------- Test pairs have same components failed (63 shrink steps): (0, 1) --- Failure -------------------------------------------------------------------- Test pairs have a zero component failed (123 shrink steps): (1, 1) --- Failure -------------------------------------------------------------------- Test pairs are (0,0) failed (63 shrink steps): (0, 1) --- Failure -------------------------------------------------------------------- Test pairs are ordered failed (100 shrink steps): (1, 0) --- Failure -------------------------------------------------------------------- Test pairs are ordered reversely failed (61 shrink steps): (0, 1) --- Failure -------------------------------------------------------------------- Test pairs sum to less than 128 failed (57 shrink steps): (0, 128) --- Failure -------------------------------------------------------------------- Test pairs lists rev concat failed (79 shrink steps): ([0], [1]) --- Failure -------------------------------------------------------------------- Test pairs lists no overlap failed (18 shrink steps): ([0], [0]) --- Failure -------------------------------------------------------------------- Test triples have pair-wise different components failed (3 shrink steps): (0, 0, 0) --- Failure -------------------------------------------------------------------- Test triples have same components failed (63 shrink steps): (0, 1, 0) --- Failure -------------------------------------------------------------------- Test triples are ordered failed (4 shrink steps): (0, 0, -1) --- Failure -------------------------------------------------------------------- Test triples are ordered reversely failed (61 shrink steps): (0, 0, 1) --- Failure -------------------------------------------------------------------- Test quadruples have pair-wise different components failed (4 shrink steps): (0, 0, 0, 0) --- Failure -------------------------------------------------------------------- Test quadruples have same components failed (127 shrink steps): (0, 1, 0, 1) --- Failure -------------------------------------------------------------------- Test quadruples are ordered failed (6 shrink steps): (0, 0, 0, -1) --- Failure -------------------------------------------------------------------- Test quadruples are ordered reversely failed (187 shrink steps): (0, 0, 0, 1) --- Failure -------------------------------------------------------------------- Test forall (a, b) in nat: a < b failed (1 shrink steps): (0, 0) --- Failure -------------------------------------------------------------------- Test forall (a, b, c) in nat: a < b < c failed (2 shrink steps): (0, 0, 0) --- Failure -------------------------------------------------------------------- Test forall (a, b, c, d) in nat: a < b < c < d failed (3 shrink steps): (0, 0, 0, 0) --- Failure -------------------------------------------------------------------- Test forall (a, b, c, d, e) in nat: a < b < c < d < e failed (3 shrink steps): (0, 0, 0, 0, 0) --- Failure -------------------------------------------------------------------- Test forall (a, b, c, d, e, f) in nat: a < b < c < d < e < f failed (4 shrink steps): (0, 0, 0, 0, 0, 0) --- Failure -------------------------------------------------------------------- Test forall (a, b, c, d, e, f, g) in nat: a < b < c < d < e < f < g failed (5 shrink steps): (0, 0, 0, 0, 0, 0, 0) --- Failure -------------------------------------------------------------------- Test forall (a, b, c, d, e, f, g, h) in nat: a < b < c < d < e < f < g < h failed (6 shrink steps): (0, 0, 0, 0, 0, 0, 0, 0) --- Failure -------------------------------------------------------------------- Test forall (a, b, c, d, e, f, g, h, i) in nat: a < b < c < d < e < f < g < h < i failed (7 shrink steps): (0, 0, 0, 0, 0, 0, 0, 0, 0) --- Failure -------------------------------------------------------------------- Test bind ordered pairs failed (1 shrink steps): (0, 0) --- Failure -------------------------------------------------------------------- Test bind list_size constant failed (12 shrink steps): (4, [0; 0; 0; 0]) --- Failure -------------------------------------------------------------------- Test lists are empty failed (4 shrink steps): [0] --- Failure -------------------------------------------------------------------- Test lists shorter than 10 failed (15 shrink steps): [0; 0; 0; 0; 0; 0; 0; 0; 0; 0] --- Failure -------------------------------------------------------------------- Test lists shorter than 432 failed (418 shrink steps): [...] list length: 432 --- Failure -------------------------------------------------------------------- Test lists shorter than 4332 failed (4005 shrink steps): [...] list length: 4332 --- Failure -------------------------------------------------------------------- Test lists have unique elems failed (3 shrink steps): [0; 0] --- Failure -------------------------------------------------------------------- Test int option are none failed (1 shrink steps): Some (0) --- Failure -------------------------------------------------------------------- Test int option are some 100 or more failed (0 shrink steps): None --- Failure -------------------------------------------------------------------- Test (int,string) result are Ok failed (5 shrink steps): Error ("") --- Failure -------------------------------------------------------------------- Test (int,string) result are Error failed (1 shrink steps): Ok (0) --- Failure -------------------------------------------------------------------- Test tree contains only 42 failed (1 shrink steps): Leaf 0 --- Failure -------------------------------------------------------------------- Test sum list = 0 failed (0 shrink steps): [0; 1; 80; 0; 9; 2; 3] --- Failure -------------------------------------------------------------------- Test fail_pred_map_commute_int failed (109 shrink steps): ([0], {0 -> 1; _ -> 0}, {1 -> true; _ -> false}) --- Failure -------------------------------------------------------------------- Test fail_pred_map_commute_int32 failed (53 shrink steps): ([0l], {0l -> 99l; _ -> 0l}, {99l -> true; _ -> false}) --- Failure -------------------------------------------------------------------- Test fail_pred_map_commute_int64 failed (109 shrink steps): ([0L], {0L -> 1L; _ -> 0L}, {1L -> true; _ -> false}) --- Failure -------------------------------------------------------------------- Test fail_pred_strings failed (1 shrink steps): {"some random string" -> true; _ -> false} --- Failure -------------------------------------------------------------------- Test fold_left fold_right failed (24 shrink steps): (0, [1], {(0, 1) -> 1; _ -> 0}) +++ Messages ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Messages for test fold_left fold_right: l=[1], fold_left=0, fold_right=1 --- Failure -------------------------------------------------------------------- Test fold_left fold_right uncurried failed (115 shrink steps): ({(6, 0) -> 1; _ -> 0}, 0, [6]) --- Failure -------------------------------------------------------------------- Test fold_left fold_right uncurried fun last failed (19 shrink steps): (0, [1], {(0, 1) -> 1; _ -> 0}) --- Failure -------------------------------------------------------------------- Test fold_left test, fun first failed (50 shrink steps): ({("", 5) -> "a"; _ -> ""}, "", [0; 5], [0]) --- Failure -------------------------------------------------------------------- Test FAIL_#99_1 failed: ERROR: uncaught exception in generator for test FAIL_#99_1 after 100 steps: Exception: QCheck2.No_example_found("") Backtrace: +++ Collect ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Collect results for test bool dist: true: 250511 cases false: 249489 cases +++ Stats for char code dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats char code: num: 500000, avg: 127.68, stddev: 73.87, median 128, min 0, max 255 0.. 12: ##################################################### 25272 13.. 25: ###################################################### 25326 26.. 38: ##################################################### 25194 39.. 51: ###################################################### 25359 52.. 64: ###################################################### 25338 65.. 77: ###################################################### 25349 78.. 90: ###################################################### 25397 91..103: ##################################################### 25243 104..116: ###################################################### 25420 117..129: ###################################################### 25438 130..142: ###################################################### 25346 143..155: ##################################################### 25177 156..168: ####################################################### 25755 169..181: ###################################################### 25408 182..194: ###################################################### 25633 195..207: ###################################################### 25613 208..220: ###################################################### 25459 221..233: ###################################################### 25322 234..246: ##################################################### 25229 247..259: ##################################### 17722 +++ Stats for printable char code dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats char code: num: 500000, avg: 78.23, stddev: 28.13, median 78, min 10, max 126 10.. 15: ######### 5167 16.. 21: 0 22.. 27: 0 28.. 33: ################## 10338 34.. 39: ###################################################### 31469 40.. 45: ###################################################### 30994 46.. 51: ###################################################### 31366 52.. 57: ###################################################### 31369 58.. 63: ####################################################### 31531 64.. 69: ###################################################### 31208 70.. 75: ###################################################### 31228 76.. 81: ###################################################### 31514 82.. 87: ###################################################### 31209 88.. 93: ###################################################### 31207 94.. 99: ###################################################### 31342 100..105: ###################################################### 31273 106..111: ###################################################### 31116 112..117: ###################################################### 31022 118..123: ##################################################### 30911 124..129: ########################### 15736 +++ Stats for numeral char code dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats char code: num: 500000, avg: 52.50, stddev: 2.87, median 53, min 48, max 57 48: ###################################################### 49848 49: ###################################################### 50118 50: ###################################################### 49837 51: ###################################################### 50252 52: ###################################################### 49765 53: ####################################################### 50369 54: ###################################################### 50270 55: ###################################################### 49885 56: ###################################################### 49821 57: ###################################################### 49835 +++ Stats for tree's depth ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats depth: num: 1000, avg: 3.90, stddev: 3.44, median 3, min 1, max 15 1: ####################################################### 376 2: ############## 98 3: ############ 84 4: #################### 139 5: ########## 71 6: ## 18 7: ####### 49 8: ####### 49 9: # 12 10: ### 25 11: ###### 43 12: 6 13: # 10 14: # 13 15: # 7 +++ Stats for bytes_size len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 7.52, stddev: 1.71, median 7, min 5, max 10 5: ################################################# 799 6: #################################################### 846 7: ###################################################### 874 8: ################################################### 824 9: ################################################ 774 10: ####################################################### 883 +++ Stats for bytes len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 373.39, stddev: 1294.83, median 9, min 0, max 9936 0.. 496: ####################################################### 4268 497.. 993: ###### 482 994..1490: 26 1491..1987: 14 1988..2484: 11 2485..2981: 12 2982..3478: 17 3479..3975: 16 3976..4472: 11 4473..4969: 7 4970..5466: 14 5467..5963: 10 5964..6460: 19 6461..6957: 17 6958..7454: 9 7455..7951: 12 7952..8448: 19 8449..8945: 7 8946..9442: 14 9443..9939: 15 +++ Stats for bytes_of len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 373.39, stddev: 1294.83, median 9, min 0, max 9936 0.. 496: ####################################################### 4268 497.. 993: ###### 482 994..1490: 26 1491..1987: 14 1988..2484: 11 2485..2981: 12 2982..3478: 17 3479..3975: 16 3976..4472: 11 4473..4969: 7 4970..5466: 14 5467..5963: 10 5964..6460: 19 6461..6957: 17 6958..7454: 9 7455..7951: 12 7952..8448: 19 8449..8945: 7 8946..9442: 14 9443..9939: 15 +++ Stats for bytes_printable len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 373.39, stddev: 1294.83, median 9, min 0, max 9936 0.. 496: ####################################################### 4268 497.. 993: ###### 482 994..1490: 26 1491..1987: 14 1988..2484: 11 2485..2981: 12 2982..3478: 17 3479..3975: 16 3976..4472: 11 4473..4969: 7 4970..5466: 14 5467..5963: 10 5964..6460: 19 6461..6957: 17 6958..7454: 9 7455..7951: 12 7952..8448: 19 8449..8945: 7 8946..9442: 14 9443..9939: 15 +++ Stats for bytes_small len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 15.50, stddev: 24.07, median 6, min 0, max 99 0.. 4: ##################################################### 1927 5.. 9: ####################################################### 1974 10.. 14: # 58 15.. 19: # 55 20.. 24: # 59 25.. 29: # 59 30.. 34: # 61 35.. 39: # 58 40.. 44: # 70 45.. 49: # 65 50.. 54: # 61 55.. 59: # 62 60.. 64: # 54 65.. 69: ## 81 70.. 74: # 62 75.. 79: # 58 80.. 84: # 67 85.. 89: # 55 90.. 94: # 59 95.. 99: # 55 +++ Stats for string_size len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 7.52, stddev: 1.71, median 7, min 5, max 10 5: ################################################# 799 6: #################################################### 846 7: ###################################################### 874 8: ################################################### 824 9: ################################################ 774 10: ####################################################### 883 +++ Stats for string len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 373.39, stddev: 1294.83, median 9, min 0, max 9936 0.. 496: ####################################################### 4268 497.. 993: ###### 482 994..1490: 26 1491..1987: 14 1988..2484: 11 2485..2981: 12 2982..3478: 17 3479..3975: 16 3976..4472: 11 4473..4969: 7 4970..5466: 14 5467..5963: 10 5964..6460: 19 6461..6957: 17 6958..7454: 9 7455..7951: 12 7952..8448: 19 8449..8945: 7 8946..9442: 14 9443..9939: 15 +++ Stats for string_of len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 373.39, stddev: 1294.83, median 9, min 0, max 9936 0.. 496: ####################################################### 4268 497.. 993: ###### 482 994..1490: 26 1491..1987: 14 1988..2484: 11 2485..2981: 12 2982..3478: 17 3479..3975: 16 3976..4472: 11 4473..4969: 7 4970..5466: 14 5467..5963: 10 5964..6460: 19 6461..6957: 17 6958..7454: 9 7455..7951: 12 7952..8448: 19 8449..8945: 7 8946..9442: 14 9443..9939: 15 +++ Stats for string_printable len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 373.39, stddev: 1294.83, median 9, min 0, max 9936 0.. 496: ####################################################### 4268 497.. 993: ###### 482 994..1490: 26 1491..1987: 14 1988..2484: 11 2485..2981: 12 2982..3478: 17 3479..3975: 16 3976..4472: 11 4473..4969: 7 4970..5466: 14 5467..5963: 10 5964..6460: 19 6461..6957: 17 6958..7454: 9 7455..7951: 12 7952..8448: 19 8449..8945: 7 8946..9442: 14 9443..9939: 15 +++ Stats for small_string len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 15.50, stddev: 24.07, median 6, min 0, max 99 0.. 4: ##################################################### 1927 5.. 9: ####################################################### 1974 10.. 14: # 58 15.. 19: # 55 20.. 24: # 59 25.. 29: # 59 30.. 34: # 61 35.. 39: # 58 40.. 44: # 70 45.. 49: # 65 50.. 54: # 61 55.. 59: # 62 60.. 64: # 54 65.. 69: ## 81 70.. 74: # 62 75.. 79: # 58 80.. 84: # 67 85.. 89: # 55 90.. 94: # 59 95.. 99: # 55 +++ Stats for pair dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats pair sum: num: 500000, avg: 100.10, stddev: 41.22, median 100, min 0, max 200 0.. 9: ### 2753 10.. 19: ######## 7572 20.. 29: ############## 12416 30.. 39: #################### 17234 40.. 49: ######################### 22216 50.. 59: ############################### 27110 60.. 69: ##################################### 32089 70.. 79: ########################################## 36885 80.. 89: ################################################ 41775 90.. 99: ###################################################### 46764 100..109: ####################################################### 47231 110..119: ################################################# 42910 120..129: ########################################### 37485 130..139: ###################################### 32673 140..149: ################################ 27901 150..159: ########################## 22900 160..169: #################### 17756 170..179: ############## 12867 180..189: ######### 8198 190..199: ### 3206 200..209: 59 +++ Stats for triple dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats triple sum: num: 500000, avg: 149.97, stddev: 50.47, median 150, min 2, max 300 2.. 16: 436 17.. 31: ## 2462 32.. 46: ###### 6168 47.. 61: ########### 11181 62.. 76: ################# 17966 77.. 91: ########################## 26835 92..106: #################################### 36662 107..121: ############################################# 46199 122..136: #################################################### 52565 137..151: ####################################################### 55318 152..166: ###################################################### 54923 167..181: ################################################## 51081 182..196: ############################################ 44563 197..211: ################################## 34853 212..226: ######################## 24865 227..241: ################ 16598 242..256: ######### 10006 257..271: ##### 5146 272..286: # 1935 287..301: 238 +++ Stats for quad dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats quad sum: num: 500000, avg: 200.11, stddev: 58.32, median 200, min 5, max 398 5.. 24: 93 25.. 44: 803 45.. 64: ## 2950 65.. 84: ###### 7307 85..104: ############ 14442 105..124: ##################### 25228 125..144: ################################ 37961 145..164: ########################################## 50311 165..184: ################################################## 60055 185..204: ####################################################### 65159 205..224: ##################################################### 63845 225..244: ############################################### 56537 245..264: ###################################### 45021 265..284: ########################### 32167 285..304: ################ 19919 305..324: ######### 10874 325..344: #### 5069 345..364: # 1849 365..384: 393 385..404: 17 +++ Stats for bind dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats ordered pair difference: num: 1000000, avg: 25.01, stddev: 22.36, median 19, min 0, max 100 0.. 4: ####################################################### 193620 5.. 9: #################################### 129807 10.. 14: ############################# 103875 15.. 19: ######################## 87161 20.. 24: ##################### 74588 25.. 29: ################## 64327 30.. 34: ################ 56519 35.. 39: ############## 49825 40.. 44: ############ 43263 45.. 49: ########## 37612 50.. 54: ######### 32623 55.. 59: ####### 28125 60.. 64: ###### 24206 65.. 69: ##### 20107 70.. 74: #### 16712 75.. 79: ### 13309 80.. 84: ## 10347 85.. 89: ## 7339 90.. 94: # 4591 95.. 99: 1957 100..104: 87 stats ordered pair sum: num: 1000000, avg: 75.09, stddev: 46.93, median 72, min 0, max 200 0.. 9: ####################################################### 70091 10.. 19: ##################################################### 68426 20.. 29: ##################################################### 68723 30.. 39: ##################################################### 68717 40.. 49: ##################################################### 68445 50.. 59: ##################################################### 68798 60.. 69: ##################################################### 68591 70.. 79: ##################################################### 68385 80.. 89: ##################################################### 68603 90.. 99: ##################################################### 68647 100..109: ################################################## 64063 110..119: ########################################### 55810 120..129: ##################################### 47218 130..139: ############################### 39763 140..149: ######################### 32908 150..159: #################### 26241 160..169: ############### 20137 170..179: ########### 14180 180..189: ###### 8622 190..199: ## 3523 200..209: 109 +++ Collect ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Collect results for test option dist: None : 1481 cases Some _: 8519 cases +++ Collect ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Collect results for test result dist: Error _: 2475 cases Ok _ : 7525 cases +++ Stats for list len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 373.39, stddev: 1294.83, median 9, min 0, max 9936 0.. 496: ####################################################### 4268 497.. 993: ###### 482 994..1490: 26 1491..1987: 14 1988..2484: 11 2485..2981: 12 2982..3478: 17 3479..3975: 16 3976..4472: 11 4473..4969: 7 4970..5466: 14 5467..5963: 10 5964..6460: 19 6461..6957: 17 6958..7454: 9 7455..7951: 12 7952..8448: 19 8449..8945: 7 8946..9442: 14 9443..9939: 15 +++ Stats for small_list len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 15.50, stddev: 24.07, median 6, min 0, max 99 0.. 4: ##################################################### 1927 5.. 9: ####################################################### 1974 10.. 14: # 58 15.. 19: # 55 20.. 24: # 59 25.. 29: # 59 30.. 34: # 61 35.. 39: # 58 40.. 44: # 70 45.. 49: # 65 50.. 54: # 61 55.. 59: # 62 60.. 64: # 54 65.. 69: ## 81 70.. 74: # 62 75.. 79: # 58 80.. 84: # 67 85.. 89: # 55 90.. 94: # 59 95.. 99: # 55 +++ Stats for list_size len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 7.52, stddev: 1.71, median 7, min 5, max 10 5: ################################################# 799 6: #################################################### 846 7: ###################################################### 874 8: ################################################### 824 9: ################################################ 774 10: ####################################################### 883 +++ Stats for list_repeat len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 42.00, stddev: 0.00, median 42, min 42, max 42 42: ####################################################### 5000 +++ Stats for array len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 373.39, stddev: 1294.83, median 9, min 0, max 9936 0.. 496: ####################################################### 4268 497.. 993: ###### 482 994..1490: 26 1491..1987: 14 1988..2484: 11 2485..2981: 12 2982..3478: 17 3479..3975: 16 3976..4472: 11 4473..4969: 7 4970..5466: 14 5467..5963: 10 5964..6460: 19 6461..6957: 17 6958..7454: 9 7455..7951: 12 7952..8448: 19 8449..8945: 7 8946..9442: 14 9443..9939: 15 +++ Stats for small_array len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 15.50, stddev: 24.07, median 6, min 0, max 99 0.. 4: ##################################################### 1927 5.. 9: ####################################################### 1974 10.. 14: # 58 15.. 19: # 55 20.. 24: # 59 25.. 29: # 59 30.. 34: # 61 35.. 39: # 58 40.. 44: # 70 45.. 49: # 65 50.. 54: # 61 55.. 59: # 62 60.. 64: # 54 65.. 69: ## 81 70.. 74: # 62 75.. 79: # 58 80.. 84: # 67 85.. 89: # 55 90.. 94: # 59 95.. 99: # 55 +++ Stats for array_size len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 7.52, stddev: 1.71, median 7, min 5, max 10 5: ################################################# 799 6: #################################################### 846 7: ###################################################### 874 8: ################################################### 824 9: ################################################ 774 10: ####################################################### 883 +++ Stats for array_repeat len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 42.00, stddev: 0.00, median 42, min 42, max 42 42: ####################################################### 5000 +++ Stats for int_stats_neg ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 5000, avg: 0.43, stddev: 28.63, median 0, min -99, max 99 -99..-90: # 45 -89..-80: # 57 -79..-70: # 68 -69..-60: # 58 -59..-50: # 76 -49..-40: # 67 -39..-30: # 52 -29..-20: # 54 -19..-10: # 47 -9.. 0: ####################################################### 2205 1.. 10: ########################################## 1697 11.. 20: # 57 21.. 30: # 70 31.. 40: # 60 41.. 50: # 66 51.. 60: # 75 61.. 70: # 68 71.. 80: # 63 81.. 90: # 66 91..100: # 49 +++ Stats for small_signed_int dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 0.86, stddev: 29.11, median 0, min -97, max 99 -97..-88: # 12 -87..-78: # 12 -77..-68: # 13 -67..-58: # 12 -57..-48: # 9 -47..-38: ## 17 -37..-28: # 13 -27..-18: # 8 -17.. -8: ######### 76 -7.. 2: ####################################################### 437 3.. 12: ################################## 276 13.. 22: ## 16 23.. 32: # 11 33.. 42: ## 16 43.. 52: # 9 53.. 62: # 12 63.. 72: # 14 73.. 82: # 12 83.. 92: # 13 93..102: # 12 +++ Stats for small_nat dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 15.86, stddev: 24.57, median 6, min 0, max 99 0.. 4: ###################################################### 387 5.. 9: ####################################################### 390 10.. 14: # 11 15.. 19: # 8 20.. 24: # 11 25.. 29: ## 15 30.. 34: # 9 35.. 39: # 11 40.. 44: # 11 45.. 49: ## 19 50.. 54: # 10 55.. 59: ## 19 60.. 64: # 9 65.. 69: # 9 70.. 74: ## 19 75.. 79: # 13 80.. 84: # 11 85.. 89: ## 16 90.. 94: # 9 95.. 99: # 13 +++ Stats for nat dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 382.03, stddev: 1290.55, median 9, min 0, max 9890 0.. 494: ####################################################### 850 495.. 989: ###### 93 990..1484: 8 1485..1979: 3 1980..2474: 7 2475..2969: 1 2970..3464: 3 3465..3959: 3 3960..4454: 3 4455..4949: 4 4950..5444: 3 5445..5939: 3 5940..6434: 3 6435..6929: 1 6930..7424: 2 7425..7919: 1 7920..8414: 1 8415..8909: 5 8910..9404: 3 9405..9899: 3 +++ Stats for int_range (-43643) 435434 dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 193479.13, stddev: 136696.70, median 189823, min -43164, max 434961 -43164..-19258: ################################### 42 -19257.. 4649: ############################################## 56 4650.. 28556: ############################################# 55 28557.. 52463: ############################################### 57 52464.. 76370: ######################################### 50 76371..100277: ############################# 35 100278..124184: ############################################### 57 124185..148091: #################################### 44 148092..171998: ############################################## 56 171999..195905: ####################################################### 66 195906..219812: ########################################### 52 219813..243719: ######################################## 49 243720..267626: ################################ 39 267627..291533: ##################################### 45 291534..315440: ##################################### 45 315441..339347: ################################################# 59 339348..363254: ################################################## 60 363255..387161: ################################# 40 387162..411068: ########################################## 51 411069..434975: ################################### 42 +++ Stats for int_range (-40000) 40000 dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: -591.06, stddev: 23026.79, median -911, min -39911, max 39959 -39911..-35918: ####################################### 45 -35917..-31924: #################################################### 59 -31923..-27930: ########################################### 49 -27929..-23936: ########################################## 48 -23935..-19942: ####################################################### 62 -19941..-15948: ############################################# 51 -15947..-11954: ######################################### 47 -11953.. -7960: ################################################# 56 -7959.. -3966: ################################### 40 -3965.. 28: ################################################### 58 29.. 4022: ########################################### 49 4023.. 8016: ############################################### 53 8017.. 12010: ############################################ 50 12011.. 16004: ################################### 40 16005.. 19998: ####################################### 44 19999.. 23992: ####################################################### 62 23993.. 27986: ##################################### 42 27987.. 31980: ######################################### 47 31981.. 35974: ########################################## 48 35975.. 39968: ############################################ 50 +++ Stats for int_range (-4) 4 dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: -0.12, stddev: 2.52, median 0, min -4, max 4 -4: ########################################## 116 -3: ###################################### 103 -2: ############################################## 125 -1: ########################################## 115 0: ####################################### 106 1: ####################################################### 149 2: ################################# 92 3: ################################# 92 4: ##################################### 102 +++ Stats for int_range (-4) 17 dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 6.42, stddev: 6.43, median 6, min -4, max 17 -4..-3: ########################################### 89 -2..-1: ################################################# 101 0.. 1: ############################################## 95 2.. 3: ########################################### 89 4.. 5: ############################################## 95 6.. 7: ##################################### 78 8.. 9: ####################################### 81 10..11: ######################################## 84 12..13: ####################################################### 113 14..15: ######################################## 84 16..17: ############################################ 91 18..19: 0 20..21: 0 22..23: 0 24..25: 0 26..27: 0 28..29: 0 30..31: 0 32..33: 0 34..35: 0 +++ Stats for int dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 100000, avg: -1.619e+16, stddev: 2.662e+18, median -19064865724378010, min -4611580124327955972, max 4611682453232767028 -4611580124327955972..-4150416995449919813: #################################################### 4939 -4150416995449919812..-3689253866571883653: ###################################################### 5114 -3689253866571883652..-3228090737693847493: ##################################################### 5019 -3228090737693847492..-2766927608815811333: ###################################################### 5064 -2766927608815811332..-2305764479937775173: ###################################################### 5071 -2305764479937775172..-1844601351059739013: ####################################################### 5132 -1844601351059739012..-1383438222181702853: ##################################################### 4949 -1383438222181702852.. -922275093303666693: ##################################################### 5015 -922275093303666692.. -461111964425630533: ##################################################### 4962 -461111964425630532.. 51164452405627: #################################################### 4934 51164452405628.. 461214293330441787: ##################################################### 5001 461214293330441788.. 922377422208477947: ###################################################### 5097 922377422208477948.. 1383540551086514107: ##################################################### 4949 1383540551086514108.. 1844703679964550267: ##################################################### 4994 1844703679964550268.. 2305866808842586427: ##################################################### 4969 2305866808842586428.. 2767029937720622587: ###################################################### 5055 2767029937720622588.. 3228193066598658747: ################################################### 4839 3228193066598658748.. 3689356195476694907: #################################################### 4912 3689356195476694908.. 4150519324354731067: ##################################################### 5027 4150519324354731068.. 4611682453232767227: ##################################################### 4958 +++ Stats for oneof int dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 4.612e+15, stddev: 2.891e+18, median 0, min -4611686018427387904, max 4611686018427387903 -4611686018427387904..-4150517416584649089: ################# 198 -4150517416584649088..-3689348814741910273: 0 -3689348814741910272..-3228180212899171457: 0 -3228180212899171456..-2767011611056432641: 0 -2767011611056432640..-2305843009213693825: 0 -2305843009213693824..-1844674407370955009: 0 -1844674407370955008..-1383505805528216193: 0 -1383505805528216192.. -922337203685477377: 0 -922337203685477376.. -461168601842738561: 0 -461168601842738560.. 255: ####################################################### 607 256.. 461168601842739071: 0 461168601842739072.. 922337203685477887: 0 922337203685477888.. 1383505805528216703: 0 1383505805528216704.. 1844674407370955519: 0 1844674407370955520.. 2305843009213694335: 0 2305843009213694336.. 2767011611056433151: 0 2767011611056433152.. 3228180212899171967: 0 3228180212899171968.. 3689348814741910783: 0 3689348814741910784.. 4150517416584649599: 0 4150517416584649600.. 4611686018427387903: ################# 195 +++ Stats for int32 lower dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 10000, avg: 32719.66, stddev: 18976.66, median 32730, min 9, max 65532 9.. 3285: ################################################### 506 3286.. 6562: #################################################### 508 6563.. 9839: ################################################# 481 9840..13116: ################################################### 506 13117..16393: #################################################### 517 16394..19670: #################################################### 512 19671..22947: ################################################## 496 22948..26224: #################################################### 510 26225..29501: ################################################# 486 29502..32778: ################################################## 491 32779..36055: ################################################## 495 36056..39332: ################################################## 489 39333..42609: ################################################## 493 42610..45886: ####################################################### 537 45887..49163: ################################################## 497 49164..52440: ################################################# 479 52441..55717: ################################################## 493 55718..58994: ################################################## 494 58995..62271: ################################################# 481 62272..65548: ###################################################### 529 +++ Stats for int32 upper dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 10000, avg: 32555.02, stddev: 18918.49, median 32323, min 3, max 65534 3.. 3279: ###################################################### 547 3280.. 6556: ################################################ 482 6557.. 9833: ############################################### 473 9834..13110: ################################################## 509 13111..16387: ################################################## 507 16388..19664: ################################################## 507 19665..22941: ################################################ 482 22942..26218: ##################################################### 536 26219..29495: ####################################################### 550 29496..32772: ############################################## 468 32773..36049: #################################################### 528 36050..39326: ################################################ 488 39327..42603: ################################################ 483 42604..45880: ################################################ 489 45881..49157: ############################################# 450 49158..52434: ################################################ 483 52435..55711: ###################################################### 548 55712..58988: ################################################ 489 58989..62265: ################################################# 498 62266..65542: ################################################ 483 +++ Stats for int64 lower dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 10000, avg: 32452.50, stddev: 18981.40, median 32331, min 22, max 65532 22.. 3297: ##################################################### 533 3298.. 6573: ##################################################### 528 6574.. 9849: ################################################### 510 9850..13125: ################################################### 506 13126..16401: ################################################ 476 16402..19677: ################################################# 489 19678..22953: ####################################################### 543 22954..26229: ################################################# 486 26230..29505: ################################################## 501 29506..32781: ################################################## 501 32782..36057: ################################################### 505 36058..39333: ############################################## 463 39334..42609: ################################################## 498 42610..45885: #################################################### 517 45886..49161: ################################################### 510 49162..52437: ############################################### 471 52438..55713: ################################################## 497 55714..58989: ################################################## 494 58990..62265: ############################################# 454 62266..65541: #################################################### 518 +++ Stats for int64 lower-mid dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 10000, avg: 32748.75, stddev: 18818.12, median 32802, min 3, max 65533 3.. 3279: ################################################### 500 3280.. 6556: ################################################### 506 6557.. 9833: ############################################### 464 9834..13110: ################################################### 502 13111..16387: ################################################## 496 16388..19664: #################################################### 513 19665..22941: ################################################## 490 22942..26218: ####################################################### 538 26219..29495: ##################################################### 524 29496..32772: ############################################### 462 32773..36049: ################################################## 494 36050..39326: ##################################################### 523 39327..42603: ################################################### 504 42604..45880: ##################################################### 525 45881..49157: ################################################ 477 49158..52434: ################################################# 487 52435..55711: ##################################################### 527 55712..58988: #################################################### 509 58989..62265: ################################################ 470 62266..65542: ################################################# 489 +++ Stats for int64 upper-mid dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 10000, avg: 32869.52, stddev: 18881.85, median 33046, min 9, max 65529 9.. 3284: ################################################## 489 3285.. 6560: ################################################# 486 6561.. 9836: ################################################### 504 9837..13112: ################################################## 492 13113..16388: ###################################################### 528 16389..19664: ################################################## 494 19665..22940: ############################################### 461 22941..26216: ###################################################### 533 26217..29492: ################################################## 489 29493..32768: ################################################# 486 32769..36044: ################################################## 495 36045..39320: ##################################################### 518 39321..42596: ################################################### 504 42597..45872: ####################################################### 535 45873..49148: ################################################ 472 49149..52424: #################################################### 513 52425..55700: ################################################### 499 55701..58976: ##################################################### 517 58977..62252: #################################################### 508 62253..65528: ################################################ 476 65529..68804: 1 +++ Stats for int64 upper dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 10000, avg: 32499.47, stddev: 18881.21, median 32265, min 5, max 65534 5.. 3281: ###################################################### 547 3282.. 6558: ################################################ 484 6559.. 9835: ############################################# 460 9836..13112: ################################################## 505 13113..16389: ##################################################### 536 16390..19666: ################################################# 496 19667..22943: ################################################ 492 22944..26220: ################################################# 502 26221..29497: ##################################################### 540 29498..32774: ################################################## 508 32775..36051: ####################################################### 554 36052..39328: ################################################ 491 39329..42605: ################################################# 498 42606..45882: ############################################## 467 45883..49159: ############################################ 447 49160..52436: ############################################### 475 52437..55713: ################################################## 508 55714..58990: ################################################### 515 58991..62267: ################################################# 499 62268..65544: ############################################### 476 +++ Stats for exponential 10. dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 5000, avg: 9.45, stddev: 9.82, median 6, min 0, max 79 0.. 3: ####################################################### 1631 4.. 7: ##################################### 1109 8..11: ######################### 747 12..15: ################# 512 16..19: ########## 308 20..23: ######## 251 24..27: ##### 165 28..31: ## 85 32..35: ## 64 36..39: # 43 40..43: 25 44..47: 20 48..51: 20 52..55: 3 56..59: 8 60..63: 3 64..67: 1 68..71: 2 72..75: 2 76..79: 1 +++ Stats for exponential -10. dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 5000, avg: -9.45, stddev: 9.82, median -6, min -79, max 0 -79..-76: 1 -75..-72: 2 -71..-68: 2 -67..-64: 1 -63..-60: 3 -59..-56: 8 -55..-52: 3 -51..-48: 20 -47..-44: 20 -43..-40: 25 -39..-36: # 43 -35..-32: ## 64 -31..-28: ## 85 -27..-24: ##### 165 -23..-20: ######## 251 -19..-16: ########## 308 -15..-12: ################# 512 -11.. -8: ######################### 747 -7.. -4: ##################################### 1109 -3.. 0: ####################################################### 1631 ================================================================================ 1 warning(s) failure (75 tests failed, 3 tests errored, ran 167 tests) random seed: 153870556 +++ Stats for int_dist_empty_bucket ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 9.626e+16, stddev: 1.859e+18, median 10, min -4602121864537469332, max 4611686018427387903 -4602121864537469332..-4141431470389226517: # 17 -4141431470389226516..-3680741076240983701: ## 19 -3680741076240983700..-3220050682092740885: ## 19 -3220050682092740884..-2759360287944498069: ### 29 -2759360287944498068..-2298669893796255253: ## 22 -2298669893796255252..-1837979499648012437: ## 27 -1837979499648012436..-1377289105499769621: ### 30 -1377289105499769620.. -916598711351526805: ### 35 -916598711351526804.. -455908317203283989: ## 24 -455908317203283988.. 4782076944958827: ####################################################### 519 4782076944958828.. 465472471093201643: ## 25 465472471093201644.. 926162865241444459: ## 21 926162865241444460.. 1386853259389687275: ## 24 1386853259389687276.. 1847543653537930091: ## 27 1847543653537930092.. 2308234047686172907: ## 25 2308234047686172908.. 2768924441834415723: ## 26 2768924441834415724.. 3229614835982658539: ### 29 3229614835982658540.. 3690305230130901355: ## 28 3690305230130901356.. 4150995624279144171: ## 24 4150995624279144172.. 4611686018427386987: ### 29 4611686018427386988.. 4611686018427387903: 1 ================================================================================ success (ran 1 tests) qcheck-0.25/test/core/QCheck2_expect_test.ml000066400000000000000000000006111477416744200210040ustar00rootroot00000000000000open QCheck2_tests (* Calling runners *) let () = QCheck_base_runner.set_seed 1234 let _ = QCheck_base_runner.run_tests ~colors:false ( Overall.tests @ Generator.tests @ Shrink.tests @ Function.tests @ FindExample.tests @ Stats.tests) let () = QCheck_base_runner.set_seed 153870556 let _ = QCheck_base_runner.run_tests ~colors:false [Stats.int_dist_empty_bucket] qcheck-0.25/test/core/QCheck2_tests.ml000066400000000000000000001156111477416744200176260ustar00rootroot00000000000000(** QCheck2 tests **) (* Please add any additional tests to both [QCheck_tests.ml] and [QCheck2_tests.ml]. This ensures that both generator approaches continue to work as expected and furthermore allows us to compare their behaviour with [diff -y test/core/QCheck_expect_test.expected test/core/QCheck2_expect_test.expected] *) (** Module representing a integer tree data structure, used in tests *) module IntTree = struct type tree = Leaf of int | Node of tree * tree let leaf x = Leaf x let node x y = Node (x,y) let rec depth = function | Leaf _ -> 1 | Node (x, y) -> 1 + max (depth x) (depth y) let rec print_tree = function | Leaf x -> Printf.sprintf "Leaf %d" x | Node (x, y) -> Printf.sprintf "Node (%s, %s)" (print_tree x) (print_tree y) let gen_tree = QCheck2.Gen.(sized @@ fix (fun self n -> match n with | 0 -> map leaf nat | n -> frequency [1, map leaf nat; 2, map2 node (self (n/2)) (self (n/2))] )) let rec rev_tree = function | Node (x, y) -> Node (rev_tree y, rev_tree x) | Leaf x -> Leaf x let rec contains_only_n tree n = match tree with | Leaf n' -> n = n' | Node (x, y) -> contains_only_n x n && contains_only_n y n end (* tests of overall functionality *) module Overall = struct open QCheck2 let passing = Test.make ~name:"list_rev_is_involutive" ~count:100 ~long_factor:100 ~print:Print.(list int) Gen.(list small_int) (fun l -> List.rev (List.rev l) = l) let failing = Test.make ~name:"should_fail_sort_id" ~count:10 ~print:Print.(list int) Gen.(small_list small_int) (fun l -> l = List.sort compare l) let max_fail = Test.make ~name:"max_fail" ~count:1000 ~max_fail:3 ~print:Print.(list int) Gen.(list small_nat) (fun l -> l = List.rev l) exception Error let error = Test.make ~name:"should_error_raise_exn" ~count:10 ~print:Print.int Gen.int (fun _ -> raise Error) let collect = Test.make ~name:"collect_results" ~count:100 ~long_factor:100 ~print:Print.int ~collect:string_of_int (Gen.int_bound 4) (fun _ -> true) let stats = Test.make ~name:"with_stats" ~count:100 ~long_factor:100 ~print:Print.int ~stats:[ "mod4", (fun i->i mod 4); "num", (fun i->i); ] (Gen.int_bound 120) (fun _ -> true) let retries = Test.make ~name:"with shrinking retries" ~retries:10 ~print:Print.int Gen.small_nat (fun i -> Printf.printf "%i %!" i; i mod 3 <> 1) let bad_assume_warn = Test.make ~name:"WARN_unlikely_precond" ~count:2_000 ~print:Print.int Gen.int (fun x -> QCheck.assume (x mod 100 = 1); true) let bad_assume_fail = Test.make ~name:"FAIL_unlikely_precond" ~count:2_000 ~if_assumptions_fail:(`Fatal, 0.1) ~print:Print.int Gen.int (fun x -> QCheck.assume (x mod 100 = 1); true) let bad_gen_fail = Test.make ~name:"FAIL_bad_gen" Gen.(int >>= fun j -> int_bound j >>= fun i -> return (i,j)) (fun (_i,_j) -> true) (* i may be negative, causing int_bound to fail *) let bad_shrinker_fail = Test.make ~name:"FAIL_bad_shrinker" (Gen.make_primitive ~shrink:(fun _i -> raise Error) ~gen:(fun rs -> Random.State.int rs)) (fun _i -> false) let neg_test_fail_as_expected = Test.make_neg ~name:"all ints are even" ~print:Print.int Gen.small_int (fun i -> i mod 2 = 0) let neg_test_unexpected_success = Test.make_neg ~name:"int double" ~print:Print.int Gen.small_int (fun i -> i + i = i * 2) let neg_test_fail_with_shrinking = Test.make_neg ~name:"list rev concat" ~print:Print.(pair (list int) (list int)) Gen.(pair (list small_int) (list small_int)) (fun (is,js) -> (List.rev is)@(List.rev js) = List.rev (is@js)) let pos_test_fails_with_error = Test.make ~name:"pos fail with error" ~print:Print.int Gen.small_int (fun _i -> raise Error) let neg_test_fail_with_error = Test.make_neg ~name:"neg fail with error" ~print:Print.int Gen.small_int (fun _i -> raise Error) (* [apply_n f x n] computes f(f(...f(x))) with n applications of f *) let rec apply_n f x n = if n=0 then x else apply_n f (f x) (pred n) (* test from #236 *) let bad_fun_repro = let sleep_time = 0.175 in let count = ref 0 in Test.make ~count:10 ~name:"bad function reproducability" Gen.(triple small_int (fun1 Observable.int small_int) small_int) (fun (i,f,j) -> incr count; Printf.printf "(%i,fun,%i)%s%!" i j (if !count mod 10 = 0 then "\n" else " "); Unix.sleepf sleep_time; if 1 = Float.to_int (Unix.time ()) mod 2 then (ignore(apply_n (Fn.apply f) i j > 0); true) else (ignore(apply_n (Fn.apply f) i i > 0); true)) let tests = [ passing; failing; max_fail; error; collect; stats; retries; bad_assume_warn; bad_assume_fail; bad_gen_fail; (*bad_shrinker_fail;*) neg_test_fail_as_expected; neg_test_unexpected_success; neg_test_fail_with_shrinking; pos_test_fails_with_error; neg_test_fail_with_error; (* we repeat the following multiple times to check the expected output for duplicate lines *) bad_fun_repro; bad_fun_repro; bad_fun_repro; bad_fun_repro; bad_fun_repro; bad_fun_repro; bad_fun_repro; bad_fun_repro; ] end (* positive tests of the various generators *) module Generator = struct open QCheck2 (* example from issue #23 *) let char_dist_issue_23 = Test.make ~name:"char never produces '\\255'" ~count:1_000_000 ~print:Print.char Gen.char (fun c -> c <> '\255') let char_test = Test.make ~name:"char has right range'" ~count:1000 ~print:Print.char Gen.char (fun c -> '\000' <= c && c <= '\255') let printable_test = Test.make ~name:"printable has right range" ~count:1000 ~print:Print.char Gen.printable (fun c -> c = '\n' || 32 <= Char.code c && Char.code c <= 126) let numeral_test = Test.make ~name:"numeral has right range" ~count:1000 ~print:Print.char Gen.numeral (fun c -> '0' <= c && c <= '9') let nat_test = Test.make ~name:"nat has right range" ~count:1000 ~print:Print.int Gen.nat (fun n -> 0 <= n && n < 10000) let int_test = Test.make ~name:"int doubling" ~count:1000 ~print:Print.int Gen.int (fun i -> i+i = 2*i) let int32_test = Test.make ~name:"int32 doubling" ~count:1000 ~print:Print.int32 Gen.int32 (fun i -> Int32.add i i = Int32.mul 2l i) let int64_test = Test.make ~name:"int64 doubling" ~count:1000 ~print:Print.int64 Gen.int64 (fun i -> Int64.add i i = Int64.mul 2L i) let bytes_test = Test.make ~name:"bytes has right length and content" ~count:1000 ~print:Print.bytes Gen.bytes (fun s -> let len = Bytes.length s in 0 <= len && len < 10000 && Bytes.to_seq s |> Seq.fold_left (fun acc c -> acc && '\000' <= c && c <= '\255') true) let string_test = Test.make ~name:"string has right length and content" ~count:1000 ~print:Print.string Gen.string (fun s -> let len = String.length s in 0 <= len && len < 10000 && String.to_seq s |> Seq.fold_left (fun acc c -> acc && '\000' <= c && c <= '\255') true) let pair_test = Test.make ~name:"int pairs - commute over +" ~count:1000 ~print:Print.(pair int int) Gen.(pair small_nat small_nat) (fun (i,j) -> i+j = j+i) let triple_test = Test.make ~name:"int triples - associative over +" ~count:1000 ~print:Print.(triple int int int) Gen.(triple small_nat small_nat small_nat) (fun (i,j,k) -> i+(j+k) = (i+j)+k) let quad_test = Test.make ~name:"int quadruples - product of sums" ~count:1000 ~print:Print.(quad int int int int) Gen.(quad small_nat small_nat small_nat small_nat) (fun (h,i,j,k) -> (h+i)*(j+k) = h*j + h*k + i*j + i*k) let test_tup2 = Test.make ~count:10 ~name:"forall x in (0, 1): x = (0, 1)" Gen.(tup2 (pure 0) (pure 1)) (fun x -> x = (0, 1)) let test_tup3 = Test.make ~count:10 ~name:"forall x in (0, 1, 2): x = (0, 1, 2)" Gen.(tup3 (pure 0) (pure 1) (pure 2)) (fun x -> x = (0, 1, 2)) let test_tup4 = Test.make ~count:10 ~name:"forall x in (0, 1, 2, 3): x = (0, 1, 2, 3)" Gen.(tup4 (pure 0) (pure 1) (pure 2) (pure 3)) (fun x -> x = (0, 1, 2, 3)) let test_tup5 = Test.make ~count:10 ~name:"forall x in (0, 1, 2, 3, 4): x = (0, 1, 2, 3, 4)" Gen.(tup5 (pure 0) (pure 1) (pure 2) (pure 3) (pure 4)) (fun x -> x = (0, 1, 2, 3, 4)) let test_tup6 = Test.make ~count:10 ~name:"forall x in (0, 1, 2, 3, 4, 5): x = (0, 1, 2, 3, 4, 5)" Gen.(tup6 (pure 0) (pure 1) (pure 2) (pure 3) (pure 4) (pure 5)) (fun x -> x = (0, 1, 2, 3, 4, 5)) let test_tup7 = Test.make ~count:10 ~name:"forall x in (0, 1, 2, 3, 4, 5, 6): x = (0, 1, 2, 3, 4, 5, 6)" Gen.(tup7 (pure 0) (pure 1) (pure 2) (pure 3) (pure 4) (pure 5) (pure 6)) (fun x -> x = (0, 1, 2, 3, 4, 5, 6)) let test_tup8 = Test.make ~count:10 ~name:"forall x in (0, 1, 2, 3, 4, 5, 6, 7): x = (0, 1, 2, 3, 4, 5, 6, 7)" Gen.(tup8 (pure 0) (pure 1) (pure 2) (pure 3) (pure 4) (pure 5) (pure 6) (pure 7)) (fun x -> x = (0, 1, 2, 3, 4, 5, 6, 7)) let test_tup9 = Test.make ~count:10 ~name:"forall x in (0, 1, 2, 3, 4, 5, 6, 7, 8): x = (0, 1, 2, 3, 4, 5, 6, 7, 8)" Gen.(tup9 (pure 0) (pure 1) (pure 2) (pure 3) (pure 4) (pure 5) (pure 6) (pure 7) (pure 8)) (fun x -> x = (0, 1, 2, 3, 4, 5, 6, 7, 8)) let bind_test = Test.make ~name:"bind test for ordered pairs" ~count:1000 ~print:Print.(pair int int) Gen.(small_nat >>= fun j -> int_bound j >>= fun i -> return (i,j)) (fun (i,j) -> i<=j) let bind_pair_list_length = Test.make ~name:"bind list length" ~count:1000 ~print:Print.(pair int (list int)) Gen.(int_bound 1000 >>= fun len -> list_size (return len) (int_bound 10) >>= fun xs -> return (len,xs)) (fun (len,xs) -> len = List.length xs) let list_test = Test.make ~name:"list has right length" ~count:1000 ~print:Print.(list unit) Gen.(list unit) (fun l -> let len = List.length l in 0 <= len && len < 10_000) let list_repeat_test = Test.make ~name:"list_repeat has constant length" ~count:1000 ~print:Print.(pair int (list unit)) Gen.(small_nat >>= fun i -> list_repeat i unit >>= fun l -> return (i,l)) (fun (i,l) -> List.length l = i) let array_repeat_test = Test.make ~name:"array_repeat has constant length" ~count:1000 ~print:Print.(pair int (array unit)) Gen.(small_nat >>= fun i -> array_repeat i unit >>= fun l -> return (i,l)) (fun (i,l) -> Array.length l = i) let int_option_test = Test.make ~name:"int option right range" ~count:1000 ~print:Print.(option int) Gen.(option (int_bound 1000)) (function None -> true | Some i -> 0 <= i && i <= 1000) let int_string_result_test = Test.make ~name:"(int,string) result right range" ~count:1000 ~print:Print.(result int string) Gen.(result (int_bound 1000) string_small) (function Ok i -> 0 <= i && i <= 1000 | Error s -> String.length s < 100) let passing_tree_rev = Test.make ~name:"tree_rev_is_involutive" ~count:1000 IntTree.gen_tree (fun tree -> IntTree.(rev_tree (rev_tree tree)) = tree) let tests = [ char_dist_issue_23; char_test; nat_test; int_test; int32_test; int64_test; bytes_test; string_test; pair_test; triple_test; quad_test; test_tup2; test_tup3; test_tup4; test_tup5; test_tup6; test_tup7; test_tup8; test_tup9; bind_test; bind_pair_list_length; list_test; list_repeat_test; array_repeat_test; int_option_test; int_string_result_test; passing_tree_rev; ] end (* negative tests that exercise shrinking behaviour *) module Shrink = struct open QCheck2 let rec fac n = match n with | 0 -> 1 | n -> n * fac (n - 1) (* example from issue #59 *) let test_fac_issue59 = Test.make ~name:"test fac issue59" (Gen.make_primitive ~gen:(fun st -> Gen.generate1 ~rand:st (Gen.small_int_corners ())) ~shrink:(fun _ -> Seq.empty)) (fun n -> try (fac n) mod n = 0 with (*| Stack_overflow -> false*) | Division_by_zero -> (n=0)) let big_bound_issue59 = Test.make ~name:"big bound issue59" ~print:Print.int (Gen.small_int_corners()) (fun i -> i < 209609) let long_shrink = let listgen = Gen.(list_size (int_range 1000 10000) int) in Test.make ~name:"long_shrink" ~print:Print.(pair (list int) (list int)) (Gen.pair listgen listgen) (fun (xs,ys) -> List.rev (xs@ys) = (List.rev xs)@(List.rev ys)) (* test from issue #36 *) let ints_arent_0_mod_3 = Test.make ~name:"ints arent 0 mod 3" ~count:1000 ~print:Print.int Gen.int (fun i -> i mod 3 <> 0) let ints_are_0 = Test.make ~name:"ints are 0" ~count:1000 ~print:Print.int Gen.int (fun i -> Printf.printf "%i\n" i; i = 0) let int32s_arent_0l_rem_3l = Test.make ~name:"int32s arent 0l rem 3l" ~count:1000 ~print:Print.int32 Gen.int32 (fun i -> Int32.rem i 3l <> 0l) let int32s_are_0l = Test.make ~name:"int32s are 0l" ~count:1000 ~print:Print.int32 Gen.int32 (fun i -> i = 0l) let int64s_arent_0L_rem_3L = Test.make ~name:"int64s arent 0L rem 3L" ~count:1000 ~print:Print.int64 Gen.int64 (fun i -> Int64.rem i 3L <> 0L) let int64s_are_0L = Test.make ~name:"int64s are 0L" ~count:1000 ~print:Print.int64 Gen.int64 (fun i -> i = 0L) (* test from issue #59 *) let ints_smaller_209609 = Test.make ~name:"ints < 209609" ~print:Print.int (Gen.small_int_corners()) (fun i -> i < 209609) let nats_smaller_5001 = Test.make ~name:"nat < 5001" ~count:1000 ~print:Print.int Gen.nat (fun n -> n < 5001) let char_is_never_abcdef = Test.make ~name:"char never produces 'abcdef'" ~count:1000 ~print:Print.char Gen.char (fun c -> not (List.mem c ['a';'b';'c';'d';'e';'f'])) let printable_is_never_sign = (* should shrink towards '!' with lowest ascii code 33 *) Test.make ~name:"printable never produces '!\"#$%&'" ~count:1000 ~print:Print.char Gen.printable (fun c -> not (List.mem c ['!';'"';'#';'$';'%';'&'])) let numeral_is_never_less_5 = Test.make ~name:"printable never produces less than '5" ~count:1000 ~print:Print.char Gen.numeral (fun c -> c >= '5') let bytes_are_empty = Test.make ~name:"bytes are empty" ~count:1000 ~print:Print.bytes Gen.bytes (fun s -> s = Bytes.empty) let bytes_never_has_000_char = Test.make ~name:"bytes never has a \\000 char" ~count:1000 ~print:Print.bytes Gen.bytes (fun s -> Bytes.to_seq s |> Seq.fold_left (fun acc c -> acc && c <> '\000') true) let bytes_never_has_255_char = Test.make ~name:"bytes never has a \\255 char" ~count:1000 ~print:Print.bytes Gen.bytes (fun s -> Bytes.to_seq s |> Seq.fold_left (fun acc c -> acc && c <> '\255') true) let bytes_unique_chars = Test.make ~name:"bytes have unique chars" ~count:1000 ~print:Print.bytes Gen.bytes (fun s -> let ch_list = Bytes.to_seq s |> List.of_seq in List.length ch_list = List.length (List.sort_uniq Char.compare ch_list)) let strings_are_empty = Test.make ~name:"strings are empty" ~count:1000 ~print:Print.string Gen.string (fun s -> s = "") let string_never_has_000_char = Test.make ~name:"string never has a \\000 char" ~count:1000 ~print:Print.string Gen.string (fun s -> String.to_seq s |> Seq.fold_left (fun acc c -> acc && c <> '\000') true) let string_never_has_255_char = Test.make ~name:"string never has a \\255 char" ~count:1000 ~print:Print.string Gen.string (fun s -> String.to_seq s |> Seq.fold_left (fun acc c -> acc && c <> '\255') true) let string_unique_chars = Test.make ~name:"strings have unique chars" ~count:1000 ~print:Print.string Gen.string (fun s -> let ch_list = String.to_seq s |> List.of_seq in List.length ch_list = List.length (List.sort_uniq Char.compare ch_list)) (* test from issue #167 *) let pair_diff_issue_64 = Test.make ~name:"pairs have different components" ~print:Print.(pair int int) Gen.(pair small_int small_int) (fun (i,j) -> i<>j) let pair_same = Test.make ~name:"pairs have same components" ~print:Print.(pair int int) Gen.(pair int int) (fun (i,j) -> i=j) let pair_one_zero = Test.make ~name:"pairs have a zero component" ~print:Print.(pair int int) Gen.(pair int int) (fun (i,j) -> i=0 || j=0) let pair_all_zero = Test.make ~name:"pairs are (0,0)" ~print:Print.(pair int int) Gen.(pair int int) (fun (i,j) -> i=0 && j=0) let pair_ordered = Test.make ~name:"pairs are ordered" ~print:Print.(pair int int) Gen.(pair (pint ~origin:0) (pint ~origin:0)) (fun (i,j) -> i<=j) let pair_ordered_rev = Test.make ~name:"pairs are ordered reversely" ~print:Print.(pair int int) Gen.(pair (pint ~origin:0) (pint ~origin:0)) (fun (i,j) -> i>=j) let pair_sum_lt_128 = Test.make ~name:"pairs sum to less than 128" ~print:Print.(pair int int) Gen.(pair (pint ~origin:0) (pint ~origin:0)) (fun (i,j) -> i+j<128) let pair_lists_rev_concat = Test.make ~name:"pairs lists rev concat" ~print:Print.(pair (list int) (list int)) Gen.(pair (list (pint ~origin:0)) (list (pint ~origin:0))) (fun (xs,ys) -> List.rev (xs@ys) = (List.rev xs)@(List.rev ys)) let pair_lists_no_overlap = Test.make ~name:"pairs lists no overlap" ~print:Print.(pair (list int) (list int)) Gen.(pair (list small_nat) (list small_nat)) (fun (xs,ys) -> List.for_all (fun x -> not (List.mem x ys)) xs) let triple_diff = Test.make ~name:"triples have pair-wise different components" ~print:Print.(triple int int int) Gen.(triple small_int small_int small_int) (fun (i,j,k) -> i<>j && j<>k) let triple_same = Test.make ~name:"triples have same components" ~print:Print.(triple int int int) Gen.(triple int int int) (fun (i,j,k) -> i=j || j=k) let triple_ordered = Test.make ~name:"triples are ordered" ~print:Print.(triple int int int) Gen.(triple int int int) (fun (i,j,k) -> i<=j && j<=k) let triple_ordered_rev = Test.make ~name:"triples are ordered reversely" ~print:Print.(triple int int int) Gen.(triple int int int) (fun (i,j,k) -> i>=j && j>=k) let quad_diff = Test.make ~name:"quadruples have pair-wise different components" ~print:Print.(quad int int int int) Gen.(quad small_int small_int small_int small_int) (fun (h,i,j,k) -> h<>i && i<>j && j<>k) let quad_same = Test.make ~name:"quadruples have same components" ~print:Print.(quad int int int int) Gen.(quad int int int int) (fun (h,i,j,k) -> h=i || i=j || j=k) let quad_ordered = Test.make ~name:"quadruples are ordered" ~print:Print.(quad int int int int) Gen.(quad int int int int) (fun (h,i,j,k) -> h <= i && i <= j && j <= k) let quad_ordered_rev = Test.make ~name:"quadruples are ordered reversely" ~print:Print.(quad int int int int) Gen.(quad int int int int) (fun (h,i,j,k) -> h >= i && i >= j && j >= k) let test_tup2 = Test.make ~print:Print.(tup2 int int) ~name:"forall (a, b) in nat: a < b" Gen.(tup2 small_int small_int) (fun (a, b) -> a < b) let test_tup3 = Test.make ~print:Print.(tup3 int int int) ~name:"forall (a, b, c) in nat: a < b < c" Gen.(tup3 small_int small_int small_int) (fun (a, b, c) -> a < b && b < c) let test_tup4 = Test.make ~print:Print.(tup4 int int int int) ~name:"forall (a, b, c, d) in nat: a < b < c < d" Gen.(tup4 small_int small_int small_int small_int) (fun (a, b, c, d) -> a < b && b < c && c < d) let test_tup5 = Test.make ~print:Print.(tup5 int int int int int) ~name:"forall (a, b, c, d, e) in nat: a < b < c < d < e" Gen.(tup5 small_int small_int small_int small_int small_int) (fun (a, b, c, d, e) -> a < b && b < c && c < d && d < e) let test_tup6 = Test.make ~print:Print.(tup6 int int int int int int) ~name:"forall (a, b, c, d, e, f) in nat: a < b < c < d < e < f" Gen.(tup6 small_int small_int small_int small_int small_int small_int) (fun (a, b, c, d, e, f) -> a < b && b < c && c < d && d < e && e < f) let test_tup7 = Test.make ~print:Print.(tup7 int int int int int int int) ~name:"forall (a, b, c, d, e, f, g) in nat: a < b < c < d < e < f < g" Gen.(tup7 small_int small_int small_int small_int small_int small_int small_int) (fun (a, b, c, d, e, f, g) -> a < b && b < c && c < d && d < e && e < f && f < g) let test_tup8 = Test.make ~print:Print.(tup8 int int int int int int int int) ~name:"forall (a, b, c, d, e, f, g, h) in nat: a < b < c < d < e < f < g < h" Gen.(tup8 small_int small_int small_int small_int small_int small_int small_int small_int) (fun (a, b, c, d, e, f, g, h) -> a < b && b < c && c < d && d < e && e < f && f < g && g < h) let test_tup9 = Test.make ~print:Print.(tup9 int int int int int int int int int) ~name:"forall (a, b, c, d, e, f, g, h, i) in nat: a < b < c < d < e < f < g < h < i" Gen.(tup9 small_int small_int small_int small_int small_int small_int small_int small_int small_int) (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) let bind_pair_ordered = Test.make ~name:"bind ordered pairs" ~print:Print.(pair int int) Gen.(pint ~origin:0 >>= fun j -> int_bound j >>= fun i -> return (i,j)) (fun (_i,_j) -> false) let bind_pair_list_size = Test.make ~name:"bind list_size constant" ~print:Print.(pair int (list int)) Gen.(int_bound 1000 >>= fun len -> list_size (return len) (int_bound 1000) >>= fun xs -> return (len,xs)) (fun (len,xs) -> let len' = List.length xs in len=len' && len' < 4) (* tests from issue #64 *) let print_list xs = print_endline Print.(list int xs) let lists_are_empty_issue_64 = Test.make ~name:"lists are empty" ~print:Print.(list int) Gen.(list small_int) (fun xs -> print_list xs; xs = []) let list_shorter_10 = Test.make ~name:"lists shorter than 10" ~print:Print.(list int) Gen.(list small_int) (fun xs -> List.length xs < 10) let length_printer xs = Printf.sprintf "[...] list length: %i" (List.length xs) let size_gen = Gen.(oneof [small_nat; int_bound 750_000]) let list_shorter_432 = Test.make ~name:"lists shorter than 432" ~print:length_printer Gen.(list_size size_gen small_int) (fun xs -> List.length xs < 432) let list_shorter_4332 = Test.make ~name:"lists shorter than 4332" ~print:length_printer Gen.(list_size size_gen small_int) (fun xs -> List.length xs < 4332) let list_equal_dupl = Test.make ~name:"lists equal to duplication" ~print:Print.(list int) Gen.(list_size size_gen small_int) (fun xs -> try xs = xs @ xs with Stack_overflow -> false) let list_unique_elems = Test.make ~name:"lists have unique elems" ~print:Print.(list int) Gen.(list small_int) (fun xs -> let ys = List.sort_uniq Int.compare xs in print_list xs; List.length xs = List.length ys) let int_option_are_none = Test.make ~name:"int option are none" ~count:1000 ~print:Print.(option int) Gen.(option (int_bound 1000)) (function None -> true | Some _ -> false) let int_option_are_some_100_or_more = Test.make ~name:"int option are some 100 or more" ~count:1000 ~print:Print.(option int) Gen.(option (int_bound 1000)) (function None -> false | Some i -> i >= 100) let int_string_result_are_ok = Test.make ~name:"(int,string) result are Ok" ~count:1000 ~print:Print.(result int string) Gen.(result (int_bound 1000) string_small) (function Ok _ -> true | Error _ -> false) let int_string_result_are_error = Test.make ~name:"(int,string) result are Error" ~count:1000 ~print:Print.(result int string) Gen.(result (int_bound 1000) string_small) (function Ok _ -> false | Error _ -> true) let tree_contains_only_42 = Test.make ~name:"tree contains only 42" ~print:IntTree.print_tree IntTree.gen_tree (fun tree -> IntTree.contains_only_n tree 42) let test_gen_no_shrink = Test.make ~name:"sum list = 0" ~print:Print.(list int) Gen.(no_shrink @@ list small_int) (fun xs -> List.fold_left (+) 0 xs = 0) let tests = [ (*test_fac_issue59;*) big_bound_issue59; long_shrink; ints_arent_0_mod_3; ints_are_0; int32s_arent_0l_rem_3l; int32s_are_0l; int64s_arent_0L_rem_3L; int64s_are_0L; ints_smaller_209609; nats_smaller_5001; char_is_never_abcdef; printable_is_never_sign; numeral_is_never_less_5; bytes_are_empty; bytes_never_has_000_char; bytes_never_has_255_char; bytes_unique_chars; strings_are_empty; string_never_has_000_char; string_never_has_255_char; string_unique_chars; pair_diff_issue_64; pair_same; pair_one_zero; pair_all_zero; pair_ordered; pair_ordered_rev; pair_sum_lt_128; pair_lists_rev_concat; pair_lists_no_overlap; triple_diff; triple_same; triple_ordered; triple_ordered_rev; quad_diff; quad_same; quad_ordered; quad_ordered_rev; test_tup2; test_tup3; test_tup4; test_tup5; test_tup6; test_tup7; test_tup8; test_tup9; bind_pair_ordered; bind_pair_list_size; lists_are_empty_issue_64; list_shorter_10; list_shorter_432; list_shorter_4332; (*list_equal_dupl;*) list_unique_elems; int_option_are_none; int_option_are_some_100_or_more; int_string_result_are_ok; int_string_result_are_error; tree_contains_only_42; test_gen_no_shrink; ] end (* tests function generator and shrinker *) module Function = struct open QCheck2 let fail_pred_map_commute_int = Test.make ~name:"fail_pred_map_commute_int" ~count:100 ~long_factor:100 ~print:Print.(triple (list int) Fn.print Fn.print) Gen.(triple (small_list small_int) (fun1 ~print:Print.int Observable.int int) (fun1 ~print:Print.bool Observable.int bool)) (fun (l,Fun (_,f),Fun (_,p)) -> List.filter p (List.map f l) = List.map f (List.filter p l)) let fail_pred_map_commute_int32 = Test.make ~name:"fail_pred_map_commute_int32" ~count:100 ~long_factor:100 ~print:Print.(triple (list int32) Fn.print Fn.print) Gen.(triple (small_list int32) (fun1 ~print:Print.int32 Observable.int32 int32) (fun1 ~print:Print.bool Observable.int32 bool)) (fun (l,Fun (_,f),Fun (_,p)) -> List.filter p (List.map f l) = List.map f (List.filter p l)) let fail_pred_map_commute_int64 = Test.make ~name:"fail_pred_map_commute_int64" ~count:100 ~long_factor:100 ~print:Print.(triple (list int64) Fn.print Fn.print) Gen.(triple (small_list int64) (fun1 ~print:Print.int64 Observable.int64 int64) (fun1 ~print:Print.bool Observable.int64 bool)) (fun (l,Fun (_,f),Fun (_,p)) -> List.filter p (List.map f l) = List.map f (List.filter p l)) let fail_pred_strings = Test.make ~name:"fail_pred_strings" ~count:100 ~print:Fn.print (fun1 Observable.string ~print:Print.bool Gen.bool) (fun (Fun (_,p)) -> not (p "some random string") || p "some other string") let int_gen = Gen.small_nat (* int *) (* Another example (false) property *) let prop_foldleft_foldright = Test.make ~name:"fold_left fold_right" ~count:1000 ~long_factor:20 ~print:Print.(triple int (list int) Fn.print) Gen.(triple int_gen (list int_gen) (fun2 ~print:Print.int Observable.int Observable.int int_gen)) (fun (z,xs,f) -> let l1 = List.fold_right (Fn.apply f) xs z in let l2 = List.fold_left (Fn.apply f) z xs in if l1=l2 then true else Test.fail_reportf "l=%s, fold_left=%s, fold_right=%s@." (Print.(list int) xs) (Print.int l1) (Print.int l2) ) (* Another example (false) property *) let prop_foldleft_foldright_uncurry = Test.make ~name:"fold_left fold_right uncurried" ~count:1000 ~long_factor:20 ~print:Print.(triple Fn.print int (list int)) Gen.(triple (fun1 ~print:Print.int Observable.(pair int int) int_gen) int_gen (list int_gen)) (fun (f,z,xs) -> List.fold_right (fun x y -> Fn.apply f (x,y)) xs z = List.fold_left (fun x y -> Fn.apply f (x,y)) z xs) (* Same as the above (false) property, but generating+shrinking functions last *) let prop_foldleft_foldright_uncurry_funlast = Test.make ~name:"fold_left fold_right uncurried fun last" ~count:1000 ~long_factor:20 ~print:Print.(triple int (list int) Fn.print) Gen.(triple int_gen (list int_gen) (fun1 ~print:Print.int Observable.(pair int int) int_gen)) (fun (z,xs,f) -> List.fold_right (fun x y -> Fn.apply f (x,y)) xs z = List.fold_left (fun x y -> Fn.apply f (x,y)) z xs) (* test from issue #64 *) let fold_left_test = Test.make ~name:"fold_left test, fun first" ~print:Print.(quad Fn.print string (list int) (list int)) Gen.(quad (* string -> int -> string *) (fun2 ~print:Print.string Observable.string Observable.int (small_string ~gen:char)) (small_string ~gen:char) (list small_int) (list small_int)) (fun (f,acc,is,js) -> let f = Fn.apply f in List.fold_left f acc (is @ js) = List.fold_left f (List.fold_left f acc is) is) (*Typo*) let tests = [ fail_pred_map_commute_int; fail_pred_map_commute_int32; fail_pred_map_commute_int64; fail_pred_strings; prop_foldleft_foldright; prop_foldleft_foldright_uncurry; prop_foldleft_foldright_uncurry_funlast; fold_left_test; ] end (* tests of (inner) find_example(_gen) behaviour *) module FindExample = struct open QCheck2 let find_ex = Test.make ~name:"find_example" ~print:Print.int Gen.(2--50) (fun n -> let st = Random.State.make [| 0 |] in let f m = n < m && m < 2 * n in try let m = find_example_gen ~rand:st ~count:100_000 ~f Gen.(0 -- 1000) in f m with No_example_found _ -> false) let find_ex_uncaught_issue_99_1_fail = let rs = (find_example ~count:10 ~f:(fun _ -> false) Gen.int) in Test.make ~name:"FAIL_#99_1" rs (fun _ -> true) let find_ex_uncaught_issue_99_2_succeed = Test.make ~name:"should_succeed_#99_2" ~count:10 Gen.int (fun i -> i <= max_int) let tests = [ find_ex; find_ex_uncaught_issue_99_1_fail; find_ex_uncaught_issue_99_2_succeed; ] end (* tests of statistics and histogram display *) module Stats = struct open QCheck2 let bool_dist = Test.make ~name:"bool dist" ~count:500_000 ~collect:Bool.to_string Gen.bool (fun _ -> true) let char_dist_tests = [ Test.make ~name:"char code dist" ~count:500_000 ~stats:[("char code", Char.code)] Gen.char (fun _ -> true); Test.make ~name:"printable char code dist" ~count:500_000 ~stats:[("char code", Char.code)] Gen.printable (fun _ -> true); Test.make ~name:"numeral char code dist" ~count:500_000 ~stats:[("char code", Char.code)] Gen.numeral (fun _ -> true); ] let bytes_len_tests = let len = ("len",Bytes.length) in [ Test.make ~name:"bytes_size len dist" ~count:5_000 ~stats:[len] Gen.(bytes_size (int_range 5 10)) (fun _ -> true); Test.make ~name:"bytes len dist" ~count:5_000 ~stats:[len] Gen.bytes (fun _ -> true); Test.make ~name:"bytes_of len dist" ~count:5_000 ~stats:[len] Gen.(bytes_of (return 'a')) (fun _ -> true); Test.make ~name:"bytes_printable len dist" ~count:5_000 ~stats:[len] Gen.bytes_printable (fun _ -> true); Test.make ~name:"bytes_small len dist" ~count:5_000 ~stats:[len] Gen.(bytes_small_of char) (fun _ -> true); ] let string_len_tests = let len = ("len",String.length) in [ Test.make ~name:"string_size len dist" ~count:5_000 ~stats:[len] Gen.(string_size (int_range 5 10)) (fun _ -> true); Test.make ~name:"string len dist" ~count:5_000 ~stats:[len] Gen.string (fun _ -> true); Test.make ~name:"string_of len dist" ~count:5_000 ~stats:[len] Gen.(string_of (return 'a')) (fun _ -> true); Test.make ~name:"string_printable len dist" ~count:5_000 ~stats:[len] Gen.string_printable (fun _ -> true); Test.make ~name:"small_string len dist" ~count:5_000 ~stats:[len] Gen.(small_string ~gen:char)(*ugh*)(fun _ -> true); ] let pair_dist = Test.make ~name:"pair dist" ~count:500_000 ~stats:[("pair sum", (fun (i,j) -> i+j))] Gen.(pair (int_bound 100) (int_bound 100)) (fun _ -> true) let triple_dist = Test.make ~name:"triple dist" ~count:500_000 ~stats:[("triple sum", (fun (i,j,k) -> i+j+k))] Gen.(triple (int_bound 100) (int_bound 100) (int_bound 100)) (fun _ -> true) let quad_dist = Test.make ~name:"quad dist" ~count:500_000 ~stats:[("quad sum", (fun (h,i,j,k) -> h+i+j+k))] Gen.(quad (int_bound 100) (int_bound 100) (int_bound 100) (int_bound 100)) (fun _ -> true) let bind_dist = Test.make ~name:"bind dist" ~count:1_000_000 ~stats:[("ordered pair difference", (fun (i,j) -> j-i));("ordered pair sum", (fun (i,j) -> i+j))] Gen.(int_bound 100 >>= fun j -> int_bound j >>= fun i -> return (i,j)) (fun _ -> true) let option_dist = Test.make ~name:"option dist" ~count:10_000 ~collect:(function None -> "None " | Some _ -> "Some _") Gen.(option int) (fun _ -> true) let result_dist = Test.make ~name:"result dist" ~count:10_000 ~collect:(function Ok _ -> "Ok _ " | Error _ -> "Error _") Gen.(result int string) (fun _ -> true) let list_len_tests = let len = ("len",List.length) in [ (* test from issue #30 *) Test.make ~name:"list len dist" ~count:5_000 ~stats:[len] Gen.(list int) (fun _ -> true); Test.make ~name:"small_list len dist" ~count:5_000 ~stats:[len] Gen.(small_list int) (fun _ -> true); Test.make ~name:"list_size len dist" ~count:5_000 ~stats:[len] Gen.(list_size (int_range 5 10) int) (fun _ -> true); Test.make ~name:"list_repeat len dist" ~count:5_000 ~stats:[len] Gen.(list_repeat 42 int) (fun _ -> true); ] let array_len_tests = let len = ("len",Array.length) in [ Test.make ~name:"array len dist" ~count:5_000 ~stats:[len] Gen.(array int) (fun _ -> true); Test.make ~name:"small_array len dist" ~count:5_000 ~stats:[len] Gen.(small_array int) (fun _ -> true); Test.make ~name:"array_size len dist" ~count:5_000 ~stats:[len] Gen.(array_size (int_range 5 10) int) (fun _ -> true); Test.make ~name:"array_repeat len dist" ~count:5_000 ~stats:[len] Gen.(array_repeat 42 int) (fun _ -> true); ] let int_dist_tests = let dist = ("dist",fun x -> x) in [ (* test from issue #40 *) Test.make ~name:"int_stats_neg" ~count:5000 ~stats:[dist] Gen.small_signed_int (fun _ -> true); (* distribution tests from PR #45 *) Test.make ~name:"small_signed_int dist" ~count:1000 ~stats:[dist] Gen.small_signed_int (fun _ -> true); Test.make ~name:"small_nat dist" ~count:1000 ~stats:[dist] Gen.small_nat (fun _ -> true); Test.make ~name:"nat dist" ~count:1000 ~stats:[dist] Gen.nat (fun _ -> true); Test.make ~name:"int_range (-43643) 435434 dist" ~count:1000 ~stats:[dist] (Gen.int_range (-43643) 435434) (fun _ -> true); Test.make ~name:"int_range (-40000) 40000 dist" ~count:1000 ~stats:[dist] (Gen.int_range (-40000) 40000) (fun _ -> true); Test.make ~name:"int_range (-4) 4 dist" ~count:1000 ~stats:[dist] (Gen.int_range (-4) 4) (fun _ -> true); Test.make ~name:"int_range (-4) 17 dist" ~count:1000 ~stats:[dist] (Gen.int_range (-4) 17) (fun _ -> true); Test.make ~name:"int dist" ~count:100000 ~stats:[dist] Gen.int (fun _ -> true); Test.make ~name:"oneof int dist" ~count:1000 ~stats:[dist] (Gen.oneofl[min_int;-1;0;1;max_int]) (fun _ -> true); ] let int_32_64_dist_tests = let stat32 shift = [("dist",fun i -> Int32.(to_int (logand 0xffffl (shift i))))] in let stat64 shift = [("dist",fun i -> Int64.(to_int (logand 0xffffL (shift i))))] in [ (* stats are int-based, so for these to work for 31-bit ints, consider blocks of 16 bits *) Test.make ~name:"int32 lower dist" ~count:10000 ~stats:(stat32 (fun i -> i)) Gen.int32 (fun _ -> true); Test.make ~name:"int32 upper dist" ~count:10000 ~stats:(stat32 (fun i -> Int32.shift_right_logical i 16)) Gen.int32 (fun _ -> true); Test.make ~name:"int64 lower dist" ~count:10000 ~stats:(stat64 (fun i -> i)) Gen.int64 (fun _ -> true); Test.make ~name:"int64 lower-mid dist" ~count:10000 ~stats:(stat64 (fun i -> Int64.shift_right i 16)) Gen.int64 (fun _ -> true); Test.make ~name:"int64 upper-mid dist" ~count:10000 ~stats:(stat64 (fun i -> Int64.shift_right i 32)) Gen.int64 (fun _ -> true); Test.make ~name:"int64 upper dist" ~count:10000 ~stats:(stat64 (fun i -> Int64.shift_right_logical i 48)) Gen.int64 (fun _ -> true); ] let exponential_tests = let float_dist = ("dist",int_of_float) in [ Test.make ~name:"exponential 10. dist" ~count:5_000 ~stats:[float_dist] (Gen.exponential 10.) (fun _ -> true); Test.make ~name:"exponential -10. dist" ~count:5_000 ~stats:[float_dist] (Gen.exponential (-10.)) (fun _ -> true); ] let tree_depth_test = let depth = ("depth", IntTree.depth) in Test.make ~name:"tree's depth" ~count:1000 ~stats:[depth] IntTree.gen_tree (fun _ -> true) let int_dist_empty_bucket = Test.make ~name:"int_dist_empty_bucket" ~count:1_000 ~stats:[("dist",fun x -> x)] Gen.(oneof [small_int_corners ();int]) (fun _ -> true) let tests = [ bool_dist; ] @ char_dist_tests @ [ tree_depth_test;] @ bytes_len_tests @ string_len_tests @ [pair_dist; triple_dist; quad_dist; bind_dist; option_dist; result_dist;] @ list_len_tests @ array_len_tests @ int_dist_tests @ int_32_64_dist_tests @ exponential_tests end qcheck-0.25/test/core/QCheck2_unit_tests.ml000066400000000000000000001235331477416744200206670ustar00rootroot00000000000000open QCheck2 let rand_init i = Random.State.make [|i|] let rec repeated_success t = Tree.root t :: match Tree.children t () with | Seq.Nil -> [] | Seq.Cons (t,_) -> repeated_success t let repeated_failure t = Tree.root t :: match Tree.children t () with | Seq.Nil -> [] | Seq.Cons (t,ts) -> Tree.root t :: (Seq.map Tree.root ts |> List.of_seq) let ocaml_major_version = try let major_version_str = List.hd (String.split_on_char '.' Sys.ocaml_version) in int_of_string major_version_str with _ -> failwith ("Unknown OCaml version format: " ^ Sys.ocaml_version) module Shrink = struct let test_int_towards () = Alcotest.(check' (list int)) ~msg:"int_towards 0 100" ~actual:(Shrink.int_towards 0 100 |> List.of_seq) ~expected:[0; 50; 75; 88; 94; 97; 99]; Alcotest.(check' (list int)) ~msg:"int_towards 500 1000" ~actual:(Shrink.int_towards 500 1000 |> List.of_seq) ~expected:[500; 750; 875; 938; 969; 985; 993; 997; 999]; Alcotest.(check' (list int)) ~msg:"int_towards (-50) (-26)" ~actual:(Shrink.int_towards (-50) (-26) |> List.of_seq) ~expected:[-50; -38; -32; -29; -28; -27] let test_int32_towards () = Alcotest.(check' (list int32)) ~msg:"int32_towards 0l 100l" ~actual:(Shrink.int32_towards 0l 100l |> List.of_seq) ~expected:[0l; 50l; 75l; 88l; 94l; 97l; 99l]; Alcotest.(check' (list int32)) ~msg:"int32_towards 500l 1000l" ~actual:(Shrink.int32_towards 500l 1000l |> List.of_seq) ~expected:[500l; 750l; 875l; 938l; 969l; 985l; 993l; 997l; 999l]; Alcotest.(check' (list int32)) ~msg:"int32_towards (-50l) (-26l)" ~actual:(Shrink.int32_towards (-50l) (-26l) |> List.of_seq) ~expected:[-50l; -38l; -32l; -29l; -28l; -27l] let test_int64_towards () = Alcotest.(check' (list int64)) ~msg:"int64_towards 0L 100L" ~actual:(Shrink.int64_towards 0L 100L |> List.of_seq) ~expected:[0L; 50L; 75L; 88L; 94L; 97L; 99L]; Alcotest.(check' (list int64)) ~msg:"int64_towards 500L 1000L" ~actual:(Shrink.int64_towards 500L 1000L |> List.of_seq) ~expected:[500L; 750L; 875L; 938L; 969L; 985L; 993L; 997L; 999L]; Alcotest.(check' (list int64)) ~msg:"int64_towards (-50L) (-26L)" ~actual:(Shrink.int64_towards (-50L) (-26L) |> List.of_seq) ~expected:[-50L; -38L; -32L; -29L; -28L; -27L] let test_float_towards () = Alcotest.(check' (list (float 0.0001))) ~msg:"float_towards 0. 100." ~actual:(Shrink.float_towards 0. 100. |> List.of_seq) ~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]; Alcotest.(check' (list (float 0.001))) ~msg:"float_towards 500. 1000." ~actual:(Shrink.float_towards 500. 1000. |> List.of_seq) ~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]; Alcotest.(check' (list (float 0.0001))) ~msg:"float_towards (-50.) (-26.)" ~actual:(Shrink.float_towards (-50.) (-26.) |> List.of_seq) ~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] let test_char () = Alcotest.(check' (list char)) ~msg:"'k' on repeated failure" ~actual:(Gen.(generate_tree ~rand:(rand_init 1234) char) |> repeated_failure) ~expected:(if ocaml_major_version < 5 then ['k'; 'a'; 'f'; 'h'; 'i'; 'j'] else ['>'; 'a'; 'P'; 'G'; 'C'; 'A'; '@'; '?']); Alcotest.(check' (list char)) ~msg:"'1' on repeated failure" ~actual:(Gen.(generate_tree ~rand:(rand_init 3345) char) |> repeated_failure) ~expected:(if ocaml_major_version < 5 then ['1'; 'a'; 'I'; '='; '7'; '4'; '2'] else ['O'; 'a'; 'X'; 'S'; 'Q'; 'P']); Alcotest.(check' (list char)) ~msg:"'k' on repeated success" ~actual:(Gen.(generate_tree ~rand:(rand_init 1234) char) |> repeated_success) ~expected:(if ocaml_major_version < 5 then ['k'; 'a';] else ['>'; 'a']); Alcotest.(check' (list char)) ~msg:"'1' on repeated success" ~actual:(Gen.(generate_tree ~rand:(rand_init 3345) char) |> repeated_success) ~expected:(if ocaml_major_version < 5 then ['1'; 'a';] else ['O'; 'a']) let test_char_numeral () = Alcotest.(check' (list char)) ~msg:"'3' on repeated failure" ~actual:(Gen.(generate_tree ~rand:(rand_init 1234) numeral) |> repeated_failure) ~expected:(if ocaml_major_version < 5 then ['3'; '0'; '1'; '2'] else ['0']); Alcotest.(check' (list char)) ~msg:"'0' on repeated failure" ~actual:(Gen.(generate_tree ~rand:(rand_init 3346) numeral) |> repeated_failure) ~expected:(if ocaml_major_version < 5 then ['0'] else ['9'; '0'; '4'; '6'; '7'; '8']); Alcotest.(check' (list char)) ~msg:"'3' on repeated success" ~actual:(Gen.(generate_tree ~rand:(rand_init 1234) numeral) |> repeated_success) ~expected:(if ocaml_major_version < 5 then ['3'; '0'] else ['0']); Alcotest.(check' (list char)) ~msg:"'0' on repeated success" ~actual:(Gen.(generate_tree ~rand:(rand_init 3346) numeral) |> repeated_success) ~expected:(if ocaml_major_version < 5 then ['0'] else ['9'; '0']) let test_char_printable () = Alcotest.(check' (list char)) ~msg:"'l' on repeated failure" ~actual:(Gen.(generate_tree ~rand:(rand_init 1234) printable) |> repeated_failure) ~expected:(if ocaml_major_version < 5 then ['l'; 'a'; 'f'; 'i'; 'j'; 'k'] else ['D'; 'a'; '%'; '5'; '='; 'A'; 'C']); Alcotest.(check' (list char)) ~msg:"'8' on repeated failure" ~actual:(Gen.(generate_tree ~rand:(rand_init 3346) printable) |> repeated_failure) ~expected:(if ocaml_major_version < 5 then ['8'; 'a'; 'z'; ','; '2'; '5'; '7'] else ['#'; 'a'; 'o'; 'v'; 'z'; '!'; '"']); Alcotest.(check' (list char)) ~msg:"'l' on repeated success" ~actual:(Gen.(generate_tree ~rand:(rand_init 1234) printable) |> repeated_success) ~expected:(if ocaml_major_version < 5 then ['l'; 'a'] else ['D'; 'a']); Alcotest.(check' (list char)) ~msg:"'8' on repeated success" ~actual:(Gen.(generate_tree ~rand:(rand_init 3346) printable) |> repeated_success) ~expected:(if ocaml_major_version < 5 then ['8'; 'a'] else ['#'; 'a']) let test_pair_small_int () = if ocaml_major_version < 5 then (Alcotest.(check' (list (pair int int))) ~msg:"9,1 on repeated failure" ~actual:(Gen.(generate_tree ~rand:(rand_init 3346) (pair small_int small_int)) |> repeated_failure) ~expected:[(9, 1); (0, 1); (4, 1); (6, 1); (7, 1); (8, 1); (9, 0)]; Alcotest.(check' (list (pair int int))) ~msg:"9,1 on repeated success" ~actual:(Gen.(generate_tree ~rand:(rand_init 3346) (pair small_int small_int)) |> repeated_success) ~expected:[(9, 1); (0, 1); (0, 0)]) else (Alcotest.(check' (list (pair int int))) ~msg:"2,6 on repeated failure" ~actual:(Gen.(generate_tree ~rand:(rand_init 3346) (pair small_int small_int)) |> repeated_failure) ~expected:[(2, 6); (0, 6); (1, 6); (2, 0); (2, 3); (2, 5)]; Alcotest.(check' (list (pair int int))) ~msg:"2,6 on repeated success" ~actual:(Gen.(generate_tree ~rand:(rand_init 3346) (pair small_int small_int)) |> repeated_success) ~expected:[(2, 6); (0, 6); (0, 0)]) let test_bind_small_int () = if ocaml_major_version < 5 then (Alcotest.(check' (list (pair int int))) ~msg:"9,1 on repeated failure" ~actual:(Gen.(generate_tree ~rand:(rand_init 3346) (small_int >>= fun i -> map (fun j -> (i,j)) small_int)) |> repeated_failure) ~expected:[(9, 1); (0, 1); (4, 1); (6, 1); (7, 1); (8, 1); (9, 0)]; Alcotest.(check' (list (pair int int))) ~msg:"9,1 on repeated success" ~actual:(Gen.(generate_tree ~rand:(rand_init 3346) (small_int >>= fun i -> map (fun j -> (i,j)) small_int)) |> repeated_success) ~expected:[(9, 1); (0, 1); (0, 0)]) else (Alcotest.(check' (list (pair int int))) ~msg:"2,6 on repeated failure" ~actual:(Gen.(generate_tree ~rand:(rand_init 3346) (small_int >>= fun i -> map (fun j -> (i,j)) small_int)) |> repeated_failure) ~expected:[(2, 6); (0, 6); (1, 6); (2, 0); (2, 3); (2, 5)]; Alcotest.(check' (list (pair int int))) ~msg:"2,6 on repeated success" ~actual:(Gen.(generate_tree ~rand:(rand_init 3346) (small_int >>= fun i -> map (fun j -> (i,j)) small_int)) |> repeated_success) ~expected:[(2, 6); (0, 6); (0, 0)]) let test_list_size_int () = if ocaml_major_version < 5 then (Alcotest.(check' (list (list int))) ~msg:"[8; 0; 9; 0; 8; 8; 2] on repeated failure" ~actual:(Gen.(generate_tree ~rand:(rand_init 3346) (list_size (int_bound 8) (int_bound 10))) |> repeated_failure) ~expected:[ [8; 0; 9; 0; 8; 8; 2]; []; [8; 0; 9]; [8; 0; 9; 0; 8]; [8; 0; 9; 0; 8; 8]; [0; 0; 9; 0; 8; 8; 2]; [4; 0; 9; 0; 8; 8; 2]; [6; 0; 9; 0; 8; 8; 2]; [7; 0; 9; 0; 8; 8; 2]; [8; 0; 0; 0; 8; 8; 2]; [8; 0; 4; 0; 8; 8; 2]; [8; 0; 6; 0; 8; 8; 2]; [8; 0; 7; 0; 8; 8; 2]; [8; 0; 8; 0; 8; 8; 2]; [8; 0; 9; 0; 0; 8; 2]; [8; 0; 9; 0; 4; 8; 2]; [8; 0; 9; 0; 6; 8; 2]; [8; 0; 9; 0; 7; 8; 2]; [8; 0; 9; 0; 8; 0; 2]; [8; 0; 9; 0; 8; 4; 2]; [8; 0; 9; 0; 8; 6; 2]; [8; 0; 9; 0; 8; 7; 2]; [8; 0; 9; 0; 8; 8; 0]; [8; 0; 9; 0; 8; 8; 1]; ]; Alcotest.(check' (list (list int))) ~msg:"[8; 0; 9; 0; 8; 8; 2] on repeated success" ~actual:(Gen.(generate_tree ~rand:(rand_init 3346) (list_size (int_bound 8) (int_bound 10))) |> repeated_success) ~expected:[ [8; 0; 9; 0; 8; 8; 2]; []; ]) else (Alcotest.(check' (list (list int))) ~msg:"[9; 2; 7; 3; 8; 6] repeated failure" ~actual:(Gen.(generate_tree ~rand:(rand_init 3346) (list_size (int_bound 8) (int_bound 10))) |> repeated_failure) ~expected:[ [9; 2; 7; 3; 8; 6]; []; [9; 2; 7]; [9; 2; 7; 3; 8]; [0; 2; 7; 3; 8; 6]; [4; 2; 7; 3; 8; 6]; [6; 2; 7; 3; 8; 6]; [7; 2; 7; 3; 8; 6]; [8; 2; 7; 3; 8; 6]; [9; 0; 7; 3; 8; 6]; [9; 1; 7; 3; 8; 6]; [9; 2; 0; 3; 8; 6]; [9; 2; 3; 3; 8; 6]; [9; 2; 5; 3; 8; 6]; [9; 2; 6; 3; 8; 6]; [9; 2; 7; 0; 8; 6]; [9; 2; 7; 1; 8; 6]; [9; 2; 7; 2; 8; 6]; [9; 2; 7; 3; 0; 6]; [9; 2; 7; 3; 4; 6]; [9; 2; 7; 3; 6; 6]; [9; 2; 7; 3; 7; 6]; [9; 2; 7; 3; 8; 0]; [9; 2; 7; 3; 8; 3]; [9; 2; 7; 3; 8; 5]; ]; Alcotest.(check' (list (list int))) ~msg:"[9; 2; 7; 3; 8; 6] repeated success" ~actual:(Gen.(generate_tree ~rand:(rand_init 3346) (list_size (int_bound 8) (int_bound 10))) |> repeated_success) ~expected:[[9; 2; 7; 3; 8; 6]; []; ]) let test_list_int () = if ocaml_major_version < 5 then (Alcotest.(check' (list (list int))) ~msg:"[0; 5; 3; 7] on repeated failure" ~actual:(Gen.(generate_tree ~rand:(rand_init 3345) (list (int_bound 10))) |> repeated_failure) ~expected:[ [0; 5; 3; 7]; [0; 5]; [3; 7]; [5; 3; 7]; [0; 5; 7]; [0; 0; 3; 7]; [0; 2; 3; 7]; [0; 3; 3; 7]; [0; 4; 3; 7]; [0; 5; 0; 7]; [0; 5; 1; 7]; [0; 5; 2; 7]; [0; 5; 3; 0]; [0; 5; 3; 3]; [0; 5; 3; 5]; [0; 5; 3; 6]; ]; Alcotest.(check' (list (list int))) ~msg:"[0; 5; 3; 7] on repeated success" ~actual:(Gen.(generate_tree ~rand:(rand_init 3345) (list (int_bound 10))) |> repeated_success) ~expected:[ [0; 5; 3; 7]; [0; 5]; [5]; []; ]) else (Alcotest.(check' (list (list int))) ~msg:"[1; 10; 10; 7; 3] on repeated failure" ~actual:(Gen.(generate_tree ~rand:(rand_init 3347) (list (int_bound 10))) |> repeated_failure) ~expected:[ [1; 10; 10; 7; 3]; [1; 10; 10]; [7; 3]; [10; 10; 7; 3]; [1; 10; 10; 3]; [0; 10; 10; 7; 3]; [1; 0; 10; 7; 3]; [1; 5; 10; 7; 3]; [1; 8; 10; 7; 3]; [1; 9; 10; 7; 3]; [1; 10; 0; 7; 3]; [1; 10; 5; 7; 3]; [1; 10; 8; 7; 3]; [1; 10; 9; 7; 3]; [1; 10; 10; 0; 3]; [1; 10; 10; 3; 3]; [1; 10; 10; 5; 3]; [1; 10; 10; 6; 3]; [1; 10; 10; 7; 0]; [1; 10; 10; 7; 1]; [1; 10; 10; 7; 2]; ]; Alcotest.(check' (list (list int))) ~msg:"[1; 10; 10; 7; 3] on repeated success" ~actual:(Gen.(generate_tree ~rand:(rand_init 3347) (list (int_bound 10))) |> repeated_success) ~expected:[ [1; 10; 10; 7; 3]; [1; 10; 10]; [10; 10]; [10]; []; ]) let test_small_list_int () = if ocaml_major_version < 5 then (Alcotest.(check' (list (list int))) ~msg:"[0; 5; 3; 7] on repeated failure" ~actual:(Gen.(generate_tree ~rand:(rand_init 3345) (small_list (int_bound 10))) |> repeated_failure) ~expected:[[0; 5; 3; 7]; [0; 5]; [3; 7]; [5; 3; 7]; [0; 5; 7]; [0; 0; 3; 7]; [0; 2; 3; 7]; [0; 3; 3; 7]; [0; 4; 3; 7]; [0; 5; 0; 7]; [0; 5; 1; 7]; [0; 5; 2; 7]; [0; 5; 3; 0]; [0; 5; 3; 3]; [0; 5; 3; 5]; [0; 5; 3; 6]; ]; Alcotest.(check' (list (list int))) ~msg:"[0; 5; 3; 7] on repeated success" ~actual:(Gen.(generate_tree ~rand:(rand_init 3345) (small_list (int_bound 10))) |> repeated_success) ~expected:[ [0; 5; 3; 7]; [0; 5]; [5]; []; ]) else (Alcotest.(check' (list (list int))) ~msg:"[1; 10; 10; 7; 3] on repeated failure" ~actual:(Gen.(generate_tree ~rand:(rand_init 3347) (small_list (int_bound 10))) |> repeated_failure) ~expected:[ [1; 10; 10; 7; 3]; [1; 10; 10]; [7; 3]; [10; 10; 7; 3]; [1; 10; 10; 3]; [0; 10; 10; 7; 3]; [1; 0; 10; 7; 3]; [1; 5; 10; 7; 3]; [1; 8; 10; 7; 3]; [1; 9; 10; 7; 3]; [1; 10; 0; 7; 3]; [1; 10; 5; 7; 3]; [1; 10; 8; 7; 3]; [1; 10; 9; 7; 3]; [1; 10; 10; 0; 3]; [1; 10; 10; 3; 3]; [1; 10; 10; 5; 3]; [1; 10; 10; 6; 3]; [1; 10; 10; 7; 0]; [1; 10; 10; 7; 1]; [1; 10; 10; 7; 2]; ]; Alcotest.(check' (list (list int))) ~msg:"[1; 10; 10; 7; 3] on repeated success" ~actual:(Gen.(generate_tree ~rand:(rand_init 3347) (small_list (int_bound 10))) |> repeated_success) ~expected:[ [1; 10; 10; 7; 3]; [1; 10; 10]; [10; 10]; [10]; []; ]) let test_array_size_int () = if ocaml_major_version < 5 then (Alcotest.(check' (list (array int))) ~msg:"[|2; 5; 1|] on repeated failure" ~actual:(Gen.(generate_tree ~rand:(rand_init 3347) (array_size (int_bound 8) (int_bound 10))) |> repeated_failure) ~expected:[ [|2; 5; 1|]; [||]; [|2|]; [|2; 5|]; [|0; 5; 1|]; [|1; 5; 1|]; [|2; 0; 1|]; [|2; 2; 1|]; [|2; 3; 1|]; [|2; 4; 1|]; [|2; 5; 0|]; ]; Alcotest.(check' (list (array int))) ~msg:"[|2; 5; 1|] on repeated success" ~actual:(Gen.(generate_tree ~rand:(rand_init 3347) (array_size (int_bound 8) (int_bound 10))) |> repeated_success) ~expected:[ [|2; 5; 1|]; [| |]; ]) else (Alcotest.(check' (list (array int))) ~msg:"[|9; 2; 7; 3; 8; 6|] repeated failure" ~actual:(Gen.(generate_tree ~rand:(rand_init 3346) (array_size (int_bound 8) (int_bound 10))) |> repeated_failure) ~expected:[ [|9; 2; 7; 3; 8; 6|]; [||]; [|9; 2; 7|]; [|9; 2; 7; 3; 8|]; [|0; 2; 7; 3; 8; 6|]; [|4; 2; 7; 3; 8; 6|]; [|6; 2; 7; 3; 8; 6|]; [|7; 2; 7; 3; 8; 6|]; [|8; 2; 7; 3; 8; 6|]; [|9; 0; 7; 3; 8; 6|]; [|9; 1; 7; 3; 8; 6|]; [|9; 2; 0; 3; 8; 6|]; [|9; 2; 3; 3; 8; 6|]; [|9; 2; 5; 3; 8; 6|]; [|9; 2; 6; 3; 8; 6|]; [|9; 2; 7; 0; 8; 6|]; [|9; 2; 7; 1; 8; 6|]; [|9; 2; 7; 2; 8; 6|]; [|9; 2; 7; 3; 0; 6|]; [|9; 2; 7; 3; 4; 6|]; [|9; 2; 7; 3; 6; 6|]; [|9; 2; 7; 3; 7; 6|]; [|9; 2; 7; 3; 8; 0|]; [|9; 2; 7; 3; 8; 3|]; [|9; 2; 7; 3; 8; 5|]; ]; Alcotest.(check' (list (array int))) ~msg:"[|9; 2; 7; 3; 8; 6|] repeated success" ~actual:(Gen.(generate_tree ~rand:(rand_init 3346) (array_size (int_bound 8) (int_bound 10))) |> repeated_success) ~expected:[[|9; 2; 7; 3; 8; 6|]; [| |]; ]) let test_array_int () = if ocaml_major_version < 5 then (Alcotest.(check' (list (array int))) ~msg:"[|0; 5; 3; 7|] on repeated failure" ~actual:(Gen.(generate_tree ~rand:(rand_init 3345) (array (int_bound 10))) |> repeated_failure) ~expected:[ [|0; 5; 3; 7|]; [|0; 5|]; [|3; 7|]; [|5; 3; 7|]; [|0; 5; 7|]; [|0; 0; 3; 7|]; [|0; 2; 3; 7|]; [|0; 3; 3; 7|]; [|0; 4; 3; 7|]; [|0; 5; 0; 7|]; [|0; 5; 1; 7|]; [|0; 5; 2; 7|]; [|0; 5; 3; 0|]; [|0; 5; 3; 3|]; [|0; 5; 3; 5|]; [|0; 5; 3; 6|]; ]; Alcotest.(check' (list (array int))) ~msg:"[|0; 5; 3; 7|] on repeated success" ~actual:(Gen.(generate_tree ~rand:(rand_init 3345) (array (int_bound 10))) |> repeated_success) ~expected:[ [|0; 5; 3; 7|]; [|0; 5|]; [|5|]; [||]; ]) else (Alcotest.(check' (list (array int))) ~msg:"[|1; 10; 10; 7; 3|] on repeated failure" ~actual:(Gen.(generate_tree ~rand:(rand_init 3347) (array (int_bound 10))) |> repeated_failure) ~expected:[ [|1; 10; 10; 7; 3|]; [|1; 10; 10|]; [|7; 3|]; [|10; 10; 7; 3|]; [|1; 10; 10; 3|]; [|0; 10; 10; 7; 3|]; [|1; 0; 10; 7; 3|]; [|1; 5; 10; 7; 3|]; [|1; 8; 10; 7; 3|]; [|1; 9; 10; 7; 3|]; [|1; 10; 0; 7; 3|]; [|1; 10; 5; 7; 3|]; [|1; 10; 8; 7; 3|]; [|1; 10; 9; 7; 3|]; [|1; 10; 10; 0; 3|]; [|1; 10; 10; 3; 3|]; [|1; 10; 10; 5; 3|]; [|1; 10; 10; 6; 3|]; [|1; 10; 10; 7; 0|]; [|1; 10; 10; 7; 1|]; [|1; 10; 10; 7; 2|]; ]; Alcotest.(check' (list (array int))) ~msg:"[|1; 10; 10; 7; 3|] on repeated success" ~actual:(Gen.(generate_tree ~rand:(rand_init 3347) (array (int_bound 10))) |> repeated_success) ~expected:[ [|1; 10; 10; 7; 3|]; [|1; 10; 10|]; [|10; 10|]; [|10|]; [||]; ]) let test_small_array_int () = if ocaml_major_version < 5 then (Alcotest.(check' (list (array int))) ~msg:"[|0; 5; 3; 7|] on repeated failure" ~actual:(Gen.(generate_tree ~rand:(rand_init 3345) (small_array (int_bound 10))) |> repeated_failure) ~expected:[ [|0; 5; 3; 7|]; [|0; 5|]; [|3; 7|]; [|5; 3; 7|]; [|0; 5; 7|]; [|0; 0; 3; 7|]; [|0; 2; 3; 7|]; [|0; 3; 3; 7|]; [|0; 4; 3; 7|]; [|0; 5; 0; 7|]; [|0; 5; 1; 7|]; [|0; 5; 2; 7|]; [|0; 5; 3; 0|]; [|0; 5; 3; 3|]; [|0; 5; 3; 5|]; [|0; 5; 3; 6|]; ]; Alcotest.(check' (list (array int))) ~msg:"[|0; 5; 3; 7|] on repeated success" ~actual:(Gen.(generate_tree ~rand:(rand_init 3345) (small_array (int_bound 10))) |> repeated_success) ~expected:[ [|0; 5; 3; 7|]; [|0; 5|]; [|5|]; [||]; ]) else (Alcotest.(check' (list (array int))) ~msg:"[|1; 10; 10; 7; 3|] on repeated failure" ~actual:(Gen.(generate_tree ~rand:(rand_init 3347) (small_array (int_bound 10))) |> repeated_failure) ~expected:[ [|1; 10; 10; 7; 3|]; [|1; 10; 10|]; [|7; 3|]; [|10; 10; 7; 3|]; [|1; 10; 10; 3|]; [|0; 10; 10; 7; 3|]; [|1; 0; 10; 7; 3|]; [|1; 5; 10; 7; 3|]; [|1; 8; 10; 7; 3|]; [|1; 9; 10; 7; 3|]; [|1; 10; 0; 7; 3|]; [|1; 10; 5; 7; 3|]; [|1; 10; 8; 7; 3|]; [|1; 10; 9; 7; 3|]; [|1; 10; 10; 0; 3|]; [|1; 10; 10; 3; 3|]; [|1; 10; 10; 5; 3|]; [|1; 10; 10; 6; 3|]; [|1; 10; 10; 7; 0|]; [|1; 10; 10; 7; 1|]; [|1; 10; 10; 7; 2|]; ]; Alcotest.(check' (list (array int))) ~msg:"[|1; 10; 10; 7; 3|] on repeated success" ~actual:(Gen.(generate_tree ~rand:(rand_init 3347) (small_array (int_bound 10))) |> repeated_success) ~expected:[ [|1; 10; 10; 7; 3|]; [|1; 10; 10|]; [|10; 10|]; [|10|]; [||]; ]) let test_bytes_size () = if ocaml_major_version < 5 then (Alcotest.(check' (list bytes)) ~msg:"\"H Ap>&U\" on repeated failure" ~actual:(Gen.(generate_tree ~rand:(rand_init 3346) (bytes_size ~gen:printable (int_bound 8))) |> repeated_failure) ~expected:(List.map Bytes.of_string [ "H Ap>&U"; ""; "H A"; "H Ap>"; "H Ap>&"; "a Ap>&U"; "' Ap>&U"; "8 Ap>&U"; "@ Ap>&U"; "D Ap>&U"; "F Ap>&U"; "G Ap>&U"; "HaAp>&U"; "HnAp>&U"; "HuAp>&U"; "HxAp>&U"; "HzAp>&U"; "H ap>&U"; "H #p>&U"; "H 2p>&U"; "H 9p>&U"; "H =p>&U"; "H ?p>&U"; "H @p>&U"; "H Aa>&U"; "H Ah>&U"; "H Al>&U"; "H An>&U"; "H Ao>&U"; "H Apa&U"; "H Ap\"&U"; "H Ap0&U"; "H Ap7&U"; "H Ap;&U"; "H Ap=&U"; "H Ap>aU"; "H Ap>qU"; "H Ap>yU"; "H Ap>\"U"; "H Ap>$U"; "H Ap>%U"; "H Ap>&a"; "H Ap>&-"; "H Ap>&A"; "H Ap>&K"; "H Ap>&P"; "H Ap>&R"; "H Ap>&S"; "H Ap>&T"; ] ); Alcotest.(check' (list bytes)) ~msg:"\"H Ap>&U\" on repeated success" ~actual:(Gen.(generate_tree ~rand:(rand_init 3346) (bytes_size ~gen:printable (int_bound 8))) |> repeated_success) ~expected:(List.map Bytes.of_string ["H Ap>&U"; ""])) else (Alcotest.(check' (list bytes)) ~msg:"\"Ns<>W\\\" on repeated failure" ~actual:(Gen.(generate_tree ~rand:(rand_init 3346) (bytes_size ~gen:printable (int_bound 8))) |> repeated_failure) ~expected:(List.map Bytes.of_string ["Ns<>W\\"; ""; "Ns<"; "Ns<>W"; "as<>W\\"; "*s<>W\\"; "W\\"; "Es<>W\\"; "Js<>W\\"; "Ls<>W\\"; "Ms<>W\\"; "Na<>W\\"; "Nj<>W\\"; "No<>W\\"; "Nq<>W\\"; "Nr<>W\\"; "Nsa>W\\"; "Ns!>W\\"; "Ns/>W\\"; "Ns6>W\\"; "Ns9>W\\"; "Ns;>W\\"; "Nsa\\"; "Ns<>.\\"; "Ns<>B\\"; "Ns<>L\\"; "Ns<>Q\\"; "Ns<>T\\"; "Ns<>U\\"; "Ns<>V\\"; "Ns<>Wa"; "Ns<>W1"; "Ns<>WG"; "Ns<>WR"; "Ns<>WW"; "Ns<>WZ"; "Ns<>W["; ] ); Alcotest.(check' (list bytes)) ~msg:"\"Ns<>W\\\" on repeated success" ~actual:(Gen.(generate_tree ~rand:(rand_init 3346) (bytes_size ~gen:printable (int_bound 8))) |> repeated_success) ~expected:(List.map Bytes.of_string ["Ns<>W\\"; ""; ])) let test_bytes () = if ocaml_major_version < 5 then (Alcotest.(check' (list bytes)) ~msg:"\"9\007\127\250\" on repeated failure" ~actual:(Gen.(generate_tree ~rand:(rand_init 3345) bytes) |> repeated_failure) ~expected:(List.map Bytes.of_string [ "9\007\127\250"; "9\007"; "\127\250"; "\007\127\250"; "9\007\250"; "a\007\127\250"; "M\007\127\250"; "C\007\127\250"; ">\007\127\250"; ";\007\127\250"; ":\007\127\250"; "9a\127\250"; "94\127\250"; "9\029\127\250"; "9\018\127\250"; "9\012\127\250"; "9\t\127\250"; "9\b\127\250"; "9\007a\250"; "9\007p\250"; "9\007w\250"; "9\007{\250"; "9\007}\250"; "9\007~\250"; "9\007\127a"; "9\007\127\174"; "9\007\127\212"; "9\007\127\231"; "9\007\127\241"; "9\007\127\246"; "9\007\127\248"; "9\007\127\249"; ] ); Alcotest.(check' (list bytes)) ~msg:"\"9\007\127\250\" on repeated success" ~actual:(Gen.(generate_tree ~rand:(rand_init 3345) bytes) |> repeated_success) ~expected:(List.map Bytes.of_string [ "9\007\127\250"; "9\007"; "\007"; ""; ])) else (Alcotest.(check' (list bytes)) ~msg:"\"\253NS\173\" on repeated failure" ~actual:(Gen.(generate_tree ~rand:(rand_init 3349) bytes) |> repeated_failure) ~expected:(List.map Bytes.of_string [ "\253NS\173"; "\253N"; "S\173"; "NS\173"; "\253N\173"; "aNS\173"; "\175NS\173"; "\214NS\173"; "\233NS\173"; "\243NS\173"; "\248NS\173"; "\250NS\173"; "\251NS\173"; "\252NS\173"; "\253aS\173"; "\253XS\173"; "\253SS\173"; "\253QS\173"; "\253PS\173"; "\253OS\173"; "\253Na\173"; "\253NZ\173"; "\253NV\173"; "\253NT\173"; "\253NSa"; "\253NS\135"; "\253NS\154"; "\253NS\163"; "\253NS\168"; "\253NS\170"; "\253NS\171"; "\253NS\172"; ] ); Alcotest.(check' (list bytes)) ~msg:"\"\253NS\173\" on repeated success" ~actual:(Gen.(generate_tree ~rand:(rand_init 3349) bytes) |> repeated_success) ~expected:(List.map Bytes.of_string [ "\253NS\173"; "\253N"; "N"; ""; ])) let test_bytes_small () = if ocaml_major_version < 5 then (Alcotest.(check' (list bytes)) ~msg:"\"9\007\127\250\" on repeated failure" ~actual:(Gen.(generate_tree ~rand:(rand_init 3345) bytes_small) |> repeated_failure) ~expected:(List.map Bytes.of_string [ "9\007\127\250"; "9\007"; "\127\250"; "\007\127\250"; "9\007\250"; "a\007\127\250"; "M\007\127\250"; "C\007\127\250"; ">\007\127\250"; ";\007\127\250"; ":\007\127\250"; "9a\127\250"; "94\127\250"; "9\029\127\250"; "9\018\127\250"; "9\012\127\250"; "9\t\127\250"; "9\b\127\250"; "9\007a\250"; "9\007p\250"; "9\007w\250"; "9\007{\250"; "9\007}\250"; "9\007~\250"; "9\007\127a"; "9\007\127\174"; "9\007\127\212"; "9\007\127\231"; "9\007\127\241"; "9\007\127\246"; "9\007\127\248"; "9\007\127\249"; ] ); Alcotest.(check' (list bytes)) ~msg:"\"9\007\127\250\" on repeated success" ~actual:(Gen.(generate_tree ~rand:(rand_init 3345) bytes_small) |> repeated_success) ~expected:(List.map Bytes.of_string [ "9\007\127\250"; "9\007"; "\007"; ""; ])) else (Alcotest.(check' (list bytes)) ~msg:"\"\253NS\173\" on repeated failure" ~actual:(Gen.(generate_tree ~rand:(rand_init 3349) bytes_small) |> repeated_failure) ~expected:(List.map Bytes.of_string [ "\253NS\173"; "\253N"; "S\173"; "NS\173"; "\253N\173"; "aNS\173"; "\175NS\173"; "\214NS\173"; "\233NS\173"; "\243NS\173"; "\248NS\173"; "\250NS\173"; "\251NS\173"; "\252NS\173"; "\253aS\173"; "\253XS\173"; "\253SS\173"; "\253QS\173"; "\253PS\173"; "\253OS\173"; "\253Na\173"; "\253NZ\173"; "\253NV\173"; "\253NT\173"; "\253NSa"; "\253NS\135"; "\253NS\154"; "\253NS\163"; "\253NS\168"; "\253NS\170"; "\253NS\171"; "\253NS\172"; ] ); Alcotest.(check' (list bytes)) ~msg:"\"\253NS\173\" on repeated success" ~actual:(Gen.(generate_tree ~rand:(rand_init 3349) bytes_small) |> repeated_success) ~expected:(List.map Bytes.of_string [ "\253NS\173"; "\253N"; "N"; ""; ])) let test_string_size () = if ocaml_major_version < 5 then (Alcotest.(check' (list string)) ~msg:"\"H Ap>&U\" on repeated failure" ~actual:(Gen.(generate_tree ~rand:(rand_init 3346) (string_size ~gen:printable (int_bound 8))) |> repeated_failure) ~expected:[ "H Ap>&U"; ""; "H A"; "H Ap>"; "H Ap>&"; "a Ap>&U"; "' Ap>&U"; "8 Ap>&U"; "@ Ap>&U"; "D Ap>&U"; "F Ap>&U"; "G Ap>&U"; "HaAp>&U"; "HnAp>&U"; "HuAp>&U"; "HxAp>&U"; "HzAp>&U"; "H ap>&U"; "H #p>&U"; "H 2p>&U"; "H 9p>&U"; "H =p>&U"; "H ?p>&U"; "H @p>&U"; "H Aa>&U"; "H Ah>&U"; "H Al>&U"; "H An>&U"; "H Ao>&U"; "H Apa&U"; "H Ap\"&U"; "H Ap0&U"; "H Ap7&U"; "H Ap;&U"; "H Ap=&U"; "H Ap>aU"; "H Ap>qU"; "H Ap>yU"; "H Ap>\"U"; "H Ap>$U"; "H Ap>%U"; "H Ap>&a"; "H Ap>&-"; "H Ap>&A"; "H Ap>&K"; "H Ap>&P"; "H Ap>&R"; "H Ap>&S"; "H Ap>&T"; ]; Alcotest.(check' (list string)) ~msg:"\"H Ap>&U\" on repeated success" ~actual:(Gen.(generate_tree ~rand:(rand_init 3346) (string_size ~gen:printable (int_bound 8))) |> repeated_success) ~expected:[ "H Ap>&U"; ""; ]) else (Alcotest.(check' (list string)) ~msg:"\"Ns<>W\\\" on repeated failure" ~actual:(Gen.(generate_tree ~rand:(rand_init 3346) (string_size ~gen:printable (int_bound 8))) |> repeated_failure) ~expected:["Ns<>W\\"; ""; "Ns<"; "Ns<>W"; "as<>W\\"; "*s<>W\\"; "W\\"; "Es<>W\\"; "Js<>W\\"; "Ls<>W\\"; "Ms<>W\\"; "Na<>W\\"; "Nj<>W\\"; "No<>W\\"; "Nq<>W\\"; "Nr<>W\\"; "Nsa>W\\"; "Ns!>W\\"; "Ns/>W\\"; "Ns6>W\\"; "Ns9>W\\"; "Ns;>W\\"; "Nsa\\"; "Ns<>.\\"; "Ns<>B\\"; "Ns<>L\\"; "Ns<>Q\\"; "Ns<>T\\"; "Ns<>U\\"; "Ns<>V\\"; "Ns<>Wa"; "Ns<>W1"; "Ns<>WG"; "Ns<>WR"; "Ns<>WW"; "Ns<>WZ"; "Ns<>W["; ]; Alcotest.(check' (list string)) ~msg:"\"Ns<>W\\\" on repeated success" ~actual:(Gen.(generate_tree ~rand:(rand_init 3346) (string_size ~gen:printable (int_bound 8))) |> repeated_success) ~expected:[ "Ns<>W\\"; ""; ]) let test_string () = if ocaml_major_version < 5 then (Alcotest.(check' (list string)) ~msg:"\"9\007\127\250\" on repeated failure" ~actual:(Gen.(generate_tree ~rand:(rand_init 3345) string) |> repeated_failure) ~expected:[ "9\007\127\250"; "9\007"; "\127\250"; "\007\127\250"; "9\007\250"; "a\007\127\250"; "M\007\127\250"; "C\007\127\250"; ">\007\127\250"; ";\007\127\250"; ":\007\127\250"; "9a\127\250"; "94\127\250"; "9\029\127\250"; "9\018\127\250"; "9\012\127\250"; "9\t\127\250"; "9\b\127\250"; "9\007a\250"; "9\007p\250"; "9\007w\250"; "9\007{\250"; "9\007}\250"; "9\007~\250"; "9\007\127a"; "9\007\127\174"; "9\007\127\212"; "9\007\127\231"; "9\007\127\241"; "9\007\127\246"; "9\007\127\248"; "9\007\127\249"; ]; Alcotest.(check' (list string)) ~msg:"\"9\007\127\250\" on repeated success" ~actual:(Gen.(generate_tree ~rand:(rand_init 3345) string) |> repeated_success) ~expected:[ "9\007\127\250"; "9\007"; "\007"; ""; ]) else (Alcotest.(check' (list string)) ~msg:"\"\253NS\173\" on repeated failure" ~actual:(Gen.(generate_tree ~rand:(rand_init 3349) string) |> repeated_failure) ~expected:[ "\253NS\173"; "\253N"; "S\173"; "NS\173"; "\253N\173"; "aNS\173"; "\175NS\173"; "\214NS\173"; "\233NS\173"; "\243NS\173"; "\248NS\173"; "\250NS\173"; "\251NS\173"; "\252NS\173"; "\253aS\173"; "\253XS\173"; "\253SS\173"; "\253QS\173"; "\253PS\173"; "\253OS\173"; "\253Na\173"; "\253NZ\173"; "\253NV\173"; "\253NT\173"; "\253NSa"; "\253NS\135"; "\253NS\154"; "\253NS\163"; "\253NS\168"; "\253NS\170"; "\253NS\171"; "\253NS\172"]; Alcotest.(check' (list string)) ~msg:"\"\253NS\173\" on repeated success" ~actual:(Gen.(generate_tree ~rand:(rand_init 3349) string) |> repeated_success) ~expected:[ "\253NS\173"; "\253N"; "N"; ""; ]) let test_string_small () = if ocaml_major_version < 5 then (Alcotest.(check' (list string)) ~msg:"\"9\007\127\250\" on repeated failure" ~actual:(Gen.(generate_tree ~rand:(rand_init 3345) string_small) |> repeated_failure) ~expected:[ "9\007\127\250"; "9\007"; "\127\250"; "\007\127\250"; "9\007\250"; "a\007\127\250"; "M\007\127\250"; "C\007\127\250"; ">\007\127\250"; ";\007\127\250"; ":\007\127\250"; "9a\127\250"; "94\127\250"; "9\029\127\250"; "9\018\127\250"; "9\012\127\250"; "9\t\127\250"; "9\b\127\250"; "9\007a\250"; "9\007p\250"; "9\007w\250"; "9\007{\250"; "9\007}\250"; "9\007~\250"; "9\007\127a"; "9\007\127\174"; "9\007\127\212"; "9\007\127\231"; "9\007\127\241"; "9\007\127\246"; "9\007\127\248"; "9\007\127\249"; ]; Alcotest.(check' (list string)) ~msg:"\"u\238\154I\" on repeated success" ~actual:(Gen.(generate_tree ~rand:(rand_init 3345) string_small) |> repeated_success) ~expected:[ "9\007\127\250"; "9\007"; "\007"; ""; ]) else (Alcotest.(check' (list string)) ~msg:"\"\253NS\173\" on repeated failure" ~actual:(Gen.(generate_tree ~rand:(rand_init 3349) string_small) |> repeated_failure) ~expected:[ "\253NS\173"; "\253N"; "S\173"; "NS\173"; "\253N\173"; "aNS\173"; "\175NS\173"; "\214NS\173"; "\233NS\173"; "\243NS\173"; "\248NS\173"; "\250NS\173"; "\251NS\173"; "\252NS\173"; "\253aS\173"; "\253XS\173"; "\253SS\173"; "\253QS\173"; "\253PS\173"; "\253OS\173"; "\253Na\173"; "\253NZ\173"; "\253NV\173"; "\253NT\173"; "\253NSa"; "\253NS\135"; "\253NS\154"; "\253NS\163"; "\253NS\168"; "\253NS\170"; "\253NS\171"; "\253NS\172"]; Alcotest.(check' (list string)) ~msg:"\"\253NS\173\" on repeated success" ~actual:(Gen.(generate_tree ~rand:(rand_init 3349) string_small) |> repeated_success) ~expected:[ "\253NS\173"; "\253N"; "N"; ""; ]) let tests = ("Shrink", Alcotest.[ test_case "int_towards" `Quick test_int_towards; test_case "int32_towards" `Quick test_int32_towards; test_case "int64_towards" `Quick test_int64_towards; test_case "float_towards" `Quick test_float_towards; test_case "Gen.char tree" `Quick test_char; test_case "Gen.numeral tree" `Quick test_char_numeral; test_case "Gen.printable tree" `Quick test_char_printable; test_case "Gen.(pair small_int small_int) tree" `Quick test_pair_small_int; test_case "Gen.bind small_int tree" `Quick test_bind_small_int; test_case "Gen.list_size int" `Quick test_list_size_int; test_case "Gen.list int" `Quick test_list_int; test_case "Gen.small_list int" `Quick test_small_list_int; test_case "Gen.array_size int" `Quick test_array_size_int; test_case "Gen.array int" `Quick test_array_int; test_case "Gen.array_small int" `Quick test_small_array_int; test_case "Gen.bytes_size" `Quick test_bytes_size; test_case "Gen.bytes" `Quick test_bytes; test_case "Gen.bytes_small" `Quick test_bytes_small; test_case "Gen.string_size" `Quick test_string_size; test_case "Gen.string" `Quick test_string; test_case "Gen.string_small" `Quick test_string_small; ]) end module Gen = struct let test_gen_option ~ratio = let opt_int = Gen.option ?ratio Gen.int in let nb = ref 0 in for _i = 0 to 1000 do Gen.generate1 opt_int |> function None -> () | Some _ -> nb := !nb + 1 done; !nb let test_gen_option_default () = let nb = test_gen_option ~ratio:None in let b = nb > 800 && nb < 900 in Alcotest.(check bool) "Gen.option produces around 85% of Some" b true let test_gen_option_custom () = let nb = test_gen_option ~ratio:(Some 0.5) in let b = nb > 400 && nb < 600 in Alcotest.(check bool) "Gen.option produces around 50% of Some" b true let tests = ("Gen", Alcotest.[ test_case "option with default ratio" `Quick test_gen_option_default; test_case "option with custom ratio" `Quick test_gen_option_custom; ]) end module TestCount = struct let test_count_n ?count expected = let t = QCheck2.(Test.make ?count Gen.int (fun _ -> true)) in let msg = Printf.sprintf "QCheck2.Test.make ~count:%s |> get_count = %d" (Option.fold ~none:"None" ~some:string_of_int count) expected in Alcotest.(check int) msg expected (QCheck2.Test.test_get_count t) let test_count_10 () = test_count_n ~count:10 10 let test_count_default () = test_count_n 100 let test_count_env () = let () = Unix.putenv "QCHECK_COUNT" "5" in let t = QCheck2.(Test.make Gen.int (fun _ -> true)) in let actual = QCheck2.Test.test_get_count t in Alcotest.(check int) "default count is from QCHECK_COUNT" 5 actual let test_count_0 () = test_count_n ~count:0 0 let test_count_negative_fail () = try let _ = test_count_n ~count:(-1) (-1) in Alcotest.fail "A negative count in a test should fail" with | _ -> () let tests = ("Test.make ~count", Alcotest.[ test_case "make with custom count" `Quick test_count_10; test_case "make with default count" `Quick test_count_default; test_case "make with env count" `Quick test_count_env; test_case "make with 0 count" `Quick test_count_0; test_case "make with negative count should fail" `Quick test_count_negative_fail; ]) end module TestLongFactor = struct let test_long_factor_n ?long_factor expected = let t = QCheck2.(Test.make ?long_factor Gen.int (fun _ -> true)) in let msg = Printf.sprintf "QCheck2.Test.make ~long_factor:%s |> long_factor = %d" (Option.fold ~none:"None" ~some:string_of_int long_factor) expected in Alcotest.(check int) msg expected (QCheck2.Test.test_get_long_factor t) let test_long_factor_10 () = test_long_factor_n ~long_factor:10 10 let test_long_factor_default () = test_long_factor_n 1 let test_long_factor_env () = let () = Unix.putenv "QCHECK_LONG_FACTOR" "5" in let t = QCheck2.(Test.make Gen.int (fun _ -> true)) in let actual = QCheck2.Test.test_get_long_factor t in Alcotest.(check int) "default long factor is from QCHECK_LONG_FACTOR" 5 actual let test_long_factor_0 () = test_long_factor_n ~long_factor:0 0 let test_long_factor_negative_fail () = try let _ = test_long_factor_n ~long_factor:(-1) (-1) in Alcotest.fail "A negative long factor in a test should fail" with | _ -> () let tests = ("Test.make ~long_factor", Alcotest.[ test_case "make with custom long_factor" `Quick test_long_factor_10; test_case "make with default long_factor" `Quick test_long_factor_default; test_case "make with env long_factor" `Quick test_long_factor_env; test_case "make with 0 long_factor" `Quick test_long_factor_0; test_case "make with negative long_factor fail should" `Quick test_long_factor_negative_fail; ]) end module String = struct let test_string_shrinking () = let shrink_result = QCheck2.(find_example_gen ~f:(fun s -> s <> s ^ s) Gen.string) in Alcotest.(check string) "Shrinking a non-empty string shrinks to \"a\"" "a" shrink_result let tests = ("String", Alcotest.[test_case "shrinking" `Quick test_string_shrinking]) end module Check_exn = struct (* String.starts_with was introduced in 4.13. Include the below to support pre-4.13 OCaml. *) let string_starts_with ~prefix s = let open Stdlib in let prefix_len = String.length prefix in prefix_len <= String.length s && prefix = String.sub s 0 prefix_len let check_exn = Test.check_exn let test_pass_trivial () = let run_test () = check_exn QCheck2.(Test.make Gen.int (fun _ -> true)) in Alcotest.(check unit) "Success-trivial" () @@ run_test () let test_pass_random () = let run_test () = check_exn QCheck2.(Test.make Gen.(list int) (fun l -> List.rev (List.rev l) = l)) in Alcotest.(check unit) "Success-random" () @@ run_test () let test_fail_always () = let name = "will-always-fail" in try check_exn QCheck2.(Test.make ~name ~print:Print.int Gen.int (fun _ -> false)); Alcotest.failf "%s: Unexpected success" name with (Test.Test_fail (n,[c_ex_str])) -> Alcotest.(check string) (Printf.sprintf "%s: name" name) n name; if not (string_starts_with ~prefix:"0" c_ex_str) then Alcotest.failf "%s: counter-example prefix. Received: \"%s\"" name c_ex_str let test_fail_random () = let name = "list is own reverse" in try check_exn QCheck2.(Test.make ~name ~print:Print.(list int) Gen.(list int) (fun l -> List.rev l = l)); Alcotest.failf "%s: Unexpected success" name with (Test.Test_fail (n,[c_ex_str])) -> Alcotest.(check string) (Printf.sprintf "%s: name" name) n name; if not (string_starts_with ~prefix:"[0; 1]" c_ex_str) then Alcotest.failf "%s: counter-example prefix. Received \"%s\"" name c_ex_str exception MyError let test_error () = let name = "will-always-error" in try Printexc.record_backtrace false; (* for easier pattern-matching below *) check_exn QCheck2.(Test.make ~name ~print:Print.int Gen.int (fun _ -> raise MyError)); Alcotest.failf "%s: Unexpected success" name with (Test.Test_error (n,c_ex_str,MyError,"")) -> Alcotest.(check string) (Printf.sprintf "%s: name" name) n name; if not (string_starts_with ~prefix:"0" c_ex_str) then Alcotest.failf "%s: counter-example prefix. Received \"%s\"" name c_ex_str let test_negative_trivial () = let run_test () = check_exn QCheck2.(Test.make_neg Gen.int (fun _ -> false)) in Alcotest.(check unit) "Success-negative-trivial" () @@ run_test () let test_negative_test_unexpected_success () = let name = "negative-trivial-test" in let run_test () = check_exn QCheck2.(Test.make_neg ~name Gen.int (fun _ -> true)) in try run_test (); Alcotest.failf "Negative test didn't raise expected exception." with Test.Test_unexpected_success n -> Alcotest.(check string) (Printf.sprintf "%s: name" name) n name let tests = ("Test.check_exn", Alcotest.[ test_case "check_exn pass trivial" `Quick test_pass_trivial; test_case "check_exn pass random" `Quick test_pass_random; test_case "check_exn fail always" `Quick test_fail_always; test_case "check_exn fail random" `Quick test_fail_random; test_case "check_exn Error" `Quick test_error; test_case "check_exn negative pass trivial" `Quick test_negative_trivial; test_case "check_exn Unexpected success" `Quick test_negative_test_unexpected_success; ]) end let () = Alcotest.run "QCheck2" [ Shrink.tests; Gen.tests; TestCount.tests; TestLongFactor.tests; String.tests; Check_exn.tests; ] qcheck-0.25/test/core/QCheck_expect_test.expected.ocaml4.32000066400000000000000000002721451477416744200235310ustar00rootroot00000000000000random seed: 1234 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) (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,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,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,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,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,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,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) 911769578 455884789 227942395 113971198 56985599 28492800 14246400 7123200 3561600 1780800 890400 445200 222600 111300 55650 27825 13913 6957 3479 1740 870 435 218 109 55 28 14 7 4 2 1 0 [7; 1; 42; 1; 8; 5; 3; 9; 5; 38; 3; 3; 0; 1; 98; 1; 4; 13; 9; 2; 6; 9; 47; 6; 5; 8; 8; 6; 0; 9; 7; 2; 8; 6; 62; 6; 4; 31; 19; 1; 41; 60; 6; 5; 8; 1; 1; 4; 7; 7; 0; 5; 5; 71; 14; 26; 47; 5; 1; 6; 34; 9; 4; 2; 37; 3; 8; 4; 31; 6; 2; 1; 0; 7; 5; 1; 0; 15; 6; 1; 8; 13; 0; 6; 2; 4; 2; 6; 6; 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] [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] [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] [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] [7; 1; 42; 1; 8; 5; 3; 9; 5; 38; 3; 3; 0; 1; 98; 1] [7; 1; 42; 1; 8; 5; 3; 9] [7; 1; 42; 1] [7; 1] [] [7] [] [4] [] [2] [] [1] [] [0] [] [7; 1; 42; 1; 8; 5; 3; 9; 5; 38; 3; 3; 0; 1; 98; 1; 4; 13; 9; 2; 6; 9; 47; 6; 5; 8; 8; 6; 0; 9; 7; 2; 8; 6; 62; 6; 4; 31; 19; 1; 41; 60; 6; 5; 8; 1; 1; 4; 7; 7; 0; 5; 5; 71; 14; 26; 47; 5; 1; 6; 34; 9; 4; 2; 37; 3; 8; 4; 31; 6; 2; 1; 0; 7; 5; 1; 0; 15; 6; 1; 8; 13; 0; 6; 2; 4; 2; 6; 6; 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] [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] [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] [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] [7; 1; 42; 1; 8; 5; 3; 9; 5; 38; 3; 3; 0; 1; 98; 1] [7; 1; 42; 1; 8; 5; 3; 9] [7; 1; 42; 1] [7; 1] [42; 1] [7; 42; 1] [1; 42; 1] [1; 42] [1] [1; 1] [] [1] [0; 1] [1; 0] --- Failure -------------------------------------------------------------------- Test should_fail_sort_id failed (13 shrink steps): [1; 0] --- Failure -------------------------------------------------------------------- Test max_fail failed (16 shrink steps): [0; 1] --- Failure -------------------------------------------------------------------- Test max_fail failed (19 shrink steps): [0; 1] --- Failure -------------------------------------------------------------------- Test max_fail failed (11 shrink steps): [1; 0] === Error ====================================================================== Test should_error_raise_exn errored on (31 shrink steps): 0 exception QCheck_tests.Overall.Error +++ Collect ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Collect results for test collect_results: 4: 20 cases 3: 25 cases 2: 17 cases 1: 18 cases 0: 20 cases +++ Stats for with_stats ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats mod4: num: 100, avg: 1.68, stddev: 1.09, median 2, min 0, max 3 0: ############################## 17 1: ################################################### 29 2: ######################################## 23 3: ####################################################### 31 stats num: num: 100, avg: 66.84, stddev: 31.94, median 65, min 2, max 120 2.. 7: ################## 3 8.. 13: ################## 3 14.. 19: 0 20.. 25: ########################################## 7 26.. 31: ######################## 4 32.. 37: ######################## 4 38.. 43: ################## 3 44.. 49: ################################################ 8 50.. 55: #################################### 6 56.. 61: #################################### 6 62.. 67: ####################################################### 9 68.. 73: ########################################## 7 74.. 79: ######################## 4 80.. 85: ################## 3 86.. 91: ############ 2 92.. 97: ########################################## 7 98..103: #################################### 6 104..109: #################################### 6 110..115: ####################################################### 9 116..121: ################## 3 --- Failure -------------------------------------------------------------------- Test with shrinking retries failed (1 shrink steps): 4 !!! Warning !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Warning for test WARN_unlikely_precond: WARNING: only 0.6% tests (of 2000) passed precondition for "WARN_unlikely_precond" NOTE: it is likely that the precondition is too strong, or that the generator is buggy. --- Failure -------------------------------------------------------------------- Test FAIL_unlikely_precond failed: ERROR: only 0.6% tests (of 2000) passed precondition for "FAIL_unlikely_precond" NOTE: it is likely that the precondition is too strong, or that the generator is buggy. --- Failure -------------------------------------------------------------------- Test FAIL_bad_gen failed: ERROR: uncaught exception in generator for test FAIL_bad_gen after 100 steps: Exception: Invalid_argument("Gen.int_bound") Backtrace: --- Failure -------------------------------------------------------------------- Test int double failed: Negative test int double succeeded but was expected to fail === Error ====================================================================== Test pos fail with error errored on (7 shrink steps): 0 exception QCheck_tests.Overall.Error === Error ====================================================================== Test neg fail with error errored on (7 shrink steps): 0 exception QCheck_tests.Overall.Error --- Failure -------------------------------------------------------------------- Test char never produces '\255' failed (0 shrink steps): '\255' --- Failure -------------------------------------------------------------------- Test big bound issue59 failed (20 shrink steps): 209609 --- Failure -------------------------------------------------------------------- Test long_shrink failed (87 shrink steps): ([0], [-1]) --- Failure -------------------------------------------------------------------- Test ints arent 0 mod 3 failed (34 shrink steps): -21 --- Failure -------------------------------------------------------------------- Test ints are 0 failed (30 shrink steps): 1 --- Failure -------------------------------------------------------------------- Test int32s arent 0l rem 3l failed (41 shrink steps): -21l --- Failure -------------------------------------------------------------------- Test int32s are 0l failed (31 shrink steps): -1l --- Failure -------------------------------------------------------------------- Test int64s arent 0L rem 3L failed (90 shrink steps): -21L --- Failure -------------------------------------------------------------------- Test int64s are 0L failed (63 shrink steps): -1L --- Failure -------------------------------------------------------------------- Test ints < 209609 failed (20 shrink steps): 209609 --- Failure -------------------------------------------------------------------- Test nat < 5001 failed (6 shrink steps): 5001 --- Failure -------------------------------------------------------------------- Test char never produces 'abcdef' failed (3 shrink steps): 'a' --- Failure -------------------------------------------------------------------- Test printable never produces '!"#$%&' failed (2 shrink steps): '&' --- Failure -------------------------------------------------------------------- Test printable never produces less than '5 failed (3 shrink steps): '0' --- Failure -------------------------------------------------------------------- Test bytes are empty failed (15 shrink steps): "a" --- Failure -------------------------------------------------------------------- Test bytes never has a \000 char failed (8 shrink steps): "\000" --- Failure -------------------------------------------------------------------- Test bytes never has a \255 char failed (14 shrink steps): "\255" --- Failure -------------------------------------------------------------------- Test bytes have unique chars failed (13 shrink steps): "\129\129" --- Failure -------------------------------------------------------------------- Test strings are empty failed (15 shrink steps): "a" --- Failure -------------------------------------------------------------------- Test string never has a \000 char failed (8 shrink steps): "\000" --- Failure -------------------------------------------------------------------- Test string never has a \255 char failed (14 shrink steps): "\255" --- Failure -------------------------------------------------------------------- Test strings have unique chars failed (13 shrink steps): "\129\129" --- Failure -------------------------------------------------------------------- Test pairs have different components failed (0 shrink steps): (4, 4) --- Failure -------------------------------------------------------------------- Test pairs have same components failed (60 shrink steps): (0, 1) --- Failure -------------------------------------------------------------------- Test pairs have a zero component failed (59 shrink steps): (-1, 1) --- Failure -------------------------------------------------------------------- Test pairs are (0,0) failed (60 shrink steps): (0, 1) --- Failure -------------------------------------------------------------------- Test pairs are ordered failed (214 shrink steps): (1, 0) --- Failure -------------------------------------------------------------------- Test pairs are ordered reversely failed (59 shrink steps): (0, 1) --- Failure -------------------------------------------------------------------- Test pairs sum to less than 128 failed (54 shrink steps): (0, 128) --- Failure -------------------------------------------------------------------- Test pairs lists rev concat failed (72 shrink steps): ([0], [1]) --- Failure -------------------------------------------------------------------- Test pairs lists no overlap failed (26 shrink steps): ([0], [0]) --- Failure -------------------------------------------------------------------- Test triples have pair-wise different components failed (7 shrink steps): (0, 7, 7) --- Failure -------------------------------------------------------------------- Test triples have same components failed (90 shrink steps): (0, -1, 0) --- Failure -------------------------------------------------------------------- Test triples are ordered failed (90 shrink steps): (0, -1, 0) --- Failure -------------------------------------------------------------------- Test triples are ordered reversely failed (90 shrink steps): (0, 0, 1) --- Failure -------------------------------------------------------------------- Test quadruples have pair-wise different components failed (23 shrink steps): (0, 0, 0, 0) --- Failure -------------------------------------------------------------------- Test quadruples have same components failed (119 shrink steps): (0, -1, -2, 0) --- Failure -------------------------------------------------------------------- Test quadruples are ordered failed (121 shrink steps): (0, 0, -1, 0) --- Failure -------------------------------------------------------------------- Test quadruples are ordered reversely failed (121 shrink steps): (0, 0, 0, 1) --- Failure -------------------------------------------------------------------- Test forall (a, b) in nat: a < b failed (13 shrink steps): (0, 0) --- Failure -------------------------------------------------------------------- Test forall (a, b, c) in nat: a < b < c failed (15 shrink steps): (0, 0, 0) --- Failure -------------------------------------------------------------------- Test forall (a, b, c, d) in nat: a < b < c < d failed (23 shrink steps): (0, 0, 0, 0) --- Failure -------------------------------------------------------------------- Test forall (a, b, c, d, e) in nat: a < b < c < d < e failed (28 shrink steps): (0, 0, 0, 0, 0) --- Failure -------------------------------------------------------------------- Test forall (a, b, c, d, e, f) in nat: a < b < c < d < e < f failed (30 shrink steps): (0, 0, 0, 0, 0, 0) --- Failure -------------------------------------------------------------------- Test forall (a, b, c, d, e, f, g) in nat: a < b < c < d < e < f < g failed (31 shrink steps): (0, 0, 0, 0, 0, 0, 0) --- Failure -------------------------------------------------------------------- Test forall (a, b, c, d, e, f, g, h) in nat: a < b < c < d < e < f < g < h failed (35 shrink steps): (0, 0, 0, 0, 0, 0, 0, 0) --- Failure -------------------------------------------------------------------- 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): (0, 0, 0, 0, 0, 0, 0, 0, 0) --- Failure -------------------------------------------------------------------- Test bind ordered pairs failed (61 shrink steps): (0, 0) --- Failure -------------------------------------------------------------------- Test bind list_size constant failed (49 shrink steps): (4, [0; 0; 0; 0]) --- Failure -------------------------------------------------------------------- Test lists are empty failed (12 shrink steps): [0] --- Failure -------------------------------------------------------------------- Test lists shorter than 10 failed (39 shrink steps): [0; 0; 0; 0; 0; 0; 0; 0; 0; 0] --- Failure -------------------------------------------------------------------- Test lists shorter than 432 failed (1632 shrink steps): [...] list length: 432 --- Failure -------------------------------------------------------------------- Test lists shorter than 4332 failed (13 shrink steps): [...] list length: 4332 --- Failure -------------------------------------------------------------------- Test lists have unique elems failed (8 shrink steps): [1; 1] --- Failure -------------------------------------------------------------------- Test int option are none failed (11 shrink steps): Some (0) --- Failure -------------------------------------------------------------------- Test int option are some 100 or more failed (1 shrink steps): None --- Failure -------------------------------------------------------------------- Test (int,string) result are Ok failed (0 shrink steps): Error ("") --- Failure -------------------------------------------------------------------- Test (int,string) result are Error failed (11 shrink steps): Ok (0) --- Failure -------------------------------------------------------------------- Test tree contains only 42 failed (10 shrink steps): Leaf 0 --- Failure -------------------------------------------------------------------- Test sum list = 0 failed (0 shrink steps): [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] --- Failure -------------------------------------------------------------------- Test fail_pred_map_commute_int failed (48 shrink steps): ([1], {_ -> 0}, {1 -> true; _ -> false}) --- Failure -------------------------------------------------------------------- Test fail_pred_map_commute_int32 failed (149 shrink steps): ([-2l], {_ -> 0l}, {-2l -> true; _ -> false}) --- Failure -------------------------------------------------------------------- Test fail_pred_map_commute_int64 failed (181 shrink steps): ([3L], {_ -> 0L}, {3L -> true; _ -> false}) --- Failure -------------------------------------------------------------------- Test fail_pred_strings failed (2 shrink steps): {"some random string" -> true; _ -> false} --- Failure -------------------------------------------------------------------- Test fold_left fold_right failed (34 shrink steps): (0, [1], {(1, 0) -> 1; _ -> 0}) +++ Messages ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Messages for test fold_left fold_right: l=[1], fold_left=1, fold_right=0 --- Failure -------------------------------------------------------------------- Test fold_left fold_right uncurried failed (44 shrink steps): ({(0, 7) -> 1; _ -> 0}, 0, [7]) --- Failure -------------------------------------------------------------------- Test fold_left fold_right uncurried fun last failed (34 shrink steps): (0, [1], {(1, 0) -> 1; _ -> 0}) --- Failure -------------------------------------------------------------------- Test fold_left test, fun first failed (36 shrink steps): ({_ -> ""}, "a", [], [0]) --- Failure -------------------------------------------------------------------- Test FAIL_#99_1 failed: ERROR: uncaught exception in generator for test FAIL_#99_1 after 100 steps: Exception: QCheck.No_example_found("") Backtrace: +++ Collect ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Collect results for test bool dist: true: 250134 cases false: 249866 cases +++ Stats for char code dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats char code: num: 500000, avg: 127.42, stddev: 73.92, median 127, min 0, max 255 0.. 12: ###################################################### 25509 13.. 25: ###################################################### 25398 26.. 38: ###################################################### 25293 39.. 51: ###################################################### 25448 52.. 64: ###################################################### 25392 65.. 77: ####################################################### 25660 78.. 90: ###################################################### 25462 91..103: ###################################################### 25331 104..116: ##################################################### 25129 117..129: ###################################################### 25351 130..142: ###################################################### 25492 143..155: ###################################################### 25370 156..168: ###################################################### 25658 169..181: ###################################################### 25400 182..194: ##################################################### 25167 195..207: ###################################################### 25338 208..220: ##################################################### 25181 221..233: ##################################################### 25145 234..246: ###################################################### 25567 247..259: ##################################### 17709 +++ Stats for printable char code dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats char code: num: 500000, avg: 77.76, stddev: 27.92, median 78, min 10, max 125 10.. 15: ######### 5392 16.. 21: 0 22.. 27: 0 28.. 33: ################## 10661 34.. 39: ###################################################### 31788 40.. 45: ###################################################### 31217 46.. 51: ####################################################### 31790 52.. 57: ###################################################### 31625 58.. 63: ###################################################### 31421 64.. 69: ###################################################### 31732 70.. 75: ###################################################### 31446 76.. 81: ###################################################### 31382 82.. 87: ###################################################### 31623 88.. 93: ###################################################### 31730 94.. 99: ##################################################### 31193 100..105: ###################################################### 31424 106..111: ###################################################### 31675 112..117: ###################################################### 31651 118..123: ###################################################### 31682 124..129: ################## 10568 +++ Stats for numeral char code dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats char code: num: 500000, avg: 52.50, stddev: 2.87, median 52, min 48, max 57 48: ###################################################### 50260 49: ###################################################### 49590 50: ###################################################### 50170 51: ####################################################### 50270 52: ###################################################### 49805 53: ###################################################### 50161 54: ###################################################### 49919 55: ###################################################### 49971 56: ###################################################### 49980 57: ###################################################### 49874 +++ Stats for tree's depth ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats depth: num: 1000, avg: 3.74, stddev: 3.28, median 3, min 1, max 15 1: ####################################################### 377 2: ################ 113 3: ############ 87 4: ################# 123 5: ########### 81 6: #### 33 7: ##### 40 8: ##### 39 9: # 9 10: ### 25 11: ####### 49 12: 4 13: # 9 14: # 7 15: 4 +++ Stats for range_subset_spec ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 5000, avg: 9.97, stddev: 6.08, median 10, min 0, max 20 0: ################################################# 246 1: ################################################ 244 2: ################################################ 240 3: ################################################ 243 4: ############################################## 232 5: ############################################## 230 6: ############################################### 239 7: ############################################### 235 8: ####################################################### 274 9: ############################################## 233 10: ########################################## 212 11: ############################################## 231 12: ############################################### 239 13: ############################################# 226 14: ############################################# 225 15: ################################################### 256 16: ################################################ 240 17: ############################################# 229 18: ################################################ 243 19: ################################################## 253 20: ############################################## 230 +++ Stats for bytes_size len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 7.49, stddev: 1.70, median 7, min 5, max 10 5: ##################################################### 837 6: ##################################################### 826 7: ###################################################### 843 8: ####################################################### 855 9: #################################################### 813 10: ##################################################### 826 +++ Stats for bytes len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 384.53, stddev: 1330.61, median 9, min 0, max 9969 0.. 498: ####################################################### 4246 499.. 997: ###### 518 998..1496: 21 1497..1995: 10 1996..2494: 11 2495..2993: 10 2994..3492: 13 3493..3991: 13 3992..4490: 5 4491..4989: 10 4990..5488: 19 5489..5987: 9 5988..6486: 10 6487..6985: 12 6986..7484: 17 7485..7983: 16 7984..8482: 16 8483..8981: 16 8982..9480: 16 9481..9979: 12 +++ Stats for bytes_of len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 363.14, stddev: 1245.80, median 9, min 0, max 9986 0.. 499: ####################################################### 4270 500.. 999: ###### 493 1000.. 1499: 16 1500.. 1999: 11 2000.. 2499: 15 2500.. 2999: 17 3000.. 3499: 11 3500.. 3999: 19 4000.. 4499: 14 4500.. 4999: 10 5000.. 5499: 16 5500.. 5999: 11 6000.. 6499: 15 6500.. 6999: 13 7000.. 7499: 12 7500.. 7999: 16 8000.. 8499: 11 8500.. 8999: 4 9000.. 9499: 13 9500.. 9999: 13 +++ Stats for bytes_small len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 15.57, stddev: 24.36, median 6, min 0, max 99 0.. 4: #################################################### 1925 5.. 9: ####################################################### 2005 10.. 14: # 52 15.. 19: # 50 20.. 24: # 55 25.. 29: # 56 30.. 34: # 55 35.. 39: # 49 40.. 44: # 65 45.. 49: # 65 50.. 54: # 55 55.. 59: # 68 60.. 64: # 61 65.. 69: # 65 70.. 74: # 57 75.. 79: # 66 80.. 84: # 65 85.. 89: # 64 90.. 94: # 60 95.. 99: # 62 +++ Stats for string_size len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 7.49, stddev: 1.70, median 7, min 5, max 10 5: ##################################################### 837 6: ##################################################### 826 7: ###################################################### 843 8: ####################################################### 855 9: #################################################### 813 10: ##################################################### 826 +++ Stats for string len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 384.53, stddev: 1330.61, median 9, min 0, max 9969 0.. 498: ####################################################### 4246 499.. 997: ###### 518 998..1496: 21 1497..1995: 10 1996..2494: 11 2495..2993: 10 2994..3492: 13 3493..3991: 13 3992..4490: 5 4491..4989: 10 4990..5488: 19 5489..5987: 9 5988..6486: 10 6487..6985: 12 6986..7484: 17 7485..7983: 16 7984..8482: 16 8483..8981: 16 8982..9480: 16 9481..9979: 12 +++ Stats for string_of len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 363.14, stddev: 1245.80, median 9, min 0, max 9986 0.. 499: ####################################################### 4270 500.. 999: ###### 493 1000.. 1499: 16 1500.. 1999: 11 2000.. 2499: 15 2500.. 2999: 17 3000.. 3499: 11 3500.. 3999: 19 4000.. 4499: 14 4500.. 4999: 10 5000.. 5499: 16 5500.. 5999: 11 6000.. 6499: 15 6500.. 6999: 13 7000.. 7499: 12 7500.. 7999: 16 8000.. 8499: 11 8500.. 8999: 4 9000.. 9499: 13 9500.. 9999: 13 +++ Stats for printable_string len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 384.53, stddev: 1330.61, median 9, min 0, max 9969 0.. 498: ####################################################### 4246 499.. 997: ###### 518 998..1496: 21 1497..1995: 10 1996..2494: 11 2495..2993: 10 2994..3492: 13 3493..3991: 13 3992..4490: 5 4491..4989: 10 4990..5488: 19 5489..5987: 9 5988..6486: 10 6487..6985: 12 6986..7484: 17 7485..7983: 16 7984..8482: 16 8483..8981: 16 8982..9480: 16 9481..9979: 12 +++ Stats for small_string len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 15.57, stddev: 24.36, median 6, min 0, max 99 0.. 4: #################################################### 1925 5.. 9: ####################################################### 2005 10.. 14: # 52 15.. 19: # 50 20.. 24: # 55 25.. 29: # 56 30.. 34: # 55 35.. 39: # 49 40.. 44: # 65 45.. 49: # 65 50.. 54: # 55 55.. 59: # 68 60.. 64: # 61 65.. 69: # 65 70.. 74: # 57 75.. 79: # 66 80.. 84: # 65 85.. 89: # 64 90.. 94: # 60 95.. 99: # 62 +++ Stats for pair dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats pair sum: num: 500000, avg: 100.02, stddev: 41.22, median 100, min 0, max 200 0.. 9: ### 2685 10.. 19: ######## 7622 20.. 29: ############## 12474 30.. 39: #################### 17330 40.. 49: ########################## 22263 50.. 59: ############################### 26982 60.. 69: ##################################### 32182 70.. 79: ########################################### 37125 80.. 89: ################################################# 42287 90.. 99: ###################################################### 46691 100..109: ####################################################### 46977 110..119: ################################################# 42444 120..129: ############################################ 37719 130..139: ###################################### 32595 140..149: ################################ 27588 150..159: ########################## 22792 160..169: #################### 17805 170..179: ############### 13068 180..189: ######### 8218 190..199: ### 3115 200..209: 38 +++ Stats for triple dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats triple sum: num: 500000, avg: 150.08, stddev: 50.51, median 150, min 0, max 299 0.. 14: 345 15.. 29: ## 2121 30.. 44: ##### 5372 45.. 59: ########## 10501 60.. 74: ################# 17031 75.. 89: ######################### 25417 90..104: ################################### 35148 105..119: ############################################# 45134 120..134: ################################################### 51751 135..149: ####################################################### 55090 150..164: ###################################################### 55074 165..179: #################################################### 52238 180..194: ############################################# 45651 195..209: ################################### 35994 210..224: ######################### 26039 225..239: ################# 17749 240..254: ########## 10870 255..269: ##### 5765 270..284: ## 2313 285..299: 397 +++ Stats for quad dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats quad sum: num: 500000, avg: 200.13, stddev: 58.33, median 200, min 5, max 394 5.. 24: 102 25.. 44: 842 45.. 64: ## 3023 65.. 84: ###### 7154 85..104: ############ 14368 105..124: ##################### 25397 125..144: ############################### 37547 145..164: ########################################## 50174 165..184: ################################################## 60558 185..204: ####################################################### 65376 205..224: ##################################################### 63687 225..244: ############################################### 56248 245..264: ###################################### 45384 265..284: ########################## 31780 285..304: ################ 20158 305..324: ######### 10899 325..344: #### 5045 345..364: # 1848 365..384: 386 385..404: 24 +++ Stats for bind dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats ordered pair difference: num: 1000000, avg: 25.02, stddev: 22.36, median 19, min 0, max 100 0.. 4: ####################################################### 193184 5.. 9: ##################################### 130024 10.. 14: ############################# 103828 15.. 19: ######################## 87496 20.. 24: ##################### 74431 25.. 29: ################## 64629 30.. 34: ################ 56663 35.. 39: ############# 48986 40.. 44: ############ 43424 45.. 49: ########## 37599 50.. 54: ######### 32787 55.. 59: ######## 28332 60.. 64: ###### 24023 65.. 69: ##### 20312 70.. 74: #### 16649 75.. 79: ### 13338 80.. 84: ## 10239 85.. 89: ## 7391 90.. 94: # 4548 95.. 99: 2015 100..104: 102 stats ordered pair sum: num: 1000000, avg: 75.12, stddev: 46.93, median 72, min 0, max 200 0.. 9: ####################################################### 70423 10.. 19: ##################################################### 68068 20.. 29: ##################################################### 68449 30.. 39: ##################################################### 68577 40.. 49: ##################################################### 68763 50.. 59: ##################################################### 68351 60.. 69: ##################################################### 68744 70.. 79: ##################################################### 68451 80.. 89: ##################################################### 68309 90.. 99: ##################################################### 68835 100..109: ################################################## 64544 110..119: ########################################### 55512 120..129: ##################################### 47595 130..139: ############################### 39809 140..149: ######################### 32677 150..159: #################### 26312 160..169: ############### 20180 170..179: ########### 14265 180..189: ###### 8625 190..199: ## 3433 200..209: 78 +++ Collect ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Collect results for test option dist: None : 1489 cases Some _: 8511 cases +++ Collect ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Collect results for test result dist: Error _: 2523 cases Ok _ : 7477 cases +++ Stats for list len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 361.42, stddev: 1230.75, median 9, min 0, max 9974 0.. 498: ####################################################### 4212 499.. 997: ####### 578 998..1496: 11 1497..1995: 15 1996..2494: 11 2495..2993: 10 2994..3492: 13 3493..3991: 12 3992..4490: 7 4491..4989: 8 4990..5488: 15 5489..5987: 14 5988..6486: 12 6487..6985: 8 6986..7484: 9 7485..7983: 19 7984..8482: 14 8483..8981: 11 8982..9480: 11 9481..9979: 10 +++ Stats for small_list len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 15.79, stddev: 24.64, median 6, min 0, max 99 0.. 4: ###################################################### 1930 5.. 9: ####################################################### 1957 10.. 14: # 59 15.. 19: # 66 20.. 24: # 61 25.. 29: # 52 30.. 34: # 61 35.. 39: # 65 40.. 44: # 62 45.. 49: # 64 50.. 54: # 70 55.. 59: # 63 60.. 64: # 50 65.. 69: # 51 70.. 74: # 52 75.. 79: # 63 80.. 84: # 56 85.. 89: ## 75 90.. 94: ## 73 95.. 99: # 70 +++ Stats for list_of_size len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 7.51, stddev: 1.71, median 8, min 5, max 10 5: ###################################################### 834 6: ##################################################### 825 7: ##################################################### 820 8: ###################################################### 833 9: ####################################################### 844 10: ####################################################### 844 +++ Stats for list_repeat len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 42.00, stddev: 0.00, median 42, min 42, max 42 42: ####################################################### 5000 +++ Stats for array len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 361.42, stddev: 1230.75, median 9, min 0, max 9974 0.. 498: ####################################################### 4212 499.. 997: ####### 578 998..1496: 11 1497..1995: 15 1996..2494: 11 2495..2993: 10 2994..3492: 13 3493..3991: 12 3992..4490: 7 4491..4989: 8 4990..5488: 15 5489..5987: 14 5988..6486: 12 6487..6985: 8 6986..7484: 9 7485..7983: 19 7984..8482: 14 8483..8981: 11 8982..9480: 11 9481..9979: 10 +++ Stats for small_array len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 15.79, stddev: 24.64, median 6, min 0, max 99 0.. 4: ###################################################### 1930 5.. 9: ####################################################### 1957 10.. 14: # 59 15.. 19: # 66 20.. 24: # 61 25.. 29: # 52 30.. 34: # 61 35.. 39: # 65 40.. 44: # 62 45.. 49: # 64 50.. 54: # 70 55.. 59: # 63 60.. 64: # 50 65.. 69: # 51 70.. 74: # 52 75.. 79: # 63 80.. 84: # 56 85.. 89: ## 75 90.. 94: ## 73 95.. 99: # 70 +++ Stats for array_of_size len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 7.51, stddev: 1.71, median 8, min 5, max 10 5: ###################################################### 834 6: ##################################################### 825 7: ##################################################### 820 8: ###################################################### 833 9: ####################################################### 844 10: ####################################################### 844 +++ Stats for array_repeat len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 42.00, stddev: 0.00, median 42, min 42, max 42 42: ####################################################### 5000 +++ Stats for int_stats_neg ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 5000, avg: 0.17, stddev: 29.68, median 0, min -99, max 99 -99..-90: # 65 -89..-80: # 63 -79..-70: # 64 -69..-60: # 58 -59..-50: # 67 -49..-40: # 72 -39..-30: # 61 -29..-20: # 61 -19..-10: # 67 -9.. 0: ####################################################### 2076 1.. 10: ############################################## 1764 11.. 20: # 66 21.. 30: # 64 31.. 40: # 64 41.. 50: # 67 51.. 60: # 60 61.. 70: # 75 71.. 80: # 60 81.. 90: # 60 91..100: # 66 +++ Stats for small_signed_int dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 0.90, stddev: 28.23, median 0, min -99, max 99 -99..-90: # 12 -89..-80: # 11 -79..-70: # 9 -69..-60: 6 -59..-50: # 11 -49..-40: # 13 -39..-30: # 9 -29..-20: # 13 -19..-10: 8 -9.. 0: ####################################################### 453 1.. 10: ######################################### 340 11.. 20: # 15 21.. 30: # 11 31.. 40: # 12 41.. 50: # 13 51.. 60: # 13 61.. 70: # 16 71.. 80: # 9 81.. 90: # 16 91..100: # 10 +++ Stats for small_nat dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 15.11, stddev: 23.27, median 6, min 0, max 99 0.. 4: #################################################### 377 5.. 9: ####################################################### 392 10.. 14: ## 20 15.. 19: ## 15 20.. 24: # 11 25.. 29: ## 17 30.. 34: ## 19 35.. 39: ## 17 40.. 44: # 10 45.. 49: # 9 50.. 54: # 8 55.. 59: # 9 60.. 64: ## 15 65.. 69: # 10 70.. 74: # 13 75.. 79: ## 19 80.. 84: # 11 85.. 89: # 13 90.. 94: 5 95.. 99: # 10 +++ Stats for nat dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 363.02, stddev: 1215.04, median 9, min 0, max 9476 0.. 473: ####################################################### 847 474.. 947: ###### 95 948..1421: 14 1422..1895: 3 1896..2369: 0 2370..2843: 3 2844..3317: 2 3318..3791: 3 3792..4265: 2 4266..4739: 4 4740..5213: 3 5214..5687: 4 5688..6161: 3 6162..6635: 4 6636..7109: 1 7110..7583: 4 7584..8057: 2 8058..8531: 1 8532..9005: 1 9006..9479: 4 +++ Stats for int_range (-43643) 435434 dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 195335.64, stddev: 136803.99, median 195583, min -43624, max 435210 -43624..-19683: ############################################ 52 -19682.. 4259: ######################################## 47 4260.. 28201: ############################## 36 28202.. 52143: ############################################ 52 52144.. 76085: ########################################## 50 76086..100027: ####################################################### 64 100028..123969: ############################################### 55 123970..147911: ######################################## 47 147912..171853: ############################################## 54 171854..195795: #################################### 43 195796..219737: ############################################## 54 219738..243679: ########################################### 51 243680..267621: ################################################ 57 267622..291563: ########################################## 49 291564..315505: #################################### 42 315506..339447: ###################################### 45 339448..363389: ################################################ 57 363390..387331: ###################################### 45 387332..411273: ########################################## 49 411274..435215: ########################################### 51 +++ Stats for int_range (-40000) 40000 dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: -173.78, stddev: 23042.92, median 180, min -39859, max 39942 -39859..-35869: ############################################# 56 -35868..-31878: ################################### 43 -31877..-27887: ################################################# 60 -27886..-23896: ##################################### 46 -23895..-19905: ######################################## 49 -19904..-15914: #################################### 45 -15913..-11923: ############################################ 54 -11922.. -7932: ############################################### 58 -7931.. -3941: ######################################### 51 -3940.. 50: ############################ 35 51.. 4041: ####################################### 48 4042.. 8032: ########################################## 52 8033.. 12023: ######################################### 51 12024.. 16014: ########################################### 53 16015.. 20005: ############################################ 54 20006.. 23996: ################################## 42 23997.. 27987: ####################################################### 67 27988.. 31978: ################################ 40 31979.. 35969: ######################################### 51 35970.. 39960: #################################### 45 +++ Stats for int_range (-4) 4 dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 0.02, stddev: 2.55, median 0, min -4, max 4 -4: ############################################ 99 -3: ##################################################### 118 -2: ################################################## 111 -1: ################################################## 113 0: ################################################## 113 1: ##################################################### 118 2: ############################################# 102 3: ####################################################### 122 4: ############################################## 104 +++ Stats for int_range (-4) 17 dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 6.67, stddev: 6.39, median 7, min -4, max 17 -4..-3: ############################################# 90 -2..-1: ############################################# 91 0.. 1: ########################################## 84 2.. 3: ############################################## 92 4.. 5: ########################################### 87 6.. 7: ########################################### 86 8.. 9: ############################################ 89 10..11: ########################################### 87 12..13: ####################################################### 110 14..15: ############################################# 91 16..17: ############################################## 93 18..19: 0 20..21: 0 22..23: 0 24..25: 0 26..27: 0 28..29: 0 30..31: 0 32..33: 0 34..35: 0 +++ Stats for int dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 100000, avg: 336840.90, stddev: 6.193e+8, median 895228, min -1073728193, max 1073739280 -1073728193.. -966354820: ##################################################### 5009 -966354819.. -858981446: #################################################### 5004 -858981445.. -751608072: #################################################### 4917 -751608071.. -644234698: ##################################################### 5028 -644234697.. -536861324: #################################################### 4962 -536861323.. -429487950: ##################################################### 5039 -429487949.. -322114576: #################################################### 4927 -322114575.. -214741202: ##################################################### 5054 -214741201.. -107367828: ##################################################### 5065 -107367827.. 5546: #################################################### 4954 5547.. 107378920: #################################################### 4943 107378921.. 214752294: ################################################### 4900 214752295.. 322125668: ###################################################### 5126 322125669.. 429499042: ####################################################### 5198 429499043.. 536872416: #################################################### 4988 536872417.. 644245790: #################################################### 4940 644245791.. 751619164: #################################################### 5002 751619165.. 858992538: #################################################### 4928 858992539.. 966365912: ##################################################### 5070 966365913.. 1073739286: #################################################### 4946 +++ Stats for oneof int dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 1073741.63, stddev: 6.766e+8, median 0, min -1073741824, max 1073741823 -1073741824.. -966367642: ################## 208 -966367641.. -858993459: 0 -858993458.. -751619276: 0 -751619275.. -644245093: 0 -644245092.. -536870910: 0 -536870909.. -429496727: 0 -429496726.. -322122544: 0 -322122543.. -214748361: 0 -214748360.. -107374178: 0 -107374177.. 5: ####################################################### 603 6.. 107374188: 0 107374189.. 214748371: 0 214748372.. 322122554: 0 322122555.. 429496737: 0 429496738.. 536870920: 0 536870921.. 644245103: 0 644245104.. 751619286: 0 751619287.. 858993469: 0 858993470.. 966367652: 0 966367653.. 1073741823: ################# 189 +++ Stats for int32 lower dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 10000, avg: 32926.27, stddev: 18808.64, median 33297, min 0, max 65534 0.. 3276: ################################################ 481 3277.. 6553: ################################################## 497 6554.. 9830: ############################################### 469 9831..13107: #################################################### 515 13108..16384: ############################################### 470 16385..19661: ####################################################### 544 19662..22938: ################################################# 487 22939..26215: ################################################ 477 26216..29492: ################################################### 509 29493..32769: ############################################### 470 32770..36046: ################################################## 502 36047..39323: ##################################################### 530 39324..42600: ##################################################### 533 42601..45877: ##################################################### 525 45878..49154: ###################################################### 537 49155..52431: ################################################# 494 52432..55708: ############################################### 473 55709..58985: ################################################# 486 58986..62262: ################################################### 509 62263..65539: ################################################# 492 +++ Stats for int32 upper dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 10000, avg: 32678.65, stddev: 19067.06, median 32890, min 10, max 65523 10.. 3285: #################################################### 514 3286.. 6561: ################################################### 505 6562.. 9837: ####################################################### 541 9838..13113: ################################################# 491 13114..16389: ##################################################### 522 16390..19665: ################################################## 495 19666..22941: ############################################### 470 22942..26217: #################################################### 512 26218..29493: ############################################### 468 29494..32769: ############################################## 457 32770..36045: #################################################### 514 36046..39321: ############################################### 468 39322..42597: #################################################### 520 42598..45873: ################################################### 510 45874..49149: #################################################### 521 49150..52425: ############################################# 450 52426..55701: ##################################################### 526 55702..58977: ##################################################### 522 58978..62253: ################################################## 493 62254..65529: ################################################## 501 +++ Stats for int64 lower dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 10000, avg: 32767.87, stddev: 18950.16, median 33187, min 0, max 65532 0.. 3276: ################################################## 513 3277.. 6553: ################################################# 500 6554.. 9830: ################################################ 491 9831..13107: ################################################# 500 13108..16384: ################################################# 500 16385..19661: ################################################### 526 19662..22938: ################################################ 491 22939..26215: ############################################## 472 26216..29492: ################################################## 510 29493..32769: ########################################### 439 32770..36046: ################################################# 503 36047..39323: ################################################### 521 39324..42600: ################################################### 524 42601..45877: ############################################## 477 45878..49154: ####################################################### 560 49155..52431: ################################################# 506 52432..55708: ############################################### 482 55709..58985: ################################################ 492 58986..62262: ################################################ 496 62263..65539: ################################################ 497 +++ Stats for int64 lower-mid dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 10000, avg: 32779.13, stddev: 18897.20, median 32848, min 0, max 65535 0.. 3276: ############################################### 473 3277.. 6553: ################################################## 502 6554.. 9830: #################################################### 522 9831..13107: ################################################# 494 13108..16384: ##################################################### 535 16385..19661: ############################################### 471 19662..22938: ################################################# 495 22939..26215: #################################################### 522 26216..29492: ################################################ 489 29493..32769: ################################################ 487 32770..36046: ################################################# 493 36047..39323: ############################################### 476 39324..42600: ################################################# 494 42601..45877: ##################################################### 538 45878..49154: ####################################################### 550 49155..52431: ############################################### 479 52432..55708: ################################################### 513 55709..58985: ################################################ 487 58986..62262: ############################################### 470 62263..65539: ################################################### 510 +++ Stats for int64 upper-mid dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 10000, avg: 32833.01, stddev: 18869.35, median 32737, min 2, max 65534 2.. 3278: ################################################# 475 3279.. 6555: #################################################### 497 6556.. 9832: #################################################### 496 9833..13109: #################################################### 502 13110..16386: ###################################################### 514 16387..19663: ################################################### 492 19664..22940: #################################################### 501 22941..26217: ###################################################### 522 26218..29494: ##################################################### 505 29495..32771: #################################################### 502 32772..36048: ##################################################### 504 36049..39325: ###################################################### 519 39326..42602: ################################################# 469 42603..45879: ################################################### 493 45880..49156: ################################################### 491 49157..52433: #################################################### 498 52434..55710: #################################################### 495 55711..58987: ###################################################### 519 58988..62264: ####################################################### 523 62265..65541: ################################################## 483 +++ Stats for int64 upper dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 10000, avg: 32717.82, stddev: 19106.27, median 32768, min 2, max 65523 2.. 3278: ##################################################### 522 3279.. 6555: ###################################################### 530 6556.. 9832: #################################################### 510 9833..13109: ################################################# 484 13110..16386: ################################################# 488 16387..19663: ###################################################### 530 19664..22940: ################################################## 494 22941..26217: ################################################### 502 26218..29494: ################################################ 477 29495..32771: ############################################### 463 32772..36048: ############################################## 457 36049..39325: ################################################# 483 39326..42602: ##################################################### 521 42603..45879: #################################################### 519 45880..49156: ################################################# 485 49157..52433: ################################################ 476 52434..55710: #################################################### 510 55711..58987: ####################################################### 539 58988..62264: #################################################### 519 62265..65541: ################################################## 491 +++ Stats for exponential 10. dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 5000, avg: 9.56, stddev: 9.91, median 7, min 0, max 89 0.. 4: ####################################################### 1934 5.. 9: ################################## 1202 10.. 14: #################### 727 15.. 19: ############ 452 20.. 24: ######## 284 25.. 29: #### 164 30.. 34: ## 103 35.. 39: # 51 40.. 44: 26 45.. 49: 24 50.. 54: 15 55.. 59: 7 60.. 64: 3 65.. 69: 2 70.. 74: 2 75.. 79: 1 80.. 84: 1 85.. 89: 2 90.. 94: 0 95.. 99: 0 +++ Stats for exponential -10. dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 5000, avg: -9.56, stddev: 9.91, median -7, min -89, max 0 -89..-85: 2 -84..-80: 1 -79..-75: 1 -74..-70: 2 -69..-65: 2 -64..-60: 3 -59..-55: 7 -54..-50: 15 -49..-45: 24 -44..-40: 26 -39..-35: # 51 -34..-30: ## 103 -29..-25: #### 164 -24..-20: ######## 284 -19..-15: ############ 452 -14..-10: #################### 727 -9.. -5: ################################## 1202 -4.. 0: ####################################################### 1934 1.. 5: 0 6.. 10: 0 ================================================================================ 1 warning(s) failure (75 tests failed, 3 tests errored, ran 175 tests) random seed: 153870556 +++ Stats for int_dist_empty_bucket ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 1.035e+7, stddev: 4.322e+8, median 9, min -1066972208, max 1073741823 -1066972208.. -959936507: ## 27 -959936506.. -852900805: ## 22 -852900804.. -745865103: ## 22 -745865102.. -638829401: # 18 -638829400.. -531793699: # 17 -531793698.. -424757997: ## 21 -424757996.. -317722295: ### 33 -317722294.. -210686593: ### 33 -210686592.. -103650891: ### 32 -103650890.. 3384811: ####################################################### 516 3384812.. 110420513: ### 34 110420514.. 217456215: ### 34 217456216.. 324491917: # 17 324491918.. 431527619: ## 24 431527620.. 538563321: ## 26 538563322.. 645599023: ## 20 645599024.. 752634725: ## 24 752634726.. 859670427: ## 27 859670428.. 966706129: ## 27 966706130.. 1073741823: ## 26 ================================================================================ success (ran 1 tests) qcheck-0.25/test/core/QCheck_expect_test.expected.ocaml4.64000066400000000000000000002754361477416744200235440ustar00rootroot00000000000000random seed: 1234 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) (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,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,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,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,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,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,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) 2724675603984413065 1362337801992206533 681168900996103267 340584450498051634 170292225249025817 85146112624512909 42573056312256455 21286528156128228 10643264078064114 5321632039032057 2660816019516029 1330408009758015 665204004879008 332602002439504 166301001219752 83150500609876 41575250304938 20787625152469 10393812576235 5196906288118 2598453144059 1299226572030 649613286015 324806643008 162403321504 81201660752 40600830376 20300415188 10150207594 5075103797 2537551899 1268775950 634387975 317193988 158596994 79298497 39649249 19824625 9912313 4956157 2478079 1239040 619520 309760 154880 77440 38720 19360 9680 4840 2420 1210 605 303 152 76 38 19 10 5 3 2 1 0 [7; 1; 42; 1; 8; 5; 3; 9; 5; 38; 3; 3; 0; 1; 98; 1; 4; 13; 9; 2; 6; 9; 47; 6; 5; 8; 8; 6; 0; 9; 7; 2; 8; 6; 62; 6; 4; 31; 19; 1; 41; 60; 6; 5; 8; 1; 1; 4; 7; 7; 0; 5; 5; 71; 14; 26; 47; 5; 1; 6; 34; 9; 4; 2; 37; 3; 8; 4; 31; 6; 2; 1; 0; 7; 5; 1; 0; 15; 6; 1; 8; 13; 0; 6; 2; 4; 2; 6; 6; 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] [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] [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] [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] [7; 1; 42; 1; 8; 5; 3; 9; 5; 38; 3; 3; 0; 1; 98; 1] [7; 1; 42; 1; 8; 5; 3; 9] [7; 1; 42; 1] [7; 1] [] [7] [] [4] [] [2] [] [1] [] [0] [] [7; 1; 42; 1; 8; 5; 3; 9; 5; 38; 3; 3; 0; 1; 98; 1; 4; 13; 9; 2; 6; 9; 47; 6; 5; 8; 8; 6; 0; 9; 7; 2; 8; 6; 62; 6; 4; 31; 19; 1; 41; 60; 6; 5; 8; 1; 1; 4; 7; 7; 0; 5; 5; 71; 14; 26; 47; 5; 1; 6; 34; 9; 4; 2; 37; 3; 8; 4; 31; 6; 2; 1; 0; 7; 5; 1; 0; 15; 6; 1; 8; 13; 0; 6; 2; 4; 2; 6; 6; 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] [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] [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] [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] [7; 1; 42; 1; 8; 5; 3; 9; 5; 38; 3; 3; 0; 1; 98; 1] [7; 1; 42; 1; 8; 5; 3; 9] [7; 1; 42; 1] [7; 1] [42; 1] [7; 42; 1] [1; 42; 1] [1; 42] [1] [1; 1] [] [1] [0; 1] [1; 0] --- Failure -------------------------------------------------------------------- Test should_fail_sort_id failed (13 shrink steps): [1; 0] --- Failure -------------------------------------------------------------------- Test max_fail failed (16 shrink steps): [0; 1] --- Failure -------------------------------------------------------------------- Test max_fail failed (19 shrink steps): [0; 1] --- Failure -------------------------------------------------------------------- Test max_fail failed (11 shrink steps): [1; 0] === Error ====================================================================== Test should_error_raise_exn errored on (63 shrink steps): 0 exception QCheck_tests.Overall.Error +++ Collect ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Collect results for test collect_results: 4: 20 cases 3: 25 cases 2: 17 cases 1: 18 cases 0: 20 cases +++ Stats for with_stats ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats mod4: num: 100, avg: 1.68, stddev: 1.09, median 2, min 0, max 3 0: ############################## 17 1: ################################################### 29 2: ######################################## 23 3: ####################################################### 31 stats num: num: 100, avg: 66.84, stddev: 31.94, median 65, min 2, max 120 2.. 7: ################## 3 8.. 13: ################## 3 14.. 19: 0 20.. 25: ########################################## 7 26.. 31: ######################## 4 32.. 37: ######################## 4 38.. 43: ################## 3 44.. 49: ################################################ 8 50.. 55: #################################### 6 56.. 61: #################################### 6 62.. 67: ####################################################### 9 68.. 73: ########################################## 7 74.. 79: ######################## 4 80.. 85: ################## 3 86.. 91: ############ 2 92.. 97: ########################################## 7 98..103: #################################### 6 104..109: #################################### 6 110..115: ####################################################### 9 116..121: ################## 3 --- Failure -------------------------------------------------------------------- Test with shrinking retries failed (1 shrink steps): 4 !!! Warning !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Warning for test WARN_unlikely_precond: WARNING: only 0.5% tests (of 2000) passed precondition for "WARN_unlikely_precond" NOTE: it is likely that the precondition is too strong, or that the generator is buggy. --- Failure -------------------------------------------------------------------- Test FAIL_unlikely_precond failed: ERROR: only 0.5% tests (of 2000) passed precondition for "FAIL_unlikely_precond" NOTE: it is likely that the precondition is too strong, or that the generator is buggy. --- Failure -------------------------------------------------------------------- Test FAIL_bad_gen failed: ERROR: uncaught exception in generator for test FAIL_bad_gen after 100 steps: Exception: Invalid_argument("Gen.int_bound") Backtrace: --- Failure -------------------------------------------------------------------- Test int double failed: Negative test int double succeeded but was expected to fail === Error ====================================================================== Test pos fail with error errored on (7 shrink steps): 0 exception QCheck_tests.Overall.Error === Error ====================================================================== Test neg fail with error errored on (7 shrink steps): 0 exception QCheck_tests.Overall.Error --- Failure -------------------------------------------------------------------- Test char never produces '\255' failed (0 shrink steps): '\255' --- Failure -------------------------------------------------------------------- Test big bound issue59 failed (52 shrink steps): 209609 --- Failure -------------------------------------------------------------------- Test long_shrink failed (149 shrink steps): ([0], [-1]) --- Failure -------------------------------------------------------------------- Test ints arent 0 mod 3 failed (84 shrink steps): -21 --- Failure -------------------------------------------------------------------- Test ints are 0 failed (62 shrink steps): 1 --- Failure -------------------------------------------------------------------- Test int32s arent 0l rem 3l failed (41 shrink steps): -21l --- Failure -------------------------------------------------------------------- Test int32s are 0l failed (31 shrink steps): -1l --- Failure -------------------------------------------------------------------- Test int64s arent 0L rem 3L failed (90 shrink steps): -21L --- Failure -------------------------------------------------------------------- Test int64s are 0L failed (63 shrink steps): -1L --- Failure -------------------------------------------------------------------- Test ints < 209609 failed (52 shrink steps): 209609 --- Failure -------------------------------------------------------------------- Test nat < 5001 failed (6 shrink steps): 5001 --- Failure -------------------------------------------------------------------- Test char never produces 'abcdef' failed (3 shrink steps): 'a' --- Failure -------------------------------------------------------------------- Test printable never produces '!"#$%&' failed (2 shrink steps): '&' --- Failure -------------------------------------------------------------------- Test printable never produces less than '5 failed (3 shrink steps): '0' --- Failure -------------------------------------------------------------------- Test bytes are empty failed (15 shrink steps): "a" --- Failure -------------------------------------------------------------------- Test bytes never has a \000 char failed (8 shrink steps): "\000" --- Failure -------------------------------------------------------------------- Test bytes never has a \255 char failed (14 shrink steps): "\255" --- Failure -------------------------------------------------------------------- Test bytes have unique chars failed (13 shrink steps): "\129\129" --- Failure -------------------------------------------------------------------- Test strings are empty failed (15 shrink steps): "a" --- Failure -------------------------------------------------------------------- Test string never has a \000 char failed (8 shrink steps): "\000" --- Failure -------------------------------------------------------------------- Test string never has a \255 char failed (14 shrink steps): "\255" --- Failure -------------------------------------------------------------------- Test strings have unique chars failed (13 shrink steps): "\129\129" --- Failure -------------------------------------------------------------------- Test pairs have different components failed (0 shrink steps): (4, 4) --- Failure -------------------------------------------------------------------- Test pairs have same components failed (125 shrink steps): (0, 1) --- Failure -------------------------------------------------------------------- Test pairs have a zero component failed (124 shrink steps): (-1, 1) --- Failure -------------------------------------------------------------------- Test pairs are (0,0) failed (125 shrink steps): (0, 1) --- Failure -------------------------------------------------------------------- Test pairs are ordered failed (827 shrink steps): (1, 0) --- Failure -------------------------------------------------------------------- Test pairs are ordered reversely failed (124 shrink steps): (0, 1) --- Failure -------------------------------------------------------------------- Test pairs sum to less than 128 failed (116 shrink steps): (0, 128) --- Failure -------------------------------------------------------------------- Test pairs lists rev concat failed (147 shrink steps): ([0], [1]) --- Failure -------------------------------------------------------------------- Test pairs lists no overlap failed (26 shrink steps): ([0], [0]) --- Failure -------------------------------------------------------------------- Test triples have pair-wise different components failed (7 shrink steps): (0, 7, 7) --- Failure -------------------------------------------------------------------- Test triples have same components failed (188 shrink steps): (0, -1, 0) --- Failure -------------------------------------------------------------------- Test triples are ordered failed (188 shrink steps): (0, -1, 0) --- Failure -------------------------------------------------------------------- Test triples are ordered reversely failed (188 shrink steps): (0, 0, 1) --- Failure -------------------------------------------------------------------- Test quadruples have pair-wise different components failed (23 shrink steps): (0, 0, 0, 0) --- Failure -------------------------------------------------------------------- Test quadruples have same components failed (250 shrink steps): (0, 1, 0, 1) --- Failure -------------------------------------------------------------------- Test quadruples are ordered failed (251 shrink steps): (0, 0, -1, 0) --- Failure -------------------------------------------------------------------- Test quadruples are ordered reversely failed (251 shrink steps): (0, 0, 0, 1) --- Failure -------------------------------------------------------------------- Test forall (a, b) in nat: a < b failed (13 shrink steps): (0, 0) --- Failure -------------------------------------------------------------------- Test forall (a, b, c) in nat: a < b < c failed (15 shrink steps): (0, 0, 0) --- Failure -------------------------------------------------------------------- Test forall (a, b, c, d) in nat: a < b < c < d failed (23 shrink steps): (0, 0, 0, 0) --- Failure -------------------------------------------------------------------- Test forall (a, b, c, d, e) in nat: a < b < c < d < e failed (28 shrink steps): (0, 0, 0, 0, 0) --- Failure -------------------------------------------------------------------- Test forall (a, b, c, d, e, f) in nat: a < b < c < d < e < f failed (30 shrink steps): (0, 0, 0, 0, 0, 0) --- Failure -------------------------------------------------------------------- Test forall (a, b, c, d, e, f, g) in nat: a < b < c < d < e < f < g failed (31 shrink steps): (0, 0, 0, 0, 0, 0, 0) --- Failure -------------------------------------------------------------------- Test forall (a, b, c, d, e, f, g, h) in nat: a < b < c < d < e < f < g < h failed (35 shrink steps): (0, 0, 0, 0, 0, 0, 0, 0) --- Failure -------------------------------------------------------------------- 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): (0, 0, 0, 0, 0, 0, 0, 0, 0) --- Failure -------------------------------------------------------------------- Test bind ordered pairs failed (125 shrink steps): (0, 0) --- Failure -------------------------------------------------------------------- Test bind list_size constant failed (49 shrink steps): (4, [0; 0; 0; 0]) --- Failure -------------------------------------------------------------------- Test lists are empty failed (12 shrink steps): [0] --- Failure -------------------------------------------------------------------- Test lists shorter than 10 failed (39 shrink steps): [0; 0; 0; 0; 0; 0; 0; 0; 0; 0] --- Failure -------------------------------------------------------------------- Test lists shorter than 432 failed (1632 shrink steps): [...] list length: 432 --- Failure -------------------------------------------------------------------- Test lists shorter than 4332 failed (13 shrink steps): [...] list length: 4332 --- Failure -------------------------------------------------------------------- Test lists have unique elems failed (8 shrink steps): [1; 1] --- Failure -------------------------------------------------------------------- Test int option are none failed (11 shrink steps): Some (0) --- Failure -------------------------------------------------------------------- Test int option are some 100 or more failed (1 shrink steps): None --- Failure -------------------------------------------------------------------- Test (int,string) result are Ok failed (0 shrink steps): Error ("") --- Failure -------------------------------------------------------------------- Test (int,string) result are Error failed (11 shrink steps): Ok (0) --- Failure -------------------------------------------------------------------- Test tree contains only 42 failed (10 shrink steps): Leaf 0 --- Failure -------------------------------------------------------------------- Test sum list = 0 failed (0 shrink steps): [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] --- Failure -------------------------------------------------------------------- Test fail_pred_map_commute_int failed (77 shrink steps): ([1], {_ -> 0}, {1 -> true; _ -> false}) --- Failure -------------------------------------------------------------------- Test fail_pred_map_commute_int32 failed (149 shrink steps): ([-2l], {_ -> 0l}, {-2l -> true; _ -> false}) --- Failure -------------------------------------------------------------------- Test fail_pred_map_commute_int64 failed (181 shrink steps): ([3L], {_ -> 0L}, {3L -> true; _ -> false}) --- Failure -------------------------------------------------------------------- Test fail_pred_strings failed (2 shrink steps): {"some random string" -> true; _ -> false} --- Failure -------------------------------------------------------------------- Test fold_left fold_right failed (34 shrink steps): (0, [1], {(1, 0) -> 1; _ -> 0}) +++ Messages ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Messages for test fold_left fold_right: l=[1], fold_left=1, fold_right=0 --- Failure -------------------------------------------------------------------- Test fold_left fold_right uncurried failed (44 shrink steps): ({(0, 7) -> 1; _ -> 0}, 0, [7]) --- Failure -------------------------------------------------------------------- Test fold_left fold_right uncurried fun last failed (34 shrink steps): (0, [1], {(1, 0) -> 1; _ -> 0}) --- Failure -------------------------------------------------------------------- Test fold_left test, fun first failed (36 shrink steps): ({_ -> ""}, "a", [], [0]) --- Failure -------------------------------------------------------------------- Test FAIL_#99_1 failed: ERROR: uncaught exception in generator for test FAIL_#99_1 after 100 steps: Exception: QCheck.No_example_found("") Backtrace: +++ Collect ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Collect results for test bool dist: true: 250134 cases false: 249866 cases +++ Stats for char code dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats char code: num: 500000, avg: 127.42, stddev: 73.92, median 127, min 0, max 255 0.. 12: ###################################################### 25509 13.. 25: ###################################################### 25398 26.. 38: ###################################################### 25293 39.. 51: ###################################################### 25448 52.. 64: ###################################################### 25392 65.. 77: ####################################################### 25660 78.. 90: ###################################################### 25462 91..103: ###################################################### 25331 104..116: ##################################################### 25129 117..129: ###################################################### 25351 130..142: ###################################################### 25492 143..155: ###################################################### 25370 156..168: ###################################################### 25658 169..181: ###################################################### 25400 182..194: ##################################################### 25167 195..207: ###################################################### 25338 208..220: ##################################################### 25181 221..233: ##################################################### 25145 234..246: ###################################################### 25567 247..259: ##################################### 17709 +++ Stats for printable char code dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats char code: num: 500000, avg: 77.76, stddev: 27.92, median 78, min 10, max 125 10.. 15: ######### 5392 16.. 21: 0 22.. 27: 0 28.. 33: ################## 10661 34.. 39: ###################################################### 31788 40.. 45: ###################################################### 31217 46.. 51: ####################################################### 31790 52.. 57: ###################################################### 31625 58.. 63: ###################################################### 31421 64.. 69: ###################################################### 31732 70.. 75: ###################################################### 31446 76.. 81: ###################################################### 31382 82.. 87: ###################################################### 31623 88.. 93: ###################################################### 31730 94.. 99: ##################################################### 31193 100..105: ###################################################### 31424 106..111: ###################################################### 31675 112..117: ###################################################### 31651 118..123: ###################################################### 31682 124..129: ################## 10568 +++ Stats for numeral char code dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats char code: num: 500000, avg: 52.50, stddev: 2.87, median 52, min 48, max 57 48: ###################################################### 50260 49: ###################################################### 49590 50: ###################################################### 50170 51: ####################################################### 50270 52: ###################################################### 49805 53: ###################################################### 50161 54: ###################################################### 49919 55: ###################################################### 49971 56: ###################################################### 49980 57: ###################################################### 49874 +++ Stats for tree's depth ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats depth: num: 1000, avg: 3.74, stddev: 3.28, median 3, min 1, max 15 1: ####################################################### 377 2: ################ 113 3: ############ 87 4: ################# 123 5: ########### 81 6: #### 33 7: ##### 40 8: ##### 39 9: # 9 10: ### 25 11: ####### 49 12: 4 13: # 9 14: # 7 15: 4 +++ Stats for range_subset_spec ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 5000, avg: 9.97, stddev: 6.08, median 10, min 0, max 20 0: ################################################# 246 1: ################################################ 244 2: ################################################ 240 3: ################################################ 243 4: ############################################## 232 5: ############################################## 230 6: ############################################### 239 7: ############################################### 235 8: ####################################################### 274 9: ############################################## 233 10: ########################################## 212 11: ############################################## 231 12: ############################################### 239 13: ############################################# 226 14: ############################################# 225 15: ################################################### 256 16: ################################################ 240 17: ############################################# 229 18: ################################################ 243 19: ################################################## 253 20: ############################################## 230 +++ Stats for bytes_size len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 7.49, stddev: 1.70, median 7, min 5, max 10 5: ##################################################### 837 6: ##################################################### 826 7: ###################################################### 843 8: ####################################################### 855 9: #################################################### 813 10: ##################################################### 826 +++ Stats for bytes len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 384.53, stddev: 1330.61, median 9, min 0, max 9969 0.. 498: ####################################################### 4246 499.. 997: ###### 518 998..1496: 21 1497..1995: 10 1996..2494: 11 2495..2993: 10 2994..3492: 13 3493..3991: 13 3992..4490: 5 4491..4989: 10 4990..5488: 19 5489..5987: 9 5988..6486: 10 6487..6985: 12 6986..7484: 17 7485..7983: 16 7984..8482: 16 8483..8981: 16 8982..9480: 16 9481..9979: 12 +++ Stats for bytes_of len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 363.14, stddev: 1245.80, median 9, min 0, max 9986 0.. 499: ####################################################### 4270 500.. 999: ###### 493 1000.. 1499: 16 1500.. 1999: 11 2000.. 2499: 15 2500.. 2999: 17 3000.. 3499: 11 3500.. 3999: 19 4000.. 4499: 14 4500.. 4999: 10 5000.. 5499: 16 5500.. 5999: 11 6000.. 6499: 15 6500.. 6999: 13 7000.. 7499: 12 7500.. 7999: 16 8000.. 8499: 11 8500.. 8999: 4 9000.. 9499: 13 9500.. 9999: 13 +++ Stats for bytes_small len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 15.57, stddev: 24.36, median 6, min 0, max 99 0.. 4: #################################################### 1925 5.. 9: ####################################################### 2005 10.. 14: # 52 15.. 19: # 50 20.. 24: # 55 25.. 29: # 56 30.. 34: # 55 35.. 39: # 49 40.. 44: # 65 45.. 49: # 65 50.. 54: # 55 55.. 59: # 68 60.. 64: # 61 65.. 69: # 65 70.. 74: # 57 75.. 79: # 66 80.. 84: # 65 85.. 89: # 64 90.. 94: # 60 95.. 99: # 62 +++ Stats for string_size len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 7.49, stddev: 1.70, median 7, min 5, max 10 5: ##################################################### 837 6: ##################################################### 826 7: ###################################################### 843 8: ####################################################### 855 9: #################################################### 813 10: ##################################################### 826 +++ Stats for string len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 384.53, stddev: 1330.61, median 9, min 0, max 9969 0.. 498: ####################################################### 4246 499.. 997: ###### 518 998..1496: 21 1497..1995: 10 1996..2494: 11 2495..2993: 10 2994..3492: 13 3493..3991: 13 3992..4490: 5 4491..4989: 10 4990..5488: 19 5489..5987: 9 5988..6486: 10 6487..6985: 12 6986..7484: 17 7485..7983: 16 7984..8482: 16 8483..8981: 16 8982..9480: 16 9481..9979: 12 +++ Stats for string_of len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 363.14, stddev: 1245.80, median 9, min 0, max 9986 0.. 499: ####################################################### 4270 500.. 999: ###### 493 1000.. 1499: 16 1500.. 1999: 11 2000.. 2499: 15 2500.. 2999: 17 3000.. 3499: 11 3500.. 3999: 19 4000.. 4499: 14 4500.. 4999: 10 5000.. 5499: 16 5500.. 5999: 11 6000.. 6499: 15 6500.. 6999: 13 7000.. 7499: 12 7500.. 7999: 16 8000.. 8499: 11 8500.. 8999: 4 9000.. 9499: 13 9500.. 9999: 13 +++ Stats for printable_string len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 384.53, stddev: 1330.61, median 9, min 0, max 9969 0.. 498: ####################################################### 4246 499.. 997: ###### 518 998..1496: 21 1497..1995: 10 1996..2494: 11 2495..2993: 10 2994..3492: 13 3493..3991: 13 3992..4490: 5 4491..4989: 10 4990..5488: 19 5489..5987: 9 5988..6486: 10 6487..6985: 12 6986..7484: 17 7485..7983: 16 7984..8482: 16 8483..8981: 16 8982..9480: 16 9481..9979: 12 +++ Stats for small_string len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 15.57, stddev: 24.36, median 6, min 0, max 99 0.. 4: #################################################### 1925 5.. 9: ####################################################### 2005 10.. 14: # 52 15.. 19: # 50 20.. 24: # 55 25.. 29: # 56 30.. 34: # 55 35.. 39: # 49 40.. 44: # 65 45.. 49: # 65 50.. 54: # 55 55.. 59: # 68 60.. 64: # 61 65.. 69: # 65 70.. 74: # 57 75.. 79: # 66 80.. 84: # 65 85.. 89: # 64 90.. 94: # 60 95.. 99: # 62 +++ Stats for pair dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats pair sum: num: 500000, avg: 100.02, stddev: 41.22, median 100, min 0, max 200 0.. 9: ### 2685 10.. 19: ######## 7622 20.. 29: ############## 12474 30.. 39: #################### 17330 40.. 49: ########################## 22263 50.. 59: ############################### 26982 60.. 69: ##################################### 32182 70.. 79: ########################################### 37125 80.. 89: ################################################# 42287 90.. 99: ###################################################### 46691 100..109: ####################################################### 46977 110..119: ################################################# 42444 120..129: ############################################ 37719 130..139: ###################################### 32595 140..149: ################################ 27588 150..159: ########################## 22792 160..169: #################### 17805 170..179: ############### 13068 180..189: ######### 8218 190..199: ### 3115 200..209: 38 +++ Stats for triple dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats triple sum: num: 500000, avg: 150.08, stddev: 50.51, median 150, min 0, max 299 0.. 14: 345 15.. 29: ## 2121 30.. 44: ##### 5372 45.. 59: ########## 10501 60.. 74: ################# 17031 75.. 89: ######################### 25417 90..104: ################################### 35148 105..119: ############################################# 45134 120..134: ################################################### 51751 135..149: ####################################################### 55090 150..164: ###################################################### 55074 165..179: #################################################### 52238 180..194: ############################################# 45651 195..209: ################################### 35994 210..224: ######################### 26039 225..239: ################# 17749 240..254: ########## 10870 255..269: ##### 5765 270..284: ## 2313 285..299: 397 +++ Stats for quad dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats quad sum: num: 500000, avg: 200.13, stddev: 58.33, median 200, min 5, max 394 5.. 24: 102 25.. 44: 842 45.. 64: ## 3023 65.. 84: ###### 7154 85..104: ############ 14368 105..124: ##################### 25397 125..144: ############################### 37547 145..164: ########################################## 50174 165..184: ################################################## 60558 185..204: ####################################################### 65376 205..224: ##################################################### 63687 225..244: ############################################### 56248 245..264: ###################################### 45384 265..284: ########################## 31780 285..304: ################ 20158 305..324: ######### 10899 325..344: #### 5045 345..364: # 1848 365..384: 386 385..404: 24 +++ Stats for bind dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats ordered pair difference: num: 1000000, avg: 25.02, stddev: 22.36, median 19, min 0, max 100 0.. 4: ####################################################### 193184 5.. 9: ##################################### 130024 10.. 14: ############################# 103828 15.. 19: ######################## 87496 20.. 24: ##################### 74431 25.. 29: ################## 64629 30.. 34: ################ 56663 35.. 39: ############# 48986 40.. 44: ############ 43424 45.. 49: ########## 37599 50.. 54: ######### 32787 55.. 59: ######## 28332 60.. 64: ###### 24023 65.. 69: ##### 20312 70.. 74: #### 16649 75.. 79: ### 13338 80.. 84: ## 10239 85.. 89: ## 7391 90.. 94: # 4548 95.. 99: 2015 100..104: 102 stats ordered pair sum: num: 1000000, avg: 75.12, stddev: 46.93, median 72, min 0, max 200 0.. 9: ####################################################### 70423 10.. 19: ##################################################### 68068 20.. 29: ##################################################### 68449 30.. 39: ##################################################### 68577 40.. 49: ##################################################### 68763 50.. 59: ##################################################### 68351 60.. 69: ##################################################### 68744 70.. 79: ##################################################### 68451 80.. 89: ##################################################### 68309 90.. 99: ##################################################### 68835 100..109: ################################################## 64544 110..119: ########################################### 55512 120..129: ##################################### 47595 130..139: ############################### 39809 140..149: ######################### 32677 150..159: #################### 26312 160..169: ############### 20180 170..179: ########### 14265 180..189: ###### 8625 190..199: ## 3433 200..209: 78 +++ Collect ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Collect results for test option dist: None : 1500 cases Some _: 8500 cases +++ Collect ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Collect results for test result dist: Error _: 2554 cases Ok _ : 7446 cases +++ Stats for list len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 400.16, stddev: 1371.90, median 9, min 0, max 9987 0.. 499: ####################################################### 4246 500.. 999: ###### 502 1000.. 1499: 13 1500.. 1999: 10 2000.. 2499: 14 2500.. 2999: 14 3000.. 3499: 20 3500.. 3999: 7 4000.. 4499: 13 4500.. 4999: 16 5000.. 5499: 12 5500.. 5999: 15 6000.. 6499: 15 6500.. 6999: 13 7000.. 7499: 16 7500.. 7999: 12 8000.. 8499: 11 8500.. 8999: 16 9000.. 9499: 15 9500.. 9999: 20 +++ Stats for small_list len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 16.14, stddev: 24.86, median 6, min 0, max 99 0.. 4: ###################################################### 1923 5.. 9: ####################################################### 1936 10.. 14: # 61 15.. 19: # 59 20.. 24: # 62 25.. 29: # 70 30.. 34: # 61 35.. 39: # 64 40.. 44: # 64 45.. 49: # 56 50.. 54: # 65 55.. 59: # 55 60.. 64: # 60 65.. 69: # 62 70.. 74: # 57 75.. 79: # 69 80.. 84: ## 73 85.. 89: # 67 90.. 94: # 62 95.. 99: ## 74 +++ Stats for list_of_size len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 7.49, stddev: 1.71, median 8, min 5, max 10 5: ####################################################### 867 6: ################################################### 813 7: ################################################### 815 8: #################################################### 833 9: ###################################################### 857 10: ################################################### 815 +++ Stats for list_repeat len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 42.00, stddev: 0.00, median 42, min 42, max 42 42: ####################################################### 5000 +++ Stats for array len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 400.16, stddev: 1371.90, median 9, min 0, max 9987 0.. 499: ####################################################### 4246 500.. 999: ###### 502 1000.. 1499: 13 1500.. 1999: 10 2000.. 2499: 14 2500.. 2999: 14 3000.. 3499: 20 3500.. 3999: 7 4000.. 4499: 13 4500.. 4999: 16 5000.. 5499: 12 5500.. 5999: 15 6000.. 6499: 15 6500.. 6999: 13 7000.. 7499: 16 7500.. 7999: 12 8000.. 8499: 11 8500.. 8999: 16 9000.. 9499: 15 9500.. 9999: 20 +++ Stats for small_array len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 16.14, stddev: 24.86, median 6, min 0, max 99 0.. 4: ###################################################### 1923 5.. 9: ####################################################### 1936 10.. 14: # 61 15.. 19: # 59 20.. 24: # 62 25.. 29: # 70 30.. 34: # 61 35.. 39: # 64 40.. 44: # 64 45.. 49: # 56 50.. 54: # 65 55.. 59: # 55 60.. 64: # 60 65.. 69: # 62 70.. 74: # 57 75.. 79: # 69 80.. 84: ## 73 85.. 89: # 67 90.. 94: # 62 95.. 99: ## 74 +++ Stats for array_of_size len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 7.49, stddev: 1.71, median 8, min 5, max 10 5: ####################################################### 867 6: ################################################### 813 7: ################################################### 815 8: #################################################### 833 9: ###################################################### 857 10: ################################################### 815 +++ Stats for array_repeat len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 42.00, stddev: 0.00, median 42, min 42, max 42 42: ####################################################### 5000 +++ Stats for int_stats_neg ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 5000, avg: 0.17, stddev: 29.68, median 0, min -99, max 99 -99..-90: # 65 -89..-80: # 63 -79..-70: # 64 -69..-60: # 58 -59..-50: # 67 -49..-40: # 72 -39..-30: # 61 -29..-20: # 61 -19..-10: # 67 -9.. 0: ####################################################### 2076 1.. 10: ############################################## 1764 11.. 20: # 66 21.. 30: # 64 31.. 40: # 64 41.. 50: # 67 51.. 60: # 60 61.. 70: # 75 71.. 80: # 60 81.. 90: # 60 91..100: # 66 +++ Stats for small_signed_int dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 0.90, stddev: 28.23, median 0, min -99, max 99 -99..-90: # 12 -89..-80: # 11 -79..-70: # 9 -69..-60: 6 -59..-50: # 11 -49..-40: # 13 -39..-30: # 9 -29..-20: # 13 -19..-10: 8 -9.. 0: ####################################################### 453 1.. 10: ######################################### 340 11.. 20: # 15 21.. 30: # 11 31.. 40: # 12 41.. 50: # 13 51.. 60: # 13 61.. 70: # 16 71.. 80: # 9 81.. 90: # 16 91..100: # 10 +++ Stats for small_nat dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 15.11, stddev: 23.27, median 6, min 0, max 99 0.. 4: #################################################### 377 5.. 9: ####################################################### 392 10.. 14: ## 20 15.. 19: ## 15 20.. 24: # 11 25.. 29: ## 17 30.. 34: ## 19 35.. 39: ## 17 40.. 44: # 10 45.. 49: # 9 50.. 54: # 8 55.. 59: # 9 60.. 64: ## 15 65.. 69: # 10 70.. 74: # 13 75.. 79: ## 19 80.. 84: # 11 85.. 89: # 13 90.. 94: 5 95.. 99: # 10 +++ Stats for nat dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 363.02, stddev: 1215.04, median 9, min 0, max 9476 0.. 473: ####################################################### 847 474.. 947: ###### 95 948..1421: 14 1422..1895: 3 1896..2369: 0 2370..2843: 3 2844..3317: 2 3318..3791: 3 3792..4265: 2 4266..4739: 4 4740..5213: 3 5214..5687: 4 5688..6161: 3 6162..6635: 4 6636..7109: 1 7110..7583: 4 7584..8057: 2 8058..8531: 1 8532..9005: 1 9006..9479: 4 +++ Stats for int_range (-43643) 435434 dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 195335.64, stddev: 136803.99, median 195583, min -43624, max 435210 -43624..-19683: ############################################ 52 -19682.. 4259: ######################################## 47 4260.. 28201: ############################## 36 28202.. 52143: ############################################ 52 52144.. 76085: ########################################## 50 76086..100027: ####################################################### 64 100028..123969: ############################################### 55 123970..147911: ######################################## 47 147912..171853: ############################################## 54 171854..195795: #################################### 43 195796..219737: ############################################## 54 219738..243679: ########################################### 51 243680..267621: ################################################ 57 267622..291563: ########################################## 49 291564..315505: #################################### 42 315506..339447: ###################################### 45 339448..363389: ################################################ 57 363390..387331: ###################################### 45 387332..411273: ########################################## 49 411274..435215: ########################################### 51 +++ Stats for int_range (-40000) 40000 dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: -173.78, stddev: 23042.92, median 180, min -39859, max 39942 -39859..-35869: ############################################# 56 -35868..-31878: ################################### 43 -31877..-27887: ################################################# 60 -27886..-23896: ##################################### 46 -23895..-19905: ######################################## 49 -19904..-15914: #################################### 45 -15913..-11923: ############################################ 54 -11922.. -7932: ############################################### 58 -7931.. -3941: ######################################### 51 -3940.. 50: ############################ 35 51.. 4041: ####################################### 48 4042.. 8032: ########################################## 52 8033.. 12023: ######################################### 51 12024.. 16014: ########################################### 53 16015.. 20005: ############################################ 54 20006.. 23996: ################################## 42 23997.. 27987: ####################################################### 67 27988.. 31978: ################################ 40 31979.. 35969: ######################################### 51 35970.. 39960: #################################### 45 +++ Stats for int_range (-4) 4 dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 0.02, stddev: 2.55, median 0, min -4, max 4 -4: ############################################ 99 -3: ##################################################### 118 -2: ################################################## 111 -1: ################################################## 113 0: ################################################## 113 1: ##################################################### 118 2: ############################################# 102 3: ####################################################### 122 4: ############################################## 104 +++ Stats for int_range (-4) 17 dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 6.67, stddev: 6.39, median 7, min -4, max 17 -4..-3: ############################################# 90 -2..-1: ############################################# 91 0.. 1: ########################################## 84 2.. 3: ############################################## 92 4.. 5: ########################################### 87 6.. 7: ########################################### 86 8.. 9: ############################################ 89 10..11: ########################################### 87 12..13: ####################################################### 110 14..15: ############################################# 91 16..17: ############################################## 93 18..19: 0 20..21: 0 22..23: 0 24..25: 0 26..27: 0 28..29: 0 30..31: 0 32..33: 0 34..35: 0 +++ Stats for int dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 100000, avg: 2.541e+15, stddev: 2.661e+18, median 158655268318060, min -4611522359435274428, max 4611540922436307689 -4611522359435274428..-4150369195341695293: ##################################################### 4976 -4150369195341695292..-3689216031248116157: ##################################################### 4963 -3689216031248116156..-3228062867154537021: ###################################################### 5038 -3228062867154537020..-2766909703060957885: ##################################################### 4979 -2766909703060957884..-2305756538967378749: ##################################################### 5001 -2305756538967378748..-1844603374873799613: ##################################################### 4982 -1844603374873799612..-1383450210780220477: ##################################################### 5025 -1383450210780220476.. -922297046686641341: #################################################### 4901 -922297046686641340.. -461143882593062205: ####################################################### 5126 -461143882593062204.. 9281500516931: ##################################################### 5008 9281500516932.. 461162445594096067: ###################################################### 5041 461162445594096068.. 922315609687675203: ##################################################### 5001 922315609687675204.. 1383468773781254339: ##################################################### 4986 1383468773781254340.. 1844621937874833475: ##################################################### 4949 1844621937874833476.. 2305775101968412611: ##################################################### 5025 2305775101968412612.. 2766928266061991747: ##################################################### 5022 2766928266061991748.. 3228081430155570883: ##################################################### 4958 3228081430155570884.. 3689234594249150019: ##################################################### 4998 3689234594249150020.. 4150387758342729155: ##################################################### 4982 4150387758342729156.. 4611540922436308291: ###################################################### 5039 +++ Stats for oneof int dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 4.612e+15, stddev: 2.906e+18, median 0, min -4611686018427387904, max 4611686018427387903 -4611686018427387904..-4150517416584649089: ################## 208 -4150517416584649088..-3689348814741910273: 0 -3689348814741910272..-3228180212899171457: 0 -3228180212899171456..-2767011611056432641: 0 -2767011611056432640..-2305843009213693825: 0 -2305843009213693824..-1844674407370955009: 0 -1844674407370955008..-1383505805528216193: 0 -1383505805528216192.. -922337203685477377: 0 -922337203685477376.. -461168601842738561: 0 -461168601842738560.. 255: ####################################################### 603 256.. 461168601842739071: 0 461168601842739072.. 922337203685477887: 0 922337203685477888.. 1383505805528216703: 0 1383505805528216704.. 1844674407370955519: 0 1844674407370955520.. 2305843009213694335: 0 2305843009213694336.. 2767011611056433151: 0 2767011611056433152.. 3228180212899171967: 0 3228180212899171968.. 3689348814741910783: 0 3689348814741910784.. 4150517416584649599: 0 4150517416584649600.. 4611686018427387903: ################# 189 +++ Stats for int32 lower dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 10000, avg: 32926.27, stddev: 18808.64, median 33297, min 0, max 65534 0.. 3276: ################################################ 481 3277.. 6553: ################################################## 497 6554.. 9830: ############################################### 469 9831..13107: #################################################### 515 13108..16384: ############################################### 470 16385..19661: ####################################################### 544 19662..22938: ################################################# 487 22939..26215: ################################################ 477 26216..29492: ################################################### 509 29493..32769: ############################################### 470 32770..36046: ################################################## 502 36047..39323: ##################################################### 530 39324..42600: ##################################################### 533 42601..45877: ##################################################### 525 45878..49154: ###################################################### 537 49155..52431: ################################################# 494 52432..55708: ############################################### 473 55709..58985: ################################################# 486 58986..62262: ################################################### 509 62263..65539: ################################################# 492 +++ Stats for int32 upper dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 10000, avg: 32678.65, stddev: 19067.06, median 32890, min 10, max 65523 10.. 3285: #################################################### 514 3286.. 6561: ################################################### 505 6562.. 9837: ####################################################### 541 9838..13113: ################################################# 491 13114..16389: ##################################################### 522 16390..19665: ################################################## 495 19666..22941: ############################################### 470 22942..26217: #################################################### 512 26218..29493: ############################################### 468 29494..32769: ############################################## 457 32770..36045: #################################################### 514 36046..39321: ############################################### 468 39322..42597: #################################################### 520 42598..45873: ################################################### 510 45874..49149: #################################################### 521 49150..52425: ############################################# 450 52426..55701: ##################################################### 526 55702..58977: ##################################################### 522 58978..62253: ################################################## 493 62254..65529: ################################################## 501 +++ Stats for int64 lower dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 10000, avg: 32767.87, stddev: 18950.16, median 33187, min 0, max 65532 0.. 3276: ################################################## 513 3277.. 6553: ################################################# 500 6554.. 9830: ################################################ 491 9831..13107: ################################################# 500 13108..16384: ################################################# 500 16385..19661: ################################################### 526 19662..22938: ################################################ 491 22939..26215: ############################################## 472 26216..29492: ################################################## 510 29493..32769: ########################################### 439 32770..36046: ################################################# 503 36047..39323: ################################################### 521 39324..42600: ################################################### 524 42601..45877: ############################################## 477 45878..49154: ####################################################### 560 49155..52431: ################################################# 506 52432..55708: ############################################### 482 55709..58985: ################################################ 492 58986..62262: ################################################ 496 62263..65539: ################################################ 497 +++ Stats for int64 lower-mid dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 10000, avg: 32779.13, stddev: 18897.20, median 32848, min 0, max 65535 0.. 3276: ############################################### 473 3277.. 6553: ################################################## 502 6554.. 9830: #################################################### 522 9831..13107: ################################################# 494 13108..16384: ##################################################### 535 16385..19661: ############################################### 471 19662..22938: ################################################# 495 22939..26215: #################################################### 522 26216..29492: ################################################ 489 29493..32769: ################################################ 487 32770..36046: ################################################# 493 36047..39323: ############################################### 476 39324..42600: ################################################# 494 42601..45877: ##################################################### 538 45878..49154: ####################################################### 550 49155..52431: ############################################### 479 52432..55708: ################################################### 513 55709..58985: ################################################ 487 58986..62262: ############################################### 470 62263..65539: ################################################### 510 +++ Stats for int64 upper-mid dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 10000, avg: 32833.01, stddev: 18869.35, median 32737, min 2, max 65534 2.. 3278: ################################################# 475 3279.. 6555: #################################################### 497 6556.. 9832: #################################################### 496 9833..13109: #################################################### 502 13110..16386: ###################################################### 514 16387..19663: ################################################### 492 19664..22940: #################################################### 501 22941..26217: ###################################################### 522 26218..29494: ##################################################### 505 29495..32771: #################################################### 502 32772..36048: ##################################################### 504 36049..39325: ###################################################### 519 39326..42602: ################################################# 469 42603..45879: ################################################### 493 45880..49156: ################################################### 491 49157..52433: #################################################### 498 52434..55710: #################################################### 495 55711..58987: ###################################################### 519 58988..62264: ####################################################### 523 62265..65541: ################################################## 483 +++ Stats for int64 upper dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 10000, avg: 32717.82, stddev: 19106.27, median 32768, min 2, max 65523 2.. 3278: ##################################################### 522 3279.. 6555: ###################################################### 530 6556.. 9832: #################################################### 510 9833..13109: ################################################# 484 13110..16386: ################################################# 488 16387..19663: ###################################################### 530 19664..22940: ################################################## 494 22941..26217: ################################################### 502 26218..29494: ################################################ 477 29495..32771: ############################################### 463 32772..36048: ############################################## 457 36049..39325: ################################################# 483 39326..42602: ##################################################### 521 42603..45879: #################################################### 519 45880..49156: ################################################# 485 49157..52433: ################################################ 476 52434..55710: #################################################### 510 55711..58987: ####################################################### 539 58988..62264: #################################################### 519 62265..65541: ################################################## 491 +++ Stats for exponential 10. dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 5000, avg: 9.56, stddev: 9.91, median 7, min 0, max 89 0.. 4: ####################################################### 1934 5.. 9: ################################## 1202 10.. 14: #################### 727 15.. 19: ############ 452 20.. 24: ######## 284 25.. 29: #### 164 30.. 34: ## 103 35.. 39: # 51 40.. 44: 26 45.. 49: 24 50.. 54: 15 55.. 59: 7 60.. 64: 3 65.. 69: 2 70.. 74: 2 75.. 79: 1 80.. 84: 1 85.. 89: 2 90.. 94: 0 95.. 99: 0 +++ Stats for exponential -10. dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 5000, avg: -9.56, stddev: 9.91, median -7, min -89, max 0 -89..-85: 2 -84..-80: 1 -79..-75: 1 -74..-70: 2 -69..-65: 2 -64..-60: 3 -59..-55: 7 -54..-50: 15 -49..-45: 24 -44..-40: 26 -39..-35: # 51 -34..-30: ## 103 -29..-25: #### 164 -24..-20: ######## 284 -19..-15: ############ 452 -14..-10: #################### 727 -9.. -5: ################################## 1202 -4.. 0: ####################################################### 1934 1.. 5: 0 6.. 10: 0 ================================================================================ 1 warning(s) failure (75 tests failed, 3 tests errored, ran 175 tests) random seed: 153870556 +++ Stats for int_dist_empty_bucket ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: -5.508e+16, stddev: 1.847e+18, median 9, min -4590718933436425025, max 4611686018427387903 -4590718933436425025..-4130598685843234370: ## 26 -4130598685843234369..-3670478438250043714: # 13 -3670478438250043713..-3210358190656853058: ### 37 -3210358190656853057..-2750237943063662402: ### 30 -2750237943063662401..-2290117695470471746: ## 27 -2290117695470471745..-1829997447877281090: ## 24 -1829997447877281089..-1369877200284090434: ## 27 -1369877200284090433.. -909756952690899778: ## 27 -909756952690899777.. -449636705097709122: ## 21 -449636705097709121.. 10483542495481534: ####################################################### 531 10483542495481535.. 470603790088672190: ## 21 470603790088672191.. 930724037681862846: ## 27 930724037681862847.. 1390844285275053502: ## 24 1390844285275053503.. 1850964532868244158: ## 25 1850964532868244159.. 2311084780461434814: ## 28 2311084780461434815.. 2771205028054625470: ## 23 2771205028054625471.. 3231325275647816126: ## 23 3231325275647816127.. 3691445523241006782: ## 25 3691445523241006783.. 4151565770834197438: # 17 4151565770834197439.. 4611686018427387903: ## 24 ================================================================================ success (ran 1 tests) qcheck-0.25/test/core/QCheck_expect_test.expected.ocaml5.32000066400000000000000000002754341477416744200235360ustar00rootroot00000000000000random seed: 1234 45 4 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 (8,fun,45) (4,fun,5) (5,fun,23) (54,fun,6) (6,fun,9) (2,fun,9) (2,fun,9) (77,fun,6) (6,fun,54) (1,fun,3) (8,fun,45) (4,fun,5) (5,fun,23) (54,fun,6) (6,fun,9) (2,fun,9) (2,fun,9) (77,fun,6) (6,fun,54) (1,fun,3) (8,fun,45) (4,fun,5) (5,fun,23) (54,fun,6) (6,fun,9) (2,fun,9) (2,fun,9) (77,fun,6) (6,fun,54) (1,fun,3) (8,fun,45) (4,fun,5) (5,fun,23) (54,fun,6) (6,fun,9) (2,fun,9) (2,fun,9) (77,fun,6) (6,fun,54) (1,fun,3) (8,fun,45) (4,fun,5) (5,fun,23) (54,fun,6) (6,fun,9) (2,fun,9) (2,fun,9) (77,fun,6) (6,fun,54) (1,fun,3) (8,fun,45) (4,fun,5) (5,fun,23) (54,fun,6) (6,fun,9) (2,fun,9) (2,fun,9) (77,fun,6) (6,fun,54) (1,fun,3) (8,fun,45) (4,fun,5) (5,fun,23) (54,fun,6) (6,fun,9) (2,fun,9) (2,fun,9) (77,fun,6) (6,fun,54) (1,fun,3) (8,fun,45) (4,fun,5) (5,fun,23) (54,fun,6) (6,fun,9) (2,fun,9) (2,fun,9) (77,fun,6) (6,fun,54) (1,fun,3) -466273346 -233136673 -116568337 -58284169 -29142085 -14571043 -7285522 -3642761 -1821381 -910691 -455346 -227673 -113837 -56919 -28460 -14230 -7115 -3558 -1779 -890 -445 -223 -112 -56 -28 -14 -7 -4 -2 -1 0 [46; 2; 22; 4; 4; 2; 6; 5; 88; 24; 7; 9; 9; 2; 5; 1; 55; 8; 45; 1; 96; 0; 1; 2; 7; 4; 1; 5; 95; 6; 8; 6; 4; 0; 5; 5; 22; 87; 2; 1; 1; 0; 2; 2; 9; 5; 9; 3; 7; 59; 7; 96; 6; 5; 1; 3; 9; 9; 65; 6; 7; 7; 2; 5; 0; 0; 70; 5; 5; 2; 1; 57; 9; 7; 8; 10; 9; 7; 9; 75; 73; 80; 7; 9; 4; 3; 16; 5; 79; 1; 8; 6; 2; 3; 4; 9; 2; 8; 4; 6; 50; 2; 1; 5; 9; 5; 4; 3; 56; 6; 5; 9; 4; 1; 47; 1; 2; 5; 2; 0; 7; 31; 55; 6; 7; 4; 7; 8; 8; 2; 4; 40; 4; 6; 9; 3; 59; 5; 1; 0; 2; 6; 90; 1; 6; 81; 0; 1; 3; 7; 2; 4; 5; 4; 7; 3; 62; 0; 1; 6; 7; 5; 97; 83; 41; 7; 2; 6; 3; 0; 4; 8; 99; 8; 6; 0; 7; 9; 7; 1; 55; 30; 25; 3; 4; 7; 1; 6; 80; 8; 0; 4; 21; 3; 5; 9; 27; 10; 60; 47; 54; 6; 5; 8; 1; 5; 9; 65; 9; 5; 7; 7; 6; 48; 9; 5; 6; 4; 9; 7; 1; 2; 71; 6; 9; 2; 7; 8; 14; 59; 71; 30; 7; 3; 5; 4; 6; 7; 3; 6; 9; 8; 2; 38; 6; 6; 7; 1; 5; 2; 43; 5; 2; 9; 3; 0; 3; 2; 7; 71; 26; 3; 9; 11; 5; 1; 5; 2; 53; 46; 4; 6; 7; 67; 1; 0; 34; 0; 48; 5; 5; 0; 7; 49; 92; 8; 3; 0; 67; 1; 5; 2; 9; 5; 9; 3; 1; 4; 8; 0; 3; 6; 46; 58; 1; 54; 77; 0; 96; 1; 6; 2; 8; 22; 3; 9; 2; 6; 25; 49; 9; 6; 3; 8; 5; 9; 54; 1; 7; 5; 6; 5; 1; 7; 8; 23; 4; 6; 4; 2; 5; 8; 4; 7; 4] [46; 2; 22; 4; 4; 2; 6; 5; 88; 24; 7; 9; 9; 2; 5; 1; 55; 8; 45; 1; 96; 0; 1; 2; 7; 4; 1; 5; 95; 6; 8; 6; 4; 0; 5; 5; 22; 87; 2; 1; 1; 0; 2; 2; 9; 5; 9; 3; 7; 59; 7; 96; 6; 5; 1; 3; 9; 9; 65; 6; 7; 7; 2; 5; 0; 0; 70; 5; 5; 2; 1; 57; 9; 7; 8; 10; 9; 7; 9; 75; 73; 80; 7; 9; 4; 3; 16; 5; 79; 1; 8; 6; 2; 3; 4; 9; 2; 8; 4; 6; 50; 2; 1; 5; 9; 5; 4; 3; 56; 6; 5; 9; 4; 1; 47; 1; 2; 5; 2; 0; 7; 31; 55; 6; 7; 4; 7; 8; 8; 2; 4; 40; 4; 6; 9; 3; 59; 5; 1; 0; 2; 6; 90; 1; 6; 81; 0; 1; 3; 7; 2; 4; 5; 4; 7; 3; 62; 0; 1; 6; 7; 5; 97; 83; 41; 7; 2; 6; 3; 0; 4; 8; 99] [46; 2; 22; 4; 4; 2; 6; 5; 88; 24; 7; 9; 9; 2; 5; 1; 55; 8; 45; 1; 96; 0; 1; 2; 7; 4; 1; 5; 95; 6; 8; 6; 4; 0; 5; 5; 22; 87; 2; 1; 1; 0; 2; 2; 9; 5; 9; 3; 7; 59; 7; 96; 6; 5; 1; 3; 9; 9; 65; 6; 7; 7; 2; 5; 0; 0; 70; 5; 5; 2; 1; 57; 9; 7; 8; 10; 9; 7; 9; 75; 73; 80; 7; 9; 4; 3; 16] [46; 2; 22; 4; 4; 2; 6; 5; 88; 24; 7; 9; 9; 2; 5; 1; 55; 8; 45; 1; 96; 0; 1; 2; 7; 4; 1; 5; 95; 6; 8; 6; 4; 0; 5; 5; 22; 87; 2; 1; 1; 0; 2; 2] [46; 2; 22; 4; 4; 2; 6; 5; 88; 24; 7; 9; 9; 2; 5; 1; 55; 8; 45; 1; 96; 0] [46; 2; 22; 4; 4; 2; 6; 5; 88; 24; 7] [46; 2; 22; 4; 4; 2] [46; 2; 22] [46; 2] [] [46] [] [23] [] [12] [] [6] [] [3] [] [2] [] [1] [] [0] [] [46; 2; 22; 4; 4; 2; 6; 5; 88; 24; 7; 9; 9; 2; 5; 1; 55; 8; 45; 1; 96; 0; 1; 2; 7; 4; 1; 5; 95; 6; 8; 6; 4; 0; 5; 5; 22; 87; 2; 1; 1; 0; 2; 2; 9; 5; 9; 3; 7; 59; 7; 96; 6; 5; 1; 3; 9; 9; 65; 6; 7; 7; 2; 5; 0; 0; 70; 5; 5; 2; 1; 57; 9; 7; 8; 10; 9; 7; 9; 75; 73; 80; 7; 9; 4; 3; 16; 5; 79; 1; 8; 6; 2; 3; 4; 9; 2; 8; 4; 6; 50; 2; 1; 5; 9; 5; 4; 3; 56; 6; 5; 9; 4; 1; 47; 1; 2; 5; 2; 0; 7; 31; 55; 6; 7; 4; 7; 8; 8; 2; 4; 40; 4; 6; 9; 3; 59; 5; 1; 0; 2; 6; 90; 1; 6; 81; 0; 1; 3; 7; 2; 4; 5; 4; 7; 3; 62; 0; 1; 6; 7; 5; 97; 83; 41; 7; 2; 6; 3; 0; 4; 8; 99; 8; 6; 0; 7; 9; 7; 1; 55; 30; 25; 3; 4; 7; 1; 6; 80; 8; 0; 4; 21; 3; 5; 9; 27; 10; 60; 47; 54; 6; 5; 8; 1; 5; 9; 65; 9; 5; 7; 7; 6; 48; 9; 5; 6; 4; 9; 7; 1; 2; 71; 6; 9; 2; 7; 8; 14; 59; 71; 30; 7; 3; 5; 4; 6; 7; 3; 6; 9; 8; 2; 38; 6; 6; 7; 1; 5; 2; 43; 5; 2; 9; 3; 0; 3; 2; 7; 71; 26; 3; 9; 11; 5; 1; 5; 2; 53; 46; 4; 6; 7; 67; 1; 0; 34; 0; 48; 5; 5; 0; 7; 49; 92; 8; 3; 0; 67; 1; 5; 2; 9; 5; 9; 3; 1; 4; 8; 0; 3; 6; 46; 58; 1; 54; 77; 0; 96; 1; 6; 2; 8; 22; 3; 9; 2; 6; 25; 49; 9; 6; 3; 8; 5; 9; 54; 1; 7; 5; 6; 5; 1; 7; 8; 23; 4; 6; 4; 2; 5; 8; 4; 7; 4] [46; 2; 22; 4; 4; 2; 6; 5; 88; 24; 7; 9; 9; 2; 5; 1; 55; 8; 45; 1; 96; 0; 1; 2; 7; 4; 1; 5; 95; 6; 8; 6; 4; 0; 5; 5; 22; 87; 2; 1; 1; 0; 2; 2; 9; 5; 9; 3; 7; 59; 7; 96; 6; 5; 1; 3; 9; 9; 65; 6; 7; 7; 2; 5; 0; 0; 70; 5; 5; 2; 1; 57; 9; 7; 8; 10; 9; 7; 9; 75; 73; 80; 7; 9; 4; 3; 16; 5; 79; 1; 8; 6; 2; 3; 4; 9; 2; 8; 4; 6; 50; 2; 1; 5; 9; 5; 4; 3; 56; 6; 5; 9; 4; 1; 47; 1; 2; 5; 2; 0; 7; 31; 55; 6; 7; 4; 7; 8; 8; 2; 4; 40; 4; 6; 9; 3; 59; 5; 1; 0; 2; 6; 90; 1; 6; 81; 0; 1; 3; 7; 2; 4; 5; 4; 7; 3; 62; 0; 1; 6; 7; 5; 97; 83; 41; 7; 2; 6; 3; 0; 4; 8; 99] [46; 2; 22; 4; 4; 2; 6; 5; 88; 24; 7; 9; 9; 2; 5; 1; 55; 8; 45; 1; 96; 0; 1; 2; 7; 4; 1; 5; 95; 6; 8; 6; 4; 0; 5; 5; 22; 87; 2; 1; 1; 0; 2; 2; 9; 5; 9; 3; 7; 59; 7; 96; 6; 5; 1; 3; 9; 9; 65; 6; 7; 7; 2; 5; 0; 0; 70; 5; 5; 2; 1; 57; 9; 7; 8; 10; 9; 7; 9; 75; 73; 80; 7; 9; 4; 3; 16] [46; 2; 22; 4; 4; 2; 6; 5; 88; 24; 7; 9; 9; 2; 5; 1; 55; 8; 45; 1; 96; 0; 1; 2; 7; 4; 1; 5; 95; 6; 8; 6; 4; 0; 5; 5; 22; 87; 2; 1; 1; 0; 2; 2] [46; 2; 22; 4; 4; 2; 6; 5; 88; 24; 7; 9; 9; 2; 5; 1; 55; 8; 45; 1; 96; 0] [46; 2; 22; 4; 4; 2; 6; 5; 88; 24; 7] [46; 2; 22; 4; 4; 2] [46; 2; 22] [46; 2; 4; 4; 2] [46; 2; 4] [46; 2; 4; 2] [46; 2] [4; 2] [46; 4; 2] [2; 4; 2] [2; 4] [2] [2; 2] [] [2] [1; 2] [2; 1] --- Failure -------------------------------------------------------------------- Test should_fail_sort_id failed (10 shrink steps): [1; 0] --- Failure -------------------------------------------------------------------- Test max_fail failed (20 shrink steps): [0; 1] --- Failure -------------------------------------------------------------------- Test max_fail failed (14 shrink steps): [0; 1] --- Failure -------------------------------------------------------------------- Test max_fail failed (16 shrink steps): [1; 0] === Error ====================================================================== Test should_error_raise_exn errored on (30 shrink steps): 0 exception QCheck_tests.Overall.Error +++ Collect ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Collect results for test collect_results: 4: 24 cases 3: 20 cases 2: 18 cases 1: 21 cases 0: 17 cases +++ Stats for with_stats ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats mod4: num: 100, avg: 1.56, stddev: 1.18, median 2, min 0, max 3 0: ################################################# 27 1: #################################### 20 2: ########################################## 23 3: ####################################################### 30 stats num: num: 100, avg: 62.24, stddev: 33.15, median 62, min 2, max 120 2.. 7: ######### 2 8.. 13: ################################ 7 14.. 19: ########################### 6 20.. 25: ############# 3 26.. 31: ###################### 5 32.. 37: ################## 4 38.. 43: ############# 3 44.. 49: ################################ 7 50.. 55: ################################ 7 56.. 61: ###################### 5 62.. 67: #################################### 8 68.. 73: ######### 2 74.. 79: ###################### 5 80.. 85: ######### 2 86.. 91: ####################################################### 12 92.. 97: ###################### 5 98..103: ################## 4 104..109: ################## 4 110..115: ############# 3 116..121: ########################### 6 --- Failure -------------------------------------------------------------------- Test with shrinking retries failed (0 shrink steps): 4 !!! Warning !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Warning for test WARN_unlikely_precond: WARNING: only 0.5% tests (of 2000) passed precondition for "WARN_unlikely_precond" NOTE: it is likely that the precondition is too strong, or that the generator is buggy. --- Failure -------------------------------------------------------------------- Test FAIL_unlikely_precond failed: ERROR: only 0.5% tests (of 2000) passed precondition for "FAIL_unlikely_precond" NOTE: it is likely that the precondition is too strong, or that the generator is buggy. --- Failure -------------------------------------------------------------------- Test FAIL_bad_gen failed: ERROR: uncaught exception in generator for test FAIL_bad_gen after 100 steps: Exception: Invalid_argument("Gen.int_bound") Backtrace: --- Failure -------------------------------------------------------------------- Test int double failed: Negative test int double succeeded but was expected to fail === Error ====================================================================== Test pos fail with error errored on (7 shrink steps): 0 exception QCheck_tests.Overall.Error === Error ====================================================================== Test neg fail with error errored on (7 shrink steps): 0 exception QCheck_tests.Overall.Error --- Failure -------------------------------------------------------------------- Test char never produces '\255' failed (0 shrink steps): '\255' --- Failure -------------------------------------------------------------------- Test big bound issue59 failed (20 shrink steps): 209609 --- Failure -------------------------------------------------------------------- Test long_shrink failed (86 shrink steps): ([0], [-1]) --- Failure -------------------------------------------------------------------- Test ints arent 0 mod 3 failed (26 shrink steps): 2061 --- Failure -------------------------------------------------------------------- Test ints are 0 failed (29 shrink steps): -1 --- Failure -------------------------------------------------------------------- Test int32s arent 0l rem 3l failed (37 shrink steps): 21l --- Failure -------------------------------------------------------------------- Test int32s are 0l failed (31 shrink steps): 1l --- Failure -------------------------------------------------------------------- Test int64s arent 0L rem 3L failed (83 shrink steps): 705L --- Failure -------------------------------------------------------------------- Test int64s are 0L failed (63 shrink steps): 1L --- Failure -------------------------------------------------------------------- Test ints < 209609 failed (20 shrink steps): 209609 --- Failure -------------------------------------------------------------------- Test nat < 5001 failed (4 shrink steps): 5001 --- Failure -------------------------------------------------------------------- Test char never produces 'abcdef' failed (2 shrink steps): 'a' --- Failure -------------------------------------------------------------------- Test printable never produces '!"#$%&' failed (1 shrink steps): '&' --- Failure -------------------------------------------------------------------- Test printable never produces less than '5 failed (0 shrink steps): '0' --- Failure -------------------------------------------------------------------- Test bytes are empty failed (13 shrink steps): "a" --- Failure -------------------------------------------------------------------- Test bytes never has a \000 char failed (13 shrink steps): "\000" --- Failure -------------------------------------------------------------------- Test bytes never has a \255 char failed (15 shrink steps): "\255" --- Failure -------------------------------------------------------------------- Test bytes have unique chars failed (14 shrink steps): "\232\232" --- Failure -------------------------------------------------------------------- Test strings are empty failed (13 shrink steps): "a" --- Failure -------------------------------------------------------------------- Test string never has a \000 char failed (13 shrink steps): "\000" --- Failure -------------------------------------------------------------------- Test string never has a \255 char failed (15 shrink steps): "\255" --- Failure -------------------------------------------------------------------- Test strings have unique chars failed (14 shrink steps): "\232\232" --- Failure -------------------------------------------------------------------- Test pairs have different components failed (0 shrink steps): (6, 6) --- Failure -------------------------------------------------------------------- Test pairs have same components failed (59 shrink steps): (0, -1) --- Failure -------------------------------------------------------------------- Test pairs have a zero component failed (58 shrink steps): (-1, -1) --- Failure -------------------------------------------------------------------- Test pairs are (0,0) failed (59 shrink steps): (0, -1) --- Failure -------------------------------------------------------------------- Test pairs are ordered failed (169 shrink steps): (1, 0) --- Failure -------------------------------------------------------------------- Test pairs are ordered reversely failed (58 shrink steps): (0, 1) --- Failure -------------------------------------------------------------------- Test pairs sum to less than 128 failed (54 shrink steps): (0, 128) --- Failure -------------------------------------------------------------------- Test pairs lists rev concat failed (77 shrink steps): ([0], [1]) --- Failure -------------------------------------------------------------------- Test pairs lists no overlap failed (24 shrink steps): ([0], [0]) --- Failure -------------------------------------------------------------------- Test triples have pair-wise different components failed (4 shrink steps): (6, 6, 0) --- Failure -------------------------------------------------------------------- Test triples have same components failed (85 shrink steps): (0, -1, -2) --- Failure -------------------------------------------------------------------- Test triples are ordered failed (87 shrink steps): (0, 0, -1) --- Failure -------------------------------------------------------------------- Test triples are ordered reversely failed (89 shrink steps): (0, 0, 1) --- Failure -------------------------------------------------------------------- Test quadruples have pair-wise different components failed (7 shrink steps): (0, 5, 5, 0) --- Failure -------------------------------------------------------------------- Test quadruples have same components failed (117 shrink steps): (0, 1, 0, -1) --- Failure -------------------------------------------------------------------- Test quadruples are ordered failed (118 shrink steps): (0, 0, 0, -1) --- Failure -------------------------------------------------------------------- Test quadruples are ordered reversely failed (120 shrink steps): (0, 0, 0, 1) --- Failure -------------------------------------------------------------------- Test forall (a, b) in nat: a < b failed (5 shrink steps): (0, 0) --- Failure -------------------------------------------------------------------- Test forall (a, b, c) in nat: a < b < c failed (14 shrink steps): (0, 0, 0) --- Failure -------------------------------------------------------------------- Test forall (a, b, c, d) in nat: a < b < c < d failed (17 shrink steps): (0, 0, 0, 0) --- Failure -------------------------------------------------------------------- Test forall (a, b, c, d, e) in nat: a < b < c < d < e failed (21 shrink steps): (0, 0, 0, 0, 0) --- Failure -------------------------------------------------------------------- Test forall (a, b, c, d, e, f) in nat: a < b < c < d < e < f failed (25 shrink steps): (0, 0, 0, 0, 0, 0) --- Failure -------------------------------------------------------------------- Test forall (a, b, c, d, e, f, g) in nat: a < b < c < d < e < f < g failed (27 shrink steps): (0, 0, 0, 0, 0, 0, 0) --- Failure -------------------------------------------------------------------- Test forall (a, b, c, d, e, f, g, h) in nat: a < b < c < d < e < f < g < h failed (30 shrink steps): (0, 0, 0, 0, 0, 0, 0, 0) --- Failure -------------------------------------------------------------------- Test forall (a, b, c, d, e, f, g, h, i) in nat: a < b < c < d < e < f < g < h < i failed (34 shrink steps): (0, 0, 0, 0, 0, 0, 0, 0, 0) --- Failure -------------------------------------------------------------------- Test bind ordered pairs failed (53 shrink steps): (0, 0) --- Failure -------------------------------------------------------------------- Test bind list_size constant failed (52 shrink steps): (4, [0; 0; 0; 0]) --- Failure -------------------------------------------------------------------- Test lists are empty failed (16 shrink steps): [0] --- Failure -------------------------------------------------------------------- Test lists shorter than 10 failed (49 shrink steps): [0; 0; 0; 0; 0; 0; 0; 0; 0; 0] --- Failure -------------------------------------------------------------------- Test lists shorter than 432 failed (1738 shrink steps): [...] list length: 432 --- Failure -------------------------------------------------------------------- Test lists shorter than 4332 failed (11 shrink steps): [...] list length: 4332 --- Failure -------------------------------------------------------------------- Test lists have unique elems failed (10 shrink steps): [2; 2] --- Failure -------------------------------------------------------------------- Test int option are none failed (11 shrink steps): Some (0) --- Failure -------------------------------------------------------------------- Test int option are some 100 or more failed (0 shrink steps): None --- Failure -------------------------------------------------------------------- Test (int,string) result are Ok failed (3 shrink steps): Error ("") --- Failure -------------------------------------------------------------------- Test (int,string) result are Error failed (11 shrink steps): Ok (0) --- Failure -------------------------------------------------------------------- Test tree contains only 42 failed (9 shrink steps): Leaf 0 --- Failure -------------------------------------------------------------------- Test sum list = 0 failed (0 shrink steps): [46; 2; 22; 4; 4; 2; 6; 5; 88; 24; 7; 9; 9; 2; 5; 1; 55; 8; 45; 1; 96; 0; 1; 2; 7; 4; 1; 5; 95; 6; 8; 6; 4; 0; 5; 5; 22; 87; 2; 1; 1; 0; 2; 2; 9; 5; 9; 3; 7; 59; 7; 96; 6; 5; 1; 3; 9; 9; 65; 6; 7; 7; 2; 5; 0; 0; 70; 5; 5; 2; 1; 57; 9; 7; 8; 10; 9; 7; 9; 75; 73; 80; 7; 9; 4; 3; 16; 5; 79; 1; 8; 6; 2; 3; 4; 9; 2; 8; 4; 6; 50; 2; 1; 5; 9; 5; 4; 3; 56; 6; 5; 9; 4; 1; 47; 1; 2; 5; 2; 0; 7; 31; 55; 6; 7; 4; 7; 8; 8; 2; 4; 40; 4; 6; 9; 3; 59; 5; 1; 0; 2; 6; 90; 1; 6; 81; 0; 1; 3; 7; 2; 4; 5; 4; 7; 3; 62; 0; 1; 6; 7; 5; 97; 83; 41; 7; 2; 6; 3; 0; 4; 8; 99; 8; 6; 0; 7; 9; 7; 1; 55; 30; 25; 3; 4; 7; 1; 6; 80; 8; 0; 4; 21; 3; 5; 9; 27; 10; 60; 47; 54; 6; 5; 8; 1; 5; 9; 65; 9; 5; 7; 7; 6; 48; 9; 5; 6; 4; 9; 7; 1; 2; 71; 6; 9; 2; 7; 8; 14; 59; 71; 30; 7; 3; 5; 4; 6; 7; 3; 6; 9; 8; 2; 38; 6; 6; 7; 1; 5; 2; 43; 5; 2; 9; 3; 0; 3; 2; 7; 71; 26; 3; 9; 11; 5; 1; 5; 2; 53; 46; 4; 6; 7; 67; 1; 0; 34; 0; 48; 5; 5; 0; 7; 49; 92; 8; 3; 0; 67; 1; 5; 2; 9; 5; 9; 3; 1; 4; 8; 0; 3; 6; 46; 58; 1; 54; 77; 0; 96; 1; 6; 2; 8; 22; 3; 9; 2; 6; 25; 49; 9; 6; 3; 8; 5; 9; 54; 1; 7; 5; 6; 5; 1; 7; 8; 23; 4; 6; 4; 2; 5; 8; 4; 7; 4] --- Failure -------------------------------------------------------------------- Test fail_pred_map_commute_int failed (47 shrink steps): ([1], {_ -> 0}, {1 -> true; _ -> false}) --- Failure -------------------------------------------------------------------- Test fail_pred_map_commute_int32 failed (110 shrink steps): ([-1l], {_ -> 0l}, {-1l -> true; _ -> false}) --- Failure -------------------------------------------------------------------- Test fail_pred_map_commute_int64 failed (185 shrink steps): ([6L], {_ -> 0L}, {6L -> true; _ -> false}) --- Failure -------------------------------------------------------------------- Test fail_pred_strings failed (2 shrink steps): {"some random string" -> true; _ -> false} --- Failure -------------------------------------------------------------------- Test fold_left fold_right failed (21 shrink steps): (0, [1], {(0, 1) -> 1; _ -> 0}) +++ Messages ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Messages for test fold_left fold_right: l=[1], fold_left=0, fold_right=1 --- Failure -------------------------------------------------------------------- Test fold_left fold_right uncurried failed (41 shrink steps): ({(0, 4) -> 1; _ -> 0}, 0, [4]) --- Failure -------------------------------------------------------------------- Test fold_left fold_right uncurried fun last failed (25 shrink steps): (0, [1], {(0, 1) -> 1; _ -> 0}) --- Failure -------------------------------------------------------------------- Test fold_left test, fun first failed (66 shrink steps): ({("", 2) -> "a"; _ -> ""}, "", [], [2]) --- Failure -------------------------------------------------------------------- Test FAIL_#99_1 failed: ERROR: uncaught exception in generator for test FAIL_#99_1 after 100 steps: Exception: QCheck.No_example_found("") Backtrace: +++ Collect ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Collect results for test bool dist: true: 250511 cases false: 249489 cases +++ Stats for char code dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats char code: num: 500000, avg: 127.68, stddev: 73.87, median 128, min 0, max 255 0.. 12: ##################################################### 25272 13.. 25: ###################################################### 25326 26.. 38: ##################################################### 25194 39.. 51: ###################################################### 25359 52.. 64: ###################################################### 25338 65.. 77: ###################################################### 25349 78.. 90: ###################################################### 25397 91..103: ##################################################### 25243 104..116: ###################################################### 25420 117..129: ###################################################### 25438 130..142: ###################################################### 25346 143..155: ##################################################### 25177 156..168: ####################################################### 25755 169..181: ###################################################### 25408 182..194: ###################################################### 25633 195..207: ###################################################### 25613 208..220: ###################################################### 25459 221..233: ###################################################### 25322 234..246: ##################################################### 25229 247..259: ##################################### 17722 +++ Stats for printable char code dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats char code: num: 500000, avg: 77.76, stddev: 27.87, median 78, min 10, max 125 10.. 15: ######### 5255 16.. 21: 0 22.. 27: 0 28.. 33: ################# 10417 34.. 39: ###################################################### 31730 40.. 45: ###################################################### 31499 46.. 51: ###################################################### 31657 52.. 57: ###################################################### 31704 58.. 63: ###################################################### 31502 64.. 69: ###################################################### 31643 70.. 75: ###################################################### 31630 76.. 81: ###################################################### 31481 82.. 87: ###################################################### 31594 88.. 93: ###################################################### 31817 94.. 99: ###################################################### 31536 100..105: ###################################################### 31528 106..111: ###################################################### 31467 112..117: ##################################################### 31246 118..123: ####################################################### 31861 124..129: ################## 10433 +++ Stats for numeral char code dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats char code: num: 500000, avg: 52.50, stddev: 2.87, median 53, min 48, max 57 48: ###################################################### 49848 49: ###################################################### 50118 50: ###################################################### 49837 51: ###################################################### 50252 52: ###################################################### 49765 53: ####################################################### 50369 54: ###################################################### 50270 55: ###################################################### 49885 56: ###################################################### 49821 57: ###################################################### 49835 +++ Stats for tree's depth ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats depth: num: 1000, avg: 4.13, stddev: 3.52, median 3, min 1, max 15 1: ####################################################### 339 2: ################ 104 3: ############### 98 4: ##################### 133 5: ######### 60 6: #### 29 7: ######## 54 8: ####### 48 9: ## 16 10: ### 21 11: ########### 68 12: 1 13: # 8 14: ## 16 15: 5 +++ Stats for range_subset_spec ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 5000, avg: 9.99, stddev: 6.01, median 10, min 0, max 20 0: ############################################### 231 1: ############################################## 223 2: ##################################################### 258 3: ################################################ 233 4: ############################################### 228 5: ############################################### 231 6: #################################################### 254 7: ############################################### 228 8: #################################################### 254 9: ####################################################### 266 10: ############################################## 224 11: ################################################## 245 12: ############################################### 230 13: #################################################### 253 14: ############################################## 223 15: ################################################# 239 16: ################################################## 243 17: ################################################## 245 18: ############################################# 220 19: ################################################## 242 20: ############################################### 230 +++ Stats for bytes_size len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 7.51, stddev: 1.69, median 8, min 5, max 10 5: ################################################## 817 6: ################################################# 797 7: ####################################################### 885 8: ################################################### 834 9: ###################################################### 877 10: ################################################# 790 +++ Stats for bytes len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 370.05, stddev: 1282.91, median 9, min 0, max 9947 0.. 497: ####################################################### 4270 498.. 995: ###### 497 996..1493: 17 1494..1991: 9 1992..2489: 13 2490..2987: 13 2988..3485: 9 3486..3983: 14 3984..4481: 14 4482..4979: 17 4980..5477: 9 5478..5975: 10 5976..6473: 15 6474..6971: 16 6972..7469: 16 7470..7967: 9 7968..8465: 12 8466..8963: 15 8964..9461: 9 9462..9959: 16 +++ Stats for bytes_of len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 359.22, stddev: 1249.46, median 9, min 0, max 9958 0.. 497: ####################################################### 4275 498.. 995: ###### 479 996..1493: 22 1494..1991: 12 1992..2489: 21 2490..2987: 16 2988..3485: 13 3486..3983: 17 3984..4481: 14 4482..4979: 14 4980..5477: 8 5478..5975: 14 5976..6473: 13 6474..6971: 9 6972..7469: 7 7470..7967: 17 7968..8465: 13 8466..8963: 15 8964..9461: 10 9462..9959: 11 +++ Stats for bytes_small len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 15.99, stddev: 24.58, median 6, min 0, max 99 0.. 4: ###################################################### 1920 5.. 9: ####################################################### 1929 10.. 14: # 69 15.. 19: # 62 20.. 24: # 63 25.. 29: # 59 30.. 34: # 68 35.. 39: # 62 40.. 44: # 57 45.. 49: ## 83 50.. 54: # 59 55.. 59: ## 80 60.. 64: # 48 65.. 69: # 53 70.. 74: # 61 75.. 79: # 66 80.. 84: # 61 85.. 89: ## 72 90.. 94: # 66 95.. 99: # 62 +++ Stats for string_size len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 7.51, stddev: 1.69, median 8, min 5, max 10 5: ################################################## 817 6: ################################################# 797 7: ####################################################### 885 8: ################################################### 834 9: ###################################################### 877 10: ################################################# 790 +++ Stats for string len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 370.05, stddev: 1282.91, median 9, min 0, max 9947 0.. 497: ####################################################### 4270 498.. 995: ###### 497 996..1493: 17 1494..1991: 9 1992..2489: 13 2490..2987: 13 2988..3485: 9 3486..3983: 14 3984..4481: 14 4482..4979: 17 4980..5477: 9 5478..5975: 10 5976..6473: 15 6474..6971: 16 6972..7469: 16 7470..7967: 9 7968..8465: 12 8466..8963: 15 8964..9461: 9 9462..9959: 16 +++ Stats for string_of len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 359.22, stddev: 1249.46, median 9, min 0, max 9958 0.. 497: ####################################################### 4275 498.. 995: ###### 479 996..1493: 22 1494..1991: 12 1992..2489: 21 2490..2987: 16 2988..3485: 13 3486..3983: 17 3984..4481: 14 4482..4979: 14 4980..5477: 8 5478..5975: 14 5976..6473: 13 6474..6971: 9 6972..7469: 7 7470..7967: 17 7968..8465: 13 8466..8963: 15 8964..9461: 10 9462..9959: 11 +++ Stats for printable_string len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 370.05, stddev: 1282.91, median 9, min 0, max 9947 0.. 497: ####################################################### 4270 498.. 995: ###### 497 996..1493: 17 1494..1991: 9 1992..2489: 13 2490..2987: 13 2988..3485: 9 3486..3983: 14 3984..4481: 14 4482..4979: 17 4980..5477: 9 5478..5975: 10 5976..6473: 15 6474..6971: 16 6972..7469: 16 7470..7967: 9 7968..8465: 12 8466..8963: 15 8964..9461: 9 9462..9959: 16 +++ Stats for small_string len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 15.99, stddev: 24.58, median 6, min 0, max 99 0.. 4: ###################################################### 1920 5.. 9: ####################################################### 1929 10.. 14: # 69 15.. 19: # 62 20.. 24: # 63 25.. 29: # 59 30.. 34: # 68 35.. 39: # 62 40.. 44: # 57 45.. 49: ## 83 50.. 54: # 59 55.. 59: ## 80 60.. 64: # 48 65.. 69: # 53 70.. 74: # 61 75.. 79: # 66 80.. 84: # 61 85.. 89: ## 72 90.. 94: # 66 95.. 99: # 62 +++ Stats for pair dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats pair sum: num: 500000, avg: 100.05, stddev: 41.29, median 100, min 0, max 200 0.. 9: ### 2618 10.. 19: ######## 7630 20.. 29: ############## 12505 30.. 39: #################### 17451 40.. 49: ########################## 22280 50.. 59: ############################### 27307 60.. 69: ##################################### 32151 70.. 79: ########################################### 37199 80.. 89: ################################################# 41901 90.. 99: ###################################################### 46313 100..109: ####################################################### 46965 110..119: ################################################# 42462 120..129: ########################################### 37348 130..139: ###################################### 32613 140..149: ################################ 27606 150..159: ########################### 23221 160..169: ##################### 18125 170..179: ############### 12890 180..189: ######### 8059 190..199: ### 3297 200..209: 59 +++ Stats for triple dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats triple sum: num: 500000, avg: 150.04, stddev: 50.53, median 150, min 1, max 300 1.. 15: 360 16.. 30: ## 2261 31.. 45: ##### 5712 46.. 60: ########## 10854 61.. 75: ################# 17760 76.. 90: ########################## 26151 91..105: ################################### 36079 106..120: ############################################# 45498 121..135: ################################################### 51977 136..150: ####################################################### 55179 151..165: ###################################################### 54821 166..180: ################################################### 51709 181..195: ############################################# 45166 196..210: ################################### 35354 211..225: ######################### 25436 226..240: ################# 17179 241..255: ########## 10652 256..270: ##### 5447 271..285: ## 2065 286..300: 340 +++ Stats for quad dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats quad sum: num: 500000, avg: 200.06, stddev: 58.39, median 200, min 2, max 394 2.. 21: 61 22.. 41: 658 42.. 61: ## 2534 62.. 81: ##### 6444 82..101: ########### 13334 102..121: ################### 23279 122..141: ############################## 35888 142..161: ######################################### 48824 162..181: ################################################## 59008 182..201: ####################################################### 64896 202..221: ###################################################### 64051 222..241: ################################################# 57864 242..261: ####################################### 46793 262..281: ############################ 33955 282..301: ################## 21775 302..321: ########## 12187 322..341: #### 5645 342..361: # 2244 362..381: 529 382..401: 31 +++ Stats for bind dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats ordered pair difference: num: 1000000, avg: 25.01, stddev: 22.38, median 19, min 0, max 100 0.. 4: ####################################################### 193610 5.. 9: #################################### 130051 10.. 14: ############################# 104209 15.. 19: ######################## 86993 20.. 24: ##################### 74295 25.. 29: ################## 64874 30.. 34: ################ 56447 35.. 39: ############## 49416 40.. 44: ############ 43051 45.. 49: ########## 37580 50.. 54: ######### 32378 55.. 59: ######## 28558 60.. 64: ###### 23971 65.. 69: ##### 20146 70.. 74: #### 16446 75.. 79: ### 13215 80.. 84: ## 10294 85.. 89: ## 7639 90.. 94: # 4698 95.. 99: 2041 100..104: 88 stats ordered pair sum: num: 1000000, avg: 74.97, stddev: 46.86, median 72, min 0, max 200 0.. 9: ####################################################### 70320 10.. 19: ##################################################### 68731 20.. 29: ##################################################### 68374 30.. 39: ##################################################### 68544 40.. 49: ##################################################### 68756 50.. 59: ##################################################### 68837 60.. 69: ##################################################### 68759 70.. 79: ##################################################### 68517 80.. 89: ##################################################### 68692 90.. 99: ###################################################### 69123 100..109: ################################################## 64777 110..119: ########################################### 55288 120..129: #################################### 47156 130..139: ############################### 39635 140..149: ######################### 32590 150..159: #################### 25685 160..169: ############### 19842 170..179: ########## 14038 180..189: ###### 8631 190..199: ## 3580 200..209: 125 +++ Collect ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Collect results for test option dist: None : 1492 cases Some _: 8508 cases +++ Collect ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Collect results for test result dist: Error _: 2439 cases Ok _ : 7561 cases +++ Stats for list len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 374.46, stddev: 1320.15, median 9, min 0, max 9984 0.. 499: ####################################################### 4269 500.. 999: ###### 503 1000.. 1499: 13 1500.. 1999: 6 2000.. 2499: 22 2500.. 2999: 13 3000.. 3499: 10 3500.. 3999: 5 4000.. 4499: 15 4500.. 4999: 10 5000.. 5499: 15 5500.. 5999: 12 6000.. 6499: 6 6500.. 6999: 12 7000.. 7499: 11 7500.. 7999: 15 8000.. 8499: 21 8500.. 8999: 11 9000.. 9499: 15 9500.. 9999: 16 +++ Stats for small_list len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 15.36, stddev: 23.76, median 6, min 0, max 99 0.. 4: ###################################################### 1933 5.. 9: ####################################################### 1962 10.. 14: # 69 15.. 19: # 57 20.. 24: # 51 25.. 29: # 62 30.. 34: # 63 35.. 39: # 65 40.. 44: ## 77 45.. 49: # 71 50.. 54: # 56 55.. 59: # 60 60.. 64: # 66 65.. 69: # 65 70.. 74: # 69 75.. 79: # 48 80.. 84: # 53 85.. 89: # 58 90.. 94: # 64 95.. 99: # 51 +++ Stats for list_of_size len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 7.50, stddev: 1.71, median 8, min 5, max 10 5: ###################################################### 853 6: #################################################### 819 7: #################################################### 820 8: #################################################### 825 9: ####################################################### 857 10: ##################################################### 826 +++ Stats for list_repeat len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 42.00, stddev: 0.00, median 42, min 42, max 42 42: ####################################################### 5000 +++ Stats for array len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 374.46, stddev: 1320.15, median 9, min 0, max 9984 0.. 499: ####################################################### 4269 500.. 999: ###### 503 1000.. 1499: 13 1500.. 1999: 6 2000.. 2499: 22 2500.. 2999: 13 3000.. 3499: 10 3500.. 3999: 5 4000.. 4499: 15 4500.. 4999: 10 5000.. 5499: 15 5500.. 5999: 12 6000.. 6499: 6 6500.. 6999: 12 7000.. 7499: 11 7500.. 7999: 15 8000.. 8499: 21 8500.. 8999: 11 9000.. 9499: 15 9500.. 9999: 16 +++ Stats for small_array len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 15.36, stddev: 23.76, median 6, min 0, max 99 0.. 4: ###################################################### 1933 5.. 9: ####################################################### 1962 10.. 14: # 69 15.. 19: # 57 20.. 24: # 51 25.. 29: # 62 30.. 34: # 63 35.. 39: # 65 40.. 44: ## 77 45.. 49: # 71 50.. 54: # 56 55.. 59: # 60 60.. 64: # 66 65.. 69: # 65 70.. 74: # 69 75.. 79: # 48 80.. 84: # 53 85.. 89: # 58 90.. 94: # 64 95.. 99: # 51 +++ Stats for array_of_size len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 7.50, stddev: 1.71, median 8, min 5, max 10 5: ###################################################### 853 6: #################################################### 819 7: #################################################### 820 8: #################################################### 825 9: ####################################################### 857 10: ##################################################### 826 +++ Stats for array_repeat len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 42.00, stddev: 0.00, median 42, min 42, max 42 42: ####################################################### 5000 +++ Stats for int_stats_neg ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 5000, avg: 0.43, stddev: 28.63, median 0, min -99, max 99 -99..-90: # 45 -89..-80: # 57 -79..-70: # 68 -69..-60: # 58 -59..-50: # 76 -49..-40: # 67 -39..-30: # 52 -29..-20: # 54 -19..-10: # 47 -9.. 0: ####################################################### 2205 1.. 10: ########################################## 1697 11.. 20: # 57 21.. 30: # 70 31.. 40: # 60 41.. 50: # 66 51.. 60: # 75 61.. 70: # 68 71.. 80: # 63 81.. 90: # 66 91..100: # 49 +++ Stats for small_signed_int dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 0.86, stddev: 29.11, median 0, min -97, max 99 -97..-88: # 12 -87..-78: # 12 -77..-68: # 13 -67..-58: # 12 -57..-48: # 9 -47..-38: ## 17 -37..-28: # 13 -27..-18: # 8 -17.. -8: ######### 76 -7.. 2: ####################################################### 437 3.. 12: ################################## 276 13.. 22: ## 16 23.. 32: # 11 33.. 42: ## 16 43.. 52: # 9 53.. 62: # 12 63.. 72: # 14 73.. 82: # 12 83.. 92: # 13 93..102: # 12 +++ Stats for small_nat dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 15.86, stddev: 24.57, median 6, min 0, max 99 0.. 4: ###################################################### 387 5.. 9: ####################################################### 390 10.. 14: # 11 15.. 19: # 8 20.. 24: # 11 25.. 29: ## 15 30.. 34: # 9 35.. 39: # 11 40.. 44: # 11 45.. 49: ## 19 50.. 54: # 10 55.. 59: ## 19 60.. 64: # 9 65.. 69: # 9 70.. 74: ## 19 75.. 79: # 13 80.. 84: # 11 85.. 89: ## 16 90.. 94: # 9 95.. 99: # 13 +++ Stats for nat dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 382.03, stddev: 1290.55, median 9, min 0, max 9890 0.. 494: ####################################################### 850 495.. 989: ###### 93 990..1484: 8 1485..1979: 3 1980..2474: 7 2475..2969: 1 2970..3464: 3 3465..3959: 3 3960..4454: 3 4455..4949: 4 4950..5444: 3 5445..5939: 3 5940..6434: 3 6435..6929: 1 6930..7424: 2 7425..7919: 1 7920..8414: 1 8415..8909: 5 8910..9404: 3 9405..9899: 3 +++ Stats for int_range (-43643) 435434 dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 193479.13, stddev: 136696.70, median 189823, min -43164, max 434961 -43164..-19258: ################################### 42 -19257.. 4649: ############################################## 56 4650.. 28556: ############################################# 55 28557.. 52463: ############################################### 57 52464.. 76370: ######################################### 50 76371..100277: ############################# 35 100278..124184: ############################################### 57 124185..148091: #################################### 44 148092..171998: ############################################## 56 171999..195905: ####################################################### 66 195906..219812: ########################################### 52 219813..243719: ######################################## 49 243720..267626: ################################ 39 267627..291533: ##################################### 45 291534..315440: ##################################### 45 315441..339347: ################################################# 59 339348..363254: ################################################## 60 363255..387161: ################################# 40 387162..411068: ########################################## 51 411069..434975: ################################### 42 +++ Stats for int_range (-40000) 40000 dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: -591.06, stddev: 23026.79, median -911, min -39911, max 39959 -39911..-35918: ####################################### 45 -35917..-31924: #################################################### 59 -31923..-27930: ########################################### 49 -27929..-23936: ########################################## 48 -23935..-19942: ####################################################### 62 -19941..-15948: ############################################# 51 -15947..-11954: ######################################### 47 -11953.. -7960: ################################################# 56 -7959.. -3966: ################################### 40 -3965.. 28: ################################################### 58 29.. 4022: ########################################### 49 4023.. 8016: ############################################### 53 8017.. 12010: ############################################ 50 12011.. 16004: ################################### 40 16005.. 19998: ####################################### 44 19999.. 23992: ####################################################### 62 23993.. 27986: ##################################### 42 27987.. 31980: ######################################### 47 31981.. 35974: ########################################## 48 35975.. 39968: ############################################ 50 +++ Stats for int_range (-4) 4 dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: -0.12, stddev: 2.52, median 0, min -4, max 4 -4: ########################################## 116 -3: ###################################### 103 -2: ############################################## 125 -1: ########################################## 115 0: ####################################### 106 1: ####################################################### 149 2: ################################# 92 3: ################################# 92 4: ##################################### 102 +++ Stats for int_range (-4) 17 dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 6.42, stddev: 6.43, median 6, min -4, max 17 -4..-3: ########################################### 89 -2..-1: ################################################# 101 0.. 1: ############################################## 95 2.. 3: ########################################### 89 4.. 5: ############################################## 95 6.. 7: ##################################### 78 8.. 9: ####################################### 81 10..11: ######################################## 84 12..13: ####################################################### 113 14..15: ######################################## 84 16..17: ############################################ 91 18..19: 0 20..21: 0 22..23: 0 24..25: 0 26..27: 0 28..29: 0 30..31: 0 32..33: 0 34..35: 0 +++ Stats for int dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 100000, avg: -2481754.31, stddev: 6.184e+8, median -5669677, min -1073719962, max 1073717275 -1073719962.. -966348101: ##################################################### 4978 -966348100.. -858976239: ##################################################### 5008 -858976238.. -751604377: #################################################### 4907 -751604376.. -644232515: ###################################################### 5037 -644232514.. -536860653: ###################################################### 5069 -536860652.. -429488791: ###################################################### 5052 -429488790.. -322116929: ###################################################### 5035 -322116928.. -214745067: ####################################################### 5128 -214745066.. -107373205: ##################################################### 5017 -107373204.. -1343: ##################################################### 5021 -1342.. 107370519: ##################################################### 5010 107370520.. 214742381: ##################################################### 4964 214742382.. 322114243: ##################################################### 4957 322114244.. 429486105: ##################################################### 4994 429486106.. 536857967: ##################################################### 5025 536857968.. 644229829: ###################################################### 5047 644229830.. 751601691: ##################################################### 4988 751601692.. 858973553: #################################################### 4924 858973554.. 966345415: #################################################### 4852 966345416.. 1073717277: ##################################################### 4987 +++ Stats for oneof int dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 1073741.60, stddev: 6.731e+8, median 0, min -1073741824, max 1073741823 -1073741824.. -966367642: ################# 198 -966367641.. -858993459: 0 -858993458.. -751619276: 0 -751619275.. -644245093: 0 -644245092.. -536870910: 0 -536870909.. -429496727: 0 -429496726.. -322122544: 0 -322122543.. -214748361: 0 -214748360.. -107374178: 0 -107374177.. 5: ####################################################### 607 6.. 107374188: 0 107374189.. 214748371: 0 214748372.. 322122554: 0 322122555.. 429496737: 0 429496738.. 536870920: 0 536870921.. 644245103: 0 644245104.. 751619286: 0 751619287.. 858993469: 0 858993470.. 966367652: 0 966367653.. 1073741823: ################# 195 +++ Stats for int32 lower dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 10000, avg: 32719.66, stddev: 18976.66, median 32730, min 9, max 65532 9.. 3285: ################################################### 506 3286.. 6562: #################################################### 508 6563.. 9839: ################################################# 481 9840..13116: ################################################### 506 13117..16393: #################################################### 517 16394..19670: #################################################### 512 19671..22947: ################################################## 496 22948..26224: #################################################### 510 26225..29501: ################################################# 486 29502..32778: ################################################## 491 32779..36055: ################################################## 495 36056..39332: ################################################## 489 39333..42609: ################################################## 493 42610..45886: ####################################################### 537 45887..49163: ################################################## 497 49164..52440: ################################################# 479 52441..55717: ################################################## 493 55718..58994: ################################################## 494 58995..62271: ################################################# 481 62272..65548: ###################################################### 529 +++ Stats for int32 upper dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 10000, avg: 32555.02, stddev: 18918.49, median 32323, min 3, max 65534 3.. 3279: ###################################################### 547 3280.. 6556: ################################################ 482 6557.. 9833: ############################################### 473 9834..13110: ################################################## 509 13111..16387: ################################################## 507 16388..19664: ################################################## 507 19665..22941: ################################################ 482 22942..26218: ##################################################### 536 26219..29495: ####################################################### 550 29496..32772: ############################################## 468 32773..36049: #################################################### 528 36050..39326: ################################################ 488 39327..42603: ################################################ 483 42604..45880: ################################################ 489 45881..49157: ############################################# 450 49158..52434: ################################################ 483 52435..55711: ###################################################### 548 55712..58988: ################################################ 489 58989..62265: ################################################# 498 62266..65542: ################################################ 483 +++ Stats for int64 lower dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 10000, avg: 32452.50, stddev: 18981.40, median 32331, min 22, max 65532 22.. 3297: ##################################################### 533 3298.. 6573: ##################################################### 528 6574.. 9849: ################################################### 510 9850..13125: ################################################### 506 13126..16401: ################################################ 476 16402..19677: ################################################# 489 19678..22953: ####################################################### 543 22954..26229: ################################################# 486 26230..29505: ################################################## 501 29506..32781: ################################################## 501 32782..36057: ################################################### 505 36058..39333: ############################################## 463 39334..42609: ################################################## 498 42610..45885: #################################################### 517 45886..49161: ################################################### 510 49162..52437: ############################################### 471 52438..55713: ################################################## 497 55714..58989: ################################################## 494 58990..62265: ############################################# 454 62266..65541: #################################################### 518 +++ Stats for int64 lower-mid dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 10000, avg: 32748.75, stddev: 18818.12, median 32802, min 3, max 65533 3.. 3279: ################################################### 500 3280.. 6556: ################################################### 506 6557.. 9833: ############################################### 464 9834..13110: ################################################### 502 13111..16387: ################################################## 496 16388..19664: #################################################### 513 19665..22941: ################################################## 490 22942..26218: ####################################################### 538 26219..29495: ##################################################### 524 29496..32772: ############################################### 462 32773..36049: ################################################## 494 36050..39326: ##################################################### 523 39327..42603: ################################################### 504 42604..45880: ##################################################### 525 45881..49157: ################################################ 477 49158..52434: ################################################# 487 52435..55711: ##################################################### 527 55712..58988: #################################################### 509 58989..62265: ################################################ 470 62266..65542: ################################################# 489 +++ Stats for int64 upper-mid dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 10000, avg: 32869.52, stddev: 18881.85, median 33046, min 9, max 65529 9.. 3284: ################################################## 489 3285.. 6560: ################################################# 486 6561.. 9836: ################################################### 504 9837..13112: ################################################## 492 13113..16388: ###################################################### 528 16389..19664: ################################################## 494 19665..22940: ############################################### 461 22941..26216: ###################################################### 533 26217..29492: ################################################## 489 29493..32768: ################################################# 486 32769..36044: ################################################## 495 36045..39320: ##################################################### 518 39321..42596: ################################################### 504 42597..45872: ####################################################### 535 45873..49148: ################################################ 472 49149..52424: #################################################### 513 52425..55700: ################################################### 499 55701..58976: ##################################################### 517 58977..62252: #################################################### 508 62253..65528: ################################################ 476 65529..68804: 1 +++ Stats for int64 upper dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 10000, avg: 32499.47, stddev: 18881.21, median 32265, min 5, max 65534 5.. 3281: ###################################################### 547 3282.. 6558: ################################################ 484 6559.. 9835: ############################################# 460 9836..13112: ################################################## 505 13113..16389: ##################################################### 536 16390..19666: ################################################# 496 19667..22943: ################################################ 492 22944..26220: ################################################# 502 26221..29497: ##################################################### 540 29498..32774: ################################################## 508 32775..36051: ####################################################### 554 36052..39328: ################################################ 491 39329..42605: ################################################# 498 42606..45882: ############################################## 467 45883..49159: ############################################ 447 49160..52436: ############################################### 475 52437..55713: ################################################## 508 55714..58990: ################################################### 515 58991..62267: ################################################# 499 62268..65544: ############################################### 476 +++ Stats for exponential 10. dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 5000, avg: 9.45, stddev: 9.82, median 6, min 0, max 79 0.. 3: ####################################################### 1631 4.. 7: ##################################### 1109 8..11: ######################### 747 12..15: ################# 512 16..19: ########## 308 20..23: ######## 251 24..27: ##### 165 28..31: ## 85 32..35: ## 64 36..39: # 43 40..43: 25 44..47: 20 48..51: 20 52..55: 3 56..59: 8 60..63: 3 64..67: 1 68..71: 2 72..75: 2 76..79: 1 +++ Stats for exponential -10. dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 5000, avg: -9.45, stddev: 9.82, median -6, min -79, max 0 -79..-76: 1 -75..-72: 2 -71..-68: 2 -67..-64: 1 -63..-60: 3 -59..-56: 8 -55..-52: 3 -51..-48: 20 -47..-44: 20 -43..-40: 25 -39..-36: # 43 -35..-32: ## 64 -31..-28: ## 85 -27..-24: ##### 165 -23..-20: ######## 251 -19..-16: ########## 308 -15..-12: ################# 512 -11.. -8: ######################### 747 -7.. -4: ##################################### 1109 -3.. 0: ####################################################### 1631 ================================================================================ 1 warning(s) failure (75 tests failed, 3 tests errored, ran 175 tests) random seed: 153870556 +++ Stats for int_dist_empty_bucket ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: -2.059e+7, stddev: 4.272e+8, median 8, min -1072292884, max 1073741823 -1072292884.. -964991149: ## 26 -964991148.. -857689413: ### 31 -857689412.. -750387677: ## 22 -750387676.. -643085941: ## 22 -643085940.. -535784205: ## 27 -535784204.. -428482469: ### 30 -428482468.. -321180733: ## 29 -321180732.. -213878997: ## 20 -213878996.. -106577261: ## 20 -106577260.. 724475: ####################################################### 543 724476.. 108026211: ## 22 108026212.. 215327947: ## 22 215327948.. 322629683: ### 32 322629684.. 429931419: ## 29 429931420.. 537233155: ## 20 537233156.. 644534891: ## 21 644534892.. 751836627: ## 20 751836628.. 859138363: ## 22 859138364.. 966440099: ## 24 966440100.. 1073741823: # 18 ================================================================================ success (ran 1 tests) qcheck-0.25/test/core/QCheck_expect_test.expected.ocaml5.64000066400000000000000000003010131477416744200235220ustar00rootroot00000000000000random seed: 1234 45 4 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 (8,fun,45) (4,fun,5) (5,fun,23) (54,fun,6) (6,fun,9) (2,fun,9) (2,fun,9) (77,fun,6) (6,fun,54) (1,fun,3) (8,fun,45) (4,fun,5) (5,fun,23) (54,fun,6) (6,fun,9) (2,fun,9) (2,fun,9) (77,fun,6) (6,fun,54) (1,fun,3) (8,fun,45) (4,fun,5) (5,fun,23) (54,fun,6) (6,fun,9) (2,fun,9) (2,fun,9) (77,fun,6) (6,fun,54) (1,fun,3) (8,fun,45) (4,fun,5) (5,fun,23) (54,fun,6) (6,fun,9) (2,fun,9) (2,fun,9) (77,fun,6) (6,fun,54) (1,fun,3) (8,fun,45) (4,fun,5) (5,fun,23) (54,fun,6) (6,fun,9) (2,fun,9) (2,fun,9) (77,fun,6) (6,fun,54) (1,fun,3) (8,fun,45) (4,fun,5) (5,fun,23) (54,fun,6) (6,fun,9) (2,fun,9) (2,fun,9) (77,fun,6) (6,fun,54) (1,fun,3) (8,fun,45) (4,fun,5) (5,fun,23) (54,fun,6) (6,fun,9) (2,fun,9) (2,fun,9) (77,fun,6) (6,fun,54) (1,fun,3) (8,fun,45) (4,fun,5) (5,fun,23) (54,fun,6) (6,fun,9) (2,fun,9) (2,fun,9) (77,fun,6) (6,fun,54) (1,fun,3) -1592932412304362665 -796466206152181333 -398233103076090667 -199116551538045334 -99558275769022667 -49779137884511334 -24889568942255667 -12444784471127834 -6222392235563917 -3111196117781959 -1555598058890980 -777799029445490 -388899514722745 -194449757361373 -97224878680687 -48612439340344 -24306219670172 -12153109835086 -6076554917543 -3038277458772 -1519138729386 -759569364693 -379784682347 -189892341174 -94946170587 -47473085294 -23736542647 -11868271324 -5934135662 -2967067831 -1483533916 -741766958 -370883479 -185441740 -92720870 -46360435 -23180218 -11590109 -5795055 -2897528 -1448764 -724382 -362191 -181096 -90548 -45274 -22637 -11319 -5660 -2830 -1415 -708 -354 -177 -89 -45 -23 -12 -6 -3 -2 -1 0 [46; 2; 22; 4; 4; 2; 6; 5; 88; 24; 7; 9; 9; 2; 5; 1; 55; 8; 45; 1; 96; 0; 1; 2; 7; 4; 1; 5; 95; 6; 8; 6; 4; 0; 5; 5; 22; 87; 2; 1; 1; 0; 2; 2; 9; 5; 9; 3; 7; 59; 7; 96; 6; 5; 1; 3; 9; 9; 65; 6; 7; 7; 2; 5; 0; 0; 70; 5; 5; 2; 1; 57; 9; 7; 8; 10; 9; 7; 9; 75; 73; 80; 7; 9; 4; 3; 16; 5; 79; 1; 8; 6; 2; 3; 4; 9; 2; 8; 4; 6; 50; 2; 1; 5; 9; 5; 4; 3; 56; 6; 5; 9; 4; 1; 47; 1; 2; 5; 2; 0; 7; 31; 55; 6; 7; 4; 7; 8; 8; 2; 4; 40; 4; 6; 9; 3; 59; 5; 1; 0; 2; 6; 90; 1; 6; 81; 0; 1; 3; 7; 2; 4; 5; 4; 7; 3; 62; 0; 1; 6; 7; 5; 97; 83; 41; 7; 2; 6; 3; 0; 4; 8; 99; 8; 6; 0; 7; 9; 7; 1; 55; 30; 25; 3; 4; 7; 1; 6; 80; 8; 0; 4; 21; 3; 5; 9; 27; 10; 60; 47; 54; 6; 5; 8; 1; 5; 9; 65; 9; 5; 7; 7; 6; 48; 9; 5; 6; 4; 9; 7; 1; 2; 71; 6; 9; 2; 7; 8; 14; 59; 71; 30; 7; 3; 5; 4; 6; 7; 3; 6; 9; 8; 2; 38; 6; 6; 7; 1; 5; 2; 43; 5; 2; 9; 3; 0; 3; 2; 7; 71; 26; 3; 9; 11; 5; 1; 5; 2; 53; 46; 4; 6; 7; 67; 1; 0; 34; 0; 48; 5; 5; 0; 7; 49; 92; 8; 3; 0; 67; 1; 5; 2; 9; 5; 9; 3; 1; 4; 8; 0; 3; 6; 46; 58; 1; 54; 77; 0; 96; 1; 6; 2; 8; 22; 3; 9; 2; 6; 25; 49; 9; 6; 3; 8; 5; 9; 54; 1; 7; 5; 6; 5; 1; 7; 8; 23; 4; 6; 4; 2; 5; 8; 4; 7; 4] [46; 2; 22; 4; 4; 2; 6; 5; 88; 24; 7; 9; 9; 2; 5; 1; 55; 8; 45; 1; 96; 0; 1; 2; 7; 4; 1; 5; 95; 6; 8; 6; 4; 0; 5; 5; 22; 87; 2; 1; 1; 0; 2; 2; 9; 5; 9; 3; 7; 59; 7; 96; 6; 5; 1; 3; 9; 9; 65; 6; 7; 7; 2; 5; 0; 0; 70; 5; 5; 2; 1; 57; 9; 7; 8; 10; 9; 7; 9; 75; 73; 80; 7; 9; 4; 3; 16; 5; 79; 1; 8; 6; 2; 3; 4; 9; 2; 8; 4; 6; 50; 2; 1; 5; 9; 5; 4; 3; 56; 6; 5; 9; 4; 1; 47; 1; 2; 5; 2; 0; 7; 31; 55; 6; 7; 4; 7; 8; 8; 2; 4; 40; 4; 6; 9; 3; 59; 5; 1; 0; 2; 6; 90; 1; 6; 81; 0; 1; 3; 7; 2; 4; 5; 4; 7; 3; 62; 0; 1; 6; 7; 5; 97; 83; 41; 7; 2; 6; 3; 0; 4; 8; 99] [46; 2; 22; 4; 4; 2; 6; 5; 88; 24; 7; 9; 9; 2; 5; 1; 55; 8; 45; 1; 96; 0; 1; 2; 7; 4; 1; 5; 95; 6; 8; 6; 4; 0; 5; 5; 22; 87; 2; 1; 1; 0; 2; 2; 9; 5; 9; 3; 7; 59; 7; 96; 6; 5; 1; 3; 9; 9; 65; 6; 7; 7; 2; 5; 0; 0; 70; 5; 5; 2; 1; 57; 9; 7; 8; 10; 9; 7; 9; 75; 73; 80; 7; 9; 4; 3; 16] [46; 2; 22; 4; 4; 2; 6; 5; 88; 24; 7; 9; 9; 2; 5; 1; 55; 8; 45; 1; 96; 0; 1; 2; 7; 4; 1; 5; 95; 6; 8; 6; 4; 0; 5; 5; 22; 87; 2; 1; 1; 0; 2; 2] [46; 2; 22; 4; 4; 2; 6; 5; 88; 24; 7; 9; 9; 2; 5; 1; 55; 8; 45; 1; 96; 0] [46; 2; 22; 4; 4; 2; 6; 5; 88; 24; 7] [46; 2; 22; 4; 4; 2] [46; 2; 22] [46; 2] [] [46] [] [23] [] [12] [] [6] [] [3] [] [2] [] [1] [] [0] [] [46; 2; 22; 4; 4; 2; 6; 5; 88; 24; 7; 9; 9; 2; 5; 1; 55; 8; 45; 1; 96; 0; 1; 2; 7; 4; 1; 5; 95; 6; 8; 6; 4; 0; 5; 5; 22; 87; 2; 1; 1; 0; 2; 2; 9; 5; 9; 3; 7; 59; 7; 96; 6; 5; 1; 3; 9; 9; 65; 6; 7; 7; 2; 5; 0; 0; 70; 5; 5; 2; 1; 57; 9; 7; 8; 10; 9; 7; 9; 75; 73; 80; 7; 9; 4; 3; 16; 5; 79; 1; 8; 6; 2; 3; 4; 9; 2; 8; 4; 6; 50; 2; 1; 5; 9; 5; 4; 3; 56; 6; 5; 9; 4; 1; 47; 1; 2; 5; 2; 0; 7; 31; 55; 6; 7; 4; 7; 8; 8; 2; 4; 40; 4; 6; 9; 3; 59; 5; 1; 0; 2; 6; 90; 1; 6; 81; 0; 1; 3; 7; 2; 4; 5; 4; 7; 3; 62; 0; 1; 6; 7; 5; 97; 83; 41; 7; 2; 6; 3; 0; 4; 8; 99; 8; 6; 0; 7; 9; 7; 1; 55; 30; 25; 3; 4; 7; 1; 6; 80; 8; 0; 4; 21; 3; 5; 9; 27; 10; 60; 47; 54; 6; 5; 8; 1; 5; 9; 65; 9; 5; 7; 7; 6; 48; 9; 5; 6; 4; 9; 7; 1; 2; 71; 6; 9; 2; 7; 8; 14; 59; 71; 30; 7; 3; 5; 4; 6; 7; 3; 6; 9; 8; 2; 38; 6; 6; 7; 1; 5; 2; 43; 5; 2; 9; 3; 0; 3; 2; 7; 71; 26; 3; 9; 11; 5; 1; 5; 2; 53; 46; 4; 6; 7; 67; 1; 0; 34; 0; 48; 5; 5; 0; 7; 49; 92; 8; 3; 0; 67; 1; 5; 2; 9; 5; 9; 3; 1; 4; 8; 0; 3; 6; 46; 58; 1; 54; 77; 0; 96; 1; 6; 2; 8; 22; 3; 9; 2; 6; 25; 49; 9; 6; 3; 8; 5; 9; 54; 1; 7; 5; 6; 5; 1; 7; 8; 23; 4; 6; 4; 2; 5; 8; 4; 7; 4] [46; 2; 22; 4; 4; 2; 6; 5; 88; 24; 7; 9; 9; 2; 5; 1; 55; 8; 45; 1; 96; 0; 1; 2; 7; 4; 1; 5; 95; 6; 8; 6; 4; 0; 5; 5; 22; 87; 2; 1; 1; 0; 2; 2; 9; 5; 9; 3; 7; 59; 7; 96; 6; 5; 1; 3; 9; 9; 65; 6; 7; 7; 2; 5; 0; 0; 70; 5; 5; 2; 1; 57; 9; 7; 8; 10; 9; 7; 9; 75; 73; 80; 7; 9; 4; 3; 16; 5; 79; 1; 8; 6; 2; 3; 4; 9; 2; 8; 4; 6; 50; 2; 1; 5; 9; 5; 4; 3; 56; 6; 5; 9; 4; 1; 47; 1; 2; 5; 2; 0; 7; 31; 55; 6; 7; 4; 7; 8; 8; 2; 4; 40; 4; 6; 9; 3; 59; 5; 1; 0; 2; 6; 90; 1; 6; 81; 0; 1; 3; 7; 2; 4; 5; 4; 7; 3; 62; 0; 1; 6; 7; 5; 97; 83; 41; 7; 2; 6; 3; 0; 4; 8; 99] [46; 2; 22; 4; 4; 2; 6; 5; 88; 24; 7; 9; 9; 2; 5; 1; 55; 8; 45; 1; 96; 0; 1; 2; 7; 4; 1; 5; 95; 6; 8; 6; 4; 0; 5; 5; 22; 87; 2; 1; 1; 0; 2; 2; 9; 5; 9; 3; 7; 59; 7; 96; 6; 5; 1; 3; 9; 9; 65; 6; 7; 7; 2; 5; 0; 0; 70; 5; 5; 2; 1; 57; 9; 7; 8; 10; 9; 7; 9; 75; 73; 80; 7; 9; 4; 3; 16] [46; 2; 22; 4; 4; 2; 6; 5; 88; 24; 7; 9; 9; 2; 5; 1; 55; 8; 45; 1; 96; 0; 1; 2; 7; 4; 1; 5; 95; 6; 8; 6; 4; 0; 5; 5; 22; 87; 2; 1; 1; 0; 2; 2] [46; 2; 22; 4; 4; 2; 6; 5; 88; 24; 7; 9; 9; 2; 5; 1; 55; 8; 45; 1; 96; 0] [46; 2; 22; 4; 4; 2; 6; 5; 88; 24; 7] [46; 2; 22; 4; 4; 2] [46; 2; 22] [46; 2; 4; 4; 2] [46; 2; 4] [46; 2; 4; 2] [46; 2] [4; 2] [46; 4; 2] [2; 4; 2] [2; 4] [2] [2; 2] [] [2] [1; 2] [2; 1] --- Failure -------------------------------------------------------------------- Test should_fail_sort_id failed (10 shrink steps): [1; 0] --- Failure -------------------------------------------------------------------- Test max_fail failed (20 shrink steps): [0; 1] --- Failure -------------------------------------------------------------------- Test max_fail failed (14 shrink steps): [0; 1] --- Failure -------------------------------------------------------------------- Test max_fail failed (16 shrink steps): [1; 0] === Error ====================================================================== Test should_error_raise_exn errored on (62 shrink steps): 0 exception QCheck_tests.Overall.Error +++ Collect ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Collect results for test collect_results: 4: 24 cases 3: 20 cases 2: 18 cases 1: 21 cases 0: 17 cases +++ Stats for with_stats ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats mod4: num: 100, avg: 1.56, stddev: 1.18, median 2, min 0, max 3 0: ################################################# 27 1: #################################### 20 2: ########################################## 23 3: ####################################################### 30 stats num: num: 100, avg: 62.24, stddev: 33.15, median 62, min 2, max 120 2.. 7: ######### 2 8.. 13: ################################ 7 14.. 19: ########################### 6 20.. 25: ############# 3 26.. 31: ###################### 5 32.. 37: ################## 4 38.. 43: ############# 3 44.. 49: ################################ 7 50.. 55: ################################ 7 56.. 61: ###################### 5 62.. 67: #################################### 8 68.. 73: ######### 2 74.. 79: ###################### 5 80.. 85: ######### 2 86.. 91: ####################################################### 12 92.. 97: ###################### 5 98..103: ################## 4 104..109: ################## 4 110..115: ############# 3 116..121: ########################### 6 --- Failure -------------------------------------------------------------------- Test with shrinking retries failed (0 shrink steps): 4 !!! Warning !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Warning for test WARN_unlikely_precond: WARNING: only 0.8% tests (of 2000) passed precondition for "WARN_unlikely_precond" NOTE: it is likely that the precondition is too strong, or that the generator is buggy. --- Failure -------------------------------------------------------------------- Test FAIL_unlikely_precond failed: ERROR: only 0.8% tests (of 2000) passed precondition for "FAIL_unlikely_precond" NOTE: it is likely that the precondition is too strong, or that the generator is buggy. --- Failure -------------------------------------------------------------------- Test FAIL_bad_gen failed: ERROR: uncaught exception in generator for test FAIL_bad_gen after 100 steps: Exception: Invalid_argument("Gen.int_bound") Backtrace: --- Failure -------------------------------------------------------------------- Test int double failed: Negative test int double succeeded but was expected to fail === Error ====================================================================== Test pos fail with error errored on (7 shrink steps): 0 exception QCheck_tests.Overall.Error === Error ====================================================================== Test neg fail with error errored on (7 shrink steps): 0 exception QCheck_tests.Overall.Error --- Failure -------------------------------------------------------------------- Test char never produces '\255' failed (0 shrink steps): '\255' --- Failure -------------------------------------------------------------------- Test big bound issue59 failed (52 shrink steps): 209609 --- Failure -------------------------------------------------------------------- Test long_shrink failed (149 shrink steps): ([0], [1]) --- Failure -------------------------------------------------------------------- Test ints arent 0 mod 3 failed (75 shrink steps): 4161 --- Failure -------------------------------------------------------------------- Test ints are 0 failed (61 shrink steps): -1 --- Failure -------------------------------------------------------------------- Test int32s arent 0l rem 3l failed (37 shrink steps): 21l --- Failure -------------------------------------------------------------------- Test int32s are 0l failed (31 shrink steps): 1l --- Failure -------------------------------------------------------------------- Test int64s arent 0L rem 3L failed (83 shrink steps): 705L --- Failure -------------------------------------------------------------------- Test int64s are 0L failed (63 shrink steps): 1L --- Failure -------------------------------------------------------------------- Test ints < 209609 failed (52 shrink steps): 209609 --- Failure -------------------------------------------------------------------- Test nat < 5001 failed (4 shrink steps): 5001 --- Failure -------------------------------------------------------------------- Test char never produces 'abcdef' failed (2 shrink steps): 'a' --- Failure -------------------------------------------------------------------- Test printable never produces '!"#$%&' failed (1 shrink steps): '&' --- Failure -------------------------------------------------------------------- Test printable never produces less than '5 failed (0 shrink steps): '0' --- Failure -------------------------------------------------------------------- Test bytes are empty failed (13 shrink steps): "a" --- Failure -------------------------------------------------------------------- Test bytes never has a \000 char failed (13 shrink steps): "\000" --- Failure -------------------------------------------------------------------- Test bytes never has a \255 char failed (15 shrink steps): "\255" --- Failure -------------------------------------------------------------------- Test bytes have unique chars failed (14 shrink steps): "\232\232" --- Failure -------------------------------------------------------------------- Test strings are empty failed (13 shrink steps): "a" --- Failure -------------------------------------------------------------------- Test string never has a \000 char failed (13 shrink steps): "\000" --- Failure -------------------------------------------------------------------- Test string never has a \255 char failed (15 shrink steps): "\255" --- Failure -------------------------------------------------------------------- Test strings have unique chars failed (14 shrink steps): "\232\232" --- Failure -------------------------------------------------------------------- Test pairs have different components failed (0 shrink steps): (6, 6) --- Failure -------------------------------------------------------------------- Test pairs have same components failed (123 shrink steps): (0, -1) --- Failure -------------------------------------------------------------------- Test pairs have a zero component failed (122 shrink steps): (1, -1) --- Failure -------------------------------------------------------------------- Test pairs are (0,0) failed (123 shrink steps): (0, -1) --- Failure -------------------------------------------------------------------- Test pairs are ordered failed (554 shrink steps): (1, 0) --- Failure -------------------------------------------------------------------- Test pairs are ordered reversely failed (123 shrink steps): (0, 1) --- Failure -------------------------------------------------------------------- Test pairs sum to less than 128 failed (118 shrink steps): (0, 128) --- Failure -------------------------------------------------------------------- Test pairs lists rev concat failed (138 shrink steps): ([0], [1]) --- Failure -------------------------------------------------------------------- Test pairs lists no overlap failed (24 shrink steps): ([0], [0]) --- Failure -------------------------------------------------------------------- Test triples have pair-wise different components failed (4 shrink steps): (6, 6, 0) --- Failure -------------------------------------------------------------------- Test triples have same components failed (184 shrink steps): (0, 1, 0) --- Failure -------------------------------------------------------------------- Test triples are ordered failed (184 shrink steps): (0, 0, -1) --- Failure -------------------------------------------------------------------- Test triples are ordered reversely failed (184 shrink steps): (0, 1, 0) --- Failure -------------------------------------------------------------------- Test quadruples have pair-wise different components failed (7 shrink steps): (0, 5, 5, 0) --- Failure -------------------------------------------------------------------- Test quadruples have same components failed (245 shrink steps): (0, 1, 2, 0) --- Failure -------------------------------------------------------------------- Test quadruples are ordered failed (247 shrink steps): (0, 0, 0, -1) --- Failure -------------------------------------------------------------------- Test quadruples are ordered reversely failed (247 shrink steps): (0, 0, 1, 0) --- Failure -------------------------------------------------------------------- Test forall (a, b) in nat: a < b failed (5 shrink steps): (0, 0) --- Failure -------------------------------------------------------------------- Test forall (a, b, c) in nat: a < b < c failed (14 shrink steps): (0, 0, 0) --- Failure -------------------------------------------------------------------- Test forall (a, b, c, d) in nat: a < b < c < d failed (17 shrink steps): (0, 0, 0, 0) --- Failure -------------------------------------------------------------------- Test forall (a, b, c, d, e) in nat: a < b < c < d < e failed (21 shrink steps): (0, 0, 0, 0, 0) --- Failure -------------------------------------------------------------------- Test forall (a, b, c, d, e, f) in nat: a < b < c < d < e < f failed (25 shrink steps): (0, 0, 0, 0, 0, 0) --- Failure -------------------------------------------------------------------- Test forall (a, b, c, d, e, f, g) in nat: a < b < c < d < e < f < g failed (27 shrink steps): (0, 0, 0, 0, 0, 0, 0) --- Failure -------------------------------------------------------------------- Test forall (a, b, c, d, e, f, g, h) in nat: a < b < c < d < e < f < g < h failed (30 shrink steps): (0, 0, 0, 0, 0, 0, 0, 0) --- Failure -------------------------------------------------------------------- Test forall (a, b, c, d, e, f, g, h, i) in nat: a < b < c < d < e < f < g < h < i failed (34 shrink steps): (0, 0, 0, 0, 0, 0, 0, 0, 0) --- Failure -------------------------------------------------------------------- Test bind ordered pairs failed (124 shrink steps): (0, 0) --- Failure -------------------------------------------------------------------- Test bind list_size constant failed (52 shrink steps): (4, [0; 0; 0; 0]) --- Failure -------------------------------------------------------------------- Test lists are empty failed (16 shrink steps): [0] --- Failure -------------------------------------------------------------------- Test lists shorter than 10 failed (49 shrink steps): [0; 0; 0; 0; 0; 0; 0; 0; 0; 0] --- Failure -------------------------------------------------------------------- Test lists shorter than 432 failed (1738 shrink steps): [...] list length: 432 --- Failure -------------------------------------------------------------------- Test lists shorter than 4332 failed (11 shrink steps): [...] list length: 4332 --- Failure -------------------------------------------------------------------- Test lists have unique elems failed (10 shrink steps): [2; 2] --- Failure -------------------------------------------------------------------- Test int option are none failed (11 shrink steps): Some (0) --- Failure -------------------------------------------------------------------- Test int option are some 100 or more failed (0 shrink steps): None --- Failure -------------------------------------------------------------------- Test (int,string) result are Ok failed (3 shrink steps): Error ("") --- Failure -------------------------------------------------------------------- Test (int,string) result are Error failed (11 shrink steps): Ok (0) --- Failure -------------------------------------------------------------------- Test tree contains only 42 failed (9 shrink steps): Leaf 0 --- Failure -------------------------------------------------------------------- Test sum list = 0 failed (0 shrink steps): [46; 2; 22; 4; 4; 2; 6; 5; 88; 24; 7; 9; 9; 2; 5; 1; 55; 8; 45; 1; 96; 0; 1; 2; 7; 4; 1; 5; 95; 6; 8; 6; 4; 0; 5; 5; 22; 87; 2; 1; 1; 0; 2; 2; 9; 5; 9; 3; 7; 59; 7; 96; 6; 5; 1; 3; 9; 9; 65; 6; 7; 7; 2; 5; 0; 0; 70; 5; 5; 2; 1; 57; 9; 7; 8; 10; 9; 7; 9; 75; 73; 80; 7; 9; 4; 3; 16; 5; 79; 1; 8; 6; 2; 3; 4; 9; 2; 8; 4; 6; 50; 2; 1; 5; 9; 5; 4; 3; 56; 6; 5; 9; 4; 1; 47; 1; 2; 5; 2; 0; 7; 31; 55; 6; 7; 4; 7; 8; 8; 2; 4; 40; 4; 6; 9; 3; 59; 5; 1; 0; 2; 6; 90; 1; 6; 81; 0; 1; 3; 7; 2; 4; 5; 4; 7; 3; 62; 0; 1; 6; 7; 5; 97; 83; 41; 7; 2; 6; 3; 0; 4; 8; 99; 8; 6; 0; 7; 9; 7; 1; 55; 30; 25; 3; 4; 7; 1; 6; 80; 8; 0; 4; 21; 3; 5; 9; 27; 10; 60; 47; 54; 6; 5; 8; 1; 5; 9; 65; 9; 5; 7; 7; 6; 48; 9; 5; 6; 4; 9; 7; 1; 2; 71; 6; 9; 2; 7; 8; 14; 59; 71; 30; 7; 3; 5; 4; 6; 7; 3; 6; 9; 8; 2; 38; 6; 6; 7; 1; 5; 2; 43; 5; 2; 9; 3; 0; 3; 2; 7; 71; 26; 3; 9; 11; 5; 1; 5; 2; 53; 46; 4; 6; 7; 67; 1; 0; 34; 0; 48; 5; 5; 0; 7; 49; 92; 8; 3; 0; 67; 1; 5; 2; 9; 5; 9; 3; 1; 4; 8; 0; 3; 6; 46; 58; 1; 54; 77; 0; 96; 1; 6; 2; 8; 22; 3; 9; 2; 6; 25; 49; 9; 6; 3; 8; 5; 9; 54; 1; 7; 5; 6; 5; 1; 7; 8; 23; 4; 6; 4; 2; 5; 8; 4; 7; 4] --- Failure -------------------------------------------------------------------- Test fail_pred_map_commute_int failed (89 shrink steps): ([1], {_ -> 0}, {0 -> true; _ -> false}) --- Failure -------------------------------------------------------------------- Test fail_pred_map_commute_int32 failed (110 shrink steps): ([-1l], {_ -> 0l}, {-1l -> true; _ -> false}) --- Failure -------------------------------------------------------------------- Test fail_pred_map_commute_int64 failed (185 shrink steps): ([6L], {_ -> 0L}, {6L -> true; _ -> false}) --- Failure -------------------------------------------------------------------- Test fail_pred_strings failed (2 shrink steps): {"some random string" -> true; _ -> false} --- Failure -------------------------------------------------------------------- Test fold_left fold_right failed (21 shrink steps): (0, [1], {(0, 1) -> 1; _ -> 0}) +++ Messages ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Messages for test fold_left fold_right: l=[1], fold_left=0, fold_right=1 --- Failure -------------------------------------------------------------------- Test fold_left fold_right uncurried failed (41 shrink steps): ({(0, 4) -> 1; _ -> 0}, 0, [4]) --- Failure -------------------------------------------------------------------- Test fold_left fold_right uncurried fun last failed (25 shrink steps): (0, [1], {(0, 1) -> 1; _ -> 0}) --- Failure -------------------------------------------------------------------- Test fold_left test, fun first failed (66 shrink steps): ({("", 2) -> "a"; _ -> ""}, "", [], [2]) --- Failure -------------------------------------------------------------------- Test FAIL_#99_1 failed: ERROR: uncaught exception in generator for test FAIL_#99_1 after 100 steps: Exception: QCheck.No_example_found("") Backtrace: +++ Collect ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Collect results for test bool dist: true: 250511 cases false: 249489 cases +++ Stats for char code dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats char code: num: 500000, avg: 127.68, stddev: 73.87, median 128, min 0, max 255 0.. 12: ##################################################### 25272 13.. 25: ###################################################### 25326 26.. 38: ##################################################### 25194 39.. 51: ###################################################### 25359 52.. 64: ###################################################### 25338 65.. 77: ###################################################### 25349 78.. 90: ###################################################### 25397 91..103: ##################################################### 25243 104..116: ###################################################### 25420 117..129: ###################################################### 25438 130..142: ###################################################### 25346 143..155: ##################################################### 25177 156..168: ####################################################### 25755 169..181: ###################################################### 25408 182..194: ###################################################### 25633 195..207: ###################################################### 25613 208..220: ###################################################### 25459 221..233: ###################################################### 25322 234..246: ##################################################### 25229 247..259: ##################################### 17722 +++ Stats for printable char code dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats char code: num: 500000, avg: 77.76, stddev: 27.87, median 78, min 10, max 125 10.. 15: ######### 5255 16.. 21: 0 22.. 27: 0 28.. 33: ################# 10417 34.. 39: ###################################################### 31730 40.. 45: ###################################################### 31499 46.. 51: ###################################################### 31657 52.. 57: ###################################################### 31704 58.. 63: ###################################################### 31502 64.. 69: ###################################################### 31643 70.. 75: ###################################################### 31630 76.. 81: ###################################################### 31481 82.. 87: ###################################################### 31594 88.. 93: ###################################################### 31817 94.. 99: ###################################################### 31536 100..105: ###################################################### 31528 106..111: ###################################################### 31467 112..117: ##################################################### 31246 118..123: ####################################################### 31861 124..129: ################## 10433 +++ Stats for numeral char code dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats char code: num: 500000, avg: 52.50, stddev: 2.87, median 53, min 48, max 57 48: ###################################################### 49848 49: ###################################################### 50118 50: ###################################################### 49837 51: ###################################################### 50252 52: ###################################################### 49765 53: ####################################################### 50369 54: ###################################################### 50270 55: ###################################################### 49885 56: ###################################################### 49821 57: ###################################################### 49835 +++ Stats for tree's depth ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats depth: num: 1000, avg: 4.13, stddev: 3.52, median 3, min 1, max 15 1: ####################################################### 339 2: ################ 104 3: ############### 98 4: ##################### 133 5: ######### 60 6: #### 29 7: ######## 54 8: ####### 48 9: ## 16 10: ### 21 11: ########### 68 12: 1 13: # 8 14: ## 16 15: 5 +++ Stats for range_subset_spec ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 5000, avg: 9.99, stddev: 6.01, median 10, min 0, max 20 0: ############################################### 231 1: ############################################## 223 2: ##################################################### 258 3: ################################################ 233 4: ############################################### 228 5: ############################################### 231 6: #################################################### 254 7: ############################################### 228 8: #################################################### 254 9: ####################################################### 266 10: ############################################## 224 11: ################################################## 245 12: ############################################### 230 13: #################################################### 253 14: ############################################## 223 15: ################################################# 239 16: ################################################## 243 17: ################################################## 245 18: ############################################# 220 19: ################################################## 242 20: ############################################### 230 +++ Stats for bytes_size len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 7.51, stddev: 1.69, median 8, min 5, max 10 5: ################################################## 817 6: ################################################# 797 7: ####################################################### 885 8: ################################################### 834 9: ###################################################### 877 10: ################################################# 790 +++ Stats for bytes len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 370.05, stddev: 1282.91, median 9, min 0, max 9947 0.. 497: ####################################################### 4270 498.. 995: ###### 497 996..1493: 17 1494..1991: 9 1992..2489: 13 2490..2987: 13 2988..3485: 9 3486..3983: 14 3984..4481: 14 4482..4979: 17 4980..5477: 9 5478..5975: 10 5976..6473: 15 6474..6971: 16 6972..7469: 16 7470..7967: 9 7968..8465: 12 8466..8963: 15 8964..9461: 9 9462..9959: 16 +++ Stats for bytes_of len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 359.22, stddev: 1249.46, median 9, min 0, max 9958 0.. 497: ####################################################### 4275 498.. 995: ###### 479 996..1493: 22 1494..1991: 12 1992..2489: 21 2490..2987: 16 2988..3485: 13 3486..3983: 17 3984..4481: 14 4482..4979: 14 4980..5477: 8 5478..5975: 14 5976..6473: 13 6474..6971: 9 6972..7469: 7 7470..7967: 17 7968..8465: 13 8466..8963: 15 8964..9461: 10 9462..9959: 11 +++ Stats for bytes_small len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 15.99, stddev: 24.58, median 6, min 0, max 99 0.. 4: ###################################################### 1920 5.. 9: ####################################################### 1929 10.. 14: # 69 15.. 19: # 62 20.. 24: # 63 25.. 29: # 59 30.. 34: # 68 35.. 39: # 62 40.. 44: # 57 45.. 49: ## 83 50.. 54: # 59 55.. 59: ## 80 60.. 64: # 48 65.. 69: # 53 70.. 74: # 61 75.. 79: # 66 80.. 84: # 61 85.. 89: ## 72 90.. 94: # 66 95.. 99: # 62 +++ Stats for string_size len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 7.51, stddev: 1.69, median 8, min 5, max 10 5: ################################################## 817 6: ################################################# 797 7: ####################################################### 885 8: ################################################### 834 9: ###################################################### 877 10: ################################################# 790 +++ Stats for string len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 370.05, stddev: 1282.91, median 9, min 0, max 9947 0.. 497: ####################################################### 4270 498.. 995: ###### 497 996..1493: 17 1494..1991: 9 1992..2489: 13 2490..2987: 13 2988..3485: 9 3486..3983: 14 3984..4481: 14 4482..4979: 17 4980..5477: 9 5478..5975: 10 5976..6473: 15 6474..6971: 16 6972..7469: 16 7470..7967: 9 7968..8465: 12 8466..8963: 15 8964..9461: 9 9462..9959: 16 +++ Stats for string_of len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 359.22, stddev: 1249.46, median 9, min 0, max 9958 0.. 497: ####################################################### 4275 498.. 995: ###### 479 996..1493: 22 1494..1991: 12 1992..2489: 21 2490..2987: 16 2988..3485: 13 3486..3983: 17 3984..4481: 14 4482..4979: 14 4980..5477: 8 5478..5975: 14 5976..6473: 13 6474..6971: 9 6972..7469: 7 7470..7967: 17 7968..8465: 13 8466..8963: 15 8964..9461: 10 9462..9959: 11 +++ Stats for printable_string len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 370.05, stddev: 1282.91, median 9, min 0, max 9947 0.. 497: ####################################################### 4270 498.. 995: ###### 497 996..1493: 17 1494..1991: 9 1992..2489: 13 2490..2987: 13 2988..3485: 9 3486..3983: 14 3984..4481: 14 4482..4979: 17 4980..5477: 9 5478..5975: 10 5976..6473: 15 6474..6971: 16 6972..7469: 16 7470..7967: 9 7968..8465: 12 8466..8963: 15 8964..9461: 9 9462..9959: 16 +++ Stats for small_string len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 15.99, stddev: 24.58, median 6, min 0, max 99 0.. 4: ###################################################### 1920 5.. 9: ####################################################### 1929 10.. 14: # 69 15.. 19: # 62 20.. 24: # 63 25.. 29: # 59 30.. 34: # 68 35.. 39: # 62 40.. 44: # 57 45.. 49: ## 83 50.. 54: # 59 55.. 59: ## 80 60.. 64: # 48 65.. 69: # 53 70.. 74: # 61 75.. 79: # 66 80.. 84: # 61 85.. 89: ## 72 90.. 94: # 66 95.. 99: # 62 +++ Stats for pair dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats pair sum: num: 500000, avg: 100.05, stddev: 41.29, median 100, min 0, max 200 0.. 9: ### 2618 10.. 19: ######## 7630 20.. 29: ############## 12505 30.. 39: #################### 17451 40.. 49: ########################## 22280 50.. 59: ############################### 27307 60.. 69: ##################################### 32151 70.. 79: ########################################### 37199 80.. 89: ################################################# 41901 90.. 99: ###################################################### 46313 100..109: ####################################################### 46965 110..119: ################################################# 42462 120..129: ########################################### 37348 130..139: ###################################### 32613 140..149: ################################ 27606 150..159: ########################### 23221 160..169: ##################### 18125 170..179: ############### 12890 180..189: ######### 8059 190..199: ### 3297 200..209: 59 +++ Stats for triple dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats triple sum: num: 500000, avg: 150.04, stddev: 50.53, median 150, min 1, max 300 1.. 15: 360 16.. 30: ## 2261 31.. 45: ##### 5712 46.. 60: ########## 10854 61.. 75: ################# 17760 76.. 90: ########################## 26151 91..105: ################################### 36079 106..120: ############################################# 45498 121..135: ################################################### 51977 136..150: ####################################################### 55179 151..165: ###################################################### 54821 166..180: ################################################### 51709 181..195: ############################################# 45166 196..210: ################################### 35354 211..225: ######################### 25436 226..240: ################# 17179 241..255: ########## 10652 256..270: ##### 5447 271..285: ## 2065 286..300: 340 +++ Stats for quad dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats quad sum: num: 500000, avg: 200.06, stddev: 58.39, median 200, min 2, max 394 2.. 21: 61 22.. 41: 658 42.. 61: ## 2534 62.. 81: ##### 6444 82..101: ########### 13334 102..121: ################### 23279 122..141: ############################## 35888 142..161: ######################################### 48824 162..181: ################################################## 59008 182..201: ####################################################### 64896 202..221: ###################################################### 64051 222..241: ################################################# 57864 242..261: ####################################### 46793 262..281: ############################ 33955 282..301: ################## 21775 302..321: ########## 12187 322..341: #### 5645 342..361: # 2244 362..381: 529 382..401: 31 +++ Stats for bind dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats ordered pair difference: num: 1000000, avg: 25.01, stddev: 22.38, median 19, min 0, max 100 0.. 4: ####################################################### 193610 5.. 9: #################################### 130051 10.. 14: ############################# 104209 15.. 19: ######################## 86993 20.. 24: ##################### 74295 25.. 29: ################## 64874 30.. 34: ################ 56447 35.. 39: ############## 49416 40.. 44: ############ 43051 45.. 49: ########## 37580 50.. 54: ######### 32378 55.. 59: ######## 28558 60.. 64: ###### 23971 65.. 69: ##### 20146 70.. 74: #### 16446 75.. 79: ### 13215 80.. 84: ## 10294 85.. 89: ## 7639 90.. 94: # 4698 95.. 99: 2041 100..104: 88 stats ordered pair sum: num: 1000000, avg: 74.97, stddev: 46.86, median 72, min 0, max 200 0.. 9: ####################################################### 70320 10.. 19: ##################################################### 68731 20.. 29: ##################################################### 68374 30.. 39: ##################################################### 68544 40.. 49: ##################################################### 68756 50.. 59: ##################################################### 68837 60.. 69: ##################################################### 68759 70.. 79: ##################################################### 68517 80.. 89: ##################################################### 68692 90.. 99: ###################################################### 69123 100..109: ################################################## 64777 110..119: ########################################### 55288 120..129: #################################### 47156 130..139: ############################### 39635 140..149: ######################### 32590 150..159: #################### 25685 160..169: ############### 19842 170..179: ########## 14038 180..189: ###### 8631 190..199: ## 3580 200..209: 125 +++ Collect ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Collect results for test option dist: None : 1464 cases Some _: 8536 cases +++ Collect ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Collect results for test result dist: Error _: 2509 cases Ok _ : 7491 cases +++ Stats for list len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 381.08, stddev: 1328.05, median 9, min 0, max 9993 0.. 499: ####################################################### 4260 500.. 999: ###### 515 1000.. 1499: 8 1500.. 1999: 11 2000.. 2499: 10 2500.. 2999: 10 3000.. 3499: 9 3500.. 3999: 18 4000.. 4499: 14 4500.. 4999: 9 5000.. 5499: 9 5500.. 5999: 14 6000.. 6499: 15 6500.. 6999: 7 7000.. 7499: 10 7500.. 7999: 23 8000.. 8499: 10 8500.. 8999: 22 9000.. 9499: 16 9500.. 9999: 10 +++ Stats for small_list len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 16.58, stddev: 25.30, median 6, min 0, max 99 0.. 4: ################################################### 1848 5.. 9: ####################################################### 1992 10.. 14: # 47 15.. 19: # 62 20.. 24: # 56 25.. 29: # 67 30.. 34: # 66 35.. 39: # 57 40.. 44: # 59 45.. 49: # 62 50.. 54: ## 75 55.. 59: # 70 60.. 64: # 55 65.. 69: # 68 70.. 74: ## 74 75.. 79: # 56 80.. 84: # 66 85.. 89: ## 74 90.. 94: # 64 95.. 99: ## 82 +++ Stats for list_of_size len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 7.50, stddev: 1.72, median 8, min 5, max 10 5: ####################################################### 854 6: ################################################### 802 7: ##################################################### 835 8: ##################################################### 838 9: #################################################### 818 10: ###################################################### 853 +++ Stats for list_repeat len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 42.00, stddev: 0.00, median 42, min 42, max 42 42: ####################################################### 5000 +++ Stats for array len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 381.08, stddev: 1328.05, median 9, min 0, max 9993 0.. 499: ####################################################### 4260 500.. 999: ###### 515 1000.. 1499: 8 1500.. 1999: 11 2000.. 2499: 10 2500.. 2999: 10 3000.. 3499: 9 3500.. 3999: 18 4000.. 4499: 14 4500.. 4999: 9 5000.. 5499: 9 5500.. 5999: 14 6000.. 6499: 15 6500.. 6999: 7 7000.. 7499: 10 7500.. 7999: 23 8000.. 8499: 10 8500.. 8999: 22 9000.. 9499: 16 9500.. 9999: 10 +++ Stats for small_array len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 16.58, stddev: 25.30, median 6, min 0, max 99 0.. 4: ################################################### 1848 5.. 9: ####################################################### 1992 10.. 14: # 47 15.. 19: # 62 20.. 24: # 56 25.. 29: # 67 30.. 34: # 66 35.. 39: # 57 40.. 44: # 59 45.. 49: # 62 50.. 54: ## 75 55.. 59: # 70 60.. 64: # 55 65.. 69: # 68 70.. 74: ## 74 75.. 79: # 56 80.. 84: # 66 85.. 89: ## 74 90.. 94: # 64 95.. 99: ## 82 +++ Stats for array_of_size len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 7.50, stddev: 1.72, median 8, min 5, max 10 5: ####################################################### 854 6: ################################################### 802 7: ##################################################### 835 8: ##################################################### 838 9: #################################################### 818 10: ###################################################### 853 +++ Stats for array_repeat len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: num: 5000, avg: 42.00, stddev: 0.00, median 42, min 42, max 42 42: ####################################################### 5000 +++ Stats for int_stats_neg ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 5000, avg: 0.43, stddev: 28.63, median 0, min -99, max 99 -99..-90: # 45 -89..-80: # 57 -79..-70: # 68 -69..-60: # 58 -59..-50: # 76 -49..-40: # 67 -39..-30: # 52 -29..-20: # 54 -19..-10: # 47 -9.. 0: ####################################################### 2205 1.. 10: ########################################## 1697 11.. 20: # 57 21.. 30: # 70 31.. 40: # 60 41.. 50: # 66 51.. 60: # 75 61.. 70: # 68 71.. 80: # 63 81.. 90: # 66 91..100: # 49 +++ Stats for small_signed_int dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 0.86, stddev: 29.11, median 0, min -97, max 99 -97..-88: # 12 -87..-78: # 12 -77..-68: # 13 -67..-58: # 12 -57..-48: # 9 -47..-38: ## 17 -37..-28: # 13 -27..-18: # 8 -17.. -8: ######### 76 -7.. 2: ####################################################### 437 3.. 12: ################################## 276 13.. 22: ## 16 23.. 32: # 11 33.. 42: ## 16 43.. 52: # 9 53.. 62: # 12 63.. 72: # 14 73.. 82: # 12 83.. 92: # 13 93..102: # 12 +++ Stats for small_nat dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 15.86, stddev: 24.57, median 6, min 0, max 99 0.. 4: ###################################################### 387 5.. 9: ####################################################### 390 10.. 14: # 11 15.. 19: # 8 20.. 24: # 11 25.. 29: ## 15 30.. 34: # 9 35.. 39: # 11 40.. 44: # 11 45.. 49: ## 19 50.. 54: # 10 55.. 59: ## 19 60.. 64: # 9 65.. 69: # 9 70.. 74: ## 19 75.. 79: # 13 80.. 84: # 11 85.. 89: ## 16 90.. 94: # 9 95.. 99: # 13 +++ Stats for nat dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 382.03, stddev: 1290.55, median 9, min 0, max 9890 0.. 494: ####################################################### 850 495.. 989: ###### 93 990..1484: 8 1485..1979: 3 1980..2474: 7 2475..2969: 1 2970..3464: 3 3465..3959: 3 3960..4454: 3 4455..4949: 4 4950..5444: 3 5445..5939: 3 5940..6434: 3 6435..6929: 1 6930..7424: 2 7425..7919: 1 7920..8414: 1 8415..8909: 5 8910..9404: 3 9405..9899: 3 +++ Stats for int_range (-43643) 435434 dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 193479.13, stddev: 136696.70, median 189823, min -43164, max 434961 -43164..-19258: ################################### 42 -19257.. 4649: ############################################## 56 4650.. 28556: ############################################# 55 28557.. 52463: ############################################### 57 52464.. 76370: ######################################### 50 76371..100277: ############################# 35 100278..124184: ############################################### 57 124185..148091: #################################### 44 148092..171998: ############################################## 56 171999..195905: ####################################################### 66 195906..219812: ########################################### 52 219813..243719: ######################################## 49 243720..267626: ################################ 39 267627..291533: ##################################### 45 291534..315440: ##################################### 45 315441..339347: ################################################# 59 339348..363254: ################################################## 60 363255..387161: ################################# 40 387162..411068: ########################################## 51 411069..434975: ################################### 42 +++ Stats for int_range (-40000) 40000 dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: -591.06, stddev: 23026.79, median -911, min -39911, max 39959 -39911..-35918: ####################################### 45 -35917..-31924: #################################################### 59 -31923..-27930: ########################################### 49 -27929..-23936: ########################################## 48 -23935..-19942: ####################################################### 62 -19941..-15948: ############################################# 51 -15947..-11954: ######################################### 47 -11953.. -7960: ################################################# 56 -7959.. -3966: ################################### 40 -3965.. 28: ################################################### 58 29.. 4022: ########################################### 49 4023.. 8016: ############################################### 53 8017.. 12010: ############################################ 50 12011.. 16004: ################################### 40 16005.. 19998: ####################################### 44 19999.. 23992: ####################################################### 62 23993.. 27986: ##################################### 42 27987.. 31980: ######################################### 47 31981.. 35974: ########################################## 48 35975.. 39968: ############################################ 50 +++ Stats for int_range (-4) 4 dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: -0.12, stddev: 2.52, median 0, min -4, max 4 -4: ########################################## 116 -3: ###################################### 103 -2: ############################################## 125 -1: ########################################## 115 0: ####################################### 106 1: ####################################################### 149 2: ################################# 92 3: ################################# 92 4: ##################################### 102 +++ Stats for int_range (-4) 17 dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 6.42, stddev: 6.43, median 6, min -4, max 17 -4..-3: ########################################### 89 -2..-1: ################################################# 101 0.. 1: ############################################## 95 2.. 3: ########################################### 89 4.. 5: ############################################## 95 6.. 7: ##################################### 78 8.. 9: ####################################### 81 10..11: ######################################## 84 12..13: ####################################################### 113 14..15: ######################################## 84 16..17: ############################################ 91 18..19: 0 20..21: 0 22..23: 0 24..25: 0 26..27: 0 28..29: 0 30..31: 0 32..33: 0 34..35: 0 +++ Stats for int dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 100000, avg: -7.216e+15, stddev: 2.666e+18, median -16620417636667326, min -4611371852367564818, max 4611613630315464842 -4611371852367564818..-4150222578233413331: ##################################################### 5003 -4150222578233413330..-3689073304099261843: ####################################################### 5106 -3689073304099261842..-3227924029965110355: ###################################################### 5052 -3227924029965110354..-2766774755830958867: ###################################################### 5017 -2766774755830958866..-2305625481696807379: #################################################### 4852 -2305625481696807378..-1844476207562655891: ###################################################### 5016 -1844476207562655890..-1383326933428504403: ###################################################### 5083 -1383326933428504402.. -922177659294352915: ##################################################### 4986 -922177659294352914.. -461028385160201427: ###################################################### 5042 -461028385160201426.. 120888973950061: ###################################################### 5017 120888973950062.. 461270163108101549: ##################################################### 4977 461270163108101550.. 922419437242253037: ##################################################### 5000 922419437242253038.. 1383568711376404525: ###################################################### 5022 1383568711376404526.. 1844717985510556013: #################################################### 4896 1844717985510556014.. 2305867259644707501: #################################################### 4884 2305867259644707502.. 2767016533778858989: ##################################################### 4981 2767016533778858990.. 3228165807913010477: ###################################################### 5026 3228165807913010478.. 3689315082047161965: ###################################################### 5016 3689315082047161966.. 4150464356181313453: ###################################################### 5021 4150464356181313454.. 4611613630315464941: ##################################################### 5003 +++ Stats for oneof int dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: 4.612e+15, stddev: 2.891e+18, median 0, min -4611686018427387904, max 4611686018427387903 -4611686018427387904..-4150517416584649089: ################# 198 -4150517416584649088..-3689348814741910273: 0 -3689348814741910272..-3228180212899171457: 0 -3228180212899171456..-2767011611056432641: 0 -2767011611056432640..-2305843009213693825: 0 -2305843009213693824..-1844674407370955009: 0 -1844674407370955008..-1383505805528216193: 0 -1383505805528216192.. -922337203685477377: 0 -922337203685477376.. -461168601842738561: 0 -461168601842738560.. 255: ####################################################### 607 256.. 461168601842739071: 0 461168601842739072.. 922337203685477887: 0 922337203685477888.. 1383505805528216703: 0 1383505805528216704.. 1844674407370955519: 0 1844674407370955520.. 2305843009213694335: 0 2305843009213694336.. 2767011611056433151: 0 2767011611056433152.. 3228180212899171967: 0 3228180212899171968.. 3689348814741910783: 0 3689348814741910784.. 4150517416584649599: 0 4150517416584649600.. 4611686018427387903: ################# 195 +++ Stats for int32 lower dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 10000, avg: 32719.66, stddev: 18976.66, median 32730, min 9, max 65532 9.. 3285: ################################################### 506 3286.. 6562: #################################################### 508 6563.. 9839: ################################################# 481 9840..13116: ################################################### 506 13117..16393: #################################################### 517 16394..19670: #################################################### 512 19671..22947: ################################################## 496 22948..26224: #################################################### 510 26225..29501: ################################################# 486 29502..32778: ################################################## 491 32779..36055: ################################################## 495 36056..39332: ################################################## 489 39333..42609: ################################################## 493 42610..45886: ####################################################### 537 45887..49163: ################################################## 497 49164..52440: ################################################# 479 52441..55717: ################################################## 493 55718..58994: ################################################## 494 58995..62271: ################################################# 481 62272..65548: ###################################################### 529 +++ Stats for int32 upper dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 10000, avg: 32555.02, stddev: 18918.49, median 32323, min 3, max 65534 3.. 3279: ###################################################### 547 3280.. 6556: ################################################ 482 6557.. 9833: ############################################### 473 9834..13110: ################################################## 509 13111..16387: ################################################## 507 16388..19664: ################################################## 507 19665..22941: ################################################ 482 22942..26218: ##################################################### 536 26219..29495: ####################################################### 550 29496..32772: ############################################## 468 32773..36049: #################################################### 528 36050..39326: ################################################ 488 39327..42603: ################################################ 483 42604..45880: ################################################ 489 45881..49157: ############################################# 450 49158..52434: ################################################ 483 52435..55711: ###################################################### 548 55712..58988: ################################################ 489 58989..62265: ################################################# 498 62266..65542: ################################################ 483 +++ Stats for int64 lower dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 10000, avg: 32452.50, stddev: 18981.40, median 32331, min 22, max 65532 22.. 3297: ##################################################### 533 3298.. 6573: ##################################################### 528 6574.. 9849: ################################################### 510 9850..13125: ################################################### 506 13126..16401: ################################################ 476 16402..19677: ################################################# 489 19678..22953: ####################################################### 543 22954..26229: ################################################# 486 26230..29505: ################################################## 501 29506..32781: ################################################## 501 32782..36057: ################################################### 505 36058..39333: ############################################## 463 39334..42609: ################################################## 498 42610..45885: #################################################### 517 45886..49161: ################################################### 510 49162..52437: ############################################### 471 52438..55713: ################################################## 497 55714..58989: ################################################## 494 58990..62265: ############################################# 454 62266..65541: #################################################### 518 +++ Stats for int64 lower-mid dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 10000, avg: 32748.75, stddev: 18818.12, median 32802, min 3, max 65533 3.. 3279: ################################################### 500 3280.. 6556: ################################################### 506 6557.. 9833: ############################################### 464 9834..13110: ################################################### 502 13111..16387: ################################################## 496 16388..19664: #################################################### 513 19665..22941: ################################################## 490 22942..26218: ####################################################### 538 26219..29495: ##################################################### 524 29496..32772: ############################################### 462 32773..36049: ################################################## 494 36050..39326: ##################################################### 523 39327..42603: ################################################### 504 42604..45880: ##################################################### 525 45881..49157: ################################################ 477 49158..52434: ################################################# 487 52435..55711: ##################################################### 527 55712..58988: #################################################### 509 58989..62265: ################################################ 470 62266..65542: ################################################# 489 +++ Stats for int64 upper-mid dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 10000, avg: 32869.52, stddev: 18881.85, median 33046, min 9, max 65529 9.. 3284: ################################################## 489 3285.. 6560: ################################################# 486 6561.. 9836: ################################################### 504 9837..13112: ################################################## 492 13113..16388: ###################################################### 528 16389..19664: ################################################## 494 19665..22940: ############################################### 461 22941..26216: ###################################################### 533 26217..29492: ################################################## 489 29493..32768: ################################################# 486 32769..36044: ################################################## 495 36045..39320: ##################################################### 518 39321..42596: ################################################### 504 42597..45872: ####################################################### 535 45873..49148: ################################################ 472 49149..52424: #################################################### 513 52425..55700: ################################################### 499 55701..58976: ##################################################### 517 58977..62252: #################################################### 508 62253..65528: ################################################ 476 65529..68804: 1 +++ Stats for int64 upper dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 10000, avg: 32499.47, stddev: 18881.21, median 32265, min 5, max 65534 5.. 3281: ###################################################### 547 3282.. 6558: ################################################ 484 6559.. 9835: ############################################# 460 9836..13112: ################################################## 505 13113..16389: ##################################################### 536 16390..19666: ################################################# 496 19667..22943: ################################################ 492 22944..26220: ################################################# 502 26221..29497: ##################################################### 540 29498..32774: ################################################## 508 32775..36051: ####################################################### 554 36052..39328: ################################################ 491 39329..42605: ################################################# 498 42606..45882: ############################################## 467 45883..49159: ############################################ 447 49160..52436: ############################################### 475 52437..55713: ################################################## 508 55714..58990: ################################################### 515 58991..62267: ################################################# 499 62268..65544: ############################################### 476 +++ Stats for exponential 10. dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 5000, avg: 9.45, stddev: 9.82, median 6, min 0, max 79 0.. 3: ####################################################### 1631 4.. 7: ##################################### 1109 8..11: ######################### 747 12..15: ################# 512 16..19: ########## 308 20..23: ######## 251 24..27: ##### 165 28..31: ## 85 32..35: ## 64 36..39: # 43 40..43: 25 44..47: 20 48..51: 20 52..55: 3 56..59: 8 60..63: 3 64..67: 1 68..71: 2 72..75: 2 76..79: 1 +++ Stats for exponential -10. dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 5000, avg: -9.45, stddev: 9.82, median -6, min -79, max 0 -79..-76: 1 -75..-72: 2 -71..-68: 2 -67..-64: 1 -63..-60: 3 -59..-56: 8 -55..-52: 3 -51..-48: 20 -47..-44: 20 -43..-40: 25 -39..-36: # 43 -35..-32: ## 64 -31..-28: ## 85 -27..-24: ##### 165 -23..-20: ######## 251 -19..-16: ########## 308 -15..-12: ################# 512 -11.. -8: ######################### 747 -7.. -4: ##################################### 1109 -3.. 0: ####################################################### 1631 ================================================================================ 1 warning(s) failure (75 tests failed, 3 tests errored, ran 175 tests) random seed: 153870556 +++ Stats for int_dist_empty_bucket ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats dist: num: 1000, avg: -3.815e+16, stddev: 1.829e+18, median 9, min -4606614955625884935, max 4611686018427387903 -4606614955625884935..-4145699906923221320: ## 27 -4145699906923221319..-3684784858220557704: ## 22 -3684784858220557703..-3223869809517894088: ## 29 -3223869809517894087..-2762954760815230472: ## 22 -2762954760815230471..-2302039712112566856: ## 20 -2302039712112566855..-1841124663409903240: ## 22 -1841124663409903239..-1380209614707239624: ## 26 -1380209614707239623.. -919294566004576008: ## 27 -919294566004576007.. -458379517301912392: ## 24 -458379517301912391.. 2535531400751224: ####################################################### 547 2535531400751225.. 463450580103414840: ## 25 463450580103414841.. 924365628806078456: ## 25 924365628806078457.. 1385280677508742072: ## 22 1385280677508742073.. 1846195726211405688: ### 30 1846195726211405689.. 2307110774914069304: ## 27 2307110774914069305.. 2768025823616732920: # 16 2768025823616732921.. 3228940872319396536: ## 23 3228940872319396537.. 3689855921022060152: # 19 3689855921022060153.. 4150770969724723768: # 18 4150770969724723769.. 4611686018427387384: ## 28 4611686018427387385.. 4611686018427387903: 1 ================================================================================ success (ran 1 tests) qcheck-0.25/test/core/QCheck_expect_test.ml000066400000000000000000000006101477416744200207210ustar00rootroot00000000000000open QCheck_tests (* Calling runners *) let () = QCheck_base_runner.set_seed 1234 let _ = QCheck_base_runner.run_tests ~colors:false ( Overall.tests @ Generator.tests @ Shrink.tests @ Function.tests @ FindExample.tests @ Stats.tests) let () = QCheck_base_runner.set_seed 153870556 let _ = QCheck_base_runner.run_tests ~colors:false [Stats.int_dist_empty_bucket] qcheck-0.25/test/core/QCheck_tests.ml000066400000000000000000001161621477416744200175460ustar00rootroot00000000000000(** QCheck(1) tests **) (* Please add any additional tests to both [QCheck_tests.ml] and [QCheck2_tests.ml]. This ensures that both generator approaches continue to work as expected and furthermore allows us to compare their behaviour with [diff -y test/core/QCheck_expect_test.expected test/core/QCheck2_expect_test.expected] *) (** Module representing a tree data structure, used in tests *) module IntTree = struct open QCheck type tree = Leaf of int | Node of tree * tree let leaf x = Leaf x let node x y = Node (x,y) let rec depth = function | Leaf _ -> 1 | Node (x, y) -> 1 + max (depth x) (depth y) let rec print_tree = function | Leaf x -> Printf.sprintf "Leaf %d" x | Node (x, y) -> Printf.sprintf "Node (%s, %s)" (print_tree x) (print_tree y) let gen_tree = Gen.(sized @@ fix (fun self n -> match n with | 0 -> map leaf nat | n -> frequency [1, map leaf nat; 2, map2 node (self (n/2)) (self (n/2))] )) let rec shrink_tree t = match t with | Leaf l -> Iter.map (fun l' -> Leaf l') (Shrink.int l) | Node (x,y) -> let open Iter in of_list [x;y] <+> map (fun x' -> Node (x',y)) (shrink_tree x) <+> map (fun y' -> Node (x,y')) (shrink_tree y) let rec rev_tree = function | Node (x, y) -> Node (rev_tree y, rev_tree x) | Leaf x -> Leaf x let rec contains_only_n tree n = match tree with | Leaf n' -> n = n' | Node (x, y) -> contains_only_n x n && contains_only_n y n end (* tests of overall functionality *) module Overall = struct open QCheck let passing = Test.make ~name:"list_rev_is_involutive" ~count:100 ~long_factor:100 (list small_int) (fun l -> List.rev (List.rev l) = l) let failing = Test.make ~name:"should_fail_sort_id" ~count:10 (small_list small_int) (fun l -> l = List.sort compare l) let max_fail = Test.make ~name:"max_fail" ~count:1000 ~max_fail:3 (list small_nat) (fun l -> l = List.rev l) exception Error let error = Test.make ~name:"should_error_raise_exn" ~count:10 int (fun _ -> raise Error) let collect = Test.make ~name:"collect_results" ~count:100 ~long_factor:100 (make ~collect:string_of_int (Gen.int_bound 4)) (fun _ -> true) let stats = Test.make ~name:"with_stats" ~count:100 ~long_factor:100 (make (Gen.int_bound 120) ~stats:[ "mod4", (fun i->i mod 4); "num", (fun i->i); ]) (fun _ -> true) let retries = Test.make ~name:"with shrinking retries" ~retries:10 small_nat (fun i -> Printf.printf "%i %!" i; i mod 3 <> 1) let bad_assume_warn = Test.make ~name:"WARN_unlikely_precond" ~count:2_000 int (fun x -> QCheck.assume (x mod 100 = 1); true) let bad_assume_fail = Test.make ~name:"FAIL_unlikely_precond" ~count:2_000 ~if_assumptions_fail:(`Fatal, 0.1) int (fun x -> QCheck.assume (x mod 100 = 1); true) let bad_gen_fail = Test.make ~name:"FAIL_bad_gen" (make Gen.(int >>= fun j -> int_bound j >>= fun i -> return (i,j))) (fun (_i,_j) -> true) (* i may be negative, causing int_bound to fail *) let bad_shrinker_fail = Test.make ~name:"FAIL_bad_shrinker" (make ~shrink:(fun _i -> raise Error) Gen.int) (fun _i -> false) let neg_test_fail_as_expected = Test.make_neg ~name:"all ints are even" small_int (fun i -> i mod 2 = 0) let neg_test_unexpected_success = Test.make_neg ~name:"int double" small_int (fun i -> i + i = i * 2) let neg_test_fail_with_shrinking = Test.make_neg ~name:"list rev concat" (pair (list small_int) (list small_int)) (fun (is,js) -> (List.rev is)@(List.rev js) = List.rev (is@js)) let pos_test_fails_with_error = Test.make ~name:"pos fail with error" small_int (fun _i -> raise Error) let neg_test_fail_with_error = Test.make_neg ~name:"neg fail with error" small_int (fun _i -> raise Error) (* [apply_n f x n] computes f(f(...f(x))) with n applications of f *) let rec apply_n f x n = if n=0 then x else apply_n f (f x) (pred n) (* test from #236 *) let bad_fun_repro = let sleep_time = 0.175 in let count = ref 0 in Test.make ~count:10 ~name:"bad function reproducability" (set_shrink Shrink.nil (triple small_int (fun1 Observable.int small_int) small_int)) (fun (i,f,j) -> incr count; Printf.printf "(%i,fun,%i)%s%!" i j (if !count mod 10 = 0 then "\n" else " "); Unix.sleepf sleep_time; if 1 = Float.to_int (Unix.time ()) mod 2 then (ignore(apply_n (Fn.apply f) i j > 0); true) else (ignore(apply_n (Fn.apply f) i i > 0); true)) let tests = [ passing; failing; max_fail; error; collect; stats; retries; bad_assume_warn; bad_assume_fail; bad_gen_fail; (*bad_shrinker_fail;*) neg_test_fail_as_expected; neg_test_unexpected_success; neg_test_fail_with_shrinking; pos_test_fails_with_error; neg_test_fail_with_error; (* we repeat the following multiple times to check the expected output for duplicate lines *) bad_fun_repro; bad_fun_repro; bad_fun_repro; bad_fun_repro; bad_fun_repro; bad_fun_repro; bad_fun_repro; bad_fun_repro; ] end (* positive tests of the various generators *) module Generator = struct open QCheck (* example from issue #23 *) let char_dist_issue_23 = Test.make ~name:"char never produces '\\255'" ~count:1_000_000 char (fun c -> c <> '\255') let char_test = Test.make ~name:"char has right range" ~count:1000 char (fun c -> '\000' <= c && c <= '\255') let printable_test = Test.make ~name:"printable has right range" ~count:1000 printable_char (fun c -> c = '\n' || 32 <= Char.code c && Char.code c <= 126) let numeral_test = Test.make ~name:"numeral has right range" ~count:1000 numeral_char (fun c -> '0' <= c && c <= '9') let nat_test = Test.make ~name:"nat has right range" ~count:1000 (make ~print:Print.int Gen.nat) (fun n -> 0 <= n && n < 10000) let int_test = Test.make ~name:"int doubling" ~count:1000 int (fun i -> i+i = 2*i) let int32_test = Test.make ~name:"int32 doubling" ~count:1000 int32 (fun i -> Int32.add i i = Int32.mul 2l i) let int64_test = Test.make ~name:"int64 doubling" ~count:1000 int64 (fun i -> Int64.add i i = Int64.mul 2L i) let bytes_test = Test.make ~name:"bytes has right length and content" ~count:1000 bytes (fun b -> let len = Bytes.length b in 0 <= len && len < 10000 && Bytes.to_seq b |> Seq.fold_left (fun acc c -> acc && '\000' <= c && c <= '\255') true) let string_test = Test.make ~name:"string has right length and content" ~count:1000 string (fun s -> let len = String.length s in 0 <= len && len < 10000 && String.to_seq s |> Seq.fold_left (fun acc c -> acc && '\000' <= c && c <= '\255') true) let pair_test = Test.make ~name:"int pairs - commute over +" ~count:1000 (pair small_nat small_nat) (fun (i,j) -> i+j = j+i) let triple_test = Test.make ~name:"int triples - associative over +" ~count:1000 (triple small_nat small_nat small_nat) (fun (i,j,k) -> i+(j+k) = (i+j)+k) let quad_test = Test.make ~name:"int quadruples - product of sums" ~count:1000 (quad small_nat small_nat small_nat small_nat) (fun (h,i,j,k) -> (h+i)*(j+k) = h*j + h*k + i*j + i*k) let test_tup2 = Test.make ~count:10 ~name:"forall x in (0, 1): x = (0, 1)" (tup2 (always 0) (always 1)) (fun x -> x = (0, 1)) let test_tup3 = Test.make ~count:10 ~name:"forall x in (0, 1, 2): x = (0, 1, 2)" (tup3 (always 0) (always 1) (always 2)) (fun x -> x = (0, 1, 2)) let test_tup4 = Test.make ~count:10 ~name:"forall x in (0, 1, 2, 3): x = (0, 1, 2, 3)" (tup4 (always 0) (always 1) (always 2) (always 3)) (fun x -> x = (0, 1, 2, 3)) let test_tup5 = Test.make ~count:10 ~name:"forall x in (0, 1, 2, 3, 4): x = (0, 1, 2, 3, 4)" (tup5 (always 0) (always 1) (always 2) (always 3) (always 4)) (fun x -> x = (0, 1, 2, 3, 4)) let test_tup6 = Test.make ~count:10 ~name:"forall x in (0, 1, 2, 3, 4, 5): x = (0, 1, 2, 3, 4, 5)" (tup6 (always 0) (always 1) (always 2) (always 3) (always 4) (always 5)) (fun x -> x = (0, 1, 2, 3, 4, 5)) let test_tup7 = Test.make ~count:10 ~name:"forall x in (0, 1, 2, 3, 4, 5, 6): x = (0, 1, 2, 3, 4, 5, 6)" (tup7 (always 0) (always 1) (always 2) (always 3) (always 4) (always 5) (always 6)) (fun x -> x = (0, 1, 2, 3, 4, 5, 6)) let test_tup8 = Test.make ~count:10 ~name:"forall x in (0, 1, 2, 3, 4, 5, 6, 7): x = (0, 1, 2, 3, 4, 5, 6, 7)" (tup8 (always 0) (always 1) (always 2) (always 3) (always 4) (always 5) (always 6) (always 7)) (fun x -> x = (0, 1, 2, 3, 4, 5, 6, 7)) let test_tup9 = Test.make ~count:10 ~name:"forall x in (0, 1, 2, 3, 4, 5, 6, 7, 8): x = (0, 1, 2, 3, 4, 5, 6, 7, 8)" (tup9 (always 0) (always 1) (always 2) (always 3) (always 4) (always 5) (always 6) (always 7) (always 8)) (fun x -> x = (0, 1, 2, 3, 4, 5, 6, 7, 8)) let bind_test = Test.make ~name:"bind test for ordered pairs" ~count:1000 (make Gen.(small_nat >>= fun j -> int_bound j >>= fun i -> return (i,j))) (fun (i,j) -> i<=j) let bind_pair_list_length = Test.make ~name:"bind list length" ~count:1000 (make Gen.(int_bound 1000 >>= fun len -> list_size (return len) (int_bound 1000) >>= fun xs -> return (len,xs))) (fun (len,xs) -> len = List.length xs) let list_test = Test.make ~name:"list has right length" ~count:1000 (list unit) (fun l -> let len = List.length l in 0 <= len && len < 10_000) let list_repeat_test = let gen = Gen.(small_nat >>= fun i -> list_repeat i unit >>= fun l -> return (i,l)) in Test.make ~name:"list_repeat has constant length" ~count:1000 (make ~print:Print.(pair int (list unit)) gen) (fun (i,l) -> List.length l = i) let array_repeat_test = let gen = Gen.(small_nat >>= fun i -> array_repeat i unit >>= fun l -> return (i,l)) in Test.make ~name:"array_repeat has constant length" ~count:1000 (make ~print:Print.(pair int (array unit)) gen) (fun (i,l) -> Array.length l = i) let int_option_test = Test.make ~name:"int option right range" ~count:1000 (option (int_bound 1000)) (function None -> true | Some i -> 0 <= i && i <= 1000) let int_string_result_test = Test.make ~name:"(int,string) result right range" ~count:1000 (result (int_bound 1000) string_small) (function Ok i -> 0 <= i && i <= 1000 | Error s -> String.length s < 100) let passing_tree_rev = Test.make ~name:"tree_rev_is_involutive" ~count:1000 (make IntTree.gen_tree) (fun tree -> IntTree.(rev_tree (rev_tree tree)) = tree) let nat_split2_spec = Test.make ~name:"nat_split2 spec" (make ~print:Print.(pair int (pair int int)) Gen.(small_nat >>= fun n -> pair (return n) (nat_split2 n))) (fun (n, (a, b)) -> 0 <= a && 0 <= b && a + b = n) let pos_split2_spec = Test.make ~name:"pos_split2 spec" (make ~print:Print.(pair int (pair int int)) Gen.(small_nat >>= fun n -> (* we need n > 2 *) let n = n + 2 in pair (return n) (pos_split2 n))) (fun (n, (a, b)) -> (0 < a && 0 < b && a + b = n)) let range_subset_spec = Test.make ~name:"range_subset_spec" (make ~print:Print.(quad int int int (array int)) Gen.(pair small_nat small_nat >>= fun (m, n) -> (* we must guarantee [low <= high] and [size <= high - low + 1] *) let low = m and high = m + n in int_range 0 (high - low + 1) >>= fun size -> quad (return size) (return low) (return high) (range_subset ~size low high))) (fun (size, low, high, arr) -> if size = 0 then arr = [||] else Array.length arr = size && low <= arr.(0) && Array.for_all (fun (a, b) -> a < b) (Array.init (size - 1) (fun k -> arr.(k), arr.(k+1))) && arr.(size - 1) <= high) let nat_split_n_way = Test.make ~name:"nat_split n-way" (make ~print:Print.(pair int (array int)) Gen.(small_nat >>= fun n -> pair (return n) (nat_split ~size:n n))) (fun (n, arr) -> Array.length arr = n && Array.for_all (fun k -> 0 <= k) arr && Array.fold_left (+) 0 arr = n) let nat_split_smaller = Test.make ~name:"nat_split smaller" (make ~print:Print.(triple int int (array int)) Gen.(small_nat >>= fun size -> int_bound size >>= fun n -> triple (return size) (return n) (nat_split ~size n))) (fun (m, n, arr) -> Array.length arr = m && Array.for_all (fun k -> 0 <= k) arr && Array.fold_left (+) 0 arr = n) let pos_split = Test.make ~name:"pos_split" (make ~print:Print.(triple int int (array int)) Gen.(pair small_nat small_nat >>= fun (m, n) -> (* we need both size>0 and n>0 and size <= n *) let size = 1 + min m n and n = 1 + max m n in triple (return size) (return n) (pos_split ~size n))) (fun (m, n, arr) -> Array.length arr = m && Array.for_all (fun k -> 0 < k) arr && Array.fold_left (+) 0 arr = n) let tests = [ char_dist_issue_23; char_test; printable_test; numeral_test; nat_test; int_test; int32_test; int64_test; bytes_test; string_test; pair_test; triple_test; quad_test; test_tup2; test_tup3; test_tup4; test_tup5; test_tup6; test_tup7; test_tup8; test_tup9; bind_test; bind_pair_list_length; list_test; list_repeat_test; array_repeat_test; int_option_test; int_string_result_test; passing_tree_rev; nat_split2_spec; pos_split2_spec; range_subset_spec; nat_split_n_way; nat_split_smaller; pos_split; ] end (* negative tests that exercise shrinking behaviour *) module Shrink = struct open QCheck let rec fac n = match n with | 0 -> 1 | n -> n * fac (n - 1) (* example from issue #59 *) let test_fac_issue59 = Test.make ~name:"test fac issue59" (set_shrink Shrink.nil (small_int_corners ())) (fun n -> try (fac n) mod n = 0 with (*| Stack_overflow -> false*) | Division_by_zero -> (n=0)) let big_bound_issue59 = Test.make ~name:"big bound issue59" (small_int_corners()) (fun i -> i < 209609) let long_shrink = let listgen = list_of_size (Gen.int_range 1000 10000) int in Test.make ~name:"long_shrink" (pair listgen listgen) (fun (xs,ys) -> List.rev (xs@ys) = (List.rev xs)@(List.rev ys)) (* test from issue #36 *) let ints_arent_0_mod_3 = Test.make ~name:"ints arent 0 mod 3" ~count:1000 int (fun i -> i mod 3 <> 0) let ints_are_0 = Test.make ~name:"ints are 0" ~count:1000 int (fun i -> Printf.printf "%i\n" i; i = 0) let int32s_arent_0l_rem_3l = Test.make ~name:"int32s arent 0l rem 3l" ~count:1000 int32 (fun i -> Int32.rem i 3l <> 0l) let int32s_are_0l = Test.make ~name:"int32s are 0l" ~count:1000 int32 (fun i -> i = 0l) let int64s_arent_0L_rem_3L = Test.make ~name:"int64s arent 0L rem 3L" ~count:1000 int64 (fun i -> Int64.rem i 3L <> 0L) let int64s_are_0L = Test.make ~name:"int64s are 0L" ~count:1000 int64 (fun i -> i = 0L) (* test from issue #59 *) let ints_smaller_209609 = Test.make ~name:"ints < 209609" (small_int_corners()) (fun i -> i < 209609) let nats_smaller_5001 = Test.make ~name:"nat < 5001" ~count:1000 (make ~print:Print.int ~shrink:Shrink.int Gen.nat) (fun n -> n < 5001) let char_is_never_abcdef = Test.make ~name:"char never produces 'abcdef'" ~count:1000 char (fun c -> not (List.mem c ['a';'b';'c';'d';'e';'f'])) let printable_is_never_sign = (* should shrink towards 'a', hence produce '&' with highest ascii code 38 *) Test.make ~name:"printable never produces '!\"#$%&'" ~count:1000 printable_char (fun c -> not (List.mem c ['!';'"';'#';'$';'%';'&'])) let numeral_is_never_less_5 = Test.make ~name:"printable never produces less than '5" ~count:1000 numeral_char (fun c -> c >= '5') let bytes_are_empty = Test.make ~name:"bytes are empty" ~count:1000 bytes (fun b -> b = Bytes.empty) let bytes_never_has_000_char = Test.make ~name:"bytes never has a \\000 char" ~count:1000 bytes (fun b -> Bytes.to_seq b |> Seq.fold_left (fun acc c -> acc && c <> '\000') true) let bytes_never_has_255_char = Test.make ~name:"bytes never has a \\255 char" ~count:1000 bytes (fun s -> Bytes.to_seq s |> Seq.fold_left (fun acc c -> acc && c <> '\255') true) let bytes_unique_chars = Test.make ~name:"bytes have unique chars" ~count:1000 bytes (fun s -> let ch_list = Bytes.to_seq s |> List.of_seq in List.length ch_list = List.length (List.sort_uniq Char.compare ch_list)) let strings_are_empty = Test.make ~name:"strings are empty" ~count:1000 string (fun s -> s = "") let string_never_has_000_char = Test.make ~name:"string never has a \\000 char" ~count:1000 string (fun s -> String.to_seq s |> Seq.fold_left (fun acc c -> acc && c <> '\000') true) let string_never_has_255_char = Test.make ~name:"string never has a \\255 char" ~count:1000 string (fun s -> String.to_seq s |> Seq.fold_left (fun acc c -> acc && c <> '\255') true) let string_unique_chars = Test.make ~name:"strings have unique chars" ~count:1000 string (fun s -> let ch_list = String.to_seq s |> List.of_seq in List.length ch_list = List.length (List.sort_uniq Char.compare ch_list)) (* test from issue #167 *) let pair_diff_issue_64 = Test.make ~name:"pairs have different components" (pair small_int small_int) (fun (i,j) -> i<>j) let pair_same = Test.make ~name:"pairs have same components" (pair int int) (fun (i,j) -> i=j) let pair_one_zero = Test.make ~name:"pairs have a zero component" (pair int int) (fun (i,j) -> i=0 || j=0) let pair_all_zero = Test.make ~name:"pairs are (0,0)" (pair int int) (fun (i,j) -> i=0 && j=0) let pair_ordered = Test.make ~name:"pairs are ordered" (pair pos_int pos_int) (fun (i,j) -> i<=j) let pair_ordered_rev = Test.make ~name:"pairs are ordered reversely" (pair pos_int pos_int) (fun (i,j) -> i>=j) let pair_sum_lt_128 = Test.make ~name:"pairs sum to less than 128" (pair pos_int pos_int) (fun (i,j) -> i+j<128) let pair_lists_rev_concat = Test.make ~name:"pairs lists rev concat" (pair (list pos_int) (list pos_int)) (fun (xs,ys) -> List.rev (xs@ys) = (List.rev xs)@(List.rev ys)) let pair_lists_no_overlap = Test.make ~name:"pairs lists no overlap" (pair (list small_nat) (list small_nat)) (fun (xs,ys) -> List.for_all (fun x -> not (List.mem x ys)) xs) let triple_diff = Test.make ~name:"triples have pair-wise different components" (triple small_int small_int small_int) (fun (i,j,k) -> i<>j && j<>k) let triple_same = Test.make ~name:"triples have same components" (triple int int int) (fun (i,j,k) -> i=j || j=k) let triple_ordered = Test.make ~name:"triples are ordered" (triple int int int) (fun (i,j,k) -> i<=j && j<=k) let triple_ordered_rev = Test.make ~name:"triples are ordered reversely" (triple int int int) (fun (i,j,k) -> i>=j && j>=k) let quad_diff = Test.make ~name:"quadruples have pair-wise different components" (quad small_int small_int small_int small_int) (fun (h,i,j,k) -> h<>i && i<>j && j<>k) let quad_same = Test.make ~name:"quadruples have same components" (quad int int int int) (fun (h,i,j,k) -> h=i || i=j || j=k) let quad_ordered = Test.make ~name:"quadruples are ordered" (quad int int int int) (fun (h,i,j,k) -> h <= i && i <= j && j <= k) let quad_ordered_rev = Test.make ~name:"quadruples are ordered reversely" (quad int int int int) (fun (h,i,j,k) -> h >= i && i >= j && j >= k) let test_tup2 = Test.make ~name:"forall (a, b) in nat: a < b" (tup2 small_int small_int) (fun (a, b) -> a < b) let test_tup3 = Test.make ~name:"forall (a, b, c) in nat: a < b < c" (tup3 small_int small_int small_int) (fun (a, b, c) -> a < b && b < c) let test_tup4 = Test.make ~name:"forall (a, b, c, d) in nat: a < b < c < d" (tup4 small_int small_int small_int small_int) (fun (a, b, c, d) -> a < b && b < c && c < d) let test_tup5 = Test.make ~name:"forall (a, b, c, d, e) in nat: a < b < c < d < e" (tup5 small_int small_int small_int small_int small_int) (fun (a, b, c, d, e) -> a < b && b < c && c < d && d < e) let test_tup6 = Test.make ~name:"forall (a, b, c, d, e, f) in nat: a < b < c < d < e < f" (tup6 small_int small_int small_int small_int small_int small_int) (fun (a, b, c, d, e, f) -> a < b && b < c && c < d && d < e && e < f) let test_tup7 = Test.make ~name:"forall (a, b, c, d, e, f, g) in nat: a < b < c < d < e < f < g" (tup7 small_int small_int small_int small_int small_int small_int small_int) (fun (a, b, c, d, e, f, g) -> a < b && b < c && c < d && d < e && e < f && f < g) let test_tup8 = Test.make ~name:"forall (a, b, c, d, e, f, g, h) in nat: a < b < c < d < e < f < g < h" (tup8 small_int small_int small_int small_int small_int small_int small_int small_int) (fun (a, b, c, d, e, f, g, h) -> a < b && b < c && c < d && d < e && e < f && f < g && g < h) let test_tup9 = Test.make ~name:"forall (a, b, c, d, e, f, g, h, i) in nat: a < b < c < d < e < f < g < h < i" (tup9 small_int small_int small_int small_int small_int small_int small_int small_int small_int) (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) let bind_pair_ordered = Test.make ~name:"bind ordered pairs" (make ~print:Print.(pair int int) ~shrink:Shrink.(filter (fun (i,j) -> i<=j) (pair int int)) Gen.(pint >>= fun j -> int_bound j >>= fun i -> return (i,j))) (fun (_i,_j) -> false) let bind_pair_list_size = let shrink (_l,xs) = Iter.map (fun xs' -> (List.length xs',xs')) Shrink.(list ~shrink:int xs) in Test.make ~name:"bind list_size constant" (make ~print:Print.(pair int (list int)) ~shrink Gen.(int_bound 1000 >>= fun len -> list_size (return len) (int_bound 1000) >>= fun xs -> return (len,xs))) (fun (len,xs) -> let len' = List.length xs in len=len' && len' < 4) let print_list xs = print_endline Print.(list int xs) (* test from issue #64 *) let lists_are_empty_issue_64 = Test.make ~name:"lists are empty" (list small_int) (fun xs -> print_list xs; xs = []) let list_shorter_10 = Test.make ~name:"lists shorter than 10" (list small_int) (fun xs -> List.length xs < 10) let length_printer xs = Printf.sprintf "[...] list length: %i" (List.length xs) let size_gen = Gen.(oneof [small_nat; int_bound 750_000]) let list_shorter_432 = Test.make ~name:"lists shorter than 432" (set_print length_printer (list_of_size size_gen small_int)) (fun xs -> List.length xs < 432) let list_shorter_4332 = Test.make ~name:"lists shorter than 4332" (set_shrink Shrink.list_spine (set_print length_printer (list_of_size size_gen small_int))) (fun xs -> List.length xs < 4332) let list_equal_dupl = Test.make ~name:"lists equal to duplication" (list_of_size size_gen small_int) (fun xs -> try xs = xs @ xs with Stack_overflow -> false) let list_unique_elems = Test.make ~name:"lists have unique elems" (list small_int) (fun xs -> let ys = List.sort_uniq Int.compare xs in print_list xs; List.length xs = List.length ys) let int_option_are_none = Test.make ~name:"int option are none" ~count:1000 (option (int_bound 1000)) (function None -> true | Some _ -> false) let int_option_are_some_100_or_more = Test.make ~name:"int option are some 100 or more" ~count:1000 (option (int_bound 1000)) (function None -> false | Some i -> i >= 100) let int_string_result_are_ok = Test.make ~name:"(int,string) result are Ok" ~count:1000 (result (int_bound 1000) string_small) (function Ok _ -> true | Error _ -> false) let int_string_result_are_error = Test.make ~name:"(int,string) result are Error" ~count:1000 (result (int_bound 1000) string_small) (function Ok _ -> false | Error _ -> true) let tree_contains_only_42 = Test.make ~name:"tree contains only 42" IntTree.(make ~print:print_tree ~shrink:shrink_tree gen_tree) (fun tree -> IntTree.contains_only_n tree 42) let test_gen_no_shrink = Test.make ~name:"sum list = 0" (set_shrink Shrink.nil (list small_int)) (fun xs -> List.fold_left (+) 0 xs = 0) let tests = [ (*test_fac_issue59;*) big_bound_issue59; long_shrink; ints_arent_0_mod_3; ints_are_0; int32s_arent_0l_rem_3l; int32s_are_0l; int64s_arent_0L_rem_3L; int64s_are_0L; ints_smaller_209609; nats_smaller_5001; char_is_never_abcdef; printable_is_never_sign; numeral_is_never_less_5; bytes_are_empty; bytes_never_has_000_char; bytes_never_has_255_char; bytes_unique_chars; strings_are_empty; string_never_has_000_char; string_never_has_255_char; string_unique_chars; pair_diff_issue_64; pair_same; pair_one_zero; pair_all_zero; pair_ordered; pair_ordered_rev; pair_sum_lt_128; pair_lists_rev_concat; pair_lists_no_overlap; triple_diff; triple_same; triple_ordered; triple_ordered_rev; quad_diff; quad_same; quad_ordered; quad_ordered_rev; test_tup2; test_tup3; test_tup4; test_tup5; test_tup6; test_tup7; test_tup8; test_tup9; bind_pair_ordered; bind_pair_list_size; lists_are_empty_issue_64; list_shorter_10; list_shorter_432; list_shorter_4332; (*list_equal_dupl;*) list_unique_elems; int_option_are_none; int_option_are_some_100_or_more; int_string_result_are_ok; int_string_result_are_error; tree_contains_only_42; test_gen_no_shrink; ] end (* tests function generator and shrinker *) module Function = struct open QCheck let fail_pred_map_commute_int = Test.make ~name:"fail_pred_map_commute_int" ~count:100 ~long_factor:100 (triple (small_list small_int) (fun1 Observable.int int) (fun1 Observable.int bool)) (fun (l,Fun (_,f),Fun (_,p)) -> List.filter p (List.map f l) = List.map f (List.filter p l)) let fail_pred_map_commute_int32 = Test.make ~name:"fail_pred_map_commute_int32" ~count:100 ~long_factor:100 (triple (small_list int32) (fun1 Observable.int32 int32) (fun1 Observable.int32 bool)) (fun (l,Fun (_,f),Fun (_,p)) -> List.filter p (List.map f l) = List.map f (List.filter p l)) let fail_pred_map_commute_int64 = Test.make ~name:"fail_pred_map_commute_int64" ~count:100 ~long_factor:100 (triple (small_list int64) (fun1 Observable.int64 int64) (fun1 Observable.int64 bool)) (fun (l,Fun (_,f),Fun (_,p)) -> List.filter p (List.map f l) = List.map f (List.filter p l)) let fail_pred_strings = Test.make ~name:"fail_pred_strings" ~count:100 (fun1 Observable.string bool) (fun (Fun (_,p)) -> not (p "some random string") || p "some other string") let int_gen = small_nat (* int *) (* Another example (false) property *) let prop_foldleft_foldright = Test.make ~name:"fold_left fold_right" ~count:1000 ~long_factor:20 (triple int_gen (list int_gen) (fun2 Observable.int Observable.int int_gen)) (fun (z,xs,f) -> let l1 = List.fold_right (Fn.apply f) xs z in let l2 = List.fold_left (Fn.apply f) z xs in if l1=l2 then true else Test.fail_reportf "l=%s, fold_left=%s, fold_right=%s@." (Print.(list int) xs) (Print.int l1) (Print.int l2) ) (* Another example (false) property *) let prop_foldleft_foldright_uncurry = Test.make ~name:"fold_left fold_right uncurried" ~count:1000 ~long_factor:20 (triple (fun1 Observable.(pair int int) int_gen) int_gen (list int_gen)) (fun (f,z,xs) -> List.fold_right (fun x y -> Fn.apply f (x,y)) xs z = List.fold_left (fun x y -> Fn.apply f (x,y)) z xs) (* Same as the above (false) property, but generating+shrinking functions last *) let prop_foldleft_foldright_uncurry_funlast = Test.make ~name:"fold_left fold_right uncurried fun last" ~count:1000 ~long_factor:20 (triple int_gen (list int_gen) (fun1 Observable.(pair int int) int_gen)) (fun (z,xs,f) -> List.fold_right (fun x y -> Fn.apply f (x,y)) xs z = List.fold_left (fun x y -> Fn.apply f (x,y)) z xs) (* test from issue #64 *) let fold_left_test = Test.make ~name:"fold_left test, fun first" (quad (* string -> int -> string *) (fun2 Observable.string Observable.int small_string) small_string (list small_int) (list small_int)) (fun (f,acc,is,js) -> let f = Fn.apply f in List.fold_left f acc (is @ js) = List.fold_left f (List.fold_left f acc is) is) (*Typo*) let tests = [ fail_pred_map_commute_int; fail_pred_map_commute_int32; fail_pred_map_commute_int64; fail_pred_strings; prop_foldleft_foldright; prop_foldleft_foldright_uncurry; prop_foldleft_foldright_uncurry_funlast; fold_left_test; ] end (* tests of (inner) find_example(_gen) behaviour *) module FindExample = struct open QCheck let find_ex = Test.make ~name:"find_example" (2--50) (fun n -> let st = Random.State.make [| 0 |] in let f m = n < m && m < 2 * n in try let m = find_example_gen ~rand:st ~count:100_000 ~f Gen.(0 -- 1000) in f m with No_example_found _ -> false) let find_ex_uncaught_issue_99_1_fail = let rs = make (find_example ~count:10 ~f:(fun _ -> false) Gen.int) in Test.make ~name:"FAIL_#99_1" rs (fun _ -> true) let find_ex_uncaught_issue_99_2_succeed = Test.make ~name:"should_succeed_#99_2" ~count:10 int (fun i -> i <= max_int) let tests = [ find_ex; find_ex_uncaught_issue_99_1_fail; find_ex_uncaught_issue_99_2_succeed; ] end (* tests of statistics and histogram display *) module Stats = struct open QCheck let bool_dist = Test.make ~name:"bool dist" ~count:500_000 (set_collect Bool.to_string bool) (fun _ -> true) let char_dist_tests = [ Test.make ~name:"char code dist" ~count:500_000 (add_stat ("char code", Char.code) char) (fun _ -> true); Test.make ~name:"printable char code dist" ~count:500_000 (add_stat ("char code", Char.code) printable_char) (fun _ -> true); Test.make ~name:"numeral char code dist" ~count:500_000 (add_stat ("char code", Char.code) numeral_char) (fun _ -> true); ] let bytes_len_tests = let len = ("len",Bytes.length) in [ Test.make ~name:"bytes_size len dist" ~count:5_000 (add_stat len (bytes_of_size (Gen.int_range 5 10))) (fun _ -> true); Test.make ~name:"bytes len dist" ~count:5_000 (add_stat len bytes) (fun _ -> true); Test.make ~name:"bytes_of len dist" ~count:5_000 (add_stat len (bytes_of (Gen.return 'a'))) (fun _ -> true); Test.make ~name:"bytes_small len dist" ~count:5_000 (add_stat len bytes_small) (fun _ -> true); ] let string_len_tests = let len = ("len",String.length) in [ Test.make ~name:"string_size len dist" ~count:5_000 (add_stat len (string_of_size (Gen.int_range 5 10))) (fun _ -> true); Test.make ~name:"string len dist" ~count:5_000 (add_stat len string) (fun _ -> true); Test.make ~name:"string_of len dist" ~count:5_000 (add_stat len (string_of (Gen.return 'a'))) (fun _ -> true); Test.make ~name:"printable_string len dist" ~count:5_000 (add_stat len printable_string) (fun _ -> true); Test.make ~name:"small_string len dist" ~count:5_000 (add_stat len small_string) (fun _ -> true); ] let pair_dist = Test.make ~name:"pair dist" ~count:500_000 (add_stat ("pair sum", (fun (i,j) -> i+j)) (pair (int_bound 100) (int_bound 100))) (fun _ -> true) let triple_dist = Test.make ~name:"triple dist" ~count:500_000 (add_stat ("triple sum", (fun (i,j,k) -> i+j+k)) (triple (int_bound 100) (int_bound 100) (int_bound 100))) (fun _ -> true) let quad_dist = Test.make ~name:"quad dist" ~count:500_000 (add_stat ("quad sum", (fun (h,i,j,k) -> h+i+j+k)) (quad (int_bound 100) (int_bound 100) (int_bound 100) (int_bound 100))) (fun _ -> true) let bind_dist = Test.make ~name:"bind dist" ~count:1_000_000 (make ~stats:[("ordered pair difference", (fun (i,j) -> j-i));("ordered pair sum", (fun (i,j) -> i+j))] Gen.(int_bound 100 >>= fun j -> int_bound j >>= fun i -> return (i,j))) (fun _ -> true) let option_dist = Test.make ~name:"option dist" ~count:10_000 (set_collect (function None -> "None " | Some _ -> "Some _") (option int)) (fun _ -> true) let result_dist = Test.make ~name:"result dist" ~count:10_000 (set_collect (function Ok _ -> "Ok _ " | Error _ -> "Error _") (result int string)) (fun _ -> true) let list_len_tests = let len = ("len",List.length) in [ (* test from issue #30 *) Test.make ~name:"list len dist" ~count:5_000 (add_stat len (list int)) (fun _ -> true); Test.make ~name:"small_list len dist" ~count:5_000 (add_stat len (small_list int)) (fun _ -> true); Test.make ~name:"list_of_size len dist" ~count:5_000 (add_stat len (list_of_size (Gen.int_range 5 10) int)) (fun _ -> true); Test.make ~name:"list_repeat len dist" ~count:5_000 (add_stat len (make Gen.(list_repeat 42 int))) (fun _ -> true); ] let array_len_tests = let len = ("len",Array.length) in [ Test.make ~name:"array len dist" ~count:5_000 (add_stat len (array int)) (fun _ -> true); Test.make ~name:"small_array len dist" ~count:5_000 (add_stat len (make Gen.(small_array int))) (fun _ -> true); Test.make ~name:"array_of_size len dist" ~count:5_000 (add_stat len (array_of_size (Gen.int_range 5 10) int)) (fun _ -> true); Test.make ~name:"array_repeat len dist" ~count:5_000 (add_stat len (make Gen.(array_repeat 42 int))) (fun _ -> true); ] let int_dist_tests = let dist = ("dist",fun x -> x) in [ (* test from issue #40 *) Test.make ~name:"int_stats_neg" ~count:5000 (add_stat dist small_signed_int) (fun _ -> true); (* distribution tests from PR #45 *) Test.make ~name:"small_signed_int dist" ~count:1000 (add_stat dist small_signed_int) (fun _ -> true); Test.make ~name:"small_nat dist" ~count:1000 (add_stat dist small_nat) (fun _ -> true); Test.make ~name:"nat dist" ~count:1000 (add_stat dist (make Gen.nat)) (fun _ -> true); Test.make ~name:"int_range (-43643) 435434 dist" ~count:1000 (add_stat dist (int_range (-43643) 435434)) (fun _ -> true); Test.make ~name:"int_range (-40000) 40000 dist" ~count:1000 (add_stat dist (int_range (-40000) 40000)) (fun _ -> true); Test.make ~name:"int_range (-4) 4 dist" ~count:1000 (add_stat dist (int_range (-4) 4)) (fun _ -> true); Test.make ~name:"int_range (-4) 17 dist" ~count:1000 (add_stat dist (int_range (-4) 17)) (fun _ -> true); Test.make ~name:"int dist" ~count:100000 (add_stat dist int) (fun _ -> true); Test.make ~name:"oneof int dist" ~count:1000 (add_stat dist (oneofl[min_int;-1;0;1;max_int])) (fun _ -> true); ] let int_32_64_dist_tests = let add_stat32 shift arb = add_stat ("dist",fun i -> Int32.(to_int (logand 0xffffl (shift i)))) arb in let add_stat64 shift arb = add_stat ("dist",fun i -> Int64.(to_int (logand 0xffffL (shift i)))) arb in [ (* stats are int-based, so for these to work for 31-bit ints, consider blocks of 16 bits *) Test.make ~name:"int32 lower dist" ~count:10000 (add_stat32 (fun i -> i) int32) (fun _ -> true); Test.make ~name:"int32 upper dist" ~count:10000 (add_stat32 (fun i -> Int32.shift_right_logical i 16) int32) (fun _ -> true); Test.make ~name:"int64 lower dist" ~count:10000 (add_stat64 (fun i -> i) int64) (fun _ -> true); Test.make ~name:"int64 lower-mid dist" ~count:10000 (add_stat64 (fun i -> Int64.shift_right i 16) int64) (fun _ -> true); Test.make ~name:"int64 upper-mid dist" ~count:10000 (add_stat64 (fun i -> Int64.shift_right i 32) int64) (fun _ -> true); Test.make ~name:"int64 upper dist" ~count:10000 (add_stat64 (fun i -> Int64.shift_right_logical i 48) int64) (fun _ -> true); ] let exponential_tests = let float_dist = ("dist",int_of_float) in [ Test.make ~name:"exponential 10. dist" ~count:5_000 (add_stat float_dist (exponential 10.)) (fun _ -> true); Test.make ~name:"exponential -10. dist" ~count:5_000 (add_stat float_dist (exponential (-10.))) (fun _ -> true); ] let tree_depth_test = let depth = ("depth", IntTree.depth) in Test.make ~name:"tree's depth" ~count:1000 (add_stat depth (make IntTree.gen_tree)) (fun _ -> true) let range_subset_test = Test.make ~name:"range_subset_spec" ~count:5_000 (add_stat ("dist", fun a -> a.(0)) (make (Gen.range_subset ~size:1 0 20))) (fun a -> Array.length a = 1) let int_dist_empty_bucket = Test.make ~name:"int_dist_empty_bucket" ~count:1_000 (add_stat ("dist",fun x -> x) (oneof [small_int_corners ();int])) (fun _ -> true) let tests = [ bool_dist; ] @ char_dist_tests @ [tree_depth_test; range_subset_test;] @ bytes_len_tests @ string_len_tests @ [pair_dist; triple_dist; quad_dist; bind_dist; option_dist; result_dist;] @ list_len_tests @ array_len_tests @ int_dist_tests @ int_32_64_dist_tests @ exponential_tests end qcheck-0.25/test/core/QCheck_unit_tests.ml000066400000000000000000000431611477416744200206030ustar00rootroot00000000000000open QCheck module Shrink = struct let trace_false shrinker x = let res = ref [] in shrinker x (fun x -> res := x::!res); List.rev !res let trace_true shrinker x = let rec loop x = match Iter.find (fun _ -> true) (shrinker x) with | None -> [] | Some y -> y::loop y in loop x let alco_check typ func msg_suffix (msg,input,expected) = Alcotest.(check (list typ)) (msg ^ " - " ^ msg_suffix) expected (func input) let test_bool () = List.iter (alco_check Alcotest.bool (trace_false Shrink.bool) "on repeated failure") [ ("bool true", true, [false]); ("bool false", false, []) ]; List.iter (alco_check Alcotest.bool (trace_true Shrink.bool) "on repeated success") [ ("bool true", true, [false]); ("bool false", false, []) ] let test_int () = List.iter (alco_check Alcotest.int (trace_false Shrink.int) "on repeated failure") [ ("int 100", 100, [50; 75; 88; 94; 97; 99]); ("int 1000", 1000, [500; 750; 875; 938; 969; 985; 993; 997; 999]); ("int (-26)", -26, [-13; -20; -23; -25]) ]; List.iter (alco_check Alcotest.int (trace_true Shrink.int) "on repeated success") [ ("int 100", 100, [50; 25; 13; 7; 4; 2; 1; 0]); ("int 1000", 1000, [500; 250; 125; 63; 32; 16; 8; 4; 2; 1; 0]); ("int (-26)", -26, [-13; -7; -4; -2; -1; 0]) ] let test_int32 () = List.iter (alco_check Alcotest.int32 (trace_false Shrink.int32) "on repeated failure") [ ("int 100", 100l, [50l; 75l; 88l; 94l; 97l; 99l]); ("int 1000", 1000l, [500l; 750l; 875l; 938l; 969l; 985l; 993l; 997l; 999l]); ("int (-26)", -26l, [-13l; -20l; -23l; -25l]) ]; List.iter (alco_check Alcotest.int32 (trace_true Shrink.int32) "on repeated success") [ ("int 100", 100l, [50l; 25l; 13l; 7l; 4l; 2l; 1l; 0l]); ("int 1000", 1000l, [500l; 250l; 125l; 63l; 32l; 16l; 8l; 4l; 2l; 1l; 0l]); ("int (-26)", -26l, [-13l; -7l; -4l; -2l; -1l; 0l]) ] let test_int64 () = List.iter (alco_check Alcotest.int64 (trace_false Shrink.int64) "on repeated failure") [ ("int 100", 100L, [50L; 75L; 88L; 94L; 97L; 99L]); ("int 1000", 1000L, [500L; 750L; 875L; 938L; 969L; 985L; 993L; 997L; 999L]); ("int (-26)", -26L, [-13L; -20L; -23L; -25L]) ]; List.iter (alco_check Alcotest.int64 (trace_true Shrink.int64) "on repeated success") [ ("int 100", 100L, [50L; 25L; 13L; 7L; 4L; 2L; 1L; 0L]); ("int 1000", 1000L, [500L; 250L; 125L; 63L; 32L; 16L; 8L; 4L; 2L; 1L; 0L]); ("int (-26)", -26L, [-13L; -7L; -4L; -2L; -1L; 0L]) ] let test_char () = List.iter (alco_check Alcotest.char (trace_false Shrink.char) "on repeated failure") [ ("char 'a'", 'a', []); ("char 'z'", 'z', ['n'; 't'; 'w'; 'y']); ("char 'A'", 'A', ['Q'; 'I'; 'E'; 'C'; 'B']); ("char '~'", '~', ['p'; 'w'; '{'; '}']) ]; List.iter (alco_check Alcotest.char (trace_true Shrink.char) "on repeated success") [ ("char 'a'", 'a', []); ("char 'z'", 'z', ['n'; 'h'; 'e'; 'c'; 'b'; 'a']); ("char 'A'", 'A', ['Q'; 'Y'; ']'; '_'; '`'; 'a']); ("char '~'", '~', ['p'; 'i'; 'e'; 'c'; 'b'; 'a']); ] let test_char_numeral () = List.iter (alco_check Alcotest.char (trace_false Shrink.char_numeral) "on repeated failure") [ ("char '0'", '0', []); ("char '9'", '9', ['5'; '7'; '8']) ]; List.iter (alco_check Alcotest.char (trace_true Shrink.char_numeral) "on repeated success") [ ("char '0'", '0', []); ("char '9'", '9', ['5'; '3'; '2'; '1'; '0']); ] let test_char_printable () = List.iter (alco_check Alcotest.char (trace_false Shrink.char_printable) "on repeated failure") [ ("char 'A'", 'A', ['Q'; 'I'; 'E'; 'C'; 'B']); ("char 'a'", 'a', []); ("char ' '", ' ', ['@'; '0'; '('; '$'; '"'; '!']); ("char '~'", '~', ['p'; 'w'; '{'; '}']); ("char '\\n'", '\n', ['p'; 'w'; '{'; '}']); ]; List.iter (alco_check Alcotest.char (trace_true Shrink.char_printable) "on repeated success") [ ("char 'A'", 'A', ['Q'; 'Y'; ']'; '_'; '`'; 'a']); ("char 'a'", 'a', []); ("char ' '", ' ', ['@'; 'P'; 'X'; '\\'; '^'; '_'; '`'; 'a']); ("char '~'", '~', ['p'; 'i'; 'e'; 'c'; 'b'; 'a']); ("char '\\n'", '\n', ['p'; 'i'; 'e'; 'c'; 'b'; 'a']); ] let test_string () = List.iter (alco_check Alcotest.string (trace_false Shrink.string) "on repeated failure") [ ("string \"\"", "", []); ("string \"a\"", "a", [""]); ("string \"aa\"", "aa", [""; "a"]); ("string \"aaaa\"", "aaaa", ["aa"; "aa"; "aaa"]); ("string \"abcd\"", "abcd", ["ab"; "cd"; "acd"; "bcd"; "aacd"; "abbd"; "abcc"]); ("string \"E'*\"", "E'*", ["E'"; "*"; "E*"; "'*"; "S'*"; "L'*"; "H'*"; "F'*"; "ED*"; "E5*"; "E.*"; "E**"; "E(*"; "E'E"; "E'7"; "E'0"; "E'-"; "E'+"]); ("string \"vi5x92xgG\"", "vi5x92xgG", (* A less exhaustive string shrinker would be preferable *) ["vi5x9"; "vi52xgG"; "vix92xgG"; "5x92xgG"; "v5x92xgG"; "i5x92xgG"; "li5x92xgG"; "qi5x92xgG"; "ti5x92xgG"; "ui5x92xgG"; "ve5x92xgG"; "vg5x92xgG"; "vh5x92xgG"; "viKx92xgG"; "vi@x92xgG"; "vi:x92xgG"; "vi7x92xgG"; "vi6x92xgG"; "vi5m92xgG"; "vi5s92xgG"; "vi5v92xgG"; "vi5w92xgG"; "vi5xM2xgG"; "vi5xC2xgG"; "vi5x>2xgG"; "vi5x;2xgG"; "vi5x:2xgG"; "vi5x9IxgG"; "vi5x9=xgG"; "vi5x97xgG"; "vi5x94xgG"; "vi5x93xgG"; "vi5x92mgG"; "vi5x92sgG"; "vi5x92vgG"; "vi5x92wgG"; "vi5x92xdG"; "vi5x92xfG"; "vi5x92xgT"; "vi5x92xgM"; "vi5x92xgJ"; "vi5x92xgH"]); ("string \"~~~~\"", "~~~~", ["~~"; "~~"; "~~~"; "p~~~"; "w~~~"; "{~~~"; "}~~~"; "~p~~"; "~w~~"; "~{~~"; "~}~~"; "~~p~"; "~~w~"; "~~{~"; "~~}~"; "~~~p"; "~~~w"; "~~~{"; "~~~}"]); ]; List.iter (alco_check Alcotest.string (trace_true Shrink.string) "on repeated success") [ ("string \"\"", "", []); ("string \"a\"", "a", [""]); ("string \"aa\"", "aa", [""]); ("string \"aaaa\"", "aaaa", ["aa"; ""]); ("string \"abcd\"", "abcd", ["ab"; ""]); ("string \"E'*\"", "E'*", ["E'"; ""]); ("string \"vi5x92xgG\"", "vi5x92xgG", ["vi5x9"; "vi5"; "vi"; ""]); ] let test_int_list () = List.iter (alco_check Alcotest.(list int) (trace_false (Shrink.list_spine)) "on repeated failure") [ ("list int [0]", [0], [[]]); ("list int [0;1]", [0;1], [[]; [0]; [1]]); ("list int [0;1;2]", [0;1;2], [[0; 1]; [2]; [0; 2]; [1; 2]]); ("list int [0;1;2;3]", [0;1;2;3], [[0; 1]; [2; 3]; [0; 2; 3]; [1; 2; 3]]); ("list int [0;0]", [0;0], [[]; [0]]); ("list int [0;0;0]", [0;0;0], [[0; 0]; [0]; [0; 0]]); ("list int [0;0;0;0]", [0;0;0;0], [[0; 0]; [0; 0]; [0; 0; 0]]); ]; List.iter (alco_check Alcotest.(list int) (trace_true (Shrink.list_spine)) "on repeated success") [ ("list int [0]", [0], [[]]); ("list int [0;1]", [0;1], [[]]); ("list int [0;1;2]", [0;1;2], [[0; 1]; []]); ("list int [0;1;2;3]", [0;1;2;3], [[0; 1]; []]); ("list int [0;0]", [0;0], [[]]); ("list int [0;0;0]", [0;0;0], [[0; 0]; []]); ("list int [0;0;0;0]", [0;0;0;0], [[0; 0]; []]); ] let test_int32_list () = (* use int32 as a boxed type and List.map to force run-time allocations *) List.iter (alco_check Alcotest.(list int32) (trace_false (Shrink.list_spine)) "on repeated failure") [ ("list int32 [0l]", List.map Int32.of_int [0], [[]]); ("list int32 [0l;1l]", List.map Int32.of_int [0;1], [[]; [0l]; [1l]]); ("list int32 [0l;1l;2l]", List.map Int32.of_int [0;1;2], [[0l; 1l]; [2l]; [0l; 2l]; [1l; 2l]]); ("list int32 [0l;1l;2l;3l]", List.map Int32.of_int [0;1;2;3], [[0l; 1l]; [2l; 3l]; [0l; 2l; 3l]; [1l; 2l; 3l]]); ("list int32 [0l;0l]", List.map Int32.of_int [0;0], [[]; [0l]]); ("list int32 [0l;0l;0l]", List.map Int32.of_int [0;0;0], [[0l; 0l]; [0l]; [0l; 0l]]); ("list int32 [0l;0l;0l;0l]", List.map Int32.of_int [0;0;0;0], [[0l; 0l]; [0l; 0l]; [0l; 0l; 0l]]); ]; List.iter (alco_check Alcotest.(list int32) (trace_true (Shrink.list_spine)) "on repeated success") [ ("list int [0l]", List.map Int32.of_int [0], [[]]); ("list int [0l;1l]", List.map Int32.of_int [0;1], [[]]); ("list int [0l;1l;2l]", List.map Int32.of_int [0;1;2], [[0l; 1l]; []]); ("list int [0l;1l;2l;3l]", List.map Int32.of_int [0;1;2;3], [[0l; 1l]; []]); ("list int [0l;0l]", List.map Int32.of_int [0;0], [[]]); ("list int [0l;0l;0l]", List.map Int32.of_int [0;0;0], [[0l; 0l]; []]); ("list int [0l;0l;0l;0l]", List.map Int32.of_int [0;0;0;0], [[0l; 0l]; []]); ] let test_list_spine_compare () = let run_test () = QCheck.Shrink.list_spine [pred;succ] ignore in Alcotest.(check unit) "doesn't compare elements" () @@ run_test () let test_int_option () = List.iter (alco_check Alcotest.(option int) (trace_false Shrink.(option int)) "on repeated failure") [ ("option int Some 42", Some 42, [None; Some 21; Some 32; Some 37; Some 40; Some 41]); ("option int None", None, []) ]; List.iter (alco_check Alcotest.(option int) (trace_true Shrink.(option int)) "on repeated success") [ ("option int Some 42", Some 42, [None]); ("option int None", None, []) ] let test_int_string_result () = List.iter (alco_check Alcotest.(result int string) (trace_false Shrink.(result int string)) "on repeated failure") [ ("result int string Ok 55", Ok 55, [Ok 28; Ok 42; Ok 49; Ok 52; Ok 54]); ("result int string Error \"oops\"", Error "oops", [Error "oo"; Error "ps"; Error "ops"; Error "hops"; Error "lops"; Error "nops"; Error "ohps"; Error "olps"; Error "onps"; Error "oois"; Error "ooms"; Error "ooos"; Error "oopj"; Error "oopo"; Error "oopq"; Error "oopr"]) ]; List.iter (alco_check Alcotest.(result int string) (trace_true Shrink.(result int string)) "on repeated success") [ ("result int string Ok 55", Ok 55, [Ok 28; Ok 14; Ok 7; Ok 4; Ok 2; Ok 1; Ok 0]); ("result int string Error \"oops\"", Error "oops", [Error "oo"; Error ""]) ] let tests = ("Shrink", Alcotest.[ test_case "bool" `Quick test_bool; test_case "int" `Quick test_int; test_case "int32" `Quick test_int32; test_case "int64" `Quick test_int64; test_case "char" `Quick test_char; test_case "char_numeral" `Quick test_char_numeral; test_case "char_printable" `Quick test_char_printable; test_case "string" `Quick test_string; test_case "int list" `Quick test_int_list; test_case "int32 list" `Quick test_int32_list; test_case "list_spine" `Quick test_list_spine_compare; test_case "int option" `Quick test_int_option; test_case "(int,string) result" `Quick test_int_string_result; ]) end module Check_exn = struct (* String.starts_with was introduced in 4.13. Include the below to support pre-4.13 OCaml. *) let string_starts_with ~prefix s = let prefix_len = String.length prefix in prefix_len <= String.length s && prefix = String.sub s 0 prefix_len let check_exn = Test.check_exn let test_pass_trivial () = let run_test () = check_exn QCheck.(Test.make int (fun _ -> true)) in Alcotest.(check unit) "Success-trivial" () @@ run_test () let test_pass_random () = let run_test () = check_exn QCheck.(Test.make (list int) (fun l -> List.rev (List.rev l) = l)) in Alcotest.(check unit) "Success-random" () @@ run_test () let test_fail_always () = let name = "will-always-fail" in try check_exn QCheck.(Test.make ~name int (fun _ -> false)); Alcotest.failf "%s: Unexpected success" name with (Test.Test_fail (n,[c_ex_str])) -> Alcotest.(check string) (Printf.sprintf "%s: name" name) n name; if not (string_starts_with ~prefix:"0" c_ex_str) then Alcotest.failf "%s: counter-example prefix. Received \"%s\"" name c_ex_str let test_fail_random () = let name = "list is own reverse" in try check_exn QCheck.(Test.make ~name (list int) (fun l -> List.rev l = l)); Alcotest.failf "%s: Unexpected success" name with (Test.Test_fail (n,[c_ex_str])) -> Alcotest.(check string) (Printf.sprintf "%s: name" name) n name; if not (string_starts_with ~prefix:"[0; 1]" c_ex_str || string_starts_with ~prefix:"[0; -1]" c_ex_str) then Alcotest.failf "%s: counter-example prefix. Received \"%s\"" name c_ex_str exception MyError let test_error () = let name = "will-always-error" in try Printexc.record_backtrace false; (* for easier pattern-matching below *) check_exn QCheck.(Test.make ~name int (fun _ -> raise MyError)); Alcotest.failf "%s: Unexpected success" name with (Test.Test_error (n,c_ex_str,MyError,"")) -> Alcotest.(check string) (Printf.sprintf "%s: name" name) n name; if not (string_starts_with ~prefix:"0" c_ex_str) then Alcotest.failf "%s: counter-example prefix. Received \"%s\"" name c_ex_str let test_negative_trivial () = let run_test () = check_exn QCheck2.(Test.make_neg Gen.int (fun _ -> false)) in Alcotest.(check unit) "Success-negative-trivial" () @@ run_test () let test_negative_test_unexpected_success () = let name = "negative-trivial-test" in let run_test () = check_exn QCheck2.(Test.make_neg ~name Gen.int (fun _ -> true)) in try run_test (); Alcotest.failf "Negative test didn't raise expected exception." with Test.Test_unexpected_success n -> Alcotest.(check string) (Printf.sprintf "%s: name" name) n name let tests = ("Test.check_exn", Alcotest.[ test_case "check_exn pass trivial" `Quick test_pass_trivial; test_case "check_exn pass random" `Quick test_pass_random; test_case "check_exn fail always" `Quick test_fail_always; test_case "check_exn fail random" `Quick test_fail_random; test_case "check_exn Error" `Quick test_error; test_case "check_exn negative pass trivial" `Quick test_negative_trivial; test_case "check_exn Unexpected success" `Quick test_negative_test_unexpected_success; ]) end module TestCount = struct let test_count_n ?count expected = let (Test cell) = QCheck.(Test.make ?count int (fun _ -> true)) in let msg = Printf.sprintf "QCheck.Test.make ~count:%s |> get_count = %d" (Option.fold ~none:"None" ~some:string_of_int count) expected in Alcotest.(check int) msg expected (QCheck.Test.get_count cell) let test_count_10 () = test_count_n ~count:10 10 let test_count_default () = test_count_n 100 let test_count_env () = let () = Unix.putenv "QCHECK_COUNT" "5" in let (Test cell) = QCheck.(Test.make int (fun _ -> true)) in let actual = QCheck.Test.get_count cell in Alcotest.(check int) "default count is from QCHECK_COUNT" 5 actual let test_count_0 () = test_count_n ~count:0 0 let test_count_negative_fail () = try let _ = test_count_n ~count:(-1) (-1) in Alcotest.fail "A negative count in a test should fail" with | _ -> () let tests = ("Test.make ~count", Alcotest.[ test_case "make with custom count" `Quick test_count_10; test_case "make with default count" `Quick test_count_default; test_case "make with env count" `Quick test_count_env; test_case "make with 0 count" `Quick test_count_0; test_case "make with negative count should fail" `Quick test_count_negative_fail; ]) end module TestLongFactor = struct let test_long_factor_n ?long_factor expected = let (Test cell) = QCheck.(Test.make ?long_factor int (fun _ -> true)) in let msg = Printf.sprintf "QCheck.Test.make ~long_factor:%s |> long_factor = %d" (Option.fold ~none:"None" ~some:string_of_int long_factor) expected in Alcotest.(check int) msg expected (QCheck.Test.get_long_factor cell) let test_long_factor_10 () = test_long_factor_n ~long_factor:10 10 let test_long_factor_default () = test_long_factor_n 1 let test_long_factor_env () = let () = Unix.putenv "QCHECK_LONG_FACTOR" "5" in let (Test cell) = QCheck.(Test.make int (fun _ -> true)) in let actual = QCheck.Test.get_long_factor cell in Alcotest.(check int) "default long factor is from QCHECK_LONG_FACTOR" 5 actual let test_long_factor_0 () = test_long_factor_n ~long_factor:0 0 let test_long_factor_negative_fail () = try let _ = test_long_factor_n ~long_factor:(-1) (-1) in Alcotest.fail "A negative long factor in a test should fail" with | _ -> () let tests = ("Test.make ~long_factor", Alcotest.[ test_case "make with custom long_factor" `Quick test_long_factor_10; test_case "make with default long_factor" `Quick test_long_factor_default; test_case "make with env long_factor" `Quick test_long_factor_env; test_case "make with 0 long_factor" `Quick test_long_factor_0; test_case "make with negative long_factor should fail" `Quick test_long_factor_negative_fail; ]) end let () = Alcotest.run "QCheck" [ Shrink.tests; Check_exn.tests; TestCount.tests; TestLongFactor.tests; ] qcheck-0.25/test/core/dune000066400000000000000000000045341477416744200155110ustar00rootroot00000000000000(library (name QCheck_tests) (modules QCheck_tests) (libraries qcheck-core)) (library (name QCheck2_tests) (modules QCheck2_tests) (libraries qcheck-core)) (rule (enabled_if (and (= %{arch_sixtyfour} true) (>= %{ocaml_version} 5))) (action (copy QCheck_expect_test.expected.ocaml5.64 QCheck_expect_test.expected))) (rule (enabled_if (and (= %{arch_sixtyfour} false) (>= %{ocaml_version} 5))) (action (copy QCheck_expect_test.expected.ocaml5.32 QCheck_expect_test.expected))) (rule (enabled_if (and (= %{arch_sixtyfour} true) (< %{ocaml_version} 5))) (action (copy QCheck_expect_test.expected.ocaml4.64 QCheck_expect_test.expected))) (rule (enabled_if (and (= %{arch_sixtyfour} false) (< %{ocaml_version} 5))) (action (copy QCheck_expect_test.expected.ocaml4.32 QCheck_expect_test.expected))) ;; implicitly compared against QCheck_expect_test.expected (test (name QCheck_expect_test) (modules QCheck_expect_test) (package qcheck-core) (libraries qcheck-core qcheck-core.runner QCheck_tests) (action (run ./%{test} --no-colors -s 1234))) (rule (enabled_if (and (= %{arch_sixtyfour} true) (>= %{ocaml_version} 5))) (action (copy QCheck2_expect_test.expected.ocaml5.64 QCheck2_expect_test.expected))) (rule (enabled_if (and (= %{arch_sixtyfour} false) (>= %{ocaml_version} 5))) (action (copy QCheck2_expect_test.expected.ocaml5.32 QCheck2_expect_test.expected))) (rule (enabled_if (and (= %{arch_sixtyfour} true) (< %{ocaml_version} 5))) (action (copy QCheck2_expect_test.expected.ocaml4.64 QCheck2_expect_test.expected))) (rule (enabled_if (and (= %{arch_sixtyfour} false) (< %{ocaml_version} 5))) (action (copy QCheck2_expect_test.expected.ocaml4.32 QCheck2_expect_test.expected))) ;; implicitly compared against QCheck2_expect_test.expected (test (name QCheck2_expect_test) (modules QCheck2_expect_test) (package qcheck-core) (libraries qcheck-core qcheck-core.runner QCheck2_tests) (action (run ./%{test} --no-colors -s 1234))) (tests (names QCheck_unit_tests QCheck2_unit_tests) (modules QCheck_unit_tests QCheck2_unit_tests) (package qcheck-core) (libraries qcheck-core alcotest)) (executable (name shrink_benchmark) (modules shrink_benchmark) (libraries qcheck-core qcheck-core.runner QCheck_tests QCheck2_tests)) (executable (name rng_independence) (modules rng_independence) (libraries qcheck-core qcheck-core.runner)) qcheck-0.25/test/core/rng_independence.ml000066400000000000000000000012201477416744200204410ustar00rootroot00000000000000open QCheck2 (* From https://github.com/haskell/random/issues/25 Assess splitting behaviour by generating stat tests of the form: let test_to_1 = Test.make ~count:2000 ~name:"2000 pairs in [0;1]" ~collect Gen.(pair (int_bound 1) (int_bound 1)) (fun _ -> true) *) let collect (x,y) = if x=y then "equal " else "not-equal" let gen_test i = let count = 1000 + i * 1000 in let name = Printf.sprintf "%i pairs in [0;%i] - should be around 1000" count i in Test.make ~count ~name ~collect Gen.(pair (int_bound i) (int_bound i)) (fun _ -> true) let _ = QCheck_base_runner.run_tests ~verbose:true (List.init 14 (fun i -> gen_test (i+1))) qcheck-0.25/test/core/shrink_benchmark.ml000066400000000000000000000124111477416744200204660ustar00rootroot00000000000000open QCheck2 (** For timing and summing run times *) let time f () = let start_time = Sys.time () in let res = f () in let end_time = Sys.time () in (end_time -. start_time,res) let sum_timing_pairs times = let sum_timings = List.fold_left (+.) 0.0 in let t1,t2 = List.split times in sum_timings t1,sum_timings t2 let get_name (Test.Test cell) = Test.get_name cell (** Runners for single tests, test pairs, and test pair lists *) (* run a single test with the given seed *) let run_timed_test seed cell = let open TestResult in let rand = Random.State.make [| seed |] in (* For total attempts, count occ. of 'Shrinking' in "event protocol": Shrunk 0 - Shrinking 0.1 - Shrinking 0.2 - Shrunk 1 - Shrinking 1.1 - Shrinking 1.2 *) let shr_attempts = ref 0 in let handler _ _ e = match e with | Test.Shrinking (_,_,_) -> incr shr_attempts | _ -> () in let dur,res = time (fun () -> QCheck.Test.check_cell ~rand ~handler cell) () in let name = Test.get_name cell in let res_str,shr_c,_msg = match get_state res with | Success -> failwith (Printf.sprintf "Test %s returned unexpected Success" name) | Error {exn;_} -> failwith (Printf.sprintf "Test %s returned unexpected Error %s" name (Printexc.to_string exn)) | Failed_other {msg} -> failwith (Printf.sprintf "Test %s returned unexpected Failed_other %s" name msg) | Failed {instances} -> "fail",(List.hd instances).shrink_steps, "Failed" (* expected *) in (dur,res_str,shr_c,!shr_attempts) (* run a pair of corresponding tests with the given seed *) let run_timed_test_pair seed (Test.Test c1, Test.Test c2) = let (dur1,res_str1,shr_c1,shr_att1) = run_timed_test seed c1 in let (dur2,res_str2,shr_c2,shr_att2) = run_timed_test seed c2 in if res_str1 <> res_str2 then failwith (Printf.sprintf "benchmark %s gave different errors: %s and %s" (Test.get_name c1) res_str1 res_str2) else (res_str1,(dur1,shr_c1,shr_att1),(dur2,shr_c2,shr_att2)) let non_repeatable_tests = ["big bound issue59";"ints < 209609"] (* run a list of corresponding test pairs over the given seed list *) (* and print the benchmark result to channel [ch] *) let run_timing ch seeds testpairs = let fprintf = Printf.fprintf in let multiple_runs = List.length seeds > 1 in (* print iteration header - name (48 chars) *) Printf.fprintf ch "%-48s" ""; List.iter (fun seed -> fprintf ch " iteration seed %-7i %!" seed) seeds; if multiple_runs then fprintf ch " total\n%!" else print_newline (); (* print column header - name + 38 chars per iteration *) fprintf ch "%-48s" "Shrink test name"; List.iter (fun _ -> fprintf ch " %-6s%-10s %!" "Q1/s" "#succ/#att"; fprintf ch " %-6s%-10s %!" "Q2/s" "#succ/#att") seeds; if multiple_runs then fprintf ch " %6s %6s" "Q1/s" "Q2/s"; fprintf ch "\n%!"; (* print separator *) fprintf ch "%s%!" (String.make 48 '-'); List.iter (fun _ -> fprintf ch "%s%!" (String.make 38 '-')) seeds; if multiple_runs then fprintf ch "%s%!" (String.make 16 '-'); fprintf ch "\n%!"; (* print timings for each test_pair and seed *) let times = List.map (fun ((test1,_test2) as test_pair) -> let name = get_name test1 in let max_len = 48 in fprintf ch "%-48s%!" (if String.length name let _res_str,(dur1,shr_cnt1,shr_att1),(dur2,shr_cnt2,shr_att2) = run_timed_test_pair seed test_pair in fprintf ch " %6.3f %4i/%-6i%!" dur1 shr_cnt1 shr_att1; fprintf ch " %6.3f %4i/%-6i%!" dur2 shr_cnt2 shr_att2; (dur1,dur2) ) seeds in let t1_sum,t2_sum = sum_timing_pairs times in if multiple_runs then fprintf ch " %6.3f %6.3f%!" t1_sum t2_sum; fprintf ch "\n%!"; (t1_sum,t2_sum)) testpairs in let t1_sum,t2_sum = sum_timing_pairs times in fprintf ch "%s%!" (String.make (48 + 38*List.length seeds) ' '); fprintf ch " %6.3f %6.3f\n%!" t1_sum t2_sum (* merge two corresponding lists of tests *) let rec merge_and_validate xs ys = match xs,ys with | [],[] -> [] | [],_ -> failwith "QCheck2_tests.Shrink has more tests than QCheck_tests.Shrink" | _,[] -> failwith "QCheck_tests.Shrink has more tests than QCheck2_tests.Shrink" | t1::xs,t2::ys -> if get_name t1 = get_name t2 then (t1,t2) :: merge_and_validate xs ys else 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 failwith msg let seeds = [1234;(*4321;*)8743;(*9876;*)6789; (*2143*) (* ouch: seed 2143 causes test "lists equal to duplication" to segfault *) ] let () = let ch = open_out "shrink_bench.log" in try merge_and_validate QCheck_tests.(Shrink.tests@Function.tests) QCheck2_tests.(Shrink.tests@Function.tests) |> run_timing ch seeds; close_out ch with e -> close_out ch; raise e qcheck-0.25/test/ppx_deriving_qcheck/000077500000000000000000000000001477416744200177115ustar00rootroot00000000000000qcheck-0.25/test/ppx_deriving_qcheck/deriver/000077500000000000000000000000001477416744200213515ustar00rootroot00000000000000qcheck-0.25/test/ppx_deriving_qcheck/deriver/qcheck/000077500000000000000000000000001477416744200226075ustar00rootroot00000000000000qcheck-0.25/test/ppx_deriving_qcheck/deriver/qcheck/dune000066400000000000000000000004471477416744200234720ustar00rootroot00000000000000(tests (package ppx_deriving_qcheck) (names test_textual test_primitives test_qualified_names test_recursive test_tuple test_variants test_record) (libraries qcheck-alcotest ppxlib ppx_deriving_qcheck qcheck-core) (preprocess (pps ppxlib.metaquot ppx_deriving_qcheck))) qcheck-0.25/test/ppx_deriving_qcheck/deriver/qcheck/helpers.ml000066400000000000000000000010121477416744200245750ustar00rootroot00000000000000open QCheck (** {1. Helpers} *) let seed = [| 42 |] let generate arb = let gen = QCheck.gen arb in Gen.generate ~n:20 ~rand:(Random.State.make seed) gen (** [test_compare msg eq arb_ref arb_cand] will arberate with the same seed [arb_ref] and [arb_cand], and test with Alcotest that both arberators arberates the same values. *) let test_compare ~msg ~eq arb_ref arb_candidate = let expected = generate arb_ref in let actual = generate arb_candidate in Alcotest.(check (list eq)) msg expected actual qcheck-0.25/test/ppx_deriving_qcheck/deriver/qcheck/test_primitives.ml000066400000000000000000000051521477416744200263760ustar00rootroot00000000000000open QCheck open Helpers (** {1. Test primitives derivation} *) (** {2. Tests} *) type int' = int [@@deriving qcheck] let test_int () = test_compare ~msg:"int <=> deriving int" ~eq:Alcotest.int int arb_int' type unit' = unit [@@deriving qcheck] (* Pretty useless though, but, meh *) let test_unit () = test_compare ~msg:"unit <=> deriving unit" ~eq:Alcotest.unit unit arb_unit' type string' = string [@@deriving qcheck] let test_string () = test_compare ~msg:"string <=> deriving string" ~eq:Alcotest.string string arb_string' type char' = char [@@deriving qcheck] let test_char () = test_compare ~msg:"char <=> deriving char" ~eq:Alcotest.char char arb_char' type bool' = bool [@@deriving qcheck] let test_bool () = test_compare ~msg:"bool <=> deriving bool" ~eq:Alcotest.bool bool arb_bool' type float' = float [@@deriving qcheck] let test_float () = test_compare ~msg:"float <=> deriving float" ~eq:(Alcotest.float 0.) float arb_float' type int32' = int32 [@@deriving qcheck] let test_int32 () = test_compare ~msg:"int32 <=> deriving int32" ~eq:Alcotest.int32 int32 arb_int32' type int64' = int64 [@@deriving qcheck] let test_int64 () = test_compare ~msg:"int64 <=> deriving int64" ~eq:Alcotest.int64 int64 arb_int64' type 'a option' = 'a option [@@deriving qcheck] let test_option () = let zero = Gen.pure 0 in test_compare ~msg:"option <=> deriving opt" ~eq:Alcotest.(option int) (option (make zero)) (arb_option' zero) type 'a array' = 'a array [@@deriving qcheck] let test_array () = let zero = Gen.pure 0 in test_compare ~msg:"array <=> deriving array" ~eq:Alcotest.(array int) (array (make zero)) (arb_array' zero) type 'a list' = 'a list [@@deriving qcheck] let test_list () = let zero = Gen.pure 0 in test_compare ~msg:"list <=> deriving list" ~eq:Alcotest.(list int) (list (make zero)) (arb_list' zero) (** {2. Execute tests} *) let () = Alcotest.run "Test_Primitives" [("Primitives", Alcotest.[ test_case "test_int" `Quick test_int; test_case "test_unit" `Quick test_unit; test_case "test_string" `Quick test_string; test_case "test_char" `Quick test_char; test_case "test_bool" `Quick test_bool; test_case "test_float" `Quick test_float; test_case "test_int32" `Quick test_int32; test_case "test_int64" `Quick test_int64; test_case "test_option" `Quick test_option; test_case "test_array" `Quick test_array; test_case "test_list" `Quick test_list; ])] qcheck-0.25/test/ppx_deriving_qcheck/deriver/qcheck/test_qualified_names.ml000066400000000000000000000014401477416744200273250ustar00rootroot00000000000000open QCheck open Helpers module type S = sig type t = int val gen : int QCheck.Gen.t val arb : int QCheck.arbitrary end module Q : S = struct type t = int [@@deriving qcheck] end module F (X : S) = struct type t = X.t [@@deriving qcheck] end module G = F (Q) type t = Q.t [@@deriving qcheck] type u = G.t [@@deriving qcheck] let test_module () = test_compare ~msg:"Gen.int <=> deriving Q.t" ~eq:Alcotest.int int arb let test_functor () = test_compare ~msg:"Gen.int <=> deriving F.t" ~eq:Alcotest.int int arb_u (** {2. Execute tests} *) let () = Alcotest.run "Test_Qualified_names" [("Qualified names", Alcotest.[ test_case "test_module" `Quick test_module; test_case "test_functor" `Quick test_functor ])] qcheck-0.25/test/ppx_deriving_qcheck/deriver/qcheck/test_record.ml000066400000000000000000000027411477416744200254620ustar00rootroot00000000000000open QCheck open Helpers type env = { rec_types : string list; curr_types : string list; curr_type : string } [@@deriving qcheck] let pp_env fmt {rec_types; curr_types; curr_type} = let open Format in fprintf fmt {|{ rec_types = [%a]; curr_types = [%a]; curr_type = [%s]; }|} (pp_print_list pp_print_string) rec_types (pp_print_list pp_print_string) curr_types curr_type let eq_env = Alcotest.of_pp pp_env let arb_env_ref = map (fun (rec_types, curr_types, curr_type) -> { rec_types; curr_types; curr_type }) (triple (list string) (list string) string) let test_env () = test_compare ~msg:"arb_env ref <=> deriving env" ~eq:eq_env arb_env_ref arb_env type color = Color of { red : float; green : float; blue : float } [@@deriving qcheck] let pp_color fmt (Color {red; green; blue}) = let open Format in fprintf fmt {|Color { red = %a; green = %a; blue = %a; }|} pp_print_float red pp_print_float green pp_print_float blue let eq_color = Alcotest.of_pp pp_color let arb_color_ref = map (fun (red, green, blue) -> Color {red; green; blue}) (triple float float float) let test_color () = test_compare ~msg:"arb_color ref <=> deriving color" ~eq:eq_color arb_color_ref arb_color (** {2. Execute tests} *) let () = Alcotest.run "Test_Record" [("Record", Alcotest.[ test_case "test_env" `Quick test_env; test_case "test_color" `Quick test_color; ])] qcheck-0.25/test/ppx_deriving_qcheck/deriver/qcheck/test_recursive.ml000066400000000000000000000037311477416744200262130ustar00rootroot00000000000000open QCheck open Helpers type 'a tree = Leaf | Node of 'a * 'a tree * 'a tree [@@deriving qcheck] let rec pp_tree pp fmt x = let open Format in match x with | Leaf -> fprintf fmt "Leaf" | Node (x, l, r) -> fprintf fmt "Node (%a, %a, %a)" pp x (pp_tree pp) l (pp_tree pp) r let eq_tree pp = Alcotest.of_pp (pp_tree pp) let arb_tree_ref gen = let open Gen in make @@ sized @@ fix (fun self -> function | 0 -> pure Leaf | n -> oneof [ pure Leaf; map3 (fun x l r -> Node (x,l,r)) gen (self (n/2)) (self (n/2)); ]) let arb_tree_candidate = arb_tree let test_tree_ref () = let gen = Gen.int in test_compare ~msg:"gen tree <=> derivation tree" ~eq:(eq_tree Format.pp_print_int) (arb_tree_ref gen) (arb_tree gen) let test_leaf = Test.make ~name:"arb_tree_sized 0 = Node (_, Leaf, Leaf)" (arb_tree_sized Gen.int 0) (function | Leaf -> true | Node (_, Leaf, Leaf) -> true | _ -> false) |> QCheck_alcotest.to_alcotest (* A slight error has been found here: If the type is named `list` then `'a list` will be derived with the QCheck generator `list` instead of the `arb_list_sized`. This could lead to a design choice: - do we allow overriding primitive types? - do we prioritize `Env.curr_types` over primitive types? *) type 'a my_list = Cons of 'a * 'a my_list | Nil [@@deriving qcheck] let rec length = function | Nil -> 0 | Cons (_, xs) -> 1 + length xs let test_length = Test.make ~name:"arb_list_sized n >>= fun l -> length l <= n" small_int (fun n -> let l = Gen.(generate1 (gen_my_list_sized Gen.int n)) in length l <= n) |> QCheck_alcotest.to_alcotest let () = Alcotest.run "Test_Recursive" [("Recursive", Alcotest.[ test_case "test_tree_ref" `Quick test_tree_ref; test_leaf ])] qcheck-0.25/test/ppx_deriving_qcheck/deriver/qcheck/test_textual.ml000066400000000000000000000736511477416744200257020ustar00rootroot00000000000000(** Module test for ppx_deriving_qcheck *) open Ppxlib (** Primitive types tests *) let loc = Location.none let f = Ppx_deriving_qcheck.derive_arbs ~loc let f' xs = List.map f xs |> List.concat let extract stri = match stri.pstr_desc with Pstr_type (x, y) -> (x, y) | _ -> assert false let extract' xs = List.map extract xs let check_eq ~expected ~actual name = let f = Ppxlib.Pprintast.string_of_structure in Alcotest.(check string) name (f expected) (f actual) let test_int () = let expected = [ [%stri let gen = QCheck.Gen.int]; [%stri let arb = QCheck.make @@ gen]; ] in let actual = f @@ extract [%stri type t = int] in check_eq ~expected ~actual "deriving int" let test_float () = let expected = [ [%stri let gen = QCheck.Gen.float]; [%stri let arb = QCheck.make @@ gen]; ] in let actual = f @@ extract [%stri type t = float] in check_eq ~expected ~actual "deriving float" let test_char () = let expected = [ [%stri let gen = QCheck.Gen.char]; [%stri let arb = QCheck.make @@ gen]; ] in let actual = f @@ extract [%stri type t = char] in check_eq ~expected ~actual "deriving char" let test_string () = let expected = [ [%stri let gen = QCheck.Gen.string]; [%stri let arb = QCheck.make @@ gen]; ] in let actual = f @@ extract [%stri type t = string] in check_eq ~expected ~actual "deriving string" let test_unit () = let expected = [ [%stri let gen = QCheck.Gen.unit]; [%stri let arb = QCheck.make @@ gen]; ] in let actual = f @@ extract [%stri type t = unit] in check_eq ~expected ~actual "deriving unit" let test_bool () = let expected = [ [%stri let gen = QCheck.Gen.bool]; [%stri let arb = QCheck.make @@ gen]; ] in let actual = f @@ extract [%stri type t = bool] in check_eq ~expected ~actual "deriving bool" let test_int32 () = let expected = [ [%stri let gen = QCheck.Gen.ui32]; [%stri let arb = QCheck.make @@ gen]; ] in let actual = f @@ extract [%stri type t = int32] in check_eq ~expected ~actual "deriving int32" let test_int32' () = let expected = [ [%stri let gen = QCheck.Gen.ui32]; [%stri let arb = QCheck.make @@ gen]; ] in let actual = f @@ extract [%stri type t = Int32.t] in check_eq ~expected ~actual "deriving int32'" let test_int64 () = let expected = [ [%stri let gen = QCheck.Gen.ui64]; [%stri let arb = QCheck.make @@ gen]; ] in let actual = f @@ extract [%stri type t = int64] in check_eq ~expected ~actual "deriving int64" let test_int64' () = let expected = [ [%stri let gen = QCheck.Gen.ui64]; [%stri let arb = QCheck.make @@ gen]; ] in let actual = f @@ extract [%stri type t = Int64.t] in check_eq ~expected ~actual "deriving int64'" (* let test_bytes () = * let expected = * [ * [%stri * let gen = * QCheck.map * (fun n -> Bytes.create n) * QCheck.(0 -- Sys.max_string_length)]; * ] * in * let actual = f @@ extract [%stri type t = Bytes.t ] in * * check_eq ~expected ~actual "deriving int64" *) let test_tuple () = let actual = f' @@ extract' [ [%stri type t = int * int]; [%stri type t = int * int * int]; [%stri type t = int * int * int * int]; [%stri type t = int * int * int * int * int]; [%stri type t = int * int * int * int * int * int]; ] in let expected = [ [%stri let gen = QCheck.Gen.map (fun (gen0, gen1) -> (gen0, gen1)) (QCheck.Gen.pair QCheck.Gen.int QCheck.Gen.int)]; [%stri let arb = QCheck.make @@ gen]; [%stri let gen = QCheck.Gen.map (fun (gen0, gen1, gen2) -> (gen0, gen1, gen2)) (QCheck.Gen.triple QCheck.Gen.int QCheck.Gen.int QCheck.Gen.int)]; [%stri let arb = QCheck.make @@ gen]; [%stri let gen = QCheck.Gen.map (fun (gen0, gen1, gen2, gen3) -> (gen0, gen1, gen2, gen3)) (QCheck.Gen.quad QCheck.Gen.int QCheck.Gen.int QCheck.Gen.int QCheck.Gen.int)]; [%stri let arb = QCheck.make @@ gen]; [%stri let gen = QCheck.Gen.map (fun ((gen0, gen1), (gen2, gen3, gen4)) -> (gen0, gen1, gen2, gen3, gen4)) (QCheck.Gen.pair (QCheck.Gen.pair QCheck.Gen.int QCheck.Gen.int) (QCheck.Gen.triple QCheck.Gen.int QCheck.Gen.int QCheck.Gen.int))]; [%stri let arb = QCheck.make @@ gen]; [%stri let gen = QCheck.Gen.map (fun ((gen0, gen1, gen2), (gen3, gen4, gen5)) -> (gen0, gen1, gen2, gen3, gen4, gen5)) (QCheck.Gen.pair (QCheck.Gen.triple QCheck.Gen.int QCheck.Gen.int QCheck.Gen.int) (QCheck.Gen.triple QCheck.Gen.int QCheck.Gen.int QCheck.Gen.int))]; [%stri let arb = QCheck.make @@ gen]; ] in check_eq ~expected ~actual "deriving tuples" let test_option () = let expected = [ [%stri let gen = QCheck.Gen.option QCheck.Gen.int]; [%stri let arb = QCheck.make @@ gen]; ] in let actual = f' @@ extract' [ [%stri type t = int option] ] in check_eq ~expected ~actual "deriving option" let test_array () = let expected = [ [%stri let gen = QCheck.Gen.array QCheck.Gen.int]; [%stri let arb = QCheck.make @@ gen]; ] in let actual = f' @@ extract' [ [%stri type t = int array] ] in check_eq ~expected ~actual "deriving option" let test_list () = let expected = [ [%stri let gen = QCheck.Gen.list QCheck.Gen.string]; [%stri let arb = QCheck.make @@ gen]; ] in let actual = f' @@ extract' [ [%stri type t = string list] ] in check_eq ~expected ~actual "deriving list" let test_alpha () = let expected = [ [%stri let gen gen_a = gen_a]; [%stri let arb gen_a = QCheck.make @@ (gen gen_a)]; [%stri let gen gen_a = QCheck.Gen.list gen_a]; [%stri let arb gen_a = QCheck.make @@ (gen gen_a)]; [%stri let gen gen_a = QCheck.Gen.map (fun gen0 -> A gen0) gen_a]; [%stri let arb gen_a = QCheck.make @@ (gen gen_a)]; [%stri let gen gen_a gen_b = QCheck.Gen.map (fun (gen0, gen1) -> A (gen0, gen1)) (QCheck.Gen.pair gen_a gen_b)]; [%stri let arb gen_a gen_b = QCheck.make @@ ((gen gen_a) gen_b)]; [%stri let gen gen_left gen_right = QCheck.Gen.map (fun (gen0, gen1) -> (gen0, gen1)) (QCheck.Gen.pair gen_left gen_right)]; [%stri let arb gen_left gen_right = QCheck.make @@ ((gen gen_left) gen_right)]; [%stri let gen_int_tree = gen_tree QCheck.Gen.int ]; [%stri let arb_int_tree = QCheck.make @@ gen_int_tree]; ] in let actual = f' @@ extract' [ [%stri type 'a t = 'a]; [%stri type 'a t = 'a list]; [%stri type 'a t = A of 'a]; [%stri type ('a, 'b) t = A of 'a * 'b]; [%stri type ('left, 'right) t = 'left * 'right]; [%stri type int_tree = int tree] ] in check_eq ~expected ~actual "deriving alpha" let test_equal () = let expected = [ [%stri let gen = QCheck.Gen.frequency [ (1, QCheck.Gen.pure A); (1, QCheck.Gen.pure B); (1, QCheck.Gen.pure C); ]]; [%stri let arb = QCheck.make @@ gen]; [%stri let gen_t' = QCheck.Gen.frequency [ (1, QCheck.Gen.pure A); (1, QCheck.Gen.pure B); (1, QCheck.Gen.pure C); ]]; [%stri let arb_t' = QCheck.make @@ gen_t']; ] in let actual = f' @@ extract' [ [%stri type t = A | B | C]; [%stri type t' = t = A | B | C] ] in check_eq ~expected ~actual "deriving equal" let test_dependencies () = let expected = [ [%stri let gen = QCheck.Gen.frequency [ (1, QCheck.Gen.map (fun gen0 -> Int gen0) SomeModule.gen); ( 1, QCheck.Gen.map (fun gen0 -> Float gen0) SomeModule.SomeOtherModule.gen ); ]]; [%stri let arb = QCheck.make @@ gen]; [%stri let gen = gen_something]; [%stri let arb = QCheck.make @@ gen]; ] in let actual = f' @@ extract' [ [%stri type t = | Int of SomeModule.t | Float of SomeModule.SomeOtherModule.t]; [%stri type t = (Something.t[@gen gen_something])]; ] in check_eq ~expected ~actual "deriving dependencies" let test_konstr () = let expected = [ [%stri let gen = QCheck.Gen.map (fun gen0 -> A gen0) QCheck.Gen.int]; [%stri let arb = QCheck.make @@ gen]; [%stri let gen = QCheck.Gen.frequency [ (1, QCheck.Gen.map (fun gen0 -> B gen0) QCheck.Gen.int); (1, QCheck.Gen.map (fun gen0 -> C gen0) QCheck.Gen.int); ]]; [%stri let arb = QCheck.make @@ gen]; [%stri let gen = QCheck.Gen.frequency [ (1, QCheck.Gen.map (fun gen0 -> X gen0) gen_t1); (1, QCheck.Gen.map (fun gen0 -> Y gen0) gen_t2); (1, QCheck.Gen.map (fun gen0 -> Z gen0) QCheck.Gen.string); ]]; [%stri let arb = QCheck.make @@ gen]; [%stri let gen = QCheck.Gen.frequency [ (1, QCheck.Gen.pure Left); (1, QCheck.Gen.pure Right) ]]; [%stri let arb = QCheck.make @@ gen]; [%stri let gen = QCheck.Gen.frequency [ (1, QCheck.Gen.map (fun gen0 -> Simple gen0) QCheck.Gen.int); ( 1, QCheck.Gen.map (fun (gen0, gen1) -> Double (gen0, gen1)) (QCheck.Gen.pair QCheck.Gen.int QCheck.Gen.int) ); ( 1, QCheck.Gen.map (fun (gen0, gen1, gen2) -> Triple (gen0, gen1, gen2)) (QCheck.Gen.triple QCheck.Gen.int QCheck.Gen.int QCheck.Gen.int) ); ]]; [%stri let arb = QCheck.make @@ gen]; ] in let actual = f' @@ extract' [ [%stri type t = A of int]; [%stri type t = B of int | C of int]; [%stri type t = X of t1 | Y of t2 | Z of string]; [%stri type t = Left | Right]; [%stri type t = | Simple of int | Double of int * int | Triple of int * int * int]; ] in check_eq ~expected ~actual "deriving constructors" let test_record () = let expected = [ [%stri let gen = QCheck.Gen.map (fun (gen0, gen1) -> { a = gen0; b = gen1 }) (QCheck.Gen.pair QCheck.Gen.int QCheck.Gen.string)]; [%stri let arb = QCheck.make @@ gen]; [%stri let gen = QCheck.Gen.map (fun (gen0, gen1) -> { a = gen0; b = gen1 }) (QCheck.Gen.pair QCheck.Gen.int QCheck.Gen.string)]; [%stri let arb = QCheck.make @@ gen]; [%stri let gen = QCheck.Gen.frequency [ (1, QCheck.Gen.map (fun gen0 -> A gen0) gen_t'); ( 1, QCheck.Gen.map (fun (gen0, gen1) -> B { left = gen0; right = gen1 }) (QCheck.Gen.pair QCheck.Gen.int QCheck.Gen.int) ); ]]; [%stri let arb = QCheck.make @@ gen]; ] in let actual = f' @@ extract' [ [%stri type t = { a : int; b : string }]; [%stri type t = { mutable a : int; mutable b : string }]; [%stri type t = A of t' | B of { left : int; right : int }]; ] in check_eq ~expected ~actual "deriving record" let test_variant () = let expected = [ [%stri let gen = (QCheck.Gen.frequency [ (1, QCheck.Gen.pure `A); (1, QCheck.Gen.map (fun gen0 -> `B gen0) QCheck.Gen.int); (1, QCheck.Gen.map (fun gen0 -> `C gen0) QCheck.Gen.string); ] : t QCheck.Gen.t)]; [%stri let arb = QCheck.make @@ gen]; [%stri let gen_t' = (QCheck.Gen.frequency [ (1, QCheck.Gen.pure `B); (1, gen) ] : t' QCheck.Gen.t)]; [%stri let arb_t' = QCheck.make @@ gen_t']; ] in let actual = f' @@ extract' [ [%stri type t = [ `A | `B of int | `C of string ]]; [%stri type t' = [ `B | t ]]; ] in check_eq ~expected ~actual "deriving variant" let test_tree () = let expected = [ [%stri let rec gen_tree_sized gen_a n = match n with | 0 -> QCheck.Gen.pure Leaf | _ -> QCheck.Gen.frequency [ (1, QCheck.Gen.pure Leaf); ( 1, QCheck.Gen.map (fun (gen0, gen1, gen2) -> Node (gen0, gen1, gen2)) (QCheck.Gen.triple gen_a ((gen_tree_sized gen_a) (n / 2)) ((gen_tree_sized gen_a) (n / 2))) ); ] ]; [%stri let gen_tree gen_a = QCheck.Gen.sized (gen_tree_sized gen_a) ]; [%stri let arb_tree_sized gen_a n = QCheck.make @@ ((gen_tree_sized gen_a) n)]; [%stri let arb_tree gen_a = QCheck.make @@ (gen_tree gen_a)]; ] in let actual = f @@ extract [%stri type 'a tree = Leaf | Node of 'a * 'a tree * 'a tree]; in check_eq ~expected ~actual "deriving tree" let test_expr () = let expected = [ [%stri let rec gen_expr_sized n = match n with | 0 -> QCheck.Gen.map (fun gen0 -> Value gen0) QCheck.Gen.int | _ -> QCheck.Gen.frequency [ ( 1, QCheck.Gen.map (fun gen0 -> Value gen0) QCheck.Gen.int ); ( 1, QCheck.Gen.map (fun (gen0, gen1, gen2) -> If (gen0, gen1, gen2)) (QCheck.Gen.triple (gen_expr_sized (n / 2)) (gen_expr_sized (n / 2)) (gen_expr_sized (n / 2))) ); ( 1, QCheck.Gen.map (fun (gen0, gen1) -> Eq (gen0, gen1)) (QCheck.Gen.pair (gen_expr_sized (n / 2)) (gen_expr_sized (n / 2))) ); ( 1, QCheck.Gen.map (fun (gen0, gen1) -> Lt (gen0, gen1)) (QCheck.Gen.pair (gen_expr_sized (n / 2)) (gen_expr_sized (n / 2))) ); ] ]; [%stri let gen_expr = QCheck.Gen.sized gen_expr_sized ]; [%stri let arb_expr_sized n = QCheck.make @@ (gen_expr_sized n)]; [%stri let arb_expr = QCheck.make @@ gen_expr]; ] in let actual = f @@ extract [%stri type expr = | Value of int | If of expr * expr * expr | Eq of expr * expr | Lt of expr * expr] in check_eq ~expected ~actual "deriving expr" let test_forest () = let expected = [ [%stri let rec gen_tree_sized gen_a n = QCheck.Gen.map (fun gen0 -> Node gen0) (QCheck.Gen.map (fun (gen0, gen1) -> (gen0, gen1)) (QCheck.Gen.pair gen_a ((gen_forest_sized gen_a) (n / 2)))) and gen_forest_sized gen_a n = match n with | 0 -> QCheck.Gen.pure Nil | _ -> QCheck.Gen.frequency [ (1, QCheck.Gen.pure Nil); ( 1, QCheck.Gen.map (fun gen0 -> Cons gen0) (QCheck.Gen.map (fun (gen0, gen1) -> (gen0, gen1)) (QCheck.Gen.pair ((gen_tree_sized gen_a) (n / 2)) ((gen_forest_sized gen_a) (n / 2)))) ); ] ]; [%stri let gen_tree gen_a = QCheck.Gen.sized (gen_tree_sized gen_a)]; [%stri let gen_forest gen_a = QCheck.Gen.sized (gen_forest_sized gen_a)]; [%stri let arb_tree_sized gen_a n = QCheck.make @@ ((gen_tree_sized gen_a) n)]; [%stri let arb_forest_sized gen_a n = QCheck.make @@ ((gen_forest_sized gen_a) n)]; [%stri let arb_tree gen_a = QCheck.make @@ (gen_tree gen_a)]; [%stri let arb_forest gen_a = QCheck.make @@ (gen_forest gen_a)]; ] in let actual = f @@ extract [%stri type 'a tree = Node of ('a * 'a forest) and 'a forest = Nil | Cons of ('a tree * 'a forest)] in check_eq ~expected ~actual "deriving forest" let test_fun_primitives () = let expected = [ [%stri let gen = QCheck.fun_nary QCheck.Tuple.( QCheck.Observable.int @-> QCheck.Observable.int @-> o_nil) (QCheck.make QCheck.Gen.string) |> QCheck.gen]; [%stri let arb = QCheck.make @@ gen]; [%stri let gen = QCheck.fun_nary QCheck.Tuple.( QCheck.Observable.float @-> QCheck.Observable.float @-> o_nil) (QCheck.make QCheck.Gen.string) |> QCheck.gen]; [%stri let arb = QCheck.make @@ gen]; [%stri let gen = QCheck.fun_nary QCheck.Tuple.( QCheck.Observable.string @-> QCheck.Observable.string @-> o_nil) (QCheck.make QCheck.Gen.string) |> QCheck.gen]; [%stri let arb = QCheck.make @@ gen]; [%stri let gen = QCheck.fun_nary QCheck.Tuple.( QCheck.Observable.bool @-> QCheck.Observable.bool @-> o_nil) (QCheck.make QCheck.Gen.string) |> QCheck.gen]; [%stri let arb = QCheck.make @@ gen]; [%stri let gen = QCheck.fun_nary QCheck.Tuple.( QCheck.Observable.char @-> QCheck.Observable.char @-> o_nil) (QCheck.make QCheck.Gen.string) |> QCheck.gen]; [%stri let arb = QCheck.make @@ gen]; [%stri let gen = QCheck.fun_nary QCheck.Tuple.(QCheck.Observable.unit @-> o_nil) (QCheck.make QCheck.Gen.string) |> QCheck.gen]; [%stri let arb = QCheck.make @@ gen]; ] in let actual = f' @@ extract' [ [%stri type t = int -> int -> string]; [%stri type t = float -> float -> string]; [%stri type t = string -> string -> string]; [%stri type t = bool -> bool -> string]; [%stri type t = char -> char -> string]; [%stri type t = unit -> string]; ] in check_eq ~expected ~actual "deriving fun primitives" let test_fun_n () = let expected = [ [%stri let gen = QCheck.fun_nary QCheck.Tuple.( QCheck.Observable.bool @-> QCheck.Observable.int @-> QCheck.Observable.float @-> QCheck.Observable.string @-> QCheck.Observable.char @-> o_nil) (QCheck.make QCheck.Gen.unit) |> QCheck.gen]; [%stri let arb = QCheck.make @@ gen]; ] in let actual = f @@ extract [%stri type t = bool -> int -> float -> string -> char -> unit] in check_eq ~expected ~actual "deriving fun n" let test_fun_option () = let expected = [ [%stri let gen = QCheck.fun_nary QCheck.Tuple.( QCheck.Observable.option QCheck.Observable.int @-> o_nil) (QCheck.make QCheck.Gen.unit) |> QCheck.gen]; [%stri let arb = QCheck.make @@ gen]; ] in let actual = f @@ extract [%stri type t = int option -> unit] in check_eq ~expected ~actual "deriving fun option" let test_fun_list () = let expected = [ [%stri let gen = QCheck.fun_nary QCheck.Tuple.( QCheck.Observable.list QCheck.Observable.int @-> o_nil) (QCheck.make QCheck.Gen.unit) |> QCheck.gen]; [%stri let arb = QCheck.make @@ gen]; ] in let actual = f @@ extract [%stri type t = int list -> unit] in check_eq ~expected ~actual "deriving fun list" let test_fun_array () = let expected = [ [%stri let gen = QCheck.fun_nary QCheck.Tuple.( QCheck.Observable.array QCheck.Observable.int @-> o_nil) (QCheck.make QCheck.Gen.unit) |> QCheck.gen]; [%stri let arb = QCheck.make @@ gen]; ] in let actual = f @@ extract [%stri type t = int array -> unit] in check_eq ~expected ~actual "deriving fun array" let test_fun_tuple () = let expected = [ [%stri let gen = QCheck.fun_nary QCheck.Tuple.( QCheck.Observable.pair QCheck.Observable.int QCheck.Observable.int @-> o_nil) (QCheck.make QCheck.Gen.unit) |> QCheck.gen]; [%stri let arb = QCheck.make @@ gen]; [%stri let gen = QCheck.fun_nary QCheck.Tuple.( QCheck.Observable.triple QCheck.Observable.int QCheck.Observable.int QCheck.Observable.int @-> o_nil) (QCheck.make QCheck.Gen.unit) |> QCheck.gen]; [%stri let arb = QCheck.make @@ gen]; [%stri let gen = QCheck.fun_nary QCheck.Tuple.( QCheck.Observable.quad QCheck.Observable.int QCheck.Observable.int QCheck.Observable.int QCheck.Observable.int @-> o_nil) (QCheck.make QCheck.Gen.unit) |> QCheck.gen]; [%stri let arb = QCheck.make @@ gen]; ] in let actual = f' @@ extract' [ [%stri type t = int * int -> unit]; [%stri type t = int * int * int -> unit]; [%stri type t = int * int * int * int -> unit]; ] in check_eq ~expected ~actual "deriving fun tuple" let test_weight_konstrs () = let expected = [ [%stri let gen = QCheck.Gen.frequency [ (5, QCheck.Gen.pure A); (6, QCheck.Gen.pure B); (1, QCheck.Gen.pure C); ]]; [%stri let arb = QCheck.make @@ gen]; ] in let actual = f @@ extract [%stri type t = A [@weight 5] | B [@weight 6] | C] in check_eq ~expected ~actual "deriving weight konstrs" (* Regression test: https://github.com/c-cube/qcheck/issues/187 *) let test_recursive_poly_variant () = let expected = [ [%stri let rec gen_tree_sized gen_a n = (match n with | 0 -> QCheck.Gen.map (fun gen0 -> `Leaf gen0) gen_a | _ -> QCheck.Gen.frequency [ ( 1, QCheck.Gen.map (fun gen0 -> `Leaf gen0) gen_a ); ( 1, QCheck.Gen.map (fun gen0 -> `Node gen0) (QCheck.Gen.map (fun (gen0, gen1) -> (gen0, gen1)) (QCheck.Gen.pair ((gen_tree_sized gen_a) (n / 2)) ((gen_tree_sized gen_a) (n / 2)))) ); ] : tree QCheck.Gen.t)]; [%stri let gen_tree gen_a = QCheck.Gen.sized (gen_tree_sized gen_a) ]; [%stri let arb_tree_sized gen_a n = QCheck.make @@ ((gen_tree_sized gen_a) n)]; [%stri let arb_tree gen_a = QCheck.make @@ gen_tree gen_a]; ] in let actual = f @@ extract [%stri type 'a tree = [ `Leaf of 'a | `Node of 'a tree * 'a tree ]] in (* On OCaml 5.1 and earlier this test hits a cornercase of the ppxlib AST-mappings to move the type annotation when pretty printed and ultimately fail this test https://github.com/ocaml-ppx/ppxlib/blob/37d7ee13f4dcac44de5244a1c1e19652a5880075/astlib/migrate_501_502.ml#L173-L181 *) let ocaml_release = Scanf.sscanf Sys.ocaml_version "%i.%i" (fun major minor -> (major,minor)) in if ocaml_release <= (5,1) then () else check_eq ~expected ~actual "deriving recursive polymorphic variants" (* Regression test: https://github.com/c-cube/qcheck/issues/213 *) let test_unused_variable () = let expected = [ [%stri let rec gen_c_sized n = match n with | 0 -> QCheck.Gen.pure A | _ -> QCheck.Gen.frequency [(1, (QCheck.Gen.pure A)); (1, (QCheck.Gen.map (fun gen0 -> B gen0) (gen_myint_sized (n / 2))))] and gen_myint_sized _n = QCheck.Gen.nat ]; [%stri let gen_c = QCheck.Gen.sized gen_c_sized]; [%stri let gen_myint = QCheck.Gen.sized gen_myint_sized]; [%stri let arb_c_sized n = QCheck.make @@ (gen_c_sized n)]; [%stri let arb_myint_sized _n = QCheck.make @@ (gen_myint_sized _n)]; [%stri let arb_c = QCheck.make @@ gen_c]; [%stri let arb_myint = QCheck.make @@ gen_myint]; [%stri let rec gen_c_sized n = QCheck.Gen.frequency [(1, (QCheck.Gen.map (fun gen0 -> A gen0) (gen_myint_sized (n / 2)))); (1, (QCheck.Gen.map (fun gen0 -> B gen0) (gen_myint_sized (n / 2))))] and gen_myint_sized _n = QCheck.Gen.nat ]; [%stri let gen_c = QCheck.Gen.sized gen_c_sized]; [%stri let gen_myint = QCheck.Gen.sized gen_myint_sized]; [%stri let arb_c_sized n = QCheck.make @@ (gen_c_sized n)]; [%stri let arb_myint_sized _n = QCheck.make @@ (gen_myint_sized _n)]; [%stri let arb_c = QCheck.make @@ gen_c]; [%stri let arb_myint = QCheck.make @@ gen_myint]; ] in let actual = f' @@ extract' [ [%stri type c = | A | B of myint and myint = int [@gen QCheck.Gen.nat] ]; [%stri type c = | A of myint | B of myint and myint = int [@gen QCheck.Gen.nat] ]; ] in check_eq ~expected ~actual "deriving variant with unused fuel parameter" (* Regression test: https://github.com/c-cube/qcheck/issues/269 *) let test_faulty_is_rec_typ_in_variant () = let expected = [ [%stri let rec gen_sized n = QCheck.Gen.map (fun gen0 -> Foo gen0) (QCheck.Gen.list (gen_sized (n / 2)))]; [%stri let gen = QCheck.Gen.sized gen_sized]; [%stri let arb_sized n = QCheck.make @@ (gen_sized n)]; [%stri let arb = QCheck.make @@ gen]; ] in let actual = f @@ extract [%stri type t = Foo of t list] in check_eq ~expected ~actual "deriving rec type in a type constructor inside variant" let test_faulty_is_rec_constr_decl () = let expected = [ [%stri let rec gen_sized n = match n with | 0 -> QCheck.Gen.pure Foo | _ -> QCheck.Gen.frequency [(1, (QCheck.Gen.pure Foo)); (1, (QCheck.Gen.map (fun gen0 -> Bar { baz = gen0 }) (gen_sized (n / 2))))]]; [%stri let gen = QCheck.Gen.sized gen_sized]; [%stri let arb_sized n = QCheck.make @@ (gen_sized n)]; [%stri let arb = QCheck.make @@ gen]; ] in let actual = f @@ extract [%stri type t = Foo | Bar of { baz : t }] in check_eq ~expected ~actual "deriving rec type in a type constructor inside record" let () = Alcotest.( run "ppx_deriving_qcheck tests" [ ( "deriving generator good", [ test_case "deriving int" `Quick test_int; test_case "deriving float" `Quick test_float; test_case "deriving char" `Quick test_char; test_case "deriving string" `Quick test_string; test_case "deriving unit" `Quick test_unit; test_case "deriving bool" `Quick test_bool; test_case "deriving int32" `Quick test_int32; test_case "deriving int32'" `Quick test_int32'; test_case "deriving int64" `Quick test_int64; test_case "deriving int64'" `Quick test_int64'; (* test_case "deriving bytes" `Quick test_bytes; *) test_case "deriving tuple" `Quick test_tuple; test_case "deriving option" `Quick test_option; test_case "deriving array" `Quick test_array; test_case "deriving list" `Quick test_list; test_case "deriving constructors" `Quick test_konstr; test_case "deriving dependencies" `Quick test_dependencies; test_case "deriving record" `Quick test_record; test_case "deriving equal" `Quick test_equal; test_case "deriving tree like" `Quick test_tree; test_case "deriving expr like" `Quick test_expr; test_case "deriving alpha" `Quick test_alpha; test_case "deriving variant" `Quick test_variant; test_case "deriving weight constructors" `Quick test_weight_konstrs; test_case "deriving forest" `Quick test_forest; test_case "deriving fun primitives" `Quick test_fun_primitives; test_case "deriving fun option" `Quick test_fun_option; test_case "deriving fun array" `Quick test_fun_array; test_case "deriving fun list" `Quick test_fun_list; test_case "deriving fun n" `Quick test_fun_n; test_case "deriving fun tuple" `Quick test_fun_tuple; test_case "deriving rec poly variants" `Quick test_recursive_poly_variant; test_case "deriving variant with unused fuel parameter" `Quick test_unused_variable; test_case "deriving rec type in a type constructor inside variant" `Quick test_faulty_is_rec_typ_in_variant; test_case "deriving rec type in a type constructor inside record" `Quick test_faulty_is_rec_constr_decl; ] ); ]) qcheck-0.25/test/ppx_deriving_qcheck/deriver/qcheck/test_tuple.ml000066400000000000000000000046651477416744200253440ustar00rootroot00000000000000open QCheck type a = char [@gen QCheck.Gen.pure 'a'] [@@deriving qcheck] type b = char [@gen QCheck.Gen.pure 'b'] [@@deriving qcheck] type c = char [@gen QCheck.Gen.pure 'c'] [@@deriving qcheck] type d = char [@gen QCheck.Gen.pure 'd'] [@@deriving qcheck] type e = char [@gen QCheck.Gen.pure 'e'] [@@deriving qcheck] type f = char [@gen QCheck.Gen.pure 'f'] [@@deriving qcheck] type g = char [@gen QCheck.Gen.pure 'g'] [@@deriving qcheck] type h = char [@gen QCheck.Gen.pure 'h'] [@@deriving qcheck] type i = char [@gen QCheck.Gen.pure 'i'] [@@deriving qcheck] type tup2 = a * b [@@deriving qcheck] type tup3 = a * b * c [@@deriving qcheck] type tup4 = a * b * c * d [@@deriving qcheck] type tup5 = a * b * c * d * e [@@deriving qcheck] type tup6 = a * b * c * d * e * f [@@deriving qcheck] type tup7 = a * b * c * d * e * f * g [@@deriving qcheck] type tup8 = a * b * c * d * e * f * g * h [@@deriving qcheck] let test_tup2 = Test.make ~count:10 ~name:"forall x in ('a', 'b'): x = ('a', 'b')" (make gen_tup2) (fun x -> x = ('a', 'b')) let test_tup3 = Test.make ~count:10 ~name:"forall x in ('a', 'b', 'c'): x = ('a', 'b', 'c')" (make gen_tup3) (fun x -> x = ('a', 'b', 'c')) let test_tup4 = Test.make ~count:10 ~name:"forall x in ('a', 'b', 'c', 'd'): x = ('a', 'b', 'c', 'd')" (make gen_tup4) (fun x -> x = ('a', 'b', 'c', 'd')) let test_tup5 = Test.make ~count:10 ~name:"forall x in ('a', 'b', 'c', 'd', 'e'): x = ('a', 'b', 'c', 'd', 'e')" (make gen_tup5) (fun x -> x = ('a', 'b', 'c', 'd', 'e')) let test_tup6 = Test.make ~count:10 ~name:"forall x in ('a', 'b', 'c', 'd', 'e', 'f'): x = ('a', 'b', 'c', 'd', 'e', 'f')" (make gen_tup6) (fun x -> x = ('a', 'b', 'c', 'd', 'e', 'f')) let test_tup7 = Test.make ~count:10 ~name:"forall x in ('a', 'b', 'c', 'd', 'e', 'f', 'g'): x = ('a', 'b', 'c', 'd', 'e', 'f', 'g')" (make gen_tup7) (fun x -> x = ('a', 'b', 'c', 'd', 'e', 'f', 'g')) let test_tup8 = Test.make ~count:10 ~name:"forall x in ('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'): x = ('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h')" (make gen_tup8) (fun x -> x = ('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h')) let tests = [ test_tup2; test_tup3; test_tup4; test_tup5; test_tup6; test_tup7; test_tup8; ] let tests = List.map (QCheck_alcotest.to_alcotest) tests (** {2. Execute tests} *) let () = Alcotest.run "Test_Tuple" [("Tuple", tests)] qcheck-0.25/test/ppx_deriving_qcheck/deriver/qcheck/test_variants.ml000066400000000000000000000034301477416744200260270ustar00rootroot00000000000000open QCheck open Helpers (** {1. Test variants and polymorphic variants derivation} *) (** {2. Variants} *) type colors = Red | Green | Blue [@@deriving qcheck] let pp_colors fmt x = let open Format in match x with | Red -> fprintf fmt "Red" | Green -> fprintf fmt "Green" | Blue -> fprintf fmt "Blue" let eq_colors = Alcotest.of_pp pp_colors let arb = oneofl [Red; Green; Blue] let test_variants () = test_compare ~msg:"Gen.oneofl <=> deriving variants" ~eq:eq_colors arb arb_colors type poly_colors = [`Red | `Green | `Blue] [@@deriving qcheck] let pp_poly_colors fmt x = let open Format in match x with | `Red -> fprintf fmt "`Red" | `Green -> fprintf fmt "`Green" | `Blue -> fprintf fmt "`Blue" let eq_poly_colors = Alcotest.of_pp pp_poly_colors let arb_poly = oneofl [`Red; `Green; `Blue] let test_poly_variants () = test_compare ~msg:"Gen.oneofl <=> deriving variants" ~eq:eq_poly_colors arb_poly arb_poly_colors (** {2. Tests weight} *) type letters = | A [@weight 0] | B [@@deriving qcheck] let test_weight = Test.make ~name:"arb_letters always produces B" arb_letters (function | A -> false | B -> true) |> QCheck_alcotest.to_alcotest type poly_letters = [ | `A [@weight 0] | `B ] [@@deriving qcheck] let test_weight_poly = Test.make ~name:"arb_poly_letters always produces B" arb_poly_letters (function | `A -> false | `B -> true) |> QCheck_alcotest.to_alcotest (** {2. Execute tests} *) let () = Alcotest.run "Test_Variant" [("Variants", Alcotest.[ test_case "test_variants" `Quick test_variants; test_case "test_poly_variants" `Quick test_poly_variants; test_weight; test_weight_poly ])] qcheck-0.25/test/ppx_deriving_qcheck/deriver/qcheck2/000077500000000000000000000000001477416744200226715ustar00rootroot00000000000000qcheck-0.25/test/ppx_deriving_qcheck/deriver/qcheck2/dune000066400000000000000000000004661477416744200235550ustar00rootroot00000000000000(tests (package ppx_deriving_qcheck) (names test_textual test_primitives test_qualified_names test_recursive test_tuple test_variants test_mutual test_record) (libraries qcheck-alcotest ppxlib ppx_deriving_qcheck qcheck-core) (preprocess (pps ppxlib.metaquot ppx_deriving_qcheck))) qcheck-0.25/test/ppx_deriving_qcheck/deriver/qcheck2/helpers.ml000066400000000000000000000007531477416744200246720ustar00rootroot00000000000000open QCheck2 (** {1. Helpers} *) let seed = [| 42 |] let generate gen = Gen.generate ~n:20 ~rand:(Random.State.make seed) gen (** [test_compare msg eq gen_ref gen_cand] will generate with the same seed [gen_ref] and [gen_cand], and test with Alcotest that both generators generates the same values. *) let test_compare ~msg ~eq gen_ref gen_candidate = let expected = generate gen_ref in let actual = generate gen_candidate in Alcotest.(check (list eq)) msg expected actual qcheck-0.25/test/ppx_deriving_qcheck/deriver/qcheck2/test_mutual.ml000066400000000000000000000022041477416744200255670ustar00rootroot00000000000000open QCheck2 open Helpers type tree = Leaf | Node of tree * tree and name = { a: tree } [@@deriving qcheck2] let rec pp_tree fmt x = let open Format in match x with | Leaf -> fprintf fmt "Leaf" | Node (l, r) -> fprintf fmt "Node (%a, %a)" (pp_tree ) l (pp_tree ) r let eq_tree = Alcotest.of_pp (pp_tree ) let gen_tree_ref = let open Gen in sized @@ fix (fun self -> function | 0 -> pure Leaf | n -> oneof [ pure Leaf; map2 (fun l r -> Node (l,r)) (self (n/2)) (self (n/2)); ]) let test_tree_ref () = test_compare ~msg:"gen tree <=> derivation tree" ~eq:(eq_tree ) (gen_tree_ref) (gen_tree ) let test_leaf = Test.make ~name:"gen_tree_sized 0 = Node (_, Leaf, Leaf)" (gen_tree_sized 0) (function | Leaf -> true | Node (Leaf, Leaf) -> true | _ -> false) |> QCheck_alcotest.to_alcotest let () = Alcotest.run "Test_Recursive" [("Recursive", Alcotest.[ test_case "test_tree_ref" `Quick test_tree_ref; ])] qcheck-0.25/test/ppx_deriving_qcheck/deriver/qcheck2/test_primitives.ml000066400000000000000000000052611477416744200264610ustar00rootroot00000000000000open QCheck2 open Helpers (** {1. Test primitives derivation} *) (** {2. Tests} *) type int' = int [@@deriving qcheck2] let test_int () = test_compare ~msg:"Gen.int <=> deriving int" ~eq:Alcotest.int Gen.int gen_int' type unit' = unit [@@deriving qcheck2] (* Pretty useless though, but, meh *) let test_unit () = test_compare ~msg:"Gen.unit <=> deriving unit" ~eq:Alcotest.unit Gen.unit gen_unit' type string' = string [@@deriving qcheck2] let test_string () = test_compare ~msg:"Gen.string <=> deriving string" ~eq:Alcotest.string Gen.string gen_string' type char' = char [@@deriving qcheck2] let test_char () = test_compare ~msg:"Gen.char <=> deriving char" ~eq:Alcotest.char Gen.char gen_char' type bool' = bool [@@deriving qcheck2] let test_bool () = test_compare ~msg:"Gen.bool <=> deriving bool" ~eq:Alcotest.bool Gen.bool gen_bool' type float' = float [@@deriving qcheck2] let test_float () = test_compare ~msg:"Gen.float <=> deriving float" ~eq:(Alcotest.float 0.) Gen.float gen_float' type int32' = int32 [@@deriving qcheck2] let test_int32 () = test_compare ~msg:"Gen.int32 <=> deriving int32" ~eq:Alcotest.int32 Gen.ui32 gen_int32' type int64' = int64 [@@deriving qcheck2] let test_int64 () = test_compare ~msg:"Gen.int64 <=> deriving int64" ~eq:Alcotest.int64 Gen.ui64 gen_int64' type 'a option' = 'a option [@@deriving qcheck2] let test_option () = let zero = Gen.pure 0 in test_compare ~msg:"Gen.opt <=> deriving opt" ~eq:Alcotest.(option int) (Gen.opt zero) (gen_option' zero) type 'a array' = 'a array [@@deriving qcheck2] let test_array () = let zero = Gen.pure 0 in test_compare ~msg:"Gen.array <=> deriving array" ~eq:Alcotest.(array int) (Gen.array zero) (gen_array' zero) type 'a list' = 'a list [@@deriving qcheck2] let test_list () = let zero = Gen.pure 0 in test_compare ~msg:"Gen.list <=> deriving list" ~eq:Alcotest.(list int) (Gen.list zero) (gen_list' zero) (** {2. Execute tests} *) let () = Alcotest.run "Test_Primitives" [("Primitives", Alcotest.[ test_case "test_int" `Quick test_int; test_case "test_unit" `Quick test_unit; test_case "test_string" `Quick test_string; test_case "test_char" `Quick test_char; test_case "test_bool" `Quick test_bool; test_case "test_float" `Quick test_float; test_case "test_int32" `Quick test_int32; test_case "test_int64" `Quick test_int64; test_case "test_option" `Quick test_option; test_case "test_array" `Quick test_array; test_case "test_list" `Quick test_list; ])] qcheck-0.25/test/ppx_deriving_qcheck/deriver/qcheck2/test_qualified_names.ml000066400000000000000000000014151477416744200274110ustar00rootroot00000000000000open QCheck2 open Helpers module type S = sig type t = int val gen : int QCheck2.Gen.t end module Q : S = struct type t = int [@@deriving qcheck2] end module F (X : S) = struct type t = X.t [@@deriving qcheck2] end module G = F (Q) type t = Q.t [@@deriving qcheck2] type u = G.t [@@deriving qcheck2] let test_module () = test_compare ~msg:"Gen.int <=> deriving Q.t" ~eq:Alcotest.int Gen.int gen let test_functor () = test_compare ~msg:"Gen.int <=> deriving F.t" ~eq:Alcotest.int Gen.int gen_u (** {2. Execute tests} *) let () = Alcotest.run "Test_Qualified_names" [("Qualified names", Alcotest.[ test_case "test_module" `Quick test_module; test_case "test_functor" `Quick test_functor ])] qcheck-0.25/test/ppx_deriving_qcheck/deriver/qcheck2/test_record.ml000066400000000000000000000005051477416744200255400ustar00rootroot00000000000000type t = { rec_types : string list; curr_types : string list; curr_type : string } [@@deriving qcheck2] type color = Color of { red : float; green : float; blue : float } [@@deriving qcheck2] (* TODO: use these types to test generated values inside records. For now, having these ensure the compilation *) qcheck-0.25/test/ppx_deriving_qcheck/deriver/qcheck2/test_recursive.ml000066400000000000000000000036651477416744200263030ustar00rootroot00000000000000open QCheck2 open Helpers type 'a tree = Leaf | Node of 'a * 'a tree * 'a tree [@@deriving qcheck2] let rec pp_tree pp fmt x = let open Format in match x with | Leaf -> fprintf fmt "Leaf" | Node (x, l, r) -> fprintf fmt "Node (%a, %a, %a)" pp x (pp_tree pp) l (pp_tree pp) r let eq_tree pp = Alcotest.of_pp (pp_tree pp) let gen_tree_ref gen = let open Gen in sized @@ fix (fun self -> function | 0 -> pure Leaf | n -> oneof [ pure Leaf; map3 (fun x l r -> Node (x,l,r)) gen (self (n/2)) (self (n/2)); ]) let test_tree_ref () = let gen = Gen.int in test_compare ~msg:"gen tree <=> derivation tree" ~eq:(eq_tree Format.pp_print_int) (gen_tree_ref gen) (gen_tree gen) let test_leaf = Test.make ~name:"gen_tree_sized 0 = Node (_, Leaf, Leaf)" (gen_tree_sized Gen.int 0) (function | Leaf -> true | Node (_, Leaf, Leaf) -> true | _ -> false) |> QCheck_alcotest.to_alcotest (* A slight error has been found here: If the type is named `list` then `'a list` will be derived with the QCheck generator `list` instead of the `gen_list_sized`. This could lead to a design choice: - do we allow overriding primitive types? - do we prioritize `Env.curr_types` over primitive types? *) type 'a my_list = Cons of 'a * 'a my_list | Nil [@@deriving qcheck2] let rec length = function | Nil -> 0 | Cons (_, xs) -> 1 + length xs let test_length = Test.make ~name:"gen_list_sized n >>= fun l -> length l <= n" Gen.small_int (fun n -> let l = Gen.(generate1 (gen_my_list_sized Gen.int n)) in length l <= n) |> QCheck_alcotest.to_alcotest let () = Alcotest.run "Test_Recursive" [("Recursive", Alcotest.[ test_case "test_tree_ref" `Quick test_tree_ref; test_leaf ])] qcheck-0.25/test/ppx_deriving_qcheck/deriver/qcheck2/test_textual.ml000066400000000000000000000557511477416744200257650ustar00rootroot00000000000000(** Module test for ppx_deriving_qcheck *) open Ppxlib (** Primitive types tests *) let loc = Location.none let f = Ppx_deriving_qcheck.derive_gens ~version:`QCheck2 ~loc let f' xs = List.map f xs |> List.concat let extract stri = match stri.pstr_desc with Pstr_type (x, y) -> (x, y) | _ -> assert false let extract' xs = List.map extract xs let check_eq ~expected ~actual name = let f = Ppxlib.Pprintast.string_of_structure in Alcotest.(check string) name (f expected) (f actual) let test_int () = let expected = [ [%stri let gen = QCheck2.Gen.int] ] in let actual = f @@ extract [%stri type t = int] in check_eq ~expected ~actual "deriving int" let test_float () = let expected = [ [%stri let gen = QCheck2.Gen.float] ] in let actual = f @@ extract [%stri type t = float] in check_eq ~expected ~actual "deriving float" let test_char () = let expected = [ [%stri let gen = QCheck2.Gen.char] ] in let actual = f @@ extract [%stri type t = char] in check_eq ~expected ~actual "deriving char" let test_string () = let expected = [ [%stri let gen = QCheck2.Gen.string] ] in let actual = f @@ extract [%stri type t = string] in check_eq ~expected ~actual "deriving string" let test_unit () = let expected = [ [%stri let gen = QCheck2.Gen.unit] ] in let actual = f @@ extract [%stri type t = unit] in check_eq ~expected ~actual "deriving unit" let test_bool () = let expected = [ [%stri let gen = QCheck2.Gen.bool] ] in let actual = f @@ extract [%stri type t = bool] in check_eq ~expected ~actual "deriving bool" let test_int32 () = let expected = [ [%stri let gen = QCheck2.Gen.ui32] ] in let actual = f @@ extract [%stri type t = int32] in check_eq ~expected ~actual "deriving int32" let test_int32' () = let expected = [ [%stri let gen = QCheck2.Gen.ui32] ] in let actual = f @@ extract [%stri type t = Int32.t] in check_eq ~expected ~actual "deriving int32'" let test_int64 () = let expected = [ [%stri let gen = QCheck2.Gen.ui64] ] in let actual = f @@ extract [%stri type t = int64] in check_eq ~expected ~actual "deriving int64" let test_int64' () = let expected = [ [%stri let gen = QCheck2.Gen.ui64] ] in let actual = f @@ extract [%stri type t = Int64.t] in check_eq ~expected ~actual "deriving int64'" (* let test_bytes () = * let expected = * [ * [%stri * let gen = * QCheck2.map * (fun n -> Bytes.create n) * QCheck2.(0 -- Sys.max_string_length)]; * ] * in * let actual = f @@ extract [%stri type t = Bytes.t ] in * * check_eq ~expected ~actual "deriving int64" *) let test_tuple () = let actual = f' @@ extract' [ [%stri type t = int * int]; [%stri type t = int * int * int]; [%stri type t = int * int * int * int]; [%stri type t = int * int * int * int * int]; [%stri type t = int * int * int * int * int * int]; ] in let expected = [ [%stri let gen = QCheck2.Gen.map (fun (gen0, gen1) -> (gen0, gen1)) (QCheck2.Gen.pair QCheck2.Gen.int QCheck2.Gen.int)]; [%stri let gen = QCheck2.Gen.map (fun (gen0, gen1, gen2) -> (gen0, gen1, gen2)) (QCheck2.Gen.triple QCheck2.Gen.int QCheck2.Gen.int QCheck2.Gen.int)]; [%stri let gen = QCheck2.Gen.map (fun (gen0, gen1, gen2, gen3) -> (gen0, gen1, gen2, gen3)) (QCheck2.Gen.quad QCheck2.Gen.int QCheck2.Gen.int QCheck2.Gen.int QCheck2.Gen.int)]; [%stri let gen = QCheck2.Gen.map (fun ((gen0, gen1), (gen2, gen3, gen4)) -> (gen0, gen1, gen2, gen3, gen4)) (QCheck2.Gen.pair (QCheck2.Gen.pair QCheck2.Gen.int QCheck2.Gen.int) (QCheck2.Gen.triple QCheck2.Gen.int QCheck2.Gen.int QCheck2.Gen.int))]; [%stri let gen = QCheck2.Gen.map (fun ((gen0, gen1, gen2), (gen3, gen4, gen5)) -> (gen0, gen1, gen2, gen3, gen4, gen5)) (QCheck2.Gen.pair (QCheck2.Gen.triple QCheck2.Gen.int QCheck2.Gen.int QCheck2.Gen.int) (QCheck2.Gen.triple QCheck2.Gen.int QCheck2.Gen.int QCheck2.Gen.int))]; ] in check_eq ~expected ~actual "deriving tuples" let test_option () = let expected = [ [%stri let gen = QCheck2.Gen.option QCheck2.Gen.int] ] in let actual = f' @@ extract' [ [%stri type t = int option] ] in check_eq ~expected ~actual "deriving option" let test_array () = let expected = [ [%stri let gen = QCheck2.Gen.array QCheck2.Gen.int] ] in let actual = f' @@ extract' [ [%stri type t = int array] ] in check_eq ~expected ~actual "deriving option" let test_list () = let expected = [ [%stri let gen = QCheck2.Gen.list QCheck2.Gen.string] ] in let actual = f' @@ extract' [ [%stri type t = string list] ] in check_eq ~expected ~actual "deriving list" let test_alpha () = let expected = [ [%stri let gen gen_a = gen_a]; [%stri let gen gen_a = QCheck2.Gen.list gen_a]; [%stri let gen gen_a = QCheck2.Gen.map (fun gen0 -> A gen0) gen_a]; [%stri let gen gen_a gen_b = QCheck2.Gen.map (fun (gen0, gen1) -> A (gen0, gen1)) (QCheck2.Gen.pair gen_a gen_b)]; [%stri let gen gen_left gen_right = QCheck2.Gen.map (fun (gen0, gen1) -> (gen0, gen1)) (QCheck2.Gen.pair gen_left gen_right)]; [%stri let gen_int_tree = gen_tree QCheck2.Gen.int ] ] in let actual = f' @@ extract' [ [%stri type 'a t = 'a]; [%stri type 'a t = 'a list]; [%stri type 'a t = A of 'a]; [%stri type ('a, 'b) t = A of 'a * 'b]; [%stri type ('left, 'right) t = 'left * 'right]; [%stri type int_tree = int tree] ] in check_eq ~expected ~actual "deriving alpha" let test_equal () = let expected = [ [%stri let gen = QCheck2.Gen.frequency [ (1, QCheck2.Gen.pure A); (1, QCheck2.Gen.pure B); (1, QCheck2.Gen.pure C); ]]; [%stri let gen_t' = QCheck2.Gen.frequency [ (1, QCheck2.Gen.pure A); (1, QCheck2.Gen.pure B); (1, QCheck2.Gen.pure C); ]]; ] in let actual = f' @@ extract' [ [%stri type t = A | B | C]; [%stri type t' = t = A | B | C] ] in check_eq ~expected ~actual "deriving equal" let test_dependencies () = let expected = [ [%stri let gen = QCheck2.Gen.frequency [ (1, QCheck2.Gen.map (fun gen0 -> Int gen0) SomeModule.gen); ( 1, QCheck2.Gen.map (fun gen0 -> Float gen0) SomeModule.SomeOtherModule.gen ); ]]; [%stri let gen = gen_something]; ] in let actual = f' @@ extract' [ [%stri type t = | Int of SomeModule.t | Float of SomeModule.SomeOtherModule.t]; [%stri type t = (Something.t[@gen gen_something])]; ] in check_eq ~expected ~actual "deriving dependencies" let test_konstr () = let expected = [ [%stri let gen = QCheck2.Gen.map (fun gen0 -> A gen0) QCheck2.Gen.int]; [%stri let gen = QCheck2.Gen.frequency [ (1, QCheck2.Gen.map (fun gen0 -> B gen0) QCheck2.Gen.int); (1, QCheck2.Gen.map (fun gen0 -> C gen0) QCheck2.Gen.int); ]]; [%stri let gen = QCheck2.Gen.frequency [ (1, QCheck2.Gen.map (fun gen0 -> X gen0) gen_t1); (1, QCheck2.Gen.map (fun gen0 -> Y gen0) gen_t2); (1, QCheck2.Gen.map (fun gen0 -> Z gen0) QCheck2.Gen.string); ]]; [%stri let gen = QCheck2.Gen.frequency [ (1, QCheck2.Gen.pure Left); (1, QCheck2.Gen.pure Right) ]]; [%stri let gen = QCheck2.Gen.frequency [ (1, QCheck2.Gen.map (fun gen0 -> Simple gen0) QCheck2.Gen.int); ( 1, QCheck2.Gen.map (fun (gen0, gen1) -> Double (gen0, gen1)) (QCheck2.Gen.pair QCheck2.Gen.int QCheck2.Gen.int) ); ( 1, QCheck2.Gen.map (fun (gen0, gen1, gen2) -> Triple (gen0, gen1, gen2)) (QCheck2.Gen.triple QCheck2.Gen.int QCheck2.Gen.int QCheck2.Gen.int) ); ]]; ] in let actual = f' @@ extract' [ [%stri type t = A of int]; [%stri type t = B of int | C of int]; [%stri type t = X of t1 | Y of t2 | Z of string]; [%stri type t = Left | Right]; [%stri type t = | Simple of int | Double of int * int | Triple of int * int * int]; ] in check_eq ~expected ~actual "deriving constructors" let test_record () = let expected = [ [%stri let gen = QCheck2.Gen.map (fun (gen0, gen1) -> { a = gen0; b = gen1 }) (QCheck2.Gen.pair QCheck2.Gen.int QCheck2.Gen.string)]; [%stri let gen = QCheck2.Gen.map (fun (gen0, gen1) -> { a = gen0; b = gen1 }) (QCheck2.Gen.pair QCheck2.Gen.int QCheck2.Gen.string)]; [%stri let gen = QCheck2.Gen.frequency [ (1, QCheck2.Gen.map (fun gen0 -> A gen0) gen_t'); ( 1, QCheck2.Gen.map (fun (gen0, gen1) -> B { left = gen0; right = gen1 }) (QCheck2.Gen.pair QCheck2.Gen.int QCheck2.Gen.int) ); ]]; ] in let actual = f' @@ extract' [ [%stri type t = { a : int; b : string }]; [%stri type t = { mutable a : int; mutable b : string }]; [%stri type t = A of t' | B of { left : int; right : int }]; ] in check_eq ~expected ~actual "deriving record" let test_variant () = let expected = [ [%stri let gen = (QCheck2.Gen.frequency [ (1, QCheck2.Gen.pure `A); (1, QCheck2.Gen.map (fun gen0 -> `B gen0) QCheck2.Gen.int); (1, QCheck2.Gen.map (fun gen0 -> `C gen0) QCheck2.Gen.string); ] : t QCheck2.Gen.t)]; [%stri let gen_t' = (QCheck2.Gen.frequency [ (1, QCheck2.Gen.pure `B); (1, gen) ] : t' QCheck2.Gen.t)]; ] in let actual = f' @@ extract' [ [%stri type t = [ `A | `B of int | `C of string ]]; [%stri type t' = [ `B | t ]]; ] in check_eq ~expected ~actual "deriving variant" let test_tree () = let expected = [ [%stri let rec gen_tree_sized gen_a n = match n with | 0 -> QCheck2.Gen.pure Leaf | _ -> QCheck2.Gen.frequency [ (1, QCheck2.Gen.pure Leaf); ( 1, QCheck2.Gen.map (fun (gen0, gen1, gen2) -> Node (gen0, gen1, gen2)) (QCheck2.Gen.triple gen_a ((gen_tree_sized gen_a) (n / 2)) ((gen_tree_sized gen_a) (n / 2))) ); ] ]; [%stri let gen_tree gen_a = QCheck2.Gen.sized (gen_tree_sized gen_a) ]; ] in let actual = f @@ extract [%stri type 'a tree = Leaf | Node of 'a * 'a tree * 'a tree]; in check_eq ~expected ~actual "deriving tree" let test_expr () = let expected = [ [%stri let rec gen_expr_sized n = match n with | 0 -> QCheck2.Gen.map (fun gen0 -> Value gen0) QCheck2.Gen.int | _ -> QCheck2.Gen.frequency [ ( 1, QCheck2.Gen.map (fun gen0 -> Value gen0) QCheck2.Gen.int ); ( 1, QCheck2.Gen.map (fun (gen0, gen1, gen2) -> If (gen0, gen1, gen2)) (QCheck2.Gen.triple (gen_expr_sized (n / 2)) (gen_expr_sized (n / 2)) (gen_expr_sized (n / 2))) ); ( 1, QCheck2.Gen.map (fun (gen0, gen1) -> Eq (gen0, gen1)) (QCheck2.Gen.pair (gen_expr_sized (n / 2)) (gen_expr_sized (n / 2))) ); ( 1, QCheck2.Gen.map (fun (gen0, gen1) -> Lt (gen0, gen1)) (QCheck2.Gen.pair (gen_expr_sized (n / 2)) (gen_expr_sized (n / 2))) ); ] ]; [%stri let gen_expr = QCheck2.Gen.sized gen_expr_sized ] ] in let actual = f @@ extract [%stri type expr = | Value of int | If of expr * expr * expr | Eq of expr * expr | Lt of expr * expr] in check_eq ~expected ~actual "deriving expr" let test_forest () = let expected = [ [%stri let rec gen_tree_sized gen_a n = QCheck2.Gen.map (fun gen0 -> Node gen0) (QCheck2.Gen.map (fun (gen0, gen1) -> (gen0, gen1)) (QCheck2.Gen.pair gen_a ((gen_forest_sized gen_a) (n / 2)))) and gen_forest_sized gen_a n = match n with | 0 -> QCheck2.Gen.pure Nil | _ -> QCheck2.Gen.frequency [ (1, QCheck2.Gen.pure Nil); ( 1, QCheck2.Gen.map (fun gen0 -> Cons gen0) (QCheck2.Gen.map (fun (gen0, gen1) -> (gen0, gen1)) (QCheck2.Gen.pair ((gen_tree_sized gen_a) (n / 2)) ((gen_forest_sized gen_a) (n / 2)))) ); ] ]; [%stri let gen_tree gen_a = QCheck2.Gen.sized (gen_tree_sized gen_a)]; [%stri let gen_forest gen_a = QCheck2.Gen.sized (gen_forest_sized gen_a)]; ] in let actual = f @@ extract [%stri type 'a tree = Node of ('a * 'a forest) and 'a forest = Nil | Cons of ('a tree * 'a forest)] in check_eq ~expected ~actual "deriving forest" let test_fun_primitives () = let expected = [ [%stri let gen = QCheck2.fun_nary QCheck2.Tuple.( QCheck2.Observable.int @-> QCheck2.Observable.int @-> o_nil) QCheck2.Gen.string]; [%stri let gen = QCheck2.fun_nary QCheck2.Tuple.( QCheck2.Observable.float @-> QCheck2.Observable.float @-> o_nil) QCheck2.Gen.string ]; [%stri let gen = QCheck2.fun_nary QCheck2.Tuple.( QCheck2.Observable.string @-> QCheck2.Observable.string @-> o_nil) QCheck2.Gen.string ]; [%stri let gen = QCheck2.fun_nary QCheck2.Tuple.( QCheck2.Observable.bool @-> QCheck2.Observable.bool @-> o_nil) QCheck2.Gen.string ]; [%stri let gen = QCheck2.fun_nary QCheck2.Tuple.( QCheck2.Observable.char @-> QCheck2.Observable.char @-> o_nil) QCheck2.Gen.string ]; [%stri let gen = QCheck2.fun_nary QCheck2.Tuple.(QCheck2.Observable.unit @-> o_nil) QCheck2.Gen.string ]; ] in let actual = f' @@ extract' [ [%stri type t = int -> int -> string]; [%stri type t = float -> float -> string]; [%stri type t = string -> string -> string]; [%stri type t = bool -> bool -> string]; [%stri type t = char -> char -> string]; [%stri type t = unit -> string]; ] in check_eq ~expected ~actual "deriving fun primitives" let test_fun_n () = let expected = [ [%stri let gen = QCheck2.fun_nary QCheck2.Tuple.( QCheck2.Observable.bool @-> QCheck2.Observable.int @-> QCheck2.Observable.float @-> QCheck2.Observable.string @-> QCheck2.Observable.char @-> o_nil) QCheck2.Gen.unit ]; ] in let actual = f @@ extract [%stri type t = bool -> int -> float -> string -> char -> unit] in check_eq ~expected ~actual "deriving fun n" let test_fun_option () = let expected = [ [%stri let gen = QCheck2.fun_nary QCheck2.Tuple.( QCheck2.Observable.option QCheck2.Observable.int @-> o_nil) QCheck2.Gen.unit ]; ] in let actual = f @@ extract [%stri type t = int option -> unit] in check_eq ~expected ~actual "deriving fun option" let test_fun_list () = let expected = [ [%stri let gen = QCheck2.fun_nary QCheck2.Tuple.( QCheck2.Observable.list QCheck2.Observable.int @-> o_nil) QCheck2.Gen.unit ]; ] in let actual = f @@ extract [%stri type t = int list -> unit] in check_eq ~expected ~actual "deriving fun list" let test_fun_array () = let expected = [ [%stri let gen = QCheck2.fun_nary QCheck2.Tuple.( QCheck2.Observable.array QCheck2.Observable.int @-> o_nil) QCheck2.Gen.unit ]; ] in let actual = f @@ extract [%stri type t = int array -> unit] in check_eq ~expected ~actual "deriving fun array" let test_fun_tuple () = let expected = [ [%stri let gen = QCheck2.fun_nary QCheck2.Tuple.( QCheck2.Observable.pair QCheck2.Observable.int QCheck2.Observable.int @-> o_nil) QCheck2.Gen.unit ]; [%stri let gen = QCheck2.fun_nary QCheck2.Tuple.( QCheck2.Observable.triple QCheck2.Observable.int QCheck2.Observable.int QCheck2.Observable.int @-> o_nil) QCheck2.Gen.unit ]; [%stri let gen = QCheck2.fun_nary QCheck2.Tuple.( QCheck2.Observable.quad QCheck2.Observable.int QCheck2.Observable.int QCheck2.Observable.int QCheck2.Observable.int @-> o_nil) QCheck2.Gen.unit ]; ] in let actual = f' @@ extract' [ [%stri type t = int * int -> unit]; [%stri type t = int * int * int -> unit]; [%stri type t = int * int * int * int -> unit]; ] in check_eq ~expected ~actual "deriving fun tuple" let test_weight_konstrs () = let expected = [ [%stri let gen = QCheck2.Gen.frequency [ (5, QCheck2.Gen.pure A); (6, QCheck2.Gen.pure B); (1, QCheck2.Gen.pure C); ]]; ] in let actual = f @@ extract [%stri type t = A [@weight 5] | B [@weight 6] | C] in check_eq ~expected ~actual "deriving weight konstrs" (* Regression test: https://github.com/c-cube/qcheck/issues/187 *) let test_recursive_poly_variant () = let expected = [ [%stri let rec gen_tree_sized gen_a n = (match n with | 0 -> QCheck2.Gen.map (fun gen0 -> `Leaf gen0) gen_a | _ -> QCheck2.Gen.frequency [ ( 1, QCheck2.Gen.map (fun gen0 -> `Leaf gen0) gen_a ); ( 1, QCheck2.Gen.map (fun gen0 -> `Node gen0) (QCheck2.Gen.map (fun (gen0, gen1) -> (gen0, gen1)) (QCheck2.Gen.pair ((gen_tree_sized gen_a) (n / 2)) ((gen_tree_sized gen_a) (n / 2)))) ); ] : tree QCheck2.Gen.t)]; [%stri let gen_tree gen_a = QCheck2.Gen.sized (gen_tree_sized gen_a) ] ] in let actual = f @@ extract [%stri type 'a tree = [ `Leaf of 'a | `Node of 'a tree * 'a tree ]] in (* On OCaml 5.1 and earlier this test hits a cornercase of the ppxlib AST-mappings to move the type annotation when pretty printed and ultimately fail this test https://github.com/ocaml-ppx/ppxlib/blob/37d7ee13f4dcac44de5244a1c1e19652a5880075/astlib/migrate_501_502.ml#L173-L181 *) let ocaml_release = Scanf.sscanf Sys.ocaml_version "%i.%i" (fun major minor -> (major,minor)) in if ocaml_release <= (5,1) then () else check_eq ~expected ~actual "deriving recursive polymorphic variants" let () = Alcotest.( run "ppx_deriving_qcheck tests" [ ( "deriving generator good", [ test_case "deriving int" `Quick test_int; test_case "deriving float" `Quick test_float; test_case "deriving char" `Quick test_char; test_case "deriving string" `Quick test_string; test_case "deriving unit" `Quick test_unit; test_case "deriving bool" `Quick test_bool; test_case "deriving int32" `Quick test_int32; test_case "deriving int32'" `Quick test_int32'; test_case "deriving int64" `Quick test_int64; test_case "deriving int64'" `Quick test_int64'; (* test_case "deriving bytes" `Quick test_bytes; *) test_case "deriving tuple" `Quick test_tuple; test_case "deriving option" `Quick test_option; test_case "deriving array" `Quick test_array; test_case "deriving list" `Quick test_list; test_case "deriving constructors" `Quick test_konstr; test_case "deriving dependencies" `Quick test_dependencies; test_case "deriving record" `Quick test_record; test_case "deriving equal" `Quick test_equal; test_case "deriving tree like" `Quick test_tree; test_case "deriving expr like" `Quick test_expr; test_case "deriving alpha" `Quick test_alpha; test_case "deriving variant" `Quick test_variant; test_case "deriving weight constructors" `Quick test_weight_konstrs; test_case "deriving forest" `Quick test_forest; test_case "deriving fun primitives" `Quick test_fun_primitives; test_case "deriving fun option" `Quick test_fun_option; test_case "deriving fun array" `Quick test_fun_array; test_case "deriving fun list" `Quick test_fun_list; test_case "deriving fun n" `Quick test_fun_n; test_case "deriving fun tuple" `Quick test_fun_tuple; test_case "deriving rec poly variants" `Quick test_recursive_poly_variant; ] ); ]) qcheck-0.25/test/ppx_deriving_qcheck/deriver/qcheck2/test_tuple.ml000066400000000000000000000010461477416744200254140ustar00rootroot00000000000000type tup2 = int * int [@@deriving qcheck2] type tup3 = int * int * int [@@deriving qcheck2] type tup4 = int * int * int * int [@@deriving qcheck2] type tup5 = int * int * int * int * int [@@deriving qcheck2] type tup6 = int * int * int * int * int * int [@@deriving qcheck2] type tup7 = int * int * int * int * int * int * int [@@deriving qcheck2] type tup8 = int * int * int * int * int * int * int * int [@@deriving qcheck2] (* TODO: use these types to test generated values inside tuples. For now, having these ensure the compilation *) qcheck-0.25/test/ppx_deriving_qcheck/deriver/qcheck2/test_variants.ml000066400000000000000000000035551477416744200261210ustar00rootroot00000000000000open QCheck2 open Helpers (** {1. Test variants and polymorphic variants derivation} *) (** {2. Variants} *) type colors = Red | Green | Blue [@@deriving qcheck2] let pp_colors fmt x = let open Format in match x with | Red -> fprintf fmt "Red" | Green -> fprintf fmt "Green" | Blue -> fprintf fmt "Blue" let eq_colors = Alcotest.of_pp pp_colors let gen = Gen.(frequency [1,pure Red; 1,pure Green; 1,pure Blue]) let test_variants () = test_compare ~msg:"Gen.oneofl <=> deriving variants" ~eq:eq_colors gen gen_colors type poly_colors = [`Red | `Green | `Blue] [@@deriving qcheck2] let pp_poly_colors fmt x = let open Format in match x with | `Red -> fprintf fmt "`Red" | `Green -> fprintf fmt "`Green" | `Blue -> fprintf fmt "`Blue" let eq_poly_colors = Alcotest.of_pp pp_poly_colors let gen_poly : poly_colors Gen.t = Gen.(frequency [1,pure `Red; 1,pure `Green; 1,pure `Blue]) let test_poly_variants () = test_compare ~msg:"Gen.oneofl <=> deriving variants" ~eq:eq_poly_colors gen_poly gen_poly_colors (** {2. Tests weight} *) type letters = | A [@weight 0] | B [@@deriving qcheck2] let test_weight = Test.make ~name:"gen_letters always produces B" gen_letters (function | A -> false | B -> true) |> QCheck_alcotest.to_alcotest type poly_letters = [ | `A [@weight 0] | `B ] [@@deriving qcheck2] let test_weight_poly = Test.make ~name:"gen_poly_letters always produces B" gen_poly_letters (function | `A -> false | `B -> true) |> QCheck_alcotest.to_alcotest (** {2. Execute tests} *) let () = Alcotest.run "Test_Variant" [("Variants", Alcotest.[ test_case "test_variants" `Quick test_variants; test_case "test_poly_variants" `Quick test_poly_variants; test_weight; test_weight_poly ])]