haf / expecto

A smooth testing lib for F#. APIs made for humans! Strong testing methodologies for everyone!
Apache License 2.0
663 stars 96 forks source link

Expecto.Diff seems to mix up actual and expected #419

Closed lydell closed 3 years ago

lydell commented 3 years ago

Repro repo: https://github.com/lydell/ExpectoDiffMixup

I’ve enabled Expecto.Diff:

Expect.defaultDiffPrinter <- Diff.colourisedDiff

Running this assertion:

Expect.equal "actual text" "expected text" ""

… results in this message:

. String does not match at position 0. Expected char: 'e', but got 'a'.
---------- Actual: --------------------
expected text
---------- Expected: ------------------
actual text

The Expected char: 'e', but got 'a'. is correct, but the part after is mixed up. I would expect this:

. String does not match at position 0. Expected char: 'e', but got 'a'.
---------- Actual: --------------------
actual text
---------- Expected: ------------------
expected text

Screen shot:

image

Also note how the blue color leaks into the -- Actual: -- line. It’s even more apparent if both actual and expected start with some common text – notice how the first “some” is blue, while it should be white:

image

It’s worse if you use Expecto.Diff.equals in Xunit using dotnet test:

image

Notice how the red color leaks into the diff and colors the first “some” red.

Pinging @drhumlen in case you’re interested 🙂