Open marklam opened 6 years ago
Thank you for reporting this 💯 I'll have a look hopefully in the next few days and get back to you.
I apologize for not getting back to this sooner, but now https://github.com/hedgehogqa/fsharp-hedgehog/issues/192#issuecomment-573017758 acts as a strong reminder.
@marklam, you may want to follow https://github.com/hedgehogqa/fsharp-hedgehog/issues/192#issuecomment-575535702 until we get back on this one.
If (say) an array is declared before the generator binds in a property computation expression, it doesn't get cleared when shrinking after a test failure. If the declaration is moved after the
let!
then it's ok.This can produce misleading failure messages where the reported state is a combination of what happened during the shrinkage, not what caused the original failure.
As a (contrived) repro case, this test takes 10 integers and copies the distinct values into an array of int options. It then tests that the
Some
values are the sorted distinct values (so it fails).During shrinkage, the
input
array is made shorter but thebuffer
array has items left-over. The output reads:But if the buffer declaration is moved, the shrinkage works properly and the message reads:
Even if this is by-design behaviour, it might be worth noting it in the docs