-
Notifications
You must be signed in to change notification settings - Fork 407
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
Shrink all tuple sizes #744
base: main
Are you sure you want to change the base?
Conversation
@jonaskoelker , sorry for the long response. This PR slipped unnoticed somehow. Would you be open to actualize your PR against the current |
"org.scalacheck.Shrink.shrinkTuple2", | ||
"org.scalacheck.Shrink.shrinkTuple3", | ||
"org.scalacheck.Shrink.shrinkTuple4", | ||
"org.scalacheck.Shrink.shrinkTuple5", | ||
"org.scalacheck.Shrink.shrinkTuple6", | ||
"org.scalacheck.Shrink.shrinkTuple7", | ||
"org.scalacheck.Shrink.shrinkTuple8", | ||
"org.scalacheck.Shrink.shrinkTuple9" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What makes the new generated methods incompatible with the current ones, could you clarify please? At first glance, the generated method should be very similar to those that they are supposed to replace.
This shrinks tuples of all sizes between 2 and 22, both inclusive. This implements issue #738.
Today I learned you do automatic code generation for various bits that are symmetric across many arities. That seems like a natural and good thing to use for tuple shrinking.
I added a few test cases. With the current tuple shrinking
eqvTupleShrinks(xs, ys)
could just returnxs == ys
. However, I think tuple shrinking might be better if we interleave rather than append the various single-component streams, and I'm pretty sure the.sorted
equivalence holds if we make that change—that is, I'm deliberately testing something weaker than what I know to be true, in order to future-proof.Would you like me to make the interleaving change? The advantage of doing e.g. a snake draft across all non-empty single-component shrink streams is that when you shrink component k of an n-tuple, in a situation where no shrunk values of the first k-1 components can provoke a test failure, the number of elements you need to look at before trying to shrink component k is k-1 rather than$sum_{i to k-1} number-of-shrinks-of-component-i$ . Stated another way: relatively speaking it prioritizes earlier shrinks of later components rather than later shrinks of earlier components.
If you think there are advantages to prioritizing focusing on the first component, I'll be happy to hear about them. (One could also do a hybrid where you foldLeft a pairwise interleaving, such that the complete interleaving gives 2^-k of the attention to the k'th component.)