[Tests] Migrate backend-independent tests from native to compiler/testData.

^KT-65979
This commit is contained in:
Vladimir Sukharev
2024-02-25 18:25:58 +01:00
committed by Space Team
parent dd9332d9e1
commit febac0dd5f
640 changed files with 68168 additions and 6313 deletions
@@ -1,78 +0,0 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the LICENSE file.
*/
import kotlin.test.*
val sb = StringBuilder()
fun foo() {
var i = 0
l1@while (true) {
sb.appendLine("foo@l1")
try {
l2@while (true) {
if ((i++ % 2) == 0) continue@l2
sb.appendLine("foo@l2")
if (i > 4) break@l1
}
} finally {
}
}
}
fun bar() {
var i = 0
l1@do {
try {
sb.appendLine("bar@l1")
throw Exception()
} catch (e: Exception) {
l2@do {
if ((i++ % 2) == 0) continue@l2
sb.appendLine("bar@l2")
if (i > 4) break@l1
} while (true)
}
} while (true)
}
fun qux() {
l1@for (i in 1..6) {
t1@try {
sb.appendLine("qux@t1")
throw Exception()
}
finally {
l2@ for (j in 1..6) {
if ((j % 2) == 0) continue@l2
sb.appendLine("qux@l2")
if (j > 4) break@l1
}
}
}
}
fun box(): String {
foo()
bar()
qux()
assertEquals("""
foo@l1
foo@l2
foo@l2
foo@l2
bar@l1
bar@l2
bar@l2
bar@l2
qux@t1
qux@l2
qux@l2
qux@l2
""".trimIndent(), sb.toString())
return "OK"
}
@@ -1,19 +0,0 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the LICENSE file.
*/
import kotlin.test.*
val sb = StringBuilder()
fun box(): String {
loop@ while (true) {
sb.appendLine("Body")
break
}
sb.appendLine("Done")
assertEquals("Body\nDone\n", sb.toString())
return "OK"
}
@@ -1,104 +0,0 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the LICENSE file.
*/
import kotlin.test.*
val sb = StringBuilder()
fun box(): String {
// Simple loops
for (i in 0..4) {
sb.append(i)
}
sb.appendLine()
for (i in 0 until 4) {
sb.append(i)
}
sb.appendLine()
for (i in 4 downTo 0) {
sb.append(i)
}
sb.appendLine()
sb.appendLine()
// Steps
for (i in 0..4 step 2) {
sb.append(i)
}
sb.appendLine()
for (i in 0 until 4 step 2) {
sb.append(i)
}
sb.appendLine()
for (i in 4 downTo 0 step 2) {
sb.append(i)
}
sb.appendLine()
sb.appendLine()
// Two steps
for (i in 0..6 step 2 step 3) {
sb.append(i)
}
sb.appendLine()
for (i in 0 until 6 step 2 step 3) {
sb.append(i)
}
sb.appendLine()
for (i in 6 downTo 0 step 2 step 3) {
sb.append(i)
}
sb.appendLine()
sb.appendLine()
// Without constants
val a = 0
val b = 4
val s = 2
for (i in a..b step s) {
sb.append(i)
}
sb.appendLine()
for (i in a until b step s) {
sb.append(i)
}
sb.appendLine()
for (i in b downTo a step s) {
sb.append(i)
}
sb.appendLine()
sb.appendLine()
assertEquals("""
01234
0123
43210
024
02
420
036
03
630
024
02
420
""".trimIndent(), sb.toString())
return "OK"
}
@@ -1,24 +0,0 @@
import kotlin.test.*
val sb = StringBuilder()
fun box(): String {
val intArray = intArrayOf(4, 0, 3, 5)
val emptyArray = arrayOf<Any>()
for (element in intArray) {
sb.append(element)
if (element == 3) {
break
}
}
sb.appendLine()
for (element in emptyArray) {
sb.append(element)
}
sb.appendLine()
assertEquals("403\n\n", sb.toString())
return "OK"
}
@@ -1,21 +0,0 @@
import kotlin.test.*
val sb = StringBuilder()
fun box(): String {
val intArray = intArrayOf(4, 0, 3, 5)
val emptyArray = arrayOf<Any>()
for (index in intArray.indices) {
sb.append(index)
}
sb.appendLine()
for (index in emptyArray.indices) {
sb.append(index)
}
sb.appendLine()
assertEquals("0123\n\n", sb.toString())
return "OK"
}
@@ -1,16 +0,0 @@
import kotlin.test.*
val sb = StringBuilder()
fun box(): String {
val intArray = arrayOf(4, 0, 3, 5)
for (element in intArray) {
intArray[2] = 0
intArray[3] = 0
sb.append(element)
}
assertEquals("4000", sb.toString())
return "OK"
}
@@ -1,34 +0,0 @@
import kotlin.test.*
val sb = StringBuilder()
fun box(): String {
val metaArray = arrayOf(
arrayOf(1, 2, 3),
arrayOf("Hello"),
arrayOf<Any>(),
arrayOf(1..10)
)
for (array in metaArray) {
inner@for (elem in array) {
if (elem is IntProgression) {
for (i in elem) {
sb.append(i)
}
continue@inner
} else {
sb.append(elem)
}
}
sb.appendLine()
}
assertEquals("""
123
Hello
12345678910
""".trimIndent(), sb.toString())
return "OK"
}
@@ -1,19 +0,0 @@
import kotlin.test.*
val sb = StringBuilder()
private fun nullableArray(a: Array<Int>): Array<Int>? {
return a
}
fun box(): String {
val array = arrayOf(1, 2, 3)
nullableArray(array)?.let {
for (elem in it) {
sb.append(elem)
}
}
assertEquals("123", sb.toString())
return "OK"
}
@@ -1,33 +0,0 @@
import kotlin.test.*
val sb = StringBuilder()
private fun <T> sideEffect(array: T): T {
sb.appendLine("side-effect")
return array
}
fun box(): String {
val intArray = intArrayOf(4, 0, 3, 5)
val emptyArray = arrayOf<Any>()
for (element in sideEffect(intArray)) {
sb.append(element.toString())
}
sb.appendLine()
for (element in sideEffect(emptyArray)) {
sb.append(element.toString())
}
sb.appendLine()
assertEquals("""
side-effect
4035
side-effect
""".trimIndent(), sb.toString())
return "OK"
}
@@ -1,27 +0,0 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the LICENSE file.
*/
import kotlin.test.*
val sb = StringBuilder()
fun f1(): Int { sb.append(1); return 0 }
fun f2(): Int { sb.append(2); return 6 }
fun f3(): Int { sb.append(3); return 2 }
fun f4(): Int { sb.append(4); return 3 }
fun box(): String {
for (i in f1()..f2() step f3() step f4()) { }; sb.appendLine()
for (i in f1() until f2() step f3() step f4()) {}; sb.appendLine()
for (i in f2() downTo f1() step f3() step f4()) {}; sb.appendLine()
assertEquals("""
1234
1234
2134
""".trimIndent(), sb.toString())
return "OK"
}
@@ -1,31 +0,0 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the LICENSE file.
*/
import kotlin.test.*
import kotlin.coroutines.*
val sb = StringBuilder()
fun box(): String {
val sq = sequence {
for (i in 0..6 step 2) {
sb.append("before: $i ")
yield(i)
sb.appendLine("after: $i")
}
}
sb.appendLine("Got: ${sq.joinToString(separator = " ")}")
assertEquals("""
before: 0 after: 0
before: 2 after: 2
before: 4 after: 4
before: 6 after: 6
Got: 0 2 4 6
""".trimIndent(), sb.toString())
return "OK"
}
@@ -1,23 +0,0 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the LICENSE file.
*/
import kotlin.test.*
fun box(): String {
// Simple loops
for (i in 4..0) { return "FAIL 11 $i" }
for (i in 4 until 0) { return "FAIL 12 $i" }
for (i in 0 downTo 4) { return "FAIL 13 $i" }
// Steps
for (i in 4..0 step 2) { return "FAIL 21 $i" }
for (i in 4 until 0 step 2) { return "FAIL 22 $i" }
for (i in 0 downTo 4 step 2) { return "FAIL 23 $i" }
// Two steps
for (i in 6..0 step 2 step 3) { return "FAIL 31 $i" }
for (i in 6 until 0 step 2 step 3) { return "FAIL 32 $i" }
for (i in 0 downTo 6 step 2 step 3) { return "FAIL 33 $i" }
return "OK"
}
@@ -1,58 +0,0 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the LICENSE file.
*/
import kotlin.test.*
fun box(): String {
// Negative step.
try {
for (i in 0 .. 4 step -2) return "FAIL 1 $i"
throw AssertionError()
} catch (e: IllegalArgumentException) {}
try {
for (i in 0 until 4 step -2) return "FAIL 2 $i"
throw AssertionError()
} catch (e: IllegalArgumentException) {}
try {
for (i in 4 downTo 0 step -2) return "FAIL 3 $i"
throw AssertionError()
} catch (e: IllegalArgumentException) {}
// Zero step.
try {
for (i in 0 .. 4 step 0) return "FAIL 4 $i"
throw AssertionError()
} catch (e: IllegalArgumentException) {}
try {
for (i in 0 until 4 step 0) return "FAIL 5 $i"
throw AssertionError()
} catch (e: IllegalArgumentException) {}
try {
for (i in 4 downTo 0 step 0) return "FAIL 6 $i"
throw AssertionError()
} catch (e: IllegalArgumentException) {}
// Two steps, one is negative.
try {
for (i in 0 .. 4 step -2 step 3) return "FAIL 7 $i"
throw AssertionError()
} catch (e: IllegalArgumentException) {}
try {
for (i in 0 until 4 step -2 step 3) return "FAIL 8 $i"
throw AssertionError()
} catch (e: IllegalArgumentException) {}
try {
for (i in 4 downTo 0 step -2 step 3) return "FAIL 9 $i"
throw AssertionError()
} catch (e: IllegalArgumentException) {}
return "OK"
}
@@ -1,188 +0,0 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the LICENSE file.
*/
import kotlin.test.*
val sb = StringBuilder()
// Github issue #1012
fun testInt(left: Int?, right: Int?, step: Int?) {
right?.let {
for (i in 0..it) { sb.append(i) }
}
sb.appendLine()
left?.let {
for (i in it..5) { sb.append(i) }
}
sb.appendLine()
step?.let {
for (i in 0..5 step it) { sb.append(i) }
}
sb.appendLine()
right?.let {
for (i in 0 until it) { sb.append(i) }
}
sb.appendLine()
left?.let {
for (i in it until 5) { sb.append(i) }
}
sb.appendLine()
step?.let {
for (i in 0 until 5 step it) { sb.append(i) }
}
sb.appendLine()
right?.let {
for (i in it downTo 0) { sb.append(i) }
}
sb.appendLine()
left?.let {
for (i in 5 downTo it) { sb.append(i) }
}
sb.appendLine()
step?.let {
for (i in 5 downTo 0 step it) { sb.append(i) }
}
sb.appendLine()
}
fun testLong(left: Long?, right: Long?, step: Long?) {
right?.let {
for (i in 0..it) { sb.append(i) }
}
sb.appendLine()
left?.let {
for (i in it..5) { sb.append(i) }
}
sb.appendLine()
step?.let {
for (i in 0..5L step it) { sb.append(i) }
}
sb.appendLine()
right?.let {
for (i in 0 until it) { sb.append(i) }
}
sb.appendLine()
left?.let {
for (i in it until 5) { sb.append(i) }
}
sb.appendLine()
step?.let {
for (i in 0 until 5L step it) { sb.append(i) }
}
sb.appendLine()
right?.let {
for (i in it downTo 0) { sb.append(i) }
}
sb.appendLine()
left?.let {
for (i in 5 downTo it) { sb.append(i) }
}
sb.appendLine()
step?.let {
for (i in 5 downTo 0L step it) { sb.append(i) }
}
sb.appendLine()
}
fun testChar(left: Char?, right: Char?, step: Int?) {
right?.let {
for (i in 'a'..it) { sb.append(i) }
}
sb.appendLine()
left?.let {
for (i in it..'f') { sb.append(i) }
}
sb.appendLine()
step?.let {
for (i in 'a'..'f' step it) { sb.append(i) }
}
sb.appendLine()
right?.let {
for (i in 'a' until it) { sb.append(i) }
}
sb.appendLine()
left?.let {
for (i in it until 'f') { sb.append(i) }
}
sb.appendLine()
step?.let {
for (i in 'a' until 'f' step it) { sb.append(i) }
}
sb.appendLine()
right?.let {
for (i in it downTo 'a') { sb.append(i) }
}
sb.appendLine()
left?.let {
for (i in 'f' downTo it) { sb.append(i) }
}
sb.appendLine()
step?.let {
for (i in 'f' downTo 'a' step it) { sb.append(i) }
}
sb.appendLine()
}
fun box(): String {
testInt(0, 5, 2)
testLong(0, 5, 2)
testChar('a', 'f', 2)
assertEquals("""
012345
012345
024
01234
01234
024
543210
543210
531
012345
012345
024
01234
01234
024
543210
543210
531
abcdef
abcdef
ace
abcde
abcde
ace
fedcba
fedcba
fdb
""".trimIndent(), sb.toString())
return "OK"
}
@@ -1,80 +0,0 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the LICENSE file.
*/
import kotlin.test.*
val sb = StringBuilder()
fun box(): String {
// Simple
for (i in 0..2) {
for (j in 0..2) {
sb.append("$i$j ")
}
}
sb.appendLine()
// Break
l1@for (i in 0..2) {
l2@for (j in 0..2) {
sb.append("$i$j ")
if (j == 1) break
}
}
sb.appendLine()
l1@for (i in 0..2) {
l2@for (j in 0..2) {
sb.append("$i$j ")
if (j == 1) break@l2
}
}
sb.appendLine()
l1@for (i in 0..2) {
l2@for (j in 0..2) {
sb.append("$i$j ")
if (j == 1) break@l1
}
}
sb.appendLine()
// Continue
l1@for (i in 0..2) {
l2@for (j in 0..2) {
if (j == 1) continue
sb.append("$i$j ")
}
}
sb.appendLine()
l1@for (i in 0..2) {
l2@for (j in 0..2) {
if (j == 1) continue@l2
sb.append("$i$j ")
}
}
sb.appendLine()
l1@for (i in 0..2) {
l2@for (j in 0..2) {
if (j == 1) continue@l1
sb.append("$i$j ")
}
}
sb.appendLine()
assertEquals("""
00 01 02 10 11 12 20 21 22
00 01 10 11 20 21
00 01 10 11 20 21
00 01
00 02 10 12 20 22
00 02 10 12 20 22
00 10 20
""".trimIndent(), sb.toString())
return "OK"
}
@@ -1,40 +0,0 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the LICENSE file.
*/
import kotlin.test.*
val sb = StringBuilder()
fun box(): String {
for (i in Int.MAX_VALUE - 1 .. Int.MAX_VALUE) { sb.append(i); sb.append(' ') }; sb.appendLine()
for (i in Int.MAX_VALUE - 1 until Int.MAX_VALUE) { sb.append(i); sb.append(' ') }; sb.appendLine()
for (i in Int.MIN_VALUE + 1 downTo Int.MIN_VALUE) { sb.append(i); sb.append(' ') }; sb.appendLine()
// Empty loops
for (i in Byte.MIN_VALUE until Byte.MIN_VALUE) { sb.append(i); sb.append(' ') }
for (i in Short.MIN_VALUE until Short.MIN_VALUE) { sb.append(i); sb.append(' ') }
for (i in Int.MIN_VALUE until Int.MIN_VALUE) { sb.append(i); sb.append(' ') }
for (i in Long.MIN_VALUE until Long.MIN_VALUE) { sb.append(i); sb.append(' ') }
for (i in 0.toChar() until 0.toChar()) { sb.append(i); sb.append(' ') }
for (i in 0 until Byte.MIN_VALUE) { sb.append(i); sb.append(' ') }
for (i in 0 until Short.MIN_VALUE) { sb.append(i); sb.append(' ') }
for (i in 0 until Int.MIN_VALUE) { sb.append(i); sb.append(' ') }
for (i in 0 until Long.MIN_VALUE) { sb.append(i); sb.append(' ') }
for (i in 'a' until 0.toChar()) { sb.append(i); sb.append(' ') }
val M = Int.MAX_VALUE / 2
for (i in M + 4..M + 10 step M) { sb.append(i); sb.append(' ') }; sb.appendLine()
assertEquals("""
2147483646 2147483647
2147483646
-2147483647 -2147483648
1073741827
""".trimIndent(), sb.toString())
return "OK"
}
@@ -1,221 +0,0 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the LICENSE file.
*/
import kotlin.test.*
val sb = StringBuilder()
fun box(): String {
for (i in 0.toByte() .. 4.toByte()) sb.append(i); sb.appendLine()
for (i in 0.toByte() .. 4.toShort()) sb.append(i); sb.appendLine()
for (i in 0.toByte() .. 4.toInt()) sb.append(i); sb.appendLine()
for (i in 0.toByte() .. 4.toLong()) sb.append(i); sb.appendLine()
for (i in 0.toShort() .. 4.toByte()) sb.append(i); sb.appendLine()
for (i in 0.toShort() .. 4.toShort()) sb.append(i); sb.appendLine()
for (i in 0.toShort() .. 4.toInt()) sb.append(i); sb.appendLine()
for (i in 0.toShort() .. 4.toLong()) sb.append(i); sb.appendLine()
for (i in 0.toInt() .. 4.toByte()) sb.append(i); sb.appendLine()
for (i in 0.toInt() .. 4.toShort()) sb.append(i); sb.appendLine()
for (i in 0.toInt() .. 4.toInt()) sb.append(i); sb.appendLine()
for (i in 0.toInt() .. 4.toLong()) sb.append(i); sb.appendLine()
for (i in 0.toLong() .. 4.toByte()) sb.append(i); sb.appendLine()
for (i in 0.toLong() .. 4.toShort()) sb.append(i); sb.appendLine()
for (i in 0.toLong() .. 4.toInt()) sb.append(i); sb.appendLine()
for (i in 0.toLong() .. 4.toLong()) sb.append(i); sb.appendLine()
for (i in 0.toByte() until 4.toByte()) sb.append(i); sb.appendLine()
for (i in 0.toByte() until 4.toShort()) sb.append(i); sb.appendLine()
for (i in 0.toByte() until 4.toInt()) sb.append(i); sb.appendLine()
for (i in 0.toByte() until 4.toLong()) sb.append(i); sb.appendLine()
for (i in 0.toShort() until 4.toByte()) sb.append(i); sb.appendLine()
for (i in 0.toShort() until 4.toShort()) sb.append(i); sb.appendLine()
for (i in 0.toShort() until 4.toInt()) sb.append(i); sb.appendLine()
for (i in 0.toShort() until 4.toLong()) sb.append(i); sb.appendLine()
for (i in 0.toInt() until 4.toByte()) sb.append(i); sb.appendLine()
for (i in 0.toInt() until 4.toShort()) sb.append(i); sb.appendLine()
for (i in 0.toInt() until 4.toInt()) sb.append(i); sb.appendLine()
for (i in 0.toInt() until 4.toLong()) sb.append(i); sb.appendLine()
for (i in 0.toLong() until 4.toByte()) sb.append(i); sb.appendLine()
for (i in 0.toLong() until 4.toShort()) sb.append(i); sb.appendLine()
for (i in 0.toLong() until 4.toInt()) sb.append(i); sb.appendLine()
for (i in 0.toLong() until 4.toLong()) sb.append(i); sb.appendLine()
for (i in 4.toByte() downTo 0.toByte()) sb.append(i); sb.appendLine()
for (i in 4.toByte() downTo 0.toShort()) sb.append(i); sb.appendLine()
for (i in 4.toByte() downTo 0.toInt()) sb.append(i); sb.appendLine()
for (i in 4.toByte() downTo 0.toLong()) sb.append(i); sb.appendLine()
for (i in 4.toShort() downTo 0.toByte()) sb.append(i); sb.appendLine()
for (i in 4.toShort() downTo 0.toShort()) sb.append(i); sb.appendLine()
for (i in 4.toShort() downTo 0.toInt()) sb.append(i); sb.appendLine()
for (i in 4.toShort() downTo 0.toLong()) sb.append(i); sb.appendLine()
for (i in 4.toInt() downTo 0.toByte()) sb.append(i); sb.appendLine()
for (i in 4.toInt() downTo 0.toShort()) sb.append(i); sb.appendLine()
for (i in 4.toInt() downTo 0.toInt()) sb.append(i); sb.appendLine()
for (i in 4.toInt() downTo 0.toLong()) sb.append(i); sb.appendLine()
for (i in 4.toLong() downTo 0.toByte()) sb.append(i); sb.appendLine()
for (i in 4.toLong() downTo 0.toShort()) sb.append(i); sb.appendLine()
for (i in 4.toLong() downTo 0.toInt()) sb.append(i); sb.appendLine()
for (i in 4.toLong() downTo 0.toLong()) sb.append(i); sb.appendLine()
for (i in 'a' .. 'd') sb.append(i); sb.appendLine()
for (i in 'a' until 'd') sb.append(i); sb.appendLine()
for (i in 'd' downTo 'a') sb.append(i); sb.appendLine()
for (i in 0.toByte() .. 4.toByte() step 2) sb.append(i); sb.appendLine()
for (i in 0.toByte() .. 4.toShort() step 2) sb.append(i); sb.appendLine()
for (i in 0.toByte() .. 4.toInt() step 2) sb.append(i); sb.appendLine()
for (i in 0.toByte() .. 4.toLong() step 2L) sb.append(i); sb.appendLine()
for (i in 0.toShort() .. 4.toByte() step 2) sb.append(i); sb.appendLine()
for (i in 0.toShort() .. 4.toShort() step 2) sb.append(i); sb.appendLine()
for (i in 0.toShort() .. 4.toInt() step 2) sb.append(i); sb.appendLine()
for (i in 0.toShort() .. 4.toLong() step 2L) sb.append(i); sb.appendLine()
for (i in 0.toInt() .. 4.toByte() step 2) sb.append(i); sb.appendLine()
for (i in 0.toInt() .. 4.toShort() step 2) sb.append(i); sb.appendLine()
for (i in 0.toInt() .. 4.toInt() step 2) sb.append(i); sb.appendLine()
for (i in 0.toInt() .. 4.toLong() step 2L) sb.append(i); sb.appendLine()
for (i in 0.toLong() .. 4.toByte() step 2L) sb.append(i); sb.appendLine()
for (i in 0.toLong() .. 4.toShort() step 2L) sb.append(i); sb.appendLine()
for (i in 0.toLong() .. 4.toInt() step 2L) sb.append(i); sb.appendLine()
for (i in 0.toLong() .. 4.toLong() step 2L) sb.append(i); sb.appendLine()
for (i in 0.toByte() until 4.toByte() step 2) sb.append(i); sb.appendLine()
for (i in 0.toByte() until 4.toShort() step 2) sb.append(i); sb.appendLine()
for (i in 0.toByte() until 4.toInt() step 2) sb.append(i); sb.appendLine()
for (i in 0.toByte() until 4.toLong() step 2L) sb.append(i); sb.appendLine()
for (i in 0.toShort() until 4.toByte() step 2) sb.append(i); sb.appendLine()
for (i in 0.toShort() until 4.toShort() step 2) sb.append(i); sb.appendLine()
for (i in 0.toShort() until 4.toInt() step 2) sb.append(i); sb.appendLine()
for (i in 0.toShort() until 4.toLong() step 2L) sb.append(i); sb.appendLine()
for (i in 0.toInt() until 4.toByte() step 2) sb.append(i); sb.appendLine()
for (i in 0.toInt() until 4.toShort() step 2) sb.append(i); sb.appendLine()
for (i in 0.toInt() until 4.toInt() step 2) sb.append(i); sb.appendLine()
for (i in 0.toInt() until 4.toLong() step 2L) sb.append(i); sb.appendLine()
for (i in 0.toLong() until 4.toByte() step 2L) sb.append(i); sb.appendLine()
for (i in 0.toLong() until 4.toShort() step 2L) sb.append(i); sb.appendLine()
for (i in 0.toLong() until 4.toInt() step 2L) sb.append(i); sb.appendLine()
for (i in 0.toLong() until 4.toLong() step 2L) sb.append(i); sb.appendLine()
for (i in 4.toByte() downTo 0.toByte() step 2) sb.append(i); sb.appendLine()
for (i in 4.toByte() downTo 0.toShort() step 2) sb.append(i); sb.appendLine()
for (i in 4.toByte() downTo 0.toInt() step 2) sb.append(i); sb.appendLine()
for (i in 4.toByte() downTo 0.toLong() step 2L) sb.append(i); sb.appendLine()
for (i in 4.toShort() downTo 0.toByte() step 2) sb.append(i); sb.appendLine()
for (i in 4.toShort() downTo 0.toShort() step 2) sb.append(i); sb.appendLine()
for (i in 4.toShort() downTo 0.toInt() step 2) sb.append(i); sb.appendLine()
for (i in 4.toShort() downTo 0.toLong() step 2L) sb.append(i); sb.appendLine()
for (i in 4.toInt() downTo 0.toByte() step 2) sb.append(i); sb.appendLine()
for (i in 4.toInt() downTo 0.toShort() step 2) sb.append(i); sb.appendLine()
for (i in 4.toInt() downTo 0.toInt() step 2) sb.append(i); sb.appendLine()
for (i in 4.toInt() downTo 0.toLong() step 2L) sb.append(i); sb.appendLine()
for (i in 4.toLong() downTo 0.toByte() step 2L) sb.append(i); sb.appendLine()
for (i in 4.toLong() downTo 0.toShort() step 2L) sb.append(i); sb.appendLine()
for (i in 4.toLong() downTo 0.toInt() step 2L) sb.append(i); sb.appendLine()
for (i in 4.toLong() downTo 0.toLong() step 2L) sb.append(i); sb.appendLine()
for (i in 'a' .. 'd' step 2) sb.append(i); sb.appendLine()
for (i in 'a' until 'd' step 2) sb.append(i); sb.appendLine()
for (i in 'd' downTo 'a' step 2) sb.append(i); sb.appendLine()
assertEquals("""
01234
01234
01234
01234
01234
01234
01234
01234
01234
01234
01234
01234
01234
01234
01234
01234
0123
0123
0123
0123
0123
0123
0123
0123
0123
0123
0123
0123
0123
0123
0123
0123
43210
43210
43210
43210
43210
43210
43210
43210
43210
43210
43210
43210
43210
43210
43210
43210
abcd
abc
dcba
024
024
024
024
024
024
024
024
024
024
024
024
024
024
024
024
02
02
02
02
02
02
02
02
02
02
02
02
02
02
02
02
420
420
420
420
420
420
420
420
420
420
420
420
420
420
420
420
ac
ac
db
""".trimIndent(), sb.toString())
return "OK"
}
@@ -1,20 +0,0 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the LICENSE file.
*/
import kotlin.test.*
val sb = StringBuilder()
fun box(): String {
sb.append(foo())
assertEquals("1", sb.toString())
return "OK"
}
fun foo(): Int {
return 1
sb.appendLine("After return")
}