Skip to content

Deprecating i/u suffixes in libcoretest #21895

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 12, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions src/libcoretest/any.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<uint>());
assert!(!b.is::<uint>());
assert!(!c.is::<uint>());
assert!(a.is::<i32>());
assert!(!b.is::<i32>());
assert!(!c.is::<i32>());

assert!(!a.is::<&'static str>());
assert!(b.is::<&'static str>());
Expand All @@ -35,7 +35,7 @@ fn any_referenced() {

#[test]
fn any_owning() {
let (a, b, c) = (box 5u as Box<Any>, box TEST as Box<Any>, box Test as Box<Any>);
let (a, b, c) = (box 5us as Box<Any>, box TEST as Box<Any>, box Test as Box<Any>);

assert!(a.is::<uint>());
assert!(!b.is::<uint>());
Expand All @@ -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::<uint>() {
Some(&5) => {}
Expand All @@ -67,24 +67,24 @@ 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;
let b_r = tmp as &mut Any;

match a_r.downcast_mut::<uint>() {
Some(x) => {
assert_eq!(*x, 5u);
assert_eq!(*x, 5);
*x = 612;
}
x => panic!("Unexpected value {:?}", x)
}

match b_r.downcast_mut::<uint>() {
Some(x) => {
assert_eq!(*x, 7u);
assert_eq!(*x, 7);
*x = 413;
}
x => panic!("Unexpected value {:?}", x)
Expand Down Expand Up @@ -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]>());
Expand Down
24 changes: 12 additions & 12 deletions src/libcoretest/cell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,21 +134,21 @@ fn clone_ref_updates_flag() {

#[test]
fn as_unsafe_cell() {
let c1: Cell<uint> = Cell::new(0u);
c1.set(1u);
assert_eq!(1u, unsafe { *c1.as_unsafe_cell().get() });
let c1: Cell<uint> = Cell::new(0);
c1.set(1);
assert_eq!(1, unsafe { *c1.as_unsafe_cell().get() });

let c2: Cell<uint> = Cell::new(0u);
unsafe { *c2.as_unsafe_cell().get() = 1u; }
assert_eq!(1u, c2.get());
let c2: Cell<uint> = Cell::new(0);
unsafe { *c2.as_unsafe_cell().get() = 1; }
assert_eq!(1, c2.get());

let r1: RefCell<uint> = RefCell::new(0u);
*r1.borrow_mut() = 1u;
assert_eq!(1u, unsafe { *r1.as_unsafe_cell().get() });
let r1: RefCell<uint> = RefCell::new(0);
*r1.borrow_mut() = 1;
assert_eq!(1, unsafe { *r1.as_unsafe_cell().get() });

let r2: RefCell<uint> = RefCell::new(0u);
unsafe { *r2.as_unsafe_cell().get() = 1u; }
assert_eq!(1u, *r2.borrow());
let r2: RefCell<uint> = RefCell::new(0);
unsafe { *r2.as_unsafe_cell().get() = 1; }
assert_eq!(1, *r2.borrow());
}

#[test]
Expand Down
24 changes: 12 additions & 12 deletions src/libcoretest/char.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
90 changes: 45 additions & 45 deletions src/libcoretest/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 {
Expand All @@ -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<uint>>() == 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);
Expand All @@ -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);
Expand Down Expand Up @@ -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]);
Expand All @@ -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]);
Expand All @@ -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;
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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 {
Expand All @@ -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)
Expand Down Expand Up @@ -291,21 +291,21 @@ 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);
}

#[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);
Expand Down Expand Up @@ -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());
}

Expand All @@ -601,7 +601,7 @@ fn check_randacc_iter<A, T>(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;
Expand All @@ -618,8 +618,8 @@ fn check_randacc_iter<A, T>(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);
Expand Down Expand Up @@ -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);
Expand All @@ -884,7 +884,7 @@ fn test_fuse() {

#[bench]
fn bench_rposition(b: &mut Bencher) {
let it: Vec<uint> = (0u..300).collect();
let it: Vec<uint> = (0..300).collect();
b.iter(|| {
it.iter().rposition(|&x| x <= 150);
});
Expand All @@ -893,18 +893,18 @@ 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);
});
}

#[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);
}
});
Expand Down
Loading