Implemented loop iterators
This commit is contained in:
@ -1,23 +0,0 @@
|
||||
import mem
|
||||
|
||||
main() {
|
||||
a := mem.alloc(4)
|
||||
i := 0
|
||||
|
||||
a[i] = i * 2
|
||||
i += 1
|
||||
a[i] = i * 2
|
||||
i += 1
|
||||
a[i] = i * 2
|
||||
i += 1
|
||||
a[i] = i * 2
|
||||
|
||||
i = 0
|
||||
assert a[i] == i * 2
|
||||
i += 1
|
||||
assert a[i] == i * 2
|
||||
i += 1
|
||||
assert a[i] == i * 2
|
||||
i += 1
|
||||
assert a[i] == i * 2
|
||||
}
|
10
tests/programs/index-dynamic.q
Normal file
10
tests/programs/index-dynamic.q
Normal file
@ -0,0 +1,10 @@
|
||||
import mem
|
||||
|
||||
main() {
|
||||
a := mem.alloc(4)
|
||||
|
||||
loop i := 0..4 {
|
||||
a[i] = i * 2
|
||||
assert a[i] == i * 2
|
||||
}
|
||||
}
|
6
tests/programs/loop-limited.q
Normal file
6
tests/programs/loop-limited.q
Normal file
@ -0,0 +1,6 @@
|
||||
main() {
|
||||
loop i := 0..10 {
|
||||
assert i >= 0
|
||||
assert i < 10
|
||||
}
|
||||
}
|
@ -57,12 +57,13 @@ var programs = []struct {
|
||||
{"branch-save", "", "", 0},
|
||||
{"jump-near", "", "", 0},
|
||||
{"switch", "", "", 0},
|
||||
{"loop", "", "", 0},
|
||||
{"loop-infinite", "", "", 0},
|
||||
{"loop-lifetime", "", "", 0},
|
||||
{"loop-limited", "", "", 0},
|
||||
{"memory-free", "", "", 0},
|
||||
{"out-of-memory", "", "", 0},
|
||||
{"array-index-static", "", "", 0},
|
||||
{"array-index-dynamic", "", "", 0},
|
||||
{"index-static", "", "", 0},
|
||||
{"index-dynamic", "", "", 0},
|
||||
{"struct", "", "", 0},
|
||||
{"len", "", "", 0},
|
||||
}
|
||||
|
Reference in New Issue
Block a user