[ANN] QCheck 0.19

I’m happy to share the release of QCheck 0.19 - a library for property-based testing in OCaml in the style of Haskell’s QuickCheck.

GitHub repo: GitHub - c-cube/qcheck: QuickCheck inspired property-based testing for OCaml.
Documentation: index

The 0.19 release brings a range of new features and improvements detailed below and combines the effort of several individual contributors.

It is now available on opam.

Release notes:

  • new features and feature extensions

    • 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
    • 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.
    • add tup2 to tup9 for generators
    • add Test.make_neg for negative property-based tests, that are expected not to satisfy the tested property.
    • add environment variable QCHECK_LONG_FACTOR similar to QCHECK_COUNT
    • rename Gen.opt to Gen.option but keep the old binding for compatibility.
    • 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 arbitrarys char, printable_char, and numeral_char
  • bug fixes

    • fix function generation affecting reproducability
    • fix distribution of QCheck2.printable which would omit certain characters
    • use Float.equal for comparing floats in the Observable module underlying function generators.
  • 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
  • internal and test suite changes

    • add additional expect and unit tests and refactor expect test suite
    • add a shrinker performance benchmark
    • remove --no-buffer option on dune runtest to avoid garbling the test output
    • make test suite run on 32-bit architectures