Skip to content

Commit

Permalink
Use assert_eq! rather than assert! where possible
Browse files Browse the repository at this point in the history
  • Loading branch information
emberian committed May 19, 2013
1 parent 3acf378 commit cc57ca0
Show file tree
Hide file tree
Showing 641 changed files with 2,831 additions and 2,831 deletions.
26 changes: 13 additions & 13 deletions src/libcore/at_vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,30 +294,30 @@ mod test {
}

assert_eq!(seq_range(10, 15), @[10, 11, 12, 13, 14]);
assert!(from_fn(5, |x| x+1) == @[1, 2, 3, 4, 5]);
assert!(from_elem(5, 3.14) == @[3.14, 3.14, 3.14, 3.14, 3.14]);
assert_eq!(from_fn(5, |x| x+1), @[1, 2, 3, 4, 5]);
assert_eq!(from_elem(5, 3.14), @[3.14, 3.14, 3.14, 3.14, 3.14]);
}

#[test]
fn append_test() {
assert!(@[1,2,3] + @[4,5,6] == @[1,2,3,4,5,6]);
assert_eq!(@[1,2,3] + @[4,5,6], @[1,2,3,4,5,6]);
}

#[test]
fn test_to_managed_consume() {
assert!(to_managed_consume::<int>(~[]) == @[]);
assert!(to_managed_consume(~[true]) == @[true]);
assert!(to_managed_consume(~[1, 2, 3, 4, 5]) == @[1, 2, 3, 4, 5]);
assert!(to_managed_consume(~[~"abc", ~"123"]) == @[~"abc", ~"123"]);
assert!(to_managed_consume(~[~[42]]) == @[~[42]]);
assert_eq!(to_managed_consume::<int>(~[]), @[]);
assert_eq!(to_managed_consume(~[true]), @[true]);
assert_eq!(to_managed_consume(~[1, 2, 3, 4, 5]), @[1, 2, 3, 4, 5]);
assert_eq!(to_managed_consume(~[~"abc", ~"123"]), @[~"abc", ~"123"]);
assert_eq!(to_managed_consume(~[~[42]]), @[~[42]]);
}

#[test]
fn test_to_managed() {
assert!(to_managed::<int>([]) == @[]);
assert!(to_managed([true]) == @[true]);
assert!(to_managed([1, 2, 3, 4, 5]) == @[1, 2, 3, 4, 5]);
assert!(to_managed([@"abc", @"123"]) == @[@"abc", @"123"]);
assert!(to_managed([@[42]]) == @[@[42]]);
assert_eq!(to_managed::<int>([]), @[]);
assert_eq!(to_managed([true]), @[true]);
assert_eq!(to_managed([1, 2, 3, 4, 5]), @[1, 2, 3, 4, 5]);
assert_eq!(to_managed([@"abc", @"123"]), @[@"abc", @"123"]);
assert_eq!(to_managed([@[42]]), @[@[42]]);
}
}
6 changes: 3 additions & 3 deletions src/libcore/bool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,14 @@ mod tests {

#[test]
fn test_bool_to_str() {
assert!(to_str(false) == ~"false");
assert!(to_str(true) == ~"true");
assert_eq!(to_str(false), ~"false");
assert_eq!(to_str(true), ~"true");
}

#[test]
fn test_bool_to_bit() {
do all_values |v| {
assert!(to_bit(v) == if is_true(v) { 1u8 } else { 0u8 });
assert_eq!(to_bit(v), if is_true(v) { 1u8 } else { 0u8 });
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/libcore/cast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ mod tests {

#[test]
fn test_transmute_copy() {
assert!(1u == unsafe { ::cast::transmute_copy(&1) });
assert_eq!(1u, unsafe { ::cast::transmute_copy(&1) });
}

#[test]
Expand Down Expand Up @@ -177,7 +177,7 @@ mod tests {
#[test]
fn test_transmute2() {
unsafe {
assert!(~[76u8, 0u8] == transmute(~"L"));
assert_eq!(~[76u8, 0u8], transmute(~"L"));
}
}
}
4 changes: 2 additions & 2 deletions src/libcore/cell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ fn test_with_ref() {
let good = 6;
let c = Cell(~[1, 2, 3, 4, 5, 6]);
let l = do c.with_ref() |v| { v.len() };
assert!(l == good);
assert_eq!(l, good);
}

#[test]
Expand All @@ -132,5 +132,5 @@ fn test_with_mut_ref() {
let c = Cell(v);
do c.with_mut_ref() |v| { v.push(3); }
let v = c.take();
assert!(v == good);
assert_eq!(v, good);
}
8 changes: 4 additions & 4 deletions src/libcore/clone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,14 +146,14 @@ deep_clone_impl!(char)
fn test_owned_clone() {
let a = ~5i;
let b: ~int = a.clone();
assert!(a == b);
assert_eq!(a, b);
}

#[test]
fn test_managed_clone() {
let a = @5i;
let b: @int = a.clone();
assert!(a == b);
assert_eq!(a, b);
}

#[test]
Expand All @@ -168,9 +168,9 @@ fn test_managed_mut_deep_clone() {
fn test_managed_mut_clone() {
let a = @mut 5i;
let b: @mut int = a.clone();
assert!(a == b);
assert_eq!(a, b);
*b = 10;
assert!(a == b);
assert_eq!(a, b);
}

#[test]
Expand Down
8 changes: 4 additions & 4 deletions src/libcore/hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ mod tests {
let vec = u8to64_le!(vecs[t], 0);
let out = buf.hash_keyed(k0, k1);
debug!("got %?, expected %?", out, vec);
assert!(vec == out);
assert_eq!(vec, out);

stream_full.reset();
stream_full.input(buf);
Expand All @@ -512,19 +512,19 @@ mod tests {
fn test_hash_uint() {
let val = 0xdeadbeef_deadbeef_u64;
assert!((val as u64).hash() != (val as uint).hash());
assert!((val as u32).hash() == (val as uint).hash());
assert_eq!((val as u32).hash(), (val as uint).hash());
}
#[test] #[cfg(target_arch = "x86_64")]
fn test_hash_uint() {
let val = 0xdeadbeef_deadbeef_u64;
assert!((val as u64).hash() == (val as uint).hash());
assert_eq!((val as u64).hash(), (val as uint).hash());
assert!((val as u32).hash() != (val as uint).hash());
}
#[test] #[cfg(target_arch = "x86")]
fn test_hash_uint() {
let val = 0xdeadbeef_deadbeef_u64;
assert!((val as u64).hash() != (val as uint).hash());
assert!((val as u32).hash() == (val as uint).hash());
assert_eq!((val as u32).hash(), (val as uint).hash());
}

#[test]
Expand Down
62 changes: 31 additions & 31 deletions src/libcore/hashmap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -842,8 +842,8 @@ mod test_map {
let mut m = HashMap::new();
assert!(m.insert(1, 2));
assert!(m.insert(2, 4));
assert!(*m.get(&1) == 2);
assert!(*m.get(&2) == 4);
assert_eq!(*m.get(&1), 2);
assert_eq!(*m.get(&2), 4);
}

#[test]
Expand All @@ -863,9 +863,9 @@ mod test_map {
fn test_insert_overwrite() {
let mut m = HashMap::new();
assert!(m.insert(1, 2));
assert!(*m.get(&1) == 2);
assert_eq!(*m.get(&1), 2);
assert!(!m.insert(1, 3));
assert!(*m.get(&1) == 3);
assert_eq!(*m.get(&1), 3);
}

#[test]
Expand All @@ -874,9 +874,9 @@ mod test_map {
assert!(m.insert(1, 2));
assert!(m.insert(5, 3));
assert!(m.insert(9, 4));
assert!(*m.get(&9) == 4);
assert!(*m.get(&5) == 3);
assert!(*m.get(&1) == 2);
assert_eq!(*m.get(&9), 4);
assert_eq!(*m.get(&5), 3);
assert_eq!(*m.get(&1), 2);
}

#[test]
Expand All @@ -886,8 +886,8 @@ mod test_map {
assert!(m.insert(5, 3));
assert!(m.insert(9, 4));
assert!(m.remove(&1));
assert!(*m.get(&9) == 4);
assert!(*m.get(&5) == 3);
assert_eq!(*m.get(&9), 4);
assert_eq!(*m.get(&5), 3);
}

#[test]
Expand All @@ -903,30 +903,30 @@ mod test_map {
fn test_pop() {
let mut m = HashMap::new();
m.insert(1, 2);
assert!(m.pop(&1) == Some(2));
assert!(m.pop(&1) == None);
assert_eq!(m.pop(&1), Some(2));
assert_eq!(m.pop(&1), None);
}

#[test]
fn test_swap() {
let mut m = HashMap::new();
assert!(m.swap(1, 2) == None);
assert!(m.swap(1, 3) == Some(2));
assert!(m.swap(1, 4) == Some(3));
assert_eq!(m.swap(1, 2), None);
assert_eq!(m.swap(1, 3), Some(2));
assert_eq!(m.swap(1, 4), Some(3));
}

#[test]
fn test_find_or_insert() {
let mut m = HashMap::new::<int, int>();
assert!(m.find_or_insert(1, 2) == &2);
assert!(m.find_or_insert(1, 3) == &2);
assert_eq!(m.find_or_insert(1, 2), &2);
assert_eq!(m.find_or_insert(1, 3), &2);
}

#[test]
fn test_find_or_insert_with() {
let mut m = HashMap::new::<int, int>();
assert!(m.find_or_insert_with(1, |_| 2) == &2);
assert!(m.find_or_insert_with(1, |_| 3) == &2);
assert_eq!(m.find_or_insert_with(1, |_| 2), &2);
assert_eq!(m.find_or_insert_with(1, |_| 3), &2);
}

#[test]
Expand All @@ -938,10 +938,10 @@ mod test_map {
do m.consume |k, v| {
m2.insert(k, v);
}
assert!(m.len() == 0);
assert!(m2.len() == 2);
assert!(m2.get(&1) == &2);
assert!(m2.get(&2) == &3);
assert_eq!(m.len(), 0);
assert_eq!(m2.len(), 2);
assert_eq!(m2.get(&1), &2);
assert_eq!(m2.get(&2), &3);
}

#[test]
Expand All @@ -952,10 +952,10 @@ mod test_map {
}
let mut observed = 0;
for m.each |k, v| {
assert!(*v == *k * 2);
assert_eq!(*v, *k * 2);
observed |= (1 << *k);
}
assert!(observed == 0xFFFF_FFFF);
assert_eq!(observed, 0xFFFF_FFFF);
}

#[test]
Expand Down Expand Up @@ -984,14 +984,14 @@ mod test_map {

m2.insert(3, 4);

assert!(m1 == m2);
assert_eq!(m1, m2);
}

#[test]
fn test_expand() {
let mut m = HashMap::new();

assert!(m.len() == 0);
assert_eq!(m.len(), 0);
assert!(m.is_empty());

let mut i = 0u;
Expand All @@ -1001,7 +1001,7 @@ mod test_map {
i += 1;
}

assert!(m.len() == i);
assert_eq!(m.len(), i);
assert!(!m.is_empty());
}
}
Expand Down Expand Up @@ -1090,7 +1090,7 @@ mod test_set {
assert!(vec::contains(expected, x));
i += 1
}
assert!(i == expected.len());
assert_eq!(i, expected.len());
}

#[test]
Expand All @@ -1113,7 +1113,7 @@ mod test_set {
assert!(vec::contains(expected, x));
i += 1
}
assert!(i == expected.len());
assert_eq!(i, expected.len());
}

#[test]
Expand All @@ -1139,7 +1139,7 @@ mod test_set {
assert!(vec::contains(expected, x));
i += 1
}
assert!(i == expected.len());
assert_eq!(i, expected.len());
}

#[test]
Expand Down Expand Up @@ -1169,6 +1169,6 @@ mod test_set {
assert!(vec::contains(expected, x));
i += 1
}
assert!(i == expected.len());
assert_eq!(i, expected.len());
}
}
Loading

5 comments on commit cc57ca0

@bors
Copy link
Contributor

@bors bors commented on cc57ca0 May 19, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors
Copy link
Contributor

@bors bors commented on cc57ca0 May 19, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging cmr/rust/assert_eq = cc57ca0 into auto

@bors
Copy link
Contributor

@bors bors commented on cc57ca0 May 19, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cmr/rust/assert_eq = cc57ca0 merged ok, testing candidate = 5cbdc53

@bors
Copy link
Contributor

@bors bors commented on cc57ca0 May 19, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors
Copy link
Contributor

@bors bors commented on cc57ca0 May 19, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding incoming to auto = 5cbdc53

Please sign in to comment.