[JS IR] Add serialization regressions tests

This commit is contained in:
Svyatoslav Kuzmich
2020-01-10 14:46:57 +03:00
parent fbf71be30c
commit 1333267983
11 changed files with 340 additions and 0 deletions
@@ -0,0 +1,3 @@
Directory contains copies of codegen box tests that used to fail during IR serialization or deserialization.
They are splitted into multiple modules to force serialization and deserializations in applicable backend.
@@ -0,0 +1,20 @@
// !LANGUAGE: +MultiPlatformProjects
// IGNORE_BACKEND: JS_IR
// IGNORE_BACKEND_FIR: JVM_IR
// MODULE: lib
// FILE: common.kt
expect class C {
val value: String
fun test(result: String = value): String
}
// FILE: platform.kt
actual class C(actual val value: String) {
actual fun test(result: String): String = result
}
// MODULE: main(lib)
// FILE: main.kt
fun box() = C("Fail").test("OK")
@@ -0,0 +1,29 @@
// IGNORE_BACKEND_FIR: JVM_IR
// IGNORE_BACKEND: NATIVE
// IGNORE_BACKEND: JS_IR
//For KT-6020
// MODULE: lib
// FILE: lib.kt
import kotlin.reflect.KProperty1
import kotlin.reflect.KMutableProperty1
import kotlin.reflect.KProperty
class Value<T>(var value: T = null as T, var text: String? = null)
val <T> Value<T>.additionalText by DVal(Value<T>::text) //works
val <T> Value<T>.additionalValue by DVal(Value<T>::value) //not work
class DVal<T, R, P: KProperty1<T, R>>(val kmember: P) {
operator fun getValue(t: T, p: KProperty<*>): R {
return kmember.get(t)
}
}
// MODULE: main(lib)
// FILE: main.kt
fun box(): String {
val p = Value("O", "K")
return p.additionalValue + p.additionalText
}
@@ -0,0 +1,25 @@
// IGNORE_BACKEND_FIR: JVM_IR
// IGNORE_BACKEND: JS_IR
// MODULE: lib
// FILE: lib.kt
enum class A {
X {
val x = "OK"
inner class Inner {
val y = x
}
val z = Inner()
override val test: String
get() = z.y
};
abstract val test: String
}
// MODULE: main(lib)
// FILE: main.kt
fun box() = A.X.test
@@ -0,0 +1,65 @@
// IGNORE_BACKEND: JS_IR
// IGNORE_BACKEND_FIR: JVM_IR
// MODULE: lib
// FILE: lib.kt
import C.f
import C.p
import C.ext
import C.g1
import C.g2
import C.fromClass
import C.fromInterface
import C.genericFromSuper
interface I<G> {
fun <T> T.fromInterface(): T = this
fun genericFromSuper(g: G) = g
}
open class BaseClass {
val <T> T.fromClass: T
get() = this
}
object C: BaseClass(), I<String> {
fun f(s: Int) = 1
fun f(s: String) = 2
fun Boolean.f() = 3
var p: Int = 4
val Int.ext: Int
get() = 6
fun <T> g1(t: T): T = t
val <T> T.g2: T
get() = this
}
// MODULE: main(lib)
// FILE: main.kt
import C.f
import C.p
import C.ext
import C.g1
import C.g2
import C.fromClass
import C.fromInterface
import C.genericFromSuper
fun box(): String {
if (f(1) != 1) return "1"
if (f("s") != 2) return "2"
if (true.f() != 3) return "3"
if (p != 4) return "4"
p = 5
if (p != 5) return "5"
if (5.ext != 6) return "6"
if (g1("7") != "7") return "7"
if ("8".g2 != "8") return "8"
if (9.fromInterface() != 9) return "9"
if ("10".fromClass != "10") return "10"
if (genericFromSuper("11") != "11") return "11"
return "OK"
}