Skip to content

Commit

Permalink
Remove some test warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
treeman committed Sep 9, 2014
1 parent 6f34760 commit 947a1b9
Show file tree
Hide file tree
Showing 15 changed files with 79 additions and 70 deletions.
2 changes: 2 additions & 0 deletions src/libarena/lib.rs
Expand Up @@ -509,6 +509,7 @@ mod tests {
use self::test::Bencher;
use super::{Arena, TypedArena};

#[allow(dead_code)]
struct Point {
x: int,
y: int,
Expand Down Expand Up @@ -564,6 +565,7 @@ mod tests {
})
}

#[allow(dead_code)]
struct Noncopy {
string: String,
array: Vec<int>,
Expand Down
12 changes: 10 additions & 2 deletions src/libcollections/slice.rs
Expand Up @@ -864,6 +864,7 @@ mod tests {
}

#[test]
#[allow(deprecated)]
fn test_tailn() {
let mut a = vec![11i, 12, 13];
let b: &[int] = &[11, 12, 13];
Expand All @@ -875,6 +876,7 @@ mod tests {

#[test]
#[should_fail]
#[allow(deprecated)]
fn test_tailn_empty() {
let a: Vec<int> = vec![];
a.tailn(2);
Expand Down Expand Up @@ -909,6 +911,7 @@ mod tests {

#[test]
#[should_fail]
#[allow(deprecated)]
fn test_initn_empty() {
let a: Vec<int> = vec![];
a.as_slice().initn(2);
Expand Down Expand Up @@ -1466,6 +1469,7 @@ mod tests {
}

#[test]
#[allow(deprecated)]
fn test_unshift() {
let mut x = vec![1i, 2, 3];
x.unshift(0);
Expand Down Expand Up @@ -2079,6 +2083,7 @@ mod tests {
}

#[test]
#[allow(deprecated)]
fn test_shift_ref() {
let mut x: &[int] = [1, 2, 3, 4, 5];
let h = x.shift_ref();
Expand All @@ -2092,6 +2097,7 @@ mod tests {
}

#[test]
#[allow(deprecated)]
fn test_pop_ref() {
let mut x: &[int] = [1, 2, 3, 4, 5];
let h = x.pop_ref();
Expand Down Expand Up @@ -2171,6 +2177,7 @@ mod tests {
}

#[test]
#[allow(deprecated)]
fn test_mut_shift_ref() {
let mut x: &mut [int] = [1, 2, 3, 4, 5];
let h = x.mut_shift_ref();
Expand All @@ -2184,6 +2191,7 @@ mod tests {
}

#[test]
#[allow(deprecated)]
fn test_mut_pop_ref() {
let mut x: &mut [int] = [1, 2, 3, 4, 5];
let h = x.mut_pop_ref();
Expand Down Expand Up @@ -2441,7 +2449,7 @@ mod bench {
b.iter(|| {
v.sort();
});
b.bytes = (v.len() * mem::size_of_val(v.get(0))) as u64;
b.bytes = (v.len() * mem::size_of_val(&v[0])) as u64;
}

type BigSortable = (u64,u64,u64,u64);
Expand Down Expand Up @@ -2485,6 +2493,6 @@ mod bench {
b.iter(|| {
v.sort();
});
b.bytes = (v.len() * mem::size_of_val(v.get(0))) as u64;
b.bytes = (v.len() * mem::size_of_val(&v[0])) as u64;
}
}
24 changes: 12 additions & 12 deletions src/libcoretest/any.rs
Expand Up @@ -51,61 +51,61 @@ fn any_owning() {
}

#[test]
fn any_as_ref() {
fn any_downcast_ref() {
let a = &5u as &Any;

match a.as_ref::<uint>() {
match a.downcast_ref::<uint>() {
Some(&5) => {}
x => fail!("Unexpected value {}", x)
}

match a.as_ref::<Test>() {
match a.downcast_ref::<Test>() {
None => {}
x => fail!("Unexpected value {}", x)
}
}

#[test]
fn any_as_mut() {
fn any_downcast_mut() {
let mut a = 5u;
let mut b = box 7u;

let a_r = &mut a as &mut Any;
let tmp: &mut uint = &mut *b;
let b_r = tmp as &mut Any;

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

match b_r.as_mut::<uint>() {
match b_r.downcast_mut::<uint>() {
Some(x) => {
assert_eq!(*x, 7u);
*x = 413;
}
x => fail!("Unexpected value {}", x)
}

match a_r.as_mut::<Test>() {
match a_r.downcast_mut::<Test>() {
None => (),
x => fail!("Unexpected value {}", x)
}

match b_r.as_mut::<Test>() {
match b_r.downcast_mut::<Test>() {
None => (),
x => fail!("Unexpected value {}", x)
}

match a_r.as_mut::<uint>() {
match a_r.downcast_mut::<uint>() {
Some(&612) => {}
x => fail!("Unexpected value {}", x)
}

match b_r.as_mut::<uint>() {
match b_r.downcast_mut::<uint>() {
Some(&413) => {}
x => fail!("Unexpected value {}", x)
}
Expand All @@ -121,11 +121,11 @@ fn any_fixed_vec() {


#[bench]
fn bench_as_ref(b: &mut Bencher) {
fn bench_downcast_ref(b: &mut Bencher) {
b.iter(|| {
let mut x = 0i;
let mut y = &mut x as &mut Any;
test::black_box(&mut y);
test::black_box(y.as_ref::<int>() == Some(&0));
test::black_box(y.downcast_ref::<int>() == Some(&0));
});
}
3 changes: 3 additions & 0 deletions src/libcoretest/option.rs
Expand Up @@ -131,6 +131,7 @@ fn test_or_else() {
}

#[test]
#[allow(deprecated)]
fn test_option_while_some() {
let mut i = 0i;
Some(10i).while_some(|j| {
Expand Down Expand Up @@ -184,6 +185,7 @@ fn test_unwrap_or_else() {
}

#[test]
#[allow(deprecated)]
fn test_filtered() {
let some_stuff = Some(42i);
let modified_stuff = some_stuff.filtered(|&x| {x < 10});
Expand Down Expand Up @@ -256,6 +258,7 @@ fn test_mutate() {
}

#[test]
#[allow(deprecated)]
fn test_collect() {
let v: Option<Vec<int>> = collect(range(0i, 0)
.map(|_| Some(0i)));
Expand Down
1 change: 1 addition & 0 deletions src/libcoretest/result.rs
Expand Up @@ -69,6 +69,7 @@ pub fn test_impl_map_err() {
}

#[test]
#[allow(deprecated)]
fn test_collect() {
let v: Result<Vec<int>, ()> = collect(range(0i, 0).map(|_| Ok::<int, ()>(0)));
assert!(v == Ok(vec![]));
Expand Down
1 change: 1 addition & 0 deletions src/libdebug/repr.rs
Expand Up @@ -568,6 +568,7 @@ pub fn repr_to_string<T>(t: &T) -> String {
}

#[cfg(test)]
#[allow(dead_code)]
struct P {a: int, b: f64}

#[test]
Expand Down
6 changes: 3 additions & 3 deletions src/libgraphviz/lib.rs
Expand Up @@ -632,9 +632,9 @@ mod tests {
id_name(n)
}
fn node_label(&'a self, n: &Node) -> LabelText<'a> {
match self.node_labels.get(*n) {
&Some(ref l) => LabelStr(str::Slice(l.as_slice())),
&None => LabelStr(id_name(n).name()),
match self.node_labels[*n] {
Some(ref l) => LabelStr(str::Slice(l.as_slice())),
None => LabelStr(id_name(n).name()),
}
}
fn edge_label(&'a self, e: & &'a Edge) -> LabelText<'a> {
Expand Down
1 change: 1 addition & 0 deletions src/libgreen/sched.rs
Expand Up @@ -1414,6 +1414,7 @@ mod test {
// Regression test that the `start` task entrypoint can
// contain dtors that use task resources
run(proc() {
#[allow(dead_code)]
struct S { field: () }

impl Drop for S {
Expand Down
84 changes: 42 additions & 42 deletions src/libnum/bigint.rs
Expand Up @@ -1978,10 +1978,10 @@ mod biguint_tests {
#[test]
fn test_checked_add() {
for elm in sum_triples.iter() {
let (aVec, bVec, cVec) = *elm;
let a = BigUint::from_slice(aVec);
let b = BigUint::from_slice(bVec);
let c = BigUint::from_slice(cVec);
let (a_vec, b_vec, c_vec) = *elm;
let a = BigUint::from_slice(a_vec);
let b = BigUint::from_slice(b_vec);
let c = BigUint::from_slice(c_vec);

assert!(a.checked_add(&b).unwrap() == c);
assert!(b.checked_add(&a).unwrap() == c);
Expand All @@ -1991,10 +1991,10 @@ mod biguint_tests {
#[test]
fn test_checked_sub() {
for elm in sum_triples.iter() {
let (aVec, bVec, cVec) = *elm;
let a = BigUint::from_slice(aVec);
let b = BigUint::from_slice(bVec);
let c = BigUint::from_slice(cVec);
let (a_vec, b_vec, c_vec) = *elm;
let a = BigUint::from_slice(a_vec);
let b = BigUint::from_slice(b_vec);
let c = BigUint::from_slice(c_vec);

assert!(c.checked_sub(&a).unwrap() == b);
assert!(c.checked_sub(&b).unwrap() == a);
Expand All @@ -2011,21 +2011,21 @@ mod biguint_tests {
#[test]
fn test_checked_mul() {
for elm in mul_triples.iter() {
let (aVec, bVec, cVec) = *elm;
let a = BigUint::from_slice(aVec);
let b = BigUint::from_slice(bVec);
let c = BigUint::from_slice(cVec);
let (a_vec, b_vec, c_vec) = *elm;
let a = BigUint::from_slice(a_vec);
let b = BigUint::from_slice(b_vec);
let c = BigUint::from_slice(c_vec);

assert!(a.checked_mul(&b).unwrap() == c);
assert!(b.checked_mul(&a).unwrap() == c);
}

for elm in div_rem_quadruples.iter() {
let (aVec, bVec, cVec, dVec) = *elm;
let a = BigUint::from_slice(aVec);
let b = BigUint::from_slice(bVec);
let c = BigUint::from_slice(cVec);
let d = BigUint::from_slice(dVec);
let (a_vec, b_vec, c_vec, d_vec) = *elm;
let a = BigUint::from_slice(a_vec);
let b = BigUint::from_slice(b_vec);
let c = BigUint::from_slice(c_vec);
let d = BigUint::from_slice(d_vec);

assert!(a == b.checked_mul(&c).unwrap() + d);
assert!(a == c.checked_mul(&b).unwrap() + d);
Expand All @@ -2035,10 +2035,10 @@ mod biguint_tests {
#[test]
fn test_checked_div() {
for elm in mul_triples.iter() {
let (aVec, bVec, cVec) = *elm;
let a = BigUint::from_slice(aVec);
let b = BigUint::from_slice(bVec);
let c = BigUint::from_slice(cVec);
let (a_vec, b_vec, c_vec) = *elm;
let a = BigUint::from_slice(a_vec);
let b = BigUint::from_slice(b_vec);
let c = BigUint::from_slice(c_vec);

if !a.is_zero() {
assert!(c.checked_div(&a).unwrap() == b);
Expand Down Expand Up @@ -2651,10 +2651,10 @@ mod bigint_tests {
#[test]
fn test_checked_add() {
for elm in sum_triples.iter() {
let (aVec, bVec, cVec) = *elm;
let a = BigInt::from_slice(Plus, aVec);
let b = BigInt::from_slice(Plus, bVec);
let c = BigInt::from_slice(Plus, cVec);
let (a_vec, b_vec, c_vec) = *elm;
let a = BigInt::from_slice(Plus, a_vec);
let b = BigInt::from_slice(Plus, b_vec);
let c = BigInt::from_slice(Plus, c_vec);

assert!(a.checked_add(&b).unwrap() == c);
assert!(b.checked_add(&a).unwrap() == c);
Expand All @@ -2670,10 +2670,10 @@ mod bigint_tests {
#[test]
fn test_checked_sub() {
for elm in sum_triples.iter() {
let (aVec, bVec, cVec) = *elm;
let a = BigInt::from_slice(Plus, aVec);
let b = BigInt::from_slice(Plus, bVec);
let c = BigInt::from_slice(Plus, cVec);
let (a_vec, b_vec, c_vec) = *elm;
let a = BigInt::from_slice(Plus, a_vec);
let b = BigInt::from_slice(Plus, b_vec);
let c = BigInt::from_slice(Plus, c_vec);

assert!(c.checked_sub(&a).unwrap() == b);
assert!(c.checked_sub(&b).unwrap() == a);
Expand All @@ -2689,10 +2689,10 @@ mod bigint_tests {
#[test]
fn test_checked_mul() {
for elm in mul_triples.iter() {
let (aVec, bVec, cVec) = *elm;
let a = BigInt::from_slice(Plus, aVec);
let b = BigInt::from_slice(Plus, bVec);
let c = BigInt::from_slice(Plus, cVec);
let (a_vec, b_vec, c_vec) = *elm;
let a = BigInt::from_slice(Plus, a_vec);
let b = BigInt::from_slice(Plus, b_vec);
let c = BigInt::from_slice(Plus, c_vec);

assert!(a.checked_mul(&b).unwrap() == c);
assert!(b.checked_mul(&a).unwrap() == c);
Expand All @@ -2702,11 +2702,11 @@ mod bigint_tests {
}

for elm in div_rem_quadruples.iter() {
let (aVec, bVec, cVec, dVec) = *elm;
let a = BigInt::from_slice(Plus, aVec);
let b = BigInt::from_slice(Plus, bVec);
let c = BigInt::from_slice(Plus, cVec);
let d = BigInt::from_slice(Plus, dVec);
let (a_vec, b_vec, c_vec, d_vec) = *elm;
let a = BigInt::from_slice(Plus, a_vec);
let b = BigInt::from_slice(Plus, b_vec);
let c = BigInt::from_slice(Plus, c_vec);
let d = BigInt::from_slice(Plus, d_vec);

assert!(a == b.checked_mul(&c).unwrap() + d);
assert!(a == c.checked_mul(&b).unwrap() + d);
Expand All @@ -2715,10 +2715,10 @@ mod bigint_tests {
#[test]
fn test_checked_div() {
for elm in mul_triples.iter() {
let (aVec, bVec, cVec) = *elm;
let a = BigInt::from_slice(Plus, aVec);
let b = BigInt::from_slice(Plus, bVec);
let c = BigInt::from_slice(Plus, cVec);
let (a_vec, b_vec, c_vec) = *elm;
let a = BigInt::from_slice(Plus, a_vec);
let b = BigInt::from_slice(Plus, b_vec);
let c = BigInt::from_slice(Plus, c_vec);

if !a.is_zero() {
assert!(c.checked_div(&a).unwrap() == b);
Expand Down

0 comments on commit 947a1b9

Please sign in to comment.