-
Couldn't load subscription status.
- Fork 1.4k
ZIO Test: Add Size Combinators #1625
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
Conversation
| * useful when the process to shrink a value is simpler than the process used | ||
| * to generate it. | ||
| */ | ||
| final def reshrink[R1 <: R, B](f: A => Sample[R1, B]): Gen[R1, B] = |
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.
Nice thinking. 👍
| * Returns two raised to the specified power. If the specified power is | ||
| * negative returns zero. | ||
| */ | ||
| final def pow2(n: Int): Int = { |
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.
How about 2.pow(n)?
| * the nearest integer. If the specified integer is zero or negative returns | ||
| * zero. | ||
| */ | ||
| final def log2Ceil(n: Int): Int = { |
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.
Nothing like this in Scala / Java math lib?
| * the nearest integer. If the specified integer is zero or negative returns | ||
| * zero. | ||
| */ | ||
| final def log2Floor(n: Int): Int = { |
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.
Can also compose logs and floor, right? e.g. here
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.
This looks great and sorely needed! Just a quick question about the math combinators. Otherwise, looks perfect!
|
Yes I think you are right about the math combinators. I went down that road because all the logarithm and power operators use |
|
Looks great! |
Adds
small,medium, andlargesized combinators for generators to generate a distribution of sizes based on the size parameter. Thelargecombinator mimics the current behavior and with the size configured at100generates uniform sizes between0and100. Themediumcombinator uses an exponential distribution and so generate values between0and100but with most values towards the smaller end of the range and some larger values. Thesmallcombinator uses a logarithmic distribution and generates values between0and7with the default configuration.I changed the collection generators like
listOfto use newmediumcombinator. I think this should be a win-win in terms of performance and test coverage. We will be generating fewer larger collections which should speed up tests. And there are a lot of bugs that can be easier to catch with smaller collections that I don't think we weren't testing enough before.Resolves #1601.