[QuickCheck] How to evaluate a Property?
Nick Smallbone
nicsma at chalmers.se
Tue Jun 17 18:20:22 BST 2014
Hi Bryan,
If your properties are just functions which return Property instead of
Bool, then you can just use quickCheck to evaluate them on a
particular input. Example:
prop_bogus :: Int -> Int -> Property
prop_bogus x y = x === y
> quickCheck prop_bogus
*** Failed! Falsifiable (after 2 tests):
1
0
1 /= 0
> quickCheck (prop_bogus 3)
*** Failed! Falsifiable (after 1 test):
0
3 /= 0
> quickCheck (prop_bogus 3 3)
+++ OK, passed 100 tests.
> quickCheck (prop_bogus 3 4)
*** Failed! Falsifiable (after 1 test):
3 /= 4
If you start using explicit forAlls and whatnot, then you're probably
out of luck (short of refactoring), as a Property is just a function
from random number seed to test outcome, and the only thing you can
sensibly do is pass it to quickCheck.
Nick
On Friday 13 June, 2014 at 01:26 pm, Bryan O'Sullivan wrote:
> A downside of switching from Bool-typed to Property-typed tests is that I
> have no idea how to evaluate a Property by hand at the ghci command line.
> If I'm doing some narrowly directed testing by hand while I iterate on a
> bug, that can significantly slow me down.
>
> I realise that this is probably not achievable in general, but for instance
> many of my tests are simple ones involving (===), (.&&.) and the like, with
> no fanciness needed.
>
> Thanks!
> _______________________________________________
> QuickCheck mailing list
> QuickCheck at projects.haskell.org
> http://projects.haskell.org/cgi-bin/mailman/listinfo/quickcheck
More information about the QuickCheck
mailing list