tests: Add test for nested 'for' loops
This commit is contained in:
@@ -337,6 +337,17 @@ task codegen_controlflow_for_loops_empty_range(type: RunKonanTest) {
|
|||||||
goldValue = "OK\n"
|
goldValue = "OK\n"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
task codegen_controlflow_for_loops_nested(type: RunKonanTest) {
|
||||||
|
source = "codegen/controlflow/for_loops_nested.kt"
|
||||||
|
goldValue = "00 01 02 10 11 12 20 21 22 \n" +
|
||||||
|
"00 01 10 11 20 21 \n" +
|
||||||
|
"00 01 10 11 20 21 \n" +
|
||||||
|
"00 01 \n" +
|
||||||
|
"00 02 10 12 20 22 \n" +
|
||||||
|
"00 02 10 12 20 22 \n" +
|
||||||
|
"00 10 20 \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,59 @@
|
|||||||
|
fun main(args: Array<String>) {
|
||||||
|
// Simple
|
||||||
|
for (i in 0..2) {
|
||||||
|
for (j in 0..2) {
|
||||||
|
print("$i$j ")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
println()
|
||||||
|
|
||||||
|
// Break
|
||||||
|
l1@for (i in 0..2) {
|
||||||
|
l2@for (j in 0..2) {
|
||||||
|
print("$i$j ")
|
||||||
|
if (j == 1) break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
println()
|
||||||
|
|
||||||
|
l1@for (i in 0..2) {
|
||||||
|
l2@for (j in 0..2) {
|
||||||
|
print("$i$j ")
|
||||||
|
if (j == 1) break@l2
|
||||||
|
}
|
||||||
|
}
|
||||||
|
println()
|
||||||
|
|
||||||
|
l1@for (i in 0..2) {
|
||||||
|
l2@for (j in 0..2) {
|
||||||
|
print("$i$j ")
|
||||||
|
if (j == 1) break@l1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
println()
|
||||||
|
|
||||||
|
// Continue
|
||||||
|
l1@for (i in 0..2) {
|
||||||
|
l2@for (j in 0..2) {
|
||||||
|
if (j == 1) continue
|
||||||
|
print("$i$j ")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
println()
|
||||||
|
|
||||||
|
l1@for (i in 0..2) {
|
||||||
|
l2@for (j in 0..2) {
|
||||||
|
if (j == 1) continue@l2
|
||||||
|
print("$i$j ")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
println()
|
||||||
|
|
||||||
|
l1@for (i in 0..2) {
|
||||||
|
l2@for (j in 0..2) {
|
||||||
|
if (j == 1) continue@l1
|
||||||
|
print("$i$j ")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
println()
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user