[K/N][Tests] Adjust moved codegen tests to new infra

^KT-61259
This commit is contained in:
Vladimir Sukharev
2023-12-12 17:06:31 +01:00
committed by Space Team
parent a5f3d5b737
commit e15068c62f
301 changed files with 2958 additions and 2382 deletions
+26 -9
View File
@@ -3,18 +3,18 @@
* that can be found in the LICENSE file.
*/
package codegen.controlflow.`break`
import kotlin.test.*
val sb = StringBuilder()
fun foo() {
var i = 0
l1@while (true) {
println("foo@l1")
sb.appendLine("foo@l1")
try {
l2@while (true) {
if ((i++ % 2) == 0) continue@l2
println("foo@l2")
sb.appendLine("foo@l2")
if (i > 4) break@l1
}
} finally {
@@ -26,12 +26,12 @@ fun bar() {
var i = 0
l1@do {
try {
println("bar@l1")
sb.appendLine("bar@l1")
throw Exception()
} catch (e: Exception) {
l2@do {
if ((i++ % 2) == 0) continue@l2
println("bar@l2")
sb.appendLine("bar@l2")
if (i > 4) break@l1
} while (true)
}
@@ -41,21 +41,38 @@ fun bar() {
fun qux() {
l1@for (i in 1..6) {
t1@try {
println("qux@t1")
sb.appendLine("qux@t1")
throw Exception()
}
finally {
l2@ for (j in 1..6) {
if ((j % 2) == 0) continue@l2
println("qux@l2")
sb.appendLine("qux@l2")
if (j > 4) break@l1
}
}
}
}
@Test fun runTest() {
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,12 +0,0 @@
foo@l1
foo@l2
foo@l2
foo@l2
bar@l1
bar@l2
bar@l2
bar@l2
qux@t1
qux@l2
qux@l2
qux@l2
+8 -5
View File
@@ -3,14 +3,17 @@
* that can be found in the LICENSE file.
*/
package codegen.controlflow.break1
import kotlin.test.*
@Test fun runTest() {
val sb = StringBuilder()
fun box(): String {
loop@ while (true) {
println("Body")
sb.appendLine("Body")
break
}
println("Done")
sb.appendLine("Done")
assertEquals("Body\nDone\n", sb.toString())
return "OK"
}
@@ -1,2 +0,0 @@
Body
Done
+52 -31
View File
@@ -3,81 +3,102 @@
* that can be found in the LICENSE file.
*/
package codegen.controlflow.for_loops
import kotlin.test.*
@Test fun runTest() {
val sb = StringBuilder()
fun box(): String {
// Simple loops
for (i in 0..4) {
print(i)
sb.append(i)
}
println()
sb.appendLine()
for (i in 0 until 4) {
print(i)
sb.append(i)
}
println()
sb.appendLine()
for (i in 4 downTo 0) {
print(i)
sb.append(i)
}
println()
println()
sb.appendLine()
sb.appendLine()
// Steps
for (i in 0..4 step 2) {
print(i)
sb.append(i)
}
println()
sb.appendLine()
for (i in 0 until 4 step 2) {
print(i)
sb.append(i)
}
println()
sb.appendLine()
for (i in 4 downTo 0 step 2) {
print(i)
sb.append(i)
}
println()
println()
sb.appendLine()
sb.appendLine()
// Two steps
for (i in 0..6 step 2 step 3) {
print(i)
sb.append(i)
}
println()
sb.appendLine()
for (i in 0 until 6 step 2 step 3) {
print(i)
sb.append(i)
}
println()
sb.appendLine()
for (i in 6 downTo 0 step 2 step 3) {
print(i)
sb.append(i)
}
println()
println()
sb.appendLine()
sb.appendLine()
// Without constants
val a = 0
val b = 4
val s = 2
for (i in a..b step s) {
print(i)
sb.append(i)
}
println()
sb.appendLine()
for (i in a until b step s) {
print(i)
sb.append(i)
}
println()
sb.appendLine()
for (i in b downTo a step s) {
print(i)
sb.append(i)
}
println()
println()
sb.appendLine()
sb.appendLine()
assertEquals("""
01234
0123
43210
024
02
420
036
03
630
024
02
420
""".trimIndent(), sb.toString())
return "OK"
}
@@ -1,16 +0,0 @@
01234
0123
43210
024
02
420
036
03
630
024
02
420
@@ -1,7 +1,7 @@
package codegen.controlflow.for_loops_array
import kotlin.test.*
val sb = StringBuilder()
fun <T : ByteArray> genericArray(data : T): Int {
var sum = 0
for (element in data) {
@@ -18,23 +18,28 @@ fun IntArray.sum(): Int {
return sum
}
@Test fun runTest() {
fun box(): String {
val intArray = intArrayOf(4, 0, 3, 5)
val emptyArray = arrayOf<Any>()
for (element in intArray) {
print(element)
sb.append(element)
}
println()
sb.appendLine()
for (element in emptyArray) {
print(element)
sb.append(element)
}
println()
sb.appendLine()
val byteArray = byteArrayOf(1, -1)
println(genericArray(byteArray))
sb.append(genericArray(byteArray))
sb.appendLine()
val fives = intArrayOf(5, 5, 5, -5, -5, -5)
println(fives.sum())
sb.append(fives.sum())
sb.appendLine()
assertEquals("4035\n\n0\n0\n", sb.toString())
return "OK"
}
@@ -1,4 +0,0 @@
4035
0
0
@@ -1,21 +1,24 @@
package codegen.controlflow.for_loops_array_break_continue
import kotlin.test.*
@Test fun runTest() {
val sb = StringBuilder()
fun box(): String {
val intArray = intArrayOf(4, 0, 3, 5)
val emptyArray = arrayOf<Any>()
for (element in intArray) {
print(element)
sb.append(element)
if (element == 3) {
break
}
}
println()
sb.appendLine()
for (element in emptyArray) {
print(element)
sb.append(element)
}
println()
sb.appendLine()
assertEquals("403\n\n", sb.toString())
return "OK"
}
@@ -1,2 +0,0 @@
403
@@ -1,18 +1,21 @@
package codegen.controlflow.for_loops_array_indices
import kotlin.test.*
@Test fun runTest() {
val sb = StringBuilder()
fun box(): String {
val intArray = intArrayOf(4, 0, 3, 5)
val emptyArray = arrayOf<Any>()
for (index in intArray.indices) {
print(index)
sb.append(index)
}
println()
sb.appendLine()
for (index in emptyArray.indices) {
print(index)
sb.append(index)
}
println()
sb.appendLine()
assertEquals("0123\n\n", sb.toString())
return "OK"
}
@@ -1,2 +0,0 @@
0123
@@ -1,13 +1,16 @@
package codegen.controlflow.for_loops_array_mutation
import kotlin.test.*
@Test fun runTest() {
val sb = StringBuilder()
fun box(): String {
val intArray = arrayOf(4, 0, 3, 5)
for (element in intArray) {
intArray[2] = 0
intArray[3] = 0
print(element)
sb.append(element)
}
assertEquals("4000", sb.toString())
return "OK"
}
@@ -1 +0,0 @@
4000
@@ -1,8 +1,8 @@
package codegen.controlflow.for_loops_array_nested
import kotlin.test.*
@Test fun arrayOfArrays() {
val sb = StringBuilder()
fun box(): String {
val metaArray = arrayOf(
arrayOf(1, 2, 3),
arrayOf("Hello"),
@@ -13,13 +13,22 @@ import kotlin.test.*
inner@for (elem in array) {
if (elem is IntProgression) {
for (i in elem) {
print(i)
sb.append(i)
}
continue@inner
} else {
print(elem)
sb.append(elem)
}
}
println()
sb.appendLine()
}
assertEquals("""
123
Hello
12345678910
""".trimIndent(), sb.toString())
return "OK"
}
@@ -1,4 +0,0 @@
123
Hello
12345678910
@@ -1,16 +1,19 @@
package codegen.controlflow.for_loops_array_nullable
import kotlin.test.*
val sb = StringBuilder()
private fun nullableArray(a: Array<Int>): Array<Int>? {
return a
}
@Test fun nullable() {
fun box(): String {
val array = arrayOf(1, 2, 3)
nullableArray(array)?.let {
for (elem in it) {
print(elem)
sb.append(elem)
}
}
assertEquals("123", sb.toString())
return "OK"
}
@@ -1 +0,0 @@
123
@@ -1,23 +1,33 @@
package codegen.controlflow.for_loops_array_side_effects
import kotlin.test.*
val sb = StringBuilder()
private fun <T> sideEffect(array: T): T {
println("side-effect")
sb.appendLine("side-effect")
return array
}
@Test fun runTest() {
fun box(): String {
val intArray = intArrayOf(4, 0, 3, 5)
val emptyArray = arrayOf<Any>()
for (element in sideEffect(intArray)) {
print(element)
sb.append(element.toString())
}
println()
sb.appendLine()
for (element in sideEffect(emptyArray)) {
print(element)
sb.append(element.toString())
}
println()
sb.appendLine()
assertEquals("""
side-effect
4035
side-effect
""".trimIndent(), sb.toString())
return "OK"
}
@@ -1,4 +0,0 @@
side-effect
4035
side-effect
@@ -3,17 +3,25 @@
* that can be found in the LICENSE file.
*/
package codegen.controlflow.for_loops_call_order
import kotlin.test.*
fun f1(): Int { print("1"); return 0 }
fun f2(): Int { print("2"); return 6 }
fun f3(): Int { print("3"); return 2 }
fun f4(): Int { print("4"); return 3 }
val sb = StringBuilder()
@Test fun runTest() {
for (i in f1()..f2() step f3() step f4()) { }; println()
for (i in f1() until f2() step f3() step f4()) {}; println()
for (i in f2() downTo f1() step f3() step f4()) {}; println()
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,3 +0,0 @@
1234
1234
2134
@@ -3,19 +3,29 @@
* that can be found in the LICENSE file.
*/
package codegen.controlflow.for_loops_coroutines
import kotlin.test.*
import kotlin.coroutines.*
@Test fun runTest() {
val sb = StringBuilder()
fun box(): String {
val sq = sequence {
for (i in 0..6 step 2) {
print("before: $i ")
sb.append("before: $i ")
yield(i)
println("after: $i")
sb.appendLine("after: $i")
}
}
println("Got: ${sq.joinToString(separator = " ")}")
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,5 +0,0 @@
before: 0 after: 0
before: 2 after: 2
before: 4 after: 4
before: 6 after: 6
Got: 0 2 4 6
@@ -3,23 +3,21 @@
* that can be found in the LICENSE file.
*/
package codegen.controlflow.for_loops_empty_range
import kotlin.test.*
@Test fun runTest() {
fun box(): String {
// Simple loops
for (i in 4..0) { print(i) }
for (i in 4 until 0) { print(i) }
for (i in 0 downTo 4) { print(i) }
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) { print(i) }
for (i in 4 until 0 step 2) { print(i) }
for (i in 0 downTo 4 step 2) { print(i) }
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) { print(i) }
for (i in 6 until 0 step 2 step 3) { print(i) }
for (i in 0 downTo 6 step 2 step 3) { print(i) }
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" }
println("OK")
return "OK"
}
@@ -1 +0,0 @@
OK
@@ -3,58 +3,56 @@
* that can be found in the LICENSE file.
*/
package codegen.controlflow.for_loops_errors
import kotlin.test.*
@Test fun runTest() {
fun box(): String {
// Negative step.
try {
for (i in 0 .. 4 step -2) print(i); println()
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) print(i); println()
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) print(i); println()
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) print(i); println()
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) print(i); println()
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) print(i); println()
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) print(i); println()
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) print(i); println()
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) print(i); println()
for (i in 4 downTo 0 step -2 step 3) return "FAIL 9 $i"
throw AssertionError()
} catch (e: IllegalArgumentException) {}
println("OK")
return "OK"
}
@@ -1 +0,0 @@
OK
@@ -3,154 +3,186 @@
* that can be found in the LICENSE file.
*/
package codegen.controlflow.for_loops_let_with_nullable
import kotlin.test.*
val sb = StringBuilder()
// Github issue #1012
fun testInt(left: Int?, right: Int?, step: Int?) {
right?.let {
for (i in 0..it) { print(i) }
for (i in 0..it) { sb.append(i) }
}
println()
sb.appendLine()
left?.let {
for (i in it..5) { print(i) }
for (i in it..5) { sb.append(i) }
}
println()
sb.appendLine()
step?.let {
for (i in 0..5 step it) { print(i) }
for (i in 0..5 step it) { sb.append(i) }
}
println()
sb.appendLine()
right?.let {
for (i in 0 until it) { print(i) }
for (i in 0 until it) { sb.append(i) }
}
println()
sb.appendLine()
left?.let {
for (i in it until 5) { print(i) }
for (i in it until 5) { sb.append(i) }
}
println()
sb.appendLine()
step?.let {
for (i in 0 until 5 step it) { print(i) }
for (i in 0 until 5 step it) { sb.append(i) }
}
println()
sb.appendLine()
right?.let {
for (i in it downTo 0) { print(i) }
for (i in it downTo 0) { sb.append(i) }
}
println()
sb.appendLine()
left?.let {
for (i in 5 downTo it) { print(i) }
for (i in 5 downTo it) { sb.append(i) }
}
println()
sb.appendLine()
step?.let {
for (i in 5 downTo 0 step it) { print(i) }
for (i in 5 downTo 0 step it) { sb.append(i) }
}
println()
sb.appendLine()
}
fun testLong(left: Long?, right: Long?, step: Long?) {
right?.let {
for (i in 0..it) { print(i) }
for (i in 0..it) { sb.append(i) }
}
println()
sb.appendLine()
left?.let {
for (i in it..5) { print(i) }
for (i in it..5) { sb.append(i) }
}
println()
sb.appendLine()
step?.let {
for (i in 0..5L step it) { print(i) }
for (i in 0..5L step it) { sb.append(i) }
}
println()
sb.appendLine()
right?.let {
for (i in 0 until it) { print(i) }
for (i in 0 until it) { sb.append(i) }
}
println()
sb.appendLine()
left?.let {
for (i in it until 5) { print(i) }
for (i in it until 5) { sb.append(i) }
}
println()
sb.appendLine()
step?.let {
for (i in 0 until 5L step it) { print(i) }
for (i in 0 until 5L step it) { sb.append(i) }
}
println()
sb.appendLine()
right?.let {
for (i in it downTo 0) { print(i) }
for (i in it downTo 0) { sb.append(i) }
}
println()
sb.appendLine()
left?.let {
for (i in 5 downTo it) { print(i) }
for (i in 5 downTo it) { sb.append(i) }
}
println()
sb.appendLine()
step?.let {
for (i in 5 downTo 0L step it) { print(i) }
for (i in 5 downTo 0L step it) { sb.append(i) }
}
println()
sb.appendLine()
}
fun testChar(left: Char?, right: Char?, step: Int?) {
right?.let {
for (i in 'a'..it) { print(i) }
for (i in 'a'..it) { sb.append(i) }
}
println()
sb.appendLine()
left?.let {
for (i in it..'f') { print(i) }
for (i in it..'f') { sb.append(i) }
}
println()
sb.appendLine()
step?.let {
for (i in 'a'..'f' step it) { print(i) }
for (i in 'a'..'f' step it) { sb.append(i) }
}
println()
sb.appendLine()
right?.let {
for (i in 'a' until it) { print(i) }
for (i in 'a' until it) { sb.append(i) }
}
println()
sb.appendLine()
left?.let {
for (i in it until 'f') { print(i) }
for (i in it until 'f') { sb.append(i) }
}
println()
sb.appendLine()
step?.let {
for (i in 'a' until 'f' step it) { print(i) }
for (i in 'a' until 'f' step it) { sb.append(i) }
}
println()
sb.appendLine()
right?.let {
for (i in it downTo 'a') { print(i) }
for (i in it downTo 'a') { sb.append(i) }
}
println()
sb.appendLine()
left?.let {
for (i in 'f' downTo it) { print(i) }
for (i in 'f' downTo it) { sb.append(i) }
}
println()
sb.appendLine()
step?.let {
for (i in 'f' downTo 'a' step it) { print(i) }
for (i in 'f' downTo 'a' step it) { sb.append(i) }
}
println()
sb.appendLine()
}
@Test fun runTest() {
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,27 +0,0 @@
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
@@ -3,66 +3,78 @@
* that can be found in the LICENSE file.
*/
package codegen.controlflow.for_loops_nested
import kotlin.test.*
@Test fun runTest() {
val sb = StringBuilder()
fun box(): String {
// Simple
for (i in 0..2) {
for (j in 0..2) {
print("$i$j ")
sb.append("$i$j ")
}
}
println()
sb.appendLine()
// Break
l1@for (i in 0..2) {
l2@for (j in 0..2) {
print("$i$j ")
sb.append("$i$j ")
if (j == 1) break
}
}
println()
sb.appendLine()
l1@for (i in 0..2) {
l2@for (j in 0..2) {
print("$i$j ")
sb.append("$i$j ")
if (j == 1) break@l2
}
}
println()
sb.appendLine()
l1@for (i in 0..2) {
l2@for (j in 0..2) {
print("$i$j ")
sb.append("$i$j ")
if (j == 1) break@l1
}
}
println()
sb.appendLine()
// Continue
l1@for (i in 0..2) {
l2@for (j in 0..2) {
if (j == 1) continue
print("$i$j ")
sb.append("$i$j ")
}
}
println()
sb.appendLine()
l1@for (i in 0..2) {
l2@for (j in 0..2) {
if (j == 1) continue@l2
print("$i$j ")
sb.append("$i$j ")
}
}
println()
sb.appendLine()
l1@for (i in 0..2) {
l2@for (j in 0..2) {
if (j == 1) continue@l1
print("$i$j ")
sb.append("$i$j ")
}
}
println()
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,7 +0,0 @@
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
@@ -3,29 +3,38 @@
* that can be found in the LICENSE file.
*/
package codegen.controlflow.for_loops_overflow
import kotlin.test.*
@Test fun runTest() {
for (i in Int.MAX_VALUE - 1 .. Int.MAX_VALUE) { print(i); print(' ') }; println()
for (i in Int.MAX_VALUE - 1 until Int.MAX_VALUE) { print(i); print(' ') }; println()
for (i in Int.MIN_VALUE + 1 downTo Int.MIN_VALUE) { print(i); print(' ') }; println()
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) { print(i); print(' ') }
for (i in Short.MIN_VALUE until Short.MIN_VALUE) { print(i); print(' ') }
for (i in Int.MIN_VALUE until Int.MIN_VALUE) { print(i); print(' ') }
for (i in Long.MIN_VALUE until Long.MIN_VALUE) { print(i); print(' ') }
for (i in 0.toChar() until 0.toChar()) { print(i); print(' ') }
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) { print(i); print(' ') }
for (i in 0 until Short.MIN_VALUE) { print(i); print(' ') }
for (i in 0 until Int.MIN_VALUE) { print(i); print(' ') }
for (i in 0 until Long.MIN_VALUE) { print(i); print(' ') }
for (i in 'a' until 0.toChar()) { print(i); print(' ') }
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) { print(i); print(' ') }; println()
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,4 +0,0 @@
2147483646 2147483647
2147483646
-2147483647 -2147483648
1073741827
@@ -3,112 +3,219 @@
* that can be found in the LICENSE file.
*/
package codegen.controlflow.for_loops_types
import kotlin.test.*
@Test fun runTest() {
for (i in 0.toByte() .. 4.toByte()) print(i); println()
for (i in 0.toByte() .. 4.toShort()) print(i); println()
for (i in 0.toByte() .. 4.toInt()) print(i); println()
for (i in 0.toByte() .. 4.toLong()) print(i); println()
for (i in 0.toShort() .. 4.toByte()) print(i); println()
for (i in 0.toShort() .. 4.toShort()) print(i); println()
for (i in 0.toShort() .. 4.toInt()) print(i); println()
for (i in 0.toShort() .. 4.toLong()) print(i); println()
for (i in 0.toInt() .. 4.toByte()) print(i); println()
for (i in 0.toInt() .. 4.toShort()) print(i); println()
for (i in 0.toInt() .. 4.toInt()) print(i); println()
for (i in 0.toInt() .. 4.toLong()) print(i); println()
for (i in 0.toLong() .. 4.toByte()) print(i); println()
for (i in 0.toLong() .. 4.toShort()) print(i); println()
for (i in 0.toLong() .. 4.toInt()) print(i); println()
for (i in 0.toLong() .. 4.toLong()) print(i); println()
for (i in 0.toByte() until 4.toByte()) print(i); println()
for (i in 0.toByte() until 4.toShort()) print(i); println()
for (i in 0.toByte() until 4.toInt()) print(i); println()
for (i in 0.toByte() until 4.toLong()) print(i); println()
for (i in 0.toShort() until 4.toByte()) print(i); println()
for (i in 0.toShort() until 4.toShort()) print(i); println()
for (i in 0.toShort() until 4.toInt()) print(i); println()
for (i in 0.toShort() until 4.toLong()) print(i); println()
for (i in 0.toInt() until 4.toByte()) print(i); println()
for (i in 0.toInt() until 4.toShort()) print(i); println()
for (i in 0.toInt() until 4.toInt()) print(i); println()
for (i in 0.toInt() until 4.toLong()) print(i); println()
for (i in 0.toLong() until 4.toByte()) print(i); println()
for (i in 0.toLong() until 4.toShort()) print(i); println()
for (i in 0.toLong() until 4.toInt()) print(i); println()
for (i in 0.toLong() until 4.toLong()) print(i); println()
for (i in 4.toByte() downTo 0.toByte()) print(i); println()
for (i in 4.toByte() downTo 0.toShort()) print(i); println()
for (i in 4.toByte() downTo 0.toInt()) print(i); println()
for (i in 4.toByte() downTo 0.toLong()) print(i); println()
for (i in 4.toShort() downTo 0.toByte()) print(i); println()
for (i in 4.toShort() downTo 0.toShort()) print(i); println()
for (i in 4.toShort() downTo 0.toInt()) print(i); println()
for (i in 4.toShort() downTo 0.toLong()) print(i); println()
for (i in 4.toInt() downTo 0.toByte()) print(i); println()
for (i in 4.toInt() downTo 0.toShort()) print(i); println()
for (i in 4.toInt() downTo 0.toInt()) print(i); println()
for (i in 4.toInt() downTo 0.toLong()) print(i); println()
for (i in 4.toLong() downTo 0.toByte()) print(i); println()
for (i in 4.toLong() downTo 0.toShort()) print(i); println()
for (i in 4.toLong() downTo 0.toInt()) print(i); println()
for (i in 4.toLong() downTo 0.toLong()) print(i); println()
for (i in 'a' .. 'd') print(i); println()
for (i in 'a' until 'd') print(i); println()
for (i in 'd' downTo 'a') print(i); println()
val sb = StringBuilder()
for (i in 0.toByte() .. 4.toByte() step 2) print(i); println()
for (i in 0.toByte() .. 4.toShort() step 2) print(i); println()
for (i in 0.toByte() .. 4.toInt() step 2) print(i); println()
for (i in 0.toByte() .. 4.toLong() step 2L) print(i); println()
for (i in 0.toShort() .. 4.toByte() step 2) print(i); println()
for (i in 0.toShort() .. 4.toShort() step 2) print(i); println()
for (i in 0.toShort() .. 4.toInt() step 2) print(i); println()
for (i in 0.toShort() .. 4.toLong() step 2L) print(i); println()
for (i in 0.toInt() .. 4.toByte() step 2) print(i); println()
for (i in 0.toInt() .. 4.toShort() step 2) print(i); println()
for (i in 0.toInt() .. 4.toInt() step 2) print(i); println()
for (i in 0.toInt() .. 4.toLong() step 2L) print(i); println()
for (i in 0.toLong() .. 4.toByte() step 2L) print(i); println()
for (i in 0.toLong() .. 4.toShort() step 2L) print(i); println()
for (i in 0.toLong() .. 4.toInt() step 2L) print(i); println()
for (i in 0.toLong() .. 4.toLong() step 2L) print(i); println()
for (i in 0.toByte() until 4.toByte() step 2) print(i); println()
for (i in 0.toByte() until 4.toShort() step 2) print(i); println()
for (i in 0.toByte() until 4.toInt() step 2) print(i); println()
for (i in 0.toByte() until 4.toLong() step 2L) print(i); println()
for (i in 0.toShort() until 4.toByte() step 2) print(i); println()
for (i in 0.toShort() until 4.toShort() step 2) print(i); println()
for (i in 0.toShort() until 4.toInt() step 2) print(i); println()
for (i in 0.toShort() until 4.toLong() step 2L) print(i); println()
for (i in 0.toInt() until 4.toByte() step 2) print(i); println()
for (i in 0.toInt() until 4.toShort() step 2) print(i); println()
for (i in 0.toInt() until 4.toInt() step 2) print(i); println()
for (i in 0.toInt() until 4.toLong() step 2L) print(i); println()
for (i in 0.toLong() until 4.toByte() step 2L) print(i); println()
for (i in 0.toLong() until 4.toShort() step 2L) print(i); println()
for (i in 0.toLong() until 4.toInt() step 2L) print(i); println()
for (i in 0.toLong() until 4.toLong() step 2L) print(i); println()
for (i in 4.toByte() downTo 0.toByte() step 2) print(i); println()
for (i in 4.toByte() downTo 0.toShort() step 2) print(i); println()
for (i in 4.toByte() downTo 0.toInt() step 2) print(i); println()
for (i in 4.toByte() downTo 0.toLong() step 2L) print(i); println()
for (i in 4.toShort() downTo 0.toByte() step 2) print(i); println()
for (i in 4.toShort() downTo 0.toShort() step 2) print(i); println()
for (i in 4.toShort() downTo 0.toInt() step 2) print(i); println()
for (i in 4.toShort() downTo 0.toLong() step 2L) print(i); println()
for (i in 4.toInt() downTo 0.toByte() step 2) print(i); println()
for (i in 4.toInt() downTo 0.toShort() step 2) print(i); println()
for (i in 4.toInt() downTo 0.toInt() step 2) print(i); println()
for (i in 4.toInt() downTo 0.toLong() step 2L) print(i); println()
for (i in 4.toLong() downTo 0.toByte() step 2L) print(i); println()
for (i in 4.toLong() downTo 0.toShort() step 2L) print(i); println()
for (i in 4.toLong() downTo 0.toInt() step 2L) print(i); println()
for (i in 4.toLong() downTo 0.toLong() step 2L) print(i); println()
for (i in 'a' .. 'd' step 2) print(i); println()
for (i in 'a' until 'd' step 2) print(i); println()
for (i in 'd' downTo 'a' step 2) print(i); println()
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,102 +0,0 @@
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
@@ -3,15 +3,18 @@
* that can be found in the LICENSE file.
*/
package codegen.controlflow.unreachable1
import kotlin.test.*
@Test fun runTest() {
println(foo())
val sb = StringBuilder()
fun box(): String {
sb.append(foo())
assertEquals("1", sb.toString())
return "OK"
}
fun foo(): Int {
return 1
println("After return")
sb.appendLine("After return")
}
@@ -1 +0,0 @@
1