Minor. Add regression tests

#KT-64725 Fixed
 #KT-64726 Fixed
 #KT-64727 Fixed
This commit is contained in:
Ilmir Usmanov
2024-03-04 20:13:57 +01:00
committed by Space Team
parent b4c2164837
commit 0bb6359ac5
13 changed files with 386 additions and 0 deletions
@@ -0,0 +1,48 @@
// See KT-64726
// IGNORE_INLINER: IR
// IGNORE_BACKEND: WASM
// FILE: test.kt
inline fun String.switchMapOnce(crossinline mapper: (String) -> String): String {
return { mapper(this) }.let { it() }
}
fun box() {
"O".switchMapOnce {
"K".switchMapOnce {
"OK"
} // Should be present
}
}
// EXPECTATIONS JVM_IR
// test.kt:10 box
// test.kt:6 box
// fake.kt:1 box
// test.kt:6 box
// test.kt:6 invoke
// test.kt:12 invoke
// test.kt:6 invoke
// fake.kt:1 invoke
// test.kt:6 invoke
// test.kt:6 invoke
// test.kt:13 invoke
// test.kt:6 invoke
// test.kt:6 invoke
// test.kt:14 invoke
// test.kt:6 invoke
// test.kt:6 box
// test.kt:16 box
// EXPECTATIONS JS_IR
// test.kt:6 box$lambda
// test.kt:6 box
// test.kt:6 box$lambda$lambda
// test.kt:6 box$lambda$lambda
// test.kt:6 box$lambda$lambda
// test.kt:6 box$lambda$lambda$lambda
// test.kt:16 box
// EXPECTATIONS WASM
// test.kt:10 $box (8, 4, 4, 4, 4, 8)
// test.kt:16 $box
@@ -0,0 +1,68 @@
// See KT-64725
// IGNORE_INLINER_K2: IR
// WITH_STDLIB
// FILE: test.kt
fun foo(block: () -> String): String = block()
inline fun bar(crossinline f: () -> String) = foo { f() }
fun flaf() {
bar {
run {
"B"
} // Should be present
}
}
fun box() {
flaf()
}
// EXPECTATIONS JVM_IR
// test.kt:18 box
// test.kt:10 flaf
// test.kt:7 flaf
// test.kt:6 foo
// test.kt:7 invoke
// test.kt:11 invoke
// test.kt:12 invoke
// test.kt:11 invoke
// test.kt:13 invoke
// test.kt:7 invoke
// test.kt:6 foo
// test.kt:7 flaf
// test.kt:15 flaf
// test.kt:19 box
// EXPECTATIONS JS_IR
// test.kt:18 box
// test.kt:7 flaf
// test.kt:6 foo
// test.kt:7 flaf$lambda
// test.kt:15 flaf
// test.kt:19 box
// EXPECTATIONS WASM
// test.kt:18 $box
// test.kt:10 $flaf
// test.kt:7 $flaf (46, 46, 57)
// test.kt:6 $foo (39, 46)
// test.kt:7 $flaf$lambda.invoke (52, 55)
// kotlin-package.kt:6 $flaf$lambda.invoke
// kotlin-package.kt:11 $flaf$lambda.invoke (917, 1002, 1002, 995)
// kotlin-package.kt:8 $flaf$lambda.invoke (3, 3, 3, 3, 6, 16)
// String.kt:141 $kotlin.stringLiteral (17, 28, 17)
// Array.kt:59 $kotlin.Array.get (19, 26, 34, 8)
// ThrowHelpers.kt:29 $kotlin.wasm.internal.rangeCheck (6, 14, 6, 19, 28, 19, 6, 14, 6, 19, 28, 19)
// ThrowHelpers.kt:30 $kotlin.wasm.internal.rangeCheck (1, 1)
// Array.kt:60 $kotlin.Array.get (15, 27, 23, 8)
// String.kt:142 $kotlin.stringLiteral
// String.kt:146 $kotlin.stringLiteral (47, 61, 16, 4)
// String.kt:147 $kotlin.stringLiteral (20, 20, 20, 20, 27, 33, 41, 20, 4)
// String.kt:148 $kotlin.stringLiteral (4, 15, 25, 4)
// Array.kt:74 $kotlin.Array.set (19, 26, 34, 8)
// Array.kt:75 $kotlin.Array.set (8, 20, 27, 16)
// Array.kt:76 $kotlin.Array.set
// String.kt:149 $kotlin.stringLiteral (11, 4)
// test.kt:15 $flaf
// test.kt:19 $box
@@ -0,0 +1,90 @@
// See KT-64727
// WITH_STDLIB
// FILE: test.kt
inline fun <reified T : Any> foo(crossinline function: () -> T) {
object {
fun bar() {
function()
}
init {
bar()
}
}
}
fun box() {
var result = "Fail"
foo {
object {
init {
result = "OK"
} // Should be hit
}
}
}
// EXPECTATIONS JVM_IR
// test.kt:21 box
// test.kt:22 box
// test.kt:9 box
// test.kt:9 <init>
// test.kt:14 <init>
// test.kt:15 <init>
// test.kt:11 bar
// test.kt:23 bar
// test.kt:23 <init>
// test.kt:24 <init>
// test.kt:25 <init>
// test.kt:26 <init>
// test.kt:23 <init>
// test.kt:27 bar
// test.kt:11 bar
// test.kt:12 bar
// test.kt:16 <init>
// test.kt:9 <init>
// test.kt:9 box
// test.kt:18 box
// test.kt:29 box
// EXPECTATIONS JS_IR
// test.kt:21 box
// test.kt:9 box
// test.kt:15 <init>
// test.kt:23 bar
// test.kt:25 <init>
// test.kt:23 <init>
// test.kt:12 bar
// test.kt:9 <init>
// test.kt:29 box
// EXPECTATIONS WASM
// test.kt:21 $box (17, 4)
// String.kt:141 $kotlin.stringLiteral (17, 28, 17, 17, 28, 17)
// Array.kt:59 $kotlin.Array.get (19, 26, 34, 8, 19, 26, 34, 8)
// ThrowHelpers.kt:29 $kotlin.wasm.internal.rangeCheck (6, 14, 6, 19, 28, 19, 6, 14, 6, 19, 28, 19, 6, 14, 6, 19, 28, 19, 6, 14, 6, 19, 28, 19)
// ThrowHelpers.kt:30 $kotlin.wasm.internal.rangeCheck (1, 1, 1, 1)
// Array.kt:60 $kotlin.Array.get (15, 27, 23, 8, 15, 27, 23, 8)
// String.kt:142 $kotlin.stringLiteral (8, 8)
// String.kt:146 $kotlin.stringLiteral (47, 61, 16, 4, 47, 61, 16, 4)
// String.kt:147 $kotlin.stringLiteral (20, 20, 20, 20, 27, 33, 41, 20, 4, 20, 20, 20, 20, 27, 33, 41, 20, 4)
// String.kt:148 $kotlin.stringLiteral (4, 15, 25, 4, 4, 15, 25, 4)
// Array.kt:74 $kotlin.Array.set (19, 26, 34, 8, 19, 26, 34, 8)
// Array.kt:75 $kotlin.Array.set (8, 20, 27, 16, 8, 20, 27, 16)
// Array.kt:76 $kotlin.Array.set (5, 5)
// String.kt:149 $kotlin.stringLiteral (11, 4, 11, 4)
// test.kt:22 $box
// test.kt:9 $box (4, 4)
// test.kt:15 $<no name provided>.<init>
// test.kt:11 $<no name provided>.bar
// kotlin-package.kt:9 $<no name provided>.bar (37, 37)
// test.kt:25 $<no name provided>.<init> (16, 25, 25, 25, 25, 16)
// test.kt:27 $<no name provided>.<init>
// kotlin-package.kt:10 $<no name provided>.bar
// test.kt:12 $<no name provided>.bar
// test.kt:17 $<no name provided>.<init>
// test.kt:29 $box