-
Notifications
You must be signed in to change notification settings - Fork 130
Open
Labels
Description
Generate edge cases (minBound, maxBound, minBound + 1, ...) with some low frequency.
abs always returns a positive number right?
>>> quickCheck (\(n :: Int) -> abs n >= 0)
+++ OK, passed 100 tests.Alright let's ship it — well — the test fails if we run it on Int8s often enough
>>> quickCheck (\(n :: Int8) -> abs n >= 0)
+++ OK, passed 100 tests.
>>> quickCheck (\(n :: Int8) -> abs n >= 0)
+++ OK, passed 100 tests.
>>> quickCheck (\(n :: Int8) -> abs n >= 0)
+++ OK, passed 100 tests.
>>> quickCheck (\(n :: Int8) -> abs n >= 0)
*** Failed! Falsifiable (after 23 tests):
-128Turns out it doesn't actually hold for Ints
>>> abs @Int minBound
-9223372036854775808This could be detected for larger sample spaces like Int if minBound were generated. I would like to see this in the Arbitrary Int instance but maybe a modifier is better?
Reactions are currently unavailable