Reputation: 41
Is there a way to falsify this (wrong) property:
prop :: Eq a => [a] -> Bool
prop xs = reverse xs == xs
When i Use QuickCheck and later VerboseCheck it gives 100 different forms of:
[(),(),(),(),(),(),(),(),(),(),(),(),(),(),()]
Passed:
and the final result is:
+++ OK, passed 100 tests.
Upvotes: 4
Views: 326
Reputation: 18199
It just so happens that
Eq a
to use, and with the ExtendedDefaultRules
extension normally enabled in GHCi, it chooses ()
.()
, because it has only one (non-bottom) value, the proposition is actually true.The simplest fix is to choose (almost) any other type by providing a type annotation:
Prelude Test.QuickCheck> quickCheck (prop :: [Int] -> Bool)
*** Failed! Falsifiable (after 4 tests and 3 shrinks):
[0,1]
Upvotes: 10