5b62c9e54d
This commit ports the (parameterless) main integration tests in `CompilerSmokeTest` to the IR backend. It also includes a simple suspend main test. The advanced ones (like `helloAppSuspendParameterlessMain`) are currently blocked by pending changes to capturing suspend lambdas, which are underway.
38 lines
757 B
Kotlin
Vendored
38 lines
757 B
Kotlin
Vendored
@file:JvmMultifileClass
|
|
@file:JvmName("Foo")
|
|
package Hello
|
|
|
|
import kotlin.concurrent.thread
|
|
import kotlin.coroutines.suspendCoroutine
|
|
import kotlin.coroutines.resume
|
|
|
|
@kotlin.jvm.Volatile
|
|
private var result = ""
|
|
@kotlin.jvm.Volatile
|
|
private var callback: Function0<Unit>? = null
|
|
|
|
suspend fun appendAndSuspend(s: String) {
|
|
result += s
|
|
|
|
suspendCoroutine<Unit> { continuation ->
|
|
callback = {
|
|
continuation.resume(Unit)
|
|
}
|
|
}
|
|
}
|
|
|
|
suspend fun main(args: Array<String>) {
|
|
thread(isDaemon = true) {
|
|
while (true) {
|
|
val c = callback
|
|
c?.invoke()
|
|
Thread.sleep(500)
|
|
}
|
|
}
|
|
|
|
appendAndSuspend(args[0])
|
|
appendAndSuspend(args[1])
|
|
println(result)
|
|
callback = null
|
|
}
|