Skip to content

Commit cca1cf6

Browse files
committed
Auto merge of #21895 - alfie:libcoretest, r=pnkfelix
2 parents c34421e + bffbcb5 commit cca1cf6

File tree

9 files changed

+112
-112
lines changed

9 files changed

+112
-112
lines changed

src/libcoretest/any.rs

+11-11
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ static TEST: &'static str = "Test";
1818

1919
#[test]
2020
fn any_referenced() {
21-
let (a, b, c) = (&5u as &Any, &TEST as &Any, &Test as &Any);
21+
let (a, b, c) = (&5 as &Any, &TEST as &Any, &Test as &Any);
2222

23-
assert!(a.is::<uint>());
24-
assert!(!b.is::<uint>());
25-
assert!(!c.is::<uint>());
23+
assert!(a.is::<i32>());
24+
assert!(!b.is::<i32>());
25+
assert!(!c.is::<i32>());
2626

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

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

4040
assert!(a.is::<uint>());
4141
assert!(!b.is::<uint>());
@@ -52,7 +52,7 @@ fn any_owning() {
5252

5353
#[test]
5454
fn any_downcast_ref() {
55-
let a = &5u as &Any;
55+
let a = &5us as &Any;
5656

5757
match a.downcast_ref::<uint>() {
5858
Some(&5) => {}
@@ -67,24 +67,24 @@ fn any_downcast_ref() {
6767

6868
#[test]
6969
fn any_downcast_mut() {
70-
let mut a = 5u;
71-
let mut b = box 7u;
70+
let mut a = 5us;
71+
let mut b = box 7us;
7272

7373
let a_r = &mut a as &mut Any;
7474
let tmp: &mut uint = &mut *b;
7575
let b_r = tmp as &mut Any;
7676

7777
match a_r.downcast_mut::<uint>() {
7878
Some(x) => {
79-
assert_eq!(*x, 5u);
79+
assert_eq!(*x, 5);
8080
*x = 612;
8181
}
8282
x => panic!("Unexpected value {:?}", x)
8383
}
8484

8585
match b_r.downcast_mut::<uint>() {
8686
Some(x) => {
87-
assert_eq!(*x, 7u);
87+
assert_eq!(*x, 7);
8888
*x = 413;
8989
}
9090
x => panic!("Unexpected value {:?}", x)
@@ -113,7 +113,7 @@ fn any_downcast_mut() {
113113

114114
#[test]
115115
fn any_fixed_vec() {
116-
let test = [0u; 8];
116+
let test = [0us; 8];
117117
let test = &test as &Any;
118118
assert!(test.is::<[uint; 8]>());
119119
assert!(!test.is::<[uint; 10]>());

src/libcoretest/cell.rs

+12-12
Original file line numberDiff line numberDiff line change
@@ -134,21 +134,21 @@ fn clone_ref_updates_flag() {
134134

135135
#[test]
136136
fn as_unsafe_cell() {
137-
let c1: Cell<uint> = Cell::new(0u);
138-
c1.set(1u);
139-
assert_eq!(1u, unsafe { *c1.as_unsafe_cell().get() });
137+
let c1: Cell<uint> = Cell::new(0);
138+
c1.set(1);
139+
assert_eq!(1, unsafe { *c1.as_unsafe_cell().get() });
140140

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

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

149-
let r2: RefCell<uint> = RefCell::new(0u);
150-
unsafe { *r2.as_unsafe_cell().get() = 1u; }
151-
assert_eq!(1u, *r2.borrow());
149+
let r2: RefCell<uint> = RefCell::new(0);
150+
unsafe { *r2.as_unsafe_cell().get() = 1; }
151+
assert_eq!(1, *r2.borrow());
152152
}
153153

154154
#[test]

src/libcoretest/char.rs

+12-12
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,18 @@ fn test_is_whitespace() {
4141

4242
#[test]
4343
fn test_to_digit() {
44-
assert_eq!('0'.to_digit(10u), Some(0u));
45-
assert_eq!('1'.to_digit(2u), Some(1u));
46-
assert_eq!('2'.to_digit(3u), Some(2u));
47-
assert_eq!('9'.to_digit(10u), Some(9u));
48-
assert_eq!('a'.to_digit(16u), Some(10u));
49-
assert_eq!('A'.to_digit(16u), Some(10u));
50-
assert_eq!('b'.to_digit(16u), Some(11u));
51-
assert_eq!('B'.to_digit(16u), Some(11u));
52-
assert_eq!('z'.to_digit(36u), Some(35u));
53-
assert_eq!('Z'.to_digit(36u), Some(35u));
54-
assert_eq!(' '.to_digit(10u), None);
55-
assert_eq!('$'.to_digit(36u), None);
44+
assert_eq!('0'.to_digit(10), Some(0));
45+
assert_eq!('1'.to_digit(2), Some(1));
46+
assert_eq!('2'.to_digit(3), Some(2));
47+
assert_eq!('9'.to_digit(10), Some(9));
48+
assert_eq!('a'.to_digit(16), Some(10));
49+
assert_eq!('A'.to_digit(16), Some(10));
50+
assert_eq!('b'.to_digit(16), Some(11));
51+
assert_eq!('B'.to_digit(16), Some(11));
52+
assert_eq!('z'.to_digit(36), Some(35));
53+
assert_eq!('Z'.to_digit(36), Some(35));
54+
assert_eq!(' '.to_digit(10), None);
55+
assert_eq!('$'.to_digit(36), None);
5656
}
5757

5858
#[test]

src/libcoretest/iter.rs

+45-45
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ fn test_counter_from_iter() {
7979

8080
#[test]
8181
fn test_iterator_chain() {
82-
let xs = [0u, 1, 2, 3, 4, 5];
83-
let ys = [30u, 40, 50, 60];
82+
let xs = [0, 1, 2, 3, 4, 5];
83+
let ys = [30, 40, 50, 60];
8484
let expected = [0, 1, 2, 3, 4, 5, 30, 40, 50, 60];
8585
let mut it = xs.iter().chain(ys.iter());
8686
let mut i = 0;
@@ -90,7 +90,7 @@ fn test_iterator_chain() {
9090
}
9191
assert_eq!(i, expected.len());
9292

93-
let ys = count(30u, 10).take(4);
93+
let ys = count(30, 10).take(4);
9494
let mut it = xs.iter().map(|&x| x).chain(ys);
9595
let mut i = 0;
9696
for x in it {
@@ -102,14 +102,14 @@ fn test_iterator_chain() {
102102

103103
#[test]
104104
fn test_filter_map() {
105-
let it = count(0u, 1u).take(10)
105+
let it = count(0, 1).take(10)
106106
.filter_map(|x| if x % 2 == 0 { Some(x*x) } else { None });
107107
assert!(it.collect::<Vec<uint>>() == vec![0*0, 2*2, 4*4, 6*6, 8*8]);
108108
}
109109

110110
#[test]
111111
fn test_iterator_enumerate() {
112-
let xs = [0u, 1, 2, 3, 4, 5];
112+
let xs = [0, 1, 2, 3, 4, 5];
113113
let mut it = xs.iter().enumerate();
114114
for (i, &x) in it {
115115
assert_eq!(i, x);
@@ -118,7 +118,7 @@ fn test_iterator_enumerate() {
118118

119119
#[test]
120120
fn test_iterator_peekable() {
121-
let xs = vec![0u, 1, 2, 3, 4, 5];
121+
let xs = vec![0, 1, 2, 3, 4, 5];
122122
let mut it = xs.iter().map(|&x|x).peekable();
123123

124124
assert_eq!(it.len(), 6);
@@ -150,9 +150,9 @@ fn test_iterator_peekable() {
150150

151151
#[test]
152152
fn test_iterator_take_while() {
153-
let xs = [0u, 1, 2, 3, 5, 13, 15, 16, 17, 19];
154-
let ys = [0u, 1, 2, 3, 5, 13];
155-
let mut it = xs.iter().take_while(|&x| *x < 15u);
153+
let xs = [0, 1, 2, 3, 5, 13, 15, 16, 17, 19];
154+
let ys = [0, 1, 2, 3, 5, 13];
155+
let mut it = xs.iter().take_while(|&x| *x < 15);
156156
let mut i = 0;
157157
for x in it {
158158
assert_eq!(*x, ys[i]);
@@ -163,9 +163,9 @@ fn test_iterator_take_while() {
163163

164164
#[test]
165165
fn test_iterator_skip_while() {
166-
let xs = [0u, 1, 2, 3, 5, 13, 15, 16, 17, 19];
166+
let xs = [0, 1, 2, 3, 5, 13, 15, 16, 17, 19];
167167
let ys = [15, 16, 17, 19];
168-
let mut it = xs.iter().skip_while(|&x| *x < 15u);
168+
let mut it = xs.iter().skip_while(|&x| *x < 15);
169169
let mut i = 0;
170170
for x in it {
171171
assert_eq!(*x, ys[i]);
@@ -176,7 +176,7 @@ fn test_iterator_skip_while() {
176176

177177
#[test]
178178
fn test_iterator_skip() {
179-
let xs = [0u, 1, 2, 3, 5, 13, 15, 16, 17, 19, 20, 30];
179+
let xs = [0, 1, 2, 3, 5, 13, 15, 16, 17, 19, 20, 30];
180180
let ys = [13, 15, 16, 17, 19, 20, 30];
181181
let mut it = xs.iter().skip(5);
182182
let mut i = 0;
@@ -191,8 +191,8 @@ fn test_iterator_skip() {
191191

192192
#[test]
193193
fn test_iterator_take() {
194-
let xs = [0us, 1, 2, 3, 5, 13, 15, 16, 17, 19];
195-
let ys = [0us, 1, 2, 3, 5];
194+
let xs = [0, 1, 2, 3, 5, 13, 15, 16, 17, 19];
195+
let ys = [0, 1, 2, 3, 5];
196196
let mut it = xs.iter().take(5);
197197
let mut i = 0;
198198
assert_eq!(it.len(), 5);
@@ -207,8 +207,8 @@ fn test_iterator_take() {
207207

208208
#[test]
209209
fn test_iterator_take_short() {
210-
let xs = [0us, 1, 2, 3];
211-
let ys = [0us, 1, 2, 3];
210+
let xs = [0, 1, 2, 3];
211+
let ys = [0, 1, 2, 3];
212212
let mut it = xs.iter().take(5);
213213
let mut i = 0;
214214
assert_eq!(it.len(), 4);
@@ -228,7 +228,7 @@ fn test_iterator_scan() {
228228
*old += *new as int;
229229
Some(*old as f64)
230230
}
231-
let xs = [0u, 1, 2, 3, 4];
231+
let xs = [0, 1, 2, 3, 4];
232232
let ys = [0f64, 1.0, 3.0, 6.0, 10.0];
233233

234234
let mut it = xs.iter().scan(0, add);
@@ -242,8 +242,8 @@ fn test_iterator_scan() {
242242

243243
#[test]
244244
fn test_iterator_flat_map() {
245-
let xs = [0u, 3, 6];
246-
let ys = [0u, 1, 2, 3, 4, 5, 6, 7, 8];
245+
let xs = [0, 3, 6];
246+
let ys = [0, 1, 2, 3, 4, 5, 6, 7, 8];
247247
let mut it = xs.iter().flat_map(|&x| count(x, 1).take(3));
248248
let mut i = 0;
249249
for x in it {
@@ -255,8 +255,8 @@ fn test_iterator_flat_map() {
255255

256256
#[test]
257257
fn test_inspect() {
258-
let xs = [1u, 2, 3, 4];
259-
let mut n = 0u;
258+
let xs = [1, 2, 3, 4];
259+
let mut n = 0;
260260

261261
let ys = xs.iter()
262262
.map(|&x| x)
@@ -291,21 +291,21 @@ fn test_unfoldr() {
291291
#[test]
292292
fn test_cycle() {
293293
let cycle_len = 3;
294-
let it = count(0u, 1).take(cycle_len).cycle();
294+
let it = count(0, 1).take(cycle_len).cycle();
295295
assert_eq!(it.size_hint(), (uint::MAX, None));
296296
for (i, x) in it.take(100).enumerate() {
297297
assert_eq!(i % cycle_len, x);
298298
}
299299

300-
let mut it = count(0u, 1).take(0).cycle();
300+
let mut it = count(0, 1).take(0).cycle();
301301
assert_eq!(it.size_hint(), (0, Some(0)));
302302
assert_eq!(it.next(), None);
303303
}
304304

305305
#[test]
306306
fn test_iterator_nth() {
307307
let v: &[_] = &[0, 1, 2, 3, 4];
308-
for i in 0u..v.len() {
308+
for i in 0..v.len() {
309309
assert_eq!(v.iter().nth(i).unwrap(), &v[i]);
310310
}
311311
assert_eq!(v.iter().nth(v.len()), None);
@@ -574,7 +574,7 @@ fn test_rposition() {
574574
fn g(xy: &(int, char)) -> bool { let (_x, y) = *xy; y == 'd' }
575575
let v = [(0, 'a'), (1, 'b'), (2, 'c'), (3, 'b')];
576576

577-
assert_eq!(v.iter().rposition(f), Some(3u));
577+
assert_eq!(v.iter().rposition(f), Some(3));
578578
assert!(v.iter().rposition(g).is_none());
579579
}
580580

@@ -601,7 +601,7 @@ fn check_randacc_iter<A, T>(a: T, len: uint) where
601601
{
602602
let mut b = a.clone();
603603
assert_eq!(len, b.indexable());
604-
let mut n = 0u;
604+
let mut n = 0;
605605
for (i, elt) in a.enumerate() {
606606
assert!(Some(elt) == b.idx(i));
607607
n += 1;
@@ -618,8 +618,8 @@ fn check_randacc_iter<A, T>(a: T, len: uint) where
618618

619619
#[test]
620620
fn test_double_ended_flat_map() {
621-
let u = [0u,1];
622-
let v = [5u,6,7,8];
621+
let u = [0,1];
622+
let v = [5,6,7,8];
623623
let mut it = u.iter().flat_map(|x| v[*x..v.len()].iter());
624624
assert_eq!(it.next_back().unwrap(), &8);
625625
assert_eq!(it.next().unwrap(), &5);
@@ -849,30 +849,30 @@ fn test_min_max_result() {
849849

850850
#[test]
851851
fn test_iterate() {
852-
let mut it = iterate(1u, |x| x * 2);
853-
assert_eq!(it.next(), Some(1u));
854-
assert_eq!(it.next(), Some(2u));
855-
assert_eq!(it.next(), Some(4u));
856-
assert_eq!(it.next(), Some(8u));
852+
let mut it = iterate(1, |x| x * 2);
853+
assert_eq!(it.next(), Some(1));
854+
assert_eq!(it.next(), Some(2));
855+
assert_eq!(it.next(), Some(4));
856+
assert_eq!(it.next(), Some(8));
857857
}
858858

859859
#[test]
860860
fn test_repeat() {
861-
let mut it = repeat(42u);
862-
assert_eq!(it.next(), Some(42u));
863-
assert_eq!(it.next(), Some(42u));
864-
assert_eq!(it.next(), Some(42u));
861+
let mut it = repeat(42);
862+
assert_eq!(it.next(), Some(42));
863+
assert_eq!(it.next(), Some(42));
864+
assert_eq!(it.next(), Some(42));
865865
}
866866

867867
#[test]
868868
fn test_fuse() {
869-
let mut it = 0us..3;
869+
let mut it = 0..3;
870870
assert_eq!(it.len(), 3);
871-
assert_eq!(it.next(), Some(0us));
871+
assert_eq!(it.next(), Some(0));
872872
assert_eq!(it.len(), 2);
873-
assert_eq!(it.next(), Some(1us));
873+
assert_eq!(it.next(), Some(1));
874874
assert_eq!(it.len(), 1);
875-
assert_eq!(it.next(), Some(2us));
875+
assert_eq!(it.next(), Some(2));
876876
assert_eq!(it.len(), 0);
877877
assert_eq!(it.next(), None);
878878
assert_eq!(it.len(), 0);
@@ -884,7 +884,7 @@ fn test_fuse() {
884884

885885
#[bench]
886886
fn bench_rposition(b: &mut Bencher) {
887-
let it: Vec<uint> = (0u..300).collect();
887+
let it: Vec<uint> = (0..300).collect();
888888
b.iter(|| {
889889
it.iter().rposition(|&x| x <= 150);
890890
});
@@ -893,18 +893,18 @@ fn bench_rposition(b: &mut Bencher) {
893893
#[bench]
894894
fn bench_skip_while(b: &mut Bencher) {
895895
b.iter(|| {
896-
let it = 0u..100;
896+
let it = 0..100;
897897
let mut sum = 0;
898898
it.skip_while(|&x| { sum += x; sum < 4000 }).all(|_| true);
899899
});
900900
}
901901

902902
#[bench]
903903
fn bench_multiple_take(b: &mut Bencher) {
904-
let mut it = (0u..42).cycle();
904+
let mut it = (0..42).cycle();
905905
b.iter(|| {
906906
let n = it.next().unwrap();
907-
for _ in 0u..n {
907+
for _ in 0..n {
908908
it.clone().take(it.next().unwrap()).all(|_| true);
909909
}
910910
});

0 commit comments

Comments
 (0)