[JS IR] Add serialization regressions tests
This commit is contained in:
@@ -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.
|
||||
+20
@@ -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
|
||||
}
|
||||
+25
@@ -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
|
||||
+65
@@ -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"
|
||||
}
|
||||
+33
@@ -14483,6 +14483,39 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
runTest("compiler/testData/codegen/box/ir/primitiveNumberComparisons/mixedNumberTypes.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/box/ir/serializationRegressions")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class SerializationRegressions extends AbstractBlackBoxCodegenTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInSerializationRegressions() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/ir/serializationRegressions"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true);
|
||||
}
|
||||
|
||||
@TestMetadata("dispatchReceiverValue.kt")
|
||||
public void testDispatchReceiverValue() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/ir/serializationRegressions/dispatchReceiverValue.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("genericProperty.kt")
|
||||
public void testGenericProperty() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/ir/serializationRegressions/genericProperty.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("innerClassInEnumEntryClass.kt")
|
||||
public void testInnerClassInEnumEntryClass() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/ir/serializationRegressions/innerClassInEnumEntryClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("useImportedMember.kt")
|
||||
public void testUseImportedMember() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/ir/serializationRegressions/useImportedMember.kt");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/box/javaInterop")
|
||||
|
||||
+33
@@ -14483,6 +14483,39 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
runTest("compiler/testData/codegen/box/ir/primitiveNumberComparisons/mixedNumberTypes.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/box/ir/serializationRegressions")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class SerializationRegressions extends AbstractLightAnalysisModeTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInSerializationRegressions() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/ir/serializationRegressions"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true);
|
||||
}
|
||||
|
||||
@TestMetadata("dispatchReceiverValue.kt")
|
||||
public void testDispatchReceiverValue() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/ir/serializationRegressions/dispatchReceiverValue.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("genericProperty.kt")
|
||||
public void testGenericProperty() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/ir/serializationRegressions/genericProperty.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("innerClassInEnumEntryClass.kt")
|
||||
public void testInnerClassInEnumEntryClass() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/ir/serializationRegressions/innerClassInEnumEntryClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("useImportedMember.kt")
|
||||
public void testUseImportedMember() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/ir/serializationRegressions/useImportedMember.kt");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/box/javaInterop")
|
||||
|
||||
+33
@@ -13333,6 +13333,39 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
||||
runTest("compiler/testData/codegen/box/ir/primitiveNumberComparisons/mixedNumberTypes.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/box/ir/serializationRegressions")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class SerializationRegressions extends AbstractFirBlackBoxCodegenTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTestWithCustomIgnoreDirective(this::doTest, TargetBackend.JVM_IR, testDataFilePath, "// IGNORE_BACKEND_FIR: ");
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInSerializationRegressions() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/ir/serializationRegressions"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
|
||||
}
|
||||
|
||||
@TestMetadata("dispatchReceiverValue.kt")
|
||||
public void testDispatchReceiverValue() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/ir/serializationRegressions/dispatchReceiverValue.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("genericProperty.kt")
|
||||
public void testGenericProperty() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/ir/serializationRegressions/genericProperty.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("innerClassInEnumEntryClass.kt")
|
||||
public void testInnerClassInEnumEntryClass() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/ir/serializationRegressions/innerClassInEnumEntryClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("useImportedMember.kt")
|
||||
public void testUseImportedMember() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/ir/serializationRegressions/useImportedMember.kt");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/box/javaInterop")
|
||||
|
||||
+33
@@ -13333,6 +13333,39 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
||||
runTest("compiler/testData/codegen/box/ir/primitiveNumberComparisons/mixedNumberTypes.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/box/ir/serializationRegressions")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class SerializationRegressions extends AbstractIrBlackBoxCodegenTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInSerializationRegressions() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/ir/serializationRegressions"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
|
||||
}
|
||||
|
||||
@TestMetadata("dispatchReceiverValue.kt")
|
||||
public void testDispatchReceiverValue() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/ir/serializationRegressions/dispatchReceiverValue.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("genericProperty.kt")
|
||||
public void testGenericProperty() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/ir/serializationRegressions/genericProperty.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("innerClassInEnumEntryClass.kt")
|
||||
public void testInnerClassInEnumEntryClass() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/ir/serializationRegressions/innerClassInEnumEntryClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("useImportedMember.kt")
|
||||
public void testUseImportedMember() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/ir/serializationRegressions/useImportedMember.kt");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/box/javaInterop")
|
||||
|
||||
Generated
+33
@@ -11593,6 +11593,39 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
|
||||
runTest("compiler/testData/codegen/box/ir/primitiveNumberComparisons/mixedNumberTypes.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/box/ir/serializationRegressions")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class SerializationRegressions extends AbstractIrJsCodegenBoxTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInSerializationRegressions() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/ir/serializationRegressions"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true);
|
||||
}
|
||||
|
||||
@TestMetadata("dispatchReceiverValue.kt")
|
||||
public void testDispatchReceiverValue() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/ir/serializationRegressions/dispatchReceiverValue.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("genericProperty.kt")
|
||||
public void testGenericProperty() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/ir/serializationRegressions/genericProperty.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("innerClassInEnumEntryClass.kt")
|
||||
public void testInnerClassInEnumEntryClass() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/ir/serializationRegressions/innerClassInEnumEntryClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("useImportedMember.kt")
|
||||
public void testUseImportedMember() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/ir/serializationRegressions/useImportedMember.kt");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/box/javaInterop")
|
||||
|
||||
+33
@@ -12733,6 +12733,39 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
||||
runTest("compiler/testData/codegen/box/ir/primitiveNumberComparisons/mixedNumberTypes.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/box/ir/serializationRegressions")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class SerializationRegressions extends AbstractJsCodegenBoxTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInSerializationRegressions() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/ir/serializationRegressions"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS, true);
|
||||
}
|
||||
|
||||
@TestMetadata("dispatchReceiverValue.kt")
|
||||
public void testDispatchReceiverValue() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/ir/serializationRegressions/dispatchReceiverValue.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("genericProperty.kt")
|
||||
public void testGenericProperty() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/ir/serializationRegressions/genericProperty.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("innerClassInEnumEntryClass.kt")
|
||||
public void testInnerClassInEnumEntryClass() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/ir/serializationRegressions/innerClassInEnumEntryClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("useImportedMember.kt")
|
||||
public void testUseImportedMember() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/ir/serializationRegressions/useImportedMember.kt");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/box/javaInterop")
|
||||
|
||||
Reference in New Issue
Block a user