Reputation: 3265
So I have a property p :: Int -> Bool
. I need to test it with a custom generator g :: Gen Int
. This works and I can run
quickCheckResult $ forAll g p
I however want to have it run more than 100 tests.
The documentation says use withMaxSuccess
. This works for
quickCheck (withMaxSuccess 1000 p)
but not for
quickCheckResult $ forAll g (withMaxSuccess 1000 p)
because it results in a:
<interactive>:38:23: error:
• Couldn't match expected type ‘Int -> prop0’
with actual type ‘Property’
• Possible cause: ‘withMaxSuccess’ is applied to too many arguments
In the second argument of ‘forAll’, namely
‘(withMaxSuccess 10000 p)’
In the expression:
forAll g (withMaxSuccess 10000 p)
In an equation for ‘it’:
it = forAll g (withMaxSuccess 10000 p)
It seems that withMaxSuccess
takes the Int->Bool
and makes it a Property
How can I run forAll
for a arbitrary amount?
Upvotes: 1
Views: 117
Reputation: 233327
You just need to compose the expressions slightly differently:
quickCheckResult $ withMaxSuccess 1000 $ forAll g p
or, if you prefer brackets:
quickCheckResult ((withMaxSuccess 1000) (forAll g p))
Looking at the types should explain why that works:
Prelude Test.QuickCheck> :t forAll g p
forAll g p :: Property
Prelude Test.QuickCheck> :t withMaxSuccess 1000
withMaxSuccess 1000 :: Testable prop => prop -> Property
Prelude Test.QuickCheck> :t (withMaxSuccess 1000) (forAll g p)
(withMaxSuccess 1000) (forAll g p) :: Property
Since Property
is a Testable
instance, the types line up.
Upvotes: 1