[K/N][Tests] Migrate objcSmoke & objcTests tests
^KT-61259
This commit is contained in:
committed by
Space Team
parent
58f7dd1c83
commit
524f0d335e
@@ -0,0 +1,34 @@
|
||||
package kt50786
|
||||
|
||||
import kotlinx.cinterop.*
|
||||
import kotlin.coroutines.*
|
||||
|
||||
open class EmptyContinuation(override val context: CoroutineContext = EmptyCoroutineContext) : Continuation<Any?> {
|
||||
companion object : EmptyContinuation()
|
||||
override fun resumeWith(result: Result<Any?>) { result.getOrThrow() }
|
||||
}
|
||||
|
||||
lateinit var continuation: Continuation<Unit>
|
||||
|
||||
suspend fun suspendHere(): Unit = suspendCoroutine { cont ->
|
||||
continuation = cont
|
||||
}
|
||||
|
||||
|
||||
fun startCoroutine(block: suspend () -> Unit) {
|
||||
block.startCoroutine(EmptyContinuation)
|
||||
}
|
||||
|
||||
@kotlin.test.Test
|
||||
fun testSafeSuspensionIsAllowedInAutoreleasepool() {
|
||||
// This test checks that the compiler doesn't prohibit calling suspend functions from `autoreleasepool {}`
|
||||
// if this call is not actually in the block, but in the local declaration inside it.
|
||||
// See https://youtrack.jetbrains.com/issue/KT-50786 for more details.
|
||||
autoreleasepool {
|
||||
startCoroutine {
|
||||
suspendHere()
|
||||
}
|
||||
}
|
||||
|
||||
continuation.resume(Unit)
|
||||
}
|
||||
Reference in New Issue
Block a user