test-check

nberger 2016-12-18T12:40:49.000022Z

Uploaded an alternative patch to http://dev.clojure.org/jira/browse/TCHECK-126 (Refactor c.t.c/quick-check as a state machine to provide more extension points). The new patch refactors c.t.c/quick-check "in-place", instead of introducing a separate namespace like in the old patch. Most important change is that it replaces the reporter-fn with a step-fn which allows feeding back the quick-check loop to drive/augment it by returning a modified quick-check state (for example, adding a timestamp, or dynamically changing the number of tests left). reporter-fn was for side-effects only, step-fn allows to do the side-effects AND modify the qc state. I understand this is not a breaking change because the reporter-fn has not been part of a release yet AFAIK

2016-12-18T12:48:44.000023Z

so step-fn is part of the public API then?

nberger 2016-12-18T12:53:06.000024Z

yes, through the new step-fn option that replaces reporter-fn. There's also a c.t.c.clojure-test/default-step-fn now

2016-12-18T12:54:14.000027Z

hm

2016-12-18T12:54:40.000028Z

I'd want to be sure that creating a well-behaved and useful step-fn isn't more difficult than a reporter-fn

nberger 2016-12-18T12:57:17.000029Z

yeah, that's a risk... we could check for nil, but not sure if much more than that... maybe check that we get a map with certain keys back? But I don't know, passing a step-fn is a bit of "advanced usage", and reading a little bit about it or seeing an example is not such a big expectation, maybe... Here's an example of a step-fn: https://github.com/clojure/test.check/compare/master...nberger:test.check2-reporter-fn#diff-5eb045ad9cf20dd057f8344a877abd89R985

nberger 2016-12-18T12:58:41.000033Z

perhaps we could provide some specs for the step-fn...

nberger 2016-12-18T13:02:59.000034Z

another option is to keep separate functions for the side-effecty part (`reporter-fn`) and the modify-qc-state part (`step-fn`? will need help with the names 😄 )

nberger 2016-12-18T13:04:30.000035Z

but I don't know... maybe that's more appropriate for a layer over this (a step-fn that composes a reporter-fn and a change-qc-state-fn or whatever)

2016-12-18T13:16:33.000036Z

what uses do you imagine a user having for a step-fn that aren't possible with reporter-fn?

nberger 2016-12-18T13:31:35.000037Z

1. implementing the stats feature 2. add timestamps at different stages of the quick-check test 3. dynamically change for how long the test should run (by changing the num-tests key, or by introducing a new abort? key in the future) 4. bound tests and shrinks in time (maybe this goes under the previous item, but it's a long-standing request in TCHECK-8 and this way it could be implemented as an extension)

nberger 2016-12-18T13:34:43.000038Z

and others that users will come up with 🙂. Another benefit IMO is that it the qc state has the same shape at all stages of the quick-check run (except for added keys during shrink that don't make sense before it starts, for example), so it should make it marginally easier for say an editor to integrate with this to provide live status of the test.check progress

nberger 2016-12-18T13:51:41.000039Z

Not sure if it gives any benefit for clojure.spec, that's something to be explored...

nberger 2016-12-18T13:52:53.000040Z

Another benefit: the periodic reporter could be re implemented to not use a global atom quite easily

2016-12-18T23:55:18.000041Z

I keep wondering if a rewrite of the generators namespace could result in a more coherent notion of size; it seems hard to come up with one

2016-12-18T23:56:22.000042Z

an initial thought is that sizing generators could be easier to understand if they tried to interpret size as a suggested value for (comp count pr-str)

2016-12-18T23:56:45.000043Z

or a suggested maximum value

2016-12-18T23:57:12.000044Z

but there are lots of cases where that's not a useful default, so users would have to be more involved with sizing to get what they want

2016-12-18T23:57:46.000045Z

and it would also be hard to pull off, especially for combining collection generators with custom generators using gen/bind

2016-12-18T23:58:09.000046Z

it'd be useful to know how well the other quickchecks do at this

2016-12-18T23:59:59.000048Z

I don't like that clojure.spec needed to do some weird depth-tracking thing