Added multi-module test on inline functions
This commit is contained in:
+26
@@ -0,0 +1,26 @@
|
|||||||
|
// IGNORE_BACKEND_FIR: JVM_IR
|
||||||
|
// IGNORE_BACKEND: NATIVE
|
||||||
|
// MODULE: lib
|
||||||
|
// FILE: lib.kt
|
||||||
|
inline fun <T> T.andAlso(block: (T) -> Unit): T {
|
||||||
|
block(this)
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
inline fun <T> tryCatch(block: () -> T, onSuccess: (T) -> Unit) {
|
||||||
|
try {
|
||||||
|
block()
|
||||||
|
} catch (e: Throwable) {
|
||||||
|
return
|
||||||
|
}.andAlso { onSuccess(it) }
|
||||||
|
}
|
||||||
|
|
||||||
|
// MODULE: main(lib)
|
||||||
|
// FILE: main.kt
|
||||||
|
fun box(): String {
|
||||||
|
var result = false
|
||||||
|
tryCatch(block = { true }) {
|
||||||
|
result = it
|
||||||
|
}
|
||||||
|
return if (result) "OK" else "Fail"
|
||||||
|
}
|
||||||
+18
@@ -1972,6 +1972,24 @@ public class BlackBoxInlineCodegenTestGenerated extends AbstractBlackBoxInlineCo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("compiler/testData/codegen/boxInline/multiModule")
|
||||||
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
public static class MultiModule extends AbstractBlackBoxInlineCodegenTest {
|
||||||
|
private void runTest(String testDataFilePath) throws Exception {
|
||||||
|
KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testAllFilesPresentInMultiModule() throws Exception {
|
||||||
|
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/boxInline/multiModule"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("tryCatchWithRecursiveInline.kt")
|
||||||
|
public void testTryCatchWithRecursiveInline() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/boxInline/multiModule/tryCatchWithRecursiveInline.kt");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("compiler/testData/codegen/boxInline/multifileClasses")
|
@TestMetadata("compiler/testData/codegen/boxInline/multifileClasses")
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
@RunWith(JUnit3RunnerWithInners.class)
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
|||||||
Generated
+18
@@ -1972,6 +1972,24 @@ public class CompileKotlinAgainstInlineKotlinTestGenerated extends AbstractCompi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("compiler/testData/codegen/boxInline/multiModule")
|
||||||
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
public static class MultiModule extends AbstractCompileKotlinAgainstInlineKotlinTest {
|
||||||
|
private void runTest(String testDataFilePath) throws Exception {
|
||||||
|
KotlinTestUtils.runTestWithCustomIgnoreDirective(this::doTest, TargetBackend.JVM, testDataFilePath, "// IGNORE_BACKEND_MULTI_MODULE: ");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testAllFilesPresentInMultiModule() throws Exception {
|
||||||
|
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/boxInline/multiModule"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("tryCatchWithRecursiveInline.kt")
|
||||||
|
public void testTryCatchWithRecursiveInline() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/boxInline/multiModule/tryCatchWithRecursiveInline.kt");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("compiler/testData/codegen/boxInline/multifileClasses")
|
@TestMetadata("compiler/testData/codegen/boxInline/multifileClasses")
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
@RunWith(JUnit3RunnerWithInners.class)
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
|||||||
+18
@@ -1972,6 +1972,24 @@ public class IrBlackBoxInlineCodegenTestGenerated extends AbstractIrBlackBoxInli
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("compiler/testData/codegen/boxInline/multiModule")
|
||||||
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
public static class MultiModule extends AbstractIrBlackBoxInlineCodegenTest {
|
||||||
|
private void runTest(String testDataFilePath) throws Exception {
|
||||||
|
KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testAllFilesPresentInMultiModule() throws Exception {
|
||||||
|
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/boxInline/multiModule"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("tryCatchWithRecursiveInline.kt")
|
||||||
|
public void testTryCatchWithRecursiveInline() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/boxInline/multiModule/tryCatchWithRecursiveInline.kt");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("compiler/testData/codegen/boxInline/multifileClasses")
|
@TestMetadata("compiler/testData/codegen/boxInline/multifileClasses")
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
@RunWith(JUnit3RunnerWithInners.class)
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
|||||||
Generated
+18
@@ -1972,6 +1972,24 @@ public class IrCompileKotlinAgainstInlineKotlinTestGenerated extends AbstractIrC
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("compiler/testData/codegen/boxInline/multiModule")
|
||||||
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
public static class MultiModule extends AbstractIrCompileKotlinAgainstInlineKotlinTest {
|
||||||
|
private void runTest(String testDataFilePath) throws Exception {
|
||||||
|
KotlinTestUtils.runTestWithCustomIgnoreDirective(this::doTest, TargetBackend.JVM_IR, testDataFilePath, "// IGNORE_BACKEND_MULTI_MODULE: ");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testAllFilesPresentInMultiModule() throws Exception {
|
||||||
|
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/boxInline/multiModule"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("tryCatchWithRecursiveInline.kt")
|
||||||
|
public void testTryCatchWithRecursiveInline() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/boxInline/multiModule/tryCatchWithRecursiveInline.kt");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("compiler/testData/codegen/boxInline/multifileClasses")
|
@TestMetadata("compiler/testData/codegen/boxInline/multifileClasses")
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
@RunWith(JUnit3RunnerWithInners.class)
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
|||||||
@@ -134,5 +134,13 @@ fun main(args: Array<String>) {
|
|||||||
testClass<AbstractJsLegacyPrimitiveArraysBoxTest> {
|
testClass<AbstractJsLegacyPrimitiveArraysBoxTest> {
|
||||||
model("codegen/box/arrays", targetBackend = TargetBackend.JS)
|
model("codegen/box/arrays", targetBackend = TargetBackend.JS)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
testClass<AbstractJsInlineMultiModuleTests> {
|
||||||
|
model("codegen/boxInline/multiModule/", targetBackend = TargetBackend.JS)
|
||||||
|
}
|
||||||
|
|
||||||
|
testClass<AbstractIrJsInlineMultiModuleTests> {
|
||||||
|
model("codegen/boxInline/multiModule/", targetBackend = TargetBackend.JS_IR)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Generated
+36
@@ -0,0 +1,36 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||||
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jetbrains.kotlin.js.test.ir.semantics;
|
||||||
|
|
||||||
|
import com.intellij.testFramework.TestDataPath;
|
||||||
|
import org.jetbrains.kotlin.test.JUnit3RunnerWithInners;
|
||||||
|
import org.jetbrains.kotlin.test.KotlinTestUtils;
|
||||||
|
import org.jetbrains.kotlin.test.TargetBackend;
|
||||||
|
import org.jetbrains.kotlin.test.TestMetadata;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */
|
||||||
|
@SuppressWarnings("all")
|
||||||
|
@TestMetadata("compiler/testData/codegen/boxInline/multiModule")
|
||||||
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
public class IrJsInlineMultiModuleTestsGenerated extends AbstractIrJsInlineMultiModuleTests {
|
||||||
|
private void runTest(String testDataFilePath) throws Exception {
|
||||||
|
KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR, testDataFilePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testAllFilesPresentInMultiModule() throws Exception {
|
||||||
|
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/boxInline/multiModule"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("tryCatchWithRecursiveInline.kt")
|
||||||
|
public void testTryCatchWithRecursiveInline() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/boxInline/multiModule/tryCatchWithRecursiveInline.kt");
|
||||||
|
}
|
||||||
|
}
|
||||||
+3
-1
@@ -43,4 +43,6 @@ abstract class AbstractIrInlineDefaultValuesTests : BorrowedIrInlineTest("defaul
|
|||||||
|
|
||||||
abstract class AbstractIrInlineSuspendTests : BorrowedIrInlineTest("suspend/")
|
abstract class AbstractIrInlineSuspendTests : BorrowedIrInlineTest("suspend/")
|
||||||
|
|
||||||
abstract class AbstractIrJsInlineContractsTests : BorrowedIrInlineTest("contracts/")
|
abstract class AbstractIrJsInlineContractsTests : BorrowedIrInlineTest("contracts/")
|
||||||
|
|
||||||
|
abstract class AbstractIrJsInlineMultiModuleTests : BorrowedIrInlineTest("multiModule/")
|
||||||
Generated
+36
@@ -0,0 +1,36 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||||
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jetbrains.kotlin.js.test.semantics;
|
||||||
|
|
||||||
|
import com.intellij.testFramework.TestDataPath;
|
||||||
|
import org.jetbrains.kotlin.test.JUnit3RunnerWithInners;
|
||||||
|
import org.jetbrains.kotlin.test.KotlinTestUtils;
|
||||||
|
import org.jetbrains.kotlin.test.TargetBackend;
|
||||||
|
import org.jetbrains.kotlin.test.TestMetadata;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */
|
||||||
|
@SuppressWarnings("all")
|
||||||
|
@TestMetadata("compiler/testData/codegen/boxInline/multiModule")
|
||||||
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
public class JsInlineMultiModuleTestsGenerated extends AbstractJsInlineMultiModuleTests {
|
||||||
|
private void runTest(String testDataFilePath) throws Exception {
|
||||||
|
KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS, testDataFilePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testAllFilesPresentInMultiModule() throws Exception {
|
||||||
|
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/boxInline/multiModule"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("tryCatchWithRecursiveInline.kt")
|
||||||
|
public void testTryCatchWithRecursiveInline() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/boxInline/multiModule/tryCatchWithRecursiveInline.kt");
|
||||||
|
}
|
||||||
|
}
|
||||||
+2
@@ -33,6 +33,8 @@ abstract class AbstractInlineSuspendTests : BorrowedInlineTest("suspend/")
|
|||||||
|
|
||||||
abstract class AbstractJsInlineContractsTests : BorrowedInlineTest("contracts/")
|
abstract class AbstractJsInlineContractsTests : BorrowedInlineTest("contracts/")
|
||||||
|
|
||||||
|
abstract class AbstractJsInlineMultiModuleTests : BorrowedInlineTest("multiModule/")
|
||||||
|
|
||||||
abstract class AbstractBoxJsTest : BasicBoxTest(
|
abstract class AbstractBoxJsTest : BasicBoxTest(
|
||||||
BasicBoxTest.TEST_DATA_DIR_PATH + "box/",
|
BasicBoxTest.TEST_DATA_DIR_PATH + "box/",
|
||||||
"box/"
|
"box/"
|
||||||
|
|||||||
Reference in New Issue
Block a user