-
Notifications
You must be signed in to change notification settings - Fork 154
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
[WIP] Revamp instances of Arbitrary for Numeric #106
[WIP] Revamp instances of Arbitrary for Numeric #106
Conversation
jedesah
commented
Dec 14, 2015
- Remove hardcoded Int
- Add instances for shapeless.Nat
- Remove hardcoded Int - Add instances for shapeless.Nat
There is still a few things to add. In particular an extra property test, as it stands this will probably decrease coverage, but wanted to open the PR sooner rather than later in order to get feedback and avoid extra work. |
Thanks for the PR, @jedesah. I'll take a deeper look at it later today. |
checkArbitraryRefType[Refined, Long, Greater[Nat._10]] | ||
|
||
property("Greater range") = | ||
forAll { (min: Refined[Long, Greater[Nat._10]], max: Refined[Long, Greater[Nat._10]]) => |
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.
If min > max
greaterArbitraryRange[Refined, Long, Nat._10](min, max)
probably doesn't produce any values which seems to be the cause of the failed Travis build.
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.
Yup, that seems like a reasonable hypothesis. Can probably add a precondition on the outer property.
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.
Tried that. The filter is still triggering scalacheck to abandon. I think there is a way to increase the ratio of discarded examples without triggering the property to abandon the "proof". Or is there a better way to encode information in the types?
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.
You could do a runtime check which of min
and max
is the smaller resp. greater value and then pass the smaller as first arg and the greater as second arg to greaterArbitraryRange
.
The |
I think it might be better to provide a (low priority?) instance for Btw, what are the different types for which I need to create instances? Probably all the types in the standard library that have instances for |
If I'm handed a Yes, we should have instances for all types that have |
Ah, I assumed it would throw an exception, but I just tested it out with |
I also just learned that |