de1e27c584
last-exclusive progressions (i.e., "until" progressions and loop over array indices). This change makes it possible to correctly implement the handling of "step" progressions. Computing the last element of a stepped progression requires that the last is inclusive. Also invert the while loop (into if + do-while) that is used when lowering for-loops over progressions that cannot overflow. This keeps the performance characteristics closer to the ForLoopsLowering in kotlin-native, since the goal is to converge to this shared version. Also used IrType instead of KotlinType, where possible. https://github.com/JetBrains/kotlin/pull/2390 https://github.com/JetBrains/kotlin/pull/2305
21 lines
410 B
Kotlin
Vendored
21 lines
410 B
Kotlin
Vendored
// KJS_WITH_FULL_RUNTIME
|
|
// WITH_RUNTIME
|
|
import kotlin.test.*
|
|
|
|
val log = StringBuilder()
|
|
|
|
fun logged(message: String, value: Int) =
|
|
value.also { log.append(message) }
|
|
|
|
fun box(): String {
|
|
var sum = 0
|
|
for (i in (logged("start;", 1) until logged("end;", 5)).reversed()) {
|
|
sum = sum * 10 + i
|
|
}
|
|
|
|
assertEquals(4321, sum)
|
|
|
|
assertEquals("start;end;", log.toString())
|
|
|
|
return "OK"
|
|
} |