Add a wrapper for disabling shrinking for an Arbitrary #293
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In some cases, users may want to disable shrinking for a specific test. Consider, for example, some complex recursive data type. Naturally, we'd want values to be shrunk for most tests in order to isolate the specific sub-structure provoking the failure. However, due to the complexity we may end up with a shrinker with a certain complexity in itself. Hence, we may want to test our shrinker. For those specific tests, the very shrinking of input values performed by quickcheck could get in our way or cause failures on its own.
Previously, the only way library users could disable shrinking in such cases was to define a wrapper type (in their own code) which forwarded
Arbitrary::arbitrary
but notArbitrary::shrink
. We suspect that the possibility of disabling shrinking for selected tests, such as in cases described above, is not too uncommon. The wrapper pattern is easy to understand and blends in well with quickcheck. Shipping one with the library will suit the described use-cases.The feature was requested in #285 (comment), the wrapper pattern was suggested as a user-side solution in #285 (comment).