jlink / shrinking-challenge

Comparing shrinking approaches and performance across different PBT libraries

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Length list - generating a list "of precise length", shouldn't shrink to a list of length 1

nth-commit opened this issue · comments

I'm wondering where other people/libraries sit on this challenge, I'm surprised by the fact that all the examples end up on the counterexample suggested in the blurb.

A list should be generated first by picking a length between 1 and 100, then by generating a list of precisely that length whose elements are integers between 0 and 1000. The test should fail if the maximum value of the list is 900 or larger.

This to me sounds like a constraint on generated values. The list should only ever have the length that it binds to, which is the length determined by the generator on the left-side of the bind. As a consumer, if I specifically ask for a list of length = x, I would not expect to see counterexamples where length != x, which is what this example implies.

Ignoring the bind, if I ask for a list of length 5, I would expect the minimal counterexample to be something like [0,0,0,0,900], not [900]. Likewise, if I ask for a list of length 10, I would expect to see something like [0,0,0,0,0,0,0,0,0,900]. I would expect this behaviour if the length of the list was determined by a bind or otherwise.

Now, if I was asking for a list where the length was at most x, then I would expect to see the counterexample [900].

Hold the line. I think I understand 😅 The left-side of the bind should shrink to 1.