Add test case to check delegation of suspend method
This commit is contained in:
committed by
Roman Artemev
parent
f826a253e3
commit
8862b26bbd
@@ -0,0 +1,31 @@
|
||||
// WITH_COROUTINES
|
||||
// COMMON_COROUTINES_TEST
|
||||
|
||||
import helpers.*
|
||||
import COROUTINES_PACKAGE.*
|
||||
import COROUTINES_PACKAGE.intrinsics.*
|
||||
|
||||
var result = "fail"
|
||||
|
||||
interface SuspendInterface {
|
||||
suspend fun foo(v: String)
|
||||
}
|
||||
|
||||
class Delegate : SuspendInterface {
|
||||
override suspend fun foo(v: String) {
|
||||
result = v
|
||||
}
|
||||
}
|
||||
|
||||
class Decorator(parent: SuspendInterface) : SuspendInterface by parent
|
||||
|
||||
fun execute(c: suspend () -> Unit) = c.startCoroutine(EmptyContinuation)
|
||||
|
||||
fun box(): String {
|
||||
|
||||
execute {
|
||||
Decorator(Delegate()).foo("OK")
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
Reference in New Issue
Block a user