auto merge of #16768 : nham/rust/libcollections_test_cleanup, r=alexcrichton

unused imports.

This is mostly converting uses of `push_back`, `pop_back`, `shift` and `unshift` to `push`, `pop`, `remove` and `insert`.
This commit is contained in:
bors 2014-08-29 02:26:28 +00:00
commit dee8423531
4 changed files with 75 additions and 77 deletions

View File

@ -805,21 +805,21 @@ pub fn check_links<T>(list: &DList<T>) {
fn test_basic() {
let mut m: DList<Box<int>> = DList::new();
assert_eq!(m.pop_front(), None);
assert_eq!(m.pop_back(), None);
assert_eq!(m.pop(), None);
assert_eq!(m.pop_front(), None);
m.push_front(box 1);
assert_eq!(m.pop_front(), Some(box 1));
m.push_back(box 2);
m.push_back(box 3);
m.push(box 2);
m.push(box 3);
assert_eq!(m.len(), 2);
assert_eq!(m.pop_front(), Some(box 2));
assert_eq!(m.pop_front(), Some(box 3));
assert_eq!(m.len(), 0);
assert_eq!(m.pop_front(), None);
m.push_back(box 1);
m.push_back(box 3);
m.push_back(box 5);
m.push_back(box 7);
m.push(box 1);
m.push(box 3);
m.push(box 5);
m.push(box 7);
assert_eq!(m.pop_front(), Some(box 1));
let mut n = DList::new();
@ -856,19 +856,19 @@ fn test_append() {
{
let mut m = DList::new();
let mut n = DList::new();
n.push_back(2i);
n.push(2i);
m.append(n);
assert_eq!(m.len(), 1);
assert_eq!(m.pop_back(), Some(2));
assert_eq!(m.pop(), Some(2));
check_links(&m);
}
{
let mut m = DList::new();
let n = DList::new();
m.push_back(2i);
m.push(2i);
m.append(n);
assert_eq!(m.len(), 1);
assert_eq!(m.pop_back(), Some(2));
assert_eq!(m.pop(), Some(2));
check_links(&m);
}
@ -889,10 +889,10 @@ fn test_prepend() {
{
let mut m = DList::new();
let mut n = DList::new();
n.push_back(2i);
n.push(2i);
m.prepend(n);
assert_eq!(m.len(), 1);
assert_eq!(m.pop_back(), Some(2));
assert_eq!(m.pop(), Some(2));
check_links(&m);
}
@ -950,9 +950,9 @@ fn test_iterator() {
#[test]
fn test_iterator_clone() {
let mut n = DList::new();
n.push_back(2i);
n.push_back(3);
n.push_back(4);
n.push(2i);
n.push(3);
n.push(4);
let mut it = n.iter();
it.next();
let mut jt = it.clone();
@ -1007,7 +1007,7 @@ fn test_mut_iter() {
let mut n = DList::new();
assert!(n.mut_iter().next().is_none());
n.push_front(4i);
n.push_back(5);
n.push(5);
let mut it = n.mut_iter();
assert_eq!(it.size_hint(), (2, Some(2)));
assert!(it.next().is_some());
@ -1081,8 +1081,8 @@ fn test_insert_ordered() {
assert_eq!(n.pop_front(), Some(1));
let mut m = DList::new();
m.push_back(2i);
m.push_back(4);
m.push(2i);
m.push(4);
m.insert_ordered(3);
check_links(&m);
assert_eq!(vec![2,3,4], m.move_iter().collect::<Vec<int>>());
@ -1119,7 +1119,7 @@ fn test_eq() {
assert!(n == m);
n.push_front(1);
assert!(n != m);
m.push_back(1);
m.push(1);
assert!(n == m);
let n = list_from([2i,3,4]);
@ -1134,9 +1134,9 @@ fn test_hash() {
assert!(hash::hash(&x) == hash::hash(&y));
x.push_back(1i);
x.push_back(2);
x.push_back(3);
x.push(1i);
x.push(2);
x.push(3);
y.push_front(3i);
y.push_front(2);
@ -1216,19 +1216,19 @@ fn fuzz_test(sz: int) {
let r: u8 = rand::random();
match r % 6 {
0 => {
m.pop_back();
m.pop();
v.pop();
}
1 => {
m.pop_front();
v.shift();
v.remove(0);
}
2 | 4 => {
m.push_front(-i);
v.unshift(-i);
v.insert(0, -i);
}
3 | 5 | _ => {
m.push_back(i);
m.push(i);
v.push(i);
}
}
@ -1264,7 +1264,7 @@ fn bench_push_front(b: &mut test::Bencher) {
fn bench_push_back(b: &mut test::Bencher) {
let mut m: DList<int> = DList::new();
b.iter(|| {
m.push_back(0);
m.push(0);
})
}
@ -1272,8 +1272,8 @@ fn bench_push_back(b: &mut test::Bencher) {
fn bench_push_back_pop_back(b: &mut test::Bencher) {
let mut m: DList<int> = DList::new();
b.iter(|| {
m.push_back(0);
m.pop_back();
m.push(0);
m.pop();
})
}

View File

@ -293,7 +293,6 @@ fn hash(&self, state: &mut S) {
#[cfg(test)]
mod tests {
use std::prelude::*;
use std::mem;
use slice::ImmutableSlice;

View File

@ -560,9 +560,9 @@ fn test_simple() {
assert_eq!(d.len(), 0u);
d.push_front(17i);
d.push_front(42i);
d.push_back(137);
d.push(137);
assert_eq!(d.len(), 3u);
d.push_back(137);
d.push(137);
assert_eq!(d.len(), 4u);
debug!("{:?}", d.front());
assert_eq!(*d.front().unwrap(), 42);
@ -571,21 +571,21 @@ fn test_simple() {
let mut i = d.pop_front();
debug!("{:?}", i);
assert_eq!(i, Some(42));
i = d.pop_back();
i = d.pop();
debug!("{:?}", i);
assert_eq!(i, Some(137));
i = d.pop_back();
i = d.pop();
debug!("{:?}", i);
assert_eq!(i, Some(137));
i = d.pop_back();
i = d.pop();
debug!("{:?}", i);
assert_eq!(i, Some(17));
assert_eq!(d.len(), 0u);
d.push_back(3);
d.push(3);
assert_eq!(d.len(), 1u);
d.push_front(2);
assert_eq!(d.len(), 2u);
d.push_back(4);
d.push(4);
assert_eq!(d.len(), 3u);
d.push_front(1);
assert_eq!(d.len(), 4u);
@ -610,22 +610,22 @@ fn test_boxes() {
assert_eq!(deq.len(), 0);
deq.push_front(a);
deq.push_front(b);
deq.push_back(c);
deq.push(c);
assert_eq!(deq.len(), 3);
deq.push_back(d);
deq.push(d);
assert_eq!(deq.len(), 4);
assert_eq!(deq.front(), Some(&b));
assert_eq!(deq.back(), Some(&d));
assert_eq!(deq.pop_front(), Some(b));
assert_eq!(deq.pop_back(), Some(d));
assert_eq!(deq.pop_back(), Some(c));
assert_eq!(deq.pop_back(), Some(a));
assert_eq!(deq.pop(), Some(d));
assert_eq!(deq.pop(), Some(c));
assert_eq!(deq.pop(), Some(a));
assert_eq!(deq.len(), 0);
deq.push_back(c);
deq.push(c);
assert_eq!(deq.len(), 1);
deq.push_front(b);
assert_eq!(deq.len(), 2);
deq.push_back(d);
deq.push(d);
assert_eq!(deq.len(), 3);
deq.push_front(a);
assert_eq!(deq.len(), 4);
@ -641,22 +641,22 @@ fn test_parameterized<T:Clone + PartialEq + Show>(a: T, b: T, c: T, d: T) {
assert_eq!(deq.len(), 0);
deq.push_front(a.clone());
deq.push_front(b.clone());
deq.push_back(c.clone());
deq.push(c.clone());
assert_eq!(deq.len(), 3);
deq.push_back(d.clone());
deq.push(d.clone());
assert_eq!(deq.len(), 4);
assert_eq!((*deq.front().unwrap()).clone(), b.clone());
assert_eq!((*deq.back().unwrap()).clone(), d.clone());
assert_eq!(deq.pop_front().unwrap(), b.clone());
assert_eq!(deq.pop_back().unwrap(), d.clone());
assert_eq!(deq.pop_back().unwrap(), c.clone());
assert_eq!(deq.pop_back().unwrap(), a.clone());
assert_eq!(deq.pop().unwrap(), d.clone());
assert_eq!(deq.pop().unwrap(), c.clone());
assert_eq!(deq.pop().unwrap(), a.clone());
assert_eq!(deq.len(), 0);
deq.push_back(c.clone());
deq.push(c.clone());
assert_eq!(deq.len(), 1);
deq.push_front(b.clone());
assert_eq!(deq.len(), 2);
deq.push_back(d.clone());
deq.push(d.clone());
assert_eq!(deq.len(), 3);
deq.push_front(a.clone());
assert_eq!(deq.len(), 4);
@ -680,7 +680,7 @@ fn test_push_front_grow() {
let mut deq = RingBuf::new();
for i in range(0u, 66) {
deq.push_back(i);
deq.push(i);
}
for i in range(0u, 66) {
@ -718,7 +718,7 @@ fn bench_new(b: &mut test::Bencher) {
fn bench_push_back(b: &mut test::Bencher) {
let mut deq = RingBuf::new();
b.iter(|| {
deq.push_back(0i);
deq.push(0i);
})
}
@ -797,10 +797,10 @@ fn test_param_reccy() {
#[test]
fn test_with_capacity() {
let mut d = RingBuf::with_capacity(0);
d.push_back(1i);
d.push(1i);
assert_eq!(d.len(), 1);
let mut d = RingBuf::with_capacity(50);
d.push_back(1i);
d.push(1i);
assert_eq!(d.len(), 1);
}
@ -848,11 +848,11 @@ fn test_with_capacity_non_power_two() {
#[test]
fn test_reserve_exact() {
let mut d = RingBuf::new();
d.push_back(0u64);
d.push(0u64);
d.reserve_exact(50);
assert_eq!(d.elts.capacity(), 50);
let mut d = RingBuf::new();
d.push_back(0u32);
d.push(0u32);
d.reserve_exact(50);
assert_eq!(d.elts.capacity(), 50);
}
@ -860,11 +860,11 @@ fn test_reserve_exact() {
#[test]
fn test_reserve() {
let mut d = RingBuf::new();
d.push_back(0u64);
d.push(0u64);
d.reserve(50);
assert_eq!(d.elts.capacity(), 64);
let mut d = RingBuf::new();
d.push_back(0u32);
d.push(0u32);
d.reserve(50);
assert_eq!(d.elts.capacity(), 64);
}
@ -884,7 +884,7 @@ fn test_iter() {
assert_eq!(d.iter().size_hint(), (0, Some(0)));
for i in range(0i, 5) {
d.push_back(i);
d.push(i);
}
{
let b: &[_] = &[&0,&1,&2,&3,&4];
@ -915,7 +915,7 @@ fn test_rev_iter() {
assert_eq!(d.iter().rev().next(), None);
for i in range(0i, 5) {
d.push_back(i);
d.push(i);
}
{
let b: &[_] = &[&4,&3,&2,&1,&0];
@ -934,11 +934,11 @@ fn test_mut_rev_iter_wrap() {
let mut d = RingBuf::with_capacity(3);
assert!(d.mut_iter().rev().next().is_none());
d.push_back(1i);
d.push_back(2);
d.push_back(3);
d.push(1i);
d.push(2);
d.push(3);
assert_eq!(d.pop_front(), Some(1));
d.push_back(4);
d.push(4);
assert_eq!(d.mut_iter().rev().map(|x| *x).collect::<Vec<int>>(),
vec!(4, 3, 2));
@ -1011,13 +1011,13 @@ fn test_clone() {
let mut d = RingBuf::new();
d.push_front(17i);
d.push_front(42);
d.push_back(137);
d.push_back(137);
d.push(137);
d.push(137);
assert_eq!(d.len(), 4u);
let mut e = d.clone();
assert_eq!(e.len(), 4u);
while !d.is_empty() {
assert_eq!(d.pop_back(), e.pop_back());
assert_eq!(d.pop(), e.pop());
}
assert_eq!(d.len(), 0u);
assert_eq!(e.len(), 0u);
@ -1030,15 +1030,15 @@ fn test_eq() {
d.push_front(137i);
d.push_front(17);
d.push_front(42);
d.push_back(137);
d.push(137);
let mut e = RingBuf::with_capacity(0);
e.push_back(42);
e.push_back(17);
e.push_back(137);
e.push_back(137);
e.push(42);
e.push(17);
e.push(137);
e.push(137);
assert!(&e == &d);
e.pop_back();
e.push_back(0);
e.pop();
e.push(0);
assert!(e != d);
e.clear();
assert!(e == RingBuf::new());

View File

@ -2374,7 +2374,6 @@ mod bench {
use test::Bencher;
use test::black_box;
use super::*;
use std::option::{None, Some};
use std::iter::{Iterator, DoubleEndedIterator};
use std::collections::Collection;