From 5afa44edea62904241616c618054f79d09e04915 Mon Sep 17 00:00:00 2001 From: Igor Chevdar Date: Wed, 19 Dec 2018 14:28:42 +0300 Subject: [PATCH] Added a coroutine test --- .../varCaptuedInCoroutineIntrinsic.kt | 33 +++++++++++++++++++ .../codegen/BlackBoxCodegenTestGenerated.java | 10 ++++++ .../LightAnalysisModeTestGenerated.java | 10 ++++++ .../ir/IrBlackBoxCodegenTestGenerated.java | 10 ++++++ .../IrJsCodegenBoxTestGenerated.java | 5 +++ .../semantics/JsCodegenBoxTestGenerated.java | 10 ++++++ 6 files changed, 78 insertions(+) create mode 100644 compiler/testData/codegen/box/coroutines/varCaptuedInCoroutineIntrinsic.kt diff --git a/compiler/testData/codegen/box/coroutines/varCaptuedInCoroutineIntrinsic.kt b/compiler/testData/codegen/box/coroutines/varCaptuedInCoroutineIntrinsic.kt new file mode 100644 index 00000000000..cff0202e63a --- /dev/null +++ b/compiler/testData/codegen/box/coroutines/varCaptuedInCoroutineIntrinsic.kt @@ -0,0 +1,33 @@ +// IGNORE_BACKEND: JVM_IR +// WITH_RUNTIME +// WITH_COROUTINES +// COMMON_COROUTINES_TEST + +import helpers.* +import COROUTINES_PACKAGE.* +import COROUTINES_PACKAGE.intrinsics.* + +suspend fun suspendHere(): String { + var s: String? = null + val z: String = suspendCoroutineUninterceptedOrReturn { x -> + s = "zzz" + x.resume("OK") + COROUTINE_SUSPENDED + } + if (s != "zzz") return "fail" + return z +} + +fun builder(c: suspend () -> Unit) { + c.startCoroutine(EmptyContinuation) +} + +fun box(): String { + var result = "" + + builder { + result = suspendHere() + } + + return result +} \ No newline at end of file diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java index 93955ae0a0e..f7c01abdb70 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java @@ -6359,6 +6359,16 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/tryFinallyWithHandleResult.kt", "kotlin.coroutines"); } + @TestMetadata("varCaptuedInCoroutineIntrinsic.kt") + public void testVarCaptuedInCoroutineIntrinsic_1_2() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/varCaptuedInCoroutineIntrinsic.kt", "kotlin.coroutines.experimental"); + } + + @TestMetadata("varCaptuedInCoroutineIntrinsic.kt") + public void testVarCaptuedInCoroutineIntrinsic_1_3() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/varCaptuedInCoroutineIntrinsic.kt", "kotlin.coroutines"); + } + @TestMetadata("varValueConflictsWithTableSameSort.kt") public void testVarValueConflictsWithTableSameSort_1_2() throws Exception { runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/varValueConflictsWithTableSameSort.kt", "kotlin.coroutines.experimental"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index 56d88894947..dd8aa8e48ec 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -6359,6 +6359,16 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/tryFinallyWithHandleResult.kt", "kotlin.coroutines"); } + @TestMetadata("varCaptuedInCoroutineIntrinsic.kt") + public void testVarCaptuedInCoroutineIntrinsic_1_2() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/varCaptuedInCoroutineIntrinsic.kt", "kotlin.coroutines.experimental"); + } + + @TestMetadata("varCaptuedInCoroutineIntrinsic.kt") + public void testVarCaptuedInCoroutineIntrinsic_1_3() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/varCaptuedInCoroutineIntrinsic.kt", "kotlin.coroutines"); + } + @TestMetadata("varValueConflictsWithTableSameSort.kt") public void testVarValueConflictsWithTableSameSort_1_2() throws Exception { runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/varValueConflictsWithTableSameSort.kt", "kotlin.coroutines.experimental"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java index f245613e46c..63f11cf0354 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java @@ -6359,6 +6359,16 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/tryFinallyWithHandleResult.kt", "kotlin.coroutines"); } + @TestMetadata("varCaptuedInCoroutineIntrinsic.kt") + public void testVarCaptuedInCoroutineIntrinsic_1_2() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/varCaptuedInCoroutineIntrinsic.kt", "kotlin.coroutines.experimental"); + } + + @TestMetadata("varCaptuedInCoroutineIntrinsic.kt") + public void testVarCaptuedInCoroutineIntrinsic_1_3() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/varCaptuedInCoroutineIntrinsic.kt", "kotlin.coroutines"); + } + @TestMetadata("varValueConflictsWithTableSameSort.kt") public void testVarValueConflictsWithTableSameSort_1_2() throws Exception { runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/varValueConflictsWithTableSameSort.kt", "kotlin.coroutines.experimental"); diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/IrJsCodegenBoxTestGenerated.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/IrJsCodegenBoxTestGenerated.java index 42c00650678..7651c0d7d13 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/IrJsCodegenBoxTestGenerated.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/IrJsCodegenBoxTestGenerated.java @@ -5084,6 +5084,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/tryFinallyWithHandleResult.kt", "kotlin.coroutines"); } + @TestMetadata("varCaptuedInCoroutineIntrinsic.kt") + public void testVarCaptuedInCoroutineIntrinsic_1_3() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/varCaptuedInCoroutineIntrinsic.kt", "kotlin.coroutines"); + } + @TestMetadata("varValueConflictsWithTableSameSort.kt") public void testVarValueConflictsWithTableSameSort_1_3() throws Exception { runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/varValueConflictsWithTableSameSort.kt", "kotlin.coroutines"); diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java index cbe23ffd244..c3c5bd48f52 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java @@ -5479,6 +5479,16 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/tryFinallyWithHandleResult.kt", "kotlin.coroutines"); } + @TestMetadata("varCaptuedInCoroutineIntrinsic.kt") + public void testVarCaptuedInCoroutineIntrinsic_1_2() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/varCaptuedInCoroutineIntrinsic.kt", "kotlin.coroutines.experimental"); + } + + @TestMetadata("varCaptuedInCoroutineIntrinsic.kt") + public void testVarCaptuedInCoroutineIntrinsic_1_3() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/varCaptuedInCoroutineIntrinsic.kt", "kotlin.coroutines"); + } + @TestMetadata("varValueConflictsWithTableSameSort.kt") public void testVarValueConflictsWithTableSameSort_1_2() throws Exception { runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/varValueConflictsWithTableSameSort.kt", "kotlin.coroutines.experimental");