bnorm/kotlin-power-assert

Wrong vertical order of values of evaluated expressions in error output

AlexTrotsenko opened this issue ยท 3 comments

Given:

        val foo = 7
        val bar = 2
        val expectedResult = 3
        assert(expectedResult == bar + foo)

Current output:

java.lang.AssertionError: Assertion failed
assert(expectedResult == bar + foo)
       |              |  |     |
       |              |  |     7
       |              |  9
       |              |  2
       |              false
       3

Instead 2 and 9 should be displayed vice versa.

Just in case following is my set-up:

plugins {
    id("com.android.application")
    kotlin("android")
    kotlin("kapt")
    kotlin("plugin.serialization") version "1.4.20"
    id("de.mannodermaus.android-junit5")
    id("com.bnorm.power.kotlin-power-assert") version ""0.6.0""
}

I thought that 9 would be attached to the +.

bnorm commented

Yes, my preference for placement would be something like this:

java.lang.AssertionError: Assertion failed
assert(expectedResult == bar + foo)
       |              |  |   | |
       |              |  |   | 7
       |              |  |   9
       |              |  2
       |              false
       3

I was able to recreate the bug and am honestly not really surprised. The handling of infix and operator functions is very sub-optimal. I have a quick fix for the problem but I want to take a closer look at this area of the library and see if I can come up with a more general solution.

bnorm commented

Fixed in version 0.6.1 which has been released.