diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/BoxJsTestGenerated.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/BoxJsTestGenerated.java index 707fac75316..132db01c201 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/BoxJsTestGenerated.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/BoxJsTestGenerated.java @@ -925,6 +925,12 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest { String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/coroutines/localVarOptimization.kt"); doTest(fileName); } + + @TestMetadata("nativeExceptions.kt") + public void testNativeExceptions() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/coroutines/nativeExceptions.kt"); + doTest(fileName); + } } @TestMetadata("js/js.translator/testData/box/crossModuleRef") diff --git a/js/js.translator/testData/box/coroutines/nativeExceptions.kt b/js/js.translator/testData/box/coroutines/nativeExceptions.kt new file mode 100644 index 00000000000..b610f0b5807 --- /dev/null +++ b/js/js.translator/testData/box/coroutines/nativeExceptions.kt @@ -0,0 +1,53 @@ +// EXPECTED_REACHABLE_NODES: 1123 +import kotlin.coroutines.experimental.* +import kotlin.coroutines.experimental.intrinsics.* + +private var next: () -> Unit = {} +private var stopped = false + +suspend fun delay(): Unit = suspendCoroutine { c -> + next = { c.resume(Unit) } +} + +fun build(c: suspend () -> Unit) { + c.startCoroutine(object : Continuation { + override fun resume(x: Unit) { + stopped = true + } + + override fun resumeWithException(x: Throwable) { + stopped = true + } + + override val context = EmptyCoroutineContext + }) +} + +fun box(): String { + var log = "" + + build { + try { + log += "before delay;" + delay() + log += "after delay;" + js("undefined").lalala + log += "ignore;" + } + catch (e: dynamic) { + log += "caught ${e.name};" + } + finally { + log += "finally;" + } + } + + while (!stopped) { + log += "@;" + next() + } + + if (log != "before delay;@;after delay;caught TypeError;finally;") return "fail: $log" + + return "OK" +} \ No newline at end of file