Add new tests for step progressions and fix existing tests.
This commit is contained in:
committed by
max-kammerer
parent
27642514b1
commit
277cb39e3b
+25
@@ -0,0 +1,25 @@
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
// WITH_RUNTIME
|
||||
import kotlin.test.*
|
||||
|
||||
fun box(): String {
|
||||
val intList = mutableListOf<Int>()
|
||||
for (i in 1 downTo 2 step 2) {
|
||||
intList += i
|
||||
}
|
||||
assertTrue(intList.isEmpty())
|
||||
|
||||
val longList = mutableListOf<Long>()
|
||||
for (i in 1L downTo 2L step 2L) {
|
||||
longList += i
|
||||
}
|
||||
assertTrue(longList.isEmpty())
|
||||
|
||||
val charList = mutableListOf<Char>()
|
||||
for (i in 'a' downTo 'b' step 2) {
|
||||
charList += i
|
||||
}
|
||||
assertTrue(charList.isEmpty())
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
// WITH_RUNTIME
|
||||
|
||||
// Bug in JS: Translation of loop over literal completely removes the validation of step
|
||||
// DONT_TARGET_EXACT_BACKEND: JS
|
||||
import kotlin.test.*
|
||||
|
||||
fun box(): String {
|
||||
assertFailsWith<IllegalArgumentException> {
|
||||
for (i in 7 downTo 1 step -1) {
|
||||
}
|
||||
}
|
||||
|
||||
assertFailsWith<IllegalArgumentException> {
|
||||
for (i in 7L downTo 1L step -1L) {
|
||||
}
|
||||
}
|
||||
|
||||
assertFailsWith<IllegalArgumentException> {
|
||||
for (i in 'g' downTo 'a' step -1) {
|
||||
}
|
||||
}
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
// WITH_RUNTIME
|
||||
|
||||
// Bug in JS: Translation of loop over literal completely removes the validation of step
|
||||
// DONT_TARGET_EXACT_BACKEND: JS
|
||||
import kotlin.test.*
|
||||
|
||||
fun zero() = 0
|
||||
|
||||
fun box(): String {
|
||||
assertFailsWith<IllegalArgumentException> {
|
||||
for (i in 7 downTo 1 step zero()) {
|
||||
}
|
||||
}
|
||||
|
||||
assertFailsWith<IllegalArgumentException> {
|
||||
for (i in 7L downTo 1L step zero().toLong()) {
|
||||
}
|
||||
}
|
||||
|
||||
assertFailsWith<IllegalArgumentException> {
|
||||
for (i in 'g' downTo 'a' step zero()) {
|
||||
}
|
||||
}
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
// WITH_RUNTIME
|
||||
import kotlin.test.*
|
||||
|
||||
fun box(): String {
|
||||
assertFailsWith<IllegalArgumentException> {
|
||||
for (i in 7 downTo 1 step 0 step 2) {
|
||||
}
|
||||
}
|
||||
|
||||
assertFailsWith<IllegalArgumentException> {
|
||||
for (i in 7L downTo 1L step 0L step 2L) {
|
||||
}
|
||||
}
|
||||
|
||||
assertFailsWith<IllegalArgumentException> {
|
||||
for (i in 'g' downTo 'a' step 0 step 2) {
|
||||
}
|
||||
}
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
// WITH_RUNTIME
|
||||
|
||||
// Bug in JS: Translation of loop over literal completely removes the validation of step
|
||||
// DONT_TARGET_EXACT_BACKEND: JS
|
||||
import kotlin.test.*
|
||||
|
||||
fun box(): String {
|
||||
assertFailsWith<IllegalArgumentException> {
|
||||
for (i in 7 downTo 1 step 0) {
|
||||
}
|
||||
}
|
||||
|
||||
assertFailsWith<IllegalArgumentException> {
|
||||
for (i in 7L downTo 1L step 0L) {
|
||||
}
|
||||
}
|
||||
|
||||
assertFailsWith<IllegalArgumentException> {
|
||||
for (i in 'g' downTo 'a' step 0) {
|
||||
}
|
||||
}
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
// WITH_RUNTIME
|
||||
import kotlin.test.*
|
||||
|
||||
fun box(): String {
|
||||
assertFailsWith<IllegalArgumentException> {
|
||||
for (i in 7 downTo 1 step 2 step 0) {
|
||||
}
|
||||
}
|
||||
|
||||
assertFailsWith<IllegalArgumentException> {
|
||||
for (i in 7L downTo 1L step 2L step 0L) {
|
||||
}
|
||||
}
|
||||
|
||||
assertFailsWith<IllegalArgumentException> {
|
||||
for (i in 'g' downTo 'a' step 2 step 0) {
|
||||
}
|
||||
}
|
||||
|
||||
return "OK"
|
||||
}
|
||||
Vendored
+25
@@ -0,0 +1,25 @@
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
// WITH_RUNTIME
|
||||
import kotlin.test.*
|
||||
|
||||
fun box(): String {
|
||||
val intList = mutableListOf<Int>()
|
||||
for (i in Int.MAX_VALUE downTo Int.MIN_VALUE step Int.MAX_VALUE) {
|
||||
intList += i
|
||||
}
|
||||
assertEquals(listOf(Int.MAX_VALUE, 0, Int.MIN_VALUE + 1), intList)
|
||||
|
||||
val longList = mutableListOf<Long>()
|
||||
for (i in Long.MAX_VALUE downTo Long.MIN_VALUE step Long.MAX_VALUE) {
|
||||
longList += i
|
||||
}
|
||||
assertEquals(listOf(Long.MAX_VALUE, 0, Long.MIN_VALUE + 1), longList)
|
||||
|
||||
val charList = mutableListOf<Char>()
|
||||
for (i in Char.MAX_VALUE downTo Char.MIN_VALUE step Char.MAX_VALUE.toInt()) {
|
||||
charList += i
|
||||
}
|
||||
assertEquals(listOf(Char.MAX_VALUE, Char.MIN_VALUE), charList)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
// WITH_RUNTIME
|
||||
import kotlin.test.*
|
||||
|
||||
fun box(): String {
|
||||
val intList = mutableListOf<Int>()
|
||||
for (i in Int.MAX_VALUE downTo 1 step Int.MAX_VALUE) {
|
||||
intList += i
|
||||
}
|
||||
assertEquals(listOf(Int.MAX_VALUE), intList)
|
||||
|
||||
val longList = mutableListOf<Long>()
|
||||
for (i in Long.MAX_VALUE downTo 1L step Long.MAX_VALUE) {
|
||||
longList += i
|
||||
}
|
||||
assertEquals(listOf(Long.MAX_VALUE), longList)
|
||||
|
||||
val charList = mutableListOf<Char>()
|
||||
for (i in Char.MAX_VALUE downTo 1.toChar() step Char.MAX_VALUE.toInt()) {
|
||||
charList += i
|
||||
}
|
||||
assertEquals(listOf(Char.MAX_VALUE), charList)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
// WITH_RUNTIME
|
||||
import kotlin.test.*
|
||||
|
||||
fun box(): String {
|
||||
val intList = mutableListOf<Int>()
|
||||
for (i in Int.MAX_VALUE downTo 0 step Int.MAX_VALUE) {
|
||||
intList += i
|
||||
}
|
||||
assertEquals(listOf(Int.MAX_VALUE, 0), intList)
|
||||
|
||||
val longList = mutableListOf<Long>()
|
||||
for (i in Long.MAX_VALUE downTo 0L step Long.MAX_VALUE) {
|
||||
longList += i
|
||||
}
|
||||
assertEquals(listOf(Long.MAX_VALUE, 0L), longList)
|
||||
|
||||
val charList = mutableListOf<Char>()
|
||||
for (i in Char.MAX_VALUE downTo 0.toChar() step Char.MAX_VALUE.toInt()) {
|
||||
charList += i
|
||||
}
|
||||
assertEquals(listOf(Char.MAX_VALUE, 0.toChar()), charList)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
// WITH_RUNTIME
|
||||
import kotlin.test.*
|
||||
|
||||
fun box(): String {
|
||||
val intList = mutableListOf<Int>()
|
||||
for (i in 7.toByte() downTo 1.toShort() step 2) {
|
||||
intList += i
|
||||
}
|
||||
assertEquals(listOf(7, 5, 3, 1), intList)
|
||||
|
||||
val longList = mutableListOf<Long>()
|
||||
for (i in 7 downTo 1L step 2) {
|
||||
longList += i
|
||||
}
|
||||
assertEquals(listOf(7L, 5L, 3L, 1L), longList)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
Vendored
+25
@@ -0,0 +1,25 @@
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
// WITH_RUNTIME
|
||||
import kotlin.test.*
|
||||
|
||||
fun box(): String {
|
||||
val intList = mutableListOf<Int>()
|
||||
for (i in 4 downTo 1 step 1 step 1) {
|
||||
intList += i
|
||||
}
|
||||
assertEquals(listOf(4, 3, 2, 1), intList)
|
||||
|
||||
val longList = mutableListOf<Long>()
|
||||
for (i in 4L downTo 1L step 1L step 1L) {
|
||||
longList += i
|
||||
}
|
||||
assertEquals(listOf(4L, 3L, 2L, 1L), longList)
|
||||
|
||||
val charList = mutableListOf<Char>()
|
||||
for (i in 'd' downTo 'a' step 1 step 1) {
|
||||
charList += i
|
||||
}
|
||||
assertEquals(listOf('d', 'c', 'b', 'a'), charList)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
// WITH_RUNTIME
|
||||
import kotlin.test.*
|
||||
|
||||
fun box(): String {
|
||||
val intList = mutableListOf<Int>()
|
||||
for (i in 8 downTo 1 step 2 step 2) {
|
||||
intList += i
|
||||
}
|
||||
assertEquals(listOf(8, 6, 4, 2), intList)
|
||||
|
||||
val longList = mutableListOf<Long>()
|
||||
for (i in 8L downTo 1L step 2L step 2L) {
|
||||
longList += i
|
||||
}
|
||||
assertEquals(listOf(8L, 6L, 4L, 2L), longList)
|
||||
|
||||
val charList = mutableListOf<Char>()
|
||||
for (i in 'h' downTo 'a' step 2 step 2) {
|
||||
charList += i
|
||||
}
|
||||
assertEquals(listOf('h', 'f', 'd', 'b'), charList)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
Vendored
+25
@@ -0,0 +1,25 @@
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
// WITH_RUNTIME
|
||||
import kotlin.test.*
|
||||
|
||||
fun box(): String {
|
||||
val intList = mutableListOf<Int>()
|
||||
for (i in 5 downTo 1 step 2 step 1) {
|
||||
intList += i
|
||||
}
|
||||
assertEquals(listOf(5, 4, 3, 2, 1), intList)
|
||||
|
||||
val longList = mutableListOf<Long>()
|
||||
for (i in 5L downTo 1L step 2L step 1L) {
|
||||
longList += i
|
||||
}
|
||||
assertEquals(listOf(5L, 4L, 3L, 2L, 1L), longList)
|
||||
|
||||
val charList = mutableListOf<Char>()
|
||||
for (i in 'e' downTo 'a' step 2 step 1) {
|
||||
charList += i
|
||||
}
|
||||
assertEquals(listOf('e', 'd', 'c', 'b', 'a'), charList)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
// WITH_RUNTIME
|
||||
import kotlin.test.*
|
||||
|
||||
fun box(): String {
|
||||
val intList = mutableListOf<Int>()
|
||||
for (i in 7 downTo 1 step 3 step 2) {
|
||||
intList += i
|
||||
}
|
||||
assertEquals(listOf(7, 5, 3, 1), intList)
|
||||
|
||||
val longList = mutableListOf<Long>()
|
||||
for (i in 7L downTo 1L step 3L step 2L) {
|
||||
longList += i
|
||||
}
|
||||
assertEquals(listOf(7L, 5L, 3L, 1L), longList)
|
||||
|
||||
val charList = mutableListOf<Char>()
|
||||
for (i in 'g' downTo 'a' step 3 step 2) {
|
||||
charList += i
|
||||
}
|
||||
assertEquals(listOf('g', 'e', 'c', 'a'), charList)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
// WITH_RUNTIME
|
||||
import kotlin.test.*
|
||||
|
||||
fun box(): String {
|
||||
val intList = mutableListOf<Int>()
|
||||
for (i in 10 downTo 1 step 3 step 2) {
|
||||
intList += i
|
||||
}
|
||||
assertEquals(listOf(10, 8, 6, 4, 2), intList)
|
||||
|
||||
val longList = mutableListOf<Long>()
|
||||
for (i in 10L downTo 1L step 3L step 2L) {
|
||||
longList += i
|
||||
}
|
||||
assertEquals(listOf(10L, 8L, 6L, 4L, 2L), longList)
|
||||
|
||||
val charList = mutableListOf<Char>()
|
||||
for (i in 'j' downTo 'a' step 3 step 2) {
|
||||
charList += i
|
||||
}
|
||||
assertEquals(listOf('j', 'h', 'f', 'd', 'b'), charList)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
// WITH_RUNTIME
|
||||
import kotlin.test.*
|
||||
|
||||
fun box(): String {
|
||||
val intList = mutableListOf<Int>()
|
||||
for (i in 6 downTo 1 step 2 step 1) {
|
||||
intList += i
|
||||
}
|
||||
assertEquals(listOf(6, 5, 4, 3, 2), intList)
|
||||
|
||||
val longList = mutableListOf<Long>()
|
||||
for (i in 6L downTo 1L step 2L step 1L) {
|
||||
longList += i
|
||||
}
|
||||
assertEquals(listOf(6L, 5L, 4L, 3L, 2L), longList)
|
||||
|
||||
val charList = mutableListOf<Char>()
|
||||
for (i in 'f' downTo 'a' step 2 step 1) {
|
||||
charList += i
|
||||
}
|
||||
assertEquals(listOf('f', 'e', 'd', 'c', 'b'), charList)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
// WITH_RUNTIME
|
||||
import kotlin.test.*
|
||||
|
||||
fun box(): String {
|
||||
val intList = mutableListOf<Int>()
|
||||
for (i in 8 downTo 1 step 2 step 3) {
|
||||
intList += i
|
||||
}
|
||||
assertEquals(listOf(8, 5, 2), intList)
|
||||
|
||||
val longList = mutableListOf<Long>()
|
||||
for (i in 8L downTo 1L step 2L step 3L) {
|
||||
longList += i
|
||||
}
|
||||
assertEquals(listOf(8L, 5L, 2L), longList)
|
||||
|
||||
val charList = mutableListOf<Char>()
|
||||
for (i in 'h' downTo 'a' step 2 step 3) {
|
||||
charList += i
|
||||
}
|
||||
assertEquals(listOf('h', 'e', 'b'), charList)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
// WITH_RUNTIME
|
||||
import kotlin.test.*
|
||||
|
||||
fun box(): String {
|
||||
val intList = mutableListOf<Int>()
|
||||
for (i in 10 downTo 1 step 2 step 3) {
|
||||
intList += i
|
||||
}
|
||||
assertEquals(listOf(10, 7, 4), intList)
|
||||
|
||||
val longList = mutableListOf<Long>()
|
||||
for (i in 10L downTo 1L step 2L step 3L) {
|
||||
longList += i
|
||||
}
|
||||
assertEquals(listOf(10L, 7L, 4L), longList)
|
||||
|
||||
val charList = mutableListOf<Char>()
|
||||
for (i in 'j' downTo 'a' step 2 step 3) {
|
||||
charList += i
|
||||
}
|
||||
assertEquals(listOf('j', 'g', 'd'), charList)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
// WITH_RUNTIME
|
||||
import kotlin.test.*
|
||||
|
||||
fun box(): String {
|
||||
val intList = mutableListOf<Int>()
|
||||
for (i in (8 downTo 1).reversed() step 2) {
|
||||
intList += i
|
||||
}
|
||||
assertEquals(listOf(1, 3, 5, 7), intList)
|
||||
|
||||
val longList = mutableListOf<Long>()
|
||||
for (i in (8L downTo 1L).reversed() step 2L) {
|
||||
longList += i
|
||||
}
|
||||
assertEquals(listOf(1L, 3L, 5L, 7L), longList)
|
||||
|
||||
val charList = mutableListOf<Char>()
|
||||
for (i in ('h' downTo 'a').reversed() step 2) {
|
||||
charList += i
|
||||
}
|
||||
assertEquals(listOf('a', 'c', 'e', 'g'), charList)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
compiler/testData/codegen/box/ranges/stepped/literal/downTo/reversed/reversedThenStepThenReversed.kt
Vendored
+25
@@ -0,0 +1,25 @@
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
// WITH_RUNTIME
|
||||
import kotlin.test.*
|
||||
|
||||
fun box(): String {
|
||||
val intList = mutableListOf<Int>()
|
||||
for (i in ((8 downTo 1).reversed() step 2).reversed()) {
|
||||
intList += i
|
||||
}
|
||||
assertEquals(listOf(7, 5, 3, 1), intList)
|
||||
|
||||
val longList = mutableListOf<Long>()
|
||||
for (i in ((8L downTo 1L).reversed() step 2L).reversed()) {
|
||||
longList += i
|
||||
}
|
||||
assertEquals(listOf(7L, 5L, 3L, 1L), longList)
|
||||
|
||||
val charList = mutableListOf<Char>()
|
||||
for (i in (('h' downTo 'a').reversed() step 2).reversed()) {
|
||||
charList += i
|
||||
}
|
||||
assertEquals(listOf('g', 'e', 'c', 'a'), charList)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
// WITH_RUNTIME
|
||||
import kotlin.test.*
|
||||
|
||||
fun box(): String {
|
||||
val intList = mutableListOf<Int>()
|
||||
for (i in ((10 downTo 1).reversed() step 2).reversed() step 3) {
|
||||
intList += i
|
||||
}
|
||||
assertEquals(listOf(9, 6, 3), intList)
|
||||
|
||||
val longList = mutableListOf<Long>()
|
||||
for (i in ((10L downTo 1L).reversed() step 2L).reversed() step 3L) {
|
||||
longList += i
|
||||
}
|
||||
assertEquals(listOf(9L, 6L, 3L), longList)
|
||||
|
||||
val charList = mutableListOf<Char>()
|
||||
for (i in (('j' downTo 'a').reversed() step 2).reversed() step 3) {
|
||||
charList += i
|
||||
}
|
||||
assertEquals(listOf('i', 'f', 'c'), charList)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
// WITH_RUNTIME
|
||||
import kotlin.test.*
|
||||
|
||||
fun box(): String {
|
||||
val intList = mutableListOf<Int>()
|
||||
for (i in (8 downTo 1 step 2).reversed()) {
|
||||
intList += i
|
||||
}
|
||||
assertEquals(listOf(2, 4, 6, 8), intList)
|
||||
|
||||
val longList = mutableListOf<Long>()
|
||||
for (i in (8L downTo 1L step 2L).reversed()) {
|
||||
longList += i
|
||||
}
|
||||
assertEquals(listOf(2L, 4L, 6L, 8L), longList)
|
||||
|
||||
val charList = mutableListOf<Char>()
|
||||
for (i in ('h' downTo 'a' step 2).reversed()) {
|
||||
charList += i
|
||||
}
|
||||
assertEquals(listOf('b', 'd', 'f', 'h'), charList)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
Vendored
+25
@@ -0,0 +1,25 @@
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
// WITH_RUNTIME
|
||||
import kotlin.test.*
|
||||
|
||||
fun box(): String {
|
||||
val intList = mutableListOf<Int>()
|
||||
for (i in (10 downTo 1 step 2).reversed() step 3) {
|
||||
intList += i
|
||||
}
|
||||
assertEquals(listOf(2, 5, 8), intList)
|
||||
|
||||
val longList = mutableListOf<Long>()
|
||||
for (i in (10L downTo 1L step 2L).reversed() step 3L) {
|
||||
longList += i
|
||||
}
|
||||
assertEquals(listOf(2L, 5L, 8L), longList)
|
||||
|
||||
val charList = mutableListOf<Char>()
|
||||
for (i in ('j' downTo 'a' step 2).reversed() step 3) {
|
||||
charList += i
|
||||
}
|
||||
assertEquals(listOf('b', 'e', 'h'), charList)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
// WITH_RUNTIME
|
||||
import kotlin.test.*
|
||||
|
||||
fun box(): String {
|
||||
val intList = mutableListOf<Int>()
|
||||
for (i in ((10 downTo 1 step 2).reversed() step 3).reversed()) {
|
||||
intList += i
|
||||
}
|
||||
assertEquals(listOf(8, 5, 2), intList)
|
||||
|
||||
val longList = mutableListOf<Long>()
|
||||
for (i in ((10L downTo 1L step 2L).reversed() step 3L).reversed()) {
|
||||
longList += i
|
||||
}
|
||||
assertEquals(listOf(8L, 5L, 2L), longList)
|
||||
|
||||
val charList = mutableListOf<Char>()
|
||||
for (i in (('j' downTo 'a' step 2).reversed() step 3).reversed()) {
|
||||
charList += i
|
||||
}
|
||||
assertEquals(listOf('h', 'e', 'b'), charList)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
// WITH_RUNTIME
|
||||
import kotlin.test.*
|
||||
|
||||
fun box(): String {
|
||||
val intList = mutableListOf<Int>()
|
||||
for (i in 1 downTo 1 step 2) {
|
||||
intList += i
|
||||
}
|
||||
assertEquals(listOf(1), intList)
|
||||
|
||||
val longList = mutableListOf<Long>()
|
||||
for (i in 1L downTo 1L step 2L) {
|
||||
longList += i
|
||||
}
|
||||
assertEquals(listOf(1L), longList)
|
||||
|
||||
val charList = mutableListOf<Char>()
|
||||
for (i in 'a' downTo 'a' step 2) {
|
||||
charList += i
|
||||
}
|
||||
assertEquals(listOf('a'), charList)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
// WITH_RUNTIME
|
||||
import kotlin.test.*
|
||||
|
||||
fun two() = 2
|
||||
|
||||
fun box(): String {
|
||||
val intList = mutableListOf<Int>()
|
||||
for (i in 8 downTo 1 step two()) {
|
||||
intList += i
|
||||
}
|
||||
assertEquals(listOf(8, 6, 4, 2), intList)
|
||||
|
||||
val longList = mutableListOf<Long>()
|
||||
for (i in 8L downTo 1L step two().toLong()) {
|
||||
longList += i
|
||||
}
|
||||
assertEquals(listOf(8L, 6L, 4L, 2L), longList)
|
||||
|
||||
val charList = mutableListOf<Char>()
|
||||
for (i in 'h' downTo 'a' step two()) {
|
||||
charList += i
|
||||
}
|
||||
assertEquals(listOf('h', 'f', 'd', 'b'), charList)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
// WITH_RUNTIME
|
||||
import kotlin.test.*
|
||||
|
||||
fun box(): String {
|
||||
val intList = mutableListOf<Int>()
|
||||
for (i in 4 downTo 1 step 1) {
|
||||
intList += i
|
||||
}
|
||||
assertEquals(listOf(4, 3, 2, 1), intList)
|
||||
|
||||
val longList = mutableListOf<Long>()
|
||||
for (i in 4L downTo 1L step 1L) {
|
||||
longList += i
|
||||
}
|
||||
assertEquals(listOf(4L, 3L, 2L, 1L), longList)
|
||||
|
||||
val charList = mutableListOf<Char>()
|
||||
for (i in 'd' downTo 'a' step 1) {
|
||||
charList += i
|
||||
}
|
||||
assertEquals(listOf('d', 'c', 'b', 'a'), charList)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
// WITH_RUNTIME
|
||||
import kotlin.test.*
|
||||
|
||||
fun box(): String {
|
||||
val intList = mutableListOf<Int>()
|
||||
for (i in 7 downTo 1 step 7) {
|
||||
intList += i
|
||||
}
|
||||
assertEquals(listOf(7), intList)
|
||||
|
||||
val longList = mutableListOf<Long>()
|
||||
for (i in 7L downTo 1L step 7L) {
|
||||
longList += i
|
||||
}
|
||||
assertEquals(listOf(7L), longList)
|
||||
|
||||
val charList = mutableListOf<Char>()
|
||||
for (i in 'g' downTo 'a' step 7) {
|
||||
charList += i
|
||||
}
|
||||
assertEquals(listOf('g'), charList)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
// WITH_RUNTIME
|
||||
import kotlin.test.*
|
||||
|
||||
fun box(): String {
|
||||
val intList = mutableListOf<Int>()
|
||||
for (i in 7 downTo 1 step 2) {
|
||||
intList += i
|
||||
}
|
||||
assertEquals(listOf(7, 5, 3, 1), intList)
|
||||
|
||||
val longList = mutableListOf<Long>()
|
||||
for (i in 7L downTo 1L step 2L) {
|
||||
longList += i
|
||||
}
|
||||
assertEquals(listOf(7L, 5L, 3L, 1L), longList)
|
||||
|
||||
val charList = mutableListOf<Char>()
|
||||
for (i in 'g' downTo 'a' step 2) {
|
||||
charList += i
|
||||
}
|
||||
assertEquals(listOf('g', 'e', 'c', 'a'), charList)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
// WITH_RUNTIME
|
||||
import kotlin.test.*
|
||||
|
||||
fun box(): String {
|
||||
val intList = mutableListOf<Int>()
|
||||
for (i in 8 downTo 1 step 2) {
|
||||
intList += i
|
||||
}
|
||||
assertEquals(listOf(8, 6, 4, 2), intList)
|
||||
|
||||
val longList = mutableListOf<Long>()
|
||||
for (i in 8L downTo 1L step 2L) {
|
||||
longList += i
|
||||
}
|
||||
assertEquals(listOf(8L, 6L, 4L, 2L), longList)
|
||||
|
||||
val charList = mutableListOf<Char>()
|
||||
for (i in 'h' downTo 'a' step 2) {
|
||||
charList += i
|
||||
}
|
||||
assertEquals(listOf('h', 'f', 'd', 'b'), charList)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
// WITH_RUNTIME
|
||||
import kotlin.test.*
|
||||
|
||||
fun box(): String {
|
||||
val intList = mutableListOf<Int>()
|
||||
for (i in 2..1 step 2) {
|
||||
intList += i
|
||||
}
|
||||
assertTrue(intList.isEmpty())
|
||||
|
||||
val longList = mutableListOf<Long>()
|
||||
for (i in 2L..1L step 2L) {
|
||||
longList += i
|
||||
}
|
||||
assertTrue(longList.isEmpty())
|
||||
|
||||
val charList = mutableListOf<Char>()
|
||||
for (i in 'b'..'a' step 2) {
|
||||
charList += i
|
||||
}
|
||||
assertTrue(charList.isEmpty())
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
// WITH_RUNTIME
|
||||
|
||||
// Bug in JS: Translation of loop over literal completely removes the validation of step
|
||||
// DONT_TARGET_EXACT_BACKEND: JS
|
||||
import kotlin.test.*
|
||||
|
||||
fun box(): String {
|
||||
assertFailsWith<IllegalArgumentException> {
|
||||
for (i in 1..7 step -1) {
|
||||
}
|
||||
}
|
||||
|
||||
assertFailsWith<IllegalArgumentException> {
|
||||
for (i in 1L..7L step -1L) {
|
||||
}
|
||||
}
|
||||
|
||||
assertFailsWith<IllegalArgumentException> {
|
||||
for (i in 'a'..'g' step -1) {
|
||||
}
|
||||
}
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
// WITH_RUNTIME
|
||||
|
||||
// Bug in JS: Translation of loop over literal completely removes the validation of step
|
||||
// DONT_TARGET_EXACT_BACKEND: JS
|
||||
import kotlin.test.*
|
||||
|
||||
fun zero() = 0
|
||||
|
||||
fun box(): String {
|
||||
assertFailsWith<IllegalArgumentException> {
|
||||
for (i in 1..7 step zero()) {
|
||||
}
|
||||
}
|
||||
|
||||
assertFailsWith<IllegalArgumentException> {
|
||||
for (i in 1L..7L step zero().toLong()) {
|
||||
}
|
||||
}
|
||||
|
||||
assertFailsWith<IllegalArgumentException> {
|
||||
for (i in 'a'..'g' step zero()) {
|
||||
}
|
||||
}
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
// WITH_RUNTIME
|
||||
import kotlin.test.*
|
||||
|
||||
fun box(): String {
|
||||
assertFailsWith<IllegalArgumentException> {
|
||||
for (i in 1..7 step 0 step 2) {
|
||||
}
|
||||
}
|
||||
|
||||
assertFailsWith<IllegalArgumentException> {
|
||||
for (i in 1L..7L step 0L step 2L) {
|
||||
}
|
||||
}
|
||||
|
||||
assertFailsWith<IllegalArgumentException> {
|
||||
for (i in 'a'..'g' step 0 step 2) {
|
||||
}
|
||||
}
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
// WITH_RUNTIME
|
||||
|
||||
// Bug in JS: Translation of loop over literal completely removes the validation of step
|
||||
// DONT_TARGET_EXACT_BACKEND: JS
|
||||
import kotlin.test.*
|
||||
|
||||
fun box(): String {
|
||||
assertFailsWith<IllegalArgumentException> {
|
||||
for (i in 1..7 step 0) {
|
||||
}
|
||||
}
|
||||
|
||||
assertFailsWith<IllegalArgumentException> {
|
||||
for (i in 1L..7L step 0L) {
|
||||
}
|
||||
}
|
||||
|
||||
assertFailsWith<IllegalArgumentException> {
|
||||
for (i in 'a'..'g' step 0) {
|
||||
}
|
||||
}
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
// WITH_RUNTIME
|
||||
import kotlin.test.*
|
||||
|
||||
fun box(): String {
|
||||
assertFailsWith<IllegalArgumentException> {
|
||||
for (i in 1..7 step 2 step 0) {
|
||||
}
|
||||
}
|
||||
|
||||
assertFailsWith<IllegalArgumentException> {
|
||||
for (i in 1L..7L step 2L step 0L) {
|
||||
}
|
||||
}
|
||||
|
||||
assertFailsWith<IllegalArgumentException> {
|
||||
for (i in 'a'..'g' step 2 step 0) {
|
||||
}
|
||||
}
|
||||
|
||||
return "OK"
|
||||
}
|
||||
Vendored
+25
@@ -0,0 +1,25 @@
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
// WITH_RUNTIME
|
||||
import kotlin.test.*
|
||||
|
||||
fun box(): String {
|
||||
val intList = mutableListOf<Int>()
|
||||
for (i in Int.MIN_VALUE..Int.MAX_VALUE step Int.MAX_VALUE) {
|
||||
intList += i
|
||||
}
|
||||
assertEquals(listOf(Int.MIN_VALUE, -1, Int.MAX_VALUE - 1), intList)
|
||||
|
||||
val longList = mutableListOf<Long>()
|
||||
for (i in Long.MIN_VALUE..Long.MAX_VALUE step Long.MAX_VALUE) {
|
||||
longList += i
|
||||
}
|
||||
assertEquals(listOf(Long.MIN_VALUE, -1L, Long.MAX_VALUE - 1), longList)
|
||||
|
||||
val charList = mutableListOf<Char>()
|
||||
for (i in Char.MIN_VALUE..Char.MAX_VALUE step Char.MAX_VALUE.toInt()) {
|
||||
charList += i
|
||||
}
|
||||
assertEquals(listOf(Char.MIN_VALUE, Char.MAX_VALUE), charList)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
// WITH_RUNTIME
|
||||
import kotlin.test.*
|
||||
|
||||
fun box(): String {
|
||||
val intList = mutableListOf<Int>()
|
||||
for (i in 1.toShort()..7.toByte() step 2) {
|
||||
intList += i
|
||||
}
|
||||
assertEquals(listOf(1, 3, 5, 7), intList)
|
||||
|
||||
val longList = mutableListOf<Long>()
|
||||
for (i in 1L..7 step 2) {
|
||||
longList += i
|
||||
}
|
||||
assertEquals(listOf(1L, 3L, 5L, 7L), longList)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
Vendored
+25
@@ -0,0 +1,25 @@
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
// WITH_RUNTIME
|
||||
import kotlin.test.*
|
||||
|
||||
fun box(): String {
|
||||
val intList = mutableListOf<Int>()
|
||||
for (i in 1..4 step 1 step 1) {
|
||||
intList += i
|
||||
}
|
||||
assertEquals(listOf(1, 2, 3, 4), intList)
|
||||
|
||||
val longList = mutableListOf<Long>()
|
||||
for (i in 1L..4L step 1L step 1L) {
|
||||
longList += i
|
||||
}
|
||||
assertEquals(listOf(1L, 2L, 3L, 4L), longList)
|
||||
|
||||
val charList = mutableListOf<Char>()
|
||||
for (i in 'a'..'d' step 1 step 1) {
|
||||
charList += i
|
||||
}
|
||||
assertEquals(listOf('a', 'b', 'c', 'd'), charList)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
Vendored
+25
@@ -0,0 +1,25 @@
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
// WITH_RUNTIME
|
||||
import kotlin.test.*
|
||||
|
||||
fun box(): String {
|
||||
val intList = mutableListOf<Int>()
|
||||
for (i in 1..8 step 2 step 2) {
|
||||
intList += i
|
||||
}
|
||||
assertEquals(listOf(1, 3, 5, 7), intList)
|
||||
|
||||
val longList = mutableListOf<Long>()
|
||||
for (i in 1L..8L step 2L step 2L) {
|
||||
longList += i
|
||||
}
|
||||
assertEquals(listOf(1L, 3L, 5L, 7L), longList)
|
||||
|
||||
val charList = mutableListOf<Char>()
|
||||
for (i in 'a'..'h' step 2 step 2) {
|
||||
charList += i
|
||||
}
|
||||
assertEquals(listOf('a', 'c', 'e', 'g'), charList)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
compiler/testData/codegen/box/ranges/stepped/literal/rangeTo/nestedStep/stepToSameLastThenStepOne.kt
Vendored
+25
@@ -0,0 +1,25 @@
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
// WITH_RUNTIME
|
||||
import kotlin.test.*
|
||||
|
||||
fun box(): String {
|
||||
val intList = mutableListOf<Int>()
|
||||
for (i in 1..5 step 2 step 1) {
|
||||
intList += i
|
||||
}
|
||||
assertEquals(listOf(1, 2, 3, 4, 5), intList)
|
||||
|
||||
val longList = mutableListOf<Long>()
|
||||
for (i in 1L..5L step 2L step 1L) {
|
||||
longList += i
|
||||
}
|
||||
assertEquals(listOf(1L, 2L, 3L, 4L, 5L), longList)
|
||||
|
||||
val charList = mutableListOf<Char>()
|
||||
for (i in 'a'..'e' step 2 step 1) {
|
||||
charList += i
|
||||
}
|
||||
assertEquals(listOf('a', 'b', 'c', 'd', 'e'), charList)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
// WITH_RUNTIME
|
||||
import kotlin.test.*
|
||||
|
||||
fun box(): String {
|
||||
val intList = mutableListOf<Int>()
|
||||
for (i in 1..7 step 3 step 2) {
|
||||
intList += i
|
||||
}
|
||||
assertEquals(listOf(1, 3, 5, 7), intList)
|
||||
|
||||
val longList = mutableListOf<Long>()
|
||||
for (i in 1L..7L step 3L step 2L) {
|
||||
longList += i
|
||||
}
|
||||
assertEquals(listOf(1L, 3L, 5L, 7L), longList)
|
||||
|
||||
val charList = mutableListOf<Char>()
|
||||
for (i in 'a'..'g' step 3 step 2) {
|
||||
charList += i
|
||||
}
|
||||
assertEquals(listOf('a', 'c', 'e', 'g'), charList)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
// WITH_RUNTIME
|
||||
import kotlin.test.*
|
||||
|
||||
fun box(): String {
|
||||
val intList = mutableListOf<Int>()
|
||||
for (i in 1..10 step 3 step 2) {
|
||||
intList += i
|
||||
}
|
||||
assertEquals(listOf(1, 3, 5, 7, 9), intList)
|
||||
|
||||
val longList = mutableListOf<Long>()
|
||||
for (i in 1L..10L step 3L step 2L) {
|
||||
longList += i
|
||||
}
|
||||
assertEquals(listOf(1L, 3L, 5L, 7L, 9L), longList)
|
||||
|
||||
val charList = mutableListOf<Char>()
|
||||
for (i in 'a'..'j' step 3 step 2) {
|
||||
charList += i
|
||||
}
|
||||
assertEquals(listOf('a', 'c', 'e', 'g', 'i'), charList)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
// WITH_RUNTIME
|
||||
import kotlin.test.*
|
||||
|
||||
fun box(): String {
|
||||
val intList = mutableListOf<Int>()
|
||||
for (i in 1..6 step 2 step 1) {
|
||||
intList += i
|
||||
}
|
||||
assertEquals(listOf(1, 2, 3, 4, 5), intList)
|
||||
|
||||
val longList = mutableListOf<Long>()
|
||||
for (i in 1L..6L step 2L step 1L) {
|
||||
longList += i
|
||||
}
|
||||
assertEquals(listOf(1L, 2L, 3L, 4L, 5L), longList)
|
||||
|
||||
val charList = mutableListOf<Char>()
|
||||
for (i in 'a'..'f' step 2 step 1) {
|
||||
charList += i
|
||||
}
|
||||
assertEquals(listOf('a', 'b', 'c', 'd', 'e'), charList)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
// WITH_RUNTIME
|
||||
import kotlin.test.*
|
||||
|
||||
fun box(): String {
|
||||
val intList = mutableListOf<Int>()
|
||||
for (i in 1..8 step 2 step 3) {
|
||||
intList += i
|
||||
}
|
||||
assertEquals(listOf(1, 4, 7), intList)
|
||||
|
||||
val longList = mutableListOf<Long>()
|
||||
for (i in 1L..8L step 2L step 3L) {
|
||||
longList += i
|
||||
}
|
||||
assertEquals(listOf(1L, 4L, 7L), longList)
|
||||
|
||||
val charList = mutableListOf<Char>()
|
||||
for (i in 'a'..'h' step 2 step 3) {
|
||||
charList += i
|
||||
}
|
||||
assertEquals(listOf('a', 'd', 'g'), charList)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
// WITH_RUNTIME
|
||||
import kotlin.test.*
|
||||
|
||||
fun box(): String {
|
||||
val intList = mutableListOf<Int>()
|
||||
for (i in 1..10 step 2 step 3) {
|
||||
intList += i
|
||||
}
|
||||
assertEquals(listOf(1, 4, 7), intList)
|
||||
|
||||
val longList = mutableListOf<Long>()
|
||||
for (i in 1L..10L step 2L step 3L) {
|
||||
longList += i
|
||||
}
|
||||
assertEquals(listOf(1L, 4L, 7L), longList)
|
||||
|
||||
val charList = mutableListOf<Char>()
|
||||
for (i in 'a'..'j' step 2 step 3) {
|
||||
charList += i
|
||||
}
|
||||
assertEquals(listOf('a', 'd', 'g'), charList)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
// WITH_RUNTIME
|
||||
import kotlin.test.*
|
||||
|
||||
fun box(): String {
|
||||
val intList = mutableListOf<Int>()
|
||||
for (i in 1..Int.MAX_VALUE step Int.MAX_VALUE) {
|
||||
intList += i
|
||||
}
|
||||
assertEquals(listOf(1), intList)
|
||||
|
||||
val longList = mutableListOf<Long>()
|
||||
for (i in 1L..Long.MAX_VALUE step Long.MAX_VALUE) {
|
||||
longList += i
|
||||
}
|
||||
assertEquals(listOf(1L), longList)
|
||||
|
||||
val charList = mutableListOf<Char>()
|
||||
for (i in 1.toChar()..Char.MAX_VALUE step Char.MAX_VALUE.toInt()) {
|
||||
charList += i
|
||||
}
|
||||
assertEquals(listOf(1.toChar()), charList)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
// WITH_RUNTIME
|
||||
import kotlin.test.*
|
||||
|
||||
fun box(): String {
|
||||
val intList = mutableListOf<Int>()
|
||||
for (i in (1..8).reversed() step 2) {
|
||||
intList += i
|
||||
}
|
||||
assertEquals(listOf(8, 6, 4, 2), intList)
|
||||
|
||||
val longList = mutableListOf<Long>()
|
||||
for (i in (1L..8L).reversed() step 2L) {
|
||||
longList += i
|
||||
}
|
||||
assertEquals(listOf(8L, 6L, 4L, 2L), longList)
|
||||
|
||||
val charList = mutableListOf<Char>()
|
||||
for (i in ('a'..'h').reversed() step 2) {
|
||||
charList += i
|
||||
}
|
||||
assertEquals(listOf('h', 'f', 'd', 'b'), charList)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
// WITH_RUNTIME
|
||||
import kotlin.test.*
|
||||
|
||||
fun box(): String {
|
||||
val intList = mutableListOf<Int>()
|
||||
for (i in ((1..8).reversed() step 2).reversed()) {
|
||||
intList += i
|
||||
}
|
||||
assertEquals(listOf(2, 4, 6, 8), intList)
|
||||
|
||||
val longList = mutableListOf<Long>()
|
||||
for (i in ((1L..8L).reversed() step 2L).reversed()) {
|
||||
longList += i
|
||||
}
|
||||
assertEquals(listOf(2L, 4L, 6L, 8L), longList)
|
||||
|
||||
val charList = mutableListOf<Char>()
|
||||
for (i in (('a'..'h').reversed() step 2).reversed()) {
|
||||
charList += i
|
||||
}
|
||||
assertEquals(listOf('b', 'd', 'f', 'h'), charList)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
// WITH_RUNTIME
|
||||
import kotlin.test.*
|
||||
|
||||
fun box(): String {
|
||||
val intList = mutableListOf<Int>()
|
||||
for (i in ((1..10).reversed() step 2).reversed() step 3) {
|
||||
intList += i
|
||||
}
|
||||
assertEquals(listOf(2, 5, 8), intList)
|
||||
|
||||
val longList = mutableListOf<Long>()
|
||||
for (i in ((1L..10L).reversed() step 2L).reversed() step 3L) {
|
||||
longList += i
|
||||
}
|
||||
assertEquals(listOf(2L, 5L, 8L), longList)
|
||||
|
||||
val charList = mutableListOf<Char>()
|
||||
for (i in (('a'..'j').reversed() step 2).reversed() step 3) {
|
||||
charList += i
|
||||
}
|
||||
assertEquals(listOf('b', 'e', 'h'), charList)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
// WITH_RUNTIME
|
||||
import kotlin.test.*
|
||||
|
||||
fun box(): String {
|
||||
val intList = mutableListOf<Int>()
|
||||
for (i in (1..8 step 2).reversed()) {
|
||||
intList += i
|
||||
}
|
||||
assertEquals(listOf(7, 5, 3, 1), intList)
|
||||
|
||||
val longList = mutableListOf<Long>()
|
||||
for (i in (1L..8L step 2L).reversed()) {
|
||||
longList += i
|
||||
}
|
||||
assertEquals(listOf(7L, 5L, 3L, 1L), longList)
|
||||
|
||||
val charList = mutableListOf<Char>()
|
||||
for (i in ('a'..'h' step 2).reversed()) {
|
||||
charList += i
|
||||
}
|
||||
assertEquals(listOf('g', 'e', 'c', 'a'), charList)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
Vendored
+25
@@ -0,0 +1,25 @@
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
// WITH_RUNTIME
|
||||
import kotlin.test.*
|
||||
|
||||
fun box(): String {
|
||||
val intList = mutableListOf<Int>()
|
||||
for (i in (1..10 step 2).reversed() step 3) {
|
||||
intList += i
|
||||
}
|
||||
assertEquals(listOf(9, 6, 3), intList)
|
||||
|
||||
val longList = mutableListOf<Long>()
|
||||
for (i in (1L..10L step 2L).reversed() step 3L) {
|
||||
longList += i
|
||||
}
|
||||
assertEquals(listOf(9L, 6L, 3L), longList)
|
||||
|
||||
val charList = mutableListOf<Char>()
|
||||
for (i in ('a'..'j' step 2).reversed() step 3) {
|
||||
charList += i
|
||||
}
|
||||
assertEquals(listOf('i', 'f', 'c'), charList)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
// WITH_RUNTIME
|
||||
import kotlin.test.*
|
||||
|
||||
fun box(): String {
|
||||
val intList = mutableListOf<Int>()
|
||||
for (i in ((1..10 step 2).reversed() step 3).reversed()) {
|
||||
intList += i
|
||||
}
|
||||
assertEquals(listOf(3, 6, 9), intList)
|
||||
|
||||
val longList = mutableListOf<Long>()
|
||||
for (i in ((1L..10L step 2L).reversed() step 3L).reversed()) {
|
||||
longList += i
|
||||
}
|
||||
assertEquals(listOf(3L, 6L, 9L), longList)
|
||||
|
||||
val charList = mutableListOf<Char>()
|
||||
for (i in (('a'..'j' step 2).reversed() step 3).reversed()) {
|
||||
charList += i
|
||||
}
|
||||
assertEquals(listOf('c', 'f', 'i'), charList)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
// WITH_RUNTIME
|
||||
import kotlin.test.*
|
||||
|
||||
fun box(): String {
|
||||
val intList = mutableListOf<Int>()
|
||||
for (i in 1..1 step 2) {
|
||||
intList += i
|
||||
}
|
||||
assertEquals(listOf(1), intList)
|
||||
|
||||
val longList = mutableListOf<Long>()
|
||||
for (i in 1L..1L step 2L) {
|
||||
longList += i
|
||||
}
|
||||
assertEquals(listOf(1L), longList)
|
||||
|
||||
val charList = mutableListOf<Char>()
|
||||
for (i in 'a'..'a' step 2) {
|
||||
charList += i
|
||||
}
|
||||
assertEquals(listOf('a'), charList)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
// WITH_RUNTIME
|
||||
import kotlin.test.*
|
||||
|
||||
fun two() = 2
|
||||
|
||||
fun box(): String {
|
||||
val intList = mutableListOf<Int>()
|
||||
for (i in 1..8 step two()) {
|
||||
intList += i
|
||||
}
|
||||
assertEquals(listOf(1, 3, 5, 7), intList)
|
||||
|
||||
val longList = mutableListOf<Long>()
|
||||
for (i in 1L..8L step two().toLong()) {
|
||||
longList += i
|
||||
}
|
||||
assertEquals(listOf(1L, 3L, 5L, 7L), longList)
|
||||
|
||||
val charList = mutableListOf<Char>()
|
||||
for (i in 'a'..'h' step two()) {
|
||||
charList += i
|
||||
}
|
||||
assertEquals(listOf('a', 'c', 'e', 'g'), charList)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
// WITH_RUNTIME
|
||||
import kotlin.test.*
|
||||
|
||||
fun box(): String {
|
||||
val intList = mutableListOf<Int>()
|
||||
for (i in 1..4 step 1) {
|
||||
intList += i
|
||||
}
|
||||
assertEquals(listOf(1, 2, 3, 4), intList)
|
||||
|
||||
val longList = mutableListOf<Long>()
|
||||
for (i in 1L..4L step 1L) {
|
||||
longList += i
|
||||
}
|
||||
assertEquals(listOf(1L, 2L, 3L, 4L), longList)
|
||||
|
||||
val charList = mutableListOf<Char>()
|
||||
for (i in 'a'..'d' step 1) {
|
||||
charList += i
|
||||
}
|
||||
assertEquals(listOf('a', 'b', 'c', 'd'), charList)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
// WITH_RUNTIME
|
||||
import kotlin.test.*
|
||||
|
||||
fun box(): String {
|
||||
val intList = mutableListOf<Int>()
|
||||
for (i in 1..7 step 7) {
|
||||
intList += i
|
||||
}
|
||||
assertEquals(listOf(1), intList)
|
||||
|
||||
val longList = mutableListOf<Long>()
|
||||
for (i in 1L..7L step 7L) {
|
||||
longList += i
|
||||
}
|
||||
assertEquals(listOf(1L), longList)
|
||||
|
||||
val charList = mutableListOf<Char>()
|
||||
for (i in 'a'..'g' step 7) {
|
||||
charList += i
|
||||
}
|
||||
assertEquals(listOf('a'), charList)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
// WITH_RUNTIME
|
||||
import kotlin.test.*
|
||||
|
||||
fun box(): String {
|
||||
val intList = mutableListOf<Int>()
|
||||
for (i in 1..7 step 2) {
|
||||
intList += i
|
||||
}
|
||||
assertEquals(listOf(1, 3, 5, 7), intList)
|
||||
|
||||
val longList = mutableListOf<Long>()
|
||||
for (i in 1L..7L step 2L) {
|
||||
longList += i
|
||||
}
|
||||
assertEquals(listOf(1L, 3L, 5L, 7L), longList)
|
||||
|
||||
val charList = mutableListOf<Char>()
|
||||
for (i in 'a'..'g' step 2) {
|
||||
charList += i
|
||||
}
|
||||
assertEquals(listOf('a', 'c', 'e', 'g'), charList)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
// WITH_RUNTIME
|
||||
import kotlin.test.*
|
||||
|
||||
fun box(): String {
|
||||
val intList = mutableListOf<Int>()
|
||||
for (i in 1..8 step 2) {
|
||||
intList += i
|
||||
}
|
||||
assertEquals(listOf(1, 3, 5, 7), intList)
|
||||
|
||||
val longList = mutableListOf<Long>()
|
||||
for (i in 1L..8L step 2L) {
|
||||
longList += i
|
||||
}
|
||||
assertEquals(listOf(1L, 3L, 5L, 7L), longList)
|
||||
|
||||
val charList = mutableListOf<Char>()
|
||||
for (i in 'a'..'h' step 2) {
|
||||
charList += i
|
||||
}
|
||||
assertEquals(listOf('a', 'c', 'e', 'g'), charList)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
// WITH_RUNTIME
|
||||
import kotlin.test.*
|
||||
|
||||
fun box(): String {
|
||||
val intList = mutableListOf<Int>()
|
||||
for (i in 0..Int.MAX_VALUE step Int.MAX_VALUE) {
|
||||
intList += i
|
||||
}
|
||||
assertEquals(listOf(0, Int.MAX_VALUE), intList)
|
||||
|
||||
val longList = mutableListOf<Long>()
|
||||
for (i in 0L..Long.MAX_VALUE step Long.MAX_VALUE) {
|
||||
longList += i
|
||||
}
|
||||
assertEquals(listOf(0L, Long.MAX_VALUE), longList)
|
||||
|
||||
val charList = mutableListOf<Char>()
|
||||
for (i in 0.toChar()..Char.MAX_VALUE step Char.MAX_VALUE.toInt()) {
|
||||
charList += i
|
||||
}
|
||||
assertEquals(listOf(0.toChar(), Char.MAX_VALUE), charList)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
// WITH_RUNTIME
|
||||
import kotlin.test.*
|
||||
|
||||
fun box(): String {
|
||||
val intList = mutableListOf<Int>()
|
||||
for (i in 2 until 2 step 2) {
|
||||
intList += i
|
||||
}
|
||||
assertTrue(intList.isEmpty())
|
||||
|
||||
val longList = mutableListOf<Long>()
|
||||
for (i in 2L until 2L step 2L) {
|
||||
longList += i
|
||||
}
|
||||
assertTrue(longList.isEmpty())
|
||||
|
||||
val charList = mutableListOf<Char>()
|
||||
for (i in 'b' until 'b' step 2) {
|
||||
charList += i
|
||||
}
|
||||
assertTrue(charList.isEmpty())
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
// WITH_RUNTIME
|
||||
import kotlin.test.*
|
||||
|
||||
fun box(): String {
|
||||
val intList = mutableListOf<Int>()
|
||||
for (i in 2 until Int.MIN_VALUE step 2) {
|
||||
intList += i
|
||||
}
|
||||
assertTrue(intList.isEmpty())
|
||||
|
||||
val longList = mutableListOf<Long>()
|
||||
for (i in 2L until Long.MIN_VALUE step 2L) {
|
||||
longList += i
|
||||
}
|
||||
assertTrue(longList.isEmpty())
|
||||
|
||||
val charList = mutableListOf<Char>()
|
||||
for (i in 'b' until Char.MIN_VALUE step 2) {
|
||||
charList += i
|
||||
}
|
||||
assertTrue(charList.isEmpty())
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
// WITH_RUNTIME
|
||||
|
||||
// Bug in JS: Translation of loop over literal completely removes the validation of step
|
||||
// DONT_TARGET_EXACT_BACKEND: JS
|
||||
import kotlin.test.*
|
||||
|
||||
fun box(): String {
|
||||
assertFailsWith<IllegalArgumentException> {
|
||||
for (i in 1 until 7 step -1) {
|
||||
}
|
||||
}
|
||||
|
||||
assertFailsWith<IllegalArgumentException> {
|
||||
for (i in 1L until 7L step -1L) {
|
||||
}
|
||||
}
|
||||
|
||||
assertFailsWith<IllegalArgumentException> {
|
||||
for (i in 'a' until 'g' step -1) {
|
||||
}
|
||||
}
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
// WITH_RUNTIME
|
||||
|
||||
// Bug in JS: Translation of loop over literal completely removes the validation of step
|
||||
// DONT_TARGET_EXACT_BACKEND: JS
|
||||
import kotlin.test.*
|
||||
|
||||
fun zero() = 0
|
||||
|
||||
fun box(): String {
|
||||
assertFailsWith<IllegalArgumentException> {
|
||||
for (i in 1 until 7 step zero()) {
|
||||
}
|
||||
}
|
||||
|
||||
assertFailsWith<IllegalArgumentException> {
|
||||
for (i in 1L until 7L step zero().toLong()) {
|
||||
}
|
||||
}
|
||||
|
||||
assertFailsWith<IllegalArgumentException> {
|
||||
for (i in 'a' until 'g' step zero()) {
|
||||
}
|
||||
}
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
// WITH_RUNTIME
|
||||
import kotlin.test.*
|
||||
|
||||
fun box(): String {
|
||||
assertFailsWith<IllegalArgumentException> {
|
||||
for (i in 1 until 7 step 0 step 2) {
|
||||
}
|
||||
}
|
||||
|
||||
assertFailsWith<IllegalArgumentException> {
|
||||
for (i in 1L until 7L step 0L step 2L) {
|
||||
}
|
||||
}
|
||||
|
||||
assertFailsWith<IllegalArgumentException> {
|
||||
for (i in 'a' until 'g' step 0 step 2) {
|
||||
}
|
||||
}
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
// WITH_RUNTIME
|
||||
|
||||
// Bug in JS: Translation of loop over literal completely removes the validation of step
|
||||
// DONT_TARGET_EXACT_BACKEND: JS
|
||||
import kotlin.test.*
|
||||
|
||||
fun box(): String {
|
||||
assertFailsWith<IllegalArgumentException> {
|
||||
for (i in 1 until 7 step 0) {
|
||||
}
|
||||
}
|
||||
|
||||
assertFailsWith<IllegalArgumentException> {
|
||||
for (i in 1L until 7L step 0L) {
|
||||
}
|
||||
}
|
||||
|
||||
assertFailsWith<IllegalArgumentException> {
|
||||
for (i in 'a' until 'g' step 0) {
|
||||
}
|
||||
}
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
// WITH_RUNTIME
|
||||
import kotlin.test.*
|
||||
|
||||
fun box(): String {
|
||||
assertFailsWith<IllegalArgumentException> {
|
||||
for (i in 1 until 7 step 2 step 0) {
|
||||
}
|
||||
}
|
||||
|
||||
assertFailsWith<IllegalArgumentException> {
|
||||
for (i in 1L until 7L step 2L step 0L) {
|
||||
}
|
||||
}
|
||||
|
||||
assertFailsWith<IllegalArgumentException> {
|
||||
for (i in 'a' until 'g' step 2 step 0) {
|
||||
}
|
||||
}
|
||||
|
||||
return "OK"
|
||||
}
|
||||
Vendored
+19
@@ -0,0 +1,19 @@
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
// WITH_RUNTIME
|
||||
import kotlin.test.*
|
||||
|
||||
fun box(): String {
|
||||
val intList = mutableListOf<Int>()
|
||||
for (i in Int.MIN_VALUE until Int.MAX_VALUE step Int.MAX_VALUE) {
|
||||
intList += i
|
||||
}
|
||||
assertEquals(listOf(Int.MIN_VALUE, -1, Int.MAX_VALUE - 1), intList)
|
||||
|
||||
val longList = mutableListOf<Long>()
|
||||
for (i in Long.MIN_VALUE until Long.MAX_VALUE step Long.MAX_VALUE) {
|
||||
longList += i
|
||||
}
|
||||
assertEquals(listOf(Long.MIN_VALUE, -1L, Long.MAX_VALUE - 1), longList)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
// WITH_RUNTIME
|
||||
import kotlin.test.*
|
||||
|
||||
fun box(): String {
|
||||
val intList = mutableListOf<Int>()
|
||||
for (i in 1.toShort() until 8.toByte() step 2) {
|
||||
intList += i
|
||||
}
|
||||
assertEquals(listOf(1, 3, 5, 7), intList)
|
||||
|
||||
val longList = mutableListOf<Long>()
|
||||
for (i in 1L until 8 step 2) {
|
||||
longList += i
|
||||
}
|
||||
assertEquals(listOf(1L, 3L, 5L, 7L), longList)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
Vendored
+25
@@ -0,0 +1,25 @@
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
// WITH_RUNTIME
|
||||
import kotlin.test.*
|
||||
|
||||
fun box(): String {
|
||||
val intList = mutableListOf<Int>()
|
||||
for (i in 1 until 5 step 1 step 1) {
|
||||
intList += i
|
||||
}
|
||||
assertEquals(listOf(1, 2, 3, 4), intList)
|
||||
|
||||
val longList = mutableListOf<Long>()
|
||||
for (i in 1L until 5L step 1L step 1L) {
|
||||
longList += i
|
||||
}
|
||||
assertEquals(listOf(1L, 2L, 3L, 4L), longList)
|
||||
|
||||
val charList = mutableListOf<Char>()
|
||||
for (i in 'a' until 'e' step 1 step 1) {
|
||||
charList += i
|
||||
}
|
||||
assertEquals(listOf('a', 'b', 'c', 'd'), charList)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
// WITH_RUNTIME
|
||||
import kotlin.test.*
|
||||
|
||||
fun box(): String {
|
||||
val intList = mutableListOf<Int>()
|
||||
for (i in 1 until 9 step 2 step 2) {
|
||||
intList += i
|
||||
}
|
||||
assertEquals(listOf(1, 3, 5, 7), intList)
|
||||
|
||||
val longList = mutableListOf<Long>()
|
||||
for (i in 1L until 9L step 2L step 2L) {
|
||||
longList += i
|
||||
}
|
||||
assertEquals(listOf(1L, 3L, 5L, 7L), longList)
|
||||
|
||||
val charList = mutableListOf<Char>()
|
||||
for (i in 'a' until 'i' step 2 step 2) {
|
||||
charList += i
|
||||
}
|
||||
assertEquals(listOf('a', 'c', 'e', 'g'), charList)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
Vendored
+25
@@ -0,0 +1,25 @@
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
// WITH_RUNTIME
|
||||
import kotlin.test.*
|
||||
|
||||
fun box(): String {
|
||||
val intList = mutableListOf<Int>()
|
||||
for (i in 1 until 6 step 2 step 1) {
|
||||
intList += i
|
||||
}
|
||||
assertEquals(listOf(1, 2, 3, 4, 5), intList)
|
||||
|
||||
val longList = mutableListOf<Long>()
|
||||
for (i in 1L until 6L step 2L step 1L) {
|
||||
longList += i
|
||||
}
|
||||
assertEquals(listOf(1L, 2L, 3L, 4L, 5L), longList)
|
||||
|
||||
val charList = mutableListOf<Char>()
|
||||
for (i in 'a' until 'f' step 2 step 1) {
|
||||
charList += i
|
||||
}
|
||||
assertEquals(listOf('a', 'b', 'c', 'd', 'e'), charList)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
// WITH_RUNTIME
|
||||
import kotlin.test.*
|
||||
|
||||
fun box(): String {
|
||||
val intList = mutableListOf<Int>()
|
||||
for (i in 1 until 8 step 3 step 2) {
|
||||
intList += i
|
||||
}
|
||||
assertEquals(listOf(1, 3, 5, 7), intList)
|
||||
|
||||
val longList = mutableListOf<Long>()
|
||||
for (i in 1L until 8L step 3L step 2L) {
|
||||
longList += i
|
||||
}
|
||||
assertEquals(listOf(1L, 3L, 5L, 7L), longList)
|
||||
|
||||
val charList = mutableListOf<Char>()
|
||||
for (i in 'a' until 'h' step 3 step 2) {
|
||||
charList += i
|
||||
}
|
||||
assertEquals(listOf('a', 'c', 'e', 'g'), charList)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
// WITH_RUNTIME
|
||||
import kotlin.test.*
|
||||
|
||||
fun box(): String {
|
||||
val intList = mutableListOf<Int>()
|
||||
for (i in 1 until 11 step 3 step 2) {
|
||||
intList += i
|
||||
}
|
||||
assertEquals(listOf(1, 3, 5, 7, 9), intList)
|
||||
|
||||
val longList = mutableListOf<Long>()
|
||||
for (i in 1L until 11L step 3L step 2L) {
|
||||
longList += i
|
||||
}
|
||||
assertEquals(listOf(1L, 3L, 5L, 7L, 9L), longList)
|
||||
|
||||
val charList = mutableListOf<Char>()
|
||||
for (i in 'a' until 'k' step 3 step 2) {
|
||||
charList += i
|
||||
}
|
||||
assertEquals(listOf('a', 'c', 'e', 'g', 'i'), charList)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
// WITH_RUNTIME
|
||||
import kotlin.test.*
|
||||
|
||||
fun box(): String {
|
||||
val intList = mutableListOf<Int>()
|
||||
for (i in 1 until 7 step 2 step 1) {
|
||||
intList += i
|
||||
}
|
||||
assertEquals(listOf(1, 2, 3, 4, 5), intList)
|
||||
|
||||
val longList = mutableListOf<Long>()
|
||||
for (i in 1L until 7L step 2L step 1L) {
|
||||
longList += i
|
||||
}
|
||||
assertEquals(listOf(1L, 2L, 3L, 4L, 5L), longList)
|
||||
|
||||
val charList = mutableListOf<Char>()
|
||||
for (i in 'a' until 'g' step 2 step 1) {
|
||||
charList += i
|
||||
}
|
||||
assertEquals(listOf('a', 'b', 'c', 'd', 'e'), charList)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
// WITH_RUNTIME
|
||||
import kotlin.test.*
|
||||
|
||||
fun box(): String {
|
||||
val intList = mutableListOf<Int>()
|
||||
for (i in 1 until 9 step 2 step 3) {
|
||||
intList += i
|
||||
}
|
||||
assertEquals(listOf(1, 4, 7), intList)
|
||||
|
||||
val longList = mutableListOf<Long>()
|
||||
for (i in 1L until 9L step 2L step 3L) {
|
||||
longList += i
|
||||
}
|
||||
assertEquals(listOf(1L, 4L, 7L), longList)
|
||||
|
||||
val charList = mutableListOf<Char>()
|
||||
for (i in 'a' until 'i' step 2 step 3) {
|
||||
charList += i
|
||||
}
|
||||
assertEquals(listOf('a', 'd', 'g'), charList)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
// WITH_RUNTIME
|
||||
import kotlin.test.*
|
||||
|
||||
fun box(): String {
|
||||
val intList = mutableListOf<Int>()
|
||||
for (i in 1 until 11 step 2 step 3) {
|
||||
intList += i
|
||||
}
|
||||
assertEquals(listOf(1, 4, 7), intList)
|
||||
|
||||
val longList = mutableListOf<Long>()
|
||||
for (i in 1L until 11L step 2L step 3L) {
|
||||
longList += i
|
||||
}
|
||||
assertEquals(listOf(1L, 4L, 7L), longList)
|
||||
|
||||
val charList = mutableListOf<Char>()
|
||||
for (i in 'a' until 'k' step 2 step 3) {
|
||||
charList += i
|
||||
}
|
||||
assertEquals(listOf('a', 'd', 'g'), charList)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
// WITH_RUNTIME
|
||||
import kotlin.test.*
|
||||
|
||||
fun nine() = 9
|
||||
|
||||
fun box(): String {
|
||||
val intList = mutableListOf<Int>()
|
||||
for (i in 1 until nine() step 2) {
|
||||
intList += i
|
||||
}
|
||||
assertEquals(listOf(1, 3, 5, 7), intList)
|
||||
|
||||
val longList = mutableListOf<Long>()
|
||||
for (i in 1L until nine().toLong() step 2L) {
|
||||
longList += i
|
||||
}
|
||||
assertEquals(listOf(1L, 3L, 5L, 7L), longList)
|
||||
|
||||
val charList = mutableListOf<Char>()
|
||||
for (i in 'a' until ('a' - 1 + nine()) step 2) {
|
||||
charList += i
|
||||
}
|
||||
assertEquals(listOf('a', 'c', 'e', 'g'), charList)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
// WITH_RUNTIME
|
||||
import kotlin.test.*
|
||||
|
||||
fun box(): String {
|
||||
val intList = mutableListOf<Int>()
|
||||
for (i in (1 until 9).reversed() step 2) {
|
||||
intList += i
|
||||
}
|
||||
assertEquals(listOf(8, 6, 4, 2), intList)
|
||||
|
||||
val longList = mutableListOf<Long>()
|
||||
for (i in (1L until 9L).reversed() step 2L) {
|
||||
longList += i
|
||||
}
|
||||
assertEquals(listOf(8L, 6L, 4L, 2L), longList)
|
||||
|
||||
val charList = mutableListOf<Char>()
|
||||
for (i in ('a' until 'i').reversed() step 2) {
|
||||
charList += i
|
||||
}
|
||||
assertEquals(listOf('h', 'f', 'd', 'b'), charList)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
Vendored
+25
@@ -0,0 +1,25 @@
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
// WITH_RUNTIME
|
||||
import kotlin.test.*
|
||||
|
||||
fun box(): String {
|
||||
val intList = mutableListOf<Int>()
|
||||
for (i in ((1 until 9).reversed() step 2).reversed()) {
|
||||
intList += i
|
||||
}
|
||||
assertEquals(listOf(2, 4, 6, 8), intList)
|
||||
|
||||
val longList = mutableListOf<Long>()
|
||||
for (i in ((1L until 9L).reversed() step 2L).reversed()) {
|
||||
longList += i
|
||||
}
|
||||
assertEquals(listOf(2L, 4L, 6L, 8L), longList)
|
||||
|
||||
val charList = mutableListOf<Char>()
|
||||
for (i in (('a' until 'i').reversed() step 2).reversed()) {
|
||||
charList += i
|
||||
}
|
||||
assertEquals(listOf('b', 'd', 'f', 'h'), charList)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
// WITH_RUNTIME
|
||||
import kotlin.test.*
|
||||
|
||||
fun box(): String {
|
||||
val intList = mutableListOf<Int>()
|
||||
for (i in ((1 until 11).reversed() step 2).reversed() step 3) {
|
||||
intList += i
|
||||
}
|
||||
assertEquals(listOf(2, 5, 8), intList)
|
||||
|
||||
val longList = mutableListOf<Long>()
|
||||
for (i in ((1L until 11L).reversed() step 2L).reversed() step 3L) {
|
||||
longList += i
|
||||
}
|
||||
assertEquals(listOf(2L, 5L, 8L), longList)
|
||||
|
||||
val charList = mutableListOf<Char>()
|
||||
for (i in (('a' until 'k').reversed() step 2).reversed() step 3) {
|
||||
charList += i
|
||||
}
|
||||
assertEquals(listOf('b', 'e', 'h'), charList)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
// WITH_RUNTIME
|
||||
import kotlin.test.*
|
||||
|
||||
fun box(): String {
|
||||
val intList = mutableListOf<Int>()
|
||||
for (i in (1 until 9 step 2).reversed()) {
|
||||
intList += i
|
||||
}
|
||||
assertEquals(listOf(7, 5, 3, 1), intList)
|
||||
|
||||
val longList = mutableListOf<Long>()
|
||||
for (i in (1L until 9L step 2L).reversed()) {
|
||||
longList += i
|
||||
}
|
||||
assertEquals(listOf(7L, 5L, 3L, 1L), longList)
|
||||
|
||||
val charList = mutableListOf<Char>()
|
||||
for (i in ('a' until 'i' step 2).reversed()) {
|
||||
charList += i
|
||||
}
|
||||
assertEquals(listOf('g', 'e', 'c', 'a'), charList)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
Vendored
+25
@@ -0,0 +1,25 @@
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
// WITH_RUNTIME
|
||||
import kotlin.test.*
|
||||
|
||||
fun box(): String {
|
||||
val intList = mutableListOf<Int>()
|
||||
for (i in (1 until 11 step 2).reversed() step 3) {
|
||||
intList += i
|
||||
}
|
||||
assertEquals(listOf(9, 6, 3), intList)
|
||||
|
||||
val longList = mutableListOf<Long>()
|
||||
for (i in (1L until 11L step 2L).reversed() step 3L) {
|
||||
longList += i
|
||||
}
|
||||
assertEquals(listOf(9L, 6L, 3L), longList)
|
||||
|
||||
val charList = mutableListOf<Char>()
|
||||
for (i in ('a' until 'k' step 2).reversed() step 3) {
|
||||
charList += i
|
||||
}
|
||||
assertEquals(listOf('i', 'f', 'c'), charList)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
// WITH_RUNTIME
|
||||
import kotlin.test.*
|
||||
|
||||
fun box(): String {
|
||||
val intList = mutableListOf<Int>()
|
||||
for (i in ((1 until 11 step 2).reversed() step 3).reversed()) {
|
||||
intList += i
|
||||
}
|
||||
assertEquals(listOf(3, 6, 9), intList)
|
||||
|
||||
val longList = mutableListOf<Long>()
|
||||
for (i in ((1L until 11L step 2L).reversed() step 3L).reversed()) {
|
||||
longList += i
|
||||
}
|
||||
assertEquals(listOf(3L, 6L, 9L), longList)
|
||||
|
||||
val charList = mutableListOf<Char>()
|
||||
for (i in (('a' until 'k' step 2).reversed() step 3).reversed()) {
|
||||
charList += i
|
||||
}
|
||||
assertEquals(listOf('c', 'f', 'i'), charList)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
// WITH_RUNTIME
|
||||
import kotlin.test.*
|
||||
|
||||
fun box(): String {
|
||||
val intList = mutableListOf<Int>()
|
||||
for (i in 1 until 2 step 2) {
|
||||
intList += i
|
||||
}
|
||||
assertEquals(listOf(1), intList)
|
||||
|
||||
val longList = mutableListOf<Long>()
|
||||
for (i in 1L until 2L step 2L) {
|
||||
longList += i
|
||||
}
|
||||
assertEquals(listOf(1L), longList)
|
||||
|
||||
val charList = mutableListOf<Char>()
|
||||
for (i in 'a' until 'b' step 2) {
|
||||
charList += i
|
||||
}
|
||||
assertEquals(listOf('a'), charList)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
// WITH_RUNTIME
|
||||
import kotlin.test.*
|
||||
|
||||
fun two() = 2
|
||||
|
||||
fun box(): String {
|
||||
val intList = mutableListOf<Int>()
|
||||
for (i in 1 until 9 step two()) {
|
||||
intList += i
|
||||
}
|
||||
assertEquals(listOf(1, 3, 5, 7), intList)
|
||||
|
||||
val longList = mutableListOf<Long>()
|
||||
for (i in 1L until 9L step two().toLong()) {
|
||||
longList += i
|
||||
}
|
||||
assertEquals(listOf(1L, 3L, 5L, 7L), longList)
|
||||
|
||||
val charList = mutableListOf<Char>()
|
||||
for (i in 'a' until 'i' step two()) {
|
||||
charList += i
|
||||
}
|
||||
assertEquals(listOf('a', 'c', 'e', 'g'), charList)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
// WITH_RUNTIME
|
||||
import kotlin.test.*
|
||||
|
||||
fun box(): String {
|
||||
val intList = mutableListOf<Int>()
|
||||
for (i in 1 until 5 step 1) {
|
||||
intList += i
|
||||
}
|
||||
assertEquals(listOf(1, 2, 3, 4), intList)
|
||||
|
||||
val longList = mutableListOf<Long>()
|
||||
for (i in 1L until 5L step 1L) {
|
||||
longList += i
|
||||
}
|
||||
assertEquals(listOf(1L, 2L, 3L, 4L), longList)
|
||||
|
||||
val charList = mutableListOf<Char>()
|
||||
for (i in 'a' until 'e' step 1) {
|
||||
charList += i
|
||||
}
|
||||
assertEquals(listOf('a', 'b', 'c', 'd'), charList)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
// WITH_RUNTIME
|
||||
import kotlin.test.*
|
||||
|
||||
fun box(): String {
|
||||
val intList = mutableListOf<Int>()
|
||||
for (i in 1 until 8 step 7) {
|
||||
intList += i
|
||||
}
|
||||
assertEquals(listOf(1), intList)
|
||||
|
||||
val longList = mutableListOf<Long>()
|
||||
for (i in 1L until 8L step 7L) {
|
||||
longList += i
|
||||
}
|
||||
assertEquals(listOf(1L), longList)
|
||||
|
||||
val charList = mutableListOf<Char>()
|
||||
for (i in 'a' until 'h' step 7) {
|
||||
charList += i
|
||||
}
|
||||
assertEquals(listOf('a'), charList)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
// WITH_RUNTIME
|
||||
import kotlin.test.*
|
||||
|
||||
fun box(): String {
|
||||
val intList = mutableListOf<Int>()
|
||||
for (i in 1 until 8 step 2) {
|
||||
intList += i
|
||||
}
|
||||
assertEquals(listOf(1, 3, 5, 7), intList)
|
||||
|
||||
val longList = mutableListOf<Long>()
|
||||
for (i in 1L until 8L step 2L) {
|
||||
longList += i
|
||||
}
|
||||
assertEquals(listOf(1L, 3L, 5L, 7L), longList)
|
||||
|
||||
val charList = mutableListOf<Char>()
|
||||
for (i in 'a' until 'h' step 2) {
|
||||
charList += i
|
||||
}
|
||||
assertEquals(listOf('a', 'c', 'e', 'g'), charList)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
// WITH_RUNTIME
|
||||
import kotlin.test.*
|
||||
|
||||
fun box(): String {
|
||||
val intList = mutableListOf<Int>()
|
||||
for (i in 1 until 9 step 2) {
|
||||
intList += i
|
||||
}
|
||||
assertEquals(listOf(1, 3, 5, 7), intList)
|
||||
|
||||
val longList = mutableListOf<Long>()
|
||||
for (i in 1L until 9L step 2L) {
|
||||
longList += i
|
||||
}
|
||||
assertEquals(listOf(1L, 3L, 5L, 7L), longList)
|
||||
|
||||
val charList = mutableListOf<Char>()
|
||||
for (i in 'a' until 'i' step 2) {
|
||||
charList += i
|
||||
}
|
||||
assertEquals(listOf('a', 'c', 'e', 'g'), charList)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
// WITH_RUNTIME
|
||||
import kotlin.test.*
|
||||
|
||||
fun box(): String {
|
||||
val intList = mutableListOf<Int>()
|
||||
for (i in 0 until Int.MAX_VALUE step Int.MAX_VALUE) {
|
||||
intList += i
|
||||
}
|
||||
assertEquals(listOf(0), intList)
|
||||
|
||||
val longList = mutableListOf<Long>()
|
||||
for (i in 0L until Long.MAX_VALUE step Long.MAX_VALUE) {
|
||||
longList += i
|
||||
}
|
||||
assertEquals(listOf(0L), longList)
|
||||
|
||||
val charList = mutableListOf<Char>()
|
||||
for (i in 0.toChar() until Char.MAX_VALUE step Char.MAX_VALUE.toInt()) {
|
||||
charList += i
|
||||
}
|
||||
assertEquals(listOf(0.toChar()), charList)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
Reference in New Issue
Block a user