Files
kotlin/compiler/testData/codegen/box/operatorConventions/compareTo/extensionArray.kt
Denis Zharkov 654411a0b0 Refactored tests using Array constructor:
Some moved to tests with stdlib
Some changed to use arrayOfNulls
2014-12-11 16:04:03 +03:00

17 lines
477 B
Kotlin

fun checkLess(x: Array<Int>, y: Array<Int>) = when {
x >= y -> "Fail $x >= $y"
!(x < y) -> "Fail !($x < $y)"
!(x <= y) -> "Fail !($x <= $y)"
x > y -> "Fail $x > $y"
x.compareTo(y) >= 0 -> "Fail $x.compareTo($y) >= 0"
else -> "OK"
}
fun Array<Int>.compareTo(other: Array<Int>) = size() - other.size()
fun box(): String {
val a = arrayOfNulls<Int>(0) as Array<Int>
val b = arrayOfNulls<Int>(1) as Array<Int>
return checkLess(a, b)
}