From 977781fa498f493a17b4be2a91718d9d29f43a68 Mon Sep 17 00:00:00 2001 From: Ilya Goncharov Date: Thu, 21 Jan 2021 13:03:56 +0300 Subject: [PATCH] [JS IR] Add tests with export all file and export nested class [JS IR] Skip dce driven for nested classes export ^KT-44469 fixed --- .../semantics/IrBoxJsES6TestGenerated.java | 10 ++++++++ .../ir/semantics/IrBoxJsTestGenerated.java | 10 ++++++++ .../js/test/semantics/BoxJsTestGenerated.java | 10 ++++++++ .../testData/box/export/exportAllFile.kt | 22 ++++++++++++++++ .../testData/box/export/exportNestedClass.kt | 25 +++++++++++++++++++ 5 files changed, 77 insertions(+) create mode 100644 js/js.translator/testData/box/export/exportAllFile.kt create mode 100644 js/js.translator/testData/box/export/exportNestedClass.kt diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrBoxJsES6TestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrBoxJsES6TestGenerated.java index 766f3af1e52..a2520f7fae2 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrBoxJsES6TestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrBoxJsES6TestGenerated.java @@ -1617,6 +1617,16 @@ public class IrBoxJsES6TestGenerated extends AbstractIrBoxJsES6Test { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("js/js.translator/testData/box/export"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.JS_IR_ES6, true); } + @TestMetadata("exportAllFile.kt") + public void testExportAllFile() throws Exception { + runTest("js/js.translator/testData/box/export/exportAllFile.kt"); + } + + @TestMetadata("exportNestedClass.kt") + public void testExportNestedClass() throws Exception { + runTest("js/js.translator/testData/box/export/exportNestedClass.kt"); + } + @TestMetadata("nonIndetifierModuleName.kt") public void testNonIndetifierModuleName() throws Exception { runTest("js/js.translator/testData/box/export/nonIndetifierModuleName.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrBoxJsTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrBoxJsTestGenerated.java index 0f8ae44fe07..6a722ac2d4b 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrBoxJsTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrBoxJsTestGenerated.java @@ -1617,6 +1617,16 @@ public class IrBoxJsTestGenerated extends AbstractIrBoxJsTest { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("js/js.translator/testData/box/export"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.JS_IR, true); } + @TestMetadata("exportAllFile.kt") + public void testExportAllFile() throws Exception { + runTest("js/js.translator/testData/box/export/exportAllFile.kt"); + } + + @TestMetadata("exportNestedClass.kt") + public void testExportNestedClass() throws Exception { + runTest("js/js.translator/testData/box/export/exportNestedClass.kt"); + } + @TestMetadata("nonIndetifierModuleName.kt") public void testNonIndetifierModuleName() throws Exception { runTest("js/js.translator/testData/box/export/nonIndetifierModuleName.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/BoxJsTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/BoxJsTestGenerated.java index 4c672f1dcaa..4bffcc65168 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/BoxJsTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/BoxJsTestGenerated.java @@ -1622,6 +1622,16 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("js/js.translator/testData/box/export"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.JS, true); } + @TestMetadata("exportAllFile.kt") + public void testExportAllFile() throws Exception { + runTest("js/js.translator/testData/box/export/exportAllFile.kt"); + } + + @TestMetadata("exportNestedClass.kt") + public void testExportNestedClass() throws Exception { + runTest("js/js.translator/testData/box/export/exportNestedClass.kt"); + } + @TestMetadata("nonIndetifierModuleName.kt") public void testNonIndetifierModuleName() throws Exception { runTest("js/js.translator/testData/box/export/nonIndetifierModuleName.kt"); diff --git a/js/js.translator/testData/box/export/exportAllFile.kt b/js/js.translator/testData/box/export/exportAllFile.kt new file mode 100644 index 00000000000..bddf364de5a --- /dev/null +++ b/js/js.translator/testData/box/export/exportAllFile.kt @@ -0,0 +1,22 @@ +// IGNORE_BACKEND: JS +// RUN_PLAIN_BOX_FUNCTION +// INFER_MAIN_MODULE + +// MODULE: export-all-file +// FILE: lib.kt +@file:JsExport + +abstract class A { + abstract fun foo(k: String): String +} + +class B : A() { + override fun foo(k: String): String { + return "O" + k + } +} + +// FILE: test.js +function box() { + return new this["export-all-file"].B().foo("K"); +} \ No newline at end of file diff --git a/js/js.translator/testData/box/export/exportNestedClass.kt b/js/js.translator/testData/box/export/exportNestedClass.kt new file mode 100644 index 00000000000..ac724223f75 --- /dev/null +++ b/js/js.translator/testData/box/export/exportNestedClass.kt @@ -0,0 +1,25 @@ +// IGNORE_BACKEND: JS +// RUN_PLAIN_BOX_FUNCTION +// INFER_MAIN_MODULE +// SKIP_DCE_DRIVEN + +// MODULE: export-nested-class +// FILE: lib.kt + +abstract class A { + abstract fun foo(k: String): String +} + +@JsExport +class B { + class Foo : A() { + override fun foo(k: String): String { + return "O" + k + } + } +} + +// FILE: test.js +function box() { + return new this["export-nested-class"].B.Foo().foo("K"); +} \ No newline at end of file