Files
kotlin-fork/compiler/testData/codegen/box/ranges/contains/evaluationOrderForDownTo.kt
T
Juan Chen 9dd8eda1c9 [FIR]: fix library methods in packages
Library methods such as 'listOf' are resolved
to have the package fragments as their parents,
but JVM expects their containing file classes as parents.
This fix generates those file classes and
uses them as parent replacements for such library methods.
2020-02-20 14:24:02 +03:00

32 lines
706 B
Kotlin
Vendored

// KJS_WITH_FULL_RUNTIME
// WITH_RUNTIME
var order = StringBuilder()
inline fun expectOrder(at: String, expected: String, body: () -> Unit) {
order = StringBuilder() // have to do that in order to run this test in JS
body()
if (order.toString() != expected) throw AssertionError("$at: expected: $expected, actual: $order")
}
fun low(i: Int): Int {
order.append("L")
return i
}
fun high(i: Int): Int {
order.append("H")
return i
}
fun x(i: Int): Int {
order.append("X")
return i
}
fun box(): String {
expectOrder("0 in 1 .. 3", "HLX") { x(0) in high(3) downTo low(1) }
expectOrder("0 !in 1 .. 3", "HLX") { x(0) !in high(3) downTo low(1) }
return "OK"
}