From efec82c0ebcf6ff26b88f6e411785c3df5510f7e Mon Sep 17 00:00:00 2001 From: Roman Artemev Date: Thu, 5 Jul 2018 17:30:40 +0300 Subject: [PATCH] Update test data * add new tests for coroutines * add copy of some tests without dependency on stdlib --- .../withCoroutinesNoStdLib.kt | 48 +++++++ .../catchWithInlineInsideSuspend.kt | 1 - .../coroutines/controlFlow/breakFinally.kt | 15 ++- .../controlFlow/complexChainSuspend.kt | 74 ++++++++++ .../coroutines/controlFlow/finallyCatch.kt | 46 +++++++ .../coroutines/controlFlow/labeledWhile.kt | 1 - .../controlFlow/multipleCatchBlocksSuspend.kt | 44 ++++++ .../controlFlow/returnWithFinally.kt | 1 - .../coroutines/controlFlow/throwFromCatch.kt | 1 - .../controlFlow/throwInTryWithHandleResult.kt | 1 - .../controlFlow/whenWithSuspensions.kt | 1 - .../codegen/box/coroutines/emptyClosure.kt | 1 - .../function/local/equalsHashCode.kt | 4 +- .../callableReference/longArgs.kt | 3 +- .../destructuringInLambdas.kt | 1 + .../safeCallOnTwoReceivers.kt | 1 - .../safeCallOnTwoReceiversLong.kt | 1 - .../suspendOperatorPlus.kt | 1 - .../suspendOperatorPlusAssign.kt | 1 - .../suspendOperatorPlusCallFromLambda.kt | 1 - .../coroutines/handleResultCallEmptyBody.kt | 1 - .../handleResultNonUnitExpression.kt | 1 - .../box/coroutines/handleResultSuspended.kt | 1 - .../indirectInlineUsedAsNonInline.kt | 1 - .../box/coroutines/inlineFunInGenericClass.kt | 1 - .../box/coroutines/innerSuspensionCalls.kt | 1 - .../intLikeVarSpilling/i2bResult.kt | 1 - .../intLikeVarSpilling/sameIconst1ManyVars.kt | 1 - .../intrinsicSemantics/intercepted.kt | 1 - .../intrinsicSemantics/startCoroutine.kt | 1 - .../startCoroutineUninterceptedOrReturn.kt | 1 - ...outineUninterceptedOrReturnInterception.kt | 1 - .../suspendCoroutineUninterceptedOrReturn.kt | 1 - .../codegen/box/coroutines/kt15016.kt | 1 - .../codegen/box/coroutines/kt15017.kt | 1 - .../codegen/box/coroutines/kt15930.kt | 1 - .../codegen/box/coroutines/kt21605.kt | 1 - .../box/coroutines/lastExpressionIsLoop.kt | 1 - .../box/coroutines/lastStatementInc.kt | 1 - .../box/coroutines/lastStementAssignment.kt | 1 - .../box/coroutines/lastUnitExpression.kt | 1 - .../box/coroutines/localCallableRef.kt | 2 +- .../coroutines/localFunctions/named/infix.kt | 1 - .../localFunctions/named/insideLambda.kt | 1 - .../coroutines/localFunctions/named/simple.kt | 1 - .../named/simpleSuspensionPoint.kt | 1 - .../box/coroutines/longRangeInSuspendCall.kt | 1 - .../box/coroutines/longRangeInSuspendFun.kt | 1 - .../box/coroutines/multipleInvokeCalls.kt | 1 - .../box/coroutines/noStdLib/breakFinally.kt | 81 +++++++++++ .../box/coroutines/noStdLib/breakStatement.kt | 67 +++++++++ .../box/coroutines/noStdLib/crossinline.kt | 79 +++++++++++ .../box/coroutines/noStdLib/ifStatement.kt | 89 ++++++++++++ .../box/coroutines/noStdLib/stateMachine.kt | 67 +++++++++ .../box/coroutines/noStdLib/switchLikeWhen.kt | 42 ++++++ .../nonLocalReturnFromInlineLambda.kt | 1 - .../nonLocalReturnFromInlineLambdaDeep.kt | 1 - .../box/coroutines/overrideDefaultArgument.kt | 1 - .../box/coroutines/recursiveSuspend.kt | 1 - .../codegen/box/coroutines/returnByLabel.kt | 1 - .../testData/codegen/box/coroutines/simple.kt | 1 - .../codegen/box/coroutines/simpleException.kt | 1 - .../box/coroutines/simpleWithHandleResult.kt | 1 - .../box/coroutines/stackUnwinding/simple.kt | 1 - .../stackUnwinding/suspendInCycle.kt | 1 - .../coroutines/statementLikeLastExpression.kt | 1 - .../box/coroutines/suspendCallsInArguments.kt | 97 +++++++++++++ .../suspendCoroutineFromStateMachine.kt | 1 - .../box/coroutines/suspendDefaultImpl.kt | 1 - .../box/coroutines/suspendDelegation.kt | 1 - .../box/coroutines/suspendFromInlineLambda.kt | 1 - .../suspendFunImportedFromObject.kt | 1 - .../suspendFunctionAsCoroutine/inline.kt | 1 - .../suspendFunctionAsCoroutine/member.kt | 1 - .../privateInFile.kt | 1 - .../returnNoSuspend.kt | 1 - .../suspendFunctionAsCoroutine/simple.kt | 1 - .../suspendFunctionAsCoroutine/superCall.kt | 1 - .../superCallAbstractClass.kt | 1 - .../superCallInterface.kt | 1 - .../suspendFunctionTypeCall/manyParameters.kt | 1 - .../suspendFunctionTypeCall/simple.kt | 1 - .../codegen/box/coroutines/suspendInCycle.kt | 1 - .../suspendInTheMiddleOfObjectConstruction.kt | 1 - .../coroutines/suspensionInsideSafeCall.kt | 1 - .../suspensionInsideSafeCallWithElvis.kt | 1 - .../inlineWithStateMachine.kt | 1 - .../inlineWithoutStateMachine.kt | 1 - .../tailCallOptimizations/simple.kt | 1 - .../tailCallOptimizations/unreachable.kt | 1 - .../tailCallOptimizations/whenUnit.kt | 1 - .../tailOperations/suspendWithIf.kt | 1 - .../tailOperations/suspendWithTryCatch.kt | 1 - .../tailOperations/suspendWithWhen.kt | 1 - .../coroutines/tailOperations/tailInlining.kt | 1 - .../tryFinallyInsideInlineLambda.kt | 1 - .../unitTypeReturn/suspendNonLocalReturn.kt | 1 - .../unitTypeReturn/suspendReturn.kt | 1 - .../coroutines/varSpilling/nullSpilling.kt | 1 - .../varValueConflictsWithTableSameSort.kt | 1 - .../ranges/forInRangeWithImplicitReceiver.kt | 1 - ...rNullableIntInRangeWithImplicitReceiver.kt | 1 - .../when/whenSubjectVariable/whenByString.kt | 2 +- .../codegen/BlackBoxCodegenTestGenerated.java | 127 ++++++++++++++++++ .../LightAnalysisModeTestGenerated.java | 127 ++++++++++++++++++ .../ir/IrBlackBoxCodegenTestGenerated.java | 127 ++++++++++++++++++ .../IrJsCodegenBoxTestGenerated.java | 72 ++++++++++ .../semantics/JsCodegenBoxTestGenerated.java | 127 ++++++++++++++++++ .../box/coroutines/localVarOptimization.kt | 1 + js/js.translator/testData/testIr.html | 12 ++ 110 files changed, 1349 insertions(+), 91 deletions(-) create mode 100644 compiler/testData/codegen/box/closures/capturedVarsOptimization/withCoroutinesNoStdLib.kt create mode 100644 compiler/testData/codegen/box/coroutines/controlFlow/complexChainSuspend.kt create mode 100644 compiler/testData/codegen/box/coroutines/controlFlow/finallyCatch.kt create mode 100644 compiler/testData/codegen/box/coroutines/controlFlow/multipleCatchBlocksSuspend.kt create mode 100644 compiler/testData/codegen/box/coroutines/noStdLib/breakFinally.kt create mode 100644 compiler/testData/codegen/box/coroutines/noStdLib/breakStatement.kt create mode 100644 compiler/testData/codegen/box/coroutines/noStdLib/crossinline.kt create mode 100644 compiler/testData/codegen/box/coroutines/noStdLib/ifStatement.kt create mode 100644 compiler/testData/codegen/box/coroutines/noStdLib/stateMachine.kt create mode 100644 compiler/testData/codegen/box/coroutines/noStdLib/switchLikeWhen.kt create mode 100644 compiler/testData/codegen/box/coroutines/suspendCallsInArguments.kt create mode 100644 js/js.translator/testData/testIr.html diff --git a/compiler/testData/codegen/box/closures/capturedVarsOptimization/withCoroutinesNoStdLib.kt b/compiler/testData/codegen/box/closures/capturedVarsOptimization/withCoroutinesNoStdLib.kt new file mode 100644 index 00000000000..e232cfcc9dd --- /dev/null +++ b/compiler/testData/codegen/box/closures/capturedVarsOptimization/withCoroutinesNoStdLib.kt @@ -0,0 +1,48 @@ +// IGNORE_BACKEND: JVM_IR +// WITH_RUNTIME +// WITH_COROUTINES +// COMMON_COROUTINES_TEST + +import helpers.* +import COROUTINES_PACKAGE.* +import COROUTINES_PACKAGE.intrinsics.* + + +class Controller { + var result = "" + + suspend fun suspendWithResult(value: T): T = suspendCoroutineUninterceptedOrReturn { c -> + c.resume(value) + COROUTINE_SUSPENDED + } +} + +fun builder(c: suspend Controller.() -> Unit): String { + val controller = Controller() + c.startCoroutine(controller, EmptyContinuation) + return controller.result +} + +fun box(): String { + val value = builder { + var r = "" + + var _i = 0 + while (_i < 3) { + val i = _i++ + val x = if (i == 0) "O" else if (i == 1) "$" else "K" + if (x == "$") continue + run { + r += suspendWithResult(x) + } + } + run { + r += "." + } + result = r + } + + if (value != "OK.") return "fail: suspend in for body: $value" + + return "OK" +} diff --git a/compiler/testData/codegen/box/coroutines/catchWithInlineInsideSuspend.kt b/compiler/testData/codegen/box/coroutines/catchWithInlineInsideSuspend.kt index f63feb61371..d85c4a71145 100644 --- a/compiler/testData/codegen/box/coroutines/catchWithInlineInsideSuspend.kt +++ b/compiler/testData/codegen/box/coroutines/catchWithInlineInsideSuspend.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // IGNORE_BACKEND: JVM_IR // WITH_RUNTIME // WITH_COROUTINES diff --git a/compiler/testData/codegen/box/coroutines/controlFlow/breakFinally.kt b/compiler/testData/codegen/box/coroutines/controlFlow/breakFinally.kt index c046cc280bd..0239d8d4ae3 100644 --- a/compiler/testData/codegen/box/coroutines/controlFlow/breakFinally.kt +++ b/compiler/testData/codegen/box/coroutines/controlFlow/breakFinally.kt @@ -1,4 +1,5 @@ // IGNORE_BACKEND: JS_IR +// IGNORE_BACKEND: JS // IGNORE_BACKEND: JVM_IR // WITH_RUNTIME // WITH_COROUTINES @@ -44,6 +45,18 @@ fun box(): String { } finally { result += "@" + for (y in listOf("F", "G")) { + try { + result += suspendWithResult(z) + if (z == "G") { + break + } + } + finally { + result += "?" + } + result += "H" + } } result += "ignore" } @@ -54,7 +67,7 @@ fun box(): String { } result += "." } - if (value != "AC!ED!@*finally.") return "fail: $value" + if (value != "AC!ED!@F?HG?*finally.") return "fail: $value" return "OK" } diff --git a/compiler/testData/codegen/box/coroutines/controlFlow/complexChainSuspend.kt b/compiler/testData/codegen/box/coroutines/controlFlow/complexChainSuspend.kt new file mode 100644 index 00000000000..0d0b5d18f7a --- /dev/null +++ b/compiler/testData/codegen/box/coroutines/controlFlow/complexChainSuspend.kt @@ -0,0 +1,74 @@ +// IGNORE_BACKEND: JVM_IR +// WITH_RUNTIME +// WITH_COROUTINES +// COMMON_COROUTINES_TEST +import helpers.* +import COROUTINES_PACKAGE.* +import COROUTINES_PACKAGE.intrinsics.* + +class Controller { + var result = "" +} + +suspend fun cleanup() {} + +suspend fun concat(x: String, y: String): String = x + y + +suspend fun throws() { + try { + throw Exception() + } + finally { + cleanup() + } +} + +suspend fun first(x: String, y: String): String = x + +fun builder(c: suspend Controller.() -> Unit): String { + val controller = Controller() + c.startCoroutine(controller, EmptyContinuation) + return controller.result +} + +fun box(): String { + + return builder { + + result = "" + concat( + try { + "" + } finally { + "0" + }, + "" + concat( + first( + try { + try { + "O" + } finally { + "1" + } + } catch (e: Exception) { + throw e + } finally { + cleanup() + }, + "2" + ), + first( + try { + throws() + throw Exception() + "3" + } catch (e: Exception) { + "K" + } finally { + cleanup() + }, + "4" + ) + ) + ) + } +} diff --git a/compiler/testData/codegen/box/coroutines/controlFlow/finallyCatch.kt b/compiler/testData/codegen/box/coroutines/controlFlow/finallyCatch.kt new file mode 100644 index 00000000000..94399889ec4 --- /dev/null +++ b/compiler/testData/codegen/box/coroutines/controlFlow/finallyCatch.kt @@ -0,0 +1,46 @@ +// IGNORE_BACKEND: JS +// IGNORE_BACKEND: JVM_IR +// WITH_RUNTIME +// WITH_COROUTINES +// COMMON_COROUTINES_TEST +import helpers.* +import COROUTINES_PACKAGE.* +import COROUTINES_PACKAGE.intrinsics.* + +class Controller { + var result = "" +} + +suspend fun excs() { throw Exception("!!!") } +suspend fun fff() {} + +suspend fun bars(): String { + var i = 0 + var s = "" + while (i < 3) { + ++i + s += "FAIL$i;" + try { + try { + fff() + return s + } finally { + excs() + } + } catch (x: Exception) { + continue + } + } + + return "OK" +} + +fun builder(c: suspend Controller.() -> Unit): String { + val controller = Controller() + c.startCoroutine(controller, EmptyContinuation) + return controller.result +} + +fun box(): String { + return builder { result = bars() } +} \ No newline at end of file diff --git a/compiler/testData/codegen/box/coroutines/controlFlow/labeledWhile.kt b/compiler/testData/codegen/box/coroutines/controlFlow/labeledWhile.kt index bec775e4df2..0129f59c7d2 100644 --- a/compiler/testData/codegen/box/coroutines/controlFlow/labeledWhile.kt +++ b/compiler/testData/codegen/box/coroutines/controlFlow/labeledWhile.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // IGNORE_BACKEND: JVM_IR // WITH_RUNTIME // WITH_COROUTINES diff --git a/compiler/testData/codegen/box/coroutines/controlFlow/multipleCatchBlocksSuspend.kt b/compiler/testData/codegen/box/coroutines/controlFlow/multipleCatchBlocksSuspend.kt new file mode 100644 index 00000000000..f665ed3601a --- /dev/null +++ b/compiler/testData/codegen/box/coroutines/controlFlow/multipleCatchBlocksSuspend.kt @@ -0,0 +1,44 @@ +// IGNORE_BACKEND: JVM_IR +// WITH_RUNTIME +// WITH_COROUTINES +// COMMON_COROUTINES_TEST +import helpers.* +import COROUTINES_PACKAGE.* +import COROUTINES_PACKAGE.intrinsics.* + +class Controller { + var result = "" +} + +class Exception1(msg: String): Exception(msg) +class Exception2(msg: String): Exception(msg) +class Exception3(msg: String): Exception(msg) + +fun builder(c: suspend Controller.() -> Unit): String { + val controller = Controller() + c.startCoroutine(controller, EmptyContinuation) + return controller.result +} + +suspend fun foo() {} + +fun box(): String { + return builder { + result = "O" + try { + foo() + throw Exception3("K") + } catch (e1: Exception1) { + foo() + "e1" + } catch (e2: Exception2) { + foo() + "e2" + } catch (e3: Exception3) { + foo() + e3.message + } catch (e: Exception) { + foo() + "e" + } + } +} diff --git a/compiler/testData/codegen/box/coroutines/controlFlow/returnWithFinally.kt b/compiler/testData/codegen/box/coroutines/controlFlow/returnWithFinally.kt index 5efe6b15a6c..b0bcc8493f2 100644 --- a/compiler/testData/codegen/box/coroutines/controlFlow/returnWithFinally.kt +++ b/compiler/testData/codegen/box/coroutines/controlFlow/returnWithFinally.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // IGNORE_BACKEND: JVM_IR // WITH_RUNTIME // WITH_COROUTINES diff --git a/compiler/testData/codegen/box/coroutines/controlFlow/throwFromCatch.kt b/compiler/testData/codegen/box/coroutines/controlFlow/throwFromCatch.kt index 4b47db56325..23ee0a32ec8 100644 --- a/compiler/testData/codegen/box/coroutines/controlFlow/throwFromCatch.kt +++ b/compiler/testData/codegen/box/coroutines/controlFlow/throwFromCatch.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // IGNORE_BACKEND: JVM_IR // WITH_RUNTIME // WITH_COROUTINES diff --git a/compiler/testData/codegen/box/coroutines/controlFlow/throwInTryWithHandleResult.kt b/compiler/testData/codegen/box/coroutines/controlFlow/throwInTryWithHandleResult.kt index eeb02805dca..1027c30596c 100644 --- a/compiler/testData/codegen/box/coroutines/controlFlow/throwInTryWithHandleResult.kt +++ b/compiler/testData/codegen/box/coroutines/controlFlow/throwInTryWithHandleResult.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // IGNORE_BACKEND: JVM_IR // WITH_RUNTIME // WITH_COROUTINES diff --git a/compiler/testData/codegen/box/coroutines/controlFlow/whenWithSuspensions.kt b/compiler/testData/codegen/box/coroutines/controlFlow/whenWithSuspensions.kt index 1e8c05f20f8..47ddff0eaf5 100644 --- a/compiler/testData/codegen/box/coroutines/controlFlow/whenWithSuspensions.kt +++ b/compiler/testData/codegen/box/coroutines/controlFlow/whenWithSuspensions.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // IGNORE_BACKEND: JVM_IR // WITH_RUNTIME // WITH_COROUTINES diff --git a/compiler/testData/codegen/box/coroutines/emptyClosure.kt b/compiler/testData/codegen/box/coroutines/emptyClosure.kt index 6b52a798628..aa23dc71bbd 100644 --- a/compiler/testData/codegen/box/coroutines/emptyClosure.kt +++ b/compiler/testData/codegen/box/coroutines/emptyClosure.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // IGNORE_BACKEND: JVM_IR // WITH_RUNTIME // WITH_COROUTINES diff --git a/compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/function/local/equalsHashCode.kt b/compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/function/local/equalsHashCode.kt index ec1b9de7a74..c6e299e355c 100644 --- a/compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/function/local/equalsHashCode.kt +++ b/compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/function/local/equalsHashCode.kt @@ -1,7 +1,9 @@ // !LANGUAGE: +ReleaseCoroutines // !API_VERSION: 1.3 -// IGNORE_BACKEND: JS, NATIVE +// IGNORE_BACKEND: JS +// IGNORE_BACKEND: JS_IR // IGNORE_BACKEND: JVM_IR +// IGNORE_BACKEND: NATIVE fun box(): String { suspend fun bar() {} diff --git a/compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/longArgs.kt b/compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/longArgs.kt index b81046cfa9a..ce1b164a743 100644 --- a/compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/longArgs.kt +++ b/compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/longArgs.kt @@ -1,7 +1,8 @@ // !LANGUAGE: +ReleaseCoroutines // !API_VERSION: 1.3 -// IGNORE_BACKEND: JS, JS_IR +// IGNORE_BACKEND: JS // IGNORE_BACKEND: JVM_IR +// IGNORE_BACKEND: JS_IR // WITH_COROUTINES import helpers.* diff --git a/compiler/testData/codegen/box/coroutines/featureIntersection/destructuringInLambdas.kt b/compiler/testData/codegen/box/coroutines/featureIntersection/destructuringInLambdas.kt index c4a4f126565..6a7975d281d 100644 --- a/compiler/testData/codegen/box/coroutines/featureIntersection/destructuringInLambdas.kt +++ b/compiler/testData/codegen/box/coroutines/featureIntersection/destructuringInLambdas.kt @@ -1,4 +1,5 @@ // IGNORE_BACKEND: JVM_IR +// IGNORE_BACKEND: JS_IR // WITH_RUNTIME // WITH_COROUTINES // COMMON_COROUTINES_TEST diff --git a/compiler/testData/codegen/box/coroutines/featureIntersection/safeCallOnTwoReceivers.kt b/compiler/testData/codegen/box/coroutines/featureIntersection/safeCallOnTwoReceivers.kt index bccf7cfbe8b..2ea7ef5c816 100644 --- a/compiler/testData/codegen/box/coroutines/featureIntersection/safeCallOnTwoReceivers.kt +++ b/compiler/testData/codegen/box/coroutines/featureIntersection/safeCallOnTwoReceivers.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // IGNORE_BACKEND: JVM_IR // WITH_RUNTIME // WITH_COROUTINES diff --git a/compiler/testData/codegen/box/coroutines/featureIntersection/safeCallOnTwoReceiversLong.kt b/compiler/testData/codegen/box/coroutines/featureIntersection/safeCallOnTwoReceiversLong.kt index 0c19e8d9abb..4f3f5a8336b 100644 --- a/compiler/testData/codegen/box/coroutines/featureIntersection/safeCallOnTwoReceiversLong.kt +++ b/compiler/testData/codegen/box/coroutines/featureIntersection/safeCallOnTwoReceiversLong.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // IGNORE_BACKEND: JVM_IR // WITH_RUNTIME // WITH_COROUTINES diff --git a/compiler/testData/codegen/box/coroutines/featureIntersection/suspendOperatorPlus.kt b/compiler/testData/codegen/box/coroutines/featureIntersection/suspendOperatorPlus.kt index f969161b283..5a79168b5f9 100644 --- a/compiler/testData/codegen/box/coroutines/featureIntersection/suspendOperatorPlus.kt +++ b/compiler/testData/codegen/box/coroutines/featureIntersection/suspendOperatorPlus.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // IGNORE_BACKEND: JVM_IR // WITH_RUNTIME // WITH_COROUTINES diff --git a/compiler/testData/codegen/box/coroutines/featureIntersection/suspendOperatorPlusAssign.kt b/compiler/testData/codegen/box/coroutines/featureIntersection/suspendOperatorPlusAssign.kt index 8f1ae570236..86002f4c2c1 100644 --- a/compiler/testData/codegen/box/coroutines/featureIntersection/suspendOperatorPlusAssign.kt +++ b/compiler/testData/codegen/box/coroutines/featureIntersection/suspendOperatorPlusAssign.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // IGNORE_BACKEND: JVM_IR // WITH_RUNTIME // WITH_COROUTINES diff --git a/compiler/testData/codegen/box/coroutines/featureIntersection/suspendOperatorPlusCallFromLambda.kt b/compiler/testData/codegen/box/coroutines/featureIntersection/suspendOperatorPlusCallFromLambda.kt index fc32035069c..f3de9618fce 100644 --- a/compiler/testData/codegen/box/coroutines/featureIntersection/suspendOperatorPlusCallFromLambda.kt +++ b/compiler/testData/codegen/box/coroutines/featureIntersection/suspendOperatorPlusCallFromLambda.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // IGNORE_BACKEND: JVM_IR // WITH_RUNTIME // WITH_COROUTINES diff --git a/compiler/testData/codegen/box/coroutines/handleResultCallEmptyBody.kt b/compiler/testData/codegen/box/coroutines/handleResultCallEmptyBody.kt index 6ab3d42429f..5333aa675a5 100644 --- a/compiler/testData/codegen/box/coroutines/handleResultCallEmptyBody.kt +++ b/compiler/testData/codegen/box/coroutines/handleResultCallEmptyBody.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // IGNORE_BACKEND: JVM_IR // WITH_RUNTIME // WITH_COROUTINES diff --git a/compiler/testData/codegen/box/coroutines/handleResultNonUnitExpression.kt b/compiler/testData/codegen/box/coroutines/handleResultNonUnitExpression.kt index 936ba29d46d..97f3322207f 100644 --- a/compiler/testData/codegen/box/coroutines/handleResultNonUnitExpression.kt +++ b/compiler/testData/codegen/box/coroutines/handleResultNonUnitExpression.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // IGNORE_BACKEND: JVM_IR // WITH_RUNTIME // WITH_COROUTINES diff --git a/compiler/testData/codegen/box/coroutines/handleResultSuspended.kt b/compiler/testData/codegen/box/coroutines/handleResultSuspended.kt index 4f7447a84e9..9566e86fd1e 100644 --- a/compiler/testData/codegen/box/coroutines/handleResultSuspended.kt +++ b/compiler/testData/codegen/box/coroutines/handleResultSuspended.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // IGNORE_BACKEND: JVM_IR // WITH_RUNTIME // WITH_COROUTINES diff --git a/compiler/testData/codegen/box/coroutines/indirectInlineUsedAsNonInline.kt b/compiler/testData/codegen/box/coroutines/indirectInlineUsedAsNonInline.kt index a9cf5fc973a..7b036b4dcb6 100644 --- a/compiler/testData/codegen/box/coroutines/indirectInlineUsedAsNonInline.kt +++ b/compiler/testData/codegen/box/coroutines/indirectInlineUsedAsNonInline.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // IGNORE_BACKEND: JVM_IR // WITH_RUNTIME // WITH_COROUTINES diff --git a/compiler/testData/codegen/box/coroutines/inlineFunInGenericClass.kt b/compiler/testData/codegen/box/coroutines/inlineFunInGenericClass.kt index 5dd8f593435..8140b414dc7 100644 --- a/compiler/testData/codegen/box/coroutines/inlineFunInGenericClass.kt +++ b/compiler/testData/codegen/box/coroutines/inlineFunInGenericClass.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // IGNORE_BACKEND: JVM_IR // WITH_RUNTIME // WITH_COROUTINES diff --git a/compiler/testData/codegen/box/coroutines/innerSuspensionCalls.kt b/compiler/testData/codegen/box/coroutines/innerSuspensionCalls.kt index a8fb8e5104a..1994e246277 100644 --- a/compiler/testData/codegen/box/coroutines/innerSuspensionCalls.kt +++ b/compiler/testData/codegen/box/coroutines/innerSuspensionCalls.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // IGNORE_BACKEND: JVM_IR // WITH_RUNTIME // WITH_COROUTINES diff --git a/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/i2bResult.kt b/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/i2bResult.kt index e9974d4499f..35e0d0c79cc 100644 --- a/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/i2bResult.kt +++ b/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/i2bResult.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // IGNORE_BACKEND: JVM_IR // WITH_RUNTIME // WITH_COROUTINES diff --git a/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/sameIconst1ManyVars.kt b/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/sameIconst1ManyVars.kt index dc94854ec25..910d80e5ee6 100644 --- a/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/sameIconst1ManyVars.kt +++ b/compiler/testData/codegen/box/coroutines/intLikeVarSpilling/sameIconst1ManyVars.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // IGNORE_BACKEND: JVM_IR // WITH_RUNTIME // WITH_COROUTINES diff --git a/compiler/testData/codegen/box/coroutines/intrinsicSemantics/intercepted.kt b/compiler/testData/codegen/box/coroutines/intrinsicSemantics/intercepted.kt index 8b87267c3be..469857ca656 100644 --- a/compiler/testData/codegen/box/coroutines/intrinsicSemantics/intercepted.kt +++ b/compiler/testData/codegen/box/coroutines/intrinsicSemantics/intercepted.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // IGNORE_BACKEND: JVM_IR // WITH_RUNTIME // WITH_COROUTINES diff --git a/compiler/testData/codegen/box/coroutines/intrinsicSemantics/startCoroutine.kt b/compiler/testData/codegen/box/coroutines/intrinsicSemantics/startCoroutine.kt index f426016ebe1..9a9f375f437 100644 --- a/compiler/testData/codegen/box/coroutines/intrinsicSemantics/startCoroutine.kt +++ b/compiler/testData/codegen/box/coroutines/intrinsicSemantics/startCoroutine.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // IGNORE_BACKEND: JVM_IR // WITH_RUNTIME // WITH_COROUTINES diff --git a/compiler/testData/codegen/box/coroutines/intrinsicSemantics/startCoroutineUninterceptedOrReturn.kt b/compiler/testData/codegen/box/coroutines/intrinsicSemantics/startCoroutineUninterceptedOrReturn.kt index 72955f7397c..1ef5224af52 100644 --- a/compiler/testData/codegen/box/coroutines/intrinsicSemantics/startCoroutineUninterceptedOrReturn.kt +++ b/compiler/testData/codegen/box/coroutines/intrinsicSemantics/startCoroutineUninterceptedOrReturn.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // IGNORE_BACKEND: JVM_IR // WITH_RUNTIME // WITH_COROUTINES diff --git a/compiler/testData/codegen/box/coroutines/intrinsicSemantics/startCoroutineUninterceptedOrReturnInterception.kt b/compiler/testData/codegen/box/coroutines/intrinsicSemantics/startCoroutineUninterceptedOrReturnInterception.kt index fc32d370b11..0de6b44a0c6 100644 --- a/compiler/testData/codegen/box/coroutines/intrinsicSemantics/startCoroutineUninterceptedOrReturnInterception.kt +++ b/compiler/testData/codegen/box/coroutines/intrinsicSemantics/startCoroutineUninterceptedOrReturnInterception.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // IGNORE_BACKEND: JVM_IR // WITH_RUNTIME // WITH_COROUTINES diff --git a/compiler/testData/codegen/box/coroutines/intrinsicSemantics/suspendCoroutineUninterceptedOrReturn.kt b/compiler/testData/codegen/box/coroutines/intrinsicSemantics/suspendCoroutineUninterceptedOrReturn.kt index 42d75fa8ebc..ae726a55d72 100644 --- a/compiler/testData/codegen/box/coroutines/intrinsicSemantics/suspendCoroutineUninterceptedOrReturn.kt +++ b/compiler/testData/codegen/box/coroutines/intrinsicSemantics/suspendCoroutineUninterceptedOrReturn.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // IGNORE_BACKEND: JVM_IR // WITH_RUNTIME // WITH_COROUTINES diff --git a/compiler/testData/codegen/box/coroutines/kt15016.kt b/compiler/testData/codegen/box/coroutines/kt15016.kt index 2e5e18df3bc..0221e025cf1 100644 --- a/compiler/testData/codegen/box/coroutines/kt15016.kt +++ b/compiler/testData/codegen/box/coroutines/kt15016.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // IGNORE_BACKEND: JVM_IR // WITH_RUNTIME // WITH_COROUTINES diff --git a/compiler/testData/codegen/box/coroutines/kt15017.kt b/compiler/testData/codegen/box/coroutines/kt15017.kt index 69961db3d26..a3d7a84e780 100644 --- a/compiler/testData/codegen/box/coroutines/kt15017.kt +++ b/compiler/testData/codegen/box/coroutines/kt15017.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // IGNORE_BACKEND: JVM_IR // WITH_RUNTIME // WITH_COROUTINES diff --git a/compiler/testData/codegen/box/coroutines/kt15930.kt b/compiler/testData/codegen/box/coroutines/kt15930.kt index 1616462a738..e836bf7aacc 100644 --- a/compiler/testData/codegen/box/coroutines/kt15930.kt +++ b/compiler/testData/codegen/box/coroutines/kt15930.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // IGNORE_BACKEND: JVM_IR // WITH_RUNTIME // WITH_COROUTINES diff --git a/compiler/testData/codegen/box/coroutines/kt21605.kt b/compiler/testData/codegen/box/coroutines/kt21605.kt index 0470b0ab913..e2f7740d7c1 100644 --- a/compiler/testData/codegen/box/coroutines/kt21605.kt +++ b/compiler/testData/codegen/box/coroutines/kt21605.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // IGNORE_BACKEND: JVM_IR // WITH_RUNTIME // WITH_COROUTINES diff --git a/compiler/testData/codegen/box/coroutines/lastExpressionIsLoop.kt b/compiler/testData/codegen/box/coroutines/lastExpressionIsLoop.kt index 2a2317de3af..304c320fa9d 100644 --- a/compiler/testData/codegen/box/coroutines/lastExpressionIsLoop.kt +++ b/compiler/testData/codegen/box/coroutines/lastExpressionIsLoop.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // IGNORE_BACKEND: JVM_IR // WITH_RUNTIME // WITH_COROUTINES diff --git a/compiler/testData/codegen/box/coroutines/lastStatementInc.kt b/compiler/testData/codegen/box/coroutines/lastStatementInc.kt index e76862be806..e018befdad7 100644 --- a/compiler/testData/codegen/box/coroutines/lastStatementInc.kt +++ b/compiler/testData/codegen/box/coroutines/lastStatementInc.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // IGNORE_BACKEND: JVM_IR // WITH_RUNTIME // WITH_COROUTINES diff --git a/compiler/testData/codegen/box/coroutines/lastStementAssignment.kt b/compiler/testData/codegen/box/coroutines/lastStementAssignment.kt index cd3a9907ff3..dba8fb47f06 100644 --- a/compiler/testData/codegen/box/coroutines/lastStementAssignment.kt +++ b/compiler/testData/codegen/box/coroutines/lastStementAssignment.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // IGNORE_BACKEND: JVM_IR // WITH_RUNTIME // WITH_COROUTINES diff --git a/compiler/testData/codegen/box/coroutines/lastUnitExpression.kt b/compiler/testData/codegen/box/coroutines/lastUnitExpression.kt index 9ce2ecdf57b..a864ea77e14 100644 --- a/compiler/testData/codegen/box/coroutines/lastUnitExpression.kt +++ b/compiler/testData/codegen/box/coroutines/lastUnitExpression.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // IGNORE_BACKEND: JVM_IR // WITH_RUNTIME // WITH_COROUTINES diff --git a/compiler/testData/codegen/box/coroutines/localCallableRef.kt b/compiler/testData/codegen/box/coroutines/localCallableRef.kt index 5135b93230b..d7b8da90eaa 100644 --- a/compiler/testData/codegen/box/coroutines/localCallableRef.kt +++ b/compiler/testData/codegen/box/coroutines/localCallableRef.kt @@ -1,5 +1,5 @@ -// IGNORE_BACKEND: JS_IR // IGNORE_BACKEND: JVM_IR +// IGNORE_BACKEND: JS_IR // WITH_RUNTIME // WITH_COROUTINES // LANGUAGE_VERSION: 1.3 diff --git a/compiler/testData/codegen/box/coroutines/localFunctions/named/infix.kt b/compiler/testData/codegen/box/coroutines/localFunctions/named/infix.kt index e2c7dd0b59c..bc58364269e 100644 --- a/compiler/testData/codegen/box/coroutines/localFunctions/named/infix.kt +++ b/compiler/testData/codegen/box/coroutines/localFunctions/named/infix.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // IGNORE_BACKEND: JVM_IR // WITH_RUNTIME // WITH_COROUTINES diff --git a/compiler/testData/codegen/box/coroutines/localFunctions/named/insideLambda.kt b/compiler/testData/codegen/box/coroutines/localFunctions/named/insideLambda.kt index 970b2e1652c..bf8b5b94897 100644 --- a/compiler/testData/codegen/box/coroutines/localFunctions/named/insideLambda.kt +++ b/compiler/testData/codegen/box/coroutines/localFunctions/named/insideLambda.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // IGNORE_BACKEND: JVM_IR // WITH_RUNTIME // WITH_COROUTINES diff --git a/compiler/testData/codegen/box/coroutines/localFunctions/named/simple.kt b/compiler/testData/codegen/box/coroutines/localFunctions/named/simple.kt index 948335dff4e..94991c64bc8 100644 --- a/compiler/testData/codegen/box/coroutines/localFunctions/named/simple.kt +++ b/compiler/testData/codegen/box/coroutines/localFunctions/named/simple.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // IGNORE_BACKEND: JVM_IR // WITH_RUNTIME // WITH_COROUTINES diff --git a/compiler/testData/codegen/box/coroutines/localFunctions/named/simpleSuspensionPoint.kt b/compiler/testData/codegen/box/coroutines/localFunctions/named/simpleSuspensionPoint.kt index f4992c78102..9aba11c931b 100644 --- a/compiler/testData/codegen/box/coroutines/localFunctions/named/simpleSuspensionPoint.kt +++ b/compiler/testData/codegen/box/coroutines/localFunctions/named/simpleSuspensionPoint.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // IGNORE_BACKEND: JVM_IR // WITH_RUNTIME // WITH_COROUTINES diff --git a/compiler/testData/codegen/box/coroutines/longRangeInSuspendCall.kt b/compiler/testData/codegen/box/coroutines/longRangeInSuspendCall.kt index 299473f6fdf..56136f82576 100644 --- a/compiler/testData/codegen/box/coroutines/longRangeInSuspendCall.kt +++ b/compiler/testData/codegen/box/coroutines/longRangeInSuspendCall.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // IGNORE_BACKEND: JVM_IR // WITH_RUNTIME // WITH_COROUTINES diff --git a/compiler/testData/codegen/box/coroutines/longRangeInSuspendFun.kt b/compiler/testData/codegen/box/coroutines/longRangeInSuspendFun.kt index bedd85c468b..fc9dd54e160 100644 --- a/compiler/testData/codegen/box/coroutines/longRangeInSuspendFun.kt +++ b/compiler/testData/codegen/box/coroutines/longRangeInSuspendFun.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // IGNORE_BACKEND: JVM_IR // WITH_RUNTIME // WITH_COROUTINES diff --git a/compiler/testData/codegen/box/coroutines/multipleInvokeCalls.kt b/compiler/testData/codegen/box/coroutines/multipleInvokeCalls.kt index 8d0dfcfc9de..e0aaccccf4f 100644 --- a/compiler/testData/codegen/box/coroutines/multipleInvokeCalls.kt +++ b/compiler/testData/codegen/box/coroutines/multipleInvokeCalls.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // IGNORE_BACKEND: JVM_IR // WITH_RUNTIME // WITH_COROUTINES diff --git a/compiler/testData/codegen/box/coroutines/noStdLib/breakFinally.kt b/compiler/testData/codegen/box/coroutines/noStdLib/breakFinally.kt new file mode 100644 index 00000000000..fb8f9e4d30f --- /dev/null +++ b/compiler/testData/codegen/box/coroutines/noStdLib/breakFinally.kt @@ -0,0 +1,81 @@ +// IGNORE_BACKEND: JS +// IGNORE_BACKEND: JVM_IR +// WITH_RUNTIME +// WITH_COROUTINES +// COMMON_COROUTINES_TEST +import helpers.* +import COROUTINES_PACKAGE.* +import COROUTINES_PACKAGE.intrinsics.* + + +class Controller { + var result = "" + + suspend fun suspendWithResult(value: T): T = suspendCoroutineUninterceptedOrReturn { c -> + c.resume(value) + COROUTINE_SUSPENDED + } +} + +fun builder(c: suspend Controller.() -> Unit): String { + val controller = Controller() + c.startCoroutine(controller, EmptyContinuation) + return controller.result +} + +fun box(): String { + val value = builder { + try { + var i1 = 0 + outer@while (i1 < 2) { + val x = if (i1 == 0) "A" else "B" + ++i1 + try { + result += suspendWithResult(x) + var i2 = 0 + while (i2 < 2) { + val y = if (i2 == 0) "C" else "D" + ++i2 + try { + result += suspendWithResult(y) + if (y == "D") { + break@outer + } + } + finally { + result += "!" + } + result += "E" + } + } + finally { + result += "@" + var i3 = 0 + while (i3 < 2) { + val z = if (i3 == 0) "F" else "G" + ++i3 + try { + result += suspendWithResult(z) + if (z == "G") { + break + } + } + finally { + result += "?" + } + result += "H" + } + } + result += "ignore" + } + result += "*" + } + finally { + result += "finally" + } + result += "." + } + if (value != "AC!ED!@F?HG?*finally.") return "fail: $value" + + return "OK" +} diff --git a/compiler/testData/codegen/box/coroutines/noStdLib/breakStatement.kt b/compiler/testData/codegen/box/coroutines/noStdLib/breakStatement.kt new file mode 100644 index 00000000000..309453f6e66 --- /dev/null +++ b/compiler/testData/codegen/box/coroutines/noStdLib/breakStatement.kt @@ -0,0 +1,67 @@ +// IGNORE_BACKEND: JVM_IR +// WITH_RUNTIME +// WITH_COROUTINES +// COMMON_COROUTINES_TEST +import helpers.* +import COROUTINES_PACKAGE.* +import COROUTINES_PACKAGE.intrinsics.* + + +class Controller { + var result = "" + + suspend fun suspendWithResult(value: T): T = suspendCoroutineUninterceptedOrReturn { c -> + c.resume(value) + COROUTINE_SUSPENDED + } +} + +fun builder(c: suspend Controller.() -> Unit): String { + val controller = Controller() + c.startCoroutine(controller, EmptyContinuation) + return controller.result +} + +fun box(): String { + var value = builder { + var i1 = 0 + outer@while (i1 < 2) { + val x = if (i1 == 0) "O" else "K" + i1++ + result += suspendWithResult(x) + var i2 = 0 + while (i2 < 2) { + val y = if (i2 == 0) "Q" else "W" + i2++ + result += suspendWithResult(y) + if (y == "W") { + break@outer + } + } + } + result += "." + } + if (value != "OQW.") return "fail: break outer loop: $value" + + value = builder { + var i1 = 0 + while (i1 < 2) { + val x = if (i1 == 0) "O" else "K" + i1++ + result += suspendWithResult(x) + var i2 = 0 + while (i2 < 2) { + val y = if (i2 == 0) "Q" else "W" + i2++ + if (y == "W") { + break + } + result += suspendWithResult(y) + } + } + result += "." + } + if (value != "OQKQ.") return "fail: break inner loop: $value" + + return "OK" +} diff --git a/compiler/testData/codegen/box/coroutines/noStdLib/crossinline.kt b/compiler/testData/codegen/box/coroutines/noStdLib/crossinline.kt new file mode 100644 index 00000000000..fa1b6ae7d95 --- /dev/null +++ b/compiler/testData/codegen/box/coroutines/noStdLib/crossinline.kt @@ -0,0 +1,79 @@ +// IGNORE_BACKEND: JS_IR +// IGNORE_BACKEND: JVM_IR +// IGNORE_BACKEND: JS +// COMMON_COROUTINES_TEST +// WITH_RUNTIME +// WITH_COROUTINES +// CHECK_BYTECODE_LISTING +import helpers.* +import COROUTINES_PACKAGE.* +import COROUTINES_PACKAGE.intrinsics.* + +interface SourceCrossinline { + suspend fun consume(sink: Sink) + companion object Factory +} + +interface Sink { + suspend fun send(item: E) + fun close(cause: Throwable?) +} + +inline fun source(crossinline action: suspend Sink.() -> Unit): SourceCrossinline = object : SourceCrossinline { + override suspend fun consume(sink: Sink) { + var cause: Throwable? = null + try { + action(sink) + } catch (e: Throwable) { + cause = e + } + sink.close(cause) + } +} + +fun SourceCrossinline.Factory.range(start: Int, count: Int): SourceCrossinline = source { + var i = start + while (i < (start + count)) { + send(i) + ++i + } +} + +suspend inline fun SourceCrossinline.consumeEach(crossinline action: suspend (E) -> Unit) { + consume(object : Sink { + override suspend fun send(item: E) = action(item) + override fun close(cause: Throwable?) { cause?.let { throw it } } + }) +} + +suspend inline fun SourceCrossinline.fold(initial: R, crossinline operation: suspend (acc: R, E) -> R): R { + var acc = initial + consumeEach { + acc = operation(acc, it) + } + return acc +} + +inline fun SourceCrossinline.filter(crossinline predicate: (E) -> Boolean) = source { + consumeEach { + if (predicate(it)) send(it) + } +} + +fun builder(c: suspend () -> Unit) { + c.startCoroutine(EmptyContinuation) +} + +fun Int.isGood() = this % 4 == 0 + +fun box(): String { + var res = 0 + builder { + res = SourceCrossinline + .range(1, 11) + .filter { it.isGood() } + .fold(0, { a, b -> a + b }) + } + if (res != 12) return "FAIL" + return "OK" +} \ No newline at end of file diff --git a/compiler/testData/codegen/box/coroutines/noStdLib/ifStatement.kt b/compiler/testData/codegen/box/coroutines/noStdLib/ifStatement.kt new file mode 100644 index 00000000000..4a342bdc8c2 --- /dev/null +++ b/compiler/testData/codegen/box/coroutines/noStdLib/ifStatement.kt @@ -0,0 +1,89 @@ +// IGNORE_BACKEND: JVM_IR +// WITH_RUNTIME +// WITH_COROUTINES +// COMMON_COROUTINES_TEST +import helpers.* +import COROUTINES_PACKAGE.* +import COROUTINES_PACKAGE.intrinsics.* + + +class Controller { + var result = "" + + suspend fun suspendWithResult(value: T): T = suspendCoroutineUninterceptedOrReturn { c -> + c.resume(value) + COROUTINE_SUSPENDED + } +} + +fun builder(c: suspend Controller.() -> Unit): String { + val controller = Controller() + c.startCoroutine(controller, EmptyContinuation) + return controller.result +} + +fun box(): String { + var value = builder { + if (suspendWithResult(true)) { + result = "OK" + } + } + if (value != "OK") return "fail: suspend as if condition: $value" + + value = builder { + var i = 0 + while (i < 2) { + val x = i == 0 + ++i + if (x) { + result += suspendWithResult("O") + } else { + result += "K" + } + } + } + if (value != "OK") return "fail: suspend in then branch: $value" + + value = builder { + var i = 0 + while (i < 2) { + val x = i == 0 + ++i + if (x) { + result += "O" + } else { + result += suspendWithResult("K") + } + } + } + if (value != "OK") return "fail: suspend in else branch: $value" + + value = builder { + var i = 0 + while (i < 2) { + val x = i == 0 + ++i + if (x) { + result += suspendWithResult("O") + } else { + result += suspendWithResult("K") + } + } + } + if (value != "OK") return "fail: suspend in both branches: $value" + + value = builder { + var i = 0 + while (i < 2) { + val x = i == 0 + ++i + if (x) { + result += suspendWithResult("O") + } + result += ";" + } + } + if (value != "O;;") return "fail: suspend in then branch without else: $value" + + return "OK" +} diff --git a/compiler/testData/codegen/box/coroutines/noStdLib/stateMachine.kt b/compiler/testData/codegen/box/coroutines/noStdLib/stateMachine.kt new file mode 100644 index 00000000000..8b776a017a2 --- /dev/null +++ b/compiler/testData/codegen/box/coroutines/noStdLib/stateMachine.kt @@ -0,0 +1,67 @@ +// IGNORE_BACKEND: JVM_IR +// WITH_RUNTIME +// WITH_COROUTINES +// COMMON_COROUTINES_TEST + +import helpers.* +import COROUTINES_PACKAGE.* +import COROUTINES_PACKAGE.intrinsics.* + +var result = "FAIL" +var i = 0 +var finished = false + +var proceed: () -> Unit = {} + +suspend fun suspendHere() = suspendCoroutine {c -> + i++ + proceed = { c.resume(Unit) } +} + +suspend fun callLocal() { + suspend fun local() { + suspendHere() + suspendHere() + suspendHere() + suspendHere() + suspendHere() + } + local() + local() +} + +fun builder(c: suspend () -> Unit) { + val continuation = object: ContinuationAdapter() { + override val context: CoroutineContext + get() = EmptyCoroutineContext + + override fun resume(value: Unit) { + proceed = { + result = "OK" + finished = true + } + } + + override fun resumeWithException(exception: Throwable) { + throw exception + } + } + c.startCoroutine(continuation) +} + +fun box(): String { + builder { + callLocal() + } + var _counter = 0 + while (_counter < 10) { + val counter = _counter++ + if (i != counter + 1) return "Expected ${counter + 1}, got $i" + proceed() + } + if (i != 10) return "FAIL $i" + if (finished) return "resume on root continuation is called" + proceed() + if (!finished) return "resume on root continuation is not called" + return result +} diff --git a/compiler/testData/codegen/box/coroutines/noStdLib/switchLikeWhen.kt b/compiler/testData/codegen/box/coroutines/noStdLib/switchLikeWhen.kt new file mode 100644 index 00000000000..857378748db --- /dev/null +++ b/compiler/testData/codegen/box/coroutines/noStdLib/switchLikeWhen.kt @@ -0,0 +1,42 @@ +// IGNORE_BACKEND: JVM_IR +// WITH_RUNTIME +// WITH_COROUTINES +// COMMON_COROUTINES_TEST +import helpers.* +import COROUTINES_PACKAGE.* +import COROUTINES_PACKAGE.intrinsics.* + + +class Controller { + var result = "" + + suspend fun suspendWithResult(value: T): T = suspendCoroutineUninterceptedOrReturn { c -> + result += "[" + c.resume(value) + COROUTINE_SUSPENDED + } +} + +fun builder(c: suspend Controller.() -> Unit): String { + val controller = Controller() + c.startCoroutine(controller, EmptyContinuation) + return controller.result +} + +fun box(): String { + var value = builder { + var j = 0 + while (j < 3) { + val i = j++ + val v = if (i == 0) "A" else if (i == 1) "B" else "C" + when (v) { + "A" -> result += "A;" + "B" -> result += suspendWithResult(v) + "]" + else -> result += suspendWithResult(v) + "]!" + } + } + } + if (value != "A;B]C]!") return "fail: suspend as if condition: $value" + + return "OK" +} diff --git a/compiler/testData/codegen/box/coroutines/nonLocalReturnFromInlineLambda.kt b/compiler/testData/codegen/box/coroutines/nonLocalReturnFromInlineLambda.kt index a47e6017c0c..52d3d384ed1 100644 --- a/compiler/testData/codegen/box/coroutines/nonLocalReturnFromInlineLambda.kt +++ b/compiler/testData/codegen/box/coroutines/nonLocalReturnFromInlineLambda.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // IGNORE_BACKEND: JVM_IR // WITH_RUNTIME // COMMON_COROUTINES_TEST diff --git a/compiler/testData/codegen/box/coroutines/nonLocalReturnFromInlineLambdaDeep.kt b/compiler/testData/codegen/box/coroutines/nonLocalReturnFromInlineLambdaDeep.kt index 2f9e6aa7624..2a2dc55fd2e 100644 --- a/compiler/testData/codegen/box/coroutines/nonLocalReturnFromInlineLambdaDeep.kt +++ b/compiler/testData/codegen/box/coroutines/nonLocalReturnFromInlineLambdaDeep.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // IGNORE_BACKEND: JVM_IR // WITH_RUNTIME // COMMON_COROUTINES_TEST diff --git a/compiler/testData/codegen/box/coroutines/overrideDefaultArgument.kt b/compiler/testData/codegen/box/coroutines/overrideDefaultArgument.kt index 886f34dff7f..0df4b807f17 100644 --- a/compiler/testData/codegen/box/coroutines/overrideDefaultArgument.kt +++ b/compiler/testData/codegen/box/coroutines/overrideDefaultArgument.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // IGNORE_BACKEND: JVM_IR // WITH_RUNTIME // WITH_COROUTINES diff --git a/compiler/testData/codegen/box/coroutines/recursiveSuspend.kt b/compiler/testData/codegen/box/coroutines/recursiveSuspend.kt index 48165f95721..62e5c9907b9 100644 --- a/compiler/testData/codegen/box/coroutines/recursiveSuspend.kt +++ b/compiler/testData/codegen/box/coroutines/recursiveSuspend.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // IGNORE_BACKEND: JVM_IR // WITH_RUNTIME // WITH_COROUTINES diff --git a/compiler/testData/codegen/box/coroutines/returnByLabel.kt b/compiler/testData/codegen/box/coroutines/returnByLabel.kt index 89ff13fb423..860deae6d7d 100644 --- a/compiler/testData/codegen/box/coroutines/returnByLabel.kt +++ b/compiler/testData/codegen/box/coroutines/returnByLabel.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // IGNORE_BACKEND: JVM_IR // WITH_RUNTIME // WITH_COROUTINES diff --git a/compiler/testData/codegen/box/coroutines/simple.kt b/compiler/testData/codegen/box/coroutines/simple.kt index 63565f9cab6..294e7760e8f 100644 --- a/compiler/testData/codegen/box/coroutines/simple.kt +++ b/compiler/testData/codegen/box/coroutines/simple.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // IGNORE_BACKEND: JVM_IR // WITH_RUNTIME // WITH_COROUTINES diff --git a/compiler/testData/codegen/box/coroutines/simpleException.kt b/compiler/testData/codegen/box/coroutines/simpleException.kt index d8b3e51f717..a244d94f1ae 100644 --- a/compiler/testData/codegen/box/coroutines/simpleException.kt +++ b/compiler/testData/codegen/box/coroutines/simpleException.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // IGNORE_BACKEND: JVM_IR // WITH_RUNTIME // WITH_COROUTINES diff --git a/compiler/testData/codegen/box/coroutines/simpleWithHandleResult.kt b/compiler/testData/codegen/box/coroutines/simpleWithHandleResult.kt index 76550090bc7..11ad9308f24 100644 --- a/compiler/testData/codegen/box/coroutines/simpleWithHandleResult.kt +++ b/compiler/testData/codegen/box/coroutines/simpleWithHandleResult.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // IGNORE_BACKEND: JVM_IR // WITH_RUNTIME // WITH_COROUTINES diff --git a/compiler/testData/codegen/box/coroutines/stackUnwinding/simple.kt b/compiler/testData/codegen/box/coroutines/stackUnwinding/simple.kt index eeee61fc1a3..417a8c48ee2 100644 --- a/compiler/testData/codegen/box/coroutines/stackUnwinding/simple.kt +++ b/compiler/testData/codegen/box/coroutines/stackUnwinding/simple.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // IGNORE_BACKEND: JVM_IR // WITH_RUNTIME // WITH_COROUTINES diff --git a/compiler/testData/codegen/box/coroutines/stackUnwinding/suspendInCycle.kt b/compiler/testData/codegen/box/coroutines/stackUnwinding/suspendInCycle.kt index ff74024b493..37050a191d8 100644 --- a/compiler/testData/codegen/box/coroutines/stackUnwinding/suspendInCycle.kt +++ b/compiler/testData/codegen/box/coroutines/stackUnwinding/suspendInCycle.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // IGNORE_BACKEND: JVM_IR // WITH_RUNTIME // WITH_COROUTINES diff --git a/compiler/testData/codegen/box/coroutines/statementLikeLastExpression.kt b/compiler/testData/codegen/box/coroutines/statementLikeLastExpression.kt index 366cce1527b..e4cdb54616a 100644 --- a/compiler/testData/codegen/box/coroutines/statementLikeLastExpression.kt +++ b/compiler/testData/codegen/box/coroutines/statementLikeLastExpression.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // IGNORE_BACKEND: JVM_IR // WITH_RUNTIME // WITH_COROUTINES diff --git a/compiler/testData/codegen/box/coroutines/suspendCallsInArguments.kt b/compiler/testData/codegen/box/coroutines/suspendCallsInArguments.kt new file mode 100644 index 00000000000..8ac40cffb20 --- /dev/null +++ b/compiler/testData/codegen/box/coroutines/suspendCallsInArguments.kt @@ -0,0 +1,97 @@ +// IGNORE_BACKEND: JVM_IR +// WITH_RUNTIME +// WITH_COROUTINES +// COMMON_COROUTINES_TEST +import helpers.* +import COROUTINES_PACKAGE.* +import COROUTINES_PACKAGE.intrinsics.* + +class Controller { + var result = "" +} + +var x = 0 + +fun builder(c: suspend Controller.() -> Unit): String { + val cc = Controller() + c.startCoroutine(cc, EmptyContinuation) + return cc.result +} + +suspend fun foo(i: Int): String { + x++ + return "$i;" +} + +var y = 0 + +suspend fun bars(p1: String, p2: String, p3: String, p4: String) : String { + y++ + return p1 + p2 + p3 + p4 +} + +var z = 0 + +fun bar(p1: String, p2: String, p3: String, p4: String) : String { + z++ + return p1 + p2 + p3 + p4 +} + +fun box(): String { + + var r1 = builder { + var i = 1 + result = bars( + bars(foo(i++), foo(i++), foo(i++), foo(i++)), + bars(foo(i++), foo(i++), foo(i++), foo(i++)), + bars(foo(i++), foo(i++), foo(i++), foo(i++)), + bars(foo(i++), foo(i++), foo(i++), foo(i++)) + ) + } + + if (r1 != "1;2;3;4;5;6;7;8;9;10;11;12;13;14;15;16;") return "FAIL1: $r1" + + var r2 = builder { + var i = 1 + result = bars( + bar(foo(i++), foo(i++), foo(i++), foo(i++)), + bar(foo(i++), foo(i++), foo(i++), foo(i++)), + bar(foo(i++), foo(i++), foo(i++), foo(i++)), + bar(foo(i++), foo(i++), foo(i++), foo(i++)) + ) + } + + if (r2 != "1;2;3;4;5;6;7;8;9;10;11;12;13;14;15;16;") return "FAIL2: $r2" + + var r3 = builder { + var i = 1 + result = bar( + bars(foo(i++), foo(i++), foo(i++), foo(i++)), + bars(foo(i++), foo(i++), foo(i++), foo(i++)), + bars(foo(i++), foo(i++), foo(i++), foo(i++)), + bars(foo(i++), foo(i++), foo(i++), foo(i++)) + ) + } + + if (r3 != "1;2;3;4;5;6;7;8;9;10;11;12;13;14;15;16;") return "FAIL3: $r3" + + var r4 = builder { + var i = 1 + result = bar( + bar(foo(i++), foo(i++), foo(i++), foo(i++)), + bar(foo(i++), foo(i++), foo(i++), foo(i++)), + bar(foo(i++), foo(i++), foo(i++), foo(i++)), + bar(foo(i++), foo(i++), foo(i++), foo(i++)) + ) + } + + if (r4 != "1;2;3;4;5;6;7;8;9;10;11;12;13;14;15;16;") return "FAIL4: $r4" + + if (x != 4 * 4 * 4) return "FAIL5: $x" + + if (y != 10) return "FAIL6: $y" + + if (z != 10) return "FAIL7: $z" + + return "OK" +} diff --git a/compiler/testData/codegen/box/coroutines/suspendCoroutineFromStateMachine.kt b/compiler/testData/codegen/box/coroutines/suspendCoroutineFromStateMachine.kt index 8efe1788d8b..f795d3b4f14 100644 --- a/compiler/testData/codegen/box/coroutines/suspendCoroutineFromStateMachine.kt +++ b/compiler/testData/codegen/box/coroutines/suspendCoroutineFromStateMachine.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // IGNORE_BACKEND: JVM_IR // WITH_RUNTIME // WITH_COROUTINES diff --git a/compiler/testData/codegen/box/coroutines/suspendDefaultImpl.kt b/compiler/testData/codegen/box/coroutines/suspendDefaultImpl.kt index 13e864113d0..9033ec08dd0 100644 --- a/compiler/testData/codegen/box/coroutines/suspendDefaultImpl.kt +++ b/compiler/testData/codegen/box/coroutines/suspendDefaultImpl.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // IGNORE_BACKEND: JVM_IR // WITH_RUNTIME // WITH_COROUTINES diff --git a/compiler/testData/codegen/box/coroutines/suspendDelegation.kt b/compiler/testData/codegen/box/coroutines/suspendDelegation.kt index 2a341540c94..649621e1627 100644 --- a/compiler/testData/codegen/box/coroutines/suspendDelegation.kt +++ b/compiler/testData/codegen/box/coroutines/suspendDelegation.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // IGNORE_BACKEND: JVM_IR // WITH_RUNTIME // WITH_COROUTINES diff --git a/compiler/testData/codegen/box/coroutines/suspendFromInlineLambda.kt b/compiler/testData/codegen/box/coroutines/suspendFromInlineLambda.kt index 2146ddf67e5..3e6a253bba2 100644 --- a/compiler/testData/codegen/box/coroutines/suspendFromInlineLambda.kt +++ b/compiler/testData/codegen/box/coroutines/suspendFromInlineLambda.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // IGNORE_BACKEND: JVM_IR // WITH_RUNTIME // WITH_COROUTINES diff --git a/compiler/testData/codegen/box/coroutines/suspendFunImportedFromObject.kt b/compiler/testData/codegen/box/coroutines/suspendFunImportedFromObject.kt index 8f4c9c47e92..50317e4c585 100644 --- a/compiler/testData/codegen/box/coroutines/suspendFunImportedFromObject.kt +++ b/compiler/testData/codegen/box/coroutines/suspendFunImportedFromObject.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // IGNORE_BACKEND: JVM_IR // WITH_RUNTIME // WITH_COROUTINES diff --git a/compiler/testData/codegen/box/coroutines/suspendFunctionAsCoroutine/inline.kt b/compiler/testData/codegen/box/coroutines/suspendFunctionAsCoroutine/inline.kt index 1f64a2d7089..4338e64f424 100644 --- a/compiler/testData/codegen/box/coroutines/suspendFunctionAsCoroutine/inline.kt +++ b/compiler/testData/codegen/box/coroutines/suspendFunctionAsCoroutine/inline.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // IGNORE_BACKEND: JVM_IR // WITH_RUNTIME // WITH_COROUTINES diff --git a/compiler/testData/codegen/box/coroutines/suspendFunctionAsCoroutine/member.kt b/compiler/testData/codegen/box/coroutines/suspendFunctionAsCoroutine/member.kt index 8e830301087..8a7a893114b 100644 --- a/compiler/testData/codegen/box/coroutines/suspendFunctionAsCoroutine/member.kt +++ b/compiler/testData/codegen/box/coroutines/suspendFunctionAsCoroutine/member.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // IGNORE_BACKEND: JVM_IR // WITH_RUNTIME // WITH_COROUTINES diff --git a/compiler/testData/codegen/box/coroutines/suspendFunctionAsCoroutine/privateInFile.kt b/compiler/testData/codegen/box/coroutines/suspendFunctionAsCoroutine/privateInFile.kt index 70efecf84d3..820b7826abe 100644 --- a/compiler/testData/codegen/box/coroutines/suspendFunctionAsCoroutine/privateInFile.kt +++ b/compiler/testData/codegen/box/coroutines/suspendFunctionAsCoroutine/privateInFile.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // IGNORE_BACKEND: JVM_IR // WITH_RUNTIME // WITH_COROUTINES diff --git a/compiler/testData/codegen/box/coroutines/suspendFunctionAsCoroutine/returnNoSuspend.kt b/compiler/testData/codegen/box/coroutines/suspendFunctionAsCoroutine/returnNoSuspend.kt index db2360e4fea..a9bcfdde60b 100644 --- a/compiler/testData/codegen/box/coroutines/suspendFunctionAsCoroutine/returnNoSuspend.kt +++ b/compiler/testData/codegen/box/coroutines/suspendFunctionAsCoroutine/returnNoSuspend.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // IGNORE_BACKEND: JVM_IR // WITH_RUNTIME // WITH_COROUTINES diff --git a/compiler/testData/codegen/box/coroutines/suspendFunctionAsCoroutine/simple.kt b/compiler/testData/codegen/box/coroutines/suspendFunctionAsCoroutine/simple.kt index a824ca12ae1..685f0e8d851 100644 --- a/compiler/testData/codegen/box/coroutines/suspendFunctionAsCoroutine/simple.kt +++ b/compiler/testData/codegen/box/coroutines/suspendFunctionAsCoroutine/simple.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // IGNORE_BACKEND: JVM_IR // WITH_RUNTIME // WITH_COROUTINES diff --git a/compiler/testData/codegen/box/coroutines/suspendFunctionAsCoroutine/superCall.kt b/compiler/testData/codegen/box/coroutines/suspendFunctionAsCoroutine/superCall.kt index 27de325ae85..51e35dc64f6 100644 --- a/compiler/testData/codegen/box/coroutines/suspendFunctionAsCoroutine/superCall.kt +++ b/compiler/testData/codegen/box/coroutines/suspendFunctionAsCoroutine/superCall.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // IGNORE_BACKEND: JVM_IR // WITH_RUNTIME // WITH_COROUTINES diff --git a/compiler/testData/codegen/box/coroutines/suspendFunctionAsCoroutine/superCallAbstractClass.kt b/compiler/testData/codegen/box/coroutines/suspendFunctionAsCoroutine/superCallAbstractClass.kt index 50648ecb78a..2e203f01621 100644 --- a/compiler/testData/codegen/box/coroutines/suspendFunctionAsCoroutine/superCallAbstractClass.kt +++ b/compiler/testData/codegen/box/coroutines/suspendFunctionAsCoroutine/superCallAbstractClass.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // IGNORE_BACKEND: JVM_IR // WITH_RUNTIME // WITH_COROUTINES diff --git a/compiler/testData/codegen/box/coroutines/suspendFunctionAsCoroutine/superCallInterface.kt b/compiler/testData/codegen/box/coroutines/suspendFunctionAsCoroutine/superCallInterface.kt index 85a2f1a34a9..f55f0a1f586 100644 --- a/compiler/testData/codegen/box/coroutines/suspendFunctionAsCoroutine/superCallInterface.kt +++ b/compiler/testData/codegen/box/coroutines/suspendFunctionAsCoroutine/superCallInterface.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // IGNORE_BACKEND: JVM_IR // WITH_RUNTIME // WITH_COROUTINES diff --git a/compiler/testData/codegen/box/coroutines/suspendFunctionTypeCall/manyParameters.kt b/compiler/testData/codegen/box/coroutines/suspendFunctionTypeCall/manyParameters.kt index 3090fc25b57..e7ea7b8087f 100644 --- a/compiler/testData/codegen/box/coroutines/suspendFunctionTypeCall/manyParameters.kt +++ b/compiler/testData/codegen/box/coroutines/suspendFunctionTypeCall/manyParameters.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // IGNORE_BACKEND: JVM_IR // WITH_RUNTIME // WITH_COROUTINES diff --git a/compiler/testData/codegen/box/coroutines/suspendFunctionTypeCall/simple.kt b/compiler/testData/codegen/box/coroutines/suspendFunctionTypeCall/simple.kt index 78438709738..0befaa7cb3e 100644 --- a/compiler/testData/codegen/box/coroutines/suspendFunctionTypeCall/simple.kt +++ b/compiler/testData/codegen/box/coroutines/suspendFunctionTypeCall/simple.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // IGNORE_BACKEND: JVM_IR // WITH_RUNTIME // COMMON_COROUTINES_TEST diff --git a/compiler/testData/codegen/box/coroutines/suspendInCycle.kt b/compiler/testData/codegen/box/coroutines/suspendInCycle.kt index d88b7d2cdbd..de0fb822fe5 100644 --- a/compiler/testData/codegen/box/coroutines/suspendInCycle.kt +++ b/compiler/testData/codegen/box/coroutines/suspendInCycle.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // IGNORE_BACKEND: JVM_IR // WITH_RUNTIME // WITH_COROUTINES diff --git a/compiler/testData/codegen/box/coroutines/suspendInTheMiddleOfObjectConstruction.kt b/compiler/testData/codegen/box/coroutines/suspendInTheMiddleOfObjectConstruction.kt index c0767167492..af3883e1bc3 100644 --- a/compiler/testData/codegen/box/coroutines/suspendInTheMiddleOfObjectConstruction.kt +++ b/compiler/testData/codegen/box/coroutines/suspendInTheMiddleOfObjectConstruction.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // IGNORE_BACKEND: JVM_IR // WITH_RUNTIME // WITH_COROUTINES diff --git a/compiler/testData/codegen/box/coroutines/suspensionInsideSafeCall.kt b/compiler/testData/codegen/box/coroutines/suspensionInsideSafeCall.kt index 125b4cf0b4f..c01585f64fe 100644 --- a/compiler/testData/codegen/box/coroutines/suspensionInsideSafeCall.kt +++ b/compiler/testData/codegen/box/coroutines/suspensionInsideSafeCall.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // IGNORE_BACKEND: JVM_IR // WITH_RUNTIME // WITH_COROUTINES diff --git a/compiler/testData/codegen/box/coroutines/suspensionInsideSafeCallWithElvis.kt b/compiler/testData/codegen/box/coroutines/suspensionInsideSafeCallWithElvis.kt index fc0ad325758..181d2e04440 100644 --- a/compiler/testData/codegen/box/coroutines/suspensionInsideSafeCallWithElvis.kt +++ b/compiler/testData/codegen/box/coroutines/suspensionInsideSafeCallWithElvis.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // IGNORE_BACKEND: JVM_IR // WITH_RUNTIME // WITH_COROUTINES diff --git a/compiler/testData/codegen/box/coroutines/tailCallOptimizations/inlineWithStateMachine.kt b/compiler/testData/codegen/box/coroutines/tailCallOptimizations/inlineWithStateMachine.kt index 680856feb1f..f3b6f416aa9 100644 --- a/compiler/testData/codegen/box/coroutines/tailCallOptimizations/inlineWithStateMachine.kt +++ b/compiler/testData/codegen/box/coroutines/tailCallOptimizations/inlineWithStateMachine.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // IGNORE_BACKEND: JVM_IR // WITH_RUNTIME // WITH_COROUTINES diff --git a/compiler/testData/codegen/box/coroutines/tailCallOptimizations/inlineWithoutStateMachine.kt b/compiler/testData/codegen/box/coroutines/tailCallOptimizations/inlineWithoutStateMachine.kt index 15941bbb3fe..ed114e23849 100644 --- a/compiler/testData/codegen/box/coroutines/tailCallOptimizations/inlineWithoutStateMachine.kt +++ b/compiler/testData/codegen/box/coroutines/tailCallOptimizations/inlineWithoutStateMachine.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // IGNORE_BACKEND: JVM_IR // WITH_RUNTIME // WITH_COROUTINES diff --git a/compiler/testData/codegen/box/coroutines/tailCallOptimizations/simple.kt b/compiler/testData/codegen/box/coroutines/tailCallOptimizations/simple.kt index 475a3d7d020..8955a3b15e9 100644 --- a/compiler/testData/codegen/box/coroutines/tailCallOptimizations/simple.kt +++ b/compiler/testData/codegen/box/coroutines/tailCallOptimizations/simple.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // IGNORE_BACKEND: JVM_IR // WITH_RUNTIME // WITH_COROUTINES diff --git a/compiler/testData/codegen/box/coroutines/tailCallOptimizations/unreachable.kt b/compiler/testData/codegen/box/coroutines/tailCallOptimizations/unreachable.kt index d7aa757e440..137ccec3893 100644 --- a/compiler/testData/codegen/box/coroutines/tailCallOptimizations/unreachable.kt +++ b/compiler/testData/codegen/box/coroutines/tailCallOptimizations/unreachable.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // IGNORE_BACKEND: JVM_IR // WITH_RUNTIME // WITH_COROUTINES diff --git a/compiler/testData/codegen/box/coroutines/tailCallOptimizations/whenUnit.kt b/compiler/testData/codegen/box/coroutines/tailCallOptimizations/whenUnit.kt index 29830b498e4..8a5675b0ccd 100644 --- a/compiler/testData/codegen/box/coroutines/tailCallOptimizations/whenUnit.kt +++ b/compiler/testData/codegen/box/coroutines/tailCallOptimizations/whenUnit.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // IGNORE_BACKEND: JVM_IR // WITH_RUNTIME // WITH_COROUTINES diff --git a/compiler/testData/codegen/box/coroutines/tailOperations/suspendWithIf.kt b/compiler/testData/codegen/box/coroutines/tailOperations/suspendWithIf.kt index 5829e9940d8..ab15dd097c3 100644 --- a/compiler/testData/codegen/box/coroutines/tailOperations/suspendWithIf.kt +++ b/compiler/testData/codegen/box/coroutines/tailOperations/suspendWithIf.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // IGNORE_BACKEND: JVM_IR // WITH_RUNTIME // WITH_COROUTINES diff --git a/compiler/testData/codegen/box/coroutines/tailOperations/suspendWithTryCatch.kt b/compiler/testData/codegen/box/coroutines/tailOperations/suspendWithTryCatch.kt index 8cf2360fa78..48fdb01be88 100644 --- a/compiler/testData/codegen/box/coroutines/tailOperations/suspendWithTryCatch.kt +++ b/compiler/testData/codegen/box/coroutines/tailOperations/suspendWithTryCatch.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // IGNORE_BACKEND: JVM_IR // WITH_RUNTIME // WITH_COROUTINES diff --git a/compiler/testData/codegen/box/coroutines/tailOperations/suspendWithWhen.kt b/compiler/testData/codegen/box/coroutines/tailOperations/suspendWithWhen.kt index e1bc6d236f3..64de4449fef 100644 --- a/compiler/testData/codegen/box/coroutines/tailOperations/suspendWithWhen.kt +++ b/compiler/testData/codegen/box/coroutines/tailOperations/suspendWithWhen.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // IGNORE_BACKEND: JVM_IR // WITH_RUNTIME // WITH_COROUTINES diff --git a/compiler/testData/codegen/box/coroutines/tailOperations/tailInlining.kt b/compiler/testData/codegen/box/coroutines/tailOperations/tailInlining.kt index 2d65e2ae077..eb9c4c48822 100644 --- a/compiler/testData/codegen/box/coroutines/tailOperations/tailInlining.kt +++ b/compiler/testData/codegen/box/coroutines/tailOperations/tailInlining.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // IGNORE_BACKEND: JVM_IR // WITH_RUNTIME // WITH_COROUTINES diff --git a/compiler/testData/codegen/box/coroutines/tryFinallyInsideInlineLambda.kt b/compiler/testData/codegen/box/coroutines/tryFinallyInsideInlineLambda.kt index 4d71143a95b..cf88b015e31 100644 --- a/compiler/testData/codegen/box/coroutines/tryFinallyInsideInlineLambda.kt +++ b/compiler/testData/codegen/box/coroutines/tryFinallyInsideInlineLambda.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // IGNORE_BACKEND: JVM_IR // WITH_RUNTIME // WITH_COROUTINES diff --git a/compiler/testData/codegen/box/coroutines/unitTypeReturn/suspendNonLocalReturn.kt b/compiler/testData/codegen/box/coroutines/unitTypeReturn/suspendNonLocalReturn.kt index 69bca8bffe4..88e0f22472a 100644 --- a/compiler/testData/codegen/box/coroutines/unitTypeReturn/suspendNonLocalReturn.kt +++ b/compiler/testData/codegen/box/coroutines/unitTypeReturn/suspendNonLocalReturn.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // IGNORE_BACKEND: JVM_IR // WITH_RUNTIME // WITH_COROUTINES diff --git a/compiler/testData/codegen/box/coroutines/unitTypeReturn/suspendReturn.kt b/compiler/testData/codegen/box/coroutines/unitTypeReturn/suspendReturn.kt index 83c1db2b473..6e11ece2aaa 100644 --- a/compiler/testData/codegen/box/coroutines/unitTypeReturn/suspendReturn.kt +++ b/compiler/testData/codegen/box/coroutines/unitTypeReturn/suspendReturn.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // IGNORE_BACKEND: JVM_IR // WITH_RUNTIME // WITH_COROUTINES diff --git a/compiler/testData/codegen/box/coroutines/varSpilling/nullSpilling.kt b/compiler/testData/codegen/box/coroutines/varSpilling/nullSpilling.kt index 9e1faa1b67e..6200eac0ef0 100644 --- a/compiler/testData/codegen/box/coroutines/varSpilling/nullSpilling.kt +++ b/compiler/testData/codegen/box/coroutines/varSpilling/nullSpilling.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // IGNORE_BACKEND: JVM_IR // WITH_RUNTIME // WITH_COROUTINES diff --git a/compiler/testData/codegen/box/coroutines/varValueConflictsWithTableSameSort.kt b/compiler/testData/codegen/box/coroutines/varValueConflictsWithTableSameSort.kt index bef3facfa79..70d86da63d2 100644 --- a/compiler/testData/codegen/box/coroutines/varValueConflictsWithTableSameSort.kt +++ b/compiler/testData/codegen/box/coroutines/varValueConflictsWithTableSameSort.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // IGNORE_BACKEND: JVM_IR // WITH_RUNTIME // WITH_COROUTINES diff --git a/compiler/testData/codegen/box/ranges/forInRangeWithImplicitReceiver.kt b/compiler/testData/codegen/box/ranges/forInRangeWithImplicitReceiver.kt index 12690da0d2e..a29e5a77e5e 100644 --- a/compiler/testData/codegen/box/ranges/forInRangeWithImplicitReceiver.kt +++ b/compiler/testData/codegen/box/ranges/forInRangeWithImplicitReceiver.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // WITH_RUNTIME import kotlin.test.assertEquals diff --git a/compiler/testData/codegen/box/ranges/forNullableIntInRangeWithImplicitReceiver.kt b/compiler/testData/codegen/box/ranges/forNullableIntInRangeWithImplicitReceiver.kt index f23f5afeb2c..8f9a4534ea6 100644 --- a/compiler/testData/codegen/box/ranges/forNullableIntInRangeWithImplicitReceiver.kt +++ b/compiler/testData/codegen/box/ranges/forNullableIntInRangeWithImplicitReceiver.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JS_IR // WITH_RUNTIME import kotlin.test.assertEquals diff --git a/compiler/testData/codegen/box/when/whenSubjectVariable/whenByString.kt b/compiler/testData/codegen/box/when/whenSubjectVariable/whenByString.kt index 49c80122e12..5d1a1a14044 100644 --- a/compiler/testData/codegen/box/when/whenSubjectVariable/whenByString.kt +++ b/compiler/testData/codegen/box/when/whenSubjectVariable/whenByString.kt @@ -1,6 +1,6 @@ // !LANGUAGE: +VariableDeclarationInWhenSubject // WITH_RUNTIME -// IGNORE_BACKEND: JS, JS_IR +// IGNORE_BACKEND: JS import kotlin.test.assertEquals diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java index ebd0138c145..db2a0763e66 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java @@ -3974,6 +3974,16 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/closures/capturedVarsOptimization/sharedSlotsWithCapturedVars.kt"); } + @TestMetadata("withCoroutinesNoStdLib.kt") + public void testWithCoroutinesNoStdLib_1_2() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/closures/capturedVarsOptimization/withCoroutinesNoStdLib.kt", "kotlin.coroutines.experimental"); + } + + @TestMetadata("withCoroutinesNoStdLib.kt") + public void testWithCoroutinesNoStdLib_1_3() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/closures/capturedVarsOptimization/withCoroutinesNoStdLib.kt", "kotlin.coroutines"); + } + @TestMetadata("withCoroutines.kt") public void testWithCoroutines_1_2() throws Exception { runTestWithPackageReplacement("compiler/testData/codegen/box/closures/capturedVarsOptimization/withCoroutines.kt", "kotlin.coroutines.experimental"); @@ -5942,6 +5952,16 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/statementLikeLastExpression.kt", "kotlin.coroutines"); } + @TestMetadata("suspendCallsInArguments.kt") + public void testSuspendCallsInArguments_1_2() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/suspendCallsInArguments.kt", "kotlin.coroutines.experimental"); + } + + @TestMetadata("suspendCallsInArguments.kt") + public void testSuspendCallsInArguments_1_3() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/suspendCallsInArguments.kt", "kotlin.coroutines"); + } + @TestMetadata("suspendCoroutineFromStateMachine.kt") public void testSuspendCoroutineFromStateMachine_1_2() throws Exception { runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/suspendCoroutineFromStateMachine.kt", "kotlin.coroutines.experimental"); @@ -6168,6 +6188,16 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/controlFlow/breakStatement.kt", "kotlin.coroutines"); } + @TestMetadata("complexChainSuspend.kt") + public void testComplexChainSuspend_1_2() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/controlFlow/complexChainSuspend.kt", "kotlin.coroutines.experimental"); + } + + @TestMetadata("complexChainSuspend.kt") + public void testComplexChainSuspend_1_3() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/controlFlow/complexChainSuspend.kt", "kotlin.coroutines"); + } + @TestMetadata("doWhileStatement.kt") public void testDoWhileStatement_1_2() throws Exception { runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/controlFlow/doWhileStatement.kt", "kotlin.coroutines.experimental"); @@ -6178,6 +6208,16 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/controlFlow/doWhileStatement.kt", "kotlin.coroutines"); } + @TestMetadata("finallyCatch.kt") + public void testFinallyCatch_1_2() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/controlFlow/finallyCatch.kt", "kotlin.coroutines.experimental"); + } + + @TestMetadata("finallyCatch.kt") + public void testFinallyCatch_1_3() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/controlFlow/finallyCatch.kt", "kotlin.coroutines"); + } + @TestMetadata("forContinue.kt") public void testForContinue_1_2() throws Exception { runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/controlFlow/forContinue.kt", "kotlin.coroutines.experimental"); @@ -6238,6 +6278,16 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/controlFlow/labeledWhile.kt", "kotlin.coroutines"); } + @TestMetadata("multipleCatchBlocksSuspend.kt") + public void testMultipleCatchBlocksSuspend_1_2() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/controlFlow/multipleCatchBlocksSuspend.kt", "kotlin.coroutines.experimental"); + } + + @TestMetadata("multipleCatchBlocksSuspend.kt") + public void testMultipleCatchBlocksSuspend_1_3() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/controlFlow/multipleCatchBlocksSuspend.kt", "kotlin.coroutines"); + } + @TestMetadata("returnFromFinally.kt") public void testReturnFromFinally_1_2() throws Exception { runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/controlFlow/returnFromFinally.kt", "kotlin.coroutines.experimental"); @@ -7156,6 +7206,83 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { } } + @TestMetadata("compiler/testData/codegen/box/coroutines/noStdLib") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class NoStdLib extends AbstractBlackBoxCodegenTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath); + } + + private void runTestWithPackageReplacement(String testDataFilePath, String packageName) throws Exception { + KotlinTestUtils.runTest(filePath -> doTestWithCoroutinesPackageReplacement(filePath, packageName), TargetBackend.JVM, testDataFilePath); + } + + public void testAllFilesPresentInNoStdLib() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/coroutines/noStdLib"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM, true); + } + + @TestMetadata("breakFinally.kt") + public void testBreakFinally_1_2() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/noStdLib/breakFinally.kt", "kotlin.coroutines.experimental"); + } + + @TestMetadata("breakFinally.kt") + public void testBreakFinally_1_3() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/noStdLib/breakFinally.kt", "kotlin.coroutines"); + } + + @TestMetadata("breakStatement.kt") + public void testBreakStatement_1_2() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/noStdLib/breakStatement.kt", "kotlin.coroutines.experimental"); + } + + @TestMetadata("breakStatement.kt") + public void testBreakStatement_1_3() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/noStdLib/breakStatement.kt", "kotlin.coroutines"); + } + + @TestMetadata("crossinline.kt") + public void testCrossinline_1_2() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/noStdLib/crossinline.kt", "kotlin.coroutines.experimental"); + } + + @TestMetadata("crossinline.kt") + public void testCrossinline_1_3() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/noStdLib/crossinline.kt", "kotlin.coroutines"); + } + + @TestMetadata("ifStatement.kt") + public void testIfStatement_1_2() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/noStdLib/ifStatement.kt", "kotlin.coroutines.experimental"); + } + + @TestMetadata("ifStatement.kt") + public void testIfStatement_1_3() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/noStdLib/ifStatement.kt", "kotlin.coroutines"); + } + + @TestMetadata("stateMachine.kt") + public void testStateMachine_1_2() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/noStdLib/stateMachine.kt", "kotlin.coroutines.experimental"); + } + + @TestMetadata("stateMachine.kt") + public void testStateMachine_1_3() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/noStdLib/stateMachine.kt", "kotlin.coroutines"); + } + + @TestMetadata("switchLikeWhen.kt") + public void testSwitchLikeWhen_1_2() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/noStdLib/switchLikeWhen.kt", "kotlin.coroutines.experimental"); + } + + @TestMetadata("switchLikeWhen.kt") + public void testSwitchLikeWhen_1_3() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/noStdLib/switchLikeWhen.kt", "kotlin.coroutines"); + } + } + @TestMetadata("compiler/testData/codegen/box/coroutines/redundantLocalsElimination") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index 5102602db92..fe284acf475 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -3974,6 +3974,16 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/closures/capturedVarsOptimization/sharedSlotsWithCapturedVars.kt"); } + @TestMetadata("withCoroutinesNoStdLib.kt") + public void testWithCoroutinesNoStdLib_1_2() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/closures/capturedVarsOptimization/withCoroutinesNoStdLib.kt", "kotlin.coroutines.experimental"); + } + + @TestMetadata("withCoroutinesNoStdLib.kt") + public void testWithCoroutinesNoStdLib_1_3() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/closures/capturedVarsOptimization/withCoroutinesNoStdLib.kt", "kotlin.coroutines"); + } + @TestMetadata("withCoroutines.kt") public void testWithCoroutines_1_2() throws Exception { runTestWithPackageReplacement("compiler/testData/codegen/box/closures/capturedVarsOptimization/withCoroutines.kt", "kotlin.coroutines.experimental"); @@ -5942,6 +5952,16 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/statementLikeLastExpression.kt", "kotlin.coroutines"); } + @TestMetadata("suspendCallsInArguments.kt") + public void testSuspendCallsInArguments_1_2() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/suspendCallsInArguments.kt", "kotlin.coroutines.experimental"); + } + + @TestMetadata("suspendCallsInArguments.kt") + public void testSuspendCallsInArguments_1_3() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/suspendCallsInArguments.kt", "kotlin.coroutines"); + } + @TestMetadata("suspendCoroutineFromStateMachine.kt") public void testSuspendCoroutineFromStateMachine_1_2() throws Exception { runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/suspendCoroutineFromStateMachine.kt", "kotlin.coroutines.experimental"); @@ -6168,6 +6188,16 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/controlFlow/breakStatement.kt", "kotlin.coroutines"); } + @TestMetadata("complexChainSuspend.kt") + public void testComplexChainSuspend_1_2() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/controlFlow/complexChainSuspend.kt", "kotlin.coroutines.experimental"); + } + + @TestMetadata("complexChainSuspend.kt") + public void testComplexChainSuspend_1_3() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/controlFlow/complexChainSuspend.kt", "kotlin.coroutines"); + } + @TestMetadata("doWhileStatement.kt") public void testDoWhileStatement_1_2() throws Exception { runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/controlFlow/doWhileStatement.kt", "kotlin.coroutines.experimental"); @@ -6178,6 +6208,16 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/controlFlow/doWhileStatement.kt", "kotlin.coroutines"); } + @TestMetadata("finallyCatch.kt") + public void testFinallyCatch_1_2() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/controlFlow/finallyCatch.kt", "kotlin.coroutines.experimental"); + } + + @TestMetadata("finallyCatch.kt") + public void testFinallyCatch_1_3() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/controlFlow/finallyCatch.kt", "kotlin.coroutines"); + } + @TestMetadata("forContinue.kt") public void testForContinue_1_2() throws Exception { runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/controlFlow/forContinue.kt", "kotlin.coroutines.experimental"); @@ -6238,6 +6278,16 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/controlFlow/labeledWhile.kt", "kotlin.coroutines"); } + @TestMetadata("multipleCatchBlocksSuspend.kt") + public void testMultipleCatchBlocksSuspend_1_2() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/controlFlow/multipleCatchBlocksSuspend.kt", "kotlin.coroutines.experimental"); + } + + @TestMetadata("multipleCatchBlocksSuspend.kt") + public void testMultipleCatchBlocksSuspend_1_3() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/controlFlow/multipleCatchBlocksSuspend.kt", "kotlin.coroutines"); + } + @TestMetadata("returnFromFinally.kt") public void testReturnFromFinally_1_2() throws Exception { runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/controlFlow/returnFromFinally.kt", "kotlin.coroutines.experimental"); @@ -7156,6 +7206,83 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes } } + @TestMetadata("compiler/testData/codegen/box/coroutines/noStdLib") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class NoStdLib extends AbstractLightAnalysisModeTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath); + } + + private void runTestWithPackageReplacement(String testDataFilePath, String packageName) throws Exception { + KotlinTestUtils.runTest(filePath -> doTestWithCoroutinesPackageReplacement(filePath, packageName), TargetBackend.JVM, testDataFilePath); + } + + public void testAllFilesPresentInNoStdLib() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/coroutines/noStdLib"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM, true); + } + + @TestMetadata("breakFinally.kt") + public void testBreakFinally_1_2() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/noStdLib/breakFinally.kt", "kotlin.coroutines.experimental"); + } + + @TestMetadata("breakFinally.kt") + public void testBreakFinally_1_3() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/noStdLib/breakFinally.kt", "kotlin.coroutines"); + } + + @TestMetadata("breakStatement.kt") + public void testBreakStatement_1_2() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/noStdLib/breakStatement.kt", "kotlin.coroutines.experimental"); + } + + @TestMetadata("breakStatement.kt") + public void testBreakStatement_1_3() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/noStdLib/breakStatement.kt", "kotlin.coroutines"); + } + + @TestMetadata("crossinline.kt") + public void testCrossinline_1_2() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/noStdLib/crossinline.kt", "kotlin.coroutines.experimental"); + } + + @TestMetadata("crossinline.kt") + public void testCrossinline_1_3() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/noStdLib/crossinline.kt", "kotlin.coroutines"); + } + + @TestMetadata("ifStatement.kt") + public void testIfStatement_1_2() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/noStdLib/ifStatement.kt", "kotlin.coroutines.experimental"); + } + + @TestMetadata("ifStatement.kt") + public void testIfStatement_1_3() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/noStdLib/ifStatement.kt", "kotlin.coroutines"); + } + + @TestMetadata("stateMachine.kt") + public void testStateMachine_1_2() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/noStdLib/stateMachine.kt", "kotlin.coroutines.experimental"); + } + + @TestMetadata("stateMachine.kt") + public void testStateMachine_1_3() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/noStdLib/stateMachine.kt", "kotlin.coroutines"); + } + + @TestMetadata("switchLikeWhen.kt") + public void testSwitchLikeWhen_1_2() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/noStdLib/switchLikeWhen.kt", "kotlin.coroutines.experimental"); + } + + @TestMetadata("switchLikeWhen.kt") + public void testSwitchLikeWhen_1_3() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/noStdLib/switchLikeWhen.kt", "kotlin.coroutines"); + } + } + @TestMetadata("compiler/testData/codegen/box/coroutines/redundantLocalsElimination") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java index 5fc97d9c5bc..5042df6b66b 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java @@ -3974,6 +3974,16 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/closures/capturedVarsOptimization/sharedSlotsWithCapturedVars.kt"); } + @TestMetadata("withCoroutinesNoStdLib.kt") + public void testWithCoroutinesNoStdLib_1_2() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/closures/capturedVarsOptimization/withCoroutinesNoStdLib.kt", "kotlin.coroutines.experimental"); + } + + @TestMetadata("withCoroutinesNoStdLib.kt") + public void testWithCoroutinesNoStdLib_1_3() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/closures/capturedVarsOptimization/withCoroutinesNoStdLib.kt", "kotlin.coroutines"); + } + @TestMetadata("withCoroutines.kt") public void testWithCoroutines_1_2() throws Exception { runTestWithPackageReplacement("compiler/testData/codegen/box/closures/capturedVarsOptimization/withCoroutines.kt", "kotlin.coroutines.experimental"); @@ -5942,6 +5952,16 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/statementLikeLastExpression.kt", "kotlin.coroutines"); } + @TestMetadata("suspendCallsInArguments.kt") + public void testSuspendCallsInArguments_1_2() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/suspendCallsInArguments.kt", "kotlin.coroutines.experimental"); + } + + @TestMetadata("suspendCallsInArguments.kt") + public void testSuspendCallsInArguments_1_3() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/suspendCallsInArguments.kt", "kotlin.coroutines"); + } + @TestMetadata("suspendCoroutineFromStateMachine.kt") public void testSuspendCoroutineFromStateMachine_1_2() throws Exception { runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/suspendCoroutineFromStateMachine.kt", "kotlin.coroutines.experimental"); @@ -6168,6 +6188,16 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/controlFlow/breakStatement.kt", "kotlin.coroutines"); } + @TestMetadata("complexChainSuspend.kt") + public void testComplexChainSuspend_1_2() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/controlFlow/complexChainSuspend.kt", "kotlin.coroutines.experimental"); + } + + @TestMetadata("complexChainSuspend.kt") + public void testComplexChainSuspend_1_3() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/controlFlow/complexChainSuspend.kt", "kotlin.coroutines"); + } + @TestMetadata("doWhileStatement.kt") public void testDoWhileStatement_1_2() throws Exception { runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/controlFlow/doWhileStatement.kt", "kotlin.coroutines.experimental"); @@ -6178,6 +6208,16 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/controlFlow/doWhileStatement.kt", "kotlin.coroutines"); } + @TestMetadata("finallyCatch.kt") + public void testFinallyCatch_1_2() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/controlFlow/finallyCatch.kt", "kotlin.coroutines.experimental"); + } + + @TestMetadata("finallyCatch.kt") + public void testFinallyCatch_1_3() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/controlFlow/finallyCatch.kt", "kotlin.coroutines"); + } + @TestMetadata("forContinue.kt") public void testForContinue_1_2() throws Exception { runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/controlFlow/forContinue.kt", "kotlin.coroutines.experimental"); @@ -6238,6 +6278,16 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/controlFlow/labeledWhile.kt", "kotlin.coroutines"); } + @TestMetadata("multipleCatchBlocksSuspend.kt") + public void testMultipleCatchBlocksSuspend_1_2() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/controlFlow/multipleCatchBlocksSuspend.kt", "kotlin.coroutines.experimental"); + } + + @TestMetadata("multipleCatchBlocksSuspend.kt") + public void testMultipleCatchBlocksSuspend_1_3() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/controlFlow/multipleCatchBlocksSuspend.kt", "kotlin.coroutines"); + } + @TestMetadata("returnFromFinally.kt") public void testReturnFromFinally_1_2() throws Exception { runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/controlFlow/returnFromFinally.kt", "kotlin.coroutines.experimental"); @@ -7156,6 +7206,83 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes } } + @TestMetadata("compiler/testData/codegen/box/coroutines/noStdLib") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class NoStdLib extends AbstractIrBlackBoxCodegenTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + private void runTestWithPackageReplacement(String testDataFilePath, String packageName) throws Exception { + KotlinTestUtils.runTest(filePath -> doTestWithCoroutinesPackageReplacement(filePath, packageName), TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInNoStdLib() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/coroutines/noStdLib"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM_IR, true); + } + + @TestMetadata("breakFinally.kt") + public void testBreakFinally_1_2() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/noStdLib/breakFinally.kt", "kotlin.coroutines.experimental"); + } + + @TestMetadata("breakFinally.kt") + public void testBreakFinally_1_3() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/noStdLib/breakFinally.kt", "kotlin.coroutines"); + } + + @TestMetadata("breakStatement.kt") + public void testBreakStatement_1_2() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/noStdLib/breakStatement.kt", "kotlin.coroutines.experimental"); + } + + @TestMetadata("breakStatement.kt") + public void testBreakStatement_1_3() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/noStdLib/breakStatement.kt", "kotlin.coroutines"); + } + + @TestMetadata("crossinline.kt") + public void testCrossinline_1_2() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/noStdLib/crossinline.kt", "kotlin.coroutines.experimental"); + } + + @TestMetadata("crossinline.kt") + public void testCrossinline_1_3() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/noStdLib/crossinline.kt", "kotlin.coroutines"); + } + + @TestMetadata("ifStatement.kt") + public void testIfStatement_1_2() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/noStdLib/ifStatement.kt", "kotlin.coroutines.experimental"); + } + + @TestMetadata("ifStatement.kt") + public void testIfStatement_1_3() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/noStdLib/ifStatement.kt", "kotlin.coroutines"); + } + + @TestMetadata("stateMachine.kt") + public void testStateMachine_1_2() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/noStdLib/stateMachine.kt", "kotlin.coroutines.experimental"); + } + + @TestMetadata("stateMachine.kt") + public void testStateMachine_1_3() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/noStdLib/stateMachine.kt", "kotlin.coroutines"); + } + + @TestMetadata("switchLikeWhen.kt") + public void testSwitchLikeWhen_1_2() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/noStdLib/switchLikeWhen.kt", "kotlin.coroutines.experimental"); + } + + @TestMetadata("switchLikeWhen.kt") + public void testSwitchLikeWhen_1_3() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/noStdLib/switchLikeWhen.kt", "kotlin.coroutines"); + } + } + @TestMetadata("compiler/testData/codegen/box/coroutines/redundantLocalsElimination") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) 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 0acff87e47d..d750f479c88 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 @@ -3864,6 +3864,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { runTest("compiler/testData/codegen/box/closures/capturedVarsOptimization/sharedSlotsWithCapturedVars.kt"); } + @TestMetadata("withCoroutinesNoStdLib.kt") + public void testWithCoroutinesNoStdLib_1_2() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/closures/capturedVarsOptimization/withCoroutinesNoStdLib.kt", "kotlin.coroutines.experimental"); + } + @TestMetadata("withCoroutines.kt") public void testWithCoroutines_1_2() throws Exception { runTestWithPackageReplacement("compiler/testData/codegen/box/closures/capturedVarsOptimization/withCoroutines.kt", "kotlin.coroutines.experimental"); @@ -5357,6 +5362,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/statementLikeLastExpression.kt", "kotlin.coroutines.experimental"); } + @TestMetadata("suspendCallsInArguments.kt") + public void testSuspendCallsInArguments_1_2() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/suspendCallsInArguments.kt", "kotlin.coroutines.experimental"); + } + @TestMetadata("suspendCoroutineFromStateMachine.kt") public void testSuspendCoroutineFromStateMachine_1_2() throws Exception { runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/suspendCoroutineFromStateMachine.kt", "kotlin.coroutines.experimental"); @@ -5468,11 +5478,21 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/controlFlow/breakStatement.kt", "kotlin.coroutines.experimental"); } + @TestMetadata("complexChainSuspend.kt") + public void testComplexChainSuspend_1_2() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/controlFlow/complexChainSuspend.kt", "kotlin.coroutines.experimental"); + } + @TestMetadata("doWhileStatement.kt") public void testDoWhileStatement_1_2() throws Exception { runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/controlFlow/doWhileStatement.kt", "kotlin.coroutines.experimental"); } + @TestMetadata("finallyCatch.kt") + public void testFinallyCatch_1_2() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/controlFlow/finallyCatch.kt", "kotlin.coroutines.experimental"); + } + @TestMetadata("forContinue.kt") public void testForContinue_1_2() throws Exception { runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/controlFlow/forContinue.kt", "kotlin.coroutines.experimental"); @@ -5503,6 +5523,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/controlFlow/labeledWhile.kt", "kotlin.coroutines.experimental"); } + @TestMetadata("multipleCatchBlocksSuspend.kt") + public void testMultipleCatchBlocksSuspend_1_2() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/controlFlow/multipleCatchBlocksSuspend.kt", "kotlin.coroutines.experimental"); + } + @TestMetadata("returnFromFinally.kt") public void testReturnFromFinally_1_2() throws Exception { runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/controlFlow/returnFromFinally.kt", "kotlin.coroutines.experimental"); @@ -6076,6 +6101,53 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { } } + @TestMetadata("compiler/testData/codegen/box/coroutines/noStdLib") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class NoStdLib extends AbstractIrJsCodegenBoxTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR, testDataFilePath); + } + + private void runTestWithPackageReplacement(String testDataFilePath, String packageName) throws Exception { + KotlinTestUtils.runTest0(filePath -> doTestWithCoroutinesPackageReplacement(filePath, packageName), TargetBackend.JS_IR, testDataFilePath); + } + + public void testAllFilesPresentInNoStdLib() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/coroutines/noStdLib"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JS_IR, true); + } + + @TestMetadata("breakFinally.kt") + public void testBreakFinally_1_2() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/noStdLib/breakFinally.kt", "kotlin.coroutines.experimental"); + } + + @TestMetadata("breakStatement.kt") + public void testBreakStatement_1_2() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/noStdLib/breakStatement.kt", "kotlin.coroutines.experimental"); + } + + @TestMetadata("crossinline.kt") + public void testCrossinline_1_2() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/noStdLib/crossinline.kt", "kotlin.coroutines.experimental"); + } + + @TestMetadata("ifStatement.kt") + public void testIfStatement_1_2() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/noStdLib/ifStatement.kt", "kotlin.coroutines.experimental"); + } + + @TestMetadata("stateMachine.kt") + public void testStateMachine_1_2() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/noStdLib/stateMachine.kt", "kotlin.coroutines.experimental"); + } + + @TestMetadata("switchLikeWhen.kt") + public void testSwitchLikeWhen_1_2() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/noStdLib/switchLikeWhen.kt", "kotlin.coroutines.experimental"); + } + } + @TestMetadata("compiler/testData/codegen/box/coroutines/redundantLocalsElimination") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) 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 7037b75c94d..90c685a1901 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 @@ -3884,6 +3884,16 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { runTest("compiler/testData/codegen/box/closures/capturedVarsOptimization/sharedSlotsWithCapturedVars.kt"); } + @TestMetadata("withCoroutinesNoStdLib.kt") + public void testWithCoroutinesNoStdLib_1_2() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/closures/capturedVarsOptimization/withCoroutinesNoStdLib.kt", "kotlin.coroutines.experimental"); + } + + @TestMetadata("withCoroutinesNoStdLib.kt") + public void testWithCoroutinesNoStdLib_1_3() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/closures/capturedVarsOptimization/withCoroutinesNoStdLib.kt", "kotlin.coroutines"); + } + @TestMetadata("withCoroutines.kt") public void testWithCoroutines_1_2() throws Exception { runTestWithPackageReplacement("compiler/testData/codegen/box/closures/capturedVarsOptimization/withCoroutines.kt", "kotlin.coroutines.experimental"); @@ -5682,6 +5692,16 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/statementLikeLastExpression.kt", "kotlin.coroutines"); } + @TestMetadata("suspendCallsInArguments.kt") + public void testSuspendCallsInArguments_1_2() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/suspendCallsInArguments.kt", "kotlin.coroutines.experimental"); + } + + @TestMetadata("suspendCallsInArguments.kt") + public void testSuspendCallsInArguments_1_3() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/suspendCallsInArguments.kt", "kotlin.coroutines"); + } + @TestMetadata("suspendCoroutineFromStateMachine.kt") public void testSuspendCoroutineFromStateMachine_1_2() throws Exception { runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/suspendCoroutineFromStateMachine.kt", "kotlin.coroutines.experimental"); @@ -5888,6 +5908,16 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/controlFlow/breakStatement.kt", "kotlin.coroutines"); } + @TestMetadata("complexChainSuspend.kt") + public void testComplexChainSuspend_1_2() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/controlFlow/complexChainSuspend.kt", "kotlin.coroutines.experimental"); + } + + @TestMetadata("complexChainSuspend.kt") + public void testComplexChainSuspend_1_3() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/controlFlow/complexChainSuspend.kt", "kotlin.coroutines"); + } + @TestMetadata("doWhileStatement.kt") public void testDoWhileStatement_1_2() throws Exception { runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/controlFlow/doWhileStatement.kt", "kotlin.coroutines.experimental"); @@ -5898,6 +5928,16 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/controlFlow/doWhileStatement.kt", "kotlin.coroutines"); } + @TestMetadata("finallyCatch.kt") + public void testFinallyCatch_1_2() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/controlFlow/finallyCatch.kt", "kotlin.coroutines.experimental"); + } + + @TestMetadata("finallyCatch.kt") + public void testFinallyCatch_1_3() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/controlFlow/finallyCatch.kt", "kotlin.coroutines"); + } + @TestMetadata("forContinue.kt") public void testForContinue_1_2() throws Exception { runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/controlFlow/forContinue.kt", "kotlin.coroutines.experimental"); @@ -5958,6 +5998,16 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/controlFlow/labeledWhile.kt", "kotlin.coroutines"); } + @TestMetadata("multipleCatchBlocksSuspend.kt") + public void testMultipleCatchBlocksSuspend_1_2() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/controlFlow/multipleCatchBlocksSuspend.kt", "kotlin.coroutines.experimental"); + } + + @TestMetadata("multipleCatchBlocksSuspend.kt") + public void testMultipleCatchBlocksSuspend_1_3() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/controlFlow/multipleCatchBlocksSuspend.kt", "kotlin.coroutines"); + } + @TestMetadata("returnFromFinally.kt") public void testReturnFromFinally_1_2() throws Exception { runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/controlFlow/returnFromFinally.kt", "kotlin.coroutines.experimental"); @@ -6856,6 +6906,83 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { } } + @TestMetadata("compiler/testData/codegen/box/coroutines/noStdLib") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class NoStdLib extends AbstractJsCodegenBoxTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS, testDataFilePath); + } + + private void runTestWithPackageReplacement(String testDataFilePath, String packageName) throws Exception { + KotlinTestUtils.runTest0(filePath -> doTestWithCoroutinesPackageReplacement(filePath, packageName), TargetBackend.JS, testDataFilePath); + } + + public void testAllFilesPresentInNoStdLib() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/coroutines/noStdLib"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JS, true); + } + + @TestMetadata("breakFinally.kt") + public void testBreakFinally_1_2() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/noStdLib/breakFinally.kt", "kotlin.coroutines.experimental"); + } + + @TestMetadata("breakFinally.kt") + public void testBreakFinally_1_3() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/noStdLib/breakFinally.kt", "kotlin.coroutines"); + } + + @TestMetadata("breakStatement.kt") + public void testBreakStatement_1_2() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/noStdLib/breakStatement.kt", "kotlin.coroutines.experimental"); + } + + @TestMetadata("breakStatement.kt") + public void testBreakStatement_1_3() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/noStdLib/breakStatement.kt", "kotlin.coroutines"); + } + + @TestMetadata("crossinline.kt") + public void testCrossinline_1_2() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/noStdLib/crossinline.kt", "kotlin.coroutines.experimental"); + } + + @TestMetadata("crossinline.kt") + public void testCrossinline_1_3() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/noStdLib/crossinline.kt", "kotlin.coroutines"); + } + + @TestMetadata("ifStatement.kt") + public void testIfStatement_1_2() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/noStdLib/ifStatement.kt", "kotlin.coroutines.experimental"); + } + + @TestMetadata("ifStatement.kt") + public void testIfStatement_1_3() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/noStdLib/ifStatement.kt", "kotlin.coroutines"); + } + + @TestMetadata("stateMachine.kt") + public void testStateMachine_1_2() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/noStdLib/stateMachine.kt", "kotlin.coroutines.experimental"); + } + + @TestMetadata("stateMachine.kt") + public void testStateMachine_1_3() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/noStdLib/stateMachine.kt", "kotlin.coroutines"); + } + + @TestMetadata("switchLikeWhen.kt") + public void testSwitchLikeWhen_1_2() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/noStdLib/switchLikeWhen.kt", "kotlin.coroutines.experimental"); + } + + @TestMetadata("switchLikeWhen.kt") + public void testSwitchLikeWhen_1_3() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/noStdLib/switchLikeWhen.kt", "kotlin.coroutines"); + } + } + @TestMetadata("compiler/testData/codegen/box/coroutines/redundantLocalsElimination") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/js/js.translator/testData/box/coroutines/localVarOptimization.kt b/js/js.translator/testData/box/coroutines/localVarOptimization.kt index 4f386c0fd21..ff89f207007 100644 --- a/js/js.translator/testData/box/coroutines/localVarOptimization.kt +++ b/js/js.translator/testData/box/coroutines/localVarOptimization.kt @@ -1,3 +1,4 @@ +// IGNORE_BACKEND: JS_IR // EXPECTED_REACHABLE_NODES: 1251 // DECLARES_VARIABLE: function=doResume name=k // PROPERTY_READ_COUNT: name=local$o count=1 diff --git a/js/js.translator/testData/testIr.html b/js/js.translator/testData/testIr.html new file mode 100644 index 00000000000..5d9b45f8887 --- /dev/null +++ b/js/js.translator/testData/testIr.html @@ -0,0 +1,12 @@ + + + + + + + + + +