Improve choose/2 and int/2 generators.
API level changes:
* Previously `choose/2` shrunk to the lowest limit, it now shrink to
lowest absolute value. This behavior is consistent with QuickCheck and Proper.
* Previously `int/2` ignored the bounds and always shrunk to 0. The new
behavior is equivalent to the `choose/2` function.
Previously `int/2` function always decremented by 1 when shrinking. That works
for small integers, but is very inefficient and slow for large integer
boundaries. `choose/2` on the other hand always halved its value, however it
might skip interesting values around the shrink target or the Min / Max
The improvement is to get the best for both cases. If the current value is
close to the shrinking target then decrement by 1 is used, otherwise
halving is used. The transition is done probabilistically based on an
exponential function. The closer to the interesting boundary the value is,
there is an exponentially higher chance of decrement being used.
3 files changed