diff options
| author | bors <bors@rust-lang.org> | 2015-04-22 03:38:20 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2015-04-22 03:38:20 +0000 |
| commit | c0eb9384af9f623563df59a9ae454ffedea1f4f8 (patch) | |
| tree | aaa36f5462dfe299902c6829795a8a8988f3061e /src/libcoretest | |
| parent | 2baf3482537f5a245a9c17ca730398f1a8b001d7 (diff) | |
| parent | 58150640254e939519e57bf643af841cc60c1ac3 (diff) | |
| download | rust-c0eb9384af9f623563df59a9ae454ffedea1f4f8.tar.gz rust-c0eb9384af9f623563df59a9ae454ffedea1f4f8.zip | |
Auto merge of #24674 - alexcrichton:rollup, r=alexcrichton
Diffstat (limited to 'src/libcoretest')
| -rw-r--r-- | src/libcoretest/cmp.rs | 2 | ||||
| -rw-r--r-- | src/libcoretest/iter.rs | 11 | ||||
| -rw-r--r-- | src/libcoretest/lib.rs | 6 | ||||
| -rw-r--r-- | src/libcoretest/num/int_macros.rs | 67 | ||||
| -rw-r--r-- | src/libcoretest/num/mod.rs | 31 | ||||
| -rw-r--r-- | src/libcoretest/num/uint_macros.rs | 27 |
6 files changed, 60 insertions, 84 deletions
diff --git a/src/libcoretest/cmp.rs b/src/libcoretest/cmp.rs index 9ed1508c3eb..e0d396c68b4 100644 --- a/src/libcoretest/cmp.rs +++ b/src/libcoretest/cmp.rs @@ -110,8 +110,6 @@ fn test_partial_max() { #[test] fn test_user_defined_eq() { - use core::num::SignedInt; - // Our type. struct SketchyNum { num : isize diff --git a/src/libcoretest/iter.rs b/src/libcoretest/iter.rs index a56820c61cc..2866c193c3b 100644 --- a/src/libcoretest/iter.rs +++ b/src/libcoretest/iter.rs @@ -11,7 +11,6 @@ use core::iter::*; use core::iter::order::*; use core::iter::MinMaxResult::*; -use core::num::SignedInt; use core::usize; use core::cmp; @@ -784,16 +783,6 @@ fn test_range_step() { } #[test] -fn test_range_step_inclusive() { - assert_eq!(range_step_inclusive(0, 20, 5).collect::<Vec<isize>>(), [0, 5, 10, 15, 20]); - assert_eq!(range_step_inclusive(20, 0, -5).collect::<Vec<isize>>(), [20, 15, 10, 5, 0]); - assert_eq!(range_step_inclusive(20, 0, -6).collect::<Vec<isize>>(), [20, 14, 8, 2]); - assert_eq!(range_step_inclusive(200, 255, 50).collect::<Vec<u8>>(), [200, 250]); - assert_eq!(range_step_inclusive(200, -5, 1).collect::<Vec<isize>>(), []); - assert_eq!(range_step_inclusive(200, 200, 1).collect::<Vec<isize>>(), [200]); -} - -#[test] fn test_reverse() { let mut ys = [1, 2, 3, 4, 5]; ys.iter_mut().reverse_in_place(); diff --git a/src/libcoretest/lib.rs b/src/libcoretest/lib.rs index 6059e49df19..e0e8e46af6c 100644 --- a/src/libcoretest/lib.rs +++ b/src/libcoretest/lib.rs @@ -10,8 +10,8 @@ // Do not remove on snapshot creation. Needed for bootstrap. (Issue #22364) #![cfg_attr(stage0, feature(custom_attribute))] + #![feature(box_syntax)] -#![feature(int_uint)] #![feature(unboxed_closures)] #![feature(unsafe_destructor)] #![feature(core)] @@ -21,13 +21,11 @@ #![feature(std_misc)] #![feature(libc)] #![feature(hash)] -#![feature(io)] -#![feature(collections)] #![feature(debug_builders)] #![feature(unique)] #![feature(step_by)] #![feature(slice_patterns)] -#![allow(deprecated)] // rand +#![feature(float_from_str_radix)] extern crate core; extern crate test; diff --git a/src/libcoretest/num/int_macros.rs b/src/libcoretest/num/int_macros.rs index cb2359873e9..b1c8aec3c35 100644 --- a/src/libcoretest/num/int_macros.rs +++ b/src/libcoretest/num/int_macros.rs @@ -8,12 +8,11 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -macro_rules! int_module { ($T:ty, $T_i:ident) => ( +macro_rules! int_module { ($T:ident, $T_i:ident) => ( #[cfg(test)] mod tests { use core::$T_i::*; use core::isize; - use core::num::{FromStrRadix, Int, SignedInt}; use core::ops::{Shl, Shr, Not, BitXor, BitAnd, BitOr}; use num; @@ -129,30 +128,30 @@ mod tests { #[test] fn test_le() { - assert_eq!(Int::from_le(A.to_le()), A); - assert_eq!(Int::from_le(B.to_le()), B); - assert_eq!(Int::from_le(C.to_le()), C); - assert_eq!(Int::from_le(_0), _0); - assert_eq!(Int::from_le(_1), _1); + assert_eq!($T::from_le(A.to_le()), A); + assert_eq!($T::from_le(B.to_le()), B); + assert_eq!($T::from_le(C.to_le()), C); + assert_eq!($T::from_le(_0), _0); + assert_eq!($T::from_le(_1), _1); assert_eq!(_0.to_le(), _0); assert_eq!(_1.to_le(), _1); } #[test] fn test_be() { - assert_eq!(Int::from_be(A.to_be()), A); - assert_eq!(Int::from_be(B.to_be()), B); - assert_eq!(Int::from_be(C.to_be()), C); - assert_eq!(Int::from_be(_0), _0); - assert_eq!(Int::from_be(_1), _1); + assert_eq!($T::from_be(A.to_be()), A); + assert_eq!($T::from_be(B.to_be()), B); + assert_eq!($T::from_be(C.to_be()), C); + assert_eq!($T::from_be(_0), _0); + assert_eq!($T::from_be(_1), _1); assert_eq!(_0.to_be(), _0); assert_eq!(_1.to_be(), _1); } #[test] fn test_signed_checked_div() { - assert!(10.checked_div(2) == Some(5)); - assert!(5.checked_div(0) == None); + assert!((10 as $T).checked_div(2) == Some(5)); + assert!((5 as $T).checked_div(0) == None); assert!(isize::MIN.checked_div(-1) == None); } @@ -180,26 +179,26 @@ mod tests { #[test] fn test_from_str_radix() { - assert_eq!(FromStrRadix::from_str_radix("123", 10), Ok(123 as $T)); - assert_eq!(FromStrRadix::from_str_radix("1001", 2), Ok(9 as $T)); - assert_eq!(FromStrRadix::from_str_radix("123", 8), Ok(83 as $T)); - assert_eq!(FromStrRadix::from_str_radix("123", 16), Ok(291 as i32)); - assert_eq!(FromStrRadix::from_str_radix("ffff", 16), Ok(65535 as i32)); - assert_eq!(FromStrRadix::from_str_radix("FFFF", 16), Ok(65535 as i32)); - assert_eq!(FromStrRadix::from_str_radix("z", 36), Ok(35 as $T)); - assert_eq!(FromStrRadix::from_str_radix("Z", 36), Ok(35 as $T)); - - assert_eq!(FromStrRadix::from_str_radix("-123", 10), Ok(-123 as $T)); - assert_eq!(FromStrRadix::from_str_radix("-1001", 2), Ok(-9 as $T)); - assert_eq!(FromStrRadix::from_str_radix("-123", 8), Ok(-83 as $T)); - assert_eq!(FromStrRadix::from_str_radix("-123", 16), Ok(-291 as i32)); - assert_eq!(FromStrRadix::from_str_radix("-ffff", 16), Ok(-65535 as i32)); - assert_eq!(FromStrRadix::from_str_radix("-FFFF", 16), Ok(-65535 as i32)); - assert_eq!(FromStrRadix::from_str_radix("-z", 36), Ok(-35 as $T)); - assert_eq!(FromStrRadix::from_str_radix("-Z", 36), Ok(-35 as $T)); - - assert_eq!(FromStrRadix::from_str_radix("Z", 35).ok(), None::<$T>); - assert_eq!(FromStrRadix::from_str_radix("-9", 2).ok(), None::<$T>); + assert_eq!($T::from_str_radix("123", 10), Ok(123 as $T)); + assert_eq!($T::from_str_radix("1001", 2), Ok(9 as $T)); + assert_eq!($T::from_str_radix("123", 8), Ok(83 as $T)); + assert_eq!(i32::from_str_radix("123", 16), Ok(291 as i32)); + assert_eq!(i32::from_str_radix("ffff", 16), Ok(65535 as i32)); + assert_eq!(i32::from_str_radix("FFFF", 16), Ok(65535 as i32)); + assert_eq!($T::from_str_radix("z", 36), Ok(35 as $T)); + assert_eq!($T::from_str_radix("Z", 36), Ok(35 as $T)); + + assert_eq!($T::from_str_radix("-123", 10), Ok(-123 as $T)); + assert_eq!($T::from_str_radix("-1001", 2), Ok(-9 as $T)); + assert_eq!($T::from_str_radix("-123", 8), Ok(-83 as $T)); + assert_eq!(i32::from_str_radix("-123", 16), Ok(-291 as i32)); + assert_eq!(i32::from_str_radix("-ffff", 16), Ok(-65535 as i32)); + assert_eq!(i32::from_str_radix("-FFFF", 16), Ok(-65535 as i32)); + assert_eq!($T::from_str_radix("-z", 36), Ok(-35 as $T)); + assert_eq!($T::from_str_radix("-Z", 36), Ok(-35 as $T)); + + assert_eq!($T::from_str_radix("Z", 35).ok(), None::<$T>); + assert_eq!($T::from_str_radix("-9", 2).ok(), None::<$T>); } #[test] diff --git a/src/libcoretest/num/mod.rs b/src/libcoretest/num/mod.rs index 9087b87f640..85ca547da85 100644 --- a/src/libcoretest/num/mod.rs +++ b/src/libcoretest/num/mod.rs @@ -10,7 +10,6 @@ use core::cmp::PartialEq; use core::fmt::Debug; -use core::num::{NumCast, cast}; use core::ops::{Add, Sub, Mul, Div, Rem}; use core::marker::Copy; @@ -32,18 +31,12 @@ mod u64; /// Helper function for testing numeric operations pub fn test_num<T>(ten: T, two: T) where - T: PartialEq + NumCast + T: PartialEq + Add<Output=T> + Sub<Output=T> + Mul<Output=T> + Div<Output=T> + Rem<Output=T> + Debug + Copy { - assert_eq!(ten.add(two), cast(12).unwrap()); - assert_eq!(ten.sub(two), cast(8).unwrap()); - assert_eq!(ten.mul(two), cast(20).unwrap()); - assert_eq!(ten.div(two), cast(5).unwrap()); - assert_eq!(ten.rem(two), cast(0).unwrap()); - assert_eq!(ten.add(two), ten + two); assert_eq!(ten.sub(two), ten - two); assert_eq!(ten.mul(two), ten * two); @@ -56,33 +49,33 @@ mod test { use core::option::Option; use core::option::Option::{Some, None}; use core::num::Float; - use core::num::from_str_radix; #[test] fn from_str_issue7588() { - let u : Option<u8> = from_str_radix("1000", 10).ok(); + let u : Option<u8> = u8::from_str_radix("1000", 10).ok(); assert_eq!(u, None); - let s : Option<i16> = from_str_radix("80000", 10).ok(); + let s : Option<i16> = i16::from_str_radix("80000", 10).ok(); assert_eq!(s, None); - let f : Option<f32> = from_str_radix("10000000000000000000000000000000000000000", 10).ok(); + let s = "10000000000000000000000000000000000000000"; + let f : Option<f32> = f32::from_str_radix(s, 10).ok(); assert_eq!(f, Some(Float::infinity())); - let fe : Option<f32> = from_str_radix("1e40", 10).ok(); + let fe : Option<f32> = f32::from_str_radix("1e40", 10).ok(); assert_eq!(fe, Some(Float::infinity())); } #[test] fn test_from_str_radix_float() { - let x1 : Option<f64> = from_str_radix("-123.456", 10).ok(); + let x1 : Option<f64> = f64::from_str_radix("-123.456", 10).ok(); assert_eq!(x1, Some(-123.456)); - let x2 : Option<f32> = from_str_radix("123.456", 10).ok(); + let x2 : Option<f32> = f32::from_str_radix("123.456", 10).ok(); assert_eq!(x2, Some(123.456)); - let x3 : Option<f32> = from_str_radix("-0.0", 10).ok(); + let x3 : Option<f32> = f32::from_str_radix("-0.0", 10).ok(); assert_eq!(x3, Some(-0.0)); - let x4 : Option<f32> = from_str_radix("0.0", 10).ok(); + let x4 : Option<f32> = f32::from_str_radix("0.0", 10).ok(); assert_eq!(x4, Some(0.0)); - let x4 : Option<f32> = from_str_radix("1.0", 10).ok(); + let x4 : Option<f32> = f32::from_str_radix("1.0", 10).ok(); assert_eq!(x4, Some(1.0)); - let x5 : Option<f32> = from_str_radix("-1.0", 10).ok(); + let x5 : Option<f32> = f32::from_str_radix("-1.0", 10).ok(); assert_eq!(x5, Some(-1.0)); } diff --git a/src/libcoretest/num/uint_macros.rs b/src/libcoretest/num/uint_macros.rs index 5e00692766d..1712345f9d9 100644 --- a/src/libcoretest/num/uint_macros.rs +++ b/src/libcoretest/num/uint_macros.rs @@ -8,11 +8,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -macro_rules! uint_module { ($T:ty, $T_i:ident) => ( +macro_rules! uint_module { ($T:ident, $T_i:ident) => ( #[cfg(test)] mod tests { use core::$T_i::*; - use core::num::Int; use num; use core::ops::{BitOr, BitAnd, BitXor, Shl, Shr, Not}; @@ -97,30 +96,30 @@ mod tests { #[test] fn test_le() { - assert_eq!(Int::from_le(A.to_le()), A); - assert_eq!(Int::from_le(B.to_le()), B); - assert_eq!(Int::from_le(C.to_le()), C); - assert_eq!(Int::from_le(_0), _0); - assert_eq!(Int::from_le(_1), _1); + assert_eq!($T::from_le(A.to_le()), A); + assert_eq!($T::from_le(B.to_le()), B); + assert_eq!($T::from_le(C.to_le()), C); + assert_eq!($T::from_le(_0), _0); + assert_eq!($T::from_le(_1), _1); assert_eq!(_0.to_le(), _0); assert_eq!(_1.to_le(), _1); } #[test] fn test_be() { - assert_eq!(Int::from_be(A.to_be()), A); - assert_eq!(Int::from_be(B.to_be()), B); - assert_eq!(Int::from_be(C.to_be()), C); - assert_eq!(Int::from_be(_0), _0); - assert_eq!(Int::from_be(_1), _1); + assert_eq!($T::from_be(A.to_be()), A); + assert_eq!($T::from_be(B.to_be()), B); + assert_eq!($T::from_be(C.to_be()), C); + assert_eq!($T::from_be(_0), _0); + assert_eq!($T::from_be(_1), _1); assert_eq!(_0.to_be(), _0); assert_eq!(_1.to_be(), _1); } #[test] fn test_unsigned_checked_div() { - assert!(10.checked_div(2) == Some(5)); - assert!(5.checked_div(0) == None); + assert!((10 as $T).checked_div(2) == Some(5)); + assert!((5 as $T).checked_div(0) == None); } } |
