Fixed bug in DefaultArgs lowering with vararg arguments + tests
This commit is contained in:
@@ -362,6 +362,16 @@ task function_defaults_from_fake_override(type: RunKonanTest) {
|
||||
source = "codegen/function/defaultsFromFakeOverride.kt"
|
||||
}
|
||||
|
||||
task function_defaults_with_vararg1(type: RunKonanTest) {
|
||||
goldValue = "Hello , Correct!\nHello World, Correct!\n , Correct!\n"
|
||||
source = "codegen/function/defaultsWithVarArg1.kt"
|
||||
}
|
||||
|
||||
task function_defaults_with_vararg2(type: RunKonanTest) {
|
||||
goldValue = "1\n2\n42\n"
|
||||
source = "codegen/function/defaultsWithVarArg2.kt"
|
||||
}
|
||||
|
||||
task sum_3const(type: RunKonanTest) {
|
||||
source = "codegen/function/sum_3const.kt"
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package codegen.function.defaultsWithVarArg1
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
fun foo(s: String = "", vararg args: Any) {
|
||||
if (args == null) {
|
||||
println("Failed!")
|
||||
} else {
|
||||
print("$s ")
|
||||
args.forEach {
|
||||
print("$it")
|
||||
}
|
||||
println(", Correct!")
|
||||
}
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
foo("Hello")
|
||||
foo("Hello", "World")
|
||||
foo()
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package codegen.function.defaultsWithVarArg2
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
fun foo(vararg arr: Int = intArrayOf(1, 2)) {
|
||||
arr.forEach { println(it) }
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
foo()
|
||||
foo(42)
|
||||
}
|
||||
Reference in New Issue
Block a user