weaver-test icon indicating copy to clipboard operation
weaver-test copied to clipboard

Invalid printing of multi-line assertions

Open kubukoz opened this issue 4 years ago • 6 comments

This might be an expecty bug, I didn't check yet.

For a test like this:


pureTest("demo") {
  assert(
    List(1, 2, 3).sum == List(
      1 + 2,
      3 + 1
    ).sum
  )
}

You will see:

[E] - demo
[E]   assertion failed (../../dev/pass/kernel/src/test/scala/com/ocado/ospnow/wms/tap/kernel/ConsumerOpsTests.scala:62)
[E]
[E]   List(1, 2, 3).sum == List(
[E]   | |           |   |  |
[E]   | 7           6   |  List(3, 4)
[E]   List(1, 2, 3)     false
[E]
[E]

You can see the 7 that was the result of the RHS, but it's not in the valid position.

kubukoz avatar Jan 25 '21 22:01 kubukoz

This was in bloop, just checked and it's also the case in sbt :)

kubukoz avatar Jan 25 '21 22:01 kubukoz

This one will have to be opened in https://github.com/eed3si9n/expecty (which we delegate power-assertions to). Fortunately, Anton and myself have stepped up as maintainers there.

Out of curiosity, what versions of weaver and scala are you using ?

Baccata avatar Jan 26 '21 09:01 Baccata

Missed this...

weaver 0.5.1, scala 2.13.4

kubukoz avatar Feb 12 '21 22:02 kubukoz

What would be the rendering you'd like to see ? Honestly I'm tempted to just make the macro fail on multi-line expressions as all possibilities I can think of will be confusing one way or the other.

Also don't hesitate to try out the latest , we're just waiting for CE3 for an official 0.6.0/0.7.0 release but I don't think we'll be breaking much between now and then.

Baccata avatar Feb 12 '21 23:02 Baccata

The project I'm using this in isn't really anything for work and there's no immediate need to upgrade 😅 I was just waiting for scala steward to do the job for me...

kubukoz avatar Feb 13 '21 03:02 kubukoz

Alright then 😄

Baccata avatar Feb 13 '21 07:02 Baccata