Minor, prevent infinite loops in range tests
This commit is contained in:
+7
@@ -7,6 +7,7 @@ fun box(): String {
|
||||
val range1 = (1 + 2)..(10 - 1)
|
||||
for (i in range1) {
|
||||
list1.add(i)
|
||||
if (list1.size() > 23) break
|
||||
}
|
||||
if (list1 != listOf<Int>(3, 4, 5, 6, 7, 8, 9)) {
|
||||
return "Wrong elements for (1 + 2)..(10 - 1): $list1"
|
||||
@@ -16,6 +17,7 @@ fun box(): String {
|
||||
val range2 = (1.toByte() + 2.toByte()).toByte()..(10.toByte() - 1.toByte()).toByte()
|
||||
for (i in range2) {
|
||||
list2.add(i)
|
||||
if (list2.size() > 23) break
|
||||
}
|
||||
if (list2 != listOf<Byte>(3, 4, 5, 6, 7, 8, 9)) {
|
||||
return "Wrong elements for (1.toByte() + 2.toByte()).toByte()..(10.toByte() - 1.toByte()).toByte(): $list2"
|
||||
@@ -25,6 +27,7 @@ fun box(): String {
|
||||
val range3 = (1.toShort() + 2.toShort()).toShort()..(10.toShort() - 1.toShort()).toShort()
|
||||
for (i in range3) {
|
||||
list3.add(i)
|
||||
if (list3.size() > 23) break
|
||||
}
|
||||
if (list3 != listOf<Short>(3, 4, 5, 6, 7, 8, 9)) {
|
||||
return "Wrong elements for (1.toShort() + 2.toShort()).toShort()..(10.toShort() - 1.toShort()).toShort(): $list3"
|
||||
@@ -34,6 +37,7 @@ fun box(): String {
|
||||
val range4 = (1.toLong() + 2.toLong())..(10.toLong() - 1.toLong())
|
||||
for (i in range4) {
|
||||
list4.add(i)
|
||||
if (list4.size() > 23) break
|
||||
}
|
||||
if (list4 != listOf<Long>(3, 4, 5, 6, 7, 8, 9)) {
|
||||
return "Wrong elements for (1.toLong() + 2.toLong())..(10.toLong() - 1.toLong()): $list4"
|
||||
@@ -43,6 +47,7 @@ fun box(): String {
|
||||
val range5 = ("ace"[1])..("age"[1])
|
||||
for (i in range5) {
|
||||
list5.add(i)
|
||||
if (list5.size() > 23) break
|
||||
}
|
||||
if (list5 != listOf<Char>('c', 'd', 'e', 'f', 'g')) {
|
||||
return "Wrong elements for (\"ace\"[1])..(\"age\"[1]): $list5"
|
||||
@@ -52,6 +57,7 @@ fun box(): String {
|
||||
val range6 = (1.5 * 2)..(3.0 * 3.0)
|
||||
for (i in range6) {
|
||||
list6.add(i)
|
||||
if (list6.size() > 23) break
|
||||
}
|
||||
if (list6 != listOf<Double>(3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0)) {
|
||||
return "Wrong elements for (1.5 * 2)..(3.0 * 3.0): $list6"
|
||||
@@ -61,6 +67,7 @@ fun box(): String {
|
||||
val range7 = (1.5.toFloat() * 2.toFloat())..(3.0.toFloat() * 3.0.toFloat())
|
||||
for (i in range7) {
|
||||
list7.add(i)
|
||||
if (list7.size() > 23) break
|
||||
}
|
||||
if (list7 != listOf<Float>(3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0)) {
|
||||
return "Wrong elements for (1.5.toFloat() * 2.toFloat())..(3.0.toFloat() * 3.0.toFloat()): $list7"
|
||||
|
||||
Reference in New Issue
Block a user