about summary refs log tree commit diff
path: root/src/libstd/num
diff options
context:
space:
mode:
authorDaniel Micay <danielmicay@gmail.com>2013-08-03 00:07:20 -0700
committerDaniel Micay <danielmicay@gmail.com>2013-08-03 00:07:20 -0700
commitdeddb009f0003734d3c73fa859826d57ec600270 (patch)
tree3646e0cc53c8b1203e8b16d6efc21e4b46c52be3 /src/libstd/num
parent2a7be1c9e4d5a50dab4f3f95c8f1d843a7d6f084 (diff)
parent87cf2864b1e427753f3153ee31aafcff19e253ca (diff)
downloadrust-deddb009f0003734d3c73fa859826d57ec600270.tar.gz
rust-deddb009f0003734d3c73fa859826d57ec600270.zip
Merge pull request #8244 from thestinger/for
make `for` parse as `foreach` does

r=huonw, bors is acting up and this has been run through the try bots
Diffstat (limited to 'src/libstd/num')
-rw-r--r--src/libstd/num/int_macros.rs49
-rw-r--r--src/libstd/num/uint_macros.rs51
2 files changed, 57 insertions, 43 deletions
diff --git a/src/libstd/num/int_macros.rs b/src/libstd/num/int_macros.rs
index 9aa79090425..9842a570d7e 100644
--- a/src/libstd/num/int_macros.rs
+++ b/src/libstd/num/int_macros.rs
@@ -889,27 +889,34 @@ mod tests {
     fn test_ranges() {
         let mut l = ~[];
 
-        for range_rev(14,11) |i| {
+        do range_rev(14,11) |i| {
             l.push(i);
-        }
-        for range_step(20,26,2) |i| {
+            true
+        };
+        do range_step(20,26,2) |i| {
             l.push(i);
-        }
-        for range_step(36,30,-2) |i| {
+            true
+        };
+        do range_step(36,30,-2) |i| {
             l.push(i);
-        }
-        for range_step(max_value - 2, max_value, 2) |i| {
+            true
+        };
+        do range_step(max_value - 2, max_value, 2) |i| {
             l.push(i);
-        }
-        for range_step(max_value - 3, max_value, 2) |i| {
+            true
+        };
+        do range_step(max_value - 3, max_value, 2) |i| {
             l.push(i);
-        }
-        for range_step(min_value + 2, min_value, -2) |i| {
+            true
+        };
+        do range_step(min_value + 2, min_value, -2) |i| {
             l.push(i);
-        }
-        for range_step(min_value + 3, min_value, -2) |i| {
+            true
+        };
+        do range_step(min_value + 3, min_value, -2) |i| {
             l.push(i);
-        }
+            true
+        };
         assert_eq!(l, ~[13,12,11,
                         20,22,24,
                         36,34,32,
@@ -919,22 +926,22 @@ mod tests {
                         min_value+3,min_value+1]);
 
         // None of the `fail`s should execute.
-        for range_rev(0,10) |_i| {
+        do range_rev(0,10) |_i| {
             fail!(~"unreachable");
-        }
-        for range_step(10,0,1) |_i| {
+        };
+        do range_step(10,0,1) |_i| {
             fail!(~"unreachable");
-        }
-        for range_step(0,10,-1) |_i| {
+        };
+        do range_step(0,10,-1) |_i| {
             fail!(~"unreachable");
-        }
+        };
     }
 
     #[test]
     #[should_fail]
     #[ignore(cfg(windows))]
     fn test_range_step_zero_step() {
-        for range_step(0,10,0) |_i| {}
+        do range_step(0,10,0) |_i| { true };
     }
 }
 
diff --git a/src/libstd/num/uint_macros.rs b/src/libstd/num/uint_macros.rs
index aa01b871b9d..a2874c96703 100644
--- a/src/libstd/num/uint_macros.rs
+++ b/src/libstd/num/uint_macros.rs
@@ -654,27 +654,34 @@ mod tests {
     pub fn test_ranges() {
         let mut l = ~[];
 
-        for range_rev(14,11) |i| {
+        do range_rev(14,11) |i| {
             l.push(i);
-        }
-        for range_step(20,26,2) |i| {
+            true
+        };
+        do range_step(20,26,2) |i| {
             l.push(i);
-        }
-        for range_step(36,30,-2) |i| {
+            true
+        };
+        do range_step(36,30,-2) |i| {
             l.push(i);
-        }
-        for range_step(max_value - 2, max_value, 2) |i| {
+            true
+        };
+        do range_step(max_value - 2, max_value, 2) |i| {
             l.push(i);
-        }
-        for range_step(max_value - 3, max_value, 2) |i| {
+            true
+        };
+        do range_step(max_value - 3, max_value, 2) |i| {
             l.push(i);
-        }
-        for range_step(min_value + 2, min_value, -2) |i| {
+            true
+        };
+        do range_step(min_value + 2, min_value, -2) |i| {
             l.push(i);
-        }
-        for range_step(min_value + 3, min_value, -2) |i| {
+            true
+        };
+        do range_step(min_value + 3, min_value, -2) |i| {
             l.push(i);
-        }
+            true
+        };
 
         assert_eq!(l, ~[13,12,11,
                         20,22,24,
@@ -685,28 +692,28 @@ mod tests {
                         min_value+3,min_value+1]);
 
         // None of the `fail`s should execute.
-        for range_rev(0,0) |_i| {
+        do range_rev(0,0) |_i| {
             fail!("unreachable");
-        }
-        for range_step(10,0,1) |_i| {
+        };
+        do range_step(10,0,1) |_i| {
             fail!("unreachable");
-        }
-        for range_step(0,1,-10) |_i| {
+        };
+        do range_step(0,1,-10) |_i| {
             fail!("unreachable");
-        }
+        };
     }
 
     #[test]
     #[should_fail]
     #[ignore(cfg(windows))]
     fn test_range_step_zero_step_up() {
-        for range_step(0,10,0) |_i| {}
+        do range_step(0,10,0) |_i| { true };
     }
     #[test]
     #[should_fail]
     #[ignore(cfg(windows))]
     fn test_range_step_zero_step_down() {
-        for range_step(0,-10,0) |_i| {}
+        do range_step(0,-10,0) |_i| { true };
     }
 }