aboutsummaryrefslogtreecommitdiff
path: root/src/test/run-pass/foreach-nested.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/run-pass/foreach-nested.rs')
-rw-r--r--src/test/run-pass/foreach-nested.rs23
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);
+}