Weired output when using newlines in error messages

Koen Claessen koen at chalmers.se
Tue Jan 24 14:54:03 GMT 2012


Hi,

Yes, this is a known issue, since QuickCheck uses backspace characters
to overwrite previously written messages. (Backspace works the same on
all systems.)

I guess we could switch to using something more complicated, which
probably means being dependent on some ugly library (such as curses).
I personally think this is a big step.

You could use the function whenFail, which executes its argument (e.g.
a print statement) only when the shrinking is done. Perhaps that works
better for you.

/Koen

On Tue, Jan 24, 2012 at 1:45 PM, Simon Hengel <sol at typeful.net> wrote:
> Hi,
> when I use a multi-line error message to indicate a failed test, I get
> wired output on shrinking.
>
> Here is an example:
>
>    import Test.QuickCheck.Property
>
>    prop_foo, prop_bar :: Int -> Result
>    prop_foo n = failed {reason = "\nexpected: 23\n but got: " ++ show n}
>    prop_bar n = failed {reason = "expected: 23, but got: " ++ show n}
>
> And here is a ghci session, that illustrates the issue:
>
>    ghci> quickCheck prop_foo
>    *** Failed!
>    expected: 23
>    expected: 23
>    expected: 23
>    expected: 23
>     but got: 0 (after 1 test and 2 shrinks):
>    0
>
>    ghci> quickCheck prop_bar
>    *** Failed! expected: 23, but got: 0 (after 1 test and 1 shrink):
>    0
>
> `quickcheck prop_foo` produces redundant output, `quickcheck prop_bar`
> works just fine.
>
> Is this a know issue?
>
> Cheers,
> Simon
>
> PS: What about setting up a proper issue tracker for QuickCheck (or
>    maybe just use GitHub)?  I would be happy to help with this.
>
> _______________________________________________
> QuickCheck mailing list
> QuickCheck at projects.haskell.org
> http://projects.haskell.org/cgi-bin/mailman/listinfo/quickcheck



More information about the QuickCheck mailing list