ifigueroap / racket-quickcheck

Quickcheck Clone implemented in Racket
Other
32 stars 16 forks source link

Make number of cases in `quickcheck` variants configurable #13

Closed jackfirth closed 9 years ago

jackfirth commented 9 years ago

This PR adds a parameter that can be used to tweak the number of cases quickcheck variants run. Most of the time when someone wants to provide a custom config, it's solely to increase the number of cases to run. The current defaults for max-fail-cases and the size function are not documented, so it's not clear what to use there when all you care about is the case count.

This doesn't directly expose the parameter, instead it provides a with-test-count sugar form and with-small-test-count, with-medium-test-count, and with-large-test-count sugar forms that run 100, 1000, and 10000 cases respectively.

In addition to making configuration simpler, it makes the configuration externally adjustable. For instance, given a module m.rkt that runs some quickcheck tests, another module can use dynamic-require to adjust the number of tests:

(require quichcheck)
(with-large-test-count
  (dynamic-require "m.rkt" #f))

This opens up the possibility for a command line "raco quichcheck" tool that can adjust the test configuration differently in different environments or in response to command line flags, e.g. raco quickcheck --large.

ifigueroap commented 9 years ago

It looks really cool, thanks!