Skip to content

Commit

Permalink
Wrong conversion of some condition instructions with zero comparison …
Browse files Browse the repository at this point in the history
…from IR to jvm bytecode #167
  • Loading branch information
lehvolk committed Sep 26, 2023
1 parent 4ecee00 commit a9857f1
Showing 1 changed file with 43 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,49 @@ package org.jacodb.testing.cfg

class WhenExpr {

val x = 1
val nx: Any? = 0
val nn: Any? = null
val x: Int = 0
val y: Int = 1

fun box() =
when (val y = x) {
in 0..2 -> "OK"
else -> "Fail: $y"
}
fun box(): String {
val ax: Any? = 0
val an: Any? = null
val bx: Int = 0
val by: Int = 1

return when {
0 != nx -> "Fail 0"
1 == nx -> "Fail 1"
!(0 == nx) -> "Fail 2"
!(1 != nx) -> "Fail 3"
x != nx -> "Fail 4"
y == nx -> "Fail 5"
!(x == nx) -> "Fail 6"
!(y != nx) -> "Fail 7"
0 == nn -> "Fail 8"
!(0 != nn) -> "Fail 9"
x == nn -> "Fail 10"
!(x != nn) -> "Fail 11"
0 != ax -> "Fail 12"
1 == ax -> "Fail 13"
!(0 == ax) -> "Fail 14"
!(1 != ax) -> "Fail 15"
x != ax -> "Fail 16"
y == ax -> "Fail 17"
!(x == ax) -> "Fail 18"
!(y != ax) -> "Fail 19"
bx != ax -> "Fail 20"
by == ax -> "Fail 21"
!(bx == ax) -> "Fail 22"
!(by != ax) -> "Fail 23"
0 == an -> "Fail 24"
!(0 != an) -> "Fail 25"
x == an -> "Fail 26"
!(x != an) -> "Fail 27"
bx == an -> "Fail 28"
!(bx != an) -> "Fail 29"
else -> "OK"
}
}
}

0 comments on commit a9857f1

Please sign in to comment.