Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update docs on infinite data in shrinkers #676

Open
wants to merge 2 commits into
base: fscheck3
Choose a base branch
from

Conversation

rynoV
Copy link

@rynoV rynoV commented Mar 5, 2024


When writing custom shrinkers, keep in mind that:

- The sequence of shrinks generated by the built-in shrinkers may be infinite.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not accurate. The built-in shrinkers all terminate for all inputs. If they do not, it's a bug.

Shrinking may take a long time though, but typically in pathological, constructed cases (such as a test that only fails for a particularly long input and for nothing else, and so all shrinks are tried without success)

A common problem with writing custom shrinkers is that they fail to terminate, typically because a shrinker returns a value that was already tried. A shrink function must take care never to return values that are larger or equal to its input.

When writing custom shrinkers, keep in mind that:

- The sequence of shrinks generated by the built-in shrinkers may be infinite.
- Your custom shrinker function may be called even if no tests fail, so if your tests start stalling remember to also check your shrinker for infinite loops
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see my comment on this on the corresponding issue for clarification

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.

None yet

2 participants