Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@adamgfraser
Copy link
Contributor

As reported by @ghostdogpr, property based tests involving filtered generators were not terminating in certain circumstances.

The issue was that we need to use slightly different concepts of filtering for generating versus shrinking random values. For shrinking if a value doesn't satisfy the predicate we want to continue to examine its shrinks because even if a value doesn't satisfy the predicate its shrinks might and could be part of the optimal solution. In contrast, for generating random values if the value doesn't satisfy the predicate we just want to discard the entire thing, including its shrink tree. Previously we weren't doing this so if the predicate was _ > 0 and the initial random value was a negative number we would fruitlessly search its shrinks for a value satisfying the predicate.

I also added some documentation on transforming generators generally being preferable to filtering them.

This was referenced Sep 6, 2019
@ghostdogpr ghostdogpr merged commit 66ea78c into zio:master Sep 6, 2019
@adamgfraser adamgfraser deleted the filter branch September 6, 2019 15:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants