JS: added spread operator inline test case
This commit is contained in:
@@ -3,28 +3,34 @@ package foo
|
|||||||
|
|
||||||
// CHECK_CONTAINS_NO_CALLS: test1
|
// CHECK_CONTAINS_NO_CALLS: test1
|
||||||
// CHECK_CONTAINS_NO_CALLS: test2
|
// CHECK_CONTAINS_NO_CALLS: test2
|
||||||
|
// CHECK_CONTAINS_NO_CALLS: test3
|
||||||
|
|
||||||
inline fun sum(vararg nums: Int): Int {
|
inline fun concat(vararg strings: String): String {
|
||||||
var result = 0
|
var result = ""
|
||||||
|
|
||||||
for (num in nums) {
|
for (string in strings) {
|
||||||
result += num
|
result += string
|
||||||
}
|
}
|
||||||
|
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
fun test1(): Int {
|
fun test1(): String {
|
||||||
return sum()
|
return concat()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun test2(): Int {
|
fun test2(): String {
|
||||||
return sum(1,2,3)
|
return concat("a", "b", "c")
|
||||||
|
}
|
||||||
|
|
||||||
|
fun test3(list: Array<String>): String {
|
||||||
|
return concat(*list)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun box(): String {
|
fun box(): String {
|
||||||
assertEquals(0, test1())
|
assertEquals("", test1())
|
||||||
assertEquals(6, test2())
|
assertEquals("abc", test2())
|
||||||
|
assertEquals("abcd", test3(array("a", "b", "c", "d")))
|
||||||
|
|
||||||
return "OK"
|
return "OK"
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user