K2 Scripting: restore some codegen scripting tests for K2

This commit is contained in:
Ilya Chernikov
2023-12-21 17:34:32 +01:00
committed by Space Team
parent a83d2b7a67
commit 3b70b3d92d
17 changed files with 248 additions and 4 deletions
@@ -51628,6 +51628,12 @@ public class LLFirBlackBoxCodegenBasedTestGenerated extends AbstractLLFirBlackBo
runTest("compiler/testData/codegen/box/script/localCaptureTests.kt");
}
@Test
@TestMetadata("localCaptureTestsK2.kt")
public void testLocalCaptureTestsK2() throws Exception {
runTest("compiler/testData/codegen/box/script/localCaptureTestsK2.kt");
}
@Test
@TestMetadata("scripInstance.kt")
public void testScripInstance() throws Exception {
@@ -51639,6 +51645,18 @@ public class LLFirBlackBoxCodegenBasedTestGenerated extends AbstractLLFirBlackBo
public void testScriptNestedClassInstance() throws Exception {
runTest("compiler/testData/codegen/box/script/scriptNestedClassInstance.kt");
}
@Test
@TestMetadata("scriptNestedClassInstanceK2.kt")
public void testScriptNestedClassInstanceK2() throws Exception {
runTest("compiler/testData/codegen/box/script/scriptNestedClassInstanceK2.kt");
}
@Test
@TestMetadata("scriptPropFromAnotherModuleK2.kt")
public void testScriptPropFromAnotherModuleK2() throws Exception {
runTest("compiler/testData/codegen/box/script/scriptPropFromAnotherModuleK2.kt");
}
}
@Nested
@@ -51628,6 +51628,12 @@ public class LLFirReversedBlackBoxCodegenBasedTestGenerated extends AbstractLLFi
runTest("compiler/testData/codegen/box/script/localCaptureTests.kt");
}
@Test
@TestMetadata("localCaptureTestsK2.kt")
public void testLocalCaptureTestsK2() throws Exception {
runTest("compiler/testData/codegen/box/script/localCaptureTestsK2.kt");
}
@Test
@TestMetadata("scripInstance.kt")
public void testScripInstance() throws Exception {
@@ -51639,6 +51645,18 @@ public class LLFirReversedBlackBoxCodegenBasedTestGenerated extends AbstractLLFi
public void testScriptNestedClassInstance() throws Exception {
runTest("compiler/testData/codegen/box/script/scriptNestedClassInstance.kt");
}
@Test
@TestMetadata("scriptNestedClassInstanceK2.kt")
public void testScriptNestedClassInstanceK2() throws Exception {
runTest("compiler/testData/codegen/box/script/scriptNestedClassInstanceK2.kt");
}
@Test
@TestMetadata("scriptPropFromAnotherModuleK2.kt")
public void testScriptPropFromAnotherModuleK2() throws Exception {
runTest("compiler/testData/codegen/box/script/scriptPropFromAnotherModuleK2.kt");
}
}
@Nested
@@ -51133,6 +51133,12 @@ public class FirLightTreeBlackBoxCodegenTestGenerated extends AbstractFirLightTr
runTest("compiler/testData/codegen/box/script/localCaptureTests.kt");
}
@Test
@TestMetadata("localCaptureTestsK2.kt")
public void testLocalCaptureTestsK2() throws Exception {
runTest("compiler/testData/codegen/box/script/localCaptureTestsK2.kt");
}
@Test
@TestMetadata("scripInstance.kt")
public void testScripInstance() throws Exception {
@@ -51144,6 +51150,18 @@ public class FirLightTreeBlackBoxCodegenTestGenerated extends AbstractFirLightTr
public void testScriptNestedClassInstance() throws Exception {
runTest("compiler/testData/codegen/box/script/scriptNestedClassInstance.kt");
}
@Test
@TestMetadata("scriptNestedClassInstanceK2.kt")
public void testScriptNestedClassInstanceK2() throws Exception {
runTest("compiler/testData/codegen/box/script/scriptNestedClassInstanceK2.kt");
}
@Test
@TestMetadata("scriptPropFromAnotherModuleK2.kt")
public void testScriptPropFromAnotherModuleK2() throws Exception {
runTest("compiler/testData/codegen/box/script/scriptPropFromAnotherModuleK2.kt");
}
}
@Nested
@@ -51133,6 +51133,12 @@ public class FirLightTreeBlackBoxCodegenWithIrFakeOverrideGeneratorTestGenerated
runTest("compiler/testData/codegen/box/script/localCaptureTests.kt");
}
@Test
@TestMetadata("localCaptureTestsK2.kt")
public void testLocalCaptureTestsK2() throws Exception {
runTest("compiler/testData/codegen/box/script/localCaptureTestsK2.kt");
}
@Test
@TestMetadata("scripInstance.kt")
public void testScripInstance() throws Exception {
@@ -51144,6 +51150,18 @@ public class FirLightTreeBlackBoxCodegenWithIrFakeOverrideGeneratorTestGenerated
public void testScriptNestedClassInstance() throws Exception {
runTest("compiler/testData/codegen/box/script/scriptNestedClassInstance.kt");
}
@Test
@TestMetadata("scriptNestedClassInstanceK2.kt")
public void testScriptNestedClassInstanceK2() throws Exception {
runTest("compiler/testData/codegen/box/script/scriptNestedClassInstanceK2.kt");
}
@Test
@TestMetadata("scriptPropFromAnotherModuleK2.kt")
public void testScriptPropFromAnotherModuleK2() throws Exception {
runTest("compiler/testData/codegen/box/script/scriptPropFromAnotherModuleK2.kt");
}
}
@Nested
@@ -51133,6 +51133,12 @@ public class FirPsiBlackBoxCodegenTestGenerated extends AbstractFirPsiBlackBoxCo
runTest("compiler/testData/codegen/box/script/localCaptureTests.kt");
}
@Test
@TestMetadata("localCaptureTestsK2.kt")
public void testLocalCaptureTestsK2() throws Exception {
runTest("compiler/testData/codegen/box/script/localCaptureTestsK2.kt");
}
@Test
@TestMetadata("scripInstance.kt")
public void testScripInstance() throws Exception {
@@ -51144,6 +51150,18 @@ public class FirPsiBlackBoxCodegenTestGenerated extends AbstractFirPsiBlackBoxCo
public void testScriptNestedClassInstance() throws Exception {
runTest("compiler/testData/codegen/box/script/scriptNestedClassInstance.kt");
}
@Test
@TestMetadata("scriptNestedClassInstanceK2.kt")
public void testScriptNestedClassInstanceK2() throws Exception {
runTest("compiler/testData/codegen/box/script/scriptNestedClassInstanceK2.kt");
}
@Test
@TestMetadata("scriptPropFromAnotherModuleK2.kt")
public void testScriptPropFromAnotherModuleK2() throws Exception {
runTest("compiler/testData/codegen/box/script/scriptPropFromAnotherModuleK2.kt");
}
}
@Nested
+1 -1
View File
@@ -1,6 +1,6 @@
// TARGET_BACKEND: JVM
// IGNORE_BACKEND_K2: JVM_IR, JS_IR, JS_IR_ES6
// FIR status: scripts aren't supported yet
// FIR status: script declarations are not visible from other sources
// IGNORE_LIGHT_ANALYSIS
// WITH_STDLIB
// FILE: test.kt
+1 -1
View File
@@ -1,6 +1,6 @@
// TARGET_BACKEND: JVM
// IGNORE_BACKEND_K2: JVM_IR, JS_IR, JS_IR_ES6
// FIR status: scripts aren't supported yet
// FIR status: script declarations are not visible from other sources
// IGNORE_LIGHT_ANALYSIS
// WITH_STDLIB
// FILE: test.kt
@@ -0,0 +1,31 @@
// TARGET_BACKEND: JVM
// IGNORE_BACKEND_K1: JVM, JVM_IR, JS_IR, JS_IR_ES6
// IGNORE_LIGHT_ANALYSIS
// WITH_STDLIB
// FILE: test.kt
fun box(): String =
Build.Debug.run { "${c0()}${c1()}" }
// FILE: script.kts
interface Base {
val v: String
fun c0(): Char {
fun getC0() = v[0]
return getC0()
}
}
enum class Build(override val v: String): Base {
Debug("OK"),
Release("NO");
fun c1(): Char {
val g = object {
val c1 = v[1]
}
return g.c1
}
}
+1 -1
View File
@@ -1,6 +1,6 @@
// TARGET_BACKEND: JVM
// IGNORE_BACKEND_K2: JVM_IR, JS_IR, JS_IR_ES6
// FIR status: scripts aren't supported yet
// FIR status: script declarations are not visible from other sources
// IGNORE_LIGHT_ANALYSIS
// WITH_STDLIB
// FILE: test.kt
@@ -1,6 +1,6 @@
// TARGET_BACKEND: JVM
// IGNORE_BACKEND_K2: JVM_IR, JS_IR, JS_IR_ES6
// FIR status: scripts aren't supported yet
// FIR status: script declarations are not visible from other sources
// IGNORE_LIGHT_ANALYSIS
// WITH_STDLIB
// FILE: test.kt
@@ -0,0 +1,14 @@
// TARGET_BACKEND: JVM
// IGNORE_BACKEND_K1: JVM, JVM_IR, JS_IR, JS_IR_ES6
// IGNORE_LIGHT_ANALYSIS
// WITH_STDLIB
// FILE: test.kt
fun box(): String =
Nested().x
// FILE: script.kts
class Nested {
val x = "OK"
}
@@ -0,0 +1,28 @@
// TARGET_BACKEND: JVM_IR
// IGNORE_BACKEND_K1: JS_IR, JS_IR_ES6
// IGNORE_LIGHT_ANALYSIS
// !LANGUAGE: -SkipStandaloneScriptsInSourceRoots
// WITH_STDLIB
// Although this test works in K1 just fine, it is named with the suffix K2 to show that the demonstrated method is the only one
// available so far to call a script from another module.
// In K1 one can do it directly, but this is not the functionality we want to retain
// MODULE: lib
// FILE: script.kts
fun ok() = "OK"
// MODULE: main(lib)
// FILE: test.kt
fun runScriptMethod(name: String, method: String): Any {
val klass = Thread.currentThread().contextClassLoader.loadClass(name)
val constructor = klass.constructors.single()
val instance = constructor.newInstance(emptyArray<String>())
val method = klass.getMethod(method)
return method.invoke(instance)
}
fun box(): String =
runScriptMethod("Script", "ok") as String
@@ -50449,6 +50449,12 @@ public class JvmAbiConsistencyTestBoxGenerated extends AbstractJvmAbiConsistency
runTest("compiler/testData/codegen/box/script/localCaptureTests.kt");
}
@Test
@TestMetadata("localCaptureTestsK2.kt")
public void testLocalCaptureTestsK2() throws Exception {
runTest("compiler/testData/codegen/box/script/localCaptureTestsK2.kt");
}
@Test
@TestMetadata("scripInstance.kt")
public void testScripInstance() throws Exception {
@@ -50460,6 +50466,18 @@ public class JvmAbiConsistencyTestBoxGenerated extends AbstractJvmAbiConsistency
public void testScriptNestedClassInstance() throws Exception {
runTest("compiler/testData/codegen/box/script/scriptNestedClassInstance.kt");
}
@Test
@TestMetadata("scriptNestedClassInstanceK2.kt")
public void testScriptNestedClassInstanceK2() throws Exception {
runTest("compiler/testData/codegen/box/script/scriptNestedClassInstanceK2.kt");
}
@Test
@TestMetadata("scriptPropFromAnotherModuleK2.kt")
public void testScriptPropFromAnotherModuleK2() throws Exception {
runTest("compiler/testData/codegen/box/script/scriptPropFromAnotherModuleK2.kt");
}
}
@Nested
@@ -47479,6 +47479,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
runTest("compiler/testData/codegen/box/script/localCaptureTests.kt");
}
@Test
@TestMetadata("localCaptureTestsK2.kt")
public void testLocalCaptureTestsK2() throws Exception {
runTest("compiler/testData/codegen/box/script/localCaptureTestsK2.kt");
}
@Test
@TestMetadata("scripInstance.kt")
public void testScripInstance() throws Exception {
@@ -47490,6 +47496,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
public void testScriptNestedClassInstance() throws Exception {
runTest("compiler/testData/codegen/box/script/scriptNestedClassInstance.kt");
}
@Test
@TestMetadata("scriptNestedClassInstanceK2.kt")
public void testScriptNestedClassInstanceK2() throws Exception {
runTest("compiler/testData/codegen/box/script/scriptNestedClassInstanceK2.kt");
}
}
@Nested
@@ -50449,6 +50449,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
runTest("compiler/testData/codegen/box/script/localCaptureTests.kt");
}
@Test
@TestMetadata("localCaptureTestsK2.kt")
public void testLocalCaptureTestsK2() throws Exception {
runTest("compiler/testData/codegen/box/script/localCaptureTestsK2.kt");
}
@Test
@TestMetadata("scripInstance.kt")
public void testScripInstance() throws Exception {
@@ -50460,6 +50466,18 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
public void testScriptNestedClassInstance() throws Exception {
runTest("compiler/testData/codegen/box/script/scriptNestedClassInstance.kt");
}
@Test
@TestMetadata("scriptNestedClassInstanceK2.kt")
public void testScriptNestedClassInstanceK2() throws Exception {
runTest("compiler/testData/codegen/box/script/scriptNestedClassInstanceK2.kt");
}
@Test
@TestMetadata("scriptPropFromAnotherModuleK2.kt")
public void testScriptPropFromAnotherModuleK2() throws Exception {
runTest("compiler/testData/codegen/box/script/scriptPropFromAnotherModuleK2.kt");
}
}
@Nested
@@ -50449,6 +50449,12 @@ public class IrBlackBoxCodegenWithIrInlinerTestGenerated extends AbstractIrBlack
runTest("compiler/testData/codegen/box/script/localCaptureTests.kt");
}
@Test
@TestMetadata("localCaptureTestsK2.kt")
public void testLocalCaptureTestsK2() throws Exception {
runTest("compiler/testData/codegen/box/script/localCaptureTestsK2.kt");
}
@Test
@TestMetadata("scripInstance.kt")
public void testScripInstance() throws Exception {
@@ -50460,6 +50466,18 @@ public class IrBlackBoxCodegenWithIrInlinerTestGenerated extends AbstractIrBlack
public void testScriptNestedClassInstance() throws Exception {
runTest("compiler/testData/codegen/box/script/scriptNestedClassInstance.kt");
}
@Test
@TestMetadata("scriptNestedClassInstanceK2.kt")
public void testScriptNestedClassInstanceK2() throws Exception {
runTest("compiler/testData/codegen/box/script/scriptNestedClassInstanceK2.kt");
}
@Test
@TestMetadata("scriptPropFromAnotherModuleK2.kt")
public void testScriptPropFromAnotherModuleK2() throws Exception {
runTest("compiler/testData/codegen/box/script/scriptPropFromAnotherModuleK2.kt");
}
}
@Nested
@@ -40552,6 +40552,16 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Script extends AbstractLightAnalysisModeTest {
@TestMetadata("localCaptureTestsK2.kt")
public void ignoreLocalCaptureTestsK2() throws Exception {
runTest("compiler/testData/codegen/box/script/localCaptureTestsK2.kt");
}
@TestMetadata("scriptNestedClassInstanceK2.kt")
public void ignoreScriptNestedClassInstanceK2() throws Exception {
runTest("compiler/testData/codegen/box/script/scriptNestedClassInstanceK2.kt");
}
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath);
}
@@ -40579,6 +40589,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
public void testScriptNestedClassInstance() throws Exception {
runTest("compiler/testData/codegen/box/script/scriptNestedClassInstance.kt");
}
@TestMetadata("scriptPropFromAnotherModuleK2.kt")
public void testScriptPropFromAnotherModuleK2() throws Exception {
runTest("compiler/testData/codegen/box/script/scriptPropFromAnotherModuleK2.kt");
}
}
@TestMetadata("compiler/testData/codegen/box/sealed")