[K/JS] Compile Kotlin coroutines as JS generator ^KT-63038 Fixed
This commit is contained in:
Vendored
+16
-1
@@ -1,3 +1,5 @@
|
||||
import kotlin.coroutines.*
|
||||
|
||||
internal suspend fun testDefaltParam(stepId: Int): Int {
|
||||
return callFun(ClassA2())
|
||||
}
|
||||
@@ -8,9 +10,22 @@ private suspend fun callFun(a: InterfaceA): Int {
|
||||
return a.functionA(0, "", false)
|
||||
}
|
||||
|
||||
suspend fun box(stepId: Int): String {
|
||||
suspend fun suspendBox(stepId: Int): String {
|
||||
if (testDefaltParam(stepId) != stepId) {
|
||||
return "Fail"
|
||||
}
|
||||
return "OK"
|
||||
}
|
||||
|
||||
fun runCoroutine(coroutine: suspend () -> String): String {
|
||||
var result: String = "Uninitialized"
|
||||
coroutine.startCoroutine(object : Continuation<String> {
|
||||
override val context = EmptyCoroutineContext
|
||||
override fun resumeWith(r: Result<String>) {
|
||||
result = r.getOrThrow()
|
||||
}
|
||||
})
|
||||
return result
|
||||
}
|
||||
|
||||
fun box(stepId: Int) = runCoroutine { suspendBox(stepId) }
|
||||
Reference in New Issue
Block a user