aboutsummaryrefslogtreecommitdiff
path: root/src/test/run-pass/linear-for-loop.rs
diff options
context:
space:
mode:
authorGraydon Hoare <[email protected]>2010-06-23 21:03:09 -0700
committerGraydon Hoare <[email protected]>2010-06-23 21:03:09 -0700
commitd6b7c96c3eb29b9244ece0c046d3f372ff432d04 (patch)
treeb425187e232966063ffc2f0d14c04a55d8f004ef /src/test/run-pass/linear-for-loop.rs
parentInitial git commit. (diff)
downloadrust-d6b7c96c3eb29b9244ece0c046d3f372ff432d04.tar.xz
rust-d6b7c96c3eb29b9244ece0c046d3f372ff432d04.zip
Populate tree.
Diffstat (limited to 'src/test/run-pass/linear-for-loop.rs')
-rw-r--r--src/test/run-pass/linear-for-loop.rs38
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);
+}