Running properties that do not draw any random values only once

Nick Smallbone nicsma at chalmers.se
Wed Apr 11 19:18:25 BST 2012


Hi Simon!

That's a good idea. It's possible to get this behaviour by looking at
the type of the property. If it has type Bool rather than a function
type, then it only needs to be tested once. I've just pushed a patch
that does exactly this:
   > quickCheck (\x -> even x || odd x)
   +++ OK, passed 100 tests.
   > quickCheck (even 2)
   +++ OK, passed 1 tests.

Nick

On 11 April 2012 17:50, Simon Hengel <sol at typeful.net> wrote:
> Hi,
> I think it would be interesting, if we could detect situation when it
> makes no sense to run a property repeatedly, say:
>
>    some_property = True
>
>
> Why is this interesting?
>
> (1) It would allow me to use QuickCheck to verify simple properties in
>    documentation (this is a frequently requested feature for doctest).
>
>    Here is an example from [1].
>
>        pathSeparator == '\\'
>
>
> (2) It would make QuickCheck suitable for cases that are currently more
>    efficiently tested with HUnit; with the added benefit that changing
>    the arity would turn such a property into a real QC property.
>
>    Say start with:
>
>        prop_foo = length xs >= 0
>          where xs = "bar"
>
>    And later turn it into:
>
>        prop_foo xs = length xs >= 0
>          where types = xs :: String
>
>
> (3) Or you could start with a QuickCheck property, and later turn it into
>    a smallcheck-like thing.
>
>    Say start with:
>
>        prop_foo x = p x
>
>    And later turn it into:
>
>        prop_foo = all p xs
>          where xs = [minBound .. maxBound]
>
>
> I haven't looked at any code yet, and haven't thought about it
> thoroughly.  So for now I'm mainly interested if somebody has already
> pushed into that direction.
>
> Could it work to just check whether a property has drawn anything from
> the random pool?
>
> Cheers,
> Simon
>
> [1] http://hackage.haskell.org/packages/archive/filepath/1.3.0.0/doc/html/System-FilePath-Posix.html
>
> _______________________________________________
> QuickCheck mailing list
> QuickCheck at projects.haskell.org
> http://projects.haskell.org/cgi-bin/mailman/listinfo/quickcheck



More information about the QuickCheck mailing list