[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:
Ilya Goncharov
2020-11-20 15:04:09 +03:00
parent e7789d2e30
commit ac42dcd8da
5 changed files with 197 additions and 0 deletions
@@ -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;
}