Files
kotlin-fork/compiler/testData/codegen/box/ranges/contains/evaluationOrderForCollection.kt
T
Ivan Kylchik c7435ba760 Replace all occurrences of WITH_RUNTIME with WITH_STDLIB
We are going to deprecate `WITH_RUNTIME` directive. The main reason
behind this change is that `WITH_STDLIB` directive better describes
its meaning, specifically it will add kotlin stdlib to test's classpath.
2021-11-17 15:26:38 +03:00

27 lines
590 B
Kotlin
Vendored

// WITH_STDLIB
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 list(): List<Int> {
order.append("L")
return emptyList()
}
fun x(i: Int): Int {
order.append("X")
return i
}
fun box(): String {
expectOrder("1 in []", "LX") { x(1) in list() }
expectOrder("1 !in []", "LX") { x(1) !in list() }
return "OK"
}