[JS IR] Add test on call of suspend super type

This commit is contained in:
Ilya Goncharov
2021-08-19 11:57:28 +03:00
committed by Space
parent ee712b2770
commit 4179d078ca
8 changed files with 86 additions and 0 deletions
@@ -9776,6 +9776,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
runTest("compiler/testData/codegen/box/coroutines/suspendFunctionAsSupertype.kt");
}
@Test
@TestMetadata("suspendFunctionAsSupertypeCall.kt")
public void testSuspendFunctionAsSupertypeCall() throws Exception {
runTest("compiler/testData/codegen/box/coroutines/suspendFunctionAsSupertypeCall.kt");
}
@Test
@TestMetadata("suspendFunctionMethodReference.kt")
public void testSuspendFunctionMethodReference() throws Exception {
@@ -0,0 +1,48 @@
// WITH_RUNTIME
// !LANGUAGE: +SuspendFunctionAsSupertype
import kotlin.coroutines.*
var failure: String? = "FAIL ILLEGAL STATE"
class SuspendNoneUnit: suspend () -> Unit {
override suspend fun invoke() {
failure = null
}
}
class SuspendIntString: suspend (Int) -> String {
override suspend fun invoke(p: Int): String {
failure = if (p == 7) null else "FAIL CONDITION"
return "OK"
}
}
fun suspendNoneUnit(): String? {
failure = "FAIL INHERITED 2"
val a = suspend {
val snu = SuspendNoneUnit()
snu()
}
a.startCoroutine(Continuation(EmptyCoroutineContext) { it.getOrThrow() })
return failure
}
fun suspendIntString(): String? {
failure = "FAIL INHERITED 3"
val a = suspend {
val sis = SuspendIntString()
sis(7)
}
a.startCoroutine(Continuation(EmptyCoroutineContext) { it.getOrThrow() })
return failure
}
fun box(): String {
val failures = listOfNotNull(
suspendNoneUnit(),
suspendIntString()
)
return if (failures.isNotEmpty()) failures.joinToString("\n") else "OK"
}
@@ -9668,6 +9668,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
runTest("compiler/testData/codegen/box/coroutines/suspendFunctionAsSupertype.kt");
}
@Test
@TestMetadata("suspendFunctionAsSupertypeCall.kt")
public void testSuspendFunctionAsSupertypeCall() throws Exception {
runTest("compiler/testData/codegen/box/coroutines/suspendFunctionAsSupertypeCall.kt");
}
@Test
@TestMetadata("suspendFunctionMethodReference.kt")
public void testSuspendFunctionMethodReference() throws Exception {
@@ -9776,6 +9776,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
runTest("compiler/testData/codegen/box/coroutines/suspendFunctionAsSupertype.kt");
}
@Test
@TestMetadata("suspendFunctionAsSupertypeCall.kt")
public void testSuspendFunctionAsSupertypeCall() throws Exception {
runTest("compiler/testData/codegen/box/coroutines/suspendFunctionAsSupertypeCall.kt");
}
@Test
@TestMetadata("suspendFunctionMethodReference.kt")
public void testSuspendFunctionMethodReference() throws Exception {
@@ -7565,6 +7565,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
runTest("compiler/testData/codegen/box/coroutines/suspendFunImportedFromObject.kt");
}
@TestMetadata("suspendFunctionAsSupertypeCall.kt")
public void testSuspendFunctionAsSupertypeCall() throws Exception {
runTest("compiler/testData/codegen/box/coroutines/suspendFunctionAsSupertypeCall.kt");
}
@TestMetadata("suspendFunctionMethodReference.kt")
public void testSuspendFunctionMethodReference() throws Exception {
runTest("compiler/testData/codegen/box/coroutines/suspendFunctionMethodReference.kt");
@@ -6729,6 +6729,11 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes
runTest("compiler/testData/codegen/box/coroutines/suspendFunctionAsSupertype.kt");
}
@TestMetadata("suspendFunctionAsSupertypeCall.kt")
public void testSuspendFunctionAsSupertypeCall() throws Exception {
runTest("compiler/testData/codegen/box/coroutines/suspendFunctionAsSupertypeCall.kt");
}
@TestMetadata("suspendFunctionMethodReference.kt")
public void testSuspendFunctionMethodReference() throws Exception {
runTest("compiler/testData/codegen/box/coroutines/suspendFunctionMethodReference.kt");
@@ -6135,6 +6135,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
runTest("compiler/testData/codegen/box/coroutines/suspendFunctionAsSupertype.kt");
}
@TestMetadata("suspendFunctionAsSupertypeCall.kt")
public void testSuspendFunctionAsSupertypeCall() throws Exception {
runTest("compiler/testData/codegen/box/coroutines/suspendFunctionAsSupertypeCall.kt");
}
@TestMetadata("suspendFunctionMethodReference.kt")
public void testSuspendFunctionMethodReference() throws Exception {
runTest("compiler/testData/codegen/box/coroutines/suspendFunctionMethodReference.kt");
@@ -6135,6 +6135,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
runTest("compiler/testData/codegen/box/coroutines/suspendFunctionAsSupertype.kt");
}
@TestMetadata("suspendFunctionAsSupertypeCall.kt")
public void testSuspendFunctionAsSupertypeCall() throws Exception {
runTest("compiler/testData/codegen/box/coroutines/suspendFunctionAsSupertypeCall.kt");
}
@TestMetadata("suspendFunctionMethodReference.kt")
public void testSuspendFunctionMethodReference() throws Exception {
runTest("compiler/testData/codegen/box/coroutines/suspendFunctionMethodReference.kt");