Running properties that do not draw any random values only once

Simon Hengel sol at typeful.net
Thu Apr 12 18:49:08 BST 2012


Hi Nick,

> A monadic property might be nondeterministic, so by default I would
> still like to test it 100 times even if it doesn't do any
> quantification.

Yes, I can see that changing the default behavior here could hurt some
people.

> But I have just added a 'once' combinator that should do what you
> want. The property 'once x' is like 'x' but will only be tested once.

I think it is possible to define a more general variant of `once` with
what we already got.

    newtype Once a = Once {unOnce :: a}

    instance Testable a => Testable (Once a) where
      property     = property . unOnce
      exhaustive _ = True

I'm not asking you to add this to QuickCheck!  I'm just saying that
`exhaustive` seems to be flexible enough.  I could easily define `once`
myself; but I will most likely experiment with a different set of
combinators.

So as far as I'm concerned, we can safely move `once` > /dev/null.

And thanks a lot for the quick turnaround on this!

Cheers,
Simon



More information about the QuickCheck mailing list