Files
kotlin-fork/compiler/testData/codegen/box/vararg/useSuspendFunResultAsVararg.kt
T
Ivan Kylchik c7435ba760 Replace all occurrences of WITH_RUNTIME with WITH_STDLIB
We are going to deprecate `WITH_RUNTIME` directive. The main reason
behind this change is that `WITH_STDLIB` directive better describes
its meaning, specifically it will add kotlin stdlib to test's classpath.
2021-11-17 15:26:38 +03:00

36 lines
788 B
Kotlin
Vendored

// WITH_STDLIB
// WITH_COROUTINES
import helpers.*
import kotlin.coroutines.*
fun builder(c: suspend () -> Unit) {
c.startCoroutine(EmptyContinuation)
}
class TodoItem(var value: String, var completed: Boolean) {
override fun toString(): String {
return "TodoItem(value='$value', completed=$completed)"
}
}
suspend fun getFromApi(): TodoItem {
return TodoItem("Test", false)
}
fun emulateLog(vararg strings: String): String {
return strings[0]
}
fun box(): String {
var stringifiedResult = ""
builder {
stringifiedResult = emulateLog("Result: " + getFromApi())
}
if (stringifiedResult != "Result: TodoItem(value='Test', completed=false)") {
return "Failed: Unexpected result ($stringifiedResult)"
}
return "OK"
}