Implemented for loops
This commit is contained in:
@ -3,7 +3,7 @@ import mem
|
||||
main() {
|
||||
a := mem.alloc(4)
|
||||
|
||||
loop i := 0..4 {
|
||||
for i := 0..4 {
|
||||
a[i] = i * 2
|
||||
assert a[i] == i * 2
|
||||
}
|
||||
|
14
tests/programs/loop-for.q
Normal file
14
tests/programs/loop-for.q
Normal file
@ -0,0 +1,14 @@
|
||||
main() {
|
||||
x := 0
|
||||
|
||||
for 0..5 {
|
||||
x += 1
|
||||
}
|
||||
|
||||
assert x == 5
|
||||
|
||||
for i := 0..5 {
|
||||
assert i >= 0
|
||||
assert i < 5
|
||||
}
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
main() {
|
||||
loop i := 0..10 {
|
||||
assert i >= 0
|
||||
assert i < 10
|
||||
}
|
||||
}
|
@ -59,7 +59,7 @@ var programs = []struct {
|
||||
{"switch", "", "", 0},
|
||||
{"loop-infinite", "", "", 0},
|
||||
{"loop-lifetime", "", "", 0},
|
||||
{"loop-limited", "", "", 0},
|
||||
{"loop-for", "", "", 0},
|
||||
{"memory-free", "", "", 0},
|
||||
{"out-of-memory", "", "", 0},
|
||||
{"index-static", "", "", 0},
|
||||
|
Reference in New Issue
Block a user