I'm learning QuickCheck, and I'm puzzled by the behavior I'm seeing
with conditional properties. After writing and loading a simple qsort
function from a separate file, I typed these into ghci:
let prop_minimum xs = (length xs > 0) ==> head (qsort xs) == minimum xs
where types = xs :: [Integer]
let prop_minimum1 xs = (length xs > 3) ==> head (qsort xs) == minimum xs
where types = xs :: [Integer]
These differ only in that prop_minimum1 uses a more restrictive
condition.
Then quickCheck prop_minimum outputs
"OK, passed 100 tests"
but quickCheck prop_minimum1 outputs
"Arguments exhausted after 0 tests"
Investigating with verboseCheck yields puzzling results. For example,
verboseCheck prop_minimum says "OK, passed 100 tests", but some of the
test instances it shows have length 0, contrary to the condition...
and a significant fraction of the test instances have length > 3, or
even length > 10! So why the problem when running quickCheck on
prop_minimum1?
Running verboseCheck prop_minimum1 just deepens the mystery. Now we
see most of the test instances generated having 0 length, and none of
them having length > 3. What's going on here? Why is the
distribution of generated test instances so drastically altered?
BTW, I'm using ghc version 6.10.1, running on Intel Mac OS 10.5.5.
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe