Files
kotlin-fork/compiler/testData/codegen/boxInline/suspend/stateMachine/lambdaTransformation.kt
T
Pavel Punegov 8dcb763eca [K/N][test] Reset state in StateMachineChecker before the test
boxInline tests for suspend use StateMachineChecker and share the state
if compiled and run together. The single value accessed from all tests.
It is enough to reset state before the test is run.
2024-02-15 18:07:25 +00:00

52 lines
907 B
Kotlin
Vendored

// CHECK_STATE_MACHINE
// WITH_COROUTINES
// NO_CHECK_LAMBDA_INLINING
// WITH_STDLIB
// FILE: test.kt
import helpers.*
import kotlin.coroutines.*
const val DEBUG = false
inline fun inlineFun(b: () -> Unit) {
if (DEBUG) {
inlineFunReal(b)
}
}
inline fun inlineFunReal(b: () -> Unit) {
try {
b()
} finally {
}
}
fun builder(c: suspend () -> Unit) {
c.startCoroutine(CheckStateMachineContinuation)
}
// FILE: box.kt
import helpers.*
class Sample {
fun test() {
inlineFun {
builder {
inlineFun {
suspendFun()
suspendFun()
}
}
}
}
suspend fun suspendFun() = StateMachineChecker.suspendHere()
}
fun box(): String {
StateMachineChecker.reset()
Sample().test()
StateMachineChecker.check(0, checkFinished = false)
return "OK"
}