-
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
Gen.posNum fails to produce a value, listOfN and other combinators don't handle this #568
Comments
@zakpatterson This is an intentional result of a change that enables floating point numbers between 0 and 1 to be generated. We could do something more sophisticated to change this behavior for integral types, but for fractional types it's very unlikely we'll be able to avoid throwing away some values. |
@non interesting. Thanks for the explanation. It seems though other parts of scalacheck are not checking for this behavior, for example Gen.listOfN will just return None forever given a large N: scala> Gen.listOfN(10000, Gen.posNum[Int]).sample
res2: Option[List[Int]] = None |
@zakpatterson Yeah, I think
|
Ok, I'll take a shot at a PR for at least the first. |
About the |
@zakpatterson My claim is that I'm planning to work on that part myself. |
Whats the reason why? EDIT: Also I agree if |
I'd support the property that generator With Gen.posNum merged in #569 I move to close the [rest of the] issue as wontfix. |
Hi there. Looks like things became even worse after upgrading from 1.14.3 to 1.15.1. val nestedGen = Gen.listOf(Gen.resize(5, Gen.nonEmptyListOf(Gen.asciiChar)))
Prop
.forAll(nestedGen, nestedGen, nestedGen, nestedGen, nestedGen, nestedGen, nestedGen, nestedGen) {
(_, _, _, _, _, _, _, _) => true
}
.check() It always succeeds on 1.14.3 but almost always fails on 1.15.1 with the following error:
As far I as can see, the implementation of In my particular case I have a quite sophisticated generator in my tests (with nested sub-generators) that started failing after the upgrade. I managed to elaborate a work-around by replacing
which works fine for me, although I'd prefer to call to But I wonder, wouldn't it better to take a similar approach for
Comparing to the current implementation:
I.e. to guarantee that a buildable always has an extra element rather than discarding empty buildables (which makes the whole generator unreliable in some cases). wdyt? |
If there is a regression with |
On 1.14.2 and 1.14.1, I get the following:
This issue is absent on 1.14.0:
This might be related to #567
1.14.1 failing build
1.14.2 failing build
My project's version pr
My use case
The text was updated successfully, but these errors were encountered: