Files
kotlin/compiler/testData/codegen/box/arrays/arrayInstanceOf.kt
Anton Bannykh 4e0af21df4 Revert "Clean up test skips after KT-17137"
This reverts commit 715d5e9

(cherry picked from commit cc1c7dcb04c98bfb70a852e2a4d3456573015682)
2018-04-10 20:46:00 +03:00

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)
}