is warning about shrinking chain based arbitrary still valid?
See original GitHub issue⚠️ Be aware that the shrinker of such construct might not be able to shrink as much as possible
Is it still valid? Shouldn’t this PR https://github.com/dubzzz/fast-check/pull/113 have made shrinking of chain smarter?
If it’s still valid. Do you have some example case in which chain
is resulting in not that good shrink? Just want to know how bad it can be so I can properly evaluate my use of chain
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
1.7.1 - jqwik User Guide
Failure Reporting. Report both the original failing sample and the shrunk sample. Caveat: The samples are reported after their use in the property...
Read more >Shrinking money funds may risk systemic ructions - Reuters
A shrinking money market fund industry has a ripple effect in the repo market, whose liquidity affects trading in cash government bonds. Market ......
Read more >[LibOS] Add support for shrinking encrypted files via truncate(2 ...
At times, geth needs to rewind the state of the blockchain to a previous block. It does so by shrinking the size of...
Read more >Property-based testing of Plutus contracts
We choose not to shrink password/guess parameters, because they are not really significant–one password is as good as another in a failed test....
Read more >Clothing Sizes: How Vanity Sizing Made Shopping Impossible
They're also discriminatory: 67% of American women wear a size 14 or above, and most stores don't carry those numbers, however arbitrary they...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks for the explanation! I have created https://github.com/dubzzz/fast-check/pull/652 to update the docs (feel free to reject it if you have better plans for updating documentation)
This warning is unfortunately still true today. The PR #113 enhances the situation but does not solve the whole issue.
Let’s consider the following case: we want to generate a pair of values -
(a, b)
- such thata
is always smaller or equal tob
. In order to build that pair we have many alternatives, some based onchain
and others onmap
. Let’s investigate two of them on a predicate that will fail ifa
andb
are too far from each others.First to notice:
map
-based implementation goes straight to the smaller failure on shrink. On the other handchain
-based shrinker is more chaotic.Second thing:
chain
-based does not report the smaller possible error. Indeed the gap betweena
andb
is larger than expected. Withmap
-based you should always get the minimal failure on this precise example.Aditionally if you run the
chain
-based proposal locally you’ll see that shrinker behaves strangely (from an external user point of view) in some situations. Here is an extract of such strange behaviour:What exactly happens there is fully expected given we used
chain
. Basically our property failed for{a: 7, b: 58}
. Arbitrary produced bychain
will behave as follow:b
(because it drives the chain)b
is29
. Basically58 / 2
b
let’s generate a newa
a
has no special link with the originala
. It has been generated from scratch.a
is24
and fulfills the propertyThere are several consequences:
a
)The scenario above is basically where
chain
fails and why we should try to usemap
orfilter
instead.By the way, just to complete the picture, in the scenario described above if we wanted to shrink
[{"a":7,"b":58}]
whileb
was already the minimal value, then the shrinker ofchain
would have shrunka
at constantb
. It would have generated[{"a":3,"b":58}]
.