diff options
| author | Brendan Zabarauskas <bjzaba@yahoo.com.au> | 2014-11-10 16:26:10 +1100 |
|---|---|---|
| committer | Brendan Zabarauskas <bjzaba@yahoo.com.au> | 2014-11-13 03:46:03 +1100 |
| commit | e965ba85ca689ad77f63b7f0af9d7e337dcb4825 (patch) | |
| tree | 0ecf2223970c18455595e523ca594fe6d3321129 /src/libcoretest | |
| parent | 891559e30d045606aa109f4991074f783a5e50f8 (diff) | |
| download | rust-e965ba85ca689ad77f63b7f0af9d7e337dcb4825.tar.gz rust-e965ba85ca689ad77f63b7f0af9d7e337dcb4825.zip | |
Remove lots of numeric traits from the preludes
Num, NumCast, Unsigned, Float, Primitive and Int have been removed.
Diffstat (limited to 'src/libcoretest')
| -rw-r--r-- | src/libcoretest/iter.rs | 46 | ||||
| -rw-r--r-- | src/libcoretest/num/int_macros.rs | 1 | ||||
| -rw-r--r-- | src/libcoretest/num/mod.rs | 12 | ||||
| -rw-r--r-- | src/libcoretest/num/uint_macros.rs | 1 |
4 files changed, 12 insertions, 48 deletions
diff --git a/src/libcoretest/iter.rs b/src/libcoretest/iter.rs index 7e7e11a3645..3bb8d735d9c 100644 --- a/src/libcoretest/iter.rs +++ b/src/libcoretest/iter.rs @@ -12,7 +12,6 @@ use core::iter::*; use core::iter::order::*; use core::uint; use core::cmp; -use core::num; use core::ops::Slice; use test::Bencher; @@ -689,50 +688,6 @@ fn test_double_ended_range() { #[test] fn test_range() { - /// A mock type to check Range when ToPrimitive returns None - struct Foo; - - impl ToPrimitive for Foo { - fn to_i64(&self) -> Option<i64> { None } - fn to_u64(&self) -> Option<u64> { None } - } - - impl Add<Foo, Foo> for Foo { - fn add(&self, _: &Foo) -> Foo { - Foo - } - } - - impl PartialEq for Foo { - fn eq(&self, _: &Foo) -> bool { - true - } - } - - impl PartialOrd for Foo { - fn partial_cmp(&self, _: &Foo) -> Option<Ordering> { - None - } - } - - impl Clone for Foo { - fn clone(&self) -> Foo { - Foo - } - } - - impl Mul<Foo, Foo> for Foo { - fn mul(&self, _: &Foo) -> Foo { - Foo - } - } - - impl num::One for Foo { - fn one() -> Foo { - Foo - } - } - assert!(range(0i, 5).collect::<Vec<int>>() == vec![0i, 1, 2, 3, 4]); assert!(range(-10i, -1).collect::<Vec<int>>() == vec![-10, -9, -8, -7, -6, -5, -4, -3, -2]); @@ -746,7 +701,6 @@ fn test_range() { // this test is only meaningful when sizeof uint < sizeof u64 assert_eq!(range(uint::MAX - 1, uint::MAX).size_hint(), (1, Some(1))); assert_eq!(range(-10i, -1).size_hint(), (9, Some(9))); - assert_eq!(range(Foo, Foo).size_hint(), (0, None)); } #[test] diff --git a/src/libcoretest/num/int_macros.rs b/src/libcoretest/num/int_macros.rs index 51af2e2916d..a1b096bf454 100644 --- a/src/libcoretest/num/int_macros.rs +++ b/src/libcoretest/num/int_macros.rs @@ -15,6 +15,7 @@ macro_rules! int_module (($T:ty, $T_i:ident) => ( mod tests { use core::$T_i::*; use core::int; + use core::num::Int; use num; #[test] diff --git a/src/libcoretest/num/mod.rs b/src/libcoretest/num/mod.rs index 51a44ef4d59..38502321c1d 100644 --- a/src/libcoretest/num/mod.rs +++ b/src/libcoretest/num/mod.rs @@ -8,7 +8,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use core::num::cast; +use core::cmp::PartialEq; +use core::fmt::Show; +use core::num::{NumCast, cast}; +use core::ops::{Add, Sub, Mul, Div, Rem}; mod int_macros; mod i8; @@ -24,7 +27,12 @@ mod u64; mod uint; /// Helper function for testing numeric operations -pub fn test_num<T: Int + ::std::fmt::Show>(ten: T, two: T) { +pub fn test_num<T>(ten: T, two: T) where + T: PartialEq + NumCast + + Add<T, T> + Sub<T, T> + + Mul<T, T> + Div<T, T> + + Rem<T, T> + Show +{ assert_eq!(ten.add(&two), cast(12i).unwrap()); assert_eq!(ten.sub(&two), cast(8i).unwrap()); assert_eq!(ten.mul(&two), cast(20i).unwrap()); diff --git a/src/libcoretest/num/uint_macros.rs b/src/libcoretest/num/uint_macros.rs index 1d3f1718d72..01a88119b64 100644 --- a/src/libcoretest/num/uint_macros.rs +++ b/src/libcoretest/num/uint_macros.rs @@ -14,6 +14,7 @@ macro_rules! uint_module (($T:ty, $T_i:ident) => ( #[cfg(test)] mod tests { use core::$T_i::*; + use core::num::Int; use num; #[test] |
