Simplify loop building by encoding open/closed bound information in the
HeaderInfo object, and modifying the operator in the loop condition. The "additional emptiness condition" is no longer necessary with this. The open/closed property was removed from HeaderInfo in an earlier commit, but bringing it back in to simplify the loop building makes more sense. Also expanded tests for evaluation order of range bounds.
This commit is contained in:
committed by
max-kammerer
parent
7680e7fd56
commit
dd65e0876f
-21
@@ -1,21 +0,0 @@
|
||||
// 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 s = 0
|
||||
for (i in (logged("start;", 2) downTo logged("end;", 1)).reversed()) {
|
||||
s += i
|
||||
}
|
||||
|
||||
assertEquals(3, s)
|
||||
|
||||
assertEquals("start;end;", log.toString())
|
||||
|
||||
return "OK"
|
||||
}
|
||||
-21
@@ -1,21 +0,0 @@
|
||||
// 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 s = 0
|
||||
for (i in (logged("start;", 1) .. logged("end;", 2)).reversed()) {
|
||||
s += i
|
||||
}
|
||||
|
||||
assertEquals(3, s)
|
||||
|
||||
assertEquals("start;end;", log.toString())
|
||||
|
||||
return "OK"
|
||||
}
|
||||
-21
@@ -1,21 +0,0 @@
|
||||
// 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 s = 0
|
||||
for (i in (logged("start;", 1) until logged("end;", 3)).reversed()) {
|
||||
s += i
|
||||
}
|
||||
|
||||
assertEquals(3, s)
|
||||
|
||||
assertEquals("start;end;", log.toString())
|
||||
|
||||
return "OK"
|
||||
}
|
||||
Reference in New Issue
Block a user