Revert "Fix Kotlin debug tests by reverting formatting"
This reverts commit 90045a8492f16ba5a5897b04fe13d33b07ac30b0.
Fix the tests with the line number changes from the formatting.
Change-Id: Iecba8050866f7c2ecd7ce6295e24132644016844
diff --git a/src/test/java/com/android/tools/r8/debug/KotlinInlineTest.java b/src/test/java/com/android/tools/r8/debug/KotlinInlineTest.java
index 38d2ee1..660f9af 100644
--- a/src/test/java/com/android/tools/r8/debug/KotlinInlineTest.java
+++ b/src/test/java/com/android/tools/r8/debug/KotlinInlineTest.java
@@ -56,29 +56,32 @@
DEBUGGEE_CLASS,
breakpoint(DEBUGGEE_CLASS, methodName),
run(),
- inspect(s -> {
- assertEquals(DEBUGGEE_CLASS, s.getClassName());
- assertEquals(methodName, s.getMethodName());
- assertEquals(SOURCE_FILE, s.getSourceFile());
- assertEquals(41, s.getLineNumber());
- s.checkLocal("this");
- }),
+ inspect(
+ s -> {
+ assertEquals(DEBUGGEE_CLASS, s.getClassName());
+ assertEquals(methodName, s.getMethodName());
+ assertEquals(SOURCE_FILE, s.getSourceFile());
+ assertEquals(40, s.getLineNumber());
+ s.checkLocal("this");
+ }),
stepOver(),
- inspect(s -> {
- assertEquals(DEBUGGEE_CLASS, s.getClassName());
- assertEquals(methodName, s.getMethodName());
- assertEquals(SOURCE_FILE, s.getSourceFile());
- assertEquals(42, s.getLineNumber());
- s.checkLocal("this");
- }),
+ inspect(
+ s -> {
+ assertEquals(DEBUGGEE_CLASS, s.getClassName());
+ assertEquals(methodName, s.getMethodName());
+ assertEquals(SOURCE_FILE, s.getSourceFile());
+ assertEquals(41, s.getLineNumber());
+ s.checkLocal("this");
+ }),
kotlinStepOver(),
- inspect(s -> {
- assertEquals(DEBUGGEE_CLASS, s.getClassName());
- assertEquals(methodName, s.getMethodName());
- assertEquals(SOURCE_FILE, s.getSourceFile());
- assertEquals(43, s.getLineNumber());
- s.checkLocal("this");
- }),
+ inspect(
+ s -> {
+ assertEquals(DEBUGGEE_CLASS, s.getClassName());
+ assertEquals(methodName, s.getMethodName());
+ assertEquals(SOURCE_FILE, s.getSourceFile());
+ assertEquals(42, s.getLineNumber());
+ s.checkLocal("this");
+ }),
run());
}
@@ -90,33 +93,36 @@
DEBUGGEE_CLASS,
breakpoint(DEBUGGEE_CLASS, methodName),
run(),
- inspect(s -> {
- assertEquals(DEBUGGEE_CLASS, s.getClassName());
- assertEquals(methodName, s.getMethodName());
- assertEquals(SOURCE_FILE, s.getSourceFile());
- assertEquals(41, s.getLineNumber());
- s.checkLocal("this");
- }),
+ inspect(
+ s -> {
+ assertEquals(DEBUGGEE_CLASS, s.getClassName());
+ assertEquals(methodName, s.getMethodName());
+ assertEquals(SOURCE_FILE, s.getSourceFile());
+ assertEquals(40, s.getLineNumber());
+ s.checkLocal("this");
+ }),
stepOver(),
- inspect(s -> {
- assertEquals(DEBUGGEE_CLASS, s.getClassName());
- assertEquals(methodName, s.getMethodName());
- assertEquals(SOURCE_FILE, s.getSourceFile());
- assertEquals(42, s.getLineNumber());
- s.checkLocal("this");
- }),
+ inspect(
+ s -> {
+ assertEquals(DEBUGGEE_CLASS, s.getClassName());
+ assertEquals(methodName, s.getMethodName());
+ assertEquals(SOURCE_FILE, s.getSourceFile());
+ assertEquals(41, s.getLineNumber());
+ s.checkLocal("this");
+ }),
stepInto(),
- inspect(s -> {
- assertEquals(DEBUGGEE_CLASS, s.getClassName());
- assertEquals(methodName, s.getMethodName());
- assertEquals(SOURCE_FILE, s.getSourceFile());
- // The actual line number (the one encoded in debug information) is different than the
- // source file one.
- // TODO(shertz) extract original line number from JSR-45's SMAP (only supported on
- // Android O+).
- assertTrue(42 != s.getLineNumber());
- s.checkLocal("this");
- }),
+ inspect(
+ s -> {
+ assertEquals(DEBUGGEE_CLASS, s.getClassName());
+ assertEquals(methodName, s.getMethodName());
+ assertEquals(SOURCE_FILE, s.getSourceFile());
+ // The actual line number (the one encoded in debug information) is different than the
+ // source file one.
+ // TODO(shertz) extract original line number from JSR-45's SMAP (only supported on
+ // Android O+).
+ assertTrue(41 != s.getLineNumber());
+ s.checkLocal("this");
+ }),
run());
}
@@ -128,34 +134,38 @@
DEBUGGEE_CLASS,
breakpoint(DEBUGGEE_CLASS, methodName),
run(),
- inspect(s -> {
- assertEquals(DEBUGGEE_CLASS, s.getClassName());
- assertEquals(methodName, s.getMethodName());
- assertEquals(SOURCE_FILE, s.getSourceFile());
- assertEquals(41, s.getLineNumber());
- s.checkLocal("this");
- }),
+ inspect(
+ s -> {
+ assertEquals(DEBUGGEE_CLASS, s.getClassName());
+ assertEquals(methodName, s.getMethodName());
+ assertEquals(SOURCE_FILE, s.getSourceFile());
+ assertEquals(40, s.getLineNumber());
+ s.checkLocal("this");
+ }),
stepOver(),
- inspect(s -> {
- assertEquals(DEBUGGEE_CLASS, s.getClassName());
- assertEquals(methodName, s.getMethodName());
- assertEquals(SOURCE_FILE, s.getSourceFile());
- assertEquals(42, s.getLineNumber());
- s.checkLocal("this");
- }),
+ inspect(
+ s -> {
+ assertEquals(DEBUGGEE_CLASS, s.getClassName());
+ assertEquals(methodName, s.getMethodName());
+ assertEquals(SOURCE_FILE, s.getSourceFile());
+ assertEquals(41, s.getLineNumber());
+ s.checkLocal("this");
+ }),
stepInto(),
- inspect(s -> {
- assertEquals(DEBUGGEE_CLASS, s.getClassName());
- assertEquals(methodName, s.getMethodName());
- }),
+ inspect(
+ s -> {
+ assertEquals(DEBUGGEE_CLASS, s.getClassName());
+ assertEquals(methodName, s.getMethodName());
+ }),
kotlinStepOut(),
- inspect(s -> {
- assertEquals(DEBUGGEE_CLASS, s.getClassName());
- assertEquals(methodName, s.getMethodName());
- assertEquals(SOURCE_FILE, s.getSourceFile());
- assertEquals(43, s.getLineNumber());
- s.checkLocal("this");
- }),
+ inspect(
+ s -> {
+ assertEquals(DEBUGGEE_CLASS, s.getClassName());
+ assertEquals(methodName, s.getMethodName());
+ assertEquals(SOURCE_FILE, s.getSourceFile());
+ assertEquals(42, s.getLineNumber());
+ s.checkLocal("this");
+ }),
run());
}
@@ -287,17 +297,17 @@
inspect(
s -> {
assertEquals(inliningMethodName, s.getMethodName());
- assertEquals(52, s.getLineNumber());
+ assertEquals(51, s.getLineNumber());
s.checkLocal("this");
}),
checkLocal("this"),
checkNoLocals("l1", "l2"),
stepOver(),
- checkLine(SOURCE_FILE, 53),
+ checkLine(SOURCE_FILE, 52),
checkLocals("this", "l1"),
checkNoLocal("l2"),
stepOver(),
- checkLine(SOURCE_FILE, 54),
+ checkLine(SOURCE_FILE, 53),
checkLocals("this", "l1", "l2"),
stepInto(),
// We jumped into 1st inlinee but the current method is the same
diff --git a/src/test/java/com/android/tools/r8/debug/KotlinTest.java b/src/test/java/com/android/tools/r8/debug/KotlinTest.java
index 49e6fb7..a0a9a12 100644
--- a/src/test/java/com/android/tools/r8/debug/KotlinTest.java
+++ b/src/test/java/com/android/tools/r8/debug/KotlinTest.java
@@ -46,28 +46,31 @@
"KotlinApp",
breakpoint("KotlinApp$Companion", "main"),
run(),
- inspect(s -> {
- assertEquals("KotlinApp$Companion", s.getClassName());
- assertEquals("KotlinApp.kt", s.getSourceFile());
- assertEquals(24, s.getLineNumber());
- s.checkLocal("this");
- s.checkLocal("args");
- checkNoLocal("instance");
- }),
+ inspect(
+ s -> {
+ assertEquals("KotlinApp$Companion", s.getClassName());
+ assertEquals("KotlinApp.kt", s.getSourceFile());
+ assertEquals(25, s.getLineNumber());
+ s.checkLocal("this");
+ s.checkLocal("args");
+ checkNoLocal("instance");
+ }),
stepOver(),
- inspect(s -> {
- assertEquals(25, s.getLineNumber());
- s.checkLocal("this");
- s.checkLocal("args");
- s.checkLocal("instance");
- }),
+ inspect(
+ s -> {
+ assertEquals(26, s.getLineNumber());
+ s.checkLocal("this");
+ s.checkLocal("args");
+ s.checkLocal("instance");
+ }),
stepOver(),
- inspect(s -> {
- assertEquals(26, s.getLineNumber());
- s.checkLocal("this");
- s.checkLocal("args");
- s.checkLocal("instance");
- }),
+ inspect(
+ s -> {
+ assertEquals(27, s.getLineNumber());
+ s.checkLocal("this");
+ s.checkLocal("args");
+ s.checkLocal("instance");
+ }),
run());
}
@@ -78,117 +81,128 @@
"KotlinApp",
breakpoint("KotlinApp$Companion", "main"),
run(),
- inspect(s -> {
- assertEquals("KotlinApp$Companion", s.getClassName());
- assertEquals("KotlinApp.kt", s.getSourceFile());
- assertEquals(24, s.getLineNumber());
- s.checkLocal("this");
- s.checkLocal("args");
- checkNoLocal("instance");
- }),
+ inspect(
+ s -> {
+ assertEquals("KotlinApp$Companion", s.getClassName());
+ assertEquals("KotlinApp.kt", s.getSourceFile());
+ assertEquals(25, s.getLineNumber());
+ s.checkLocal("this");
+ s.checkLocal("args");
+ checkNoLocal("instance");
+ }),
stepOver(),
- inspect(s -> {
- assertEquals(25, s.getLineNumber());
- s.checkLocal("this");
- s.checkLocal("args");
- s.checkLocal("instance");
- }),
+ inspect(
+ s -> {
+ assertEquals(26, s.getLineNumber());
+ s.checkLocal("this");
+ s.checkLocal("args");
+ s.checkLocal("instance");
+ }),
// Step into 1st invoke of ifElse
stepInto(),
- inspect(s -> {
- assertEquals("KotlinApp", s.getClassName());
- assertEquals("KotlinApp.kt", s.getSourceFile());
- assertEquals(8, s.getLineNumber());
- s.checkLocal("this");
- s.checkLocal("cond", Value.createBoolean(true));
- checkNoLocal("a");
- checkNoLocal("b");
- checkNoLocal("c");
- }),
+ inspect(
+ s -> {
+ assertEquals("KotlinApp", s.getClassName());
+ assertEquals("KotlinApp.kt", s.getSourceFile());
+ assertEquals(8, s.getLineNumber());
+ s.checkLocal("this");
+ s.checkLocal("cond", Value.createBoolean(true));
+ checkNoLocal("a");
+ checkNoLocal("b");
+ checkNoLocal("c");
+ }),
stepInto(),
- inspect(s -> {
- assertEquals("KotlinApp", s.getClassName());
- assertEquals(9, s.getLineNumber());
- s.checkLocal("this");
- s.checkLocal("cond", Value.createBoolean(true));
- s.checkLocal("a", Value.createInt(10));
- checkNoLocal("b");
- checkNoLocal("c");
- }),
+ inspect(
+ s -> {
+ assertEquals("KotlinApp", s.getClassName());
+ assertEquals(9, s.getLineNumber());
+ s.checkLocal("this");
+ s.checkLocal("cond", Value.createBoolean(true));
+ s.checkLocal("a", Value.createInt(10));
+ checkNoLocal("b");
+ checkNoLocal("c");
+ }),
stepInto(),
- inspect(s -> {
- // We should be into the 'then' statement.
- assertEquals("KotlinApp", s.getClassName());
- assertEquals(10, s.getLineNumber());
- s.checkLocal("this");
- s.checkLocal("cond", Value.createBoolean(true));
- s.checkLocal("a", Value.createInt(10));
- checkNoLocal("b");
- checkNoLocal("c");
- }),
+ inspect(
+ s -> {
+ // We should be into the 'then' statement.
+ assertEquals("KotlinApp", s.getClassName());
+ assertEquals(10, s.getLineNumber());
+ s.checkLocal("this");
+ s.checkLocal("cond", Value.createBoolean(true));
+ s.checkLocal("a", Value.createInt(10));
+ checkNoLocal("b");
+ checkNoLocal("c");
+ }),
stepInto(),
- inspect(s -> {
- assertEquals("KotlinApp", s.getClassName());
- assertEquals(11, s.getLineNumber());
- s.checkLocal("this");
- s.checkLocal("cond", Value.createBoolean(true));
- s.checkLocal("a", Value.createInt(10));
- s.checkLocal("b", Value.createInt(20));
- checkNoLocal("c");
- }),
+ inspect(
+ s -> {
+ assertEquals("KotlinApp", s.getClassName());
+ assertEquals(11, s.getLineNumber());
+ s.checkLocal("this");
+ s.checkLocal("cond", Value.createBoolean(true));
+ s.checkLocal("a", Value.createInt(10));
+ s.checkLocal("b", Value.createInt(20));
+ checkNoLocal("c");
+ }),
// Go back to the main method
stepOut(),
- inspect(s -> {
- assertEquals("KotlinApp$Companion", s.getClassName());
- assertEquals("KotlinApp.kt", s.getSourceFile());
- assertEquals(26, s.getLineNumber());
- s.checkLocal("this");
- s.checkLocal("args");
- checkNoLocal("instance");
- }),
+ inspect(
+ s -> {
+ assertEquals("KotlinApp$Companion", s.getClassName());
+ assertEquals("KotlinApp.kt", s.getSourceFile());
+ assertEquals(27, s.getLineNumber());
+ s.checkLocal("this");
+ s.checkLocal("args");
+ checkNoLocal("instance");
+ }),
// Step into 2nd invoke of ifElse
stepInto(),
- inspect(s -> {
- assertEquals("KotlinApp", s.getClassName());
- assertEquals("KotlinApp.kt", s.getSourceFile());
- assertEquals(8, s.getLineNumber());
- s.checkLocal("this");
- s.checkLocal("cond", Value.createBoolean(false));
- checkNoLocal("a");
- checkNoLocal("b");
- checkNoLocal("c");
- }),
+ inspect(
+ s -> {
+ assertEquals("KotlinApp", s.getClassName());
+ assertEquals("KotlinApp.kt", s.getSourceFile());
+ assertEquals(8, s.getLineNumber());
+ s.checkLocal("this");
+ s.checkLocal("cond", Value.createBoolean(false));
+ checkNoLocal("a");
+ checkNoLocal("b");
+ checkNoLocal("c");
+ }),
stepInto(),
- inspect(s -> {
- assertEquals("KotlinApp", s.getClassName());
- assertEquals(9, s.getLineNumber());
- s.checkLocal("this");
- s.checkLocal("cond", Value.createBoolean(false));
- s.checkLocal("a", Value.createInt(10));
- checkNoLocal("b");
- checkNoLocal("c");
- }),
+ inspect(
+ s -> {
+ assertEquals("KotlinApp", s.getClassName());
+ assertEquals(9, s.getLineNumber());
+ s.checkLocal("this");
+ s.checkLocal("cond", Value.createBoolean(false));
+ s.checkLocal("a", Value.createInt(10));
+ checkNoLocal("b");
+ checkNoLocal("c");
+ }),
stepInto(),
- inspect(s -> {
- // We should be into the 'else' statement this time.
- assertEquals("KotlinApp", s.getClassName());
- assertEquals(13, s.getLineNumber());
- s.checkLocal("this");
- s.checkLocal("cond", Value.createBoolean(false));
- s.checkLocal("a", Value.createInt(10));
- checkNoLocal("b");
- checkNoLocal("c");
- }),
+ inspect(
+ s -> {
+ // We should be into the 'else' statement this time.
+ assertEquals("KotlinApp", s.getClassName());
+ assertEquals(13, s.getLineNumber());
+ s.checkLocal("this");
+ s.checkLocal("cond", Value.createBoolean(false));
+ s.checkLocal("a", Value.createInt(10));
+ checkNoLocal("b");
+ checkNoLocal("c");
+ }),
stepInto(),
- inspect(s -> {
- assertEquals("KotlinApp", s.getClassName());
- assertEquals(14, s.getLineNumber());
- s.checkLocal("this");
- s.checkLocal("cond", Value.createBoolean(false));
- s.checkLocal("a", Value.createInt(10));
- checkNoLocal("b");
- s.checkLocal("c", Value.createInt(5));
- }),
+ inspect(
+ s -> {
+ assertEquals("KotlinApp", s.getClassName());
+ assertEquals(14, s.getLineNumber());
+ s.checkLocal("this");
+ s.checkLocal("cond", Value.createBoolean(false));
+ s.checkLocal("a", Value.createInt(10));
+ checkNoLocal("b");
+ s.checkLocal("c", Value.createInt(5));
+ }),
run());
}
diff --git a/src/test/kotlinR8TestResources/debug/KotlinApp.kt b/src/test/kotlinR8TestResources/debug/KotlinApp.kt
index 094407b..f347218 100644
--- a/src/test/kotlinR8TestResources/debug/KotlinApp.kt
+++ b/src/test/kotlinR8TestResources/debug/KotlinApp.kt
@@ -4,26 +4,27 @@
class KotlinApp {
- fun ifElse(cond: Boolean) {
- val a = 10
- if (cond) {
- val b = a * 2
- printInt(b)
- } else {
- val c = a / 2
- print(c)
- }
+ fun ifElse(cond: Boolean) {
+ val a = 10
+ if (cond) {
+ val b = a * 2
+ printInt(b)
+ } else {
+ val c = a / 2
+ print(c)
}
+ }
- fun printInt(i: Int) {
- println(i)
- }
+ fun printInt(i: Int) {
+ println(i)
+ }
- companion object {
- @JvmStatic fun main(args: Array<String>) {
- val instance = KotlinApp()
- instance.ifElse(true)
- instance.ifElse(false)
- }
+ companion object {
+ @JvmStatic
+ fun main(args: Array<String>) {
+ val instance = KotlinApp()
+ instance.ifElse(true)
+ instance.ifElse(false)
}
-}
\ No newline at end of file
+ }
+}
diff --git a/src/test/kotlinR8TestResources/debug/KotlinInline.kt b/src/test/kotlinR8TestResources/debug/KotlinInline.kt
index 4b55c57..479efe2 100644
--- a/src/test/kotlinR8TestResources/debug/KotlinInline.kt
+++ b/src/test/kotlinR8TestResources/debug/KotlinInline.kt
@@ -4,81 +4,80 @@
class KotlinInline {
- fun processObject(obj: Any, func: (Any) -> Unit) {
- func(obj)
- }
+ fun processObject(obj: Any, func: (Any) -> Unit) {
+ func(obj)
+ }
- fun printObject(obj: Any) {
- println(obj)
- }
+ fun printObject(obj: Any) {
+ println(obj)
+ }
- fun invokeInlinedFunctions() {
- inlinedA {
- val inA = 1
- inlinedB {
- val inB = 2
- foo(inA, inB)
- }
- }
+ fun invokeInlinedFunctions() {
+ inlinedA {
+ val inA = 1
+ inlinedB {
+ val inB = 2
+ foo(inA, inB)
+ }
}
+ }
- inline fun inlinedA(f: () -> Unit) {
- f()
- }
+ inline fun inlinedA(f: () -> Unit) {
+ f()
+ }
- inline fun inlinedB(f: () -> Unit) {
- f()
- }
+ inline fun inlinedB(f: () -> Unit) {
+ f()
+ }
- fun foo(a: Int, b: Int) {
- println("a=$a, b=$b")
- }
+ fun foo(a: Int, b: Int) {
+ println("a=$a, b=$b")
+ }
- fun emptyMethod(unused: Int) {
- }
+ fun emptyMethod(unused: Int) {}
- fun singleInline() {
- emptyMethod(0)
- inlined()
- emptyMethod(1)
- }
+ fun singleInline() {
+ emptyMethod(0)
+ inlined()
+ emptyMethod(1)
+ }
- inline fun inlined() {
- emptyMethod(-1)
- }
+ inline fun inlined() {
+ emptyMethod(-1)
+ }
- // Double inlining
- fun testNestedInlining() {
- val l1 = Int.MAX_VALUE
- val l2 = Int.MIN_VALUE
- inlinee1(l1, l2)
- }
- inline fun inlinee1(a: Int, b: Int) {
- val c = a - 2
- inlinee2(1) {
- val left = a + b
- val right = a - b
- foo(left, right)
- }
- inlinee2(c) {
- foo(b, a)
- }
- }
+ // Double inlining
+ fun testNestedInlining() {
+ val l1 = Int.MAX_VALUE
+ val l2 = Int.MIN_VALUE
+ inlinee1(l1, l2)
+ }
- inline fun inlinee2(p: Int, block: () -> Unit) {
- if (p > 0) {
- block()
- }
+ inline fun inlinee1(a: Int, b: Int) {
+ val c = a - 2
+ inlinee2(1) {
+ val left = a + b
+ val right = a - b
+ foo(left, right)
}
+ inlinee2(c) { foo(b, a) }
+ }
- companion object {
- @JvmStatic fun main(args: Array<String>) {
- println("Hello world!")
- val instance = KotlinInline()
- instance.processObject(instance, instance::printObject)
- instance.invokeInlinedFunctions()
- instance.singleInline()
- instance.testNestedInlining()
- }
+ inline fun inlinee2(p: Int, block: () -> Unit) {
+ if (p > 0) {
+ block()
}
-}
\ No newline at end of file
+ }
+
+ companion object {
+ @JvmStatic
+ fun main(args: Array<String>) {
+ println("Hello world!")
+ val instance = KotlinInline()
+ instance.processObject(instance, instance::printObject)
+ instance.invokeInlinedFunctions()
+ instance.singleInline()
+ instance.testNestedInlining()
+ }
+ }
+}