tests: Add tests for empty ranges in 'for' loops
This commit is contained in:
@@ -330,6 +330,11 @@ task codegen_basics_for_loops_errors(type: RunKonanTest) {
|
|||||||
goldValue = "OK\n"
|
goldValue = "OK\n"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
task codegen_basics_for_loops_empty_range(type: RunKonanTest) {
|
||||||
|
source = "codegen/basics/for_loops_empty_range.kt"
|
||||||
|
goldValue = "OK\n"
|
||||||
|
}
|
||||||
|
|
||||||
task local_variable(type: RunKonanTest) {
|
task local_variable(type: RunKonanTest) {
|
||||||
source = "codegen/basics/local_variable.kt"
|
source = "codegen/basics/local_variable.kt"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
fun main(args: Array<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) }
|
||||||
|
// 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) }
|
||||||
|
// 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) }
|
||||||
|
|
||||||
|
println("OK")
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user