-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Remove some unneeded Arbitrary
and Gen
instances
#3775
Comments
Removing cats overrides of
|
Is this something we can fix upstream? |
What's the policy for scalacheck default As for the overflow issue, I'm giving a second look at cat's current law tests implementation as it uses default |
Are you sure it's the |
If it's just about |
The tests still pass when I remove cats' overrides of the
Will try that. As for the overflow, Duration has an exception-throwing implementation of addition and substraction upon overflow, contrary to numerical primitives which silently overflow. The default instance must be constrained further. |
Thanks a lot for your investigation. |
It seems that filtering the default instances from scalacheck doesn't work. val overflowPreventionFactor = 500
val maxNs = Long.MaxValue / overflowPreventionFactor
implicit val arbitraryDuration: Arbitrary[Duration] =
Arbitrary(
Gen.duration
.filter {
case fd: FiniteDuration => fd.toNanos >= - maxNs && fd.toNanos <= maxNs
case _ => true
}
.filterNot(_ eq Duration.Undefined)
)
What can still be done is deleting the |
Thanks @larsrh for opening this small issue and for the high reactivity 👍 |
Thank you for taking care of it 😄 |
Follow-up to #3772.
ScalaCheck already provides instances for
Duration
andFiniteDuration
. We should use them and delete ours. If it turns out that the ScalaCheck provided instances don't work for us, we should fix them upstream.Requires deleting some lines in https://github.com/typelevel/cats/blob/master/kernel-laws/shared/src/test/scala/cats/kernel/laws/LawTests.scala.
The text was updated successfully, but these errors were encountered: