Support const-bound counter loop generation for 'downTo'

This commit is contained in:
Dmitry Petrov
2017-12-12 13:47:17 +03:00
parent 2f0df832c0
commit 5f7460a8c7
14 changed files with 213 additions and 10 deletions
@@ -0,0 +1,15 @@
// WITH_RUNTIME
const val M = 0.toChar()
fun box(): String {
var count = 0
for (i in M downTo M) {
++count
if (count > 1) {
throw AssertionError("Loop should be executed once")
}
}
if (count != 1) throw AssertionError("Should be executed once")
return "OK"
}
@@ -0,0 +1,15 @@
// WITH_RUNTIME
const val M = Int.MIN_VALUE
fun box(): String {
var count = 0
for (i in M downTo M) {
++count
if (count > 1) {
throw AssertionError("Loop should be executed once")
}
}
if (count != 1) throw AssertionError("Should be executed once")
return "OK"
}
@@ -0,0 +1,15 @@
// WITH_RUNTIME
const val M = Long.MIN_VALUE
fun box(): String {
var count = 0
for (i in M downTo M) {
++count
if (count > 1) {
throw AssertionError("Loop should be executed once")
}
}
if (count != 1) throw AssertionError("Should be executed once")
return "OK"
}