Fork me on GitHub
#test-check
<
2016-12-08
>
nwjsmith15:12:30

Is there a way to observe how a generator shrinks?

nwjsmith15:12:58

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

gfredericks18:12:53

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

gfredericks18:12:22

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

gfredericks18:12:57

your request can be interpreted a couple of different ways though

gfredericks18:12:30

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 []

nwjsmith19:12:17

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?

gfredericks19:12:39

that might be weirder than it sounds

nwjsmith19:12:53

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

gfredericks19:12:02

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

gfredericks19:12:29

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

gfredericks19:12:08

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

gfredericks19:12:26

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

gfredericks19:12:52

@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

nwjsmith19:12:27

Oh, excellent. Thanks!

gfredericks19:12:25

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