From bffbcb5729a2b4cb2ab924e5f0d9ddebe470eebc Mon Sep 17 00:00:00 2001 From: Alfie John Date: Tue, 3 Feb 2015 13:50:52 +0000 Subject: [PATCH] Deprecating i/u suffixes in libcoretest --- src/libcoretest/any.rs | 22 ++++---- src/libcoretest/cell.rs | 24 ++++---- src/libcoretest/char.rs | 24 ++++---- src/libcoretest/iter.rs | 90 +++++++++++++++--------------- src/libcoretest/mem.rs | 38 ++++++------- src/libcoretest/num/uint_macros.rs | 8 +-- src/libcoretest/ops.rs | 14 ++--- src/libcoretest/ptr.rs | 2 +- src/libcoretest/tuple.rs | 2 +- 9 files changed, 112 insertions(+), 112 deletions(-) diff --git a/src/libcoretest/any.rs b/src/libcoretest/any.rs index 5ad3833a5ef..2156a99c332 100644 --- a/src/libcoretest/any.rs +++ b/src/libcoretest/any.rs @@ -18,11 +18,11 @@ static TEST: &'static str = "Test"; #[test] fn any_referenced() { - let (a, b, c) = (&5u as &Any, &TEST as &Any, &Test as &Any); + let (a, b, c) = (&5 as &Any, &TEST as &Any, &Test as &Any); - assert!(a.is::()); - assert!(!b.is::()); - assert!(!c.is::()); + assert!(a.is::()); + assert!(!b.is::()); + assert!(!c.is::()); assert!(!a.is::<&'static str>()); assert!(b.is::<&'static str>()); @@ -35,7 +35,7 @@ fn any_referenced() { #[test] fn any_owning() { - let (a, b, c) = (box 5u as Box, box TEST as Box, box Test as Box); + let (a, b, c) = (box 5us as Box, box TEST as Box, box Test as Box); assert!(a.is::()); assert!(!b.is::()); @@ -52,7 +52,7 @@ fn any_owning() { #[test] fn any_downcast_ref() { - let a = &5u as &Any; + let a = &5us as &Any; match a.downcast_ref::() { Some(&5) => {} @@ -67,8 +67,8 @@ fn any_downcast_ref() { #[test] fn any_downcast_mut() { - let mut a = 5u; - let mut b = box 7u; + let mut a = 5us; + let mut b = box 7us; let a_r = &mut a as &mut Any; let tmp: &mut uint = &mut *b; @@ -76,7 +76,7 @@ fn any_downcast_mut() { match a_r.downcast_mut::() { Some(x) => { - assert_eq!(*x, 5u); + assert_eq!(*x, 5); *x = 612; } x => panic!("Unexpected value {:?}", x) @@ -84,7 +84,7 @@ fn any_downcast_mut() { match b_r.downcast_mut::() { Some(x) => { - assert_eq!(*x, 7u); + assert_eq!(*x, 7); *x = 413; } x => panic!("Unexpected value {:?}", x) @@ -113,7 +113,7 @@ fn any_downcast_mut() { #[test] fn any_fixed_vec() { - let test = [0u; 8]; + let test = [0us; 8]; let test = &test as &Any; assert!(test.is::<[uint; 8]>()); assert!(!test.is::<[uint; 10]>()); diff --git a/src/libcoretest/cell.rs b/src/libcoretest/cell.rs index 8939bd61fe4..317ef3a5701 100644 --- a/src/libcoretest/cell.rs +++ b/src/libcoretest/cell.rs @@ -134,21 +134,21 @@ fn clone_ref_updates_flag() { #[test] fn as_unsafe_cell() { - let c1: Cell = Cell::new(0u); - c1.set(1u); - assert_eq!(1u, unsafe { *c1.as_unsafe_cell().get() }); + let c1: Cell = Cell::new(0); + c1.set(1); + assert_eq!(1, unsafe { *c1.as_unsafe_cell().get() }); - let c2: Cell = Cell::new(0u); - unsafe { *c2.as_unsafe_cell().get() = 1u; } - assert_eq!(1u, c2.get()); + let c2: Cell = Cell::new(0); + unsafe { *c2.as_unsafe_cell().get() = 1; } + assert_eq!(1, c2.get()); - let r1: RefCell = RefCell::new(0u); - *r1.borrow_mut() = 1u; - assert_eq!(1u, unsafe { *r1.as_unsafe_cell().get() }); + let r1: RefCell = RefCell::new(0); + *r1.borrow_mut() = 1; + assert_eq!(1, unsafe { *r1.as_unsafe_cell().get() }); - let r2: RefCell = RefCell::new(0u); - unsafe { *r2.as_unsafe_cell().get() = 1u; } - assert_eq!(1u, *r2.borrow()); + let r2: RefCell = RefCell::new(0); + unsafe { *r2.as_unsafe_cell().get() = 1; } + assert_eq!(1, *r2.borrow()); } #[test] diff --git a/src/libcoretest/char.rs b/src/libcoretest/char.rs index 9ba9c2c4a9c..32dc6440b13 100644 --- a/src/libcoretest/char.rs +++ b/src/libcoretest/char.rs @@ -41,18 +41,18 @@ fn test_is_whitespace() { #[test] fn test_to_digit() { - assert_eq!('0'.to_digit(10u), Some(0u)); - assert_eq!('1'.to_digit(2u), Some(1u)); - assert_eq!('2'.to_digit(3u), Some(2u)); - assert_eq!('9'.to_digit(10u), Some(9u)); - assert_eq!('a'.to_digit(16u), Some(10u)); - assert_eq!('A'.to_digit(16u), Some(10u)); - assert_eq!('b'.to_digit(16u), Some(11u)); - assert_eq!('B'.to_digit(16u), Some(11u)); - assert_eq!('z'.to_digit(36u), Some(35u)); - assert_eq!('Z'.to_digit(36u), Some(35u)); - assert_eq!(' '.to_digit(10u), None); - assert_eq!('$'.to_digit(36u), None); + assert_eq!('0'.to_digit(10), Some(0)); + assert_eq!('1'.to_digit(2), Some(1)); + assert_eq!('2'.to_digit(3), Some(2)); + assert_eq!('9'.to_digit(10), Some(9)); + assert_eq!('a'.to_digit(16), Some(10)); + assert_eq!('A'.to_digit(16), Some(10)); + assert_eq!('b'.to_digit(16), Some(11)); + assert_eq!('B'.to_digit(16), Some(11)); + assert_eq!('z'.to_digit(36), Some(35)); + assert_eq!('Z'.to_digit(36), Some(35)); + assert_eq!(' '.to_digit(10), None); + assert_eq!('$'.to_digit(36), None); } #[test] diff --git a/src/libcoretest/iter.rs b/src/libcoretest/iter.rs index 3f8e330b332..7eb0fb97bed 100644 --- a/src/libcoretest/iter.rs +++ b/src/libcoretest/iter.rs @@ -79,8 +79,8 @@ fn test_counter_from_iter() { #[test] fn test_iterator_chain() { - let xs = [0u, 1, 2, 3, 4, 5]; - let ys = [30u, 40, 50, 60]; + let xs = [0, 1, 2, 3, 4, 5]; + let ys = [30, 40, 50, 60]; let expected = [0, 1, 2, 3, 4, 5, 30, 40, 50, 60]; let mut it = xs.iter().chain(ys.iter()); let mut i = 0; @@ -90,7 +90,7 @@ fn test_iterator_chain() { } assert_eq!(i, expected.len()); - let ys = count(30u, 10).take(4); + let ys = count(30, 10).take(4); let mut it = xs.iter().map(|&x| x).chain(ys); let mut i = 0; for x in it { @@ -102,14 +102,14 @@ fn test_iterator_chain() { #[test] fn test_filter_map() { - let it = count(0u, 1u).take(10) + let it = count(0, 1).take(10) .filter_map(|x| if x % 2 == 0 { Some(x*x) } else { None }); assert!(it.collect::>() == vec![0*0, 2*2, 4*4, 6*6, 8*8]); } #[test] fn test_iterator_enumerate() { - let xs = [0u, 1, 2, 3, 4, 5]; + let xs = [0, 1, 2, 3, 4, 5]; let mut it = xs.iter().enumerate(); for (i, &x) in it { assert_eq!(i, x); @@ -118,7 +118,7 @@ fn test_iterator_enumerate() { #[test] fn test_iterator_peekable() { - let xs = vec![0u, 1, 2, 3, 4, 5]; + let xs = vec![0, 1, 2, 3, 4, 5]; let mut it = xs.iter().map(|&x|x).peekable(); assert_eq!(it.len(), 6); @@ -150,9 +150,9 @@ fn test_iterator_peekable() { #[test] fn test_iterator_take_while() { - let xs = [0u, 1, 2, 3, 5, 13, 15, 16, 17, 19]; - let ys = [0u, 1, 2, 3, 5, 13]; - let mut it = xs.iter().take_while(|&x| *x < 15u); + let xs = [0, 1, 2, 3, 5, 13, 15, 16, 17, 19]; + let ys = [0, 1, 2, 3, 5, 13]; + let mut it = xs.iter().take_while(|&x| *x < 15); let mut i = 0; for x in it { assert_eq!(*x, ys[i]); @@ -163,9 +163,9 @@ fn test_iterator_take_while() { #[test] fn test_iterator_skip_while() { - let xs = [0u, 1, 2, 3, 5, 13, 15, 16, 17, 19]; + let xs = [0, 1, 2, 3, 5, 13, 15, 16, 17, 19]; let ys = [15, 16, 17, 19]; - let mut it = xs.iter().skip_while(|&x| *x < 15u); + let mut it = xs.iter().skip_while(|&x| *x < 15); let mut i = 0; for x in it { assert_eq!(*x, ys[i]); @@ -176,7 +176,7 @@ fn test_iterator_skip_while() { #[test] fn test_iterator_skip() { - let xs = [0u, 1, 2, 3, 5, 13, 15, 16, 17, 19, 20, 30]; + let xs = [0, 1, 2, 3, 5, 13, 15, 16, 17, 19, 20, 30]; let ys = [13, 15, 16, 17, 19, 20, 30]; let mut it = xs.iter().skip(5); let mut i = 0; @@ -191,8 +191,8 @@ fn test_iterator_skip() { #[test] fn test_iterator_take() { - let xs = [0us, 1, 2, 3, 5, 13, 15, 16, 17, 19]; - let ys = [0us, 1, 2, 3, 5]; + let xs = [0, 1, 2, 3, 5, 13, 15, 16, 17, 19]; + let ys = [0, 1, 2, 3, 5]; let mut it = xs.iter().take(5); let mut i = 0; assert_eq!(it.len(), 5); @@ -207,8 +207,8 @@ fn test_iterator_take() { #[test] fn test_iterator_take_short() { - let xs = [0us, 1, 2, 3]; - let ys = [0us, 1, 2, 3]; + let xs = [0, 1, 2, 3]; + let ys = [0, 1, 2, 3]; let mut it = xs.iter().take(5); let mut i = 0; assert_eq!(it.len(), 4); @@ -228,7 +228,7 @@ fn test_iterator_scan() { *old += *new as int; Some(*old as f64) } - let xs = [0u, 1, 2, 3, 4]; + let xs = [0, 1, 2, 3, 4]; let ys = [0f64, 1.0, 3.0, 6.0, 10.0]; let mut it = xs.iter().scan(0, add); @@ -242,8 +242,8 @@ fn test_iterator_scan() { #[test] fn test_iterator_flat_map() { - let xs = [0u, 3, 6]; - let ys = [0u, 1, 2, 3, 4, 5, 6, 7, 8]; + let xs = [0, 3, 6]; + let ys = [0, 1, 2, 3, 4, 5, 6, 7, 8]; let mut it = xs.iter().flat_map(|&x| count(x, 1).take(3)); let mut i = 0; for x in it { @@ -255,8 +255,8 @@ fn test_iterator_flat_map() { #[test] fn test_inspect() { - let xs = [1u, 2, 3, 4]; - let mut n = 0u; + let xs = [1, 2, 3, 4]; + let mut n = 0; let ys = xs.iter() .map(|&x| x) @@ -291,13 +291,13 @@ fn test_unfoldr() { #[test] fn test_cycle() { let cycle_len = 3; - let it = count(0u, 1).take(cycle_len).cycle(); + let it = count(0, 1).take(cycle_len).cycle(); assert_eq!(it.size_hint(), (uint::MAX, None)); for (i, x) in it.take(100).enumerate() { assert_eq!(i % cycle_len, x); } - let mut it = count(0u, 1).take(0).cycle(); + let mut it = count(0, 1).take(0).cycle(); assert_eq!(it.size_hint(), (0, Some(0))); assert_eq!(it.next(), None); } @@ -305,7 +305,7 @@ fn test_cycle() { #[test] fn test_iterator_nth() { let v: &[_] = &[0, 1, 2, 3, 4]; - for i in 0u..v.len() { + for i in 0..v.len() { assert_eq!(v.iter().nth(i).unwrap(), &v[i]); } assert_eq!(v.iter().nth(v.len()), None); @@ -574,7 +574,7 @@ fn test_rposition() { fn g(xy: &(int, char)) -> bool { let (_x, y) = *xy; y == 'd' } let v = [(0, 'a'), (1, 'b'), (2, 'c'), (3, 'b')]; - assert_eq!(v.iter().rposition(f), Some(3u)); + assert_eq!(v.iter().rposition(f), Some(3)); assert!(v.iter().rposition(g).is_none()); } @@ -601,7 +601,7 @@ fn check_randacc_iter(a: T, len: uint) where { let mut b = a.clone(); assert_eq!(len, b.indexable()); - let mut n = 0u; + let mut n = 0; for (i, elt) in a.enumerate() { assert!(Some(elt) == b.idx(i)); n += 1; @@ -618,8 +618,8 @@ fn check_randacc_iter(a: T, len: uint) where #[test] fn test_double_ended_flat_map() { - let u = [0u,1]; - let v = [5u,6,7,8]; + let u = [0,1]; + let v = [5,6,7,8]; let mut it = u.iter().flat_map(|x| v[*x..v.len()].iter()); assert_eq!(it.next_back().unwrap(), &8); assert_eq!(it.next().unwrap(), &5); @@ -849,30 +849,30 @@ fn test_min_max_result() { #[test] fn test_iterate() { - let mut it = iterate(1u, |x| x * 2); - assert_eq!(it.next(), Some(1u)); - assert_eq!(it.next(), Some(2u)); - assert_eq!(it.next(), Some(4u)); - assert_eq!(it.next(), Some(8u)); + let mut it = iterate(1, |x| x * 2); + assert_eq!(it.next(), Some(1)); + assert_eq!(it.next(), Some(2)); + assert_eq!(it.next(), Some(4)); + assert_eq!(it.next(), Some(8)); } #[test] fn test_repeat() { - let mut it = repeat(42u); - assert_eq!(it.next(), Some(42u)); - assert_eq!(it.next(), Some(42u)); - assert_eq!(it.next(), Some(42u)); + let mut it = repeat(42); + assert_eq!(it.next(), Some(42)); + assert_eq!(it.next(), Some(42)); + assert_eq!(it.next(), Some(42)); } #[test] fn test_fuse() { - let mut it = 0us..3; + let mut it = 0..3; assert_eq!(it.len(), 3); - assert_eq!(it.next(), Some(0us)); + assert_eq!(it.next(), Some(0)); assert_eq!(it.len(), 2); - assert_eq!(it.next(), Some(1us)); + assert_eq!(it.next(), Some(1)); assert_eq!(it.len(), 1); - assert_eq!(it.next(), Some(2us)); + assert_eq!(it.next(), Some(2)); assert_eq!(it.len(), 0); assert_eq!(it.next(), None); assert_eq!(it.len(), 0); @@ -884,7 +884,7 @@ fn test_fuse() { #[bench] fn bench_rposition(b: &mut Bencher) { - let it: Vec = (0u..300).collect(); + let it: Vec = (0..300).collect(); b.iter(|| { it.iter().rposition(|&x| x <= 150); }); @@ -893,7 +893,7 @@ fn bench_rposition(b: &mut Bencher) { #[bench] fn bench_skip_while(b: &mut Bencher) { b.iter(|| { - let it = 0u..100; + let it = 0..100; let mut sum = 0; it.skip_while(|&x| { sum += x; sum < 4000 }).all(|_| true); }); @@ -901,10 +901,10 @@ fn bench_skip_while(b: &mut Bencher) { #[bench] fn bench_multiple_take(b: &mut Bencher) { - let mut it = (0u..42).cycle(); + let mut it = (0..42).cycle(); b.iter(|| { let n = it.next().unwrap(); - for _ in 0u..n { + for _ in 0..n { it.clone().take(it.next().unwrap()).all(|_| true); } }); diff --git a/src/libcoretest/mem.rs b/src/libcoretest/mem.rs index fd9dc696bdf..421ce76caaf 100644 --- a/src/libcoretest/mem.rs +++ b/src/libcoretest/mem.rs @@ -12,24 +12,24 @@ use test::Bencher; #[test] fn size_of_basic() { - assert_eq!(size_of::(), 1u); - assert_eq!(size_of::(), 2u); - assert_eq!(size_of::(), 4u); - assert_eq!(size_of::(), 8u); + assert_eq!(size_of::(), 1); + assert_eq!(size_of::(), 2); + assert_eq!(size_of::(), 4); + assert_eq!(size_of::(), 8); } #[test] #[cfg(target_pointer_width = "32")] fn size_of_32() { - assert_eq!(size_of::(), 4u); - assert_eq!(size_of::<*const uint>(), 4u); + assert_eq!(size_of::(), 4); + assert_eq!(size_of::<*const uint>(), 4); } #[test] #[cfg(target_pointer_width = "64")] fn size_of_64() { - assert_eq!(size_of::(), 8u); - assert_eq!(size_of::<*const uint>(), 8u); + assert_eq!(size_of::(), 8); + assert_eq!(size_of::<*const uint>(), 8); } #[test] @@ -42,30 +42,30 @@ fn size_of_val_basic() { #[test] fn align_of_basic() { - assert_eq!(align_of::(), 1u); - assert_eq!(align_of::(), 2u); - assert_eq!(align_of::(), 4u); + assert_eq!(align_of::(), 1); + assert_eq!(align_of::(), 2); + assert_eq!(align_of::(), 4); } #[test] #[cfg(target_pointer_width = "32")] fn align_of_32() { - assert_eq!(align_of::(), 4u); - assert_eq!(align_of::<*const uint>(), 4u); + assert_eq!(align_of::(), 4); + assert_eq!(align_of::<*const uint>(), 4); } #[test] #[cfg(target_pointer_width = "64")] fn align_of_64() { - assert_eq!(align_of::(), 8u); - assert_eq!(align_of::<*const uint>(), 8u); + assert_eq!(align_of::(), 8); + assert_eq!(align_of::<*const uint>(), 8); } #[test] fn align_of_val_basic() { - assert_eq!(align_of_val(&1u8), 1u); - assert_eq!(align_of_val(&1u16), 2u); - assert_eq!(align_of_val(&1u32), 4u); + assert_eq!(align_of_val(&1u8), 1); + assert_eq!(align_of_val(&1u16), 2); + assert_eq!(align_of_val(&1u32), 4); } #[test] @@ -87,7 +87,7 @@ fn test_replace() { #[test] fn test_transmute_copy() { - assert_eq!(1u, unsafe { transmute_copy(&1) }); + assert_eq!(1, unsafe { transmute_copy(&1) }); } #[test] diff --git a/src/libcoretest/num/uint_macros.rs b/src/libcoretest/num/uint_macros.rs index 04d8fb15cf5..5c6efc857f1 100644 --- a/src/libcoretest/num/uint_macros.rs +++ b/src/libcoretest/num/uint_macros.rs @@ -33,8 +33,8 @@ mod tests { assert!(0b1110 as $T == (0b1100 as $T).bitor(0b1010 as $T)); assert!(0b1000 as $T == (0b1100 as $T).bitand(0b1010 as $T)); assert!(0b0110 as $T == (0b1100 as $T).bitxor(0b1010 as $T)); - assert!(0b1110 as $T == (0b0111 as $T).shl(1u)); - assert!(0b0111 as $T == (0b1110 as $T).shr(1u)); + assert!(0b1110 as $T == (0b0111 as $T).shl(1)); + assert!(0b0111 as $T == (0b1110 as $T).shr(1)); assert!(MAX - (0b1011 as $T) == (0b1011 as $T).not()); } @@ -119,8 +119,8 @@ mod tests { #[test] fn test_unsigned_checked_div() { - assert!(10u.checked_div(2) == Some(5)); - assert!(5u.checked_div(0) == None); + assert!(10.checked_div(2) == Some(5)); + assert!(5.checked_div(0) == None); } } diff --git a/src/libcoretest/ops.rs b/src/libcoretest/ops.rs index 3da572f65a6..0183e6a93cf 100644 --- a/src/libcoretest/ops.rs +++ b/src/libcoretest/ops.rs @@ -33,11 +33,11 @@ fn alloc_obj_with_dtor(b: &mut Bencher) { #[test] fn test_range() { - let r = Range { start: 2u, end: 10 }; - let mut count = 0u; + let r = Range { start: 2, end: 10 }; + let mut count = 0; for (i, ri) in r.enumerate() { assert!(ri == i + 2); - assert!(ri >= 2u && ri < 10u); + assert!(ri >= 2 && ri < 10); count += 1; } assert!(count == 8); @@ -45,11 +45,11 @@ fn test_range() { #[test] fn test_range_from() { - let r = RangeFrom { start: 2u }; - let mut count = 0u; + let r = RangeFrom { start: 2 }; + let mut count = 0; for (i, ri) in r.take(10).enumerate() { assert!(ri == i + 2); - assert!(ri >= 2u && ri < 12u); + assert!(ri >= 2 && ri < 12); count += 1; } assert!(count == 10); @@ -58,7 +58,7 @@ fn test_range_from() { #[test] fn test_range_to() { // Not much to test. - let _ = RangeTo { end: 42u }; + let _ = RangeTo { end: 42 }; } #[test] diff --git a/src/libcoretest/ptr.rs b/src/libcoretest/ptr.rs index 2365b907b3f..a54ba7ad29b 100644 --- a/src/libcoretest/ptr.rs +++ b/src/libcoretest/ptr.rs @@ -46,7 +46,7 @@ fn test() { v1[1] == 32001u16 && v1[2] == 0u16)); copy_memory(v1.as_mut_ptr().offset(2), - v0.as_ptr(), 1u); + v0.as_ptr(), 1); assert!((v1[0] == 32002u16 && v1[1] == 32001u16 && v1[2] == 32000u16)); diff --git a/src/libcoretest/tuple.rs b/src/libcoretest/tuple.rs index 57844f5995f..4fe5e0a740b 100644 --- a/src/libcoretest/tuple.rs +++ b/src/libcoretest/tuple.rs @@ -19,7 +19,7 @@ fn test_clone() { #[test] fn test_tuple_cmp() { - let (small, big) = ((1u, 2u, 3u), (3u, 2u, 1u)); + let (small, big) = ((1, 2, 3), (3, 2, 1)); let nan = 0.0f64/0.0;