[QuickCheck] Test of type Property doesn't report counter example
Lennart Kolmodin
kolmodin at gmail.com
Fri Apr 25 20:47:27 BST 2014
Hi,
I ran into an issue where a test that fails with an exception does not
report the input given to that test.
As an example, see this simple test;
quickCheck $ \x -> if (x == 10) then error "oh noes" else property True
This test either succeeds;
+++ OK, passed 100 tests.
or fails;
*** Failed! Exception: 'oh noes' (after 32 tests):
Notice the lack of the counter example!
Now if we change the test slightly, and make it Bool instead of Property;
quickCheck $ \x -> if (x == 10) then error "oh noes" else True
It either succeeds or fails with;
*** Failed! Exception: 'oh noes' (after 11 tests):
10
Aha! The counter example is given!
If we don't throw an exception but rather just fail the test with False;
quickCheck $ \x -> if (x == 10) then False else True
or
quickCheck $ \x -> if (x == 10) then property False else property True
The both succeed or fail with counter examples.
It looks to me that tests of type Property which fails with an exception
doesn't give a counter example. It look useful to me if it gave a counter
example also in this case.
Regards,
Lennart
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://projects.haskell.org/pipermail/quickcheck/attachments/20140425/68b22368/attachment.htm>
More information about the QuickCheck
mailing list