-
Notifications
You must be signed in to change notification settings - Fork 120
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature Request: Get failed value (instead of outputting to IO) #117
Comments
Hi, The trouble is, what type should the counterexample have?
For this feature to work, the type of properties would need to be enriched to encode which types were quantified over. This change would of course be extremely backwards-incompatible. For now, the best thing is to make your property write to an For simple properties which don't use any of the property combinators like
You can use it like this:
Perhaps this code should go into QuickCheck somewhere but then again it's quite limited. |
I polished this idea a bit and put it into a library, which is now on Hackage: http://hackage.haskell.org/package/quickcheck-with-counterexamples |
Thank you @nick8325 for this great library! |
In case you aren't aware, you can easily use a non-snapshot package with stack by adding it to the In this case this would look like:
The stack.yaml for your global / default project is typically at |
I wouldn't mind doing so in the future, but I would like to wait for a bit in case there are any serious bugs or whatever. |
How about providing counterexamples as |
I used |
We have a new feature in the pipeline for addressing this in #376 |
I saw this SO post https://stackoverflow.com/questions/8191131/find-the-value-that-failed-for-quickcheck
is it possible to have a function like this build into quickcheck itself?
My use case is that i have a parser and a pretty printer and the test flow is like this:
quickcheck generate random syntax tree -> print -> source code -> parse -> syntax tree (should be same as input)
If a test case fails i get the syntax tree which is hard to read and i like to try to send it to the printer.
The text was updated successfully, but these errors were encountered: