diff options
Diffstat (limited to 'src/libstd/num')
| -rw-r--r-- | src/libstd/num/int_macros.rs | 49 | ||||
| -rw-r--r-- | src/libstd/num/uint_macros.rs | 51 |
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 }; } } |
