From de8bbd2b164f1839186ce8a5117e86902701bdfe Mon Sep 17 00:00:00 2001 From: Squirrel Date: Thu, 8 Jun 2017 18:38:49 +0100 Subject: [PATCH] Assert failure message easier to read By having the left and right strings above and below on the same line it helps spot the difference between the two. E.g. thread 'tests::test_safe_filename' panicked at 'assertion failed: `(left == right)` left: `"-aandb--S123.html"` right: `"-aandb-S123.html"`', When the strings are both on the same line it take a lot longer to spot the difference. It is a small change but the small time savings add up with repetition. This helps Rust be an excellent language to write tests in. --- src/libcore/macros.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/libcore/macros.rs b/src/libcore/macros.rs index 99000a031fea..5cb56433ac78 100644 --- a/src/libcore/macros.rs +++ b/src/libcore/macros.rs @@ -116,8 +116,9 @@ macro_rules! assert_eq { match (&$left, &$right) { (left_val, right_val) => { if !(*left_val == *right_val) { - panic!("assertion failed: `(left == right)` \ - (left: `{:?}`, right: `{:?}`)", left_val, right_val) + panic!(r#"assertion failed: `(left == right)` +left: `{:?}` +right: `{:?}`"#, left_val, right_val) } } } @@ -126,8 +127,9 @@ macro_rules! assert_eq { match (&($left), &($right)) { (left_val, right_val) => { if !(*left_val == *right_val) { - panic!("assertion failed: `(left == right)` \ - (left: `{:?}`, right: `{:?}`): {}", left_val, right_val, + panic!(r#"assertion failed: `(left == right)` +left: `{:?}` +right: `{:?}`: {}"#, left_val, right_val, format_args!($($arg)+)) } }