-
Notifications
You must be signed in to change notification settings - Fork 40
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
Getting values outside of range when using gen.IntRange (probably during shrink) #81
Comments
No, the IntRange should not shrink outside the given range. Can you give me a short sniplet about the different ways you construct the initial state, i.e. the working variant and the one that panics |
Hello, and thanks for following up! I've simplified my test to try to reduce it to a condensed form. I think the a second IntRange for the InitialState was a distraction as I can reproduce the issue with a single IntRange for the command and a constant for the InitalState. Here's the simplified example: https://gist.github.com/rciorba/79e17881b1739afe2ff504b7edbcfc73/revisions?diff=unified |
Thanks for the detailed example. There is indeed something of with command shrinker, unluckily it is not so easy to fix. So here the TLDR workaround:
Longer explanation: |
Just after writing the comment above I came up with a new solution that required only a small change. The current version in the master branch should fix the problem. |
@untoldwind Thanks for the fix! |
Sorry, seems I tried it with the "intentional bug" commented out and that never triggers the shrink stage. I can still reproduce the issue, using |
I tested with this: https://gist.github.com/untoldwind/f78910c522f6efb81ac140891016a5da According to the output the "Index" stays within its bounds during shrinking. |
Hello! Thanks for this great library and apologies in advance if this is me just missunderstanding it (go newbie).
I've got a stateful system, a bitarray and the state is a
[]bool
. I'm trying to assert that the bitarray is equivalent to the state ([]bool).I'm using 2 gen.IntRange:
Despite using IntRange to stay within the bounds of he SUT and state, I eventually see illegal values (I suspect during the shrink phase, as they only appear after the post condition fails), which causes the test to panic.
Is this intended behaviour for the gen.IntRange (to shrink outside the range)?
Another interesting detail: if I remove the IntRange from the initial state and only keep it in the command, the Index values for the command stay within range and I never see the panic.
See an example here: https://play.golang.org/p/xplrfKS_Nvm
Thanks!
The text was updated successfully, but these errors were encountered: