[Haskell-beginners] Quickcheck Preconditions

Jonas Almström Duregård jonas.duregard at chalmers.se
Wed May 25 13:09:16 CEST 2011


You can write your own generators and use the forall function. Or for these
simple examples you can just test on wrappers:

testFoo :: (a,a,a,[a]) -> IO Bool
testFoo (a1,a2,a3,as) = foo (a1:a2:a3:as)

testBar :: (a,[a]) -> Int -> IO ()
testBar (x,xs) n = bar xs' (n `mod` length xs') where xs' = x:xs

/J

On 25 May 2011 12:40, Guy <guytsalmaves-h at yahoo.com> wrote:

> I have some functions with preconditions. For example, foo::[a]->IO Bool
> requires a list of at least three elements, and bar::[a]->Int->IO ()
> requires that its second argument is some position within the list.
>
> How can I test these with quickcheck? If I use ==>, quickcheck gives up
> with very few test cases.
>
>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://www.haskell.org/mailman/listinfo/beginners
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20110525/03f86e26/attachment.htm>


More information about the Beginners mailing list