Files
kotlin-fork/compiler/testData/codegen/boxWithStdlib/ranges/literal/simpleRangeWithNonConstantEnds.kt
T
2016-01-22 05:54:38 +03:00

52 lines
1.7 KiB
Kotlin
Vendored

// Auto-generated by org.jetbrains.kotlin.generators.tests.GenerateRangesCodegenTestData. DO NOT EDIT!
import java.util.ArrayList
fun box(): String {
val list1 = ArrayList<Int>()
for (i in (1 + 2)..(10 - 1)) {
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"
}
val list2 = ArrayList<Int>()
for (i in (1.toByte() + 2.toByte()).toByte()..(10.toByte() - 1.toByte()).toByte()) {
list2.add(i)
if (list2.size > 23) break
}
if (list2 != listOf<Int>(3, 4, 5, 6, 7, 8, 9)) {
return "Wrong elements for (1.toByte() + 2.toByte()).toByte()..(10.toByte() - 1.toByte()).toByte(): $list2"
}
val list3 = ArrayList<Int>()
for (i in (1.toShort() + 2.toShort()).toShort()..(10.toShort() - 1.toShort()).toShort()) {
list3.add(i)
if (list3.size > 23) break
}
if (list3 != listOf<Int>(3, 4, 5, 6, 7, 8, 9)) {
return "Wrong elements for (1.toShort() + 2.toShort()).toShort()..(10.toShort() - 1.toShort()).toShort(): $list3"
}
val list4 = ArrayList<Long>()
for (i in (1.toLong() + 2.toLong())..(10.toLong() - 1.toLong())) {
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"
}
val list5 = ArrayList<Char>()
for (i in ("ace"[1])..("age"[1])) {
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"
}
return "OK"
}