Skip to content

Commit 87cfb54

Browse files
committed
Updated tests and fixed inconsistent message on assert_eq
1 parent de8bbd2 commit 87cfb54

File tree

3 files changed

+30
-9
lines changed

3 files changed

+30
-9
lines changed

src/libcore/macros.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,8 @@ macro_rules! assert_eq {
117117
(left_val, right_val) => {
118118
if !(*left_val == *right_val) {
119119
panic!(r#"assertion failed: `(left == right)`
120-
left: `{:?}`
121-
right: `{:?}`"#, left_val, right_val)
120+
left: `{:?}`
121+
right: `{:?}`"#, left_val, right_val)
122122
}
123123
}
124124
}
@@ -128,8 +128,8 @@ right: `{:?}`"#, left_val, right_val)
128128
(left_val, right_val) => {
129129
if !(*left_val == *right_val) {
130130
panic!(r#"assertion failed: `(left == right)`
131-
left: `{:?}`
132-
right: `{:?}`: {}"#, left_val, right_val,
131+
left: `{:?}`
132+
right: `{:?}`: {}"#, left_val, right_val,
133133
format_args!($($arg)+))
134134
}
135135
}
@@ -164,8 +164,9 @@ macro_rules! assert_ne {
164164
match (&$left, &$right) {
165165
(left_val, right_val) => {
166166
if *left_val == *right_val {
167-
panic!("assertion failed: `(left != right)` \
168-
(left: `{:?}`, right: `{:?}`)", left_val, right_val)
167+
panic!(r#"assertion failed: `(left != right)`
168+
left: `{:?}`
169+
right: `{:?}`"#, left_val, right_val)
169170
}
170171
}
171172
}
@@ -174,8 +175,9 @@ macro_rules! assert_ne {
174175
match (&($left), &($right)) {
175176
(left_val, right_val) => {
176177
if *left_val == *right_val {
177-
panic!("assertion failed: `(left != right)` \
178-
(left: `{:?}`, right: `{:?}`): {}", left_val, right_val,
178+
panic!(r#"assertion failed: `(left != right)`
179+
left: `{:?}`
180+
right: `{:?}`: {}"#, left_val, right_val,
179181
format_args!($($arg)+))
180182
}
181183
}

src/test/run-fail/assert-eq-macro-panic.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
// error-pattern:assertion failed: `(left == right)` (left: `14`, right: `15`)
11+
// error-pattern:assertion failed: `(left == right)`
12+
// error-pattern: left: `14`
13+
// error-pattern:right: `15`
1214

1315
fn main() {
1416
assert_eq!(14, 15);
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// error-pattern:assertion failed: `(left != right)`
12+
// error-pattern: left: `14`
13+
// error-pattern:right: `14`
14+
15+
fn main() {
16+
assert_ne!(14, 14);
17+
}

0 commit comments

Comments
 (0)