Add overflow-related tests for 'reversed'
This commit is contained in:
Vendored
+15
@@ -0,0 +1,15 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
const val M = 0.toChar()
|
||||
|
||||
fun box(): String {
|
||||
var count = 0
|
||||
for (i in (M downTo M).reversed()) {
|
||||
++count
|
||||
if (count > 1) {
|
||||
throw AssertionError("Loop should be executed once")
|
||||
}
|
||||
}
|
||||
if (count != 1) throw AssertionError("Should be executed once")
|
||||
return "OK"
|
||||
}
|
||||
Vendored
+15
@@ -0,0 +1,15 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
const val M = Int.MIN_VALUE
|
||||
|
||||
fun box(): String {
|
||||
var count = 0
|
||||
for (i in (M downTo M).reversed()) {
|
||||
++count
|
||||
if (count > 1) {
|
||||
throw AssertionError("Loop should be executed once")
|
||||
}
|
||||
}
|
||||
if (count != 1) throw AssertionError("Should be executed once")
|
||||
return "OK"
|
||||
}
|
||||
Vendored
+15
@@ -0,0 +1,15 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
const val M = Long.MIN_VALUE
|
||||
|
||||
fun box(): String {
|
||||
var count = 0
|
||||
for (i in (M downTo M).reversed()) {
|
||||
++count
|
||||
if (count > 1) {
|
||||
throw AssertionError("Loop should be executed once")
|
||||
}
|
||||
}
|
||||
if (count != 1) throw AssertionError("Should be executed once")
|
||||
return "OK"
|
||||
}
|
||||
Vendored
+15
@@ -0,0 +1,15 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
const val M = 0xFFFF.toChar()
|
||||
|
||||
fun box(): String {
|
||||
var count = 0
|
||||
for (i in (M .. M).reversed()) {
|
||||
++count
|
||||
if (count > 1) {
|
||||
throw AssertionError("Loop should be executed once")
|
||||
}
|
||||
}
|
||||
if (count != 1) throw AssertionError("Should be executed once")
|
||||
return "OK"
|
||||
}
|
||||
Vendored
+14
@@ -0,0 +1,14 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
const val M = Int.MAX_VALUE
|
||||
|
||||
fun box(): String {
|
||||
var step = 0
|
||||
for (i in (M .. M).reversed()) {
|
||||
++step
|
||||
if (step > 1) throw AssertionError("Should be executed once")
|
||||
}
|
||||
if (step != 1) throw AssertionError("Should be executed once")
|
||||
|
||||
return "OK"
|
||||
}
|
||||
Vendored
+15
@@ -0,0 +1,15 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
const val M = Long.MAX_VALUE
|
||||
|
||||
fun box(): String {
|
||||
var count = 0
|
||||
for (i in (M .. M).reversed()) {
|
||||
++count
|
||||
if (count > 1) {
|
||||
throw AssertionError("Loop should be executed once")
|
||||
}
|
||||
}
|
||||
if (count != 1) throw AssertionError("Should be executed once")
|
||||
return "OK"
|
||||
}
|
||||
Reference in New Issue
Block a user