Add a suspend test that fails on JVM_IR

This commit is contained in:
pyos
2020-02-20 11:38:58 +01:00
committed by Ilmir Usmanov
parent 52e7cd5725
commit 39ebc8cfa5
7 changed files with 90 additions and 0 deletions
@@ -0,0 +1,50 @@
// FILE: test.kt
// COMMON_COROUTINES_TEST
// WITH_RUNTIME
// WITH_COROUTINES
// IGNORE_BACKEND: JVM_IR
// IGNORE_BACKEND_MULTI_MODULE: JVM_IR
interface Flow<T> {
abstract suspend fun collect(collector: FlowCollector<T>)
}
interface FlowCollector<T> {
suspend fun emit(value: T)
}
inline fun <T> flow(crossinline body: suspend FlowCollector<T>.() -> Unit): Flow<T> =
object : Flow<T> {
override suspend fun collect(collector: FlowCollector<T>) = collector.body()
}
suspend inline fun <T> Flow<T>.collect(crossinline body: suspend (T) -> Unit) =
collect(object : FlowCollector<T> {
override suspend fun emit(value: T) = body(value)
})
inline fun <T> Flow<T>.filter(crossinline predicate: suspend (T) -> Boolean): Flow<T> =
flow<T> {
this@filter.collect { if (predicate(it)) emit(it) }
}
inline fun <reified R> Flow<*>.filterIsInstance(): Flow<R> =
filter { it is R } as Flow<R>
// FILE: box.kt
// COMMON_COROUTINES_TEST
import COROUTINES_PACKAGE.*
import helpers.*
fun builder(c: suspend () -> Unit) {
c.startCoroutine(EmptyContinuation)
}
fun box(): String {
var result = "fail"
builder {
flow<String> { emit("OK") }.filterIsInstance<String>().collect { result = it }
}
return result
}
@@ -3653,6 +3653,16 @@ public class BlackBoxInlineCodegenTestGenerated extends AbstractBlackBoxInlineCo
runTestWithPackageReplacement("compiler/testData/codegen/boxInline/suspend/crossinlineSuspendLambdaInsideCrossinlineSuspendLambda.kt", "kotlin.coroutines");
}
@TestMetadata("doubleRegenerationWithNonSuspendingLambda.kt")
public void testDoubleRegenerationWithNonSuspendingLambda_1_2() throws Exception {
runTestWithPackageReplacement("compiler/testData/codegen/boxInline/suspend/doubleRegenerationWithNonSuspendingLambda.kt", "kotlin.coroutines.experimental");
}
@TestMetadata("doubleRegenerationWithNonSuspendingLambda.kt")
public void testDoubleRegenerationWithNonSuspendingLambda_1_3() throws Exception {
runTestWithPackageReplacement("compiler/testData/codegen/boxInline/suspend/doubleRegenerationWithNonSuspendingLambda.kt", "kotlin.coroutines");
}
@TestMetadata("enclodingMethod.kt")
public void testEnclodingMethod_1_2() throws Exception {
runTestWithPackageReplacement("compiler/testData/codegen/boxInline/suspend/enclodingMethod.kt", "kotlin.coroutines.experimental");
@@ -3653,6 +3653,16 @@ public class CompileKotlinAgainstInlineKotlinTestGenerated extends AbstractCompi
runTestWithPackageReplacement("compiler/testData/codegen/boxInline/suspend/crossinlineSuspendLambdaInsideCrossinlineSuspendLambda.kt", "kotlin.coroutines");
}
@TestMetadata("doubleRegenerationWithNonSuspendingLambda.kt")
public void testDoubleRegenerationWithNonSuspendingLambda_1_2() throws Exception {
runTestWithPackageReplacement("compiler/testData/codegen/boxInline/suspend/doubleRegenerationWithNonSuspendingLambda.kt", "kotlin.coroutines.experimental");
}
@TestMetadata("doubleRegenerationWithNonSuspendingLambda.kt")
public void testDoubleRegenerationWithNonSuspendingLambda_1_3() throws Exception {
runTestWithPackageReplacement("compiler/testData/codegen/boxInline/suspend/doubleRegenerationWithNonSuspendingLambda.kt", "kotlin.coroutines");
}
@TestMetadata("enclodingMethod.kt")
public void testEnclodingMethod_1_2() throws Exception {
runTestWithPackageReplacement("compiler/testData/codegen/boxInline/suspend/enclodingMethod.kt", "kotlin.coroutines.experimental");
@@ -3643,6 +3643,11 @@ public class IrBlackBoxInlineCodegenTestGenerated extends AbstractIrBlackBoxInli
runTestWithPackageReplacement("compiler/testData/codegen/boxInline/suspend/crossinlineSuspendLambdaInsideCrossinlineSuspendLambda.kt", "kotlin.coroutines");
}
@TestMetadata("doubleRegenerationWithNonSuspendingLambda.kt")
public void testDoubleRegenerationWithNonSuspendingLambda_1_3() throws Exception {
runTestWithPackageReplacement("compiler/testData/codegen/boxInline/suspend/doubleRegenerationWithNonSuspendingLambda.kt", "kotlin.coroutines");
}
@TestMetadata("enclodingMethod.kt")
public void testEnclodingMethod_1_3() throws Exception {
runTestWithPackageReplacement("compiler/testData/codegen/boxInline/suspend/enclodingMethod.kt", "kotlin.coroutines");
@@ -3643,6 +3643,11 @@ public class IrCompileKotlinAgainstInlineKotlinTestGenerated extends AbstractIrC
runTestWithPackageReplacement("compiler/testData/codegen/boxInline/suspend/crossinlineSuspendLambdaInsideCrossinlineSuspendLambda.kt", "kotlin.coroutines");
}
@TestMetadata("doubleRegenerationWithNonSuspendingLambda.kt")
public void testDoubleRegenerationWithNonSuspendingLambda_1_3() throws Exception {
runTestWithPackageReplacement("compiler/testData/codegen/boxInline/suspend/doubleRegenerationWithNonSuspendingLambda.kt", "kotlin.coroutines");
}
@TestMetadata("enclodingMethod.kt")
public void testEnclodingMethod_1_3() throws Exception {
runTestWithPackageReplacement("compiler/testData/codegen/boxInline/suspend/enclodingMethod.kt", "kotlin.coroutines");
@@ -43,6 +43,11 @@ public class IrInlineSuspendTestsGenerated extends AbstractIrInlineSuspendTests
runTestWithPackageReplacement("compiler/testData/codegen/boxInline/suspend/crossinlineSuspendLambdaInsideCrossinlineSuspendLambda.kt", "kotlin.coroutines");
}
@TestMetadata("doubleRegenerationWithNonSuspendingLambda.kt")
public void testDoubleRegenerationWithNonSuspendingLambda_1_3() throws Exception {
runTestWithPackageReplacement("compiler/testData/codegen/boxInline/suspend/doubleRegenerationWithNonSuspendingLambda.kt", "kotlin.coroutines");
}
@TestMetadata("inlineOrdinaryOfCrossinlineSuspend.kt")
public void testInlineOrdinaryOfCrossinlineSuspend_1_3() throws Exception {
runTestWithPackageReplacement("compiler/testData/codegen/boxInline/suspend/inlineOrdinaryOfCrossinlineSuspend.kt", "kotlin.coroutines");
@@ -43,6 +43,11 @@ public class InlineSuspendTestsGenerated extends AbstractInlineSuspendTests {
runTestWithPackageReplacement("compiler/testData/codegen/boxInline/suspend/crossinlineSuspendLambdaInsideCrossinlineSuspendLambda.kt", "kotlin.coroutines");
}
@TestMetadata("doubleRegenerationWithNonSuspendingLambda.kt")
public void testDoubleRegenerationWithNonSuspendingLambda_1_3() throws Exception {
runTestWithPackageReplacement("compiler/testData/codegen/boxInline/suspend/doubleRegenerationWithNonSuspendingLambda.kt", "kotlin.coroutines");
}
@TestMetadata("inlineOrdinaryOfCrossinlineSuspend.kt")
public void testInlineOrdinaryOfCrossinlineSuspend_1_3() throws Exception {
runTestWithPackageReplacement("compiler/testData/codegen/boxInline/suspend/inlineOrdinaryOfCrossinlineSuspend.kt", "kotlin.coroutines");