Giter VIP home page Giter VIP logo

Comments (3)

jmid avatar jmid commented on June 11, 2024

Acknowledged! 🙂

In a past role teaching this stuff I prepared slides to explain the Gen.t vs arbitrary difference.
See https://janmidtgaard.dk/quickcheck/slides/lec03.pdf from p.48 of the pdf (labeled 21/48 in the bottom right corner).
The slides summarize my own view: Gen.t is purely for generation and nothing else, while arbitrary is a generator packaged up with a corresponding printer, shrinker, etc.

With that in mind, e.g., a string arbitrary combinator needing a 'size generator' we really only need "something that can generate an int size", i.e., an int Gen.t.

Whereas my old slides go top-down, the relevant Cornell book chapter instead explains this bottom-up, starting from "pure generation" and explains arbitrary as their enhancement IIRC.

Finally I should mention that QCheck2 with integrated shrinking, doesn't have the same distinction because generators and shrinkers are merged into one common (lazy tree) structure.

For example: I need a small list of key-value pairs. Should I use the Gen.t or arbitrary combinators to define this?

Tests built with Test.make accept an arbitrary in order to be able to print (and shrink) any counterexamples.
As such I expect you would want something like the following (using char keys and bool values):

list_of_size Gen.small_nat (pair char bool) : (char * bool) list QCheck.arbitrary =

Notice how this uses Gen.t for size generation, for the reason explained above.

I hope this helps! As always, PRs to improve the documentation are very welcome! 🙏😃

from qcheck.

lindig avatar lindig commented on June 11, 2024

The documentation on the slides is helpful; maybe include a link or the slides in this repository. I believe this kind of high-level explanation would at the top of the MLI file would help. Something that is not obvious: is QCheck2 an older or more recent version? The current release is 0.21.x so I fail to see the connection and which interface should new code target?

from qcheck.

jmid avatar jmid commented on June 11, 2024

The documentation on the slides is helpful; maybe include a link or the slides in this repository. I believe this kind of high-level explanation would at the top of the MLI file would help.

That's a good point and a constructive suggestion, thanks!

Something that is not obvious: is QCheck2 an older or more recent version? The current release is 0.21.x so I fail to see the connection and which interface should new code target?

Indeed. QCheck2 offers integrated shrinking (see #106 #109 and #116 for details).
It is a newer development offering "shrinking for free", meaning an end user does not need to write a boilerplate shrinker for 'custom generators' (think: 2 for the price of 1).

QCheck2 isn't as battle tested as the older QCheck(1).
I started an effort to strengthen both implementations by adding tests in #153 and collecting a suite of shrinker benchmarks in #177 about 2 years back.
For this reason I chose to go with QCheck(1) for https://github.com/ocaml-multicore/multicoretests 1.5 years ago.
One day:tm: (famous last words) I want to switch it to QCheck2.
I believe @vch9 has already switched to using QCheck2 to test Tezos so it may indeed be ready for production.

The QCheck(1) vs. QCheck2 distinction could certainly also be made clearer in the documentation...

Finally I'm realizing that https://c-cube.github.io/qcheck/0.21/qcheck-core/QCheck2/index.html is perhaps not as easily reachable from https://c-cube.github.io/qcheck/ as one could hope for.

from qcheck.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.