diff options
Diffstat (limited to 'src/test/run-pass/linear-for-loop.rs')
| -rw-r--r-- | src/test/run-pass/linear-for-loop.rs | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/test/run-pass/linear-for-loop.rs b/src/test/run-pass/linear-for-loop.rs new file mode 100644 index 00000000..4312aea8 --- /dev/null +++ b/src/test/run-pass/linear-for-loop.rs @@ -0,0 +1,38 @@ +fn main() { + auto x = vec(1,2,3); + auto y = 0; + for (int i in x) { + log i; + y += i; + } + log y; + check (y == 6); + + auto s = "hello there"; + let int i = 0; + for (u8 c in s) { + if (i == 0) { + check (c == u8('h')); + } + if (i == 1) { + check (c == u8('e')); + } + if (i == 2) { + check (c == u8('l')); + } + if (i == 3) { + check (c == u8('l')); + } + if (i == 4) { + check (c == u8('o')); + } + // ... + if (i == 12) { + check (c == u8(0)); + } + i += 1; + log i; + log c; + } + check(i == 12); +} |