tests: Add tests for empty ranges in 'for' loops

This commit is contained in:
Ilya Matveev
2017-07-13 12:29:48 +07:00
committed by ilmat192
parent d474f207e3
commit a97a310987
2 changed files with 21 additions and 0 deletions
+5
View File
@@ -330,6 +330,11 @@ task codegen_basics_for_loops_errors(type: RunKonanTest) {
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) {
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")
}