I am trying to compare the QuickCheck library to the SmallCheck one. In SmallCheck I can reach particular value manipulating depth parameter. In QuickCheck:
>a<-generate (replicateM 10000 arbitrary) :: IO [Int]
>length a
10000
>maximum a
30
and my question then is: why are 10,000 "random" ("arbitrary") integers limited by 30?! I expected to see more "widely" distributed values within the range 0..10,000, maybe the maximum value close to 5,000.
The documentation contains a clue:
By default QuickCheck works by starting with 'easy' or 'small' inputs to see if it can find counterexamples with those. Only if it finds no problems with the small inputs does it gradually widen the range of generated input. The
sizevalue (which runs implicitly throughout everything that QuickCheck does) is the value that controls this behaviour.When you run QuickCheck (e.g. with quickCheck) it automatically increases the size as it goes.
You're not really supposed to use the
generatefunction directly, but if you do, you can resize it:That said, how are you supposed to use QuickCheck? The documentation describes
quickCheckalong with a multitude of variations you can use to evaluate properties.Personally, I integrate my QuickCheck properties with a unit testing framework with testProperty. You can see examples here: Property-based testing is not the same as partition testing.