mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-08 08:31:26 +00:00
This reverts commit 715d5e9
(cherry picked from commit cc1c7dcb04c98bfb70a852e2a4d3456573015682)
29 lines
765 B
Kotlin
Vendored
29 lines
765 B
Kotlin
Vendored
//test [], get and iterator calls
|
|
fun test(createIntNotLong: Boolean): String {
|
|
val a = if (createIntNotLong) IntArray(5) else LongArray(5)
|
|
if (a is IntArray) {
|
|
val x = a.iterator()
|
|
var i = 0
|
|
while (x.hasNext()) {
|
|
if (a[i] != x.next()) return "Fail $i"
|
|
i++
|
|
}
|
|
return "O"
|
|
} else if (a is LongArray) {
|
|
val x = a.iterator()
|
|
var i = 0
|
|
while (x.hasNext()) {
|
|
if (a.get(i) != x.next()) return "Fail $i"
|
|
i++
|
|
}
|
|
return "K"
|
|
}
|
|
return "fail"
|
|
}
|
|
|
|
fun box(): String {
|
|
// Only run this test if primitive array `is` checks work (KT-17137)
|
|
if ((intArrayOf() as Any) is Array<*>) return "OK"
|
|
|
|
return test(true) + test(false)
|
|
} |