Fork me on GitHub
#clojure-spec
<
2016-12-18
>
gfredericks12:12:09

I wrote a little essay about growth & shrinking of test.check generators: https://github.com/clojure/test.check/blob/master/doc/growth-and-shrinking.md

mfikes17:12:27

Is it considered bad practice to employ custom generators to produce values that lead to decent perf of the functions being checked? Motivation: You have a function which, for certain valid inputs, would slow down checking considerably. Would it be considered an abuse of s/with-gen for this purpose, or is there a better way, or is this still an open question?

mfikes18:12:52

A concrete hypothetical example: Testing the 2-arg arity of repeat. You want the spec to allow any number for n, but you want to limit the size of the generated values of n, just for testing purposes.

dergutemoritz18:12:23

@mfikes Seems like the essay @gfredericks just posted here is relevant to your question: https://github.com/clojure/test.check/blob/master/doc/growth-and-shrinking.md -- it only hints at sizing being relevant for performance (memory usage) but in general I think it makes sense to apply custom generators for this purpose. I don't have authority on blessing it as a good practice, though 🙂

Alex Miller (Clojure team)19:12:26

You can also supply the generators at test time rather than in the registered spec if you want smaller scope

gfredericks20:12:32

👍 to all that