From 06009a532b846120503de11fbecb1d8c58f139af Mon Sep 17 00:00:00 2001 From: Roman Artemev Date: Mon, 28 May 2018 19:14:56 +0300 Subject: [PATCH] Add test case to detect name clash in stdlib-js --- .../js/test/semantics/BoxJsTestGenerated.java | 5 +++++ .../js/test/semantics/IrBoxJsTestGenerated.java | 5 +++++ .../box/expression/cast/checkThrowCCE.kt | 16 ++++++++++++++++ 3 files changed, 26 insertions(+) create mode 100644 js/js.translator/testData/box/expression/cast/checkThrowCCE.kt 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 095b9aa00ec..bf8eb5933e6 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 @@ -1809,6 +1809,11 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest { runTest("js/js.translator/testData/box/expression/cast/castToNullable.kt"); } + @TestMetadata("checkThrowCCE.kt") + public void testCheckThrowCCE() throws Exception { + runTest("js/js.translator/testData/box/expression/cast/checkThrowCCE.kt"); + } + @TestMetadata("explicitUpcast.kt") public void testExplicitUpcast() throws Exception { runTest("js/js.translator/testData/box/expression/cast/explicitUpcast.kt"); diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/IrBoxJsTestGenerated.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/IrBoxJsTestGenerated.java index 241b6169e0c..b7db4e375ef 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/IrBoxJsTestGenerated.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/IrBoxJsTestGenerated.java @@ -1809,6 +1809,11 @@ public class IrBoxJsTestGenerated extends AbstractIrBoxJsTest { runTest("js/js.translator/testData/box/expression/cast/castToNullable.kt"); } + @TestMetadata("checkThrowCCE.kt") + public void testCheckThrowCCE() throws Exception { + runTest("js/js.translator/testData/box/expression/cast/checkThrowCCE.kt"); + } + @TestMetadata("explicitUpcast.kt") public void testExplicitUpcast() throws Exception { runTest("js/js.translator/testData/box/expression/cast/explicitUpcast.kt"); diff --git a/js/js.translator/testData/box/expression/cast/checkThrowCCE.kt b/js/js.translator/testData/box/expression/cast/checkThrowCCE.kt new file mode 100644 index 00000000000..696a5cd5c83 --- /dev/null +++ b/js/js.translator/testData/box/expression/cast/checkThrowCCE.kt @@ -0,0 +1,16 @@ +// IGNORE_BACKEND: JS_IR +// EXPECTED_REACHABLE_NODES: 1094 +package foo + +import kotlin.reflect.* + +fun box(): String { + try { + "fail".unsafeCast>().js + return "fail try" + } catch (cce: ClassCastException) { + return "OK" + } + + return "fail common" +} \ No newline at end of file