[JS IR] Add test for external fun vararg
[JS IR] Add tests with empty vararg and default arg before it [JS IR] Ignore backend in tests instead of target backend [JS IR] Add function with named spread operator [JS IR] Remove ignoring of current js backend in jsExternalVarargFun [JS IR] Add with arguments after vararg ^KT-42357 fixed
This commit is contained in:
Generated
+23
@@ -7840,4 +7840,27 @@ public class IrBoxJsES6TestGenerated extends AbstractIrBoxJsES6Test {
|
|||||||
runTest("js/js.translator/testData/box/trait/traitExtendsTwoTraits.kt");
|
runTest("js/js.translator/testData/box/trait/traitExtendsTwoTraits.kt");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("js/js.translator/testData/box/vararg")
|
||||||
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
public static class Vararg extends AbstractIrBoxJsES6Test {
|
||||||
|
private void runTest(String testDataFilePath) throws Exception {
|
||||||
|
KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR_ES6, testDataFilePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testAllFilesPresentInVararg() throws Exception {
|
||||||
|
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("js/js.translator/testData/box/vararg"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.JS_IR_ES6, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("jsExternalVarargCtor.kt")
|
||||||
|
public void testJsExternalVarargCtor() throws Exception {
|
||||||
|
runTest("js/js.translator/testData/box/vararg/jsExternalVarargCtor.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("jsExternalVarargFun.kt")
|
||||||
|
public void testJsExternalVarargFun() throws Exception {
|
||||||
|
runTest("js/js.translator/testData/box/vararg/jsExternalVarargFun.kt");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+23
@@ -7840,4 +7840,27 @@ public class IrBoxJsTestGenerated extends AbstractIrBoxJsTest {
|
|||||||
runTest("js/js.translator/testData/box/trait/traitExtendsTwoTraits.kt");
|
runTest("js/js.translator/testData/box/trait/traitExtendsTwoTraits.kt");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("js/js.translator/testData/box/vararg")
|
||||||
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
public static class Vararg extends AbstractIrBoxJsTest {
|
||||||
|
private void runTest(String testDataFilePath) throws Exception {
|
||||||
|
KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR, testDataFilePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testAllFilesPresentInVararg() throws Exception {
|
||||||
|
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("js/js.translator/testData/box/vararg"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.JS_IR, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("jsExternalVarargCtor.kt")
|
||||||
|
public void testJsExternalVarargCtor() throws Exception {
|
||||||
|
runTest("js/js.translator/testData/box/vararg/jsExternalVarargCtor.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("jsExternalVarargFun.kt")
|
||||||
|
public void testJsExternalVarargFun() throws Exception {
|
||||||
|
runTest("js/js.translator/testData/box/vararg/jsExternalVarargFun.kt");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+23
@@ -7870,4 +7870,27 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
|
|||||||
runTest("js/js.translator/testData/box/trait/traitExtendsTwoTraits.kt");
|
runTest("js/js.translator/testData/box/trait/traitExtendsTwoTraits.kt");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("js/js.translator/testData/box/vararg")
|
||||||
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
public static class Vararg extends AbstractBoxJsTest {
|
||||||
|
private void runTest(String testDataFilePath) throws Exception {
|
||||||
|
KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS, testDataFilePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testAllFilesPresentInVararg() throws Exception {
|
||||||
|
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("js/js.translator/testData/box/vararg"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.JS, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("jsExternalVarargCtor.kt")
|
||||||
|
public void testJsExternalVarargCtor() throws Exception {
|
||||||
|
runTest("js/js.translator/testData/box/vararg/jsExternalVarargCtor.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("jsExternalVarargFun.kt")
|
||||||
|
public void testJsExternalVarargFun() throws Exception {
|
||||||
|
runTest("js/js.translator/testData/box/vararg/jsExternalVarargFun.kt");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,67 @@
|
|||||||
|
// IGNORE_BACKEND: JS
|
||||||
|
|
||||||
|
//KT-42357
|
||||||
|
|
||||||
|
// FILE: main.kt
|
||||||
|
external class FieldPath {
|
||||||
|
constructor(
|
||||||
|
arg: Int = definedExternally,
|
||||||
|
vararg args: String
|
||||||
|
)
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
arg: Int = definedExternally,
|
||||||
|
vararg args: String,
|
||||||
|
o: Long
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
external val ctorCallArgs: Array<String>
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
FieldPath()
|
||||||
|
if (ctorCallArgs.size != 0) return "fail: $ctorCallArgs arguments"
|
||||||
|
|
||||||
|
FieldPath(1)
|
||||||
|
if (ctorCallArgs.size != 1 || js("typeof ctorCallArgs[0] !== 'number'")) return "fail1: $ctorCallArgs arguments"
|
||||||
|
|
||||||
|
FieldPath(2, "p0", "p1", "p3")
|
||||||
|
if (ctorCallArgs.size != 4 || js("typeof ctorCallArgs[0] !== 'number'") || js("typeof ctorCallArgs[1] !== 'string'"))
|
||||||
|
return "fail2: $ctorCallArgs arguments"
|
||||||
|
|
||||||
|
FieldPath(3, args = arrayOf("p0", "p1"))
|
||||||
|
if (ctorCallArgs.size != 3 || js("typeof ctorCallArgs[0] !== 'number'") || js("typeof ctorCallArgs[1] !== 'string'"))
|
||||||
|
return "fail3: $ctorCallArgs arguments"
|
||||||
|
|
||||||
|
FieldPath(4, *arrayOf("p0", "p1"))
|
||||||
|
if (ctorCallArgs.size != 3 || js("typeof ctorCallArgs[0] !== 'number'") || js("typeof ctorCallArgs[1] !== 'string'"))
|
||||||
|
return "fail4: $ctorCallArgs arguments"
|
||||||
|
|
||||||
|
FieldPath(5, args = *arrayOf("p0", "p1"))
|
||||||
|
if (ctorCallArgs.size != 3 || js("typeof ctorCallArgs[0] !== 'number'") || js("typeof ctorCallArgs[1] !== 'string'"))
|
||||||
|
return "fail5: $ctorCallArgs arguments"
|
||||||
|
|
||||||
|
FieldPath(42, "a", "b", "c", o = 99L)
|
||||||
|
if (ctorCallArgs.size != 5 || js("typeof ctorCallArgs[0] !== 'number'") || js("typeof ctorCallArgs[1] !== 'string'"))
|
||||||
|
return "fail6: $ctorCallArgs arguments"
|
||||||
|
|
||||||
|
FieldPath(5, args = *arrayOf("p0", "p1"), o = 87L)
|
||||||
|
if (ctorCallArgs.size != 4 || js("typeof ctorCallArgs[0] !== 'number'") || js("typeof ctorCallArgs[1] !== 'string'"))
|
||||||
|
return "fail6: $ctorCallArgs arguments"
|
||||||
|
|
||||||
|
FieldPath(4, *arrayOf("p0", "p1"), o = 99L)
|
||||||
|
if (ctorCallArgs.size != 4 || js("typeof ctorCallArgs[0] !== 'number'") || js("typeof ctorCallArgs[1] !== 'string'"))
|
||||||
|
return "fail7: $ctorCallArgs arguments"
|
||||||
|
|
||||||
|
FieldPath(11, *arrayOf(), o = 123456L)
|
||||||
|
if (ctorCallArgs.size != 2 || js("typeof ctorCallArgs[0] !== 'number'"))
|
||||||
|
return "fail9: $ctorCallArgs arguments"
|
||||||
|
|
||||||
|
return "OK"
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: main.js
|
||||||
|
var ctorCallArgs;
|
||||||
|
function FieldPath() {
|
||||||
|
ctorCallArgs = arguments;
|
||||||
|
}
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
//KT-42357
|
||||||
|
|
||||||
|
// FILE: main.kt
|
||||||
|
external fun create(
|
||||||
|
arg: Int = definedExternally,
|
||||||
|
vararg args: String
|
||||||
|
) : Array<String>
|
||||||
|
|
||||||
|
external fun create(
|
||||||
|
arg: Int = definedExternally,
|
||||||
|
vararg args: String,
|
||||||
|
o: Long
|
||||||
|
) : Array<String>
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
val zeroArgs = create()
|
||||||
|
if (zeroArgs.size != 0) return "fail: $zeroArgs arguments"
|
||||||
|
|
||||||
|
val oneArg = create(1)
|
||||||
|
if (oneArg.size != 1 || js("typeof oneArg[0] !== 'number'"))
|
||||||
|
return "fail1: $oneArg arguments"
|
||||||
|
|
||||||
|
val varArgs = create(2, "p0", "p1", "p3")
|
||||||
|
if (varArgs.size != 4 || js("typeof varArgs[0] !== 'number'") || js("typeof varArgs[1] !== 'string'"))
|
||||||
|
return "fail2: $varArgs arguments"
|
||||||
|
|
||||||
|
val namedParameter = create(3, args = arrayOf("p0", "p1"))
|
||||||
|
if (namedParameter.size != 3 || js("typeof namedParameter[0] !== 'number'") || js("typeof namedParameter[1] !== 'string'"))
|
||||||
|
return "fail3: $namedParameter arguments"
|
||||||
|
|
||||||
|
val spreadArgs = create(4, *arrayOf("p0", "p1"))
|
||||||
|
if (spreadArgs.size != 3 || js("typeof spreadArgs[0] !== 'number'") || js("typeof spreadArgs[1] !== 'string'"))
|
||||||
|
return "fail4: $spreadArgs arguments"
|
||||||
|
|
||||||
|
val spreadNamedArgs = create(5, args = *arrayOf("p0", "p1"))
|
||||||
|
if (spreadNamedArgs.size != 3 || js("typeof spreadNamedArgs[0] !== 'number'") || js("typeof spreadNamedArgs[1] !== 'string'"))
|
||||||
|
return "fail5: $spreadNamedArgs arguments"
|
||||||
|
|
||||||
|
val argAfterVararg = create(42, "a", "b", "c", o = 99L)
|
||||||
|
if (argAfterVararg.size != 5 || js("typeof argAfterVararg[0] !== 'number'") || js("typeof argAfterVararg[1] !== 'string'"))
|
||||||
|
return "fail6: $argAfterVararg arguments"
|
||||||
|
|
||||||
|
val argAfterSpreadNamedVararg = create(5, args = *arrayOf("p0", "p1"), o = 87L)
|
||||||
|
if (argAfterSpreadNamedVararg.size != 4 || js("typeof argAfterSpreadNamedVararg[0] !== 'number'") || js("typeof argAfterSpreadNamedVararg[1] !== 'string'"))
|
||||||
|
return "fail7: $argAfterSpreadNamedVararg arguments"
|
||||||
|
|
||||||
|
val argAfterSpreadVararg = create(4, *arrayOf("p0", "p1"), o = 99L)
|
||||||
|
if (argAfterSpreadVararg.size != 4 || js("typeof argAfterSpreadVararg[0] !== 'number'") || js("typeof argAfterSpreadVararg[1] !== 'string'"))
|
||||||
|
return "fail8: $argAfterSpreadVararg arguments"
|
||||||
|
|
||||||
|
val argAfterSpreadEmptyVararg = create(11, *arrayOf(), o = 123456L)
|
||||||
|
if (argAfterSpreadEmptyVararg.size != 2 || js("typeof argAfterSpreadEmptyVararg[0] !== 'number'"))
|
||||||
|
return "fail9: $argAfterSpreadEmptyVararg arguments"
|
||||||
|
|
||||||
|
return "OK"
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: main.js
|
||||||
|
function create() {
|
||||||
|
return arguments
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user