Debugger: Add breakpoint applicability tests

This commit adds a number of tests that check breakpoint placing behavior, and an inline action that work the same way as tests.
This commit is contained in:
Yan Zhulanow
2019-07-16 17:05:37 +09:00
parent a8d08815a6
commit 25fb77e7ad
19 changed files with 436 additions and 17 deletions
@@ -0,0 +1,39 @@
// Should stop on primary constructor invocation
class Foo1(val a: Int) /// M
class Foo2( /// M
val a: Int, /// F
val b: String /// F
)
class Foo3(val a: Int) { /// M
constructor(a: String) : this(a.toInt()) /// M
}
// Initializers are not currently recognized as functions
class Foo4 { /// M
init { /// L
println() /// L
} /// L
}
class Foo5 {
constructor(a: String) {} /// M
constructor(a: Int) {} /// M
}
interface Intf
annotation class Anno
enum class Enum1 { /// M
FOO
}
enum class Enum2(val a: Int) { /// M
FOO(1)
}
object Obj1
object Obj2 {}
@@ -0,0 +1,44 @@
// Simple one-liners should have only method breakpoint
// Simple = no lambdas on a line
fun foo1() = println() /// M
fun foo2() {} /// M
// Lambdas should be available if present
fun foo3() = run { println() } /// *, L, M, λ
// Code blocks {} are not considered as expressions
fun foo4() { /// M
println() /// L
} /// L
// And parenthesis as well
fun foo5() = ( /// M
println() /// L
)
// For expression-body functions, a line breakpoint should be available
// if there is an expression on the first line
fun foo6() = when (2 + 3) { /// M, L
5 -> {} /// L
else -> {} /// L
}
// Line breakpoint should not be displayed for lambda literal results
fun foo7() = { println() } /// M, λ
fun foo8() = (3 + 5).run { /// M, L
println() /// L
} /// L
// Expressions in default parameter values should be recognized
fun foo9(a: String = readLine()!!) = a /// M, L
// Lambdas in default parameter values also should be recognized
fun foo10(a: () -> Unit = { println() }) { /// *, L, M, λ
a() /// L
} /// L
// If a default parameter value is not just a lambda, but a function call with a lambda argument,
// there should be a line breakpoint as well
fun foo11(a: String = run { "foo" }) = a /// *, L, M, λ
@@ -0,0 +1,22 @@
fun foo1() {
// We don't support function breakpoints for local functions yet
fun local() { /// L
println() /// L
} /// L
} /// L
fun foo2() { /// M
val local = fun() { /// L
println() /// L
} /// L
} /// L
fun foo3() { /// M
val local = { /// L
println() /// L
} /// L
} /// L
fun foo4() { /// M
fun local(block: () -> Unit = { println() }) {} /// *, L, λ
} /// L
@@ -0,0 +1,9 @@
class Foo1 {
val x: String /// F, L
get() = "foo" /// M
}
class Foo2 { /// M
val x: String = "foo" /// F, L
get() = field + "x" /// M
}
@@ -0,0 +1,10 @@
package simple
fun main() { /// M
val a = 5 /// L
foo(a) /// L
} /// L
fun foo(a: Int) { /// M
val b = 6 /// L
} /// L