[K/JS] test(@JsExport): add few more tests on export after ExportModel discussion meeting.
This commit is contained in:
@@ -2118,6 +2118,12 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
|
||||
runTest("js/js.translator/testData/box/export/exportEnumClass.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("exportInnerClass.kt")
|
||||
public void testExportInnerClass() throws Exception {
|
||||
runTest("js/js.translator/testData/box/export/exportInnerClass.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("exportInterface.kt")
|
||||
public void testExportInterface() throws Exception {
|
||||
@@ -2177,6 +2183,12 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
|
||||
public void testReservedModuleName() throws Exception {
|
||||
runTest("js/js.translator/testData/box/export/reservedModuleName.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("vararg.kt")
|
||||
public void testVararg() throws Exception {
|
||||
runTest("js/js.translator/testData/box/export/vararg.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
|
||||
+12
@@ -2584,6 +2584,12 @@ public class FirJsTestGenerated extends AbstractFirJsTest {
|
||||
runTest("js/js.translator/testData/box/export/exportEnumClass.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("exportInnerClass.kt")
|
||||
public void testExportInnerClass() throws Exception {
|
||||
runTest("js/js.translator/testData/box/export/exportInnerClass.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("exportInterface.kt")
|
||||
public void testExportInterface() throws Exception {
|
||||
@@ -2649,6 +2655,12 @@ public class FirJsTestGenerated extends AbstractFirJsTest {
|
||||
public void testReservedModuleName() throws Exception {
|
||||
runTest("js/js.translator/testData/box/export/reservedModuleName.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("vararg.kt")
|
||||
public void testVararg() throws Exception {
|
||||
runTest("js/js.translator/testData/box/export/vararg.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
|
||||
+12
@@ -2584,6 +2584,12 @@ public class IrBoxJsTestGenerated extends AbstractIrBoxJsTest {
|
||||
runTest("js/js.translator/testData/box/export/exportEnumClass.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("exportInnerClass.kt")
|
||||
public void testExportInnerClass() throws Exception {
|
||||
runTest("js/js.translator/testData/box/export/exportInnerClass.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("exportInterface.kt")
|
||||
public void testExportInterface() throws Exception {
|
||||
@@ -2649,6 +2655,12 @@ public class IrBoxJsTestGenerated extends AbstractIrBoxJsTest {
|
||||
public void testReservedModuleName() throws Exception {
|
||||
runTest("js/js.translator/testData/box/export/reservedModuleName.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("vararg.kt")
|
||||
public void testVararg() throws Exception {
|
||||
runTest("js/js.translator/testData/box/export/vararg.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
// EXPECTED_REACHABLE_NODES: 1252
|
||||
// IGNORE_BACKEND: JS
|
||||
// RUN_PLAIN_BOX_FUNCTION
|
||||
// INFER_MAIN_MODULE
|
||||
|
||||
// MODULE: export_inner_class
|
||||
// FILE: lib.kt
|
||||
|
||||
@JsExport
|
||||
class RegularParent(val value: String) {
|
||||
inner class RegularInner(val message: String, val anotherValue: Int) {
|
||||
fun getResult() = value + message
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@JsExport
|
||||
class ParentForSecondary {
|
||||
inner class InnerWithSecondaryConstructor(val value: String) {
|
||||
@JsName("innerSuccess")
|
||||
constructor(): this("OK")
|
||||
}
|
||||
}
|
||||
|
||||
@JsExport
|
||||
class ParentWithSecondary(val value: String) {
|
||||
@JsName("createO")
|
||||
constructor(): this("O")
|
||||
|
||||
inner class InnerWithSecondaryConstructor(val anotherValue: String) {
|
||||
@JsName("createK")
|
||||
constructor(): this("K")
|
||||
|
||||
fun getResult() = value + anotherValue
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// FILE: test.js
|
||||
function box() {
|
||||
var pckg = this["export_inner_class"]
|
||||
|
||||
var regularParent = new pckg.RegularParent("O")
|
||||
var regularInner = new regularParent.RegularInner("K", 42)
|
||||
|
||||
if (regularInner.anotherValue !== 42) return "Fail: second parameter of the RegularInner primary constructor was ignored"
|
||||
if (regularInner.getResult() !== "OK") return "Fail: something is going wrong with the outer this capturing logic"
|
||||
|
||||
var parentForSecondary = new pckg.ParentForSecondary()
|
||||
var innerWithSecondary = new parentForSecondary.InnerWithSecondaryConstructor("OK")
|
||||
|
||||
if (innerWithSecondary.value !== "OK") return "Fail: something is going wrong with primary constructor when a secondary one exists"
|
||||
|
||||
var fromSecondary = parentForSecondary.InnerWithSecondaryConstructor.innerSuccess()
|
||||
|
||||
if (fromSecondary.value !== "OK") return "Fail: something is going wrong with secondary constructor inside the inner class"
|
||||
|
||||
var parentFromSecondary = pckg.ParentWithSecondary.createO()
|
||||
var innerFromSecondary = parentFromSecondary.InnerWithSecondaryConstructor.createK()
|
||||
|
||||
if (innerFromSecondary.getResult() !== "OK") return "Fail: there is a problem when both parent and inner class have secondary constructors"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
// IGNORE_BACKEND: JS
|
||||
// EXPECTED_REACHABLE_NODES: 1270
|
||||
// SKIP_MINIFICATION
|
||||
// RUN_PLAIN_BOX_FUNCTION
|
||||
// INFER_MAIN_MODULE
|
||||
|
||||
// MODULE: vararg
|
||||
// FILE: lib.kt
|
||||
@JsExport
|
||||
fun uintVararg(vararg uints: UInt): String {
|
||||
for (u in uints) {
|
||||
if (u == 0u) return "Failed"
|
||||
}
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
@JsExport
|
||||
fun uint(a: Int): UInt {
|
||||
return a.toUInt()
|
||||
}
|
||||
|
||||
// FILE: test.js
|
||||
function box() {
|
||||
var vararg = this.vararg
|
||||
var uintVararg = vararg.uintVararg
|
||||
var uint = vararg.uint
|
||||
|
||||
return uintVararg([uint(1), uint(2), uint(3)])
|
||||
}
|
||||
Reference in New Issue
Block a user