Verifying a list of properties using QuickCheck

Hi, I would like to verify a list of properties using QuickCheck. Of course, I can test a single property using: quickCheck :: Testable prop => prop -> IO () Then, I can check a list of properties my mapping this function over a list: quickCheckL :: Testable prop => [prop] -> IO () quickCheckL = mapM_ quickCheck This gives me a result for each property: Prelude Test.QuickCheck> quickCheckL [1==1,2==2] OK, passed 100 tests. OK, passed 100 tests. However, I would like a single result for the complete list of properties instead of a result for each property. I realize that this restricts the properties to be of the same type, but that isn't a problem for my application. Did I miss a library function that provides me this functionality? Regards, Thomas

On Mon, Oct 20, 2008 at 01:29:10PM +0200, Thomas van Noort wrote:
Hi,
I would like to verify a list of properties using QuickCheck. Of course, I can test a single property using:
quickCheck :: Testable prop => prop -> IO ()
Then, I can check a list of properties my mapping this function over a list:
quickCheckL :: Testable prop => [prop] -> IO () quickCheckL = mapM_ quickCheck
This gives me a result for each property:
Prelude Test.QuickCheck> quickCheckL [1==1,2==2] OK, passed 100 tests. OK, passed 100 tests.
However, I would like a single result for the complete list of properties instead of a result for each property. I realize that this restricts the properties to be of the same type, but that isn't a problem for my application.
Did I miss a library function that provides me this functionality?
If you use QuickCheck 2, you could 'mapM quickCheckResult' over your list of properties, and then check that all the results returned Success. You could also try using the HTF library [1], I seem to recall that it has this sort of functionality baked in. -Brent [1] http://hackage.haskell.org/cgi-bin/hackage-scripts/package/HTF

Thomas van Noort wrote:
However, I would like a single result for the complete list of properties instead of a result for each property. I realize that this restricts the properties to be of the same type, but that isn't a problem for my application.
Why not concatenate your properties into one big conjuction? Prelude Test.QuickCheck> (quickCheck . and) [1==1,2==2] +++ OK, passed 100 tests. Martijn.

On Oct 22, 2008, at 1:03 PM, Martijn van Steenbergen wrote:
Thomas van Noort wrote:
However, I would like a single result for the complete list of properties instead of a result for each property. I realize that this restricts the properties to be of the same type, but that isn't a problem for my application.
Why not concatenate your properties into one big conjuction?
Prelude Test.QuickCheck> (quickCheck . and) [1==1,2==2] +++ OK, passed 100 tests.
Martijn.
What to do when your properties are parametrised by some `arbitrary' value? Sebastiaan.

Thomas van Noort wrote:
However, I would like a single result for the complete list of properties instead of a result for each property. I realize that this restricts the properties to be of the same type, but that isn't a problem for my application.
You're types can be different, so long as the result of quickCheck isn't. I've often seen (and used): data Test = forall a. (Testable a) => T String a testSetA :: [Test] testSetA = [T "1+1=2" prop_onePlusOne ,T "2+2=5" prop_twoPlusTwo ... ] tests = testSetA ++ testSetB ++ ... runTests = :: [Test] -> Bool runTests = and $ map runTest tests runTest :: Test -> Bool runTest (T s a) = putStr (s ++ ": ") >> quickCheck a >> putStr "\n" Tom
participants (5)
-
Brent Yorgey
-
Martijn van Steenbergen
-
Sebastiaan Visser
-
Thomas M. DuBuisson
-
Thomas van Noort