[Haskell-cafe] Verifying a list of properties using QuickCheck

Brent Yorgey byorgey at seas.upenn.edu
Tue Oct 21 10:02:01 EDT 2008


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


More information about the Haskell-Cafe mailing list