Weired output when using newlines in error messages

Nick Smallbone nick.smallbone at gmail.com
Wed Jan 25 12:37:45 GMT 2012


Hi Simon,

On 25 January 2012 12:23, Simon Hengel <sol at typeful.net> wrote:
>> What happens is that QuickCheck prints the error reason when it first
>> finds a counterexample, then starts shrinking. Whenever it
>> successfully shrinks the counterexample, it backspaces over the old
>> reason to erase it and then prints the new reason.
>
> Out of curiosity, what is the purpose of printing the intermediate
> values while shrinking.

Well, it's nice to see the failure reason for the first counterexample
so you get a little bit of information immediately---did your property
return False, did it crash, etc. And you certainly want to see it for
the shrunk counterexample. So it seems reasonable to print it for the
intermediate ones too.

>> I've pushed a couple of patches that fix this: during shrinking, the
>> message is squeezed to fit on one line, and at the end the whole error
>> message is printed in full. (Single-line error messages are printed as
>> part of the "*** Failed!" line, as before, but multi-line error
>> messages are printed separately.)
>
> Works like a charm.  Thanks for that!
>
>> You might also like the printTestCase function. It includes a string
>> as part of the counterexample when a property fails. It copes fine
>> with newlines, and QuickCheck won't meddle with the formatting.
>
> Nice, looks like this is more appropriate than using `failed` directly.
> Is there something like that for monadic properties (`fail` seems to be
> analogous to `failed`).

I don't know monadic QuickCheck so well, but it seems that
   monitor (printTestCase "foo")
will work.

Nick



More information about the QuickCheck mailing list