-
Notifications
You must be signed in to change notification settings - Fork 122
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
IntegralGenerator shrinker or shrinking implementation seems wrong #219
Comments
@sir4ur0n What version of junit-quickcheck are you using? When I run your test from the head of
|
Tested with both
Has there been any fix since 0.8.2 release? |
I have created a repo to showcase the issue: https://github.com/Sir4ur0n/junit-quickcheck-bug-shrinker
|
Yes, something's a bit squirrely with integral shrinking. Investigating... |
I just debugged and I don't get how this is supposed to converge quickly, would you mind explaining please?
So overall, the Which makes me wonder again: is there any reason why the shrinking process goes from biggest to smallest (stopping as soon as one passes), instead of smallest to biggest, stopping as soon as one doesn't pass? Going from small to big would ensure a quick convergence, and let users provide aggressive shrinkers. Bonus point: QuickCheck (in Haskell) goes from smallest to biggest too, so that would actually make more sense to align with it. |
@sir4ur0n I agree; there's no particular reason why junit-quickcheck's shrinking implies must go from largest to smallest. If anything, I'd like to align with Haskell QuickCheck's behavior. I think it's even more ganked than I originally thought. My goal was to go from |
I did a quick trial as such:
This seems to work for my test :o
Of course this is quite a change, because the order of all shrinkers must now be reversed (i.e. not backward-compatible, probably deserves a new major release), but I think this is much better for the library. What's your opinion/idea of the next move? |
@sir4ur0n I think this sounds reasonable. Would you mind to issue a PR? Because junit-quickcheck is at a version < 1, I think this would be worth a new pre-1 minor release (0.9), with plenty of caveat to developers via the Google group. |
I agree that abandoning prior shrinks when a smaller counterexample is found sounds reasonable. If I can get it to where the shrinks are produced lazily rather than a (potentially) big list at a time, so much the better. |
* Align with Haskell's QuickCheck which shrinks from smallest to biggest (faster convergence) * Migrate test string to generic platform newline feed (builds on Windows) Closes pholser#219.
* Align with Haskell's QuickCheck which shrinks from smallest to biggest (faster convergence) * Migrate test string to generic platform newline feed (builds on Windows) * As soon as a counter example is found during shrinking, drop all remaining shrinks and start again by shrinking the smaller counter-example Closes pholser#219.
I think there is a bug either in the IntegralGenerator, or in the shrinking implementation. Example:
The starting point is
849426243
and it never shrinks lower than424713121
(i.e. more or less divided by 2).I think this is a bug: given enough time, shrinks and shrink depth (the difference between those 2 is hard to understand by the way), the generator should succeed to identify the smallest value that doesn't pass the property is
8
and not424713121
.The text was updated successfully, but these errors were encountered: