diff --git a/compiler/android-tests/android-tests.iml b/compiler/android-tests/android-tests.iml index 7394c76b537..0c5a764ac63 100644 --- a/compiler/android-tests/android-tests.iml +++ b/compiler/android-tests/android-tests.iml @@ -18,5 +18,6 @@ + - \ No newline at end of file + diff --git a/compiler/android-tests/tests/org/jetbrains/kotlin/android/tests/AndroidTestGenerator.kt b/compiler/android-tests/tests/org/jetbrains/kotlin/android/tests/AndroidTestGenerator.kt index ebf935efe94..0d0facca92a 100644 --- a/compiler/android-tests/tests/org/jetbrains/kotlin/android/tests/AndroidTestGenerator.kt +++ b/compiler/android-tests/tests/org/jetbrains/kotlin/android/tests/AndroidTestGenerator.kt @@ -31,20 +31,25 @@ private val packagePattern = Pattern.compile("(?m)^\\s*package[ |\t]+([\\w|\\.]* private val importPattern = Pattern.compile("import[ |\t]([\\w|]*\\.)") -internal fun genFiles(file: File, fileContent: String, filesHolder: CodegenTestsOnAndroidGenerator.FilesWriter): FqName? { - val testFiles = createTestFiles(file, fileContent) +internal fun genFiles( + testFileName: String, + filePath: String, + fileContent: String, + filesHolder: CodegenTestsOnAndroidGenerator.FilesWriter +): FqName? { + val testFiles = createTestFiles(testFileName, fileContent) if (testFiles.filter { it.name.endsWith(".java") }.isNotEmpty()) { //TODO support java files - return null; + return null } val ktFiles = testFiles.filter { it.name.endsWith(".kt") } if (ktFiles.isEmpty()) return null - val newPackagePrefix = file.path.replace("\\\\|-|\\.|/".toRegex(), "_") + val newPackagePrefix = filePath.replace("\\\\|-|\\.|/".toRegex(), "_") val oldPackage = Ref() val isSingle = testFiles.size == 1 val resultFiles = testFiles.map { - val fileName = if (isSingle) it.name else file.name.substringBeforeLast(".kt") + "/" + it.name + val fileName = if (isSingle) it.name else testFileName.substringBeforeLast(".kt") + "/" + it.name TestClassInfo( fileName, changePackage(newPackagePrefix, it.content, oldPackage), @@ -77,14 +82,14 @@ internal fun genFiles(file: File, fileContent: String, filesHolder: CodegenTests val boxFiles = resultFiles.filter { hasBoxMethod(it.content) } if (boxFiles.size != 1) { - println("Several box methods in $file") + println("Several box methods in $filePath") } return boxFiles.last().newClassId } -private fun createTestFiles(file: File, expectedText: String): List { - val files = KotlinTestUtils.createTestFiles(file.name, expectedText, object : KotlinTestUtils.TestFileFactoryNoModules() { +private fun createTestFiles(fileName: String, expectedText: String): List { + val files = KotlinTestUtils.createTestFiles(fileName, expectedText, object : KotlinTestUtils.TestFileFactoryNoModules() { override fun create(fileName: String, text: String, directives: Map): CodegenTestCase.TestFile { return CodegenTestCase.TestFile(fileName, text) } diff --git a/compiler/android-tests/tests/org/jetbrains/kotlin/android/tests/CodegenTestsOnAndroidGenerator.java b/compiler/android-tests/tests/org/jetbrains/kotlin/android/tests/CodegenTestsOnAndroidGenerator.java index 3a9c1456574..79ca4ca959e 100644 --- a/compiler/android-tests/tests/org/jetbrains/kotlin/android/tests/CodegenTestsOnAndroidGenerator.java +++ b/compiler/android-tests/tests/org/jetbrains/kotlin/android/tests/CodegenTestsOnAndroidGenerator.java @@ -25,6 +25,7 @@ import org.jetbrains.kotlin.backend.common.output.OutputFileCollection; import org.jetbrains.kotlin.cli.common.output.outputUtils.OutputUtilsKt; import org.jetbrains.kotlin.cli.jvm.compiler.EnvironmentConfigFiles; import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment; +import org.jetbrains.kotlin.codegen.AbstractAdditionalCoroutineBlackBoxCodegenTest; import org.jetbrains.kotlin.codegen.CodegenTestFiles; import org.jetbrains.kotlin.codegen.GenerationUtils; import org.jetbrains.kotlin.codegen.forTestCompile.ForTestCompileRuntime; @@ -252,17 +253,46 @@ public class CodegenTestsOnAndroidGenerator extends KtUsefulTestCase { InTextDirectivesUtils.isDirectiveDefined(fullFileText, "WITH_REFLECT") ? holderFull : holderMock; filesHolder = fullFileText.contains("+JVM.INHERIT_MULTIFILE_PARTS") ? holderInheritMFP : filesHolder; - FqName classWithBoxMethod = AndroidTestGeneratorKt.genFiles(file, fullFileText, filesHolder); - if (classWithBoxMethod == null) - continue; + if (!generateTest(file.getName(), file.getPath(), fullFileText, printer, filesHolder)) continue; + + if (fullFileText.contains(AbstractAdditionalCoroutineBlackBoxCodegenTest.INTERCEPT_RESUME_PLACEHOLDER)) { + int counter = 1; + for (String replacement : AbstractAdditionalCoroutineBlackBoxCodegenTest.ALL_REPLACEMENTS) { + String testFileName = file.getName().replace(".kt", "_" + counter + ".kt"); + String filePath = file.getPath().replace(".kt", "_" + counter + ".kt"); + generateTest( + testFileName, + filePath, + fullFileText.replace( + AbstractAdditionalCoroutineBlackBoxCodegenTest.INTERCEPT_RESUME_PLACEHOLDER, replacement + ), + printer, + filesHolder + ); + + counter++; + } + } - String generatedTestName = generateTestName(file.getName()); - generateTestMethod(printer, generatedTestName, classWithBoxMethod.asString(), StringUtil.escapeStringCharacters(file.getPath())); } } } } + private boolean generateTest( + @NotNull String testFileName, + @NotNull String filePath, + @NotNull String fullFileText, + @NotNull Printer printer, + @NotNull FilesWriter filesHolder + ) { + FqName classWithBoxMethod = AndroidTestGeneratorKt.genFiles(testFileName, filePath, fullFileText, filesHolder); + if (classWithBoxMethod == null) return false; + + String generatedTestName = generateTestName(testFileName); + generateTestMethod(printer, generatedTestName, classWithBoxMethod.asString(), StringUtil.escapeStringCharacters(filePath)); + return true; + } private static boolean hasBoxMethod(String text) { diff --git a/compiler/testData/codegen/box/coroutines/beginWithException.kt b/compiler/testData/codegen/box/coroutines/beginWithException.kt index 120b0effc37..45bc615447d 100644 --- a/compiler/testData/codegen/box/coroutines/beginWithException.kt +++ b/compiler/testData/codegen/box/coroutines/beginWithException.kt @@ -7,6 +7,8 @@ class Controller { } suspend fun suspendHere(x: Continuation) {} + + // INTERCEPT_RESUME_PLACEHOLDER } fun builder(coroutine c: Controller.() -> Continuation) { diff --git a/compiler/testData/codegen/box/coroutines/beginWithExceptionNoHandleException.kt b/compiler/testData/codegen/box/coroutines/beginWithExceptionNoHandleException.kt index c7687613777..b7abcc41fdf 100644 --- a/compiler/testData/codegen/box/coroutines/beginWithExceptionNoHandleException.kt +++ b/compiler/testData/codegen/box/coroutines/beginWithExceptionNoHandleException.kt @@ -1,6 +1,8 @@ // WITH_RUNTIME class Controller { suspend fun suspendHere(x: Continuation) {} + + // INTERCEPT_RESUME_PLACEHOLDER } fun builder(coroutine c: Controller.() -> Continuation) { diff --git a/compiler/testData/codegen/box/coroutines/coercionToUnit.kt b/compiler/testData/codegen/box/coroutines/coercionToUnit.kt index b80fb589b2d..264363c23fd 100644 --- a/compiler/testData/codegen/box/coroutines/coercionToUnit.kt +++ b/compiler/testData/codegen/box/coroutines/coercionToUnit.kt @@ -7,6 +7,8 @@ class Controller { suspend fun await(t: T, c: Continuation) { c.resume(t) } + + // INTERCEPT_RESUME_PLACEHOLDER } fun builder(coroutine c: Controller.() -> Continuation): String { diff --git a/compiler/testData/codegen/box/coroutines/controlFlow/breakFinally.kt b/compiler/testData/codegen/box/coroutines/controlFlow/breakFinally.kt index 64817dab553..4fac18968b0 100644 --- a/compiler/testData/codegen/box/coroutines/controlFlow/breakFinally.kt +++ b/compiler/testData/codegen/box/coroutines/controlFlow/breakFinally.kt @@ -1,4 +1,5 @@ // WITH_RUNTIME +// NO_INTERCEPT_RESUME_TESTS class Controller { var result = "" @@ -48,4 +49,4 @@ fun box(): String { if (value != "AC!ED!@*finally.") return "fail: $value" return "OK" -} \ No newline at end of file +} diff --git a/compiler/testData/codegen/box/coroutines/controlFlow/breakStatement.kt b/compiler/testData/codegen/box/coroutines/controlFlow/breakStatement.kt index 869770d4b31..b5141c96108 100644 --- a/compiler/testData/codegen/box/coroutines/controlFlow/breakStatement.kt +++ b/compiler/testData/codegen/box/coroutines/controlFlow/breakStatement.kt @@ -1,4 +1,5 @@ // WITH_RUNTIME +// NO_INTERCEPT_RESUME_TESTS class Controller { var result = "" @@ -44,4 +45,4 @@ fun box(): String { if (value != "OQKQ.") return "fail: break inner loop: $value" return "OK" -} \ No newline at end of file +} diff --git a/compiler/testData/codegen/box/coroutines/controlFlow/doWhileStatement.kt b/compiler/testData/codegen/box/coroutines/controlFlow/doWhileStatement.kt index 63dfc90a06a..af76f56fc91 100644 --- a/compiler/testData/codegen/box/coroutines/controlFlow/doWhileStatement.kt +++ b/compiler/testData/codegen/box/coroutines/controlFlow/doWhileStatement.kt @@ -1,4 +1,5 @@ // WITH_RUNTIME +// NO_INTERCEPT_RESUME_TESTS class Controller { var result = "" @@ -35,4 +36,4 @@ fun box(): String { if (value != "1;2;3;.") return "fail: suspend in do..while body: $value" return "OK" -} \ No newline at end of file +} diff --git a/compiler/testData/codegen/box/coroutines/controlFlow/forContinue.kt b/compiler/testData/codegen/box/coroutines/controlFlow/forContinue.kt index fba1e746198..eed3dcea86c 100644 --- a/compiler/testData/codegen/box/coroutines/controlFlow/forContinue.kt +++ b/compiler/testData/codegen/box/coroutines/controlFlow/forContinue.kt @@ -1,4 +1,5 @@ // WITH_RUNTIME +// NO_INTERCEPT_RESUME_TESTS class Controller { var result = "" @@ -25,4 +26,4 @@ fun box(): String { if (value != "OK.") return "fail: suspend in for body: $value" return "OK" -} \ No newline at end of file +} diff --git a/compiler/testData/codegen/box/coroutines/controlFlow/forStatement.kt b/compiler/testData/codegen/box/coroutines/controlFlow/forStatement.kt index 6dc2c2ddcd8..67d5f34b2b3 100644 --- a/compiler/testData/codegen/box/coroutines/controlFlow/forStatement.kt +++ b/compiler/testData/codegen/box/coroutines/controlFlow/forStatement.kt @@ -1,4 +1,5 @@ // WITH_RUNTIME +// NO_INTERCEPT_RESUME_TESTS class Controller { var result = "" @@ -24,4 +25,4 @@ fun box(): String { if (value != "OK.") return "fail: suspend in for body: $value" return "OK" -} \ No newline at end of file +} diff --git a/compiler/testData/codegen/box/coroutines/controlFlow/ifStatement.kt b/compiler/testData/codegen/box/coroutines/controlFlow/ifStatement.kt index e1474b4cdea..649eeb3669e 100644 --- a/compiler/testData/codegen/box/coroutines/controlFlow/ifStatement.kt +++ b/compiler/testData/codegen/box/coroutines/controlFlow/ifStatement.kt @@ -1,4 +1,5 @@ // WITH_RUNTIME +// NO_INTERCEPT_RESUME_TESTS class Controller { var result = "" @@ -69,4 +70,4 @@ fun box(): String { if (value != "O;;") return "fail: suspend in then branch without else: $value" return "OK" -} \ No newline at end of file +} diff --git a/compiler/testData/codegen/box/coroutines/controlFlow/returnFromFinally.kt b/compiler/testData/codegen/box/coroutines/controlFlow/returnFromFinally.kt index 74b7a885176..13c96817486 100644 --- a/compiler/testData/codegen/box/coroutines/controlFlow/returnFromFinally.kt +++ b/compiler/testData/codegen/box/coroutines/controlFlow/returnFromFinally.kt @@ -1,4 +1,5 @@ // WITH_RUNTIME +// NO_INTERCEPT_RESUME_TESTS // Does not work in JVM backend, probably due to bug. It's not clear which behaviour is right. // TODO: fix the bug and enable for JVM backend @@ -41,4 +42,4 @@ fun box(): String { if (value != "suspend(OK);finally;return(OK);") return "fail: $value" return "OK" -} \ No newline at end of file +} diff --git a/compiler/testData/codegen/box/coroutines/controlFlow/switchLikeWhen.kt b/compiler/testData/codegen/box/coroutines/controlFlow/switchLikeWhen.kt index a757817e081..295f1240e1c 100644 --- a/compiler/testData/codegen/box/coroutines/controlFlow/switchLikeWhen.kt +++ b/compiler/testData/codegen/box/coroutines/controlFlow/switchLikeWhen.kt @@ -1,4 +1,5 @@ // WITH_RUNTIME +// NO_INTERCEPT_RESUME_TESTS // TODO: fix bug in JVM backend and remove this directive // TARGET_BACKEND: JS @@ -31,4 +32,4 @@ fun box(): String { if (value != "A;[B][C]!") return "fail: suspend as if condition: $value" return "OK" -} \ No newline at end of file +} diff --git a/compiler/testData/codegen/box/coroutines/controlFlow/throwFromCatch.kt b/compiler/testData/codegen/box/coroutines/controlFlow/throwFromCatch.kt index 0cb279481e8..919c2cb7d91 100644 --- a/compiler/testData/codegen/box/coroutines/controlFlow/throwFromCatch.kt +++ b/compiler/testData/codegen/box/coroutines/controlFlow/throwFromCatch.kt @@ -1,4 +1,5 @@ // WITH_RUNTIME +// NO_INTERCEPT_RESUME_TESTS class Controller { var result = "" @@ -45,4 +46,4 @@ fun box(): String { } return "OK" -} \ No newline at end of file +} diff --git a/compiler/testData/codegen/box/coroutines/controlFlow/whileStatement.kt b/compiler/testData/codegen/box/coroutines/controlFlow/whileStatement.kt index ad2faf23896..2daa0827e00 100644 --- a/compiler/testData/codegen/box/coroutines/controlFlow/whileStatement.kt +++ b/compiler/testData/codegen/box/coroutines/controlFlow/whileStatement.kt @@ -1,4 +1,5 @@ // WITH_RUNTIME +// NO_INTERCEPT_RESUME_TESTS class Controller { var result = "" @@ -35,4 +36,4 @@ fun box(): String { if (value != "1;2;3;.") return "fail: suspend in while body: $value" return "OK" -} \ No newline at end of file +} diff --git a/compiler/testData/codegen/box/coroutines/controllerAccessFromInnerLambda.kt b/compiler/testData/codegen/box/coroutines/controllerAccessFromInnerLambda.kt index 05d3b54165b..8ecb16c3c90 100644 --- a/compiler/testData/codegen/box/coroutines/controllerAccessFromInnerLambda.kt +++ b/compiler/testData/codegen/box/coroutines/controllerAccessFromInnerLambda.kt @@ -7,6 +7,8 @@ class Controller { fun foo() { result = true } + + // INTERCEPT_RESUME_PLACEHOLDER } fun builder(coroutine c: Controller.() -> Continuation) { diff --git a/compiler/testData/codegen/box/coroutines/defaultParametersInSuspend.kt b/compiler/testData/codegen/box/coroutines/defaultParametersInSuspend.kt index 8a6b3532842..f2a5d6937f6 100644 --- a/compiler/testData/codegen/box/coroutines/defaultParametersInSuspend.kt +++ b/compiler/testData/codegen/box/coroutines/defaultParametersInSuspend.kt @@ -2,6 +2,8 @@ class Controller { suspend fun suspendHere(a: String = "abc", i: Int = 2, x: Continuation) { x.resume(a + "#" + (i + 1)) } + + // INTERCEPT_RESUME_PLACEHOLDER } fun builder(coroutine c: Controller.() -> Continuation) { diff --git a/compiler/testData/codegen/box/coroutines/emptyClosure.kt b/compiler/testData/codegen/box/coroutines/emptyClosure.kt index 9b816123909..36fa1f59a67 100644 --- a/compiler/testData/codegen/box/coroutines/emptyClosure.kt +++ b/compiler/testData/codegen/box/coroutines/emptyClosure.kt @@ -5,6 +5,8 @@ class Controller { result++ x.resume("OK") } + + // INTERCEPT_RESUME_PLACEHOLDER } diff --git a/compiler/testData/codegen/box/coroutines/falseUnitCoercion.kt b/compiler/testData/codegen/box/coroutines/falseUnitCoercion.kt index c827d4dea5b..8a07ae8dc08 100644 --- a/compiler/testData/codegen/box/coroutines/falseUnitCoercion.kt +++ b/compiler/testData/codegen/box/coroutines/falseUnitCoercion.kt @@ -2,6 +2,8 @@ class Controller { suspend fun suspendHere(v: T, x: Continuation) { x.resume(v) } + + // INTERCEPT_RESUME_PLACEHOLDER } fun builder(coroutine c: Controller.() -> Continuation) { diff --git a/compiler/testData/codegen/box/coroutines/generate.kt b/compiler/testData/codegen/box/coroutines/generate.kt index 51158972a04..2d7522606c6 100644 --- a/compiler/testData/codegen/box/coroutines/generate.kt +++ b/compiler/testData/codegen/box/coroutines/generate.kt @@ -51,4 +51,6 @@ class GeneratorController() : AbstractIterator() { operator fun handleResult(result: Unit, c: Continuation) { done() } + + // INTERCEPT_RESUME_PLACEHOLDER } diff --git a/compiler/testData/codegen/box/coroutines/handleException.kt b/compiler/testData/codegen/box/coroutines/handleException.kt index 8551260ffc6..b9690cc1c2e 100644 --- a/compiler/testData/codegen/box/coroutines/handleException.kt +++ b/compiler/testData/codegen/box/coroutines/handleException.kt @@ -26,6 +26,8 @@ class Controller { postponedActions.removeAt(0) } } + + // INTERCEPT_RESUME_PLACEHOLDER } fun builder(coroutine c: Controller.() -> Continuation) { diff --git a/compiler/testData/codegen/box/coroutines/handleResultCallEmptyBody.kt b/compiler/testData/codegen/box/coroutines/handleResultCallEmptyBody.kt index 10bd07cfc9d..641ddcb9d8b 100644 --- a/compiler/testData/codegen/box/coroutines/handleResultCallEmptyBody.kt +++ b/compiler/testData/codegen/box/coroutines/handleResultCallEmptyBody.kt @@ -4,6 +4,8 @@ class Controller { operator fun handleResult(u: Unit, v: Continuation) { ok = true } + + // INTERCEPT_RESUME_PLACEHOLDER } fun builder(coroutine c: Controller.() -> Continuation): String { diff --git a/compiler/testData/codegen/box/coroutines/handleResultNonUnitExpression.kt b/compiler/testData/codegen/box/coroutines/handleResultNonUnitExpression.kt index d6ed8c55c99..547c24f9cc4 100644 --- a/compiler/testData/codegen/box/coroutines/handleResultNonUnitExpression.kt +++ b/compiler/testData/codegen/box/coroutines/handleResultNonUnitExpression.kt @@ -7,6 +7,8 @@ class Controller { operator fun handleResult(x: Unit, y: Continuation) { isCompleted = true } + + // INTERCEPT_RESUME_PLACEHOLDER } fun builder(coroutine c: Controller.() -> Continuation) { diff --git a/compiler/testData/codegen/box/coroutines/handleResultSuspended.kt b/compiler/testData/codegen/box/coroutines/handleResultSuspended.kt index d17302d15c4..bdcbea1bc02 100644 --- a/compiler/testData/codegen/box/coroutines/handleResultSuspended.kt +++ b/compiler/testData/codegen/box/coroutines/handleResultSuspended.kt @@ -9,6 +9,8 @@ class Controller { operator fun handleResult(value: String, y: Continuation) { log += "return($value);" } + + // INTERCEPT_RESUME_PLACEHOLDER } fun builder(coroutine c: Controller.() -> Continuation): String { diff --git a/compiler/testData/codegen/box/coroutines/illegalState.kt b/compiler/testData/codegen/box/coroutines/illegalState.kt index cc2df2cfeff..0f9eda9538b 100644 --- a/compiler/testData/codegen/box/coroutines/illegalState.kt +++ b/compiler/testData/codegen/box/coroutines/illegalState.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // TARGET_BACKEND: JVM +// NO_INTERCEPT_RESUME_TESTS class Controller { suspend fun suspendHere(x: Continuation) { x.resume(Unit) diff --git a/compiler/testData/codegen/box/coroutines/inlineSuspendFunction.kt b/compiler/testData/codegen/box/coroutines/inlineSuspendFunction.kt index 460610909eb..afa2c2dd1da 100644 --- a/compiler/testData/codegen/box/coroutines/inlineSuspendFunction.kt +++ b/compiler/testData/codegen/box/coroutines/inlineSuspendFunction.kt @@ -16,6 +16,8 @@ class Controller { suspend inline fun suspendInline(x: Continuation) { suspendInline({ T::class.simpleName!! }, x) } + + // INTERCEPT_RESUME_PLACEHOLDER } fun builder(coroutine c: Controller.() -> Continuation) { diff --git a/compiler/testData/codegen/box/coroutines/inlinedTryCatchFinally.kt b/compiler/testData/codegen/box/coroutines/inlinedTryCatchFinally.kt index 7d6dce2651a..c25321154d8 100644 --- a/compiler/testData/codegen/box/coroutines/inlinedTryCatchFinally.kt +++ b/compiler/testData/codegen/box/coroutines/inlinedTryCatchFinally.kt @@ -27,6 +27,8 @@ class Controller { postponedActions.removeAt(0) } } + + // INTERCEPT_RESUME_PLACEHOLDER } fun builder(expectException: Boolean = false, coroutine c: Controller.() -> Continuation) { diff --git a/compiler/testData/codegen/box/coroutines/innerSuspensionCalls.kt b/compiler/testData/codegen/box/coroutines/innerSuspensionCalls.kt index acacbf92695..a3e8d6aaeb5 100644 --- a/compiler/testData/codegen/box/coroutines/innerSuspensionCalls.kt +++ b/compiler/testData/codegen/box/coroutines/innerSuspensionCalls.kt @@ -3,6 +3,8 @@ class Controller { suspend fun suspendHere(x: Continuation) { x.resume((i++).toString()) } + + // INTERCEPT_RESUME_PLACEHOLDER } fun builder(coroutine c: Controller.() -> Continuation) { diff --git a/compiler/testData/codegen/box/coroutines/instanceOfContinuation.kt b/compiler/testData/codegen/box/coroutines/instanceOfContinuation.kt index 88d43908380..f2c8450e69a 100644 --- a/compiler/testData/codegen/box/coroutines/instanceOfContinuation.kt +++ b/compiler/testData/codegen/box/coroutines/instanceOfContinuation.kt @@ -11,6 +11,8 @@ class Controller { val y: Any = x x.resume(Continuation::class.isInstance(y as Continuation<*>)) } + + // INTERCEPT_RESUME_PLACEHOLDER } fun builder(coroutine c: Controller.() -> Continuation) { diff --git a/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/complicatedMerge.kt b/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/complicatedMerge.kt index 8e8c9f5d9f1..3949bfb83ab 100644 --- a/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/complicatedMerge.kt +++ b/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/complicatedMerge.kt @@ -2,6 +2,8 @@ class Controller { suspend fun suspendHere(x: Continuation) { x.resume(Unit) } + + // INTERCEPT_RESUME_PLACEHOLDER } fun builder(coroutine c: Controller.() -> Continuation) { diff --git a/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/i2bResult.kt b/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/i2bResult.kt index f4c86ef86fd..242d26ce688 100644 --- a/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/i2bResult.kt +++ b/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/i2bResult.kt @@ -2,6 +2,8 @@ class Controller { suspend fun suspendHere(x: Continuation) { x.resume(Unit) } + + // INTERCEPT_RESUME_PLACEHOLDER } fun builder(coroutine c: Controller.() -> Continuation) { diff --git a/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/loadFromBooleanArray.kt b/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/loadFromBooleanArray.kt index f791030fd76..b223e711dd4 100644 --- a/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/loadFromBooleanArray.kt +++ b/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/loadFromBooleanArray.kt @@ -2,6 +2,8 @@ class Controller { suspend fun suspendHere(x: Continuation) { x.resume(Unit) } + + // INTERCEPT_RESUME_PLACEHOLDER } fun builder(coroutine c: Controller.() -> Continuation) { diff --git a/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/loadFromByteArray.kt b/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/loadFromByteArray.kt index 888b7c76543..67a26a5baab 100644 --- a/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/loadFromByteArray.kt +++ b/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/loadFromByteArray.kt @@ -2,6 +2,8 @@ class Controller { suspend fun suspendHere(x: Continuation) { x.resume(Unit) } + + // INTERCEPT_RESUME_PLACEHOLDER } fun builder(coroutine c: Controller.() -> Continuation) { diff --git a/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/noVariableInTable.kt b/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/noVariableInTable.kt index 2d4af13cabf..90dabd283c7 100644 --- a/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/noVariableInTable.kt +++ b/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/noVariableInTable.kt @@ -2,6 +2,8 @@ class Controller { suspend fun suspendHere(x: Continuation) { x.resume(Unit) } + + // INTERCEPT_RESUME_PLACEHOLDER } fun builder(coroutine c: Controller.() -> Continuation) { diff --git a/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/sameIconst1ManyVars.kt b/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/sameIconst1ManyVars.kt index 4c10a589253..6aacb10e705 100644 --- a/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/sameIconst1ManyVars.kt +++ b/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/sameIconst1ManyVars.kt @@ -2,6 +2,8 @@ class Controller { suspend fun suspendHere(x: Continuation) { x.resume(Unit) } + + // INTERCEPT_RESUME_PLACEHOLDER } fun builder(coroutine c: Controller.() -> Continuation) { diff --git a/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/usedInArrayStore.kt b/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/usedInArrayStore.kt index f2265c73a0e..6a58a59cfba 100644 --- a/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/usedInArrayStore.kt +++ b/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/usedInArrayStore.kt @@ -4,6 +4,8 @@ class Controller { suspend fun suspendHere(x: Continuation) { x.resume(Unit) } + + // INTERCEPT_RESUME_PLACEHOLDER } fun builder(coroutine c: Controller.() -> Continuation) { diff --git a/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/usedInMethodCall.kt b/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/usedInMethodCall.kt index a9939ff9721..b8a863ea44a 100644 --- a/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/usedInMethodCall.kt +++ b/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/usedInMethodCall.kt @@ -2,6 +2,8 @@ class Controller { suspend fun suspendHere(x: Continuation) { x.resume(Unit) } + + // INTERCEPT_RESUME_PLACEHOLDER } fun builder(coroutine c: Controller.() -> Continuation) { diff --git a/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/usedInPutfield.kt b/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/usedInPutfield.kt index 5a996ade0da..47ed21240cd 100644 --- a/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/usedInPutfield.kt +++ b/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/usedInPutfield.kt @@ -4,6 +4,8 @@ class Controller { suspend fun suspendHere(x: Continuation) { x.resume(Unit) } + + // INTERCEPT_RESUME_PLACEHOLDER } fun builder(coroutine c: Controller.() -> Continuation) { diff --git a/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/usedInVarStore.kt b/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/usedInVarStore.kt index 2ddb6f1b790..b58dfb8ee7c 100644 --- a/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/usedInVarStore.kt +++ b/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/usedInVarStore.kt @@ -2,6 +2,8 @@ class Controller { suspend fun suspendHere(x: Continuation) { x.resume(Unit) } + + // INTERCEPT_RESUME_PLACEHOLDER } fun builder(coroutine c: Controller.() -> Continuation) { diff --git a/compiler/testData/codegen/box/coroutines/iterateOverArray.kt b/compiler/testData/codegen/box/coroutines/iterateOverArray.kt index 7fbfb772254..4849fa72044 100644 --- a/compiler/testData/codegen/box/coroutines/iterateOverArray.kt +++ b/compiler/testData/codegen/box/coroutines/iterateOverArray.kt @@ -2,6 +2,8 @@ class Controller { suspend fun suspendHere(x: Continuation) { x.resume("OK") } + + // INTERCEPT_RESUME_PLACEHOLDER } fun builder(coroutine c: Controller.() -> Continuation) { diff --git a/compiler/testData/codegen/box/coroutines/kt12958.kt b/compiler/testData/codegen/box/coroutines/kt12958.kt index 978b80c54a5..41e4631c20b 100644 --- a/compiler/testData/codegen/box/coroutines/kt12958.kt +++ b/compiler/testData/codegen/box/coroutines/kt12958.kt @@ -7,6 +7,8 @@ class Controller { operator fun handleResult(x: String, c: Continuation) { result = x } + + // INTERCEPT_RESUME_PLACEHOLDER } fun builder(coroutine c: Controller.() -> Continuation): String { diff --git a/compiler/testData/codegen/box/coroutines/lambdaParameters.kt b/compiler/testData/codegen/box/coroutines/lambdaParameters.kt index 31b98ee0129..c6628e5715e 100644 --- a/compiler/testData/codegen/box/coroutines/lambdaParameters.kt +++ b/compiler/testData/codegen/box/coroutines/lambdaParameters.kt @@ -2,6 +2,8 @@ class Controller { suspend fun suspendHere(v: String, x: Continuation) { x.resume(v) } + + // INTERCEPT_RESUME_PLACEHOLDER } fun builder(coroutine c: Controller.(Long, String) -> Continuation) { diff --git a/compiler/testData/codegen/box/coroutines/lastExpressionIsLoop.kt b/compiler/testData/codegen/box/coroutines/lastExpressionIsLoop.kt index f1ba600cc15..e61564905e5 100644 --- a/compiler/testData/codegen/box/coroutines/lastExpressionIsLoop.kt +++ b/compiler/testData/codegen/box/coroutines/lastExpressionIsLoop.kt @@ -9,6 +9,8 @@ class Controller { operator fun handleResult(u: Unit, v: Continuation) { ok = true } + + // INTERCEPT_RESUME_PLACEHOLDER } fun builder(coroutine c: Controller.() -> Continuation): String { diff --git a/compiler/testData/codegen/box/coroutines/lastStatementInc.kt b/compiler/testData/codegen/box/coroutines/lastStatementInc.kt index 6bbcca3969b..2135e0686e7 100644 --- a/compiler/testData/codegen/box/coroutines/lastStatementInc.kt +++ b/compiler/testData/codegen/box/coroutines/lastStatementInc.kt @@ -7,6 +7,8 @@ class Controller { operator fun handleResult(x: Unit, y: Continuation) { wasHandleResultCalled = true } + + // INTERCEPT_RESUME_PLACEHOLDER } fun builder(coroutine c: Controller.() -> Continuation) { diff --git a/compiler/testData/codegen/box/coroutines/lastStementAssignment.kt b/compiler/testData/codegen/box/coroutines/lastStementAssignment.kt index 7e8e1388a8a..7dc36448c04 100644 --- a/compiler/testData/codegen/box/coroutines/lastStementAssignment.kt +++ b/compiler/testData/codegen/box/coroutines/lastStementAssignment.kt @@ -7,6 +7,8 @@ class Controller { operator fun handleResult(x: Unit, y: Continuation) { wasHandleResultCalled = true } + + // INTERCEPT_RESUME_PLACEHOLDER } fun builder(coroutine c: Controller.() -> Continuation) { diff --git a/compiler/testData/codegen/box/coroutines/lastUnitExpression.kt b/compiler/testData/codegen/box/coroutines/lastUnitExpression.kt index de544286406..d4b6cdcbae0 100644 --- a/compiler/testData/codegen/box/coroutines/lastUnitExpression.kt +++ b/compiler/testData/codegen/box/coroutines/lastUnitExpression.kt @@ -9,6 +9,8 @@ class Controller { operator fun handleResult(u: Unit, v: Continuation) { ok = true } + + // INTERCEPT_RESUME_PLACEHOLDER } fun builder(coroutine c: Controller.() -> Continuation): String { diff --git a/compiler/testData/codegen/box/coroutines/manualContinuationImpl.kt b/compiler/testData/codegen/box/coroutines/manualContinuationImpl.kt index 56e64f70550..b424649cac6 100644 --- a/compiler/testData/codegen/box/coroutines/manualContinuationImpl.kt +++ b/compiler/testData/codegen/box/coroutines/manualContinuationImpl.kt @@ -2,6 +2,8 @@ class Controller { suspend fun suspendHere(x: Continuation) { x.resume("OK") } + + // INTERCEPT_RESUME_PLACEHOLDER } fun builder(coroutine c: Controller.() -> Continuation) { diff --git a/compiler/testData/codegen/box/coroutines/multiModule/simple.kt b/compiler/testData/codegen/box/coroutines/multiModule/simple.kt index c479879f386..ee35053ca86 100644 --- a/compiler/testData/codegen/box/coroutines/multiModule/simple.kt +++ b/compiler/testData/codegen/box/coroutines/multiModule/simple.kt @@ -6,6 +6,8 @@ class Controller { suspend fun suspendHere(x: Continuation) { x.resume("OK") } + + // INTERCEPT_RESUME_PLACEHOLDER } // MODULE: main(controller) diff --git a/compiler/testData/codegen/box/coroutines/multiModule/suspendExtension.kt b/compiler/testData/codegen/box/coroutines/multiModule/suspendExtension.kt index 492805aac7d..1fcaa7bb796 100644 --- a/compiler/testData/codegen/box/coroutines/multiModule/suspendExtension.kt +++ b/compiler/testData/codegen/box/coroutines/multiModule/suspendExtension.kt @@ -11,6 +11,8 @@ class Controller { inline suspend fun String.inlineSuspendHere(x: Continuation) { suspendHere(x) } + + // INTERCEPT_RESUME_PLACEHOLDER } suspend fun Controller.suspendExtension(v: String, x: Continuation) { diff --git a/compiler/testData/codegen/box/coroutines/multipleInvokeCalls.kt b/compiler/testData/codegen/box/coroutines/multipleInvokeCalls.kt index f9a28899110..8e49083773e 100644 --- a/compiler/testData/codegen/box/coroutines/multipleInvokeCalls.kt +++ b/compiler/testData/codegen/box/coroutines/multipleInvokeCalls.kt @@ -11,6 +11,8 @@ class Controller { lastSuspension = null x.resume("56") } + + // INTERCEPT_RESUME_PLACEHOLDER } fun builder(coroutine c: Controller.() -> Continuation) { diff --git a/compiler/testData/codegen/box/coroutines/multipleInvokeCallsInsideInlineLambda1.kt b/compiler/testData/codegen/box/coroutines/multipleInvokeCallsInsideInlineLambda1.kt index 75a2a71e1d1..c793ce03b05 100644 --- a/compiler/testData/codegen/box/coroutines/multipleInvokeCallsInsideInlineLambda1.kt +++ b/compiler/testData/codegen/box/coroutines/multipleInvokeCallsInsideInlineLambda1.kt @@ -11,6 +11,8 @@ class Controller { lastSuspension = null x.resume("56") } + + // INTERCEPT_RESUME_PLACEHOLDER } fun builder(coroutine c: Controller.() -> Continuation) { diff --git a/compiler/testData/codegen/box/coroutines/multipleInvokeCallsInsideInlineLambda2.kt b/compiler/testData/codegen/box/coroutines/multipleInvokeCallsInsideInlineLambda2.kt index d2e93661f23..4df1a8a1532 100644 --- a/compiler/testData/codegen/box/coroutines/multipleInvokeCallsInsideInlineLambda2.kt +++ b/compiler/testData/codegen/box/coroutines/multipleInvokeCallsInsideInlineLambda2.kt @@ -11,6 +11,8 @@ class Controller { lastSuspension = null x.resume("56") } + + // INTERCEPT_RESUME_PLACEHOLDER } fun builder(coroutine c: Controller.() -> Continuation) { diff --git a/compiler/testData/codegen/box/coroutines/multipleInvokeCallsInsideInlineLambda3.kt b/compiler/testData/codegen/box/coroutines/multipleInvokeCallsInsideInlineLambda3.kt index a54bf7ae7af..f7f728e0639 100644 --- a/compiler/testData/codegen/box/coroutines/multipleInvokeCallsInsideInlineLambda3.kt +++ b/compiler/testData/codegen/box/coroutines/multipleInvokeCallsInsideInlineLambda3.kt @@ -11,6 +11,8 @@ class Controller { lastSuspension = null x.resume("56") } + + // INTERCEPT_RESUME_PLACEHOLDER } fun builder(coroutine c: Controller.() -> Continuation) { diff --git a/compiler/testData/codegen/box/coroutines/nestedTryCatch.kt b/compiler/testData/codegen/box/coroutines/nestedTryCatch.kt index 1475c7aec62..3671921ae3f 100644 --- a/compiler/testData/codegen/box/coroutines/nestedTryCatch.kt +++ b/compiler/testData/codegen/box/coroutines/nestedTryCatch.kt @@ -27,6 +27,8 @@ class Controller { postponedActions.removeAt(0) } } + + // INTERCEPT_RESUME_PLACEHOLDER } fun builder(expectException: Boolean = false, coroutine c: Controller.() -> Continuation) { diff --git a/compiler/testData/codegen/box/coroutines/noSuspensionPoints.kt b/compiler/testData/codegen/box/coroutines/noSuspensionPoints.kt index 03da19b5897..d95c3f839a8 100644 --- a/compiler/testData/codegen/box/coroutines/noSuspensionPoints.kt +++ b/compiler/testData/codegen/box/coroutines/noSuspensionPoints.kt @@ -3,6 +3,8 @@ class Controller { operator fun handleResult(x: Int, y: Continuation) { res = x } + + // INTERCEPT_RESUME_PLACEHOLDER } fun builder(coroutine c: Controller.() -> Continuation): Int { diff --git a/compiler/testData/codegen/box/coroutines/nonLocalReturnFromInlineLambda.kt b/compiler/testData/codegen/box/coroutines/nonLocalReturnFromInlineLambda.kt index fa43e81de5d..5239de89163 100644 --- a/compiler/testData/codegen/box/coroutines/nonLocalReturnFromInlineLambda.kt +++ b/compiler/testData/codegen/box/coroutines/nonLocalReturnFromInlineLambda.kt @@ -7,6 +7,8 @@ class Controller { operator fun handleResult(x: Int, y: Continuation) { cResult = x } + + // INTERCEPT_RESUME_PLACEHOLDER } fun builder(coroutine c: Controller.() -> Continuation): Controller { diff --git a/compiler/testData/codegen/box/coroutines/nonLocalReturnFromInlineLambdaDeep.kt b/compiler/testData/codegen/box/coroutines/nonLocalReturnFromInlineLambdaDeep.kt index 8075f9b3a96..56a49681320 100644 --- a/compiler/testData/codegen/box/coroutines/nonLocalReturnFromInlineLambdaDeep.kt +++ b/compiler/testData/codegen/box/coroutines/nonLocalReturnFromInlineLambdaDeep.kt @@ -9,6 +9,8 @@ class Controller { operator fun handleResult(x: Int, y: Continuation) { cResult = x } + + // INTERCEPT_RESUME_PLACEHOLDER } fun builder(coroutine c: Controller.() -> Continuation): Controller { diff --git a/compiler/testData/codegen/box/coroutines/returnByLabel.kt b/compiler/testData/codegen/box/coroutines/returnByLabel.kt index 0ac5d8cfbbc..d41ada18134 100644 --- a/compiler/testData/codegen/box/coroutines/returnByLabel.kt +++ b/compiler/testData/codegen/box/coroutines/returnByLabel.kt @@ -7,6 +7,8 @@ class Controller { operator fun handleResult(x: Int, y: Continuation) { res = x } + + // INTERCEPT_RESUME_PLACEHOLDER } fun builder(coroutine c: Controller.() -> Continuation): Int { diff --git a/compiler/testData/codegen/box/coroutines/simple.kt b/compiler/testData/codegen/box/coroutines/simple.kt index 05dc60e0c70..3fb38062032 100644 --- a/compiler/testData/codegen/box/coroutines/simple.kt +++ b/compiler/testData/codegen/box/coroutines/simple.kt @@ -2,6 +2,8 @@ class Controller { suspend fun suspendHere(x: Continuation) { x.resume("OK") } + + // INTERCEPT_RESUME_PLACEHOLDER } fun builder(coroutine c: Controller.() -> Continuation) { diff --git a/compiler/testData/codegen/box/coroutines/simpleException.kt b/compiler/testData/codegen/box/coroutines/simpleException.kt index d84b75ac988..36f31cfa127 100644 --- a/compiler/testData/codegen/box/coroutines/simpleException.kt +++ b/compiler/testData/codegen/box/coroutines/simpleException.kt @@ -2,6 +2,8 @@ class Controller { suspend fun suspendHere(x: Continuation) { x.resumeWithException(RuntimeException("OK")) } + + // INTERCEPT_RESUME_PLACEHOLDER } fun builder(coroutine c: Controller.() -> Continuation) { diff --git a/compiler/testData/codegen/box/coroutines/simpleWithHandleResult.kt b/compiler/testData/codegen/box/coroutines/simpleWithHandleResult.kt index 647b98aaaf3..bc07190ea21 100644 --- a/compiler/testData/codegen/box/coroutines/simpleWithHandleResult.kt +++ b/compiler/testData/codegen/box/coroutines/simpleWithHandleResult.kt @@ -7,6 +7,8 @@ class Controller { operator fun handleResult(x: Int, y: Continuation) { res = x } + + // INTERCEPT_RESUME_PLACEHOLDER } fun builder(coroutine c: Controller.() -> Continuation): Int { diff --git a/compiler/testData/codegen/box/coroutines/statementLikeLastExpression.kt b/compiler/testData/codegen/box/coroutines/statementLikeLastExpression.kt index 6b3e8fe3be9..d12f254df89 100644 --- a/compiler/testData/codegen/box/coroutines/statementLikeLastExpression.kt +++ b/compiler/testData/codegen/box/coroutines/statementLikeLastExpression.kt @@ -7,6 +7,8 @@ class Controller { operator fun handleResult(x: String, c: Continuation) { globalResult = x } + + // INTERCEPT_RESUME_PLACEHOLDER } fun builder(coroutine c: Controller.() -> Continuation) { diff --git a/compiler/testData/codegen/box/coroutines/suspendDelegation.kt b/compiler/testData/codegen/box/coroutines/suspendDelegation.kt index 361b65d1d3c..81d31ab79e1 100644 --- a/compiler/testData/codegen/box/coroutines/suspendDelegation.kt +++ b/compiler/testData/codegen/box/coroutines/suspendDelegation.kt @@ -6,6 +6,8 @@ class Controller { suspend fun suspendThere(x: Continuation) { x.resume("OK") } + + // INTERCEPT_RESUME_PLACEHOLDER } fun builder(coroutine c: Controller.() -> Continuation) { diff --git a/compiler/testData/codegen/box/coroutines/suspendExtension.kt b/compiler/testData/codegen/box/coroutines/suspendExtension.kt index 6293cfee91b..4e3e9532c52 100644 --- a/compiler/testData/codegen/box/coroutines/suspendExtension.kt +++ b/compiler/testData/codegen/box/coroutines/suspendExtension.kt @@ -7,6 +7,8 @@ class Controller { inline suspend fun String.inlineSuspendHere(x: Continuation) { suspendHere(x) } + + // INTERCEPT_RESUME_PLACEHOLDER } suspend fun Controller.suspendExtension(v: String, x: Continuation) { diff --git a/compiler/testData/codegen/box/coroutines/suspendFromInlineLambda.kt b/compiler/testData/codegen/box/coroutines/suspendFromInlineLambda.kt index 05af6e01711..f8dc2ce4a00 100644 --- a/compiler/testData/codegen/box/coroutines/suspendFromInlineLambda.kt +++ b/compiler/testData/codegen/box/coroutines/suspendFromInlineLambda.kt @@ -2,6 +2,8 @@ class Controller { suspend fun suspendHere(v: Int, x: Continuation) { x.resume(v * 2) } + + // INTERCEPT_RESUME_PLACEHOLDER } fun builder(coroutine c: Controller.() -> Continuation) { diff --git a/compiler/testData/codegen/box/coroutines/suspendInCycle.kt b/compiler/testData/codegen/box/coroutines/suspendInCycle.kt index b3d3b99b6c9..977f16eda70 100644 --- a/compiler/testData/codegen/box/coroutines/suspendInCycle.kt +++ b/compiler/testData/codegen/box/coroutines/suspendInCycle.kt @@ -6,6 +6,8 @@ class Controller { suspend fun suspendThere(x: Continuation) { x.resume("?") } + + // INTERCEPT_RESUME_PLACEHOLDER } fun builder(coroutine c: Controller.() -> Continuation) { diff --git a/compiler/testData/codegen/box/coroutines/suspendInTheMiddleOfObjectConstruction.kt b/compiler/testData/codegen/box/coroutines/suspendInTheMiddleOfObjectConstruction.kt index 3d45dab49f7..99bb5c89253 100644 --- a/compiler/testData/codegen/box/coroutines/suspendInTheMiddleOfObjectConstruction.kt +++ b/compiler/testData/codegen/box/coroutines/suspendInTheMiddleOfObjectConstruction.kt @@ -10,6 +10,8 @@ class Controller { suspend fun suspendWithDouble(v: Double, x: Continuation) { x.resume(v) } + + // INTERCEPT_RESUME_PLACEHOLDER } fun builder(coroutine c: Controller.() -> Continuation) { diff --git a/compiler/testData/codegen/box/coroutines/tryCatchFinallyWithHandleResult.kt b/compiler/testData/codegen/box/coroutines/tryCatchFinallyWithHandleResult.kt index 67759e8ca84..590325fb0d6 100644 --- a/compiler/testData/codegen/box/coroutines/tryCatchFinallyWithHandleResult.kt +++ b/compiler/testData/codegen/box/coroutines/tryCatchFinallyWithHandleResult.kt @@ -27,6 +27,8 @@ class Controller { postponedActions.removeAt(0) } } + + // INTERCEPT_RESUME_PLACEHOLDER } fun builder(expectException: Boolean = false, coroutine c: Controller.() -> Continuation) { diff --git a/compiler/testData/codegen/box/coroutines/tryCatchWithHandleResult.kt b/compiler/testData/codegen/box/coroutines/tryCatchWithHandleResult.kt index 0d22aec8bb1..6c32812b848 100644 --- a/compiler/testData/codegen/box/coroutines/tryCatchWithHandleResult.kt +++ b/compiler/testData/codegen/box/coroutines/tryCatchWithHandleResult.kt @@ -27,6 +27,8 @@ class Controller { postponedActions.removeAt(0) } } + + // INTERCEPT_RESUME_PLACEHOLDER } fun builder(expectException: Boolean = false, coroutine c: Controller.() -> Continuation) { diff --git a/compiler/testData/codegen/box/coroutines/tryFinallyInsideInlineLambda.kt b/compiler/testData/codegen/box/coroutines/tryFinallyInsideInlineLambda.kt index 4bbd39697cf..8be989f0d34 100644 --- a/compiler/testData/codegen/box/coroutines/tryFinallyInsideInlineLambda.kt +++ b/compiler/testData/codegen/box/coroutines/tryFinallyInsideInlineLambda.kt @@ -2,6 +2,8 @@ class Controller { suspend fun suspendHere(v: String, x: Continuation) { x.resume(v) } + + // INTERCEPT_RESUME_PLACEHOLDER } fun builder(coroutine c: Controller.() -> Continuation) { diff --git a/compiler/testData/codegen/box/coroutines/tryFinallyWithHandleResult.kt b/compiler/testData/codegen/box/coroutines/tryFinallyWithHandleResult.kt index ecb47dbd848..395056e9ab3 100644 --- a/compiler/testData/codegen/box/coroutines/tryFinallyWithHandleResult.kt +++ b/compiler/testData/codegen/box/coroutines/tryFinallyWithHandleResult.kt @@ -27,6 +27,8 @@ class Controller { postponedActions.removeAt(0) } } + + // INTERCEPT_RESUME_PLACEHOLDER } fun builder(expectException: Boolean = false, coroutine c: Controller.() -> Continuation) { diff --git a/compiler/testData/codegen/box/coroutines/varValueConflictsWithTable.kt b/compiler/testData/codegen/box/coroutines/varValueConflictsWithTable.kt index 798641da29a..04d0d082b8a 100644 --- a/compiler/testData/codegen/box/coroutines/varValueConflictsWithTable.kt +++ b/compiler/testData/codegen/box/coroutines/varValueConflictsWithTable.kt @@ -2,6 +2,8 @@ class Controller { suspend fun suspendHere(x: Continuation) { x.resume("OK") } + + // INTERCEPT_RESUME_PLACEHOLDER } fun builder(coroutine c: Controller.() -> Continuation) { diff --git a/compiler/testData/codegen/box/coroutines/varValueConflictsWithTableSameSort.kt b/compiler/testData/codegen/box/coroutines/varValueConflictsWithTableSameSort.kt index 29a3eb3136d..b77bf58abd4 100644 --- a/compiler/testData/codegen/box/coroutines/varValueConflictsWithTableSameSort.kt +++ b/compiler/testData/codegen/box/coroutines/varValueConflictsWithTableSameSort.kt @@ -2,6 +2,8 @@ class Controller { suspend fun suspendHere(x: Continuation) { x.resume("OK") } + + // INTERCEPT_RESUME_PLACEHOLDER } fun builder(coroutine c: Controller.() -> Continuation) { diff --git a/compiler/tests-common/org/jetbrains/kotlin/test/KotlinTestUtils.java b/compiler/tests-common/org/jetbrains/kotlin/test/KotlinTestUtils.java index 5258346729b..1803c872ca4 100644 --- a/compiler/tests-common/org/jetbrains/kotlin/test/KotlinTestUtils.java +++ b/compiler/tests-common/org/jetbrains/kotlin/test/KotlinTestUtils.java @@ -863,13 +863,24 @@ public class KotlinTestUtils { assertTestClassPresentByMetadata(testCaseClass, file); } } - else if (filenamePattern.matcher(file.getName()).matches() && isCompatibleTarget(targetBackend, file)) { + else if (filenamePattern.matcher(file.getName()).matches() && isCompatibleTarget(targetBackend, file) && + !isThereCustomReasonToSkip(file, testCaseClass)) { assertFilePathPresent(file, rootFile, filePaths); } } } } + private static boolean isThereCustomReasonToSkip(File file, Class aClass) { + if (!aClass.getSuperclass().getSimpleName().equals("AbstractAdditionalCoroutineBlackBoxCodegenTest")) return false; + try { + return InTextDirectivesUtils.isDirectiveDefined(FileUtil.loadFile(file), "// NO_INTERCEPT_RESUME_TESTS"); + } + catch (IOException e) { + throw new RuntimeException(e); + } + } + public static void assertAllTestsPresentInSingleGeneratedClass( @NotNull Class testCaseClass, @NotNull File testDataDir, diff --git a/compiler/tests/org/jetbrains/kotlin/code/ModulesDependenciesTest.kt b/compiler/tests/org/jetbrains/kotlin/code/ModulesDependenciesTest.kt index aa51b6277f2..07da2b71222 100644 --- a/compiler/tests/org/jetbrains/kotlin/code/ModulesDependenciesTest.kt +++ b/compiler/tests/org/jetbrains/kotlin/code/ModulesDependenciesTest.kt @@ -27,13 +27,15 @@ class ModulesDependenciesTest : TestCase() { val GENERATORS_MODULE_FILE = File("generators/generators.iml") val COMPILER_TESTS_JAVA8_MODULE_FILE = File("compiler/tests-java8/compiler-tests-java8.iml") val NON_COMPILER_TESTS_MODULE_FILE = File("non-compiler-tests/non-compiler-tests.iml") + val ANDROID_TESTS_MODULE_FILE = File("compiler/android-tests/android-tests.iml") val COMPILER_TESTS_MODULE_NAME = COMPILER_TESTS_MODULE_FILE.nameWithoutExtension - val MODULES_CAN_DEPEND_ON_COMPILER_TESTS = listOf(COMPILER_TESTS_JAVA8_MODULE_FILE, GENERATORS_MODULE_FILE) + val MODULES_CAN_DEPEND_ON_COMPILER_TESTS = listOf(COMPILER_TESTS_JAVA8_MODULE_FILE, GENERATORS_MODULE_FILE, ANDROID_TESTS_MODULE_FILE) fun testModulesPresent() { val modules = listOf( - COMPILER_TESTS_MODULE_FILE, GENERATORS_MODULE_FILE, COMPILER_TESTS_JAVA8_MODULE_FILE, NON_COMPILER_TESTS_MODULE_FILE + COMPILER_TESTS_MODULE_FILE, GENERATORS_MODULE_FILE, COMPILER_TESTS_JAVA8_MODULE_FILE, NON_COMPILER_TESTS_MODULE_FILE, + ANDROID_TESTS_MODULE_FILE ) for (module in modules) { diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/AbstractAdditionalCoroutineBlackBoxCodegenTest.kt b/compiler/tests/org/jetbrains/kotlin/codegen/AbstractAdditionalCoroutineBlackBoxCodegenTest.kt new file mode 100644 index 00000000000..9463e9295f6 --- /dev/null +++ b/compiler/tests/org/jetbrains/kotlin/codegen/AbstractAdditionalCoroutineBlackBoxCodegenTest.kt @@ -0,0 +1,120 @@ +/* + * Copyright 2010-2016 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.codegen + +import org.junit.Assert +import java.io.File + +abstract class AbstractAdditionalCoroutineBlackBoxCodegenTest : AbstractBlackBoxCodegenTest() { + companion object { + private val callLambda = """ + | operator inline fun interceptResume(crossinline x: () -> Unit) { + | x() + | } + """.trimMargin() + + private val sendToLambda = """ + | operator inline fun interceptResume(crossinline x: () -> Unit) { + | myInvokeLater { x() } + | } + | + | fun myInvokeLater(block: () -> Unit) { + | block() + | } + """.trimMargin() + + private val makeRunnableSamConstructor = """ + | operator inline fun interceptResume(crossinline x: () -> Unit) { + | myInvokeLater(Runnable { x() }) + | } + | + | fun myInvokeLater(r: java.lang.Runnable) { + | r.run() + | } + """.trimMargin() + + private val makeRunnableSamAdapter = """ + | operator inline fun interceptResume(crossinline x: () -> Unit) { + | val t = Thread { x() } + | t.run() // run in same Thread + | } + | + """.trimMargin() + + // That's how asyncUI's implementation should look like (but it should call SwingUtilities.invokeLater instead if Thread) + private val bothSamAndPlainExecution1 = """ + | val TRUE = hashCode() % 2 == 0 || hashCode() xor 1 == 1 + | operator inline fun interceptResume(crossinline x: () -> Unit) { + | if (TRUE) { + | x() + | } else { + | val t = Thread { x() } + | t.run() + | } + | } + | + """.trimMargin() + + private val bothSamAndPlainExecution2 = """ + | val FALSE = !(hashCode() % 2 == 0 || hashCode() xor 1 == 1) + | operator inline fun interceptResume(crossinline x: () -> Unit) { + | if (FALSE) { + | x() + | } else { + | val t = Thread { x() } + | t.run() + | } + | } + | + """.trimMargin() + + private val noInline = """ + | operator fun interceptResume(x: () -> Unit) { + | x() + | } + """.trimMargin() + + @JvmField + val ALL_REPLACEMENTS = + listOf(callLambda, sendToLambda, makeRunnableSamConstructor, makeRunnableSamAdapter, bothSamAndPlainExecution1, + bothSamAndPlainExecution2, noInline + ) + + const val INTERCEPT_RESUME_PLACEHOLDER = "// INTERCEPT_RESUME_PLACEHOLDER" + } + + override fun doMultiFileTest(wholeFile: File, files: MutableList, javaFilesDir: File?) { + // add "// NO_INTERCEPT_RESUME_TESTS" directive and run "Generate tests" + // if you think that interceptResume is irrelevant for the test + Assert.assertTrue("No placeholder in $wholeFile", files.any { it.content.contains(INTERCEPT_RESUME_PLACEHOLDER) }) + for (replacement in ALL_REPLACEMENTS) { + + try { + super.doMultiFileTest( + wholeFile, + files.map { TestFile(it.name, it.content.replace(INTERCEPT_RESUME_PLACEHOLDER, replacement)) }, + javaFilesDir + ) + } + catch(t: Throwable) { + throw RuntimeException("Fail for replacement: \n$replacement", t) + } + + this.initializedClassLoader = null + } + } +} diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/AdditionalCoroutineBlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/AdditionalCoroutineBlackBoxCodegenTestGenerated.java new file mode 100644 index 00000000000..56242791130 --- /dev/null +++ b/compiler/tests/org/jetbrains/kotlin/codegen/AdditionalCoroutineBlackBoxCodegenTestGenerated.java @@ -0,0 +1,426 @@ +/* + * Copyright 2010-2016 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.codegen; + +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/box/coroutines") +@TestDataPath("$PROJECT_ROOT") +@RunWith(JUnit3RunnerWithInners.class) +public class AdditionalCoroutineBlackBoxCodegenTestGenerated extends AbstractAdditionalCoroutineBlackBoxCodegenTest { + public void testAllFilesPresentInCoroutines() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/coroutines"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true); + } + + @TestMetadata("beginWithException.kt") + public void testBeginWithException() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/beginWithException.kt"); + doTest(fileName); + } + + @TestMetadata("beginWithExceptionNoHandleException.kt") + public void testBeginWithExceptionNoHandleException() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/beginWithExceptionNoHandleException.kt"); + doTest(fileName); + } + + @TestMetadata("coercionToUnit.kt") + public void testCoercionToUnit() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/coercionToUnit.kt"); + doTest(fileName); + } + + @TestMetadata("controllerAccessFromInnerLambda.kt") + public void testControllerAccessFromInnerLambda() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/controllerAccessFromInnerLambda.kt"); + doTest(fileName); + } + + @TestMetadata("defaultParametersInSuspend.kt") + public void testDefaultParametersInSuspend() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/defaultParametersInSuspend.kt"); + doTest(fileName); + } + + @TestMetadata("emptyClosure.kt") + public void testEmptyClosure() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/emptyClosure.kt"); + doTest(fileName); + } + + @TestMetadata("falseUnitCoercion.kt") + public void testFalseUnitCoercion() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/falseUnitCoercion.kt"); + doTest(fileName); + } + + @TestMetadata("generate.kt") + public void testGenerate() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/generate.kt"); + doTest(fileName); + } + + @TestMetadata("handleException.kt") + public void testHandleException() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/handleException.kt"); + doTest(fileName); + } + + @TestMetadata("handleResultCallEmptyBody.kt") + public void testHandleResultCallEmptyBody() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/handleResultCallEmptyBody.kt"); + doTest(fileName); + } + + @TestMetadata("handleResultNonUnitExpression.kt") + public void testHandleResultNonUnitExpression() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/handleResultNonUnitExpression.kt"); + doTest(fileName); + } + + @TestMetadata("handleResultSuspended.kt") + public void testHandleResultSuspended() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/handleResultSuspended.kt"); + doTest(fileName); + } + + @TestMetadata("inlineSuspendFunction.kt") + public void testInlineSuspendFunction() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/inlineSuspendFunction.kt"); + doTest(fileName); + } + + @TestMetadata("inlinedTryCatchFinally.kt") + public void testInlinedTryCatchFinally() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/inlinedTryCatchFinally.kt"); + doTest(fileName); + } + + @TestMetadata("innerSuspensionCalls.kt") + public void testInnerSuspensionCalls() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/innerSuspensionCalls.kt"); + doTest(fileName); + } + + @TestMetadata("instanceOfContinuation.kt") + public void testInstanceOfContinuation() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/instanceOfContinuation.kt"); + doTest(fileName); + } + + @TestMetadata("iterateOverArray.kt") + public void testIterateOverArray() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/iterateOverArray.kt"); + doTest(fileName); + } + + @TestMetadata("kt12958.kt") + public void testKt12958() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/kt12958.kt"); + doTest(fileName); + } + + @TestMetadata("lambdaParameters.kt") + public void testLambdaParameters() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/lambdaParameters.kt"); + doTest(fileName); + } + + @TestMetadata("lastExpressionIsLoop.kt") + public void testLastExpressionIsLoop() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/lastExpressionIsLoop.kt"); + doTest(fileName); + } + + @TestMetadata("lastStatementInc.kt") + public void testLastStatementInc() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/lastStatementInc.kt"); + doTest(fileName); + } + + @TestMetadata("lastStementAssignment.kt") + public void testLastStementAssignment() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/lastStementAssignment.kt"); + doTest(fileName); + } + + @TestMetadata("lastUnitExpression.kt") + public void testLastUnitExpression() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/lastUnitExpression.kt"); + doTest(fileName); + } + + @TestMetadata("manualContinuationImpl.kt") + public void testManualContinuationImpl() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/manualContinuationImpl.kt"); + doTest(fileName); + } + + @TestMetadata("multipleInvokeCalls.kt") + public void testMultipleInvokeCalls() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/multipleInvokeCalls.kt"); + doTest(fileName); + } + + @TestMetadata("multipleInvokeCallsInsideInlineLambda1.kt") + public void testMultipleInvokeCallsInsideInlineLambda1() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/multipleInvokeCallsInsideInlineLambda1.kt"); + doTest(fileName); + } + + @TestMetadata("multipleInvokeCallsInsideInlineLambda2.kt") + public void testMultipleInvokeCallsInsideInlineLambda2() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/multipleInvokeCallsInsideInlineLambda2.kt"); + doTest(fileName); + } + + @TestMetadata("multipleInvokeCallsInsideInlineLambda3.kt") + public void testMultipleInvokeCallsInsideInlineLambda3() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/multipleInvokeCallsInsideInlineLambda3.kt"); + doTest(fileName); + } + + @TestMetadata("nestedTryCatch.kt") + public void testNestedTryCatch() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/nestedTryCatch.kt"); + doTest(fileName); + } + + @TestMetadata("noSuspensionPoints.kt") + public void testNoSuspensionPoints() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/noSuspensionPoints.kt"); + doTest(fileName); + } + + @TestMetadata("nonLocalReturnFromInlineLambda.kt") + public void testNonLocalReturnFromInlineLambda() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/nonLocalReturnFromInlineLambda.kt"); + doTest(fileName); + } + + @TestMetadata("nonLocalReturnFromInlineLambdaDeep.kt") + public void testNonLocalReturnFromInlineLambdaDeep() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/nonLocalReturnFromInlineLambdaDeep.kt"); + doTest(fileName); + } + + @TestMetadata("returnByLabel.kt") + public void testReturnByLabel() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/returnByLabel.kt"); + doTest(fileName); + } + + @TestMetadata("simple.kt") + public void testSimple() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/simple.kt"); + doTest(fileName); + } + + @TestMetadata("simpleException.kt") + public void testSimpleException() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/simpleException.kt"); + doTest(fileName); + } + + @TestMetadata("simpleWithHandleResult.kt") + public void testSimpleWithHandleResult() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/simpleWithHandleResult.kt"); + doTest(fileName); + } + + @TestMetadata("statementLikeLastExpression.kt") + public void testStatementLikeLastExpression() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/statementLikeLastExpression.kt"); + doTest(fileName); + } + + @TestMetadata("suspendDelegation.kt") + public void testSuspendDelegation() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/suspendDelegation.kt"); + doTest(fileName); + } + + @TestMetadata("suspendExtension.kt") + public void testSuspendExtension() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/suspendExtension.kt"); + doTest(fileName); + } + + @TestMetadata("suspendFromInlineLambda.kt") + public void testSuspendFromInlineLambda() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/suspendFromInlineLambda.kt"); + doTest(fileName); + } + + @TestMetadata("suspendInCycle.kt") + public void testSuspendInCycle() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/suspendInCycle.kt"); + doTest(fileName); + } + + @TestMetadata("suspendInTheMiddleOfObjectConstruction.kt") + public void testSuspendInTheMiddleOfObjectConstruction() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/suspendInTheMiddleOfObjectConstruction.kt"); + doTest(fileName); + } + + @TestMetadata("tryCatchFinallyWithHandleResult.kt") + public void testTryCatchFinallyWithHandleResult() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/tryCatchFinallyWithHandleResult.kt"); + doTest(fileName); + } + + @TestMetadata("tryCatchWithHandleResult.kt") + public void testTryCatchWithHandleResult() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/tryCatchWithHandleResult.kt"); + doTest(fileName); + } + + @TestMetadata("tryFinallyInsideInlineLambda.kt") + public void testTryFinallyInsideInlineLambda() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/tryFinallyInsideInlineLambda.kt"); + doTest(fileName); + } + + @TestMetadata("tryFinallyWithHandleResult.kt") + public void testTryFinallyWithHandleResult() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/tryFinallyWithHandleResult.kt"); + doTest(fileName); + } + + @TestMetadata("varValueConflictsWithTable.kt") + public void testVarValueConflictsWithTable() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/varValueConflictsWithTable.kt"); + doTest(fileName); + } + + @TestMetadata("varValueConflictsWithTableSameSort.kt") + public void testVarValueConflictsWithTableSameSort() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/varValueConflictsWithTableSameSort.kt"); + doTest(fileName); + } + + @TestMetadata("compiler/testData/codegen/box/coroutines/controlFlow") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ControlFlow extends AbstractAdditionalCoroutineBlackBoxCodegenTest { + public void testAllFilesPresentInControlFlow() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/coroutines/controlFlow"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true); + } + + } + + @TestMetadata("compiler/testData/codegen/box/coroutines/intLikeVarSpilling") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class IntLikeVarSpilling extends AbstractAdditionalCoroutineBlackBoxCodegenTest { + public void testAllFilesPresentInIntLikeVarSpilling() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/coroutines/intLikeVarSpilling"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true); + } + + @TestMetadata("complicatedMerge.kt") + public void testComplicatedMerge() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/intLikeVarSpilling/complicatedMerge.kt"); + doTest(fileName); + } + + @TestMetadata("i2bResult.kt") + public void testI2bResult() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/intLikeVarSpilling/i2bResult.kt"); + doTest(fileName); + } + + @TestMetadata("loadFromBooleanArray.kt") + public void testLoadFromBooleanArray() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/intLikeVarSpilling/loadFromBooleanArray.kt"); + doTest(fileName); + } + + @TestMetadata("loadFromByteArray.kt") + public void testLoadFromByteArray() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/intLikeVarSpilling/loadFromByteArray.kt"); + doTest(fileName); + } + + @TestMetadata("noVariableInTable.kt") + public void testNoVariableInTable() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/intLikeVarSpilling/noVariableInTable.kt"); + doTest(fileName); + } + + @TestMetadata("sameIconst1ManyVars.kt") + public void testSameIconst1ManyVars() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/intLikeVarSpilling/sameIconst1ManyVars.kt"); + doTest(fileName); + } + + @TestMetadata("usedInArrayStore.kt") + public void testUsedInArrayStore() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/intLikeVarSpilling/usedInArrayStore.kt"); + doTest(fileName); + } + + @TestMetadata("usedInMethodCall.kt") + public void testUsedInMethodCall() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/intLikeVarSpilling/usedInMethodCall.kt"); + doTest(fileName); + } + + @TestMetadata("usedInPutfield.kt") + public void testUsedInPutfield() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/intLikeVarSpilling/usedInPutfield.kt"); + doTest(fileName); + } + + @TestMetadata("usedInVarStore.kt") + public void testUsedInVarStore() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/intLikeVarSpilling/usedInVarStore.kt"); + doTest(fileName); + } + } + + @TestMetadata("compiler/testData/codegen/box/coroutines/multiModule") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class MultiModule extends AbstractAdditionalCoroutineBlackBoxCodegenTest { + public void testAllFilesPresentInMultiModule() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/coroutines/multiModule"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true); + } + + @TestMetadata("simple.kt") + public void testSimple() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/multiModule/simple.kt"); + doTest(fileName); + } + + @TestMetadata("suspendExtension.kt") + public void testSuspendExtension() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/multiModule/suspendExtension.kt"); + doTest(fileName); + } + } +} diff --git a/generators/src/org/jetbrains/kotlin/generators/tests/GenerateTests.kt b/generators/src/org/jetbrains/kotlin/generators/tests/GenerateTests.kt index 05a9d612b26..404e225990d 100755 --- a/generators/src/org/jetbrains/kotlin/generators/tests/GenerateTests.kt +++ b/generators/src/org/jetbrains/kotlin/generators/tests/GenerateTests.kt @@ -240,6 +240,10 @@ fun main(args: Array) { model("codegen/boxAgainstJava") } + testClass { + model("codegen/box/coroutines") + } + testClass() { model("codegen/script", extension = "kts") } @@ -1118,7 +1122,7 @@ fun main(args: Array) { testClass() { model("wrappers", recursive = true, extension = "kt") } - + testClass() { model("sourceRetention", extension = "kt") } diff --git a/generators/src/org/jetbrains/kotlin/generators/tests/generator/SimpleTestClassModel.java b/generators/src/org/jetbrains/kotlin/generators/tests/generator/SimpleTestClassModel.java index 33328d0ac78..b57eea85073 100644 --- a/generators/src/org/jetbrains/kotlin/generators/tests/generator/SimpleTestClassModel.java +++ b/generators/src/org/jetbrains/kotlin/generators/tests/generator/SimpleTestClassModel.java @@ -235,7 +235,7 @@ public class SimpleTestClassModel implements TestClassModel { } @Override - public boolean shouldBeGenerated() { + public boolean shouldBeGenerated(@NotNull String baseClassName) { return true; } } diff --git a/generators/src/org/jetbrains/kotlin/generators/tests/generator/SimpleTestMethodModel.java b/generators/src/org/jetbrains/kotlin/generators/tests/generator/SimpleTestMethodModel.java index 72e596523c3..98b93f1e1ec 100644 --- a/generators/src/org/jetbrains/kotlin/generators/tests/generator/SimpleTestMethodModel.java +++ b/generators/src/org/jetbrains/kotlin/generators/tests/generator/SimpleTestMethodModel.java @@ -20,12 +20,14 @@ import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.util.text.StringUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jetbrains.kotlin.codegen.AbstractAdditionalCoroutineBlackBoxCodegenTest; import org.jetbrains.kotlin.test.InTextDirectivesUtils; import org.jetbrains.kotlin.test.KotlinTestUtils; import org.jetbrains.kotlin.test.TargetBackend; import org.jetbrains.kotlin.utils.Printer; import java.io.File; +import java.io.IOException; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -102,8 +104,19 @@ public class SimpleTestMethodModel implements TestMethodModel { } @Override - public boolean shouldBeGenerated() { - return InTextDirectivesUtils.isCompatibleTarget(targetBackend, file); + public boolean shouldBeGenerated(@NotNull String baseClassName) { + if (!InTextDirectivesUtils.isCompatibleTarget(targetBackend, file)) { + return false; + } + + if (!baseClassName.equals(AbstractAdditionalCoroutineBlackBoxCodegenTest.class.getSimpleName())) return true; + + try { + return !InTextDirectivesUtils.isDirectiveDefined(FileUtil.loadFile(file), "// NO_INTERCEPT_RESUME_TESTS"); + } + catch (IOException e) { + throw new RuntimeException(e); + } } @NotNull diff --git a/generators/src/org/jetbrains/kotlin/generators/tests/generator/SingleClassTestModel.java b/generators/src/org/jetbrains/kotlin/generators/tests/generator/SingleClassTestModel.java index 9a57d59655c..eba95adbb78 100644 --- a/generators/src/org/jetbrains/kotlin/generators/tests/generator/SingleClassTestModel.java +++ b/generators/src/org/jetbrains/kotlin/generators/tests/generator/SingleClassTestModel.java @@ -162,7 +162,7 @@ public class SingleClassTestModel implements TestClassModel { } @Override - public boolean shouldBeGenerated() { + public boolean shouldBeGenerated(@NotNull String baseClassName) { return true; } } diff --git a/generators/src/org/jetbrains/kotlin/generators/tests/generator/TestGenerator.java b/generators/src/org/jetbrains/kotlin/generators/tests/generator/TestGenerator.java index 85c0d1f6fe8..42f7fbdcda9 100644 --- a/generators/src/org/jetbrains/kotlin/generators/tests/generator/TestGenerator.java +++ b/generators/src/org/jetbrains/kotlin/generators/tests/generator/TestGenerator.java @@ -164,7 +164,7 @@ public class TestGenerator { for (Iterator iterator = testMethods.iterator(); iterator.hasNext(); ) { MethodModel methodModel = iterator.next(); - if (!methodModel.shouldBeGenerated()) continue; + if (!methodModel.shouldBeGenerated(baseTestClassName)) continue; generateTestMethod(p, methodModel); if (iterator.hasNext() || !innerTestClasses.isEmpty()) { @@ -188,11 +188,11 @@ public class TestGenerator { private static void generateTestMethod(Printer p, MethodModel methodModel) { generateMetadata(p, methodModel); - + methodModel.generateSignature(p); p.printWithNoIndent(" {"); p.println(); - + p.pushIndent(); methodModel.generateBody(p); diff --git a/generators/src/org/jetbrains/kotlin/generators/tests/generator/TestModel.kt b/generators/src/org/jetbrains/kotlin/generators/tests/generator/TestModel.kt index a7826cd4c1a..f9200f11a08 100644 --- a/generators/src/org/jetbrains/kotlin/generators/tests/generator/TestModel.kt +++ b/generators/src/org/jetbrains/kotlin/generators/tests/generator/TestModel.kt @@ -31,7 +31,7 @@ interface TestClassModel : TestEntityModel { } interface MethodModel : TestEntityModel { - fun shouldBeGenerated(): Boolean = true + fun shouldBeGenerated(baseClassName: String): Boolean = true fun generateSignature(p: Printer) fun generateBody(p: Printer) } @@ -40,4 +40,4 @@ interface TestMethodModel : MethodModel { override fun generateSignature(p: Printer) { p.print("public void $name() throws Exception") } -} +}