-
Notifications
You must be signed in to change notification settings - Fork 18
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
Fix integer overflow test with Ints #58
Conversation
test/Test/Prim/Int.purs
Outdated
-- | Necessary for the EuclideanRing test | ||
-- | so as to prevent integer overflow when multiplying large integer values |
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 do you think of naming this SmallInt
instead, usable to avoid overflows when testing large integer values? It doesn't seem specific to EuclideanRing
other than that we're using it in a test for it.
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.
Now that #57 is in, this could be refactored to use the gen
version and not even need this newtype.
test/Test/Prim/Int.purs
Outdated
instance arbitraryEuclideanRingInt :: Arbitrary EuclideanRingInt where | ||
arbitrary = do | ||
EuclideanRingInt <$> chooseInt (-10_000) 10_000 |
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.
instance arbitraryEuclideanRingInt :: Arbitrary EuclideanRingInt where | |
arbitrary = do | |
EuclideanRingInt <$> chooseInt (-10_000) 10_000 | |
instance arbitraryEuclideanRingInt :: Arbitrary EuclideanRingInt where | |
arbitrary = EuclideanRingInt <$> chooseInt (-10_000) 10_000 |
Is there a reason for -10_000
to 10_000
specifically?
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.
Number.MAX_SAFE_INTEGER is 9007199254740991
. I figured 10k was a large enough range to test without being too large to produce the overflow.
Description of the change
Fixes #30.
Checklist: