diff --git a/compiler/testData/codegen/boxInline/multiModule/tryCatchWithRecursiveInline.kt b/compiler/testData/codegen/boxInline/multiModule/tryCatchWithRecursiveInline.kt new file mode 100644 index 00000000000..fdb21c27e86 --- /dev/null +++ b/compiler/testData/codegen/boxInline/multiModule/tryCatchWithRecursiveInline.kt @@ -0,0 +1,26 @@ +// IGNORE_BACKEND_FIR: JVM_IR +// IGNORE_BACKEND: NATIVE +// MODULE: lib +// FILE: lib.kt +inline fun T.andAlso(block: (T) -> Unit): T { + block(this) + return this +} + +inline fun 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" +} diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxInlineCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxInlineCodegenTestGenerated.java index af79ed45984..7a61f36083e 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxInlineCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxInlineCodegenTestGenerated.java @@ -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") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/CompileKotlinAgainstInlineKotlinTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/CompileKotlinAgainstInlineKotlinTestGenerated.java index 9b11e9c1794..421d95f1601 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/CompileKotlinAgainstInlineKotlinTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/CompileKotlinAgainstInlineKotlinTestGenerated.java @@ -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") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxInlineCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxInlineCodegenTestGenerated.java index 13c55c5e146..2802dc8f459 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxInlineCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxInlineCodegenTestGenerated.java @@ -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") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrCompileKotlinAgainstInlineKotlinTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrCompileKotlinAgainstInlineKotlinTestGenerated.java index 164f9c0e2d7..dd9e68eff66 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrCompileKotlinAgainstInlineKotlinTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrCompileKotlinAgainstInlineKotlinTestGenerated.java @@ -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") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/js/js.tests/test/org/jetbrains/kotlin/generators/tests/GenerateJsTests.kt b/js/js.tests/test/org/jetbrains/kotlin/generators/tests/GenerateJsTests.kt index b6a1d1fb81d..557b5d93a17 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/generators/tests/GenerateJsTests.kt +++ b/js/js.tests/test/org/jetbrains/kotlin/generators/tests/GenerateJsTests.kt @@ -134,5 +134,13 @@ fun main(args: Array) { testClass { model("codegen/box/arrays", targetBackend = TargetBackend.JS) } + + testClass { + model("codegen/boxInline/multiModule/", targetBackend = TargetBackend.JS) + } + + testClass { + model("codegen/boxInline/multiModule/", targetBackend = TargetBackend.JS_IR) + } } } diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/ir/semantics/IrJsInlineMultiModuleTestsGenerated.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/ir/semantics/IrJsInlineMultiModuleTestsGenerated.java new file mode 100644 index 00000000000..8095084caad --- /dev/null +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/ir/semantics/IrJsInlineMultiModuleTestsGenerated.java @@ -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"); + } +} diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/ir/semantics/abstractClassesForGeneratedIrTests.kt b/js/js.tests/test/org/jetbrains/kotlin/js/test/ir/semantics/abstractClassesForGeneratedIrTests.kt index 288e97e159d..802be7d6aff 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/ir/semantics/abstractClassesForGeneratedIrTests.kt +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/ir/semantics/abstractClassesForGeneratedIrTests.kt @@ -43,4 +43,6 @@ abstract class AbstractIrInlineDefaultValuesTests : BorrowedIrInlineTest("defaul abstract class AbstractIrInlineSuspendTests : BorrowedIrInlineTest("suspend/") -abstract class AbstractIrJsInlineContractsTests : BorrowedIrInlineTest("contracts/") \ No newline at end of file +abstract class AbstractIrJsInlineContractsTests : BorrowedIrInlineTest("contracts/") + +abstract class AbstractIrJsInlineMultiModuleTests : BorrowedIrInlineTest("multiModule/") \ No newline at end of file diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsInlineMultiModuleTestsGenerated.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsInlineMultiModuleTestsGenerated.java new file mode 100644 index 00000000000..7f48b4610c4 --- /dev/null +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsInlineMultiModuleTestsGenerated.java @@ -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"); + } +} diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/abstractClassesForGeneratedTests.kt b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/abstractClassesForGeneratedTests.kt index 2680046a99a..ead38e5cbf2 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/abstractClassesForGeneratedTests.kt +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/abstractClassesForGeneratedTests.kt @@ -33,6 +33,8 @@ abstract class AbstractInlineSuspendTests : BorrowedInlineTest("suspend/") abstract class AbstractJsInlineContractsTests : BorrowedInlineTest("contracts/") +abstract class AbstractJsInlineMultiModuleTests : BorrowedInlineTest("multiModule/") + abstract class AbstractBoxJsTest : BasicBoxTest( BasicBoxTest.TEST_DATA_DIR_PATH + "box/", "box/"