test: add labels and breaks count tests.

This commit is contained in:
Artem Kobzar
2022-04-08 01:30:37 +02:00
committed by teamcity
parent 12f337f63d
commit c724ca943d
69 changed files with 217 additions and 1 deletions
@@ -5,6 +5,8 @@ package foo
inline fun <T> block(f: () -> T): T = f() inline fun <T> block(f: () -> T): T = f()
// CHECK_BREAKS_COUNT: function=test count=0 TARGET_BACKENDS=JS_IR
// CHECK_LABELS_COUNT: function=test name=$l$block count=0 TARGET_BACKENDS=JS_IR
fun test() = block(fun(): Int { return 23 }) fun test() = block(fun(): Int { return 23 })
fun box(): String { fun box(): String {
@@ -1,6 +1,8 @@
// EXPECTED_REACHABLE_NODES: 1287 // EXPECTED_REACHABLE_NODES: 1287
package foo package foo
// CHECK_BREAKS_COUNT: function=add count=0 TARGET_BACKENDS=JS_IR
// CHECK_LABELS_COUNT: function=add name=$l$block count=0 TARGET_BACKENDS=JS_IR
fun add(a: Int, b: Int): Int { fun add(a: Int, b: Int): Int {
val o = object { val o = object {
inline fun add(a: Int, b: Int): Int = a + b inline fun add(a: Int, b: Int): Int = a + b
@@ -47,6 +47,8 @@ inline fun moveTo(source: Array<Int>, sink: Array<Int>): PairArray<Int, Int> {
return PairArray(source, sink) return PairArray(source, sink)
} }
// CHECK_BREAKS_COUNT: function=box count=0 TARGET_BACKENDS=JS_IR
// CHECK_LABELS_COUNT: function=box name=$l$block count=0 TARGET_BACKENDS=JS_IR
fun box(): String { fun box(): String {
val expected = PairArray<Int, Int>(arrayOf(), arrayOf(1,2,3,4)) val expected = PairArray<Int, Int>(arrayOf(), arrayOf(1,2,3,4))
assertTrue(expected.deepEquals(moveTo(arrayOf(3, 4), arrayOf(1, 2)))) assertTrue(expected.deepEquals(moveTo(arrayOf(3, 4), arrayOf(1, 2))))
+2
View File
@@ -67,6 +67,8 @@ fun syntaxTest() {
syntaxTestInline() syntaxTestInline()
} }
// CHECK_BREAKS_COUNT: function=box count=0 TARGET_BACKENDS=JS_IR
// CHECK_LABELS_COUNT: function=box name=$l$block count=0 TARGET_BACKENDS=JS_IR
fun box(): String { fun box(): String {
syntaxTest() syntaxTest()
return "OK" return "OK"
+2
View File
@@ -33,6 +33,8 @@ fun callLocalExtension(a: Int): String {
return Boo().call(a) return Boo().call(a)
} }
// CHECK_BREAKS_COUNT: function=box count=0 TARGET_BACKENDS=JS_IR
// CHECK_LABELS_COUNT: function=box name=$l$block count=0 TARGET_BACKENDS=JS_IR
fun box(): String { fun box(): String {
var result = call(1) var result = call(1)
if (result != "call(1)") return "fail1: $result" if (result != "call(1)") return "fail1: $result"
+6
View File
@@ -23,15 +23,21 @@ class InlineAll {
} }
} }
// CHECK_BREAKS_COUNT: function=testClassObjectCall count=0 TARGET_BACKENDS=JS_IR
// CHECK_LABELS_COUNT: function=testClassObjectCall name=$l$block count=0 TARGET_BACKENDS=JS_IR
fun testClassObjectCall(): String { fun testClassObjectCall(): String {
return InlineAll.inline({"classobject"}) return InlineAll.inline({"classobject"})
} }
// CHECK_BREAKS_COUNT: function=testInstanceCall count=0 TARGET_BACKENDS=JS_IR
// CHECK_LABELS_COUNT: function=testInstanceCall name=$l$block count=0 TARGET_BACKENDS=JS_IR
fun testInstanceCall(): String { fun testInstanceCall(): String {
val inlineX = InlineAll() val inlineX = InlineAll()
return inlineX.inline({"instance"}) return inlineX.inline({"instance"})
} }
// CHECK_BREAKS_COUNT: function=testPackageCall count=0 TARGET_BACKENDS=JS_IR
// CHECK_LABELS_COUNT: function=testPackageCall name=$l$block count=0 TARGET_BACKENDS=JS_IR
fun testPackageCall(): String { fun testPackageCall(): String {
return inline({"package"}) return inline({"package"})
} }
@@ -6,6 +6,8 @@ package foo
inline fun condition() = false inline fun condition() = false
// CHECK_BREAKS_COUNT: function=run count=0 TARGET_BACKENDS=JS_IR
// CHECK_LABELS_COUNT: function=run name=$block count=0 TARGET_BACKENDS=JS_IR
fun run(x: Boolean): String { fun run(x: Boolean): String {
var y = 0 var y = 0
do { do {
@@ -11,6 +11,8 @@ inline fun tenULong() = 10UL
// MODULE: main(lib) // MODULE: main(lib)
// FILE: main.kt // FILE: main.kt
// CHECK_BREAKS_COUNT: function=box count=0 TARGET_BACKENDS=JS_IR
// CHECK_LABELS_COUNT: function=box name=$l$block count=0 TARGET_BACKENDS=JS_IR
fun box(): String { fun box(): String {
if (tenUInt() != 10U) return "fail 1" if (tenUInt() != 10U) return "fail 1"
@@ -5,6 +5,8 @@ inline fun block(p: () -> Int) = p()
fun createFunction(x: Int): () -> Int = { x } fun createFunction(x: Int): () -> Int = { x }
// CHECK_BREAKS_COUNT: function=box count=0 TARGET_BACKENDS=JS_IR
// CHECK_LABELS_COUNT: function=box name=$l$block count=0 TARGET_BACKENDS=JS_IR
fun box(): String { fun box(): String {
assertEquals(23, block(createFunction(23))) assertEquals(23, block(createFunction(23)))
return "OK" return "OK"
@@ -8,6 +8,8 @@ package foo
// It's important, that the body is just `return fn()`. // It's important, that the body is just `return fn()`.
internal inline fun <T> evaluate(fn: ()->T): T = fn() internal inline fun <T> evaluate(fn: ()->T): T = fn()
// CHECK_BREAKS_COUNT: function=test count=0 TARGET_BACKENDS=JS_IR
// CHECK_LABELS_COUNT: function=test name=$l$block count=0 TARGET_BACKENDS=JS_IR
internal fun test(n: Int): Int { internal fun test(n: Int): Int {
return evaluate { return evaluate {
var i = n var i = n
@@ -7,6 +7,8 @@ internal class A(val a: Int)
internal inline fun <T, R> with2(receiver: T, arg1: R, arg2: R, f: T.(R, R) -> R): R = receiver.f(arg1, arg2) internal inline fun <T, R> with2(receiver: T, arg1: R, arg2: R, f: T.(R, R) -> R): R = receiver.f(arg1, arg2)
// CHECK_BREAKS_COUNT: function=myMultiply count=0 TARGET_BACKENDS=JS_IR
// CHECK_LABELS_COUNT: function=myMultiply name=$l$block count=0 TARGET_BACKENDS=JS_IR
internal fun myMultiply(a: Int, b: Int, c: Int): Int = with2(A(a), b, c) { x, y -> a*x*y } internal fun myMultiply(a: Int, b: Int, c: Int): Int = with2(A(a), b, c) { x, y -> a*x*y }
fun box(): String { fun box(): String {
@@ -2,6 +2,8 @@
inline fun foo() = (object : II {}).ok() inline fun foo() = (object : II {}).ok()
// CHECK_BREAKS_COUNT: function=box count=0 TARGET_BACKENDS=JS_IR
// CHECK_LABELS_COUNT: function=box name=$l$block count=0 TARGET_BACKENDS=JS_IR
fun box() = foo() fun box() = foo()
interface I { interface I {
@@ -16,6 +16,9 @@ inline fun bar() = foo()
// MODULE: main(libB) // MODULE: main(libB)
// FILE: main.kt // FILE: main.kt
// CHECK_BREAKS_COUNT: function=box count=0 TARGET_BACKENDS=JS_IR
// CHECK_LABELS_COUNT: function=box name=$l$block count=0 TARGET_BACKENDS=JS_IR
fun box() = bar() fun box() = bar()
@@ -23,4 +23,6 @@ inline fun K(a: A) = a.foo.call(a, "K")
val a = A val a = A
// CHECK_BREAKS_COUNT: function=box count=0 TARGET_BACKENDS=JS_IR
// CHECK_LABELS_COUNT: function=box name=$l$block count=0 TARGET_BACKENDS=JS_IR
fun box() = O() + K(a) fun box() = O() + K(a)
@@ -11,6 +11,8 @@ inline fun compare2(a1: A, a2: A): Boolean {
return a1 === a2 return a1 === a2
} }
// CHECK_BREAKS_COUNT: function=box count=0 TARGET_BACKENDS=JS_IR
// CHECK_LABELS_COUNT: function=box name=$l$block count=0 TARGET_BACKENDS=JS_IR
fun box(): String { fun box(): String {
assertEquals(true, compare1(A()), "compare1(A())") assertEquals(true, compare1(A()), "compare1(A())")
assertEquals(false, compare2(A(), A()), "compare2(A(), A())") assertEquals(false, compare2(A(), A()), "compare2(A(), A())")
@@ -12,6 +12,8 @@ inline fun inc(countable: Countable) = countable.count++
inline fun run(func: () -> Unit) = func() inline fun run(func: () -> Unit) = func()
// CHECK_BREAKS_COUNT: function=incNoInline count=0 TARGET_BACKENDS=JS_IR
// CHECK_LABELS_COUNT: function=incNoInline name=$l$block count=0 TARGET_BACKENDS=JS_IR
fun incNoInline(countable: Countable) = run { inc(countable) } fun incNoInline(countable: Countable) = run { inc(countable) }
fun box(): String { fun box(): String {
@@ -3,6 +3,8 @@ package foo
inline fun foo(): Any? = "foo()" inline fun foo(): Any? = "foo()"
// CHECK_BREAKS_COUNT: function=box count=0 TARGET_BACKENDS=JS_IR
// CHECK_LABELS_COUNT: function=box name=$l$block count=0 TARGET_BACKENDS=JS_IR
fun box(): String { fun box(): String {
assertEquals("foo()", "${foo()}") assertEquals("foo()", "${foo()}")
assertEquals("aaa foo() bb", "aaa ${foo()} bb") assertEquals("aaa foo() bb", "aaa ${foo()} bb")
@@ -23,6 +23,8 @@ inline fun sumEvenInRange(a: Int, b: Int): Int {
return c return c
} }
// CHECK_BREAKS_COUNT: function=box count=0 TARGET_BACKENDS=JS_IR
// CHECK_LABELS_COUNT: function=box name=$l$block count=0 TARGET_BACKENDS=JS_IR
fun box(): String { fun box(): String {
val sum6 = sumEvenInRange(1, 5) val sum6 = sumEvenInRange(1, 5)
assertEquals(6, sum6) assertEquals(6, sum6)
+2
View File
@@ -15,6 +15,8 @@ internal inline fun inline3(a: Int): Int {
return inline1(a) * inline2(a) return inline1(a) * inline2(a)
} }
// CHECK_BREAKS_COUNT: function=squareMultipliedByTwo count=0 TARGET_BACKENDS=JS_IR
// CHECK_LABELS_COUNT: function=squareMultipliedByTwo name=$l$block count=0 TARGET_BACKENDS=JS_IR
internal fun squareMultipliedByTwo(a: Int): Int { internal fun squareMultipliedByTwo(a: Int): Int {
return inline3(a) return inline3(a)
} }
@@ -20,4 +20,6 @@ inline fun foo()= baz()
// MODULE: main(mid) // MODULE: main(mid)
// FILE: main.kt // FILE: main.kt
// CHECK_BREAKS_COUNT: function=box count=0 TARGET_BACKENDS=JS_IR
// CHECK_LABELS_COUNT: function=box name=$l$block count=0 TARGET_BACKENDS=JS_IR
fun box() = foo() fun box() = foo()
@@ -20,6 +20,9 @@ internal inline fun inline3(a: Int): Int {
return i1 return i1
} }
// CHECK_BREAKS_COUNT: function=squareMultipliedByTwo count=2 TARGET_BACKENDS=JS_IR
// CHECK_LABELS_COUNT: function=squareMultipliedByTwo name=$l$block count=1 TARGET_BACKENDS=JS_IR
// CHECK_LABELS_COUNT: function=squareMultipliedByTwo name=$l$block_0 count=1 TARGET_BACKENDS=JS_IR
internal fun squareMultipliedByTwo(a: Int): Int { internal fun squareMultipliedByTwo(a: Int): Int {
return inline3(a) return inline3(a)
} }
@@ -8,10 +8,14 @@ internal inline fun sum(a: Int, b: Int = 0): Int {
return a + b return a + b
} }
// CHECK_BREAKS_COUNT: function=identity count=0 TARGET_BACKENDS=JS_IR
// CHECK_LABELS_COUNT: function=identity name=$l$block count=0 TARGET_BACKENDS=JS_IR
internal fun identity(a: Int): Int { internal fun identity(a: Int): Int {
return sum(a) return sum(a)
} }
// CHECK_BREAKS_COUNT: function=sumNoInline count=0 TARGET_BACKENDS=JS_IR
// CHECK_LABELS_COUNT: function=sumNoInline name=$l$block count=0 TARGET_BACKENDS=JS_IR
internal fun sumNoInline(a: Int, b: Int): Int { internal fun sumNoInline(a: Int, b: Int): Int {
return sum(a, b) return sum(a, b)
} }
@@ -11,6 +11,8 @@ internal inline fun <T> doNothing2(a: T, f: (T) -> T): T {
return f(a) return f(a)
} }
// CHECK_BREAKS_COUNT: function=doNothingNoInline count=0 TARGET_BACKENDS=JS_IR
// CHECK_LABELS_COUNT: function=doNothingNoInline name=$l$block count=0 TARGET_BACKENDS=JS_IR
internal fun doNothingNoInline(a: Int): Int { internal fun doNothingNoInline(a: Int): Int {
return doNothing2(a, { x -> doNothing1(x)}) return doNothing2(a, { x -> doNothing1(x)})
} }
@@ -8,10 +8,14 @@ internal inline fun <T> doNothing(a: T): T {
return a return a
} }
// CHECK_BREAKS_COUNT: function=doNothingInt count=0 TARGET_BACKENDS=JS_IR
// CHECK_LABELS_COUNT: function=doNothingInt name=$l$block count=0 TARGET_BACKENDS=JS_IR
internal fun doNothingInt(a: Int): Int { internal fun doNothingInt(a: Int): Int {
return doNothing(a) return doNothing(a)
} }
// CHECK_BREAKS_COUNT: function=doNothingStr count=0 TARGET_BACKENDS=JS_IR
// CHECK_LABELS_COUNT: function=doNothingStr name=$l$block count=0 TARGET_BACKENDS=JS_IR
internal fun doNothingStr(a: String): String { internal fun doNothingStr(a: String): String {
return doNothing(a) return doNothing(a)
} }
+9
View File
@@ -31,6 +31,9 @@ inline fun if3(f: (Int) -> Int, a: Int, b: Int, c: Int): Int {
} }
} }
// CHECK_BREAKS_COUNT: function=testIf1 count=2 TARGET_BACKENDS=JS_IR
// CHECK_LABELS_COUNT: function=testIf1 name=$l$block count=1 TARGET_BACKENDS=JS_IR
// CHECK_LABELS_COUNT: function=testIf1 name=$l$block_0 count=1 TARGET_BACKENDS=JS_IR
fun testIf1(): String { fun testIf1(): String {
val test1 = if1({it}, 1, 2, 3) val test1 = if1({it}, 1, 2, 3)
if (test1 != 3) return "testIf1: test1 fail" if (test1 != 3) return "testIf1: test1 fail"
@@ -41,6 +44,9 @@ fun testIf1(): String {
return "OK" return "OK"
} }
// CHECK_BREAKS_COUNT: function=testIf2 count=2 TARGET_BACKENDS=JS_IR
// CHECK_LABELS_COUNT: function=testIf2 name=$l$block count=1 TARGET_BACKENDS=JS_IR
// CHECK_LABELS_COUNT: function=testIf2 name=$l$block_0 count=1 TARGET_BACKENDS=JS_IR
fun testIf2(): String { fun testIf2(): String {
val test1 = if2({it}, 1, 2, 3) val test1 = if2({it}, 1, 2, 3)
if (test1 != 3) return "testIf2: test1 fail" if (test1 != 3) return "testIf2: test1 fail"
@@ -51,6 +57,9 @@ fun testIf2(): String {
return "OK" return "OK"
} }
// CHECK_BREAKS_COUNT: function=testIf3 count=4 TARGET_BACKENDS=JS_IR
// CHECK_LABELS_COUNT: function=testIf3 name=$l$block_0 count=1 TARGET_BACKENDS=JS_IR
// CHECK_LABELS_COUNT: function=testIf3 name=$l$block_2 count=1 TARGET_BACKENDS=JS_IR
fun testIf3(): String { fun testIf3(): String {
val test1 = if3({it}, 1, 2, 3) val test1 = if3({it}, 1, 2, 3)
if (test1 != 3) return "testIf3: test1 fail" if (test1 != 3) return "testIf3: test1 fail"
@@ -26,6 +26,8 @@ inline fun foo() {
baz("BBB", 333) baz("BBB", 333)
} }
// CHECK_BREAKS_COUNT: function=box count=0 TARGET_BACKENDS=JS_IR
// CHECK_LABELS_COUNT: function=box name=$l$block count=0 TARGET_BACKENDS=JS_IR
fun box(): String { fun box(): String {
bar() bar()
if (l != "baz(AAA);foo();baz(BBB, 333);") return "fail: $l" if (l != "baz(AAA);foo();baz(BBB, 333);") return "fail: $l"
@@ -21,6 +21,8 @@ inline fun shouldBeInlined() {
log("shouldBeInlined") log("shouldBeInlined")
} }
// CHECK_BREAKS_COUNT: function=box count=0 TARGET_BACKENDS=JS_IR
// CHECK_LABELS_COUNT: function=box name=$l$block count=0 TARGET_BACKENDS=JS_IR
fun box(): String { fun box(): String {
val result = foo() val result = foo()
if (result != "([(OK)])") return "fail1: $result" if (result != "([(OK)])") return "fail1: $result"
@@ -21,6 +21,8 @@ private inline fun shouldBeInlined() {
log("shouldBeInlined") log("shouldBeInlined")
} }
// CHECK_BREAKS_COUNT: function=box count=0 TARGET_BACKENDS=JS_IR
// CHECK_LABELS_COUNT: function=box name=$l$block count=0 TARGET_BACKENDS=JS_IR
fun box(): String { fun box(): String {
val result = foo() val result = foo()
if (result != "([(OK)])") return "fail: $result" if (result != "([(OK)])") return "fail: $result"
+2
View File
@@ -13,6 +13,8 @@ internal fun multiplyNoInline(a: Int, b: Int): Int {
return (c++) + (d++) + multiply(c, d) - (--c + --d) return (c++) + (d++) + multiply(c, d) - (--c + --d)
} }
// CHECK_BREAKS_COUNT: function=box count=0 TARGET_BACKENDS=JS_IR
// CHECK_LABELS_COUNT: function=box name=$l$block count=0 TARGET_BACKENDS=JS_IR
fun box(): String { fun box(): String {
assertEquals(0, multiplyNoInline(1, 0)) assertEquals(0, multiplyNoInline(1, 0))
assertEquals(1, multiplyNoInline(1, 1)) assertEquals(1, multiplyNoInline(1, 1))
@@ -19,14 +19,20 @@ internal class Inline {
} }
} }
// CHECK_BREAKS_COUNT: function=doNothing1 count=0 TARGET_BACKENDS=JS_IR
// CHECK_LABELS_COUNT: function=doNothing1 name=$l$block count=0 TARGET_BACKENDS=JS_IR
internal fun doNothing1 (inline1: Inline, a: Int): Int { internal fun doNothing1 (inline1: Inline, a: Int): Int {
return inline1.identity1(a) return inline1.identity1(a)
} }
// CHECK_BREAKS_COUNT: function=doNothing2 count=0 TARGET_BACKENDS=JS_IR
// CHECK_LABELS_COUNT: function=doNothing2 name=$l$block count=0 TARGET_BACKENDS=JS_IR
internal fun doNothing2 (inline2: Inline, a: Int): Int { internal fun doNothing2 (inline2: Inline, a: Int): Int {
return inline2.identity2(a, {it}) return inline2.identity2(a, {it})
} }
// CHECK_BREAKS_COUNT: function=doNothing3 count=0 TARGET_BACKENDS=JS_IR
// CHECK_LABELS_COUNT: function=doNothing3 name=$l$block count=0 TARGET_BACKENDS=JS_IR
internal fun doNothing3 (inline3: Inline): Int { internal fun doNothing3 (inline3: Inline): Int {
return inline3.identity3({11}) return inline3.identity3({11})
} }
@@ -16,6 +16,8 @@ internal inline fun filteredReduce(a: Array<Int>, predicate: (Int) -> Boolean, r
return result return result
} }
// CHECK_BREAKS_COUNT: function=sumEven count=0 TARGET_BACKENDS=JS_IR
// CHECK_LABELS_COUNT: function=sumEven name=$l$block count=0 TARGET_BACKENDS=JS_IR
internal fun sumEven(a: Array<Int>): Int { internal fun sumEven(a: Array<Int>): Int {
return filteredReduce(a, { x -> x % 2 == 0}, { x, y -> x + y}) return filteredReduce(a, { x -> x % 2 == 0}, { x, y -> x + y})
} }
@@ -21,6 +21,8 @@ internal inline fun maxBy(a: Array<Int>, keyFun: (Int) -> Int): Int {
return maxVal return maxVal
} }
// CHECK_BREAKS_COUNT: function=maxBySquare count=0 TARGET_BACKENDS=JS_IR
// CHECK_LABELS_COUNT: function=maxBySquare name=$l$block count=0 TARGET_BACKENDS=JS_IR
internal fun maxBySquare(a: Array<Int>, r: Result): Result { internal fun maxBySquare(a: Array<Int>, r: Result): Result {
var invocationCount = 0 var invocationCount = 0
val maxVal = maxBy(a, { x -> invocationCount++; x * x;}) val maxVal = maxBy(a, { x -> invocationCount++; x * x;})
+2
View File
@@ -11,6 +11,8 @@ internal data class IntPair(public var fst: Int, public var snd: Int) {
inline public fun setSnd(v: Int) { this.snd = v } inline public fun setSnd(v: Int) { this.snd = v }
} }
// CHECK_BREAKS_COUNT: function=myAdd count=0 TARGET_BACKENDS=JS_IR
// CHECK_LABELS_COUNT: function=myAdd name=$l$block count=0 TARGET_BACKENDS=JS_IR
internal fun myAdd(p: IntPair, toFst: Int, toSnd: Int) { internal fun myAdd(p: IntPair, toFst: Int, toSnd: Int) {
val fst = p.getFst() val fst = p.getFst()
p.setFst(fst + toFst) p.setFst(fst + toFst)
@@ -33,6 +33,8 @@ internal inline fun factAbs(state: State) {
} }
} }
// CHECK_BREAKS_COUNT: function=factAbsNoInline1 count=1 TARGET_BACKENDS=JS_IR
// CHECK_LABELS_COUNT: function=factAbsNoInline1 name=$l$block count=1 TARGET_BACKENDS=JS_IR
internal fun factAbsNoInline1(state: State): Int { internal fun factAbsNoInline1(state: State): Int {
factAbs(state) factAbs(state)
return state.value return state.value
+4
View File
@@ -3,6 +3,8 @@ package foo
// CHECK_FUNCTIONS_HAVE_SAME_LINES: declaredBefore declaredAfter match=(h|g)1 replace=$1 TARGET_BACKENDS=JS // CHECK_FUNCTIONS_HAVE_SAME_LINES: declaredBefore declaredAfter match=(h|g)1 replace=$1 TARGET_BACKENDS=JS
// CHECK_BREAKS_COUNT: function=declaredBefore count=0 TARGET_BACKENDS=JS_IR
// CHECK_LABELS_COUNT: function=declaredBefore name=$l$block count=0 TARGET_BACKENDS=JS_IR
fun declaredBefore(): Int { fun declaredBefore(): Int {
val a = g() + h() val a = g() + h()
return a return a
@@ -28,6 +30,8 @@ inline fun h1(): Int {
return a return a
} }
// CHECK_BREAKS_COUNT: function=declaredAfter count=0 TARGET_BACKENDS=JS_IR
// CHECK_LABELS_COUNT: function=declaredAfter name=$l$block count=0 TARGET_BACKENDS=JS_IR
fun declaredAfter(): Int { fun declaredAfter(): Int {
val a = g1() + h1() val a = g1() + h1()
return a return a
@@ -7,6 +7,8 @@ inline fun sum(a: Int, b: Int): Int {
return a + b return a + b
} }
// CHECK_BREAKS_COUNT: function=box count=0 TARGET_BACKENDS=JS_IR
// CHECK_LABELS_COUNT: function=box name=$l$block count=0 TARGET_BACKENDS=JS_IR
fun box(): String { fun box(): String {
val sum3 = sum(1, 2) val sum3 = sum(1, 2)
assertEquals(3, sum3) assertEquals(3, sum3)
@@ -20,6 +20,8 @@ inline fun convolutedOk(): I {
return ok() return ok()
} }
// CHECK_BREAKS_COUNT: function=box count=0 TARGET_BACKENDS=JS_IR
// CHECK_LABELS_COUNT: function=box name=$l$block count=0 TARGET_BACKENDS=JS_IR
fun box(): String { fun box(): String {
val ok = js("_").convolutedOk() val ok = js("_").convolutedOk()
if (ok !is I) return "fail" if (ok !is I) return "fail"
+4
View File
@@ -13,11 +13,15 @@ class Foo {
val baz = Baz() val baz = Baz()
} }
// CHECK_BREAKS_COUNT: function=testDispatch count=0 TARGET_BACKENDS=JS_IR
// CHECK_LABELS_COUNT: function=testDispatch name=$l$block count=0 TARGET_BACKENDS=JS_IR
fun testDispatch(foo: Foo): String { fun testDispatch(foo: Foo): String {
foo.bar { return "O" } foo.bar { return "O" }
return "FailDispatch;" return "FailDispatch;"
} }
// CHECK_BREAKS_COUNT: function=testExtension count=0 TARGET_BACKENDS=JS_IR
// CHECK_LABELS_COUNT: function=testExtension name=$l$block count=0 TARGET_BACKENDS=JS_IR
fun testExtension(foo: Foo): String { fun testExtension(foo: Foo): String {
foo.baz { return "K" } foo.baz { return "K" }
return "FailExtension;" return "FailExtension;"
@@ -3,6 +3,8 @@ package foo
inline fun bar(f: () -> Int): Array<Int> = arrayOf(f()) inline fun bar(f: () -> Int): Array<Int> = arrayOf(f())
// CHECK_BREAKS_COUNT: function=box count=0 TARGET_BACKENDS=JS_IR
// CHECK_LABELS_COUNT: function=box name=$l$block count=0 TARGET_BACKENDS=JS_IR
fun box(): String { fun box(): String {
val iterator = bar { 23 }.iterator() val iterator = bar { 23 }.iterator()
assertEquals(true, iterator.hasNext()) assertEquals(true, iterator.hasNext())
+2
View File
@@ -7,6 +7,8 @@ package foo
internal inline fun sum(x: Int, y: Int): Int = js("x + y") internal inline fun sum(x: Int, y: Int): Int = js("x + y")
// CHECK_BREAKS_COUNT: function=test count=0 TARGET_BACKENDS=JS_IR
// CHECK_LABELS_COUNT: function=test name=$l$block count=0 TARGET_BACKENDS=JS_IR
internal fun test(x: Int, y: Int): Int = sum(sum(x, x), sum(y, y)) internal fun test(x: Int, y: Int): Int = sum(sum(x, x), sum(y, y))
fun box(): String { fun box(): String {
@@ -7,6 +7,8 @@ package foo
internal inline fun sum(x: Int, y: Int): Int = js("var a = x; a + y") internal inline fun sum(x: Int, y: Int): Int = js("var a = x; a + y")
// CHECK_BREAKS_COUNT: function=test count=0 TARGET_BACKENDS=JS_IR
// CHECK_LABELS_COUNT: function=test name=$l$block count=0 TARGET_BACKENDS=JS_IR
internal fun test(x: Int, y: Int): Int { internal fun test(x: Int, y: Int): Int {
val xx = sum(x, x) val xx = sum(x, x)
js("var a = 0;") js("var a = 0;")
@@ -11,6 +11,8 @@ internal inline fun <T> runLambdaInLambda(noinline inner: (T) -> T, outer: ((T)
return outer(inner, arg) return outer(inner, arg)
} }
// CHECK_BREAKS_COUNT: function=multiplyBy2 count=0 TARGET_BACKENDS=JS_IR
// CHECK_LABELS_COUNT: function=multiplyBy2 name=$l$block count=0 TARGET_BACKENDS=JS_IR
internal fun multiplyBy2(x: Int): Int { internal fun multiplyBy2(x: Int): Int {
return runLambdaInLambda({ it * 2 }, { f, x -> f(x) }, x) return runLambdaInLambda({ it * 2 }, { f, x -> f(x) }, x)
} }
@@ -5,6 +5,8 @@ inline fun run(func: () -> Int): Int {
return func() return func()
} }
// CHECK_BREAKS_COUNT: function=box count=0 TARGET_BACKENDS=JS_IR
// CHECK_LABELS_COUNT: function=box name=$l$block count=0 TARGET_BACKENDS=JS_IR
fun bar(): Int { fun bar(): Int {
var f = { -> 0 } var f = { -> 0 }
var get0 = f var get0 = f
@@ -7,6 +7,8 @@ inline fun run(func: () -> Int): Int {
return func() return func()
} }
// CHECK_BREAKS_COUNT: function=bar count=0 TARGET_BACKENDS=JS_IR
// CHECK_LABELS_COUNT: function=bar name=$l$block count=0 TARGET_BACKENDS=JS_IR
fun bar(p: IntPair): Int { fun bar(p: IntPair): Int {
var f = { -> p.fst++ } var f = { -> p.fst++ }
var get0 = f var get0 = f
@@ -1,6 +1,8 @@
inline fun foo(l: () -> Unit) { l() } inline fun foo(l: () -> Unit) { l() }
inline fun bar(l: () -> Unit) { l() } inline fun bar(l: () -> Unit) { l() }
// CHECK_BREAKS_COUNT: function=box count=1 TARGET_BACKENDS=JS_IR
// CHECK_LABELS_COUNT: function=box name=$l$block count=1 TARGET_BACKENDS=JS_IR
fun box(): String { fun box(): String {
foo { foo {
bar { bar {
@@ -26,6 +26,8 @@ inline fun run(): String {
// FILE: 3.kt // FILE: 3.kt
// CHECK_BREAKS_COUNT: function=ok count=0 TARGET_BACKENDS=JS_IR
// CHECK_LABELS_COUNT: function=ok name=$l$block count=0 TARGET_BACKENDS=JS_IR
fun ok() = o.run() + k.run() fun ok() = o.run() + k.run()
// FILE: main.kt // FILE: main.kt
@@ -12,6 +12,8 @@ internal inline fun repeatAction(times: Int, action: () -> Unit) {
} }
} }
// CHECK_BREAKS_COUNT: function=capturedInLambda count=0 TARGET_BACKENDS=JS_IR
// CHECK_LABELS_COUNT: function=capturedInLambda name=$l$block count=0 TARGET_BACKENDS=JS_IR
internal fun capturedInLambda(state: State, a: Int, b: Int): Int { internal fun capturedInLambda(state: State, a: Int, b: Int): Int {
inline fun State.inc() { inline fun State.inc() {
count++ count++
@@ -25,6 +27,8 @@ internal fun capturedInLambda(state: State, a: Int, b: Int): Int {
} }
// CHECK_BREAKS_COUNT: function=declaredInLambda count=0 TARGET_BACKENDS=JS_IR
// CHECK_LABELS_COUNT: function=declaredInLambda name=$l$block count=0 TARGET_BACKENDS=JS_IR
internal fun declaredInLambda(state: State, a: Int, b: Int): Int { internal fun declaredInLambda(state: State, a: Int, b: Int): Int {
repeatAction(a) { repeatAction(a) {
inline fun State.inc() { inline fun State.inc() {
@@ -10,6 +10,8 @@ internal inline fun repeatAction(times: Int, action: () -> Unit) {
} }
} }
// CHECK_BREAKS_COUNT: function=localWithoutCapture count=0 TARGET_BACKENDS=JS_IR
// CHECK_LABELS_COUNT: function=localWithoutCapture name=$l$block count=0 TARGET_BACKENDS=JS_IR
internal fun localWithoutCapture(a: Int, b: Int): Int { internal fun localWithoutCapture(a: Int, b: Int): Int {
var sum = 0 var sum = 0
@@ -24,6 +26,8 @@ internal fun localWithoutCapture(a: Int, b: Int): Int {
return sum return sum
} }
// CHECK_BREAKS_COUNT: function=localWithCapture count=0 TARGET_BACKENDS=JS_IR
// CHECK_LABELS_COUNT: function=localWithCapture name=$l$block count=0 TARGET_BACKENDS=JS_IR
internal fun localWithCapture(a: Int, b: Int): Int { internal fun localWithCapture(a: Int, b: Int): Int {
var sum = 0 var sum = 0
@@ -11,6 +11,8 @@ internal inline fun repeatAction(times: Int, action: () -> Unit) {
} }
} }
// CHECK_BREAKS_COUNT: function=addToState count=0 TARGET_BACKENDS=JS_IR
// CHECK_LABELS_COUNT: function=addToState name=$l$block count=0 TARGET_BACKENDS=JS_IR
internal fun addToState(state: State, a: Int, b: Int): Int { internal fun addToState(state: State, a: Int, b: Int): Int {
inline fun inc(a: Int): Int { inline fun inc(a: Int): Int {
return a + 1 return a + 1
@@ -10,6 +10,8 @@ internal inline fun repeatAction(times: Int, action: () -> Unit) {
} }
} }
// CHECK_BREAKS_COUNT: function=localWithoutCapture count=0 TARGET_BACKENDS=JS_IR
// CHECK_LABELS_COUNT: function=localWithoutCapture name=$l$block count=0 TARGET_BACKENDS=JS_IR
internal fun localWithoutCapture(a: Int, b: Int): Int { internal fun localWithoutCapture(a: Int, b: Int): Int {
var mult = 0 var mult = 0
@@ -26,6 +28,8 @@ internal fun localWithoutCapture(a: Int, b: Int): Int {
return mult return mult
} }
// CHECK_BREAKS_COUNT: function=localWithCapture count=0 TARGET_BACKENDS=JS_IR
// CHECK_LABELS_COUNT: function=localWithCapture name=$l$block count=0 TARGET_BACKENDS=JS_IR
internal fun localWithCapture(a: Int, b: Int): Int { internal fun localWithCapture(a: Int, b: Int): Int {
var mult = 0 var mult = 0
@@ -7,6 +7,8 @@ internal inline fun run(action: () -> Int): Int {
return action() return action()
} }
// CHECK_BREAKS_COUNT: function=myAdd count=0 TARGET_BACKENDS=JS_IR
// CHECK_LABELS_COUNT: function=myAdd name=$l$block count=0 TARGET_BACKENDS=JS_IR
internal fun myAdd(a: Int, b: Int): Int { internal fun myAdd(a: Int, b: Int): Int {
var sum = a + b var sum = a + b
@@ -9,6 +9,8 @@ class A(val a: Int, val b: Int)
inline operator fun A.component1(): Int = a inline operator fun A.component1(): Int = a
inline operator fun A.component2(): Int = b inline operator fun A.component2(): Int = b
// CHECK_BREAKS_COUNT: function=box count=0 TARGET_BACKENDS=JS_IR
// CHECK_LABELS_COUNT: function=box name=$l$block count=0 TARGET_BACKENDS=JS_IR
fun box(): String { fun box(): String {
val (a, b) = A(1, 2) val (a, b) = A(1, 2)
assertEquals(1, a) assertEquals(1, a)
@@ -10,6 +10,8 @@ internal inline fun <T> run(noinline func: (T) -> T, arg: T): T {
return func(arg) return func(arg)
} }
// CHECK_BREAKS_COUNT: function=multiplyBy2 count=0 TARGET_BACKENDS=JS_IR
// CHECK_LABELS_COUNT: function=multiplyBy2 name=$l$block count=0 TARGET_BACKENDS=JS_IR
internal fun multiplyBy2(x: Int): Int { internal fun multiplyBy2(x: Int): Int {
return run({ it * 2 }, x) return run({ it * 2 }, x)
} }
+2
View File
@@ -58,6 +58,8 @@ class N(val value: Int) {
inline operator fun dec() = N(value - 1) inline operator fun dec() = N(value - 1)
} }
// CHECK_BREAKS_COUNT: function=box count=0 TARGET_BACKENDS=JS_IR
// CHECK_LABELS_COUNT: function=box name=$l$block count=0 TARGET_BACKENDS=JS_IR
fun box(): String { fun box(): String {
var result = A() + 1 var result = A() + 1
if (result != 11) return "fail: member operator: $result" if (result != 11) return "fail: member operator: $result"
+8
View File
@@ -21,21 +21,29 @@ class Inline() {
} }
} }
// CHECK_BREAKS_COUNT: function=test1 count=0 TARGET_BACKENDS=JS_IR
// CHECK_LABELS_COUNT: function=test1 name=$l$block count=0 TARGET_BACKENDS=JS_IR
fun test1(): Int { fun test1(): Int {
val inlineX = Inline() val inlineX = Inline()
return inlineX.foo1Int({ z: Int -> z}, 25) return inlineX.foo1Int({ z: Int -> z}, 25)
} }
// CHECK_BREAKS_COUNT: function=test2 count=0 TARGET_BACKENDS=JS_IR
// CHECK_LABELS_COUNT: function=test2 name=$l$block count=0 TARGET_BACKENDS=JS_IR
fun test2(): Double { fun test2(): Double {
val inlineX = Inline() val inlineX = Inline()
return inlineX.foo1Double(25.0, { z: Double -> z}) return inlineX.foo1Double(25.0, { z: Double -> z})
} }
// CHECK_BREAKS_COUNT: function=test3 count=0 TARGET_BACKENDS=JS_IR
// CHECK_LABELS_COUNT: function=test3 name=$l$block count=0 TARGET_BACKENDS=JS_IR
fun test3(): Double { fun test3(): Double {
val inlineX = Inline() val inlineX = Inline()
return inlineX.foo2Param(15.0, { z1: Int, z2: Double -> z1 + z2}, 10) return inlineX.foo2Param(15.0, { z1: Int, z2: Double -> z1 + z2}, 10)
} }
// CHECK_BREAKS_COUNT: function=test3WithCaptured count=0 TARGET_BACKENDS=JS_IR
// CHECK_LABELS_COUNT: function=test3WithCaptured name=$l$block count=0 TARGET_BACKENDS=JS_IR
fun test3WithCaptured(): Double { fun test3WithCaptured(): Double {
val inlineX = Inline() val inlineX = Inline()
var c = 11.0; var c = 11.0;
@@ -176,6 +176,8 @@ private var A.p17: Int
} }
// CHECK_BREAKS_COUNT: function=box count=0 TARGET_BACKENDS=JS_IR
// CHECK_LABELS_COUNT: function=box name=$l$block count=0 TARGET_BACKENDS=JS_IR
fun box(): String { fun box(): String {
p1 = 1 p1 = 1
if (p1 != 10101) return "test1: $p1" if (p1 != 10101) return "test1: $p1"
+2
View File
@@ -5,6 +5,8 @@ package foo
inline fun <T : Any, R> T.doLet(f: (T) -> R): R = f(this) inline fun <T : Any, R> T.doLet(f: (T) -> R): R = f(this)
// CHECK_BREAKS_COUNT: function=sum count=0 TARGET_BACKENDS=JS_IR
// CHECK_LABELS_COUNT: function=sum name=$l$block count=0 TARGET_BACKENDS=JS_IR
private fun sum(x: Int?, y: Int): Int = private fun sum(x: Int?, y: Int): Int =
x?.doLet { it + y } ?: 0 x?.doLet { it + y } ?: 0
@@ -7,6 +7,8 @@ inline fun bar(x: Int) = foo(x)
inline fun bar(x: String) = foo(x) inline fun bar(x: String) = foo(x)
// CHECK_BREAKS_COUNT: function=box count=0 TARGET_BACKENDS=JS_IR
// CHECK_LABELS_COUNT: function=box name=$l$block count=0 TARGET_BACKENDS=JS_IR
fun box(): String { fun box(): String {
val a = bar(23) val a = bar(23)
if (a != "int: 23") return "fail1: $a" if (a != "int: 23") return "fail1: $a"
@@ -17,17 +17,23 @@ class Inline() {
} }
} }
// CHECK_BREAKS_COUNT: function=test1 count=0 TARGET_BACKENDS=JS_IR
// CHECK_LABELS_COUNT: function=test1 name=$l$block count=0 TARGET_BACKENDS=JS_IR
fun test1(): Double { fun test1(): Double {
val inlineX = Inline() val inlineX = Inline()
return inlineX.foo1({ z: Int -> z}, 25, { z: Double -> z}, 11.5) return inlineX.foo1({ z: Int -> z}, 25, { z: Double -> z}, 11.5)
} }
// CHECK_BREAKS_COUNT: function=test1WithCaptured count=0 TARGET_BACKENDS=JS_IR
// CHECK_LABELS_COUNT: function=test1WithCaptured name=$l$block count=0 TARGET_BACKENDS=JS_IR
fun test1WithCaptured(): Double { fun test1WithCaptured(): Double {
val inlineX = Inline() val inlineX = Inline()
var d = 0.0; var d = 0.0;
return inlineX.foo1({ z: Int -> d = 1.0; z}, 25, { z: Double -> z + d}, 11.5) return inlineX.foo1({ z: Int -> d = 1.0; z}, 25, { z: Double -> z + d}, 11.5)
} }
// CHECK_BREAKS_COUNT: function=test2 count=0 TARGET_BACKENDS=JS_IR
// CHECK_LABELS_COUNT: function=test2 name=$l$block count=0 TARGET_BACKENDS=JS_IR
fun test2(): Double { fun test2(): Double {
val inlineX = Inline() val inlineX = Inline()
return inlineX.foo2({ z: Int, p: Int -> z + p}, 25, { x: Double, y: Int, z: Int -> z + x + y}, 11.5, 2) return inlineX.foo2({ z: Int, p: Int -> z + p}, 25, { x: Double, y: Int, z: Int -> z + x + y}, 11.5, 2)
+2 -1
View File
@@ -15,7 +15,8 @@ public inline fun <R> minByTest(f: (Int) -> R): R {
val v = f(1) val v = f(1)
return v return v
} }
// CHECK_BREAKS_COUNT: function=box count=0 TARGET_BACKENDS=JS_IR
// CHECK_LABELS_COUNT: function=box name=$l$block count=0 TARGET_BACKENDS=JS_IR
fun box(): String { fun box(): String {
val result = runTest{minByTest<Int> { it }} val result = runTest{minByTest<Int> { it }}
+14
View File
@@ -30,37 +30,51 @@ class InlineDouble(val res : Double) {
} }
} }
// CHECK_BREAKS_COUNT: function=test0Param count=0 TARGET_BACKENDS=JS_IR
// CHECK_LABELS_COUNT: function=test0Param name=$l$block count=0 TARGET_BACKENDS=JS_IR
fun test0Param(): Double { fun test0Param(): Double {
val inlineX = InlineDouble(10.0) val inlineX = InlineDouble(10.0)
return inlineX.foo({ -> 1.0}) return inlineX.foo({ -> 1.0})
} }
// CHECK_BREAKS_COUNT: function=test1Param count=0 TARGET_BACKENDS=JS_IR
// CHECK_LABELS_COUNT: function=test1Param name=$l$block count=0 TARGET_BACKENDS=JS_IR
fun test1Param(): Double { fun test1Param(): Double {
val inlineX = InlineDouble(10.0) val inlineX = InlineDouble(10.0)
return inlineX.foo11({ z: Double -> z}) return inlineX.foo11({ z: Double -> z})
} }
// CHECK_BREAKS_COUNT: function=test1ParamCaptured count=0 TARGET_BACKENDS=JS_IR
// CHECK_LABELS_COUNT: function=test1ParamCaptured name=$l$block count=0 TARGET_BACKENDS=JS_IR
fun test1ParamCaptured(): Double { fun test1ParamCaptured(): Double {
val s = 100.0 val s = 100.0
val inlineX = InlineDouble(10.0) val inlineX = InlineDouble(10.0)
return inlineX.foo11({ z: Double -> s}) return inlineX.foo11({ z: Double -> s})
} }
// CHECK_BREAKS_COUNT: function=test1ParamMissed count=0 TARGET_BACKENDS=JS_IR
// CHECK_LABELS_COUNT: function=test1ParamMissed name=$l$block count=0 TARGET_BACKENDS=JS_IR
fun test1ParamMissed() : Double { fun test1ParamMissed() : Double {
val inlineX = InlineDouble(10.0) val inlineX = InlineDouble(10.0)
return inlineX.foo11({ z: Double -> 111.0}) return inlineX.foo11({ z: Double -> 111.0})
} }
// CHECK_BREAKS_COUNT: function=test1ParamFromCallContext count=0 TARGET_BACKENDS=JS_IR
// CHECK_LABELS_COUNT: function=test1ParamFromCallContext name=$l$block count=0 TARGET_BACKENDS=JS_IR
fun test1ParamFromCallContext() : Double { fun test1ParamFromCallContext() : Double {
val inlineX = InlineDouble(1000.0) val inlineX = InlineDouble(1000.0)
return inlineX.fooRes({ z: Double -> z}) return inlineX.fooRes({ z: Double -> z})
} }
// CHECK_BREAKS_COUNT: function=test2Params count=0 TARGET_BACKENDS=JS_IR
// CHECK_LABELS_COUNT: function=test2Params name=$l$block count=0 TARGET_BACKENDS=JS_IR
fun test2Params() : Double { fun test2Params() : Double {
val inlineX = InlineDouble(1000.0) val inlineX = InlineDouble(1000.0)
return inlineX.fooRes2({ y: Double, z: Double -> 2.0 * y + 3.0 * z}) return inlineX.fooRes2({ y: Double, z: Double -> 2.0 * y + 3.0 * z})
} }
// CHECK_BREAKS_COUNT: function=test2ParamsWithCaptured count=0 TARGET_BACKENDS=JS_IR
// CHECK_LABELS_COUNT: function=test2ParamsWithCaptured name=$l$block count=0 TARGET_BACKENDS=JS_IR
fun test2ParamsWithCaptured() : Double { fun test2ParamsWithCaptured() : Double {
val inlineX = InlineDouble(1000.0) val inlineX = InlineDouble(1000.0)
val s = 9.0 val s = 9.0
+2
View File
@@ -15,6 +15,8 @@ enum class MyEnum {
} }
} }
// CHECK_BREAKS_COUNT: function=test1 count=0 TARGET_BACKENDS=JS_IR
// CHECK_LABELS_COUNT: function=test1 name=$l$block count=0 TARGET_BACKENDS=JS_IR
fun test1(): String { fun test1(): String {
return MyEnum.K.doSmth("O") return MyEnum.K.doSmth("O")
} }
+14
View File
@@ -30,37 +30,51 @@ class Inline(val res : Int) {
} }
} }
// CHECK_BREAKS_COUNT: function=test0Param count=0 TARGET_BACKENDS=JS_IR
// CHECK_LABELS_COUNT: function=test0Param name=$l$block count=0 TARGET_BACKENDS=JS_IR
fun test0Param(): Int { fun test0Param(): Int {
val inlineX = Inline(10) val inlineX = Inline(10)
return inlineX.foo({ -> 1}) return inlineX.foo({ -> 1})
} }
// CHECK_BREAKS_COUNT: function=test1Param count=0 TARGET_BACKENDS=JS_IR
// CHECK_LABELS_COUNT: function=test1Param name=$l$block count=0 TARGET_BACKENDS=JS_IR
fun test1Param(): Int { fun test1Param(): Int {
val inlineX = Inline(10) val inlineX = Inline(10)
return inlineX.foo11({ z: Int -> z}) return inlineX.foo11({ z: Int -> z})
} }
// CHECK_BREAKS_COUNT: function=test1ParamCaptured count=0 TARGET_BACKENDS=JS_IR
// CHECK_LABELS_COUNT: function=test1ParamCaptured name=$l$block count=0 TARGET_BACKENDS=JS_IR
fun test1ParamCaptured(): Int { fun test1ParamCaptured(): Int {
val s = 100 val s = 100
val inlineX = Inline(10) val inlineX = Inline(10)
return inlineX.foo11({ z: Int -> s}) return inlineX.foo11({ z: Int -> s})
} }
// CHECK_BREAKS_COUNT: function=test1ParamMissed count=0 TARGET_BACKENDS=JS_IR
// CHECK_LABELS_COUNT: function=test1ParamMissed name=$l$block count=0 TARGET_BACKENDS=JS_IR
fun test1ParamMissed() : Int { fun test1ParamMissed() : Int {
val inlineX = Inline(10) val inlineX = Inline(10)
return inlineX.foo11({ z: Int -> 111}) return inlineX.foo11({ z: Int -> 111})
} }
// CHECK_BREAKS_COUNT: function=test1ParamFromCallContext count=0 TARGET_BACKENDS=JS_IR
// CHECK_LABELS_COUNT: function=test1ParamFromCallContext name=$l$block count=0 TARGET_BACKENDS=JS_IR
fun test1ParamFromCallContext() : Int { fun test1ParamFromCallContext() : Int {
val inlineX = Inline(1000) val inlineX = Inline(1000)
return inlineX.fooRes({ z: Int -> z}) return inlineX.fooRes({ z: Int -> z})
} }
// CHECK_BREAKS_COUNT: function=test2Params count=0 TARGET_BACKENDS=JS_IR
// CHECK_LABELS_COUNT: function=test2Params name=$l$block count=0 TARGET_BACKENDS=JS_IR
fun test2Params() : Int { fun test2Params() : Int {
val inlineX = Inline(1000) val inlineX = Inline(1000)
return inlineX.fooRes2({ y: Int, z: Int -> 2 * y + 3 * z}) return inlineX.fooRes2({ y: Int, z: Int -> 2 * y + 3 * z})
} }
// CHECK_BREAKS_COUNT: function=test2ParamsWithCaptured count=0 TARGET_BACKENDS=JS_IR
// CHECK_LABELS_COUNT: function=test2ParamsWithCaptured name=$l$block count=0 TARGET_BACKENDS=JS_IR
fun test2ParamsWithCaptured() : Int { fun test2ParamsWithCaptured() : Int {
val inlineX = Inline(1000) val inlineX = Inline(1000)
val s = 9 val s = 9
+4
View File
@@ -19,6 +19,8 @@ public inline fun use2() : Int {
class Z {} class Z {}
// CHECK_BREAKS_COUNT: function=test1 count=0 TARGET_BACKENDS=JS_IR
// CHECK_LABELS_COUNT: function=test1 name=$l$block count=0 TARGET_BACKENDS=JS_IR
fun test1() : Int { fun test1() : Int {
val input = Z() val input = Z()
return input.use<Z, Int>{ return input.use<Z, Int>{
@@ -26,6 +28,8 @@ fun test1() : Int {
} }
} }
// CHECK_BREAKS_COUNT: function=test2 count=0 TARGET_BACKENDS=JS_IR
// CHECK_LABELS_COUNT: function=test2 name=$l$block count=0 TARGET_BACKENDS=JS_IR
fun test2() : Int { fun test2() : Int {
val x = 1000 val x = 1000
return use2() + x return use2() + x
+14
View File
@@ -30,37 +30,51 @@ class InlineString(val res : String) {
} }
} }
// CHECK_BREAKS_COUNT: function=test0Param count=0 TARGET_BACKENDS=JS_IR
// CHECK_LABELS_COUNT: function=test0Param name=$l$block count=0 TARGET_BACKENDS=JS_IR
fun test0Param(): String { fun test0Param(): String {
val inlineX = InlineString("10") val inlineX = InlineString("10")
return inlineX.foo({ -> "1"}) return inlineX.foo({ -> "1"})
} }
// CHECK_BREAKS_COUNT: function=test1Param count=0 TARGET_BACKENDS=JS_IR
// CHECK_LABELS_COUNT: function=test1Param name=$l$block count=0 TARGET_BACKENDS=JS_IR
fun test1Param(): String { fun test1Param(): String {
val inlineX = InlineString("10") val inlineX = InlineString("10")
return inlineX.foo11({ z: String -> z}) return inlineX.foo11({ z: String -> z})
} }
// CHECK_BREAKS_COUNT: function=test1ParamCaptured count=0 TARGET_BACKENDS=JS_IR
// CHECK_LABELS_COUNT: function=test1ParamCaptured name=$l$block count=0 TARGET_BACKENDS=JS_IR
fun test1ParamCaptured(): String { fun test1ParamCaptured(): String {
val s = "100" val s = "100"
val inlineX = InlineString("10") val inlineX = InlineString("10")
return inlineX.foo11({ z: String -> s}) return inlineX.foo11({ z: String -> s})
} }
// CHECK_BREAKS_COUNT: function=test1ParamMissed count=0 TARGET_BACKENDS=JS_IR
// CHECK_LABELS_COUNT: function=test1ParamMissed name=$l$block count=0 TARGET_BACKENDS=JS_IR
fun test1ParamMissed() : String { fun test1ParamMissed() : String {
val inlineX = InlineString("10") val inlineX = InlineString("10")
return inlineX.foo11({ z: String -> "111"}) return inlineX.foo11({ z: String -> "111"})
} }
// CHECK_BREAKS_COUNT: function=test1ParamFromCallContext count=0 TARGET_BACKENDS=JS_IR
// CHECK_LABELS_COUNT: function=test1ParamFromCallContext name=$l$block count=0 TARGET_BACKENDS=JS_IR
fun test1ParamFromCallContext() : String { fun test1ParamFromCallContext() : String {
val inlineX = InlineString("1000") val inlineX = InlineString("1000")
return inlineX.fooRes({ z: String -> z}) return inlineX.fooRes({ z: String -> z})
} }
// CHECK_BREAKS_COUNT: function=test2Params count=0 TARGET_BACKENDS=JS_IR
// CHECK_LABELS_COUNT: function=test2Params name=$l$block count=0 TARGET_BACKENDS=JS_IR
fun test2Params() : String { fun test2Params() : String {
val inlineX = InlineString("1000") val inlineX = InlineString("1000")
return inlineX.fooRes2({ y: String, z: String -> y + "0" + z}) return inlineX.fooRes2({ y: String, z: String -> y + "0" + z})
} }
// CHECK_BREAKS_COUNT: function=test2ParamsWithCaptured count=0 TARGET_BACKENDS=JS_IR
// CHECK_LABELS_COUNT: function=test2ParamsWithCaptured name=$l$block count=0 TARGET_BACKENDS=JS_IR
fun test2ParamsWithCaptured() : String { fun test2ParamsWithCaptured() : String {
val inlineX = InlineString("1000") val inlineX = InlineString("1000")
val s = "9" val s = "9"
@@ -12,6 +12,8 @@ inline fun run(noinline f: () -> Int): Int {
return f() return f()
} }
// CHECK_BREAKS_COUNT: function=box count=0 TARGET_BACKENDS=JS_IR
// CHECK_LABELS_COUNT: function=box name=$l$block count=0 TARGET_BACKENDS=JS_IR
fun box(): String { fun box(): String {
run({ toggle(); 4 }) run({ toggle(); 4 })
assertEquals(true, flag) assertEquals(true, flag)
@@ -9,6 +9,8 @@ inline fun withState(state: State, ext: State.() -> Unit) {
state.value = 0 state.value = 0
} }
// CHECK_BREAKS_COUNT: function=box count=0 TARGET_BACKENDS=JS_IR
// CHECK_LABELS_COUNT: function=box name=$block count=0 TARGET_BACKENDS=JS_IR
fun box(): String { fun box(): String {
val state = State() val state = State()
@@ -16,6 +16,8 @@ class B(val value: Int) {
} }
} }
// CHECK_BREAKS_COUNT: function=box count=0 TARGET_BACKENDS=JS_IR
// CHECK_LABELS_COUNT: function=box name=$l$block count=0 TARGET_BACKENDS=JS_IR
public fun box(): String { public fun box(): String {
val a = A() val a = A()
a.setParam(10) a.setParam(10)
+2
View File
@@ -28,6 +28,8 @@ internal fun test3(list: Array<String>): String {
return concat(*list) return concat(*list)
} }
// CHECK_BREAKS_COUNT: function=box count=0 TARGET_BACKENDS=JS_IR
// CHECK_LABELS_COUNT: function=box name=$l$block count=0 TARGET_BACKENDS=JS_IR
fun box(): String { fun box(): String {
assertEquals("", test1()) assertEquals("", test1())
assertEquals("abc", test2()) assertEquals("abc", test2())