Skip to content

Commit

Permalink
avoid "==" in assert! when one of the values is a bool
Browse files Browse the repository at this point in the history
  • Loading branch information
tshepang committed Apr 6, 2016
1 parent 7ded11a commit 922e666
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/libcore/ptr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ impl<T: ?Sized> *const T {
/// ```
/// let s: &str = "Follow the rabbit";
/// let ptr: *const u8 = s.as_ptr();
/// assert!(ptr.is_null() == false);
/// assert!(!ptr.is_null());
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
Expand Down Expand Up @@ -306,7 +306,7 @@ impl<T: ?Sized> *mut T {
/// ```
/// let mut s = [1, 2, 3];
/// let ptr: *mut u32 = s.as_mut_ptr();
/// assert!(ptr.is_null() == false);
/// assert!(!ptr.is_null());
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1708,7 +1708,7 @@ mod tests {
let tmpdir = tmpdir();
let dir = &tmpdir.join("fileinfo_false_on_dir");
check!(fs::create_dir(dir));
assert!(dir.is_file() == false);
assert!(!dir.is_file());
check!(fs::remove_dir(dir));
}

Expand Down
2 changes: 1 addition & 1 deletion src/libtest/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1509,7 +1509,7 @@ mod tests {

assert_eq!(filtered.len(), 1);
assert_eq!(filtered[0].desc.name.to_string(), "1");
assert!(filtered[0].desc.ignore == false);
assert!(!filtered[0].desc.ignore);
}

#[test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ impl Foo for LocalOverride {
}

fn test_foo() {
assert!(0i8.foo() == false);
assert!(0i32.foo() == false);
assert!(0i64.foo() == true);
assert!(!0i8.foo());
assert!(!0i32.foo());
assert!(0i64.foo());

assert!(LocalDefault.foo() == false);
assert!(LocalOverride.foo() == true);
assert!(!LocalDefault.foo());
assert!(LocalOverride.foo());
}

fn test_bar() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ impl Foo for i64 {
}

fn test_foo() {
assert!(0i8.foo() == false);
assert!(0i32.foo() == false);
assert!(0i64.foo() == true);
assert!(!0i8.foo());
assert!(!0i32.foo());
assert!(0i64.foo());
}

// Next, test mixture of explicit `default` and provided methods:
Expand Down

0 comments on commit 922e666

Please sign in to comment.