[K/JS] test(Inner Classes): check exported and not-exported inner classes inside kotlin.
This commit is contained in:
@@ -7736,6 +7736,18 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
|
||||
runTest("js/js.translator/testData/box/nestedTypes/innerReferenceFromChild.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("innerWithMultipleArgs.kt")
|
||||
public void testInnerWithMultipleArgs() throws Exception {
|
||||
runTest("js/js.translator/testData/box/nestedTypes/innerWithMultipleArgs.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("innerWithSecondaryConstructor.kt")
|
||||
public void testInnerWithSecondaryConstructor() throws Exception {
|
||||
runTest("js/js.translator/testData/box/nestedTypes/innerWithSecondaryConstructor.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("nested.kt")
|
||||
public void testNested() throws Exception {
|
||||
|
||||
+12
@@ -8208,6 +8208,18 @@ public class FirJsTestGenerated extends AbstractFirJsTest {
|
||||
runTest("js/js.translator/testData/box/nestedTypes/innerReferenceFromChild.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("innerWithMultipleArgs.kt")
|
||||
public void testInnerWithMultipleArgs() throws Exception {
|
||||
runTest("js/js.translator/testData/box/nestedTypes/innerWithMultipleArgs.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("innerWithSecondaryConstructor.kt")
|
||||
public void testInnerWithSecondaryConstructor() throws Exception {
|
||||
runTest("js/js.translator/testData/box/nestedTypes/innerWithSecondaryConstructor.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("nested.kt")
|
||||
public void testNested() throws Exception {
|
||||
|
||||
+12
@@ -8208,6 +8208,18 @@ public class IrBoxJsTestGenerated extends AbstractIrBoxJsTest {
|
||||
runTest("js/js.translator/testData/box/nestedTypes/innerReferenceFromChild.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("innerWithMultipleArgs.kt")
|
||||
public void testInnerWithMultipleArgs() throws Exception {
|
||||
runTest("js/js.translator/testData/box/nestedTypes/innerWithMultipleArgs.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("innerWithSecondaryConstructor.kt")
|
||||
public void testInnerWithSecondaryConstructor() throws Exception {
|
||||
runTest("js/js.translator/testData/box/nestedTypes/innerWithSecondaryConstructor.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("nested.kt")
|
||||
public void testNested() throws Exception {
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
// EXPECTED_REACHABLE_NODES: 1286
|
||||
// WITH_STDLIB
|
||||
|
||||
package foo
|
||||
|
||||
open class NotExportedParent(val a: Int, val b: Int) {
|
||||
inner class Inner(val c: Int, val d: Int) {
|
||||
fun foo() = a + b + c + d
|
||||
}
|
||||
|
||||
inner class WithVararg(vararg val values: Int) {
|
||||
fun foo() = a + b + values.sum()
|
||||
}
|
||||
}
|
||||
|
||||
@JsExport
|
||||
open class ExportedParent(val a: Int, val b: Int) {
|
||||
inner class Inner(val c: Int, val d: Int) {
|
||||
fun foo() = a + b + c + d
|
||||
}
|
||||
|
||||
inner class WithVararg(vararg val values: Int) {
|
||||
fun foo() = a + b + values.sum()
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val notExportedParent = NotExportedParent(1, 2)
|
||||
val notExportedInner = notExportedParent.Inner(3, 4)
|
||||
val notExportedInnerWithVararg = notExportedParent.WithVararg(3, 4)
|
||||
|
||||
if (notExportedInner.foo() != 10) return "Failed: something wrong with multiple arguments inside not-exported inner class primary constructor"
|
||||
if (notExportedInnerWithVararg.foo() != 10) return "Failed: something wrong with vararg arguments inside not-exported inner class primary constructor"
|
||||
|
||||
val exportedParent = ExportedParent(1, 2)
|
||||
val exportedInner = exportedParent.Inner(3, 4)
|
||||
val exportedInnerWithVararg = exportedParent.WithVararg(3, 4)
|
||||
|
||||
if (exportedInner.foo() != 10) return "Failed: something wrong with multiple arguments inside exported inner class primary constructor"
|
||||
if (exportedInnerWithVararg.foo() != 10) return "Failed: something wrong with vararg arguments inside exported inner class primary constructor"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
// EXPECTED_REACHABLE_NODES: 1286
|
||||
package foo
|
||||
|
||||
open class NotExportedParent(val o: String) {
|
||||
constructor(): this("O")
|
||||
|
||||
inner class Inner(val k: String) {
|
||||
constructor(): this("K")
|
||||
fun foo() = o + k
|
||||
}
|
||||
}
|
||||
|
||||
@JsExport
|
||||
open class ExportedParent(val o: String) {
|
||||
@JsName("createO")
|
||||
constructor(): this("O")
|
||||
|
||||
inner class Inner(val k: String) {
|
||||
@JsName("createK")
|
||||
constructor(): this("K")
|
||||
fun foo() = o + k
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val notExportedParent = NotExportedParent("OO")
|
||||
|
||||
if (notExportedParent.Inner("KK").foo() != "OOKK") return "Fail1: primary constructor capturing"
|
||||
if (notExportedParent.Inner().foo() != "OOK") return "Fail2: inner secondary constructor capturing"
|
||||
|
||||
val notExportedParentDefault = NotExportedParent()
|
||||
|
||||
if (notExportedParentDefault.Inner("KK").foo() != "OKK") return "Fail3: primary constructor capturing"
|
||||
if (notExportedParentDefault.Inner().foo() != "OK") return "Fail4: inner secondary constructor capturing"
|
||||
|
||||
val exportedParent = ExportedParent("OO")
|
||||
|
||||
if (exportedParent.Inner("KK").foo() != "OOKK") return "Fail5: exported primary constructor capturing"
|
||||
if (exportedParent.Inner().foo() != "OOK") return "Fail6: exported inner secondary constructor capturing"
|
||||
|
||||
val exportedParentDefault = ExportedParent()
|
||||
|
||||
if (exportedParentDefault.Inner("KK").foo() != "OKK") return "Fail7: exported primary constructor capturing"
|
||||
if (exportedParentDefault.Inner().foo() != "OK") return "Fail8: exported inner secondary constructor capturing"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user