diff options
| author | Jason Orendorff <[email protected]> | 2010-07-16 12:24:28 +0800 |
|---|---|---|
| committer | Graydon Hoare <[email protected]> | 2010-07-16 14:53:49 +0800 |
| commit | 7671828d45ea3b0d2f3814fc59bb01cba3d481d5 (patch) | |
| tree | fa4f7c58465350e4aea9e35f8b0f7db8c751a597 /src/test/run-pass/foreach-nested.rs | |
| parent | Update AUTHORS.txt. (diff) | |
| download | rust-7671828d45ea3b0d2f3814fc59bb01cba3d481d5.tar.xz rust-7671828d45ea3b0d2f3814fc59bb01cba3d481d5.zip | |
Support nested for-each loops. Closes #79.
Diffstat (limited to 'src/test/run-pass/foreach-nested.rs')
| -rw-r--r-- | src/test/run-pass/foreach-nested.rs | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/test/run-pass/foreach-nested.rs b/src/test/run-pass/foreach-nested.rs new file mode 100644 index 00000000..848adb26 --- /dev/null +++ b/src/test/run-pass/foreach-nested.rs @@ -0,0 +1,23 @@ +// -*- rust -*- + +iter two() -> int { + put 0; + put 1; +} + +fn main() { + let vec[int] a = vec(-1, -1, -1, -1); + let int p = 0; + + for each (int i in two()) { + for each (int j in two()) { + a.(p) = 10 * i + j; + p += 1; + } + } + + check (a.(0) == 0); + check (a.(1) == 1); + check (a.(2) == 10); + check (a.(3) == 11); +} |