Skip to content

Commit

Permalink
Use assert_eq! instead of assert! in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
petrochenkov committed Jun 13, 2015
1 parent a9f1e29 commit bddb685
Show file tree
Hide file tree
Showing 150 changed files with 396 additions and 383 deletions.
16 changes: 8 additions & 8 deletions src/test/auxiliary/extern_calling_convention.rs
Expand Up @@ -14,10 +14,10 @@
#[inline(never)]
#[cfg(target_arch = "x86_64")]
pub extern "win64" fn foo(a: isize, b: isize, c: isize, d: isize) {
assert!(a == 1);
assert!(b == 2);
assert!(c == 3);
assert!(d == 4);
assert_eq!(a, 1);
assert_eq!(b, 2);
assert_eq!(c, 3);
assert_eq!(d, 4);

println!("a: {}, b: {}, c: {}, d: {}",
a, b, c, d)
Expand All @@ -26,10 +26,10 @@ pub extern "win64" fn foo(a: isize, b: isize, c: isize, d: isize) {
#[inline(never)]
#[cfg(any(target_arch = "x86", target_arch = "arm", target_arch = "aarch64"))]
pub extern fn foo(a: isize, b: isize, c: isize, d: isize) {
assert!(a == 1);
assert!(b == 2);
assert!(c == 3);
assert!(d == 4);
assert_eq!(a, 1);
assert_eq!(b, 2);
assert_eq!(c, 3);
assert_eq!(d, 4);

println!("a: {}, b: {}, c: {}, d: {}",
a, b, c, d)
Expand Down
4 changes: 2 additions & 2 deletions src/test/bench/shootout-mandelbrot.rs
Expand Up @@ -54,7 +54,7 @@ const LIMIT: f64 = 2.0;
const WORKERS: usize = 16;

fn mandelbrot<W: Write>(w: usize, mut out: W) -> io::Result<()> {
assert!(WORKERS % 2 == 0);
assert_eq!(WORKERS % 2, 0);

// Ensure w and h are multiples of 8.
let w = (w + 7) / 8 * 8;
Expand All @@ -76,7 +76,7 @@ fn mandelbrot<W: Write>(w: usize, mut out: W) -> io::Result<()> {
let v_consts = f64x2(1.5, 1.0);

// A lot of this code assumes this (so do other lang benchmarks)
assert!(w == h);
assert_eq!(w, h);
let mut precalc_r = Vec::with_capacity(w);
let mut precalc_i = Vec::with_capacity(h);

Expand Down
2 changes: 1 addition & 1 deletion src/test/compile-fail/builtin-superkinds-self-type.rs
Expand Up @@ -23,5 +23,5 @@ impl <T: Sync> Foo for T { }
fn main() {
let (tx, rx) = channel();
1193182.foo(tx);
assert!(rx.recv() == 1193182);
assert_eq!(rx.recv(), 1193182);
}
6 changes: 3 additions & 3 deletions src/test/compile-fail/match-static-const-lc.rs
Expand Up @@ -22,7 +22,7 @@ fn f() {
//~^ ERROR constant in pattern `a` should have an upper case name such as `A`
(x, y) => 1 + x + y,
};
assert!(r == 1);
assert_eq!(r, 1);
}

mod m {
Expand All @@ -37,7 +37,7 @@ fn g() {
//~^ ERROR constant in pattern `aha` should have an upper case name such as `AHA`
(x, y) => 1 + x + y,
};
assert!(r == 1);
assert_eq!(r, 1);
}

mod n {
Expand All @@ -51,7 +51,7 @@ fn h() {
//~^ ERROR constant in pattern `not_okay` should have an upper case name such as `NOT_OKAY`
(x, y) => 1 + x + y,
};
assert!(r == 1);
assert_eq!(r, 1);
}

fn main () {
Expand Down
2 changes: 1 addition & 1 deletion src/test/compile-fail/mod_file_correct_spans.rs
Expand Up @@ -13,5 +13,5 @@
mod mod_file_aux;

fn main() {
assert!(mod_file_aux::bar() == 10); //~ ERROR unresolved name
assert_eq!(mod_file_aux::bar(), 10); //~ ERROR unresolved name
}
2 changes: 1 addition & 1 deletion src/test/compile-fail/private-struct-field-cross-crate.rs
Expand Up @@ -14,6 +14,6 @@ use cci_class::kitties::cat;

fn main() {
let nyan : cat = cat(52, 99);
assert!((nyan.meows == 52));
assert_eq!(nyan.meows, 52);
//~^ ERROR field `meows` of struct `cci_class::kitties::cat` is private
}
2 changes: 1 addition & 1 deletion src/test/compile-fail/private-struct-field.rs
Expand Up @@ -20,5 +20,5 @@ mod cat {

fn main() {
let nyan = cat::new_cat();
assert!(nyan.meows == 52); //~ ERROR field `meows` of struct `cat::Cat` is private
assert_eq!(nyan.meows, 52); //~ ERROR field `meows` of struct `cat::Cat` is private
}
3 changes: 1 addition & 2 deletions src/test/compile-fail/syntax-extension-minor.rs
Expand Up @@ -17,6 +17,5 @@ pub fn main() {
assert_eq!(concat_idents!(asd, f_f, dsa), "<.<".to_string());
//~^ ERROR: unresolved name `asdf_fdsa`

assert!(stringify!(use_mention_distinction) ==
"use_mention_distinction");
assert_eq!(stringify!(use_mention_distinction), "use_mention_distinction");
}
4 changes: 2 additions & 2 deletions src/test/parse-fail/macros-no-semicolon.rs
Expand Up @@ -11,7 +11,7 @@
// compile-flags: -Z parse-only

fn main() {
assert!(1 == 2)
assert!(3 == 4) //~ ERROR expected one of `.`, `;`, `}`, or an operator, found `assert`
assert_eq!(1, 2)
assert_eq!(3, 4) //~ ERROR expected one of `.`, `;`, `}`, or an operator, found `assert_eq`
println!("hello");
}
2 changes: 1 addition & 1 deletion src/test/pretty/do1.rs
Expand Up @@ -12,4 +12,4 @@

fn f<F>(f: F) where F: Fn(isize) { f(10) }

fn main() { f(|i| { assert!(i == 10) }) }
fn main() { f(|i| { assert_eq!(i , 10) }) }
2 changes: 1 addition & 1 deletion src/test/run-fail/panic.rs
Expand Up @@ -9,4 +9,4 @@
// except according to those terms.

// error-pattern:1 == 2
fn main() { assert!((1 == 2)); }
fn main() { assert!(1 == 2); }
2 changes: 1 addition & 1 deletion src/test/run-make/extern-flag-disambiguates/d.rs
Expand Up @@ -16,6 +16,6 @@ extern crate c;
fn t(a: &'static usize) -> usize { a as *const _ as usize }

fn main() {
assert!(t(a::token()) == t(b::a_token()));
assert_eq!(t(a::token()), t(b::a_token()));
assert!(t(a::token()) != t(c::a_token()));
}
4 changes: 2 additions & 2 deletions src/test/run-make/static-unwinding/main.rs
Expand Up @@ -28,7 +28,7 @@ fn main() {
}).join().err().unwrap();

unsafe {
assert!(lib::statik == 1);
assert!(statik == 1);
assert_eq!(lib::statik, 1);
assert_eq!(statik, 1);
}
}
2 changes: 1 addition & 1 deletion src/test/run-pass-fulldeps/compiler-calls.rs
Expand Up @@ -78,5 +78,5 @@ fn main() {
// we should never get use this filename, but lets make sure they are valid args.
let args = vec!["compiler-calls".to_string(), "foo.rs".to_string()];
rustc_driver::run_compiler(&args, &mut tc);
assert!(tc.count == 30);
assert_eq!(tc.count, 30);
}
2 changes: 1 addition & 1 deletion src/test/run-pass-valgrind/dst-dtor-2.rs
Expand Up @@ -27,6 +27,6 @@ pub fn main() {
let _x: Box<Fat<[Foo]>> = Box::<Fat<[Foo; 3]>>::new(Fat { f: [Foo, Foo, Foo] });
}
unsafe {
assert!(DROP_RAN == 3);
assert_eq!(DROP_RAN, 3);
}
}
2 changes: 1 addition & 1 deletion src/test/run-pass/arith-2.rs
Expand Up @@ -13,6 +13,6 @@

pub fn main() {
let i32_c: isize = 0x10101010;
assert!(i32_c + i32_c * 2 / 3 * 2 + (i32_c - 7 % 3) ==
assert_eq!(i32_c + i32_c * 2 / 3 * 2 + (i32_c - 7 % 3),
i32_c + i32_c * 2 / 3 * 2 + (i32_c - 7 % 3));
}
2 changes: 1 addition & 1 deletion src/test/run-pass/artificial-block.rs
Expand Up @@ -11,4 +11,4 @@

fn f() -> isize { { return 3; } }

pub fn main() { assert!((f() == 3)); }
pub fn main() { assert_eq!(f(), 3); }
2 changes: 1 addition & 1 deletion src/test/run-pass/assignability-trait.rs
Expand Up @@ -43,7 +43,7 @@ fn length<A, T: iterable<A>>(x: T) -> usize {
pub fn main() {
let x: Vec<isize> = vec!(0,1,2,3);
// Call a method
x.iterate(|y| { assert!(x[*y as usize] == *y); true });
x.iterate(|y| { assert_eq!(x[*y as usize], *y); true });
// Call a parameterized function
assert_eq!(length(x.clone()), x.len());
// Call a parameterized function, with type arguments that require
Expand Down
8 changes: 4 additions & 4 deletions src/test/run-pass/associated-types-return.rs
Expand Up @@ -16,7 +16,7 @@ pub trait Foo {
fn boo(&self) -> <Self as Foo>::A;
}

#[derive(PartialEq)]
#[derive(PartialEq, Debug)]
pub struct Bar;

impl Foo for isize {
Expand Down Expand Up @@ -44,12 +44,12 @@ fn foo2<I: Foo>(x: I) -> <I as Foo>::A {

pub fn main() {
let a = 42;
assert!(foo2(a) == 42);
assert_eq!(foo2(a), 42);

let a = Bar;
assert!(foo2(a) == 43);
assert_eq!(foo2(a), 43);

let a = 'a';
foo1(a);
assert!(foo2(a) == Bar);
assert_eq!(foo2(a), Bar);
}
8 changes: 4 additions & 4 deletions src/test/run-pass/bool.rs
Expand Up @@ -74,8 +74,8 @@ fn main() {
assert!(true >= false);
assert!(!(true <= false));

assert!(true.cmp(&true) == Equal);
assert!(false.cmp(&false) == Equal);
assert!(true.cmp(&false) == Greater);
assert!(false.cmp(&true) == Less);
assert_eq!(true.cmp(&true), Equal);
assert_eq!(false.cmp(&false), Equal);
assert_eq!(true.cmp(&false), Greater);
assert_eq!(false.cmp(&true), Less);
}
Expand Up @@ -30,5 +30,5 @@ fn foo<T: Foo + 'static>(val: T, chan: Sender<T>) {
pub fn main() {
let (tx, rx) = channel();
foo(31337, tx);
assert!(rx.recv().unwrap() == 31337);
assert_eq!(rx.recv().unwrap(), 31337);
}
4 changes: 2 additions & 2 deletions src/test/run-pass/builtin-superkinds-capabilities-xc.rs
Expand Up @@ -20,7 +20,7 @@ extern crate trait_superkinds_in_metadata;
use std::sync::mpsc::{channel, Sender, Receiver};
use trait_superkinds_in_metadata::{RequiresRequiresShareAndSend, RequiresShare};

#[derive(PartialEq)]
#[derive(PartialEq, Debug)]
struct X<T>(T);

impl <T: Sync> RequiresShare for X<T> { }
Expand All @@ -33,5 +33,5 @@ fn foo<T: RequiresRequiresShareAndSend + 'static>(val: T, chan: Sender<T>) {
pub fn main() {
let (tx, rx): (Sender<X<isize>>, Receiver<X<isize>>) = channel();
foo(X(31337), tx);
assert!(rx.recv().unwrap() == X(31337));
assert_eq!(rx.recv().unwrap(), X(31337));
}
2 changes: 1 addition & 1 deletion src/test/run-pass/builtin-superkinds-capabilities.rs
Expand Up @@ -26,5 +26,5 @@ fn foo<T: Foo + 'static>(val: T, chan: Sender<T>) {
pub fn main() {
let (tx, rx): (Sender<isize>, Receiver<isize>) = channel();
foo(31337, tx);
assert!(rx.recv().unwrap() == 31337);
assert_eq!(rx.recv().unwrap(), 31337);
}
2 changes: 1 addition & 1 deletion src/test/run-pass/builtin-superkinds-self-type.rs
Expand Up @@ -25,5 +25,5 @@ impl <T: Send + 'static> Foo for T { }
pub fn main() {
let (tx, rx) = channel();
1193182.foo(tx);
assert!(rx.recv().unwrap() == 1193182);
assert_eq!(rx.recv().unwrap(), 1193182);
}
2 changes: 1 addition & 1 deletion src/test/run-pass/c-stack-returning-int64.rs
Expand Up @@ -37,6 +37,6 @@ fn atoll(s: String) -> i64 {

pub fn main() {
assert_eq!(atol("1024".to_string()) * 10, atol("10240".to_string()));
assert!((atoll("11111111111111111".to_string()) * 10) ==
assert_eq!((atoll("11111111111111111".to_string()) * 10),
atoll("111111111111111110".to_string()));
}
2 changes: 1 addition & 1 deletion src/test/run-pass/cci_impl_exe.rs
Expand Up @@ -22,6 +22,6 @@ pub fn main() {

//let bt1 = sys::frame_address();
//println!("%?", bt1);
//assert!(bt0 == bt1);
//assert_eq!(bt0, bt1);
})
}
2 changes: 1 addition & 1 deletion src/test/run-pass/cci_iter_exe.rs
Expand Up @@ -17,6 +17,6 @@ pub fn main() {
//println!("%?", bt0);
cci_iter_lib::iter(&[1, 2, 3], |i| {
println!("{}", *i);
//assert!(bt0 == sys::rusti::frame_address(2));
//assert_eq!(bt0, sys::rusti::frame_address(2));
})
}
18 changes: 9 additions & 9 deletions src/test/run-pass/check-static-slice.rs
Expand Up @@ -28,14 +28,14 @@ static cf: isize = af[2];

fn main () {
let b: &[isize] = &[1, 2, 3];
assert!(ac == b);
assert!(ad == b);
assert!(af == b);
assert_eq!(ac, b);
assert_eq!(ad, b);
assert_eq!(af, b);

assert!(ca == 1);
assert!(cb == 2);
assert!(cc == 3);
assert!(cd == 1);
assert!(ce == 2);
assert!(cf == 3);
assert_eq!(ca, 1);
assert_eq!(cb, 2);
assert_eq!(cc, 3);
assert_eq!(cd, 1);
assert_eq!(ce, 2);
assert_eq!(cf, 3);
}
2 changes: 1 addition & 1 deletion src/test/run-pass/class-impl-very-parameterized-trait.rs
Expand Up @@ -104,7 +104,7 @@ impl<T> cat<T> {
pub fn main() {
let mut nyan: cat<String> = cat::new(0, 2, "nyan".to_string());
for _ in 1_usize..5 { nyan.speak(); }
assert!(*nyan.find(&1).unwrap() == "nyan".to_string());
assert_eq!(*nyan.find(&1).unwrap(), "nyan".to_string());
assert_eq!(nyan.find(&10), None);
let mut spotty: cat<cat_type> = cat::new(2, 57, cat_type::tuxedo);
for _ in 0_usize..6 { spotty.speak(); }
Expand Down
5 changes: 3 additions & 2 deletions src/test/run-pass/cmp-default.rs
Expand Up @@ -13,6 +13,7 @@ use std::cmp::Ordering;

// Test default methods in PartialOrd and PartialEq
//
#[derive(Debug)]
struct Fool(bool);

impl PartialEq for Fool {
Expand Down Expand Up @@ -74,8 +75,8 @@ pub fn main() {
assert!(RevInt(1) >= RevInt(2));
assert!(RevInt(1) >= RevInt(1));

assert!(Fool(true) == Fool(false));
assert_eq!(Fool(true), Fool(false));
assert!(Fool(true) != Fool(true));
assert!(Fool(false) != Fool(false));
assert!(Fool(false) == Fool(true));
assert_eq!(Fool(false), Fool(true));
}
2 changes: 1 addition & 1 deletion src/test/run-pass/const-big-enum.rs
Expand Up @@ -23,7 +23,7 @@ pub fn main() {
_ => panic!()
}
match Y {
Foo::Bar(s) => assert!(s == 2654435769),
Foo::Bar(s) => assert_eq!(s, 2654435769),
_ => panic!()
}
match Z {
Expand Down
2 changes: 1 addition & 1 deletion src/test/run-pass/const-enum-structlike.rs
Expand Up @@ -19,6 +19,6 @@ static C: E = E::S1 { u: 23 };
pub fn main() {
match C {
E::S0 { .. } => panic!(),
E::S1 { u } => assert!(u == 23)
E::S1 { u } => assert_eq!(u, 23)
}
}
4 changes: 2 additions & 2 deletions src/test/run-pass/const-enum-vec-index.rs
Expand Up @@ -23,7 +23,7 @@ pub fn main() {
_ => panic!()
}
match C1 {
E::V1(n) => assert!(n == 0xDEADBEE),
E::V1(n) => assert_eq!(n, 0xDEADBEE),
_ => panic!()
}

Expand All @@ -32,7 +32,7 @@ pub fn main() {
_ => panic!()
}
match D1 {
E::V1(n) => assert!(n == 0xDEADBEE),
E::V1(n) => assert_eq!(n, 0xDEADBEE),
_ => panic!()
}
}
2 changes: 1 addition & 1 deletion src/test/run-pass/const-enum-vec-ptr.rs
Expand Up @@ -14,7 +14,7 @@ static C: &'static [E] = &[E::V0, E::V1(0xDEADBEE), E::V0];

pub fn main() {
match C[1] {
E::V1(n) => assert!(n == 0xDEADBEE),
E::V1(n) => assert_eq!(n, 0xDEADBEE),
_ => panic!()
}
match C[2] {
Expand Down
2 changes: 1 addition & 1 deletion src/test/run-pass/const-enum-vector.rs
Expand Up @@ -14,7 +14,7 @@ static C: [E; 3] = [E::V0, E::V1(0xDEADBEE), E::V0];

pub fn main() {
match C[1] {
E::V1(n) => assert!(n == 0xDEADBEE),
E::V1(n) => assert_eq!(n, 0xDEADBEE),
_ => panic!()
}
match C[2] {
Expand Down

0 comments on commit bddb685

Please sign in to comment.