test-check

nwjsmith 2016-12-08T15:59:30.000002Z

Is there a way to observe how a generator shrinks?

nwjsmith 2016-12-08T15:59:58.000003Z

Like sample, but starting from a “big” generated value and then shrinking down?

2016-12-08T18:45:53.000004Z

theoretically yes, there's just not an easy function included that does this

2016-12-08T18:46:22.000005Z

I've written it once or twice, it's only a few lines; I probably don't have one handy though

2016-12-08T18:46:57.000006Z

your request can be interpreted a couple of different ways though

2016-12-08T18:51:30.000007Z

default shrinks are going to be less interesting; e.g., if your generator is (gen/vector gen-some-big-hairy-data-structure), then the easiest way of shrinking it consists of taking one step to []

nwjsmith 2016-12-08T19:11:17.000008Z

Maybe a version of sample that returns small, medium, big, medium, small, so that it’s easy to see how a value grows then shrinks?

2016-12-08T19:11:39.000009Z

that might be weirder than it sounds

nwjsmith 2016-12-08T19:11:53.000010Z

I should probably get a much better understanding of test.check’s shrinking before bugging you furthur

2016-12-08T19:12:02.000011Z

it's tempting to think that the growing you see in sample and in a test run is related to the shrinking you get in a failure, but they're almost entirely unrelated processes

2016-12-08T19:12:29.000012Z

I don't mind discussing it, the whole thing is currently underdocumented so I deserve to have to explain things live :)

2016-12-08T19:13:08.000013Z

another thing you could implement without too much trouble is a random shrink

2016-12-08T19:13:26.000014Z

it might not resemble too closely what would happen in a real test, but it could at least give you an idea of what sorts of steps are possible

2016-12-08T19:16:52.000015Z

@nwjsmith this part of this talk introduces the idea of a shrink tree, which is most of what you need to know to understand the shrinking mechanics: https://youtu.be/u0t-6lUvXHo?t=11m6s

nwjsmith 2016-12-08T19:17:27.000016Z

Oh, excellent. Thanks!

2016-12-08T19:27:25.000017Z

I suppose it's a rather steep introduction, but it's at least better than me typing stuff