diff options
Diffstat (limited to 'crates/test_utils/src/lib.rs')
-rw-r--r-- | crates/test_utils/src/lib.rs | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/crates/test_utils/src/lib.rs b/crates/test_utils/src/lib.rs index 1ae800d7c..beb936c61 100644 --- a/crates/test_utils/src/lib.rs +++ b/crates/test_utils/src/lib.rs | |||
@@ -10,22 +10,20 @@ pub const CURSOR_MARKER: &str = "<|>"; | |||
10 | 10 | ||
11 | #[macro_export] | 11 | #[macro_export] |
12 | macro_rules! assert_eq_text { | 12 | macro_rules! assert_eq_text { |
13 | ($expected:expr, $actual:expr) => {{ | 13 | ($expected:expr, $actual:expr) => { |
14 | let expected = $expected; | 14 | assert_eq_text!($expected, $actual,) |
15 | let actual = $actual; | 15 | }; |
16 | if expected != actual { | ||
17 | let changeset = $crate::__Changeset::new(actual, expected, "\n"); | ||
18 | println!("Expected:\n{}\n\nActual:\n{}\nDiff:{}\n", expected, actual, changeset); | ||
19 | panic!("text differs"); | ||
20 | } | ||
21 | }}; | ||
22 | ($expected:expr, $actual:expr, $($tt:tt)*) => {{ | 16 | ($expected:expr, $actual:expr, $($tt:tt)*) => {{ |
23 | let expected = $expected; | 17 | let expected = $expected; |
24 | let actual = $actual; | 18 | let actual = $actual; |
25 | if expected != actual { | 19 | if expected != actual { |
26 | let changeset = $crate::__Changeset::new(actual, expected, "\n"); | 20 | if expected.trim() == actual.trim() { |
27 | println!("Expected:\n{}\n\nActual:\n{}\n\nDiff:\n{}\n", expected, actual, changeset); | 21 | eprintln!("Expected:\n{:?}\n\nActual:\n{:?}\n\nWhitespace difference\n", expected, actual); |
28 | println!($($tt)*); | 22 | } else { |
23 | let changeset = $crate::__Changeset::new(actual, expected, "\n"); | ||
24 | eprintln!("Expected:\n{}\n\nActual:\n{}\n\nDiff:\n{}\n", expected, actual, changeset); | ||
25 | } | ||
26 | eprintln!($($tt)*); | ||
29 | panic!("text differs"); | 27 | panic!("text differs"); |
30 | } | 28 | } |
31 | }}; | 29 | }}; |