[JS IR] Add tests for JS IR IC + PL

^KT-57347 related
This commit is contained in:
Alexander Korepanov
2023-05-08 16:54:30 +02:00
committed by Space Team
parent 97620030c6
commit 82a1242f22
96 changed files with 710 additions and 3 deletions
@@ -0,0 +1 @@
fun foo() = 0
@@ -0,0 +1 @@
fun foo(x: Int) = x + 1
@@ -0,0 +1 @@
fun foo() = 2
@@ -0,0 +1,3 @@
// this is known issue, that return type doesn not affect IdSignature
// https://youtrack.jetbrains.com/issue/KT-51707
fun foo() = "4"
@@ -0,0 +1 @@
fun foo(x: Int = 1) = "${x + 5}"
@@ -0,0 +1,27 @@
STEP 0:
modifications:
U : l1.0.kt -> l1.kt
added file: l1.kt
STEP 1:
modifications:
U : l1.1.kt -> l1.kt
modified ir: l1.kt
updated exports: l1.kt
STEP 2:
modifications:
U : l1.2.kt -> l1.kt
modified ir: l1.kt
updated exports: l1.kt
STEP 3:
STEP 4:
modifications:
U : l1.4.bug.kt -> l1.kt
modified ir: l1.kt
STEP 5:
STEP 6:
modifications:
U : l1.6.kt -> l1.kt
modified ir: l1.kt
updated exports: l1.kt
STEP 7:
updated exports: l1.kt
@@ -0,0 +1,11 @@
fun box(stepId: Int): String {
val x = test()
if (stepId == 4) {
// this is known issue, that return type doesn not affect IdSignature
// https://youtrack.jetbrains.com/issue/KT-51707
if (x != 41) return "Fail; got $x"
} else {
if (stepId != x) return "Fail; got $x"
}
return "OK"
}
@@ -0,0 +1,28 @@
STEP 0:
dependencies: lib1
modifications:
U : test.0.kt -> test.kt
added file: m.kt, test.kt
STEP 1..2:
dependencies: lib1
rebuild klib: false
updated imports: test.kt
STEP 3:
dependencies: lib1
modifications:
U : test.3.kt -> test.kt
modified ir: test.kt
STEP 4:
dependencies: lib1
rebuild klib: false
updated imports: test.kt
STEP 5:
dependencies: lib1
modified ir: test.kt
STEP 6:
dependencies: lib1
rebuild klib: false
updated imports: test.kt
STEP 7:
dependencies: lib1
modified ir: test.kt
@@ -0,0 +1,7 @@
fun test(): Int {
try {
return foo()
} catch (e: Error) {
return 1
}
}
@@ -0,0 +1,7 @@
fun test(): Int {
try {
return foo().toInt() + 1
} catch (e: Error) {
return 6
}
}
@@ -0,0 +1,20 @@
MODULES: lib1, main
STEP 0..2:
libs: lib1, main
dirty js: lib1, main
STEP 3:
libs: lib1, main
dirty js: main
STEP 4:
libs: lib1, main
dirty js: lib1, main
STEP 5:
libs: lib1, main
dirty js: main
STEP 6:
libs: lib1, main
dirty js: lib1, main
STEP 7:
libs: lib1, main
dirty js: lib1, main
@@ -0,0 +1,3 @@
interface Foo {
fun getSomething() = 0
}
@@ -0,0 +1,3 @@
open class Foo {
fun getSomething() = 77
}
@@ -0,0 +1,3 @@
interface Foo {
fun getSomething() = 2
}
@@ -0,0 +1,3 @@
open class Foo {
open fun getSomething() = 7
}
@@ -0,0 +1,21 @@
STEP 0:
modifications:
U : l1.0.kt -> l1.kt
added file: l1.kt
STEP 1:
modifications:
U : l1.1.kt -> l1.kt
modified ir: l1.kt
STEP 2:
modifications:
U : l1.2.kt -> l1.kt
modified ir: l1.kt
STEP 3..4:
STEP 5:
modifications:
U : l1.5.kt -> l1.kt
modified ir: l1.kt
STEP 6:
updated exports: l1.kt
STEP 7:
@@ -0,0 +1,2 @@
open class Bar : Foo {
}
@@ -0,0 +1,3 @@
open class Bar : Foo {
override fun getSomething() = 3
}
@@ -0,0 +1,3 @@
interface Bar : Foo {
override fun getSomething() = 4
}
@@ -0,0 +1,3 @@
open class Bar : Foo() {
override fun getSomething() = 6
}
@@ -0,0 +1,2 @@
open class Bar : Foo() {
}
@@ -0,0 +1,34 @@
STEP 0:
dependencies: lib1
modifications:
U : l2.0.kt -> l2.kt
added file: l2.kt
STEP 1..2:
dependencies: lib1
rebuild klib: false
updated imports: l2.kt
STEP 3:
dependencies: lib1
modifications:
U : l2.3.kt -> l2.kt
modified ir: l2.kt
STEP 4:
dependencies: lib1
modifications:
U : l2.4.kt -> l2.kt
modified ir: l2.kt
STEP 5:
dependencies: lib1
rebuild klib: false
updated exports: l2.kt
updated imports: l2.kt
STEP 6:
dependencies: lib1
modifications:
U : l2.6.kt -> l2.kt
modified ir: l2.kt
STEP 7:
dependencies: lib1
modifications:
U : l2.7.kt -> l2.kt
modified ir: l2.kt
@@ -0,0 +1,2 @@
class Klass: Bar() {
}
@@ -0,0 +1,2 @@
class Klass: Bar {
}
@@ -0,0 +1,3 @@
class Klass: Bar() {
override fun getSomething() = super.getSomething()
}
@@ -0,0 +1,5 @@
fun box(stepId: Int): String {
val x = test()
if (stepId != x) return "Fail; got $x"
return "OK"
}
@@ -0,0 +1,35 @@
STEP 0:
dependencies: lib1, lib2
modifications:
U : klass.0.kt -> klass.kt
U : test.0.kt -> test.kt
added file: m.kt, test.kt, klass.kt
STEP 1..2:
dependencies: lib1, lib2
rebuild klib: false
updated imports: test.kt, klass.kt
STEP 3:
dependencies: lib1, lib2
rebuild klib: false
STEP 4:
dependencies: lib1, lib2
modifications:
U : klass.4.kt -> klass.kt
U : test.4.kt -> test.kt
modified ir: klass.kt, test.kt
STEP 5:
dependencies: lib1, lib2
rebuild klib: false
updated exports: klass.kt
updated imports: test.kt, klass.kt
STEP 6:
dependencies: lib1, lib2
modifications:
U : klass.6.kt -> klass.kt
modified ir: klass.kt
updated exports: klass.kt
updated imports: test.kt
STEP 7:
dependencies: lib1, lib2
rebuild klib: false
updated imports: klass.kt
@@ -0,0 +1,7 @@
fun test(): Int {
try {
return Klass().getSomething()
} catch (e: Error) {
return 1
}
}
@@ -0,0 +1,7 @@
fun test(): Int {
try {
return Klass().getSomething()
} catch (e: Error) {
return 5
}
}
@@ -0,0 +1,17 @@
MODULES: lib1, lib2, main
STEP 0..2:
libs: lib1, lib2, main
dirty js: lib1, lib2, main
STEP 3:
libs: lib1, lib2, main
dirty js: lib1, lib2
STEP 4:
libs: lib1, lib2, main
dirty js: lib2, main
STEP 5..6:
libs: lib1, lib2, main
dirty js: lib1, lib2, main
STEP 7:
libs: lib1, lib2, main
dirty js: lib2, main
@@ -0,0 +1 @@
fun foo() = 0
@@ -0,0 +1 @@
fun bar() = 2
@@ -0,0 +1 @@
fun foo() = 2
@@ -0,0 +1,14 @@
STEP 0:
modifications:
U : l1.0.kt -> l1.kt
added file: l1.kt
STEP 1:
modifications:
U : l1.1.kt -> l1.kt
modified ir: l1.kt
updated exports: l1.kt
STEP 2:
modifications:
U : l1.2.kt -> l1.kt
modified ir: l1.kt
updated exports: l1.kt
@@ -0,0 +1,5 @@
fun box(stepId: Int): String {
val x = test()
if (stepId != x) return "Fail; got $x"
return "OK"
}
@@ -0,0 +1,8 @@
STEP 0:
dependencies: lib1
modifications:
added file: m.kt, test.kt
STEP 1..2:
dependencies: lib1
rebuild klib: false
updated imports: test.kt
@@ -0,0 +1,7 @@
fun test(): Int {
try {
return foo().toInt()
} catch (e: Error) {
return 1
}
}
@@ -0,0 +1,5 @@
MODULES: lib1, main
STEP 0..2:
libs: lib1, main
dirty js: lib1, main
@@ -0,0 +1,3 @@
fun foo() {
fooX = 0
}
@@ -0,0 +1,3 @@
fun bar() {
fooX = 1
}
@@ -0,0 +1,3 @@
fun foo() {
fooX = 2
}
@@ -0,0 +1 @@
inline fun baz() = 10
@@ -0,0 +1 @@
inline fun baz() = 11
@@ -0,0 +1 @@
var fooX = -100
@@ -0,0 +1,19 @@
STEP 0:
modifications:
U : l1a.0.kt -> l1a.kt
U : l1b.0.kt -> l1b.kt
added file: l1a.kt, l1b.kt, l1c.kt
STEP 1:
modifications:
U : l1a.1.kt -> l1a.kt
modified ir: l1a.kt
updated exports: l1a.kt, l1c.kt
STEP 2:
modifications:
U : l1a.2.kt -> l1a.kt
modified ir: l1a.kt
updated exports: l1a.kt, l1c.kt
STEP 3:
modifications:
U : l1b.3.kt -> l1b.kt
modified ir: l1b.kt
@@ -0,0 +1,5 @@
fun box(stepId: Int): String {
val x = test()
if (stepId != x) return "Fail; got $x"
return "OK"
}
@@ -0,0 +1,8 @@
STEP 0:
dependencies: lib1
modifications:
added file: m.kt, test.kt
STEP 1..3:
dependencies: lib1
rebuild klib: false
updated imports: test.kt
@@ -0,0 +1,13 @@
internal fun doTest() : Int {
foo()
val y = baz()
return y + fooX - 10
}
fun test(): Int {
try {
return doTest()
} catch (e: Error) {
return 1
}
}
@@ -0,0 +1,5 @@
MODULES: lib1, main
STEP 0..3:
libs: lib1, main
dirty js: lib1, main
@@ -0,0 +1,3 @@
class Klass {
inline fun foo() = 0
}
@@ -0,0 +1,3 @@
class Klass {
inline fun foo() = 3
}
@@ -0,0 +1,3 @@
class Klass {
inline fun foo() = 4
}
@@ -0,0 +1 @@
fun makeKlass() = Klass()
@@ -0,0 +1 @@
fun makeKlassOther() = Klass()
@@ -0,0 +1 @@
fun makeKlass() = Klass()
@@ -0,0 +1,23 @@
STEP 0:
modifications:
U : klass.0.kt -> klass.kt
U : l1a.0.kt -> l1a.kt
added file: l1a.kt, klass.kt
STEP 1:
modifications:
U : l1a.1.kt -> l1a.kt
modified ir: l1a.kt
updated exports: l1a.kt, klass.kt
STEP 2:
modifications:
U : klass.2.kt -> klass.kt
modified ir: klass.kt
STEP 3:
modifications:
U : l1a.3.kt -> l1a.kt
modified ir: l1a.kt
updated exports: l1a.kt, klass.kt
STEP 4:
modifications:
U : klass.4.kt -> klass.kt
modified ir: klass.kt
@@ -0,0 +1,11 @@
fun box(stepId: Int): String {
val x = test()
val expected = when (stepId) {
0, 1, 3, 4 -> stepId
2 -> 1
else -> return "Unknown"
}
if (expected != x) return "Fail; $expected != $x"
return "OK"
}
@@ -0,0 +1,8 @@
STEP 0:
dependencies: lib1
modifications:
added file: m.kt, test.kt
STEP 1..4:
dependencies: lib1
rebuild klib: false
updated imports: test.kt
@@ -0,0 +1,7 @@
fun test(): Int {
try {
return makeKlass().foo()
} catch (e: Error) {
return 1
}
}
@@ -0,0 +1,5 @@
MODULES: lib1, main
STEP 0..4:
libs: lib1, main
dirty js: lib1, main
@@ -0,0 +1 @@
inline fun foo(): Int? = null
@@ -0,0 +1 @@
inline fun foo77(): Int? = 77
@@ -0,0 +1 @@
inline fun foo(): Int? = 3
@@ -0,0 +1 @@
inline fun foo(): Int? = null
@@ -0,0 +1 @@
inline fun bar() = 0
@@ -0,0 +1 @@
inline fun bar() = 4
@@ -0,0 +1,23 @@
STEP 0:
modifications:
U : l1a.0.kt -> l1a.kt
U : l1b.0.kt -> l1b.kt
added file: l1a.kt, l1b.kt
STEP 1:
modifications:
U : l1a.1.kt -> l1a.kt
modified ir: l1a.kt
updated exports: l1a.kt
STEP 2:
modifications:
U : l1b.2.kt -> l1b.kt
modified ir: l1b.kt
STEP 3:
modifications:
U : l1a.3.kt -> l1a.kt
modified ir: l1a.kt
updated exports: l1a.kt
STEP 4:
modifications:
U : l1a.4.kt -> l1a.kt
modified ir: l1a.kt
@@ -0,0 +1,11 @@
fun box(stepId: Int): String {
val x = test()
val expected = when (stepId) {
0, 1, 3, 4 -> stepId
2 -> 1
else -> return "Unknown"
}
if (expected != x) return "Fail; $expected != $x"
return "OK"
}
@@ -0,0 +1,8 @@
STEP 0:
dependencies: lib1
modifications:
added file: m.kt, test.kt
STEP 1..4:
dependencies: lib1
rebuild klib: false
updated imports: test.kt
@@ -0,0 +1,7 @@
fun test(): Int {
try {
return foo() ?: bar()
} catch (e: Error) {
return 1
}
}
@@ -0,0 +1,5 @@
MODULES: lib1, main
STEP 0..4:
libs: lib1, main
dirty js: lib1, main
@@ -0,0 +1 @@
fun foo() = 0
@@ -0,0 +1 @@
fun bar() = 77
@@ -0,0 +1 @@
fun foo() = 2
@@ -0,0 +1,14 @@
STEP 0:
modifications:
U : l1.0.kt -> l1.kt
added file: l1.kt
STEP 1:
modifications:
U : l1.1.kt -> l1.kt
modified ir: l1.kt
updated exports: l1.kt
STEP 2:
modifications:
U : l1.2.kt -> l1.kt
modified ir: l1.kt
updated exports: l1.kt
@@ -0,0 +1 @@
inline fun inlineFun() = foo()
@@ -0,0 +1,7 @@
STEP 0:
dependencies: lib1
added file: l2.kt
STEP 1..2:
dependencies: lib1
rebuild klib: false
updated imports: l2.kt
@@ -0,0 +1,5 @@
fun box(stepId: Int): String {
val x = test()
if (x != stepId) return "Fail; got $x"
return "OK"
}
@@ -0,0 +1,7 @@
STEP 0:
dependencies: lib1, lib2
added file: m.kt, test.kt
STEP 1..2:
dependencies: lib1, lib2
rebuild klib: false
updated imports: test.kt
@@ -0,0 +1,7 @@
fun test(): Int {
try {
return inlineFun()
} catch (e: Error) {
return 1
}
}
@@ -0,0 +1,5 @@
MODULES: lib1, lib2, main
STEP 0..2:
libs: lib1, lib2, main
dirty js: lib1, lib2, main
@@ -0,0 +1 @@
inline fun foo() = -1
@@ -0,0 +1 @@
inline fun foo() = 1
@@ -0,0 +1 @@
inline fun inlineFoo(f: () -> Int) = f() + 1
@@ -0,0 +1 @@
inline fun inlineBar(f: () -> Int) = f() + 1
@@ -0,0 +1 @@
inline fun inlineFoo(f: () -> Int) = f() + 2
@@ -0,0 +1 @@
inline fun inlineFoo(f: () -> Int) = f() + 3
@@ -0,0 +1,23 @@
STEP 0:
modifications:
U : l1a.0.kt -> l1a.kt
U : l1b.0.kt -> l1b.kt
added file: l1a.kt, l1b.kt
STEP 1:
modifications:
U : l1b.1.kt -> l1b.kt
modified ir: l1b.kt
updated exports: l1b.kt
STEP 2:
modifications:
U : l1a.2.kt -> l1a.kt
modified ir: l1a.kt
STEP 3:
modifications:
U : l1b.3.kt -> l1b.kt
modified ir: l1b.kt
updated exports: l1b.kt
STEP 4:
modifications:
U : l1b.4.kt -> l1b.kt
modified ir: l1b.kt
@@ -0,0 +1,11 @@
fun box(stepId: Int): String {
val x = test()
val expected = when (stepId) {
0, 1, 3, 4 -> stepId
2 -> 1
else -> return "Unknown"
}
if (expected != x) return "Fail; $expected != $x"
return "OK"
}
@@ -0,0 +1,8 @@
STEP 0:
dependencies: lib1
modifications:
added file: m.kt, test.kt
STEP 1..4:
dependencies: lib1
rebuild klib: false
updated imports: test.kt
@@ -0,0 +1,7 @@
fun test(): Int {
try {
return inlineFoo { foo() }
} catch (e: Error) {
return 1
}
}
@@ -0,0 +1,5 @@
MODULES: lib1, main
STEP 0..4:
libs: lib1, main
dirty js: lib1, main