[JVM] Port remaining line number tests to stepping infrastructure.

These line number tests only tested that a set of line numbers where
present in the java bytecode. Not that they would be hit in the
right order by the debugger. Moving them to stepping tests fixes that.

This exposes a couple of issues (in particular around try-catch-finally)
that should be fixed.

A number of tests are marked as failing now. Will investigate and
work on fixes next.
This commit is contained in:
Mads Ager
2020-05-26 14:33:36 +02:00
committed by max-kammerer
parent 5db6a0b563
commit 7d7b9262e7
60 changed files with 1462 additions and 1039 deletions
@@ -0,0 +1,36 @@
// FILE: test.kt
var current = true
fun alternate(): Boolean {
current = !current
return current
}
fun foo() {
while (true) {
if (alternate()) {
break
}
}
}
fun box() {
foo()
}
// LINENUMBERS
// test.kt:19 box
// test.kt:11 foo
// test.kt:12 foo
// test.kt:6 alternate
// test.kt:7 alternate
// test.kt:12 foo
// test.kt:11 foo
// test.kt:12 foo
// test.kt:6 alternate
// test.kt:7 alternate
// test.kt:12 foo
// test.kt:13 foo
// test.kt:16 foo
// test.kt:20 box
@@ -0,0 +1,33 @@
// FILE: test.kt
class A
fun bar(a: A) = A()
fun box() {
val a = A()
bar(
bar(
bar(a)
)
)
}
// LINENUMBERS
// test.kt:8 box
// test.kt:3 <init>
// test.kt:8 box
// test.kt:11 box
// test.kt:5 bar
// test.kt:3 <init>
// test.kt:5 bar
// test.kt:10 box
// test.kt:5 bar
// test.kt:3 <init>
// test.kt:5 bar
// test.kt:9 box
// test.kt:5 bar
// test.kt:3 <init>
// test.kt:5 bar
// test.kt:9 box
// test.kt:14 box
+28
View File
@@ -0,0 +1,28 @@
// FILE: test.kt
class A {
fun foo() = this
inline fun bar() = this
}
fun box() {
val a = A()
a
.foo()
a
.bar()
}
// LINENUMBERS
// test.kt:9 box
// test.kt:3 <init>
// test.kt:9 box
// test.kt:10 box
// test.kt:11 box
// test.kt:4 foo
// test.kt:11 box
// test.kt:13 box
// test.kt:14 box
// test.kt:5 box
// test.kt:15 box
+30
View File
@@ -0,0 +1,30 @@
// FILE: test.kt
class A {
fun foo() = this
inline fun bar() = this
}
fun box() {
val a = A()
a.foo()
.foo()
a.bar()
.bar()
}
// LINENUMBERS
// test.kt:9 box
// test.kt:3 <init>
// test.kt:9 box
// test.kt:10 box
// test.kt:4 foo
// test.kt:11 box
// test.kt:4 foo
// test.kt:11 box
// test.kt:13 box
// test.kt:5 box
// test.kt:14 box
// test.kt:5 box
// test.kt:15 box
+14
View File
@@ -0,0 +1,14 @@
// FILE: test.kt
fun box() {
val x =
42
}
// IGNORE_BACKEND: JVM_IR
// The JVM_IR backend does not hit line 4. That should be fixed.
// LINENUMBERS
// test.kt:5 box
// test.kt:4 box
// test.kt:6 box
@@ -0,0 +1,32 @@
// FILE: test.kt
fun box() {
foo()
bar()
}
fun foo(i: Int = 1) {
}
inline fun bar(i: Int = 1) {
}
// TODO: The JVM_IR backend has line number 11 for the inlined
// default argument handling both before and after the actual
// body of bar. That is consistent with what happens with the
// $default method in the non-inlined case, but it is not what
// happens with the JVM backend.
// FORCE_STEP_INTO
// LINENUMBERS
// test.kt:4 box
// test.kt:8 foo$default (synthetic)
// test.kt:9 foo
// test.kt:8 foo$default (synthetic)
// test.kt:5 box
// test.kt:11 box
// test.kt:12 box
// LINENUMBERS JVM_IR
// test.kt:11 box
// LINENUMBERS
// test.kt:6 box
@@ -0,0 +1,31 @@
// FILE: test.kt
fun box() {
foo({
val a = 1
})
foo() {
val a = 1
}
}
inline fun foo(f: () -> Unit) {
val a = 1
f()
}
// LINENUMBERS
// test.kt:4 box
// test.kt:14 box
// test.kt:15 box
// test.kt:5 box
// test.kt:6 box
// test.kt:16 box
// test.kt:8 box
// test.kt:14 box
// test.kt:15 box
// test.kt:9 box
// test.kt:10 box
// test.kt:16 box
// test.kt:11 box
@@ -0,0 +1,30 @@
// FILE: test.kt
fun box() {
foo({
val a = 1
})
foo() {
val a = 1
}
}
fun foo(f: () -> Unit) {
f()
}
// LINENUMBERS
// test.kt:4 box
// test.kt:14 foo
// test.kt:5 invoke
// test.kt:6 invoke
// test.kt:14 foo
// test.kt:15 foo
// test.kt:8 box
// test.kt:14 foo
// test.kt:9 invoke
// test.kt:10 invoke
// test.kt:14 foo
// test.kt:15 foo
// test.kt:11 box
+25
View File
@@ -0,0 +1,25 @@
// FILE: test.kt
fun foo() {
if (flag) {
return
}
}
var flag = true
fun box() {
foo()
flag = false
foo()
}
// LINENUMBERS
// test.kt:12 box
// test.kt:4 foo
// test.kt:5 foo
// test.kt:13 box
// test.kt:14 box
// test.kt:4 foo
// test.kt:7 foo
// test.kt:15 box
+41
View File
@@ -0,0 +1,41 @@
// FILE: test.kt
fun foo() {
if (flag) {
"OK"
} else {
"OK"
}
val b = if (flag) {
"OK"
} else {
"OK"
}
}
var flag = true
fun box() {
foo()
flag = false
foo()
}
// LINENUMBERS
// test.kt:20 box
// test.kt:4 foo
// test.kt:5 foo
// test.kt:10 foo
// test.kt:11 foo
// test.kt:10 foo
// test.kt:15 foo
// test.kt:21 box
// test.kt:22 box
// test.kt:4 foo
// test.kt:7 foo
// test.kt:10 foo
// test.kt:13 foo
// test.kt:10 foo
// test.kt:15 foo
// test.kt:23 box
+36
View File
@@ -0,0 +1,36 @@
// FILE: test.kt
var value = false
fun cond() = value
fun foo() {
if (cond())
cond()
else
false
}
fun box() {
foo()
value = true
foo()
}
// LINENUMBERS
// test.kt:15 box
// test.kt:8 foo
// test.kt:5 cond
// test.kt:8 foo
// test.kt:11 foo
// test.kt:12 foo
// test.kt:16 box
// test.kt:17 box
// test.kt:8 foo
// test.kt:5 cond
// test.kt:8 foo
// test.kt:9 foo
// test.kt:5 cond
// test.kt:9 foo
// test.kt:12 foo
// test.kt:18 box
@@ -0,0 +1,34 @@
// FILE: test.kt
fun box() {
bar {
nop()
baz()
}
}
inline fun bar(f: () -> Unit) {
nop()
f()
}
inline fun baz() {
nop()
}
fun nop() {}
// LINENUMBERS
// test.kt:4 box
// test.kt:11 box
// test.kt:19 nop
// test.kt:12 box
// test.kt:5 box
// test.kt:19 nop
// test.kt:6 box
// test.kt:16 box
// test.kt:19 nop
// test.kt:17 box
// test.kt:7 box
// test.kt:13 box
// test.kt:8 box
+98
View File
@@ -0,0 +1,98 @@
// FILE: test.kt
class Foo {
var a: String
init {
a = x()
}
}
class Bar {
init {
val a = 5
}
init {
val b = 2
}
}
class Boo {
init {
val a = 5
}
val x = x()
init {
val b = 2
}
}
class Zoo {
init { val a = 5 }
init { val b = 6 }
init {
val c = 7
}
init { val d = 8 }
}
fun x() = ""
fun box() {
Foo()
Bar()
Boo()
Zoo()
}
// IGNORE_BACKEND: JVM_IR
// The JVM_IR does not generate code that will break on the line
// containing the `init`, nor the exit from the `init`. It only
// contains lines for the contents of the init blocks.
// LINENUMBERS
// test.kt:48 box
// test.kt:3 <init>
// test.kt:6 <init>
// test.kt:7 <init>
// test.kt:45 x
// test.kt:7 <init>
// test.kt:8 <init>
// test.kt:48 box
// test.kt:49 box
// test.kt:11 <init>
// test.kt:12 <init>
// test.kt:13 <init>
// test.kt:14 <init>
// test.kt:16 <init>
// test.kt:17 <init>
// test.kt:18 <init>
// test.kt:49 box
// test.kt:50 box
// test.kt:21 <init>
// test.kt:22 <init>
// test.kt:23 <init>
// test.kt:24 <init>
// test.kt:26 <init>
// test.kt:45 x
// test.kt:26 <init>
// test.kt:28 <init>
// test.kt:29 <init>
// test.kt:30 <init>
// test.kt:50 box
// test.kt:51 box
// test.kt:33 <init>
// test.kt:34 <init>
// test.kt:36 <init>
// test.kt:38 <init>
// test.kt:39 <init>
// test.kt:40 <init>
// test.kt:42 <init>
// test.kt:51 box
// test.kt:52 box
@@ -0,0 +1,16 @@
// FILE: test.kt
fun box() {
foo(
1 + 1
)
}
fun foo(i: Int) {
}
// LINENUMBERS
// test.kt:5 box
// test.kt:4 box
// test.kt:10 foo
// test.kt:7 box
+16
View File
@@ -0,0 +1,16 @@
// FILE: test.kt
fun box() {
1 foo
1
}
infix fun Int.foo(i: Int) {
}
// LINENUMBERS
// test.kt:4 box
// test.kt:5 box
// test.kt:4 box
// test.kt:9 foo
// test.kt:6 box
@@ -0,0 +1,20 @@
// FILE: test.kt
fun box() {
lookAtMe {
42
}
}
inline fun lookAtMe(f: () -> Int) {
val a = 21
a + f()
}
// LINENUMBERS
// test.kt:4 box
// test.kt:10 box
// test.kt:11 box
// test.kt:5 box
// test.kt:12 box
// test.kt:7 box
+12
View File
@@ -0,0 +1,12 @@
// FILE: test.kt
fun box(): String {
42!!
42.toLong()!!
return "OK"!!
}
// LINENUMBERS
// test.kt:4 box
// test.kt:5 box
// test.kt:6 box
@@ -0,0 +1,38 @@
// FILE: test.kt
fun box(){
checkEquals(test(),
fail())
checkEquals(fail(),
test())
}
public fun checkEquals(p1: String, p2: String) {
"check"
}
inline fun test() : String {
return "123"
}
fun fail() : String {
return "fail"
}
// LINENUMBERS
// test.kt:4 box
// test.kt:16 box
// test.kt:5 box
// test.kt:20 fail
// test.kt:4 box
// test.kt:12 checkEquals
// test.kt:13 checkEquals
// test.kt:7 box
// test.kt:20 fail
// test.kt:8 box
// test.kt:16 box
// test.kt:7 box
// test.kt:12 checkEquals
// test.kt:13 checkEquals
// test.kt:9 box
@@ -0,0 +1,36 @@
// FILE: test.kt
infix fun String.execute(p: String) = this + p
fun box(){
test() execute
fail()
fail() execute
test()
}
inline fun test() : String {
return "123"
}
fun fail() : String {
return "fail"
}
// LINENUMBERS
// test.kt:6 box
// test.kt:14 box
// test.kt:7 box
// test.kt:18 fail
// test.kt:6 box
// test.kt:3 execute
// test.kt:6 box
// test.kt:9 box
// test.kt:18 fail
// test.kt:10 box
// test.kt:14 box
// test.kt:9 box
// test.kt:3 execute
// test.kt:9 box
// test.kt:11 box
@@ -0,0 +1,38 @@
// FILE: test.kt
fun box(){
test(test("1", "2"),
fail())
test(fail(),
test("1", "2"))
}
public fun checkEquals(p1: String, p2: String) {
"check"
}
inline fun test(p: String, s: String) : String {
return "123"
}
fun fail() : String {
return "fail"
}
// LINENUMBERS
// test.kt:4 box
// test.kt:16 box
// test.kt:5 box
// test.kt:20 fail
// test.kt:5 box
// test.kt:4 box
// test.kt:16 box
// test.kt:7 box
// test.kt:20 fail
// test.kt:7 box
// test.kt:8 box
// test.kt:16 box
// test.kt:7 box
// test.kt:16 box
// test.kt:9 box
@@ -0,0 +1,37 @@
// FILE: test.kt
fun box(){
test() +
fail()
fail() +
test()
}
inline fun test() : String {
return "123"
}
fun fail() : String {
return "fail"
}
// IGNORE_BACKEND: JVM
// The JVM backend does not go back to line 4 and 7 for the
// addition. Instead it treats the addition of the evaluated
// arguments as being on line 5 and 8. That seems incorrect
// and the JVM_IR stepping is more correct.
// LINENUMBERS
// test.kt:4 box
// test.kt:12 box
// test.kt:5 box
// test.kt:16 fail
// test.kt:4 box
// test.kt:7 box
// test.kt:16 fail
// test.kt:8 box
// test.kt:12 box
// test.kt:7 box
// test.kt:9 box
+73
View File
@@ -0,0 +1,73 @@
// FILE: test.kt
fun foo() {
try {
mightThrow()
} catch (e: Throwable) {
return
}
val t = try {
mightThrow2()
} catch (e: Throwable) {
return
}
}
var throw1 = false
var throw2 = false
fun mightThrow() {
if (throw1) throw Exception()
}
fun mightThrow2() {
if (throw2) throw Exception()
}
fun box() {
foo()
throw2 = true
foo()
throw1 = true
foo()
}
// IGNORE_BACKEND: JVM_IR
// The JVM_IR backend will stop on line 13 even when mightThrow2
// does not throw!
// LINENUMBERS
// test.kt:29 box
// test.kt:4 foo
// test.kt:5 foo
// test.kt:21 mightThrow
// test.kt:22 mightThrow
// test.kt:5 foo
// test.kt:10 foo
// test.kt:11 foo
// test.kt:25 mightThrow2
// test.kt:26 mightThrow2
// test.kt:11 foo
// test.kt:10 foo
// test.kt:15 foo
// test.kt:30 box
// test.kt:31 box
// test.kt:4 foo
// test.kt:5 foo
// test.kt:21 mightThrow
// test.kt:22 mightThrow
// test.kt:5 foo
// test.kt:10 foo
// test.kt:11 foo
// test.kt:25 mightThrow2
// test.kt:12 foo
// test.kt:13 foo
// test.kt:32 box
// test.kt:33 box
// test.kt:4 foo
// test.kt:5 foo
// test.kt:21 mightThrow
// test.kt:6 foo
// test.kt:7 foo
// test.kt:34 box
+96
View File
@@ -0,0 +1,96 @@
// FILE: test.kt
fun foo() {
try {
mightThrow()
} catch (e: Throwable) {
"OK"
} finally {
"FINALLY"
}
val t = try {
mightThrow2()
} catch (e: Throwable) {
"OK2"
} finally {
"FINALLY2"
}
}
var throw1 = false
var throw2 = false
fun mightThrow() {
if (throw1) throw Exception()
}
fun mightThrow2() {
if (throw2) throw Exception()
}
fun box() {
foo()
throw2 = true
foo()
throw1 = true
foo()
}
// IGNORE_BACKEND: JVM_IR
// The JVM_IR backend goes back to line 17 after line 18. It has the
// sequence 17, 18, 17 which doesn't make sense.
// LINENUMBERS
// test.kt:33 box
// test.kt:4 foo
// test.kt:5 foo
// test.kt:25 mightThrow
// test.kt:26 mightThrow
// test.kt:9 foo
// test.kt:10 foo
// test.kt:12 foo
// test.kt:13 foo
// test.kt:29 mightThrow2
// test.kt:30 mightThrow2
// test.kt:13 foo
// test.kt:17 foo
// test.kt:18 foo
// test.kt:12 foo
// test.kt:19 foo
// test.kt:34 box
// test.kt:35 box
// test.kt:4 foo
// test.kt:5 foo
// test.kt:25 mightThrow
// test.kt:26 mightThrow
// test.kt:9 foo
// test.kt:10 foo
// test.kt:12 foo
// test.kt:13 foo
// test.kt:29 mightThrow2
// test.kt:14 foo
// test.kt:15 foo
// test.kt:17 foo
// test.kt:18 foo
// test.kt:12 foo
// test.kt:19 foo
// test.kt:36 box
// test.kt:37 box
// test.kt:4 foo
// test.kt:5 foo
// test.kt:25 mightThrow
// test.kt:6 foo
// test.kt:7 foo
// test.kt:9 foo
// test.kt:10 foo
// test.kt:12 foo
// test.kt:13 foo
// test.kt:29 mightThrow2
// test.kt:14 foo
// test.kt:15 foo
// test.kt:17 foo
// test.kt:18 foo
// test.kt:12 foo
// test.kt:19 foo
// test.kt:38 box
+70
View File
@@ -0,0 +1,70 @@
// FILE: test.kt
fun foo() {
try {
mightThrow()
} finally {
"FINALLY"
}
val t = try {
mightThrow2()
} finally {
"FINALLY2"
}
}
var throw1 = false
var throw2 = false
fun mightThrow() {
if (throw1) throw Exception()
}
fun mightThrow2() {
if (throw2) throw Exception()
}
fun box() {
foo()
throw2 = true
foo()
// Never gets here.
throw1 = true
foo()
}
// IGNORE_BACKEND: JVM_IR
// The JVM_IR backend goes back to line 13 after line 14. It has the
// sequence 13, 14, 13 which doesn't make sense.
// LINENUMBERS
// test.kt:29 box
// test.kt:4 foo
// test.kt:5 foo
// test.kt:21 mightThrow
// test.kt:22 mightThrow
// test.kt:7 foo
// test.kt:8 foo
// test.kt:10 foo
// test.kt:11 foo
// test.kt:25 mightThrow2
// test.kt:26 mightThrow2
// test.kt:11 foo
// test.kt:13 foo
// test.kt:14 foo
// test.kt:10 foo
// test.kt:15 foo
// test.kt:30 box
// test.kt:31 box
// test.kt:4 foo
// test.kt:5 foo
// test.kt:21 mightThrow
// test.kt:22 mightThrow
// test.kt:7 foo
// test.kt:8 foo
// test.kt:10 foo
// test.kt:11 foo
// test.kt:25 mightThrow2
// test.kt:14 foo
// test.kt:13 foo
+98
View File
@@ -0,0 +1,98 @@
// FILE: test.kt
fun foo(x: Int) {
when {
x == 21 -> foo(42)
x == 42 -> foo(63)
else -> 1
}
val t = when {
x == 21 -> foo(42)
x == 42 -> foo(63)
else -> 2
}
}
fun box() {
foo(21)
}
// IGNORE_BACKEND: JVM_IR
// The JVM_IR backend has line number 8 when leaving the first
// when. Also, the stepping is different, probably because the when
// is compiled to a switch which it isn't with JVM? The stepping
// behavior is likely OK, but should be double checked.
// LINENUMBERS
// test.kt:18 box
// test.kt:4 foo
// test.kt:5 foo
// test.kt:4 foo
// test.kt:5 foo
// test.kt:6 foo
// test.kt:4 foo
// test.kt:5 foo
// test.kt:6 foo
// test.kt:7 foo
// test.kt:10 foo
// test.kt:11 foo
// test.kt:12 foo
// test.kt:13 foo
// test.kt:10 foo
// test.kt:15 foo
// test.kt:6 foo
// test.kt:10 foo
// test.kt:11 foo
// test.kt:12 foo
// test.kt:4 foo
// test.kt:5 foo
// test.kt:6 foo
// test.kt:7 foo
// test.kt:10 foo
// test.kt:11 foo
// test.kt:12 foo
// test.kt:13 foo
// test.kt:10 foo
// test.kt:15 foo
// test.kt:12 foo
// test.kt:10 foo
// test.kt:15 foo
// test.kt:5 foo
// test.kt:10 foo
// test.kt:11 foo
// test.kt:4 foo
// test.kt:5 foo
// test.kt:6 foo
// test.kt:4 foo
// test.kt:5 foo
// test.kt:6 foo
// test.kt:7 foo
// test.kt:10 foo
// test.kt:11 foo
// test.kt:12 foo
// test.kt:13 foo
// test.kt:10 foo
// test.kt:15 foo
// test.kt:6 foo
// test.kt:10 foo
// test.kt:11 foo
// test.kt:12 foo
// test.kt:4 foo
// test.kt:5 foo
// test.kt:6 foo
// test.kt:7 foo
// test.kt:10 foo
// test.kt:11 foo
// test.kt:12 foo
// test.kt:13 foo
// test.kt:10 foo
// test.kt:15 foo
// test.kt:12 foo
// test.kt:10 foo
// test.kt:15 foo
// test.kt:11 foo
// test.kt:10 foo
// test.kt:15 foo
// test.kt:19 box
+94
View File
@@ -0,0 +1,94 @@
// FILE: test.kt
fun foo(x: Int) {
when (x) {
21 -> foo(42)
42 -> foo(63)
else -> 1
}
val t = when (x) {
21 -> foo(42)
42 -> foo(63)
else -> 1
}
}
fun box() {
foo(21)
}
// JVM_IR stops on line 8 when exiting the first when.
// LINENUMBERS
// test.kt:18 box
// test.kt:4 foo
// test.kt:5 foo
// test.kt:4 foo
// test.kt:6 foo
// test.kt:4 foo
// test.kt:7 foo
// LINENUMBERS JVM_IR
// test.kt:8 foo
// LINENUMBERS
// test.kt:10 foo
// test.kt:13 foo
// test.kt:10 foo
// test.kt:15 foo
// test.kt:6 foo
// LINENUMBERS JVM_IR
// test.kt:8 foo
// LINENUMBERS
// test.kt:10 foo
// test.kt:12 foo
// test.kt:4 foo
// test.kt:7 foo
// LINENUMBERS JVM_IR
// test.kt:8 foo
// LINENUMBERS
// test.kt:10 foo
// test.kt:13 foo
// test.kt:10 foo
// test.kt:15 foo
// test.kt:12 foo
// test.kt:10 foo
// test.kt:15 foo
// test.kt:5 foo
// LINENUMBERS JVM_IR
// test.kt:8 foo
// LINENUMBERS
// test.kt:10 foo
// test.kt:11 foo
// test.kt:4 foo
// test.kt:6 foo
// test.kt:4 foo
// test.kt:7 foo
// LINENUMBERS JVM_IR
// test.kt:8 foo
// LINENUMBERS
// test.kt:10 foo
// test.kt:13 foo
// test.kt:10 foo
// test.kt:15 foo
// test.kt:6 foo
// LINENUMBERS JVM_IR
// test.kt:8 foo
// LINENUMBERS
// test.kt:10 foo
// test.kt:12 foo
// test.kt:4 foo
// test.kt:7 foo
// LINENUMBERS JVM_IR
// test.kt:8 foo
// LINENUMBERS
// test.kt:10 foo
// test.kt:13 foo
// test.kt:10 foo
// test.kt:15 foo
// test.kt:12 foo
// test.kt:10 foo
// test.kt:15 foo
// test.kt:11 foo
// test.kt:10 foo
// test.kt:15 foo
// test.kt:19 box