Skip to content

Commit 9eb37fb

Browse files
bors[bot]u5surf
andauthored
Merge #7292
7292: Swap assert_eq_text\!(expected, actual) r=matklad a=u5surf Fixes #7283 Swap assert_eq_text parameters in the order (expected, actual) Co-authored-by: yugo-horie <u5.horie@gmail.com>
2 parents fde4a86 + f273995 commit 9eb37fb

File tree

6 files changed

+27
-27
lines changed

6 files changed

+27
-27
lines changed

crates/hir_expand/src/proc_macro.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,6 @@ mod tests {
135135
let result = format!("{:#?}", remove_derive_attrs(&tt).unwrap());
136136

137137
assert_eq_text!(
138-
&result,
139138
r#"
140139
SUBTREE $
141140
PUNCH # [alone] 0
@@ -150,7 +149,8 @@ SUBTREE $
150149
PUNCH : [alone] 19
151150
IDENT u32 20
152151
"#
153-
.trim()
152+
.trim(),
153+
&result
154154
);
155155
}
156156
}

crates/ide/src/syntax_tree.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,6 @@ mod tests {
111111
let syn = analysis.syntax_tree(file_id, None).unwrap();
112112

113113
assert_eq_text!(
114-
syn.trim(),
115114
r#"
116115
SOURCE_FILE@0..11
117116
FN@0..11
@@ -127,7 +126,8 @@ SOURCE_FILE@0..11
127126
L_CURLY@9..10 "{"
128127
R_CURLY@10..11 "}"
129128
"#
130-
.trim()
129+
.trim(),
130+
syn.trim()
131131
);
132132

133133
let (analysis, file_id) = fixture::file(
@@ -143,7 +143,6 @@ fn test() {
143143
let syn = analysis.syntax_tree(file_id, None).unwrap();
144144

145145
assert_eq_text!(
146-
syn.trim(),
147146
r#"
148147
SOURCE_FILE@0..60
149148
FN@0..60
@@ -176,7 +175,8 @@ SOURCE_FILE@0..60
176175
WHITESPACE@58..59 "\n"
177176
R_CURLY@59..60 "}"
178177
"#
179-
.trim()
178+
.trim(),
179+
syn.trim()
180180
);
181181
}
182182

@@ -186,7 +186,6 @@ SOURCE_FILE@0..60
186186
let syn = analysis.syntax_tree(range.file_id, Some(range.range)).unwrap();
187187

188188
assert_eq_text!(
189-
syn.trim(),
190189
r#"
191190
FN@0..11
192191
FN_KW@0..2 "fn"
@@ -201,7 +200,8 @@ FN@0..11
201200
L_CURLY@9..10 "{"
202201
R_CURLY@10..11 "}"
203202
"#
204-
.trim()
203+
.trim(),
204+
syn.trim()
205205
);
206206

207207
let (analysis, range) = fixture::range(
@@ -216,7 +216,6 @@ FN@0..11
216216
let syn = analysis.syntax_tree(range.file_id, Some(range.range)).unwrap();
217217

218218
assert_eq_text!(
219-
syn.trim(),
220219
r#"
221220
EXPR_STMT@16..58
222221
MACRO_CALL@16..57
@@ -234,7 +233,8 @@ EXPR_STMT@16..58
234233
R_PAREN@56..57 ")"
235234
SEMICOLON@57..58 ";"
236235
"#
237-
.trim()
236+
.trim(),
237+
syn.trim()
238238
);
239239
}
240240

@@ -253,7 +253,6 @@ fn bar() {
253253
);
254254
let syn = analysis.syntax_tree(range.file_id, Some(range.range)).unwrap();
255255
assert_eq_text!(
256-
syn.trim(),
257256
r#"
258257
SOURCE_FILE@0..12
259258
FN@0..12
@@ -270,7 +269,8 @@ SOURCE_FILE@0..12
270269
WHITESPACE@10..11 "\n"
271270
R_CURLY@11..12 "}"
272271
"#
273-
.trim()
272+
.trim(),
273+
syn.trim()
274274
);
275275

276276
// With a raw string
@@ -287,7 +287,6 @@ fn bar() {
287287
);
288288
let syn = analysis.syntax_tree(range.file_id, Some(range.range)).unwrap();
289289
assert_eq_text!(
290-
syn.trim(),
291290
r#"
292291
SOURCE_FILE@0..12
293292
FN@0..12
@@ -304,7 +303,8 @@ SOURCE_FILE@0..12
304303
WHITESPACE@10..11 "\n"
305304
R_CURLY@11..12 "}"
306305
"#
307-
.trim()
306+
.trim(),
307+
syn.trim()
308308
);
309309

310310
// With a raw string
@@ -320,7 +320,6 @@ fn bar() {
320320
);
321321
let syn = analysis.syntax_tree(range.file_id, Some(range.range)).unwrap();
322322
assert_eq_text!(
323-
syn.trim(),
324323
r#"
325324
SOURCE_FILE@0..25
326325
FN@0..12
@@ -351,7 +350,8 @@ SOURCE_FILE@0..25
351350
WHITESPACE@23..24 "\n"
352351
R_CURLY@24..25 "}"
353352
"#
354-
.trim()
353+
.trim(),
354+
syn.trim()
355355
);
356356
}
357357
}

crates/ide_db/src/helpers/insert_use/tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,7 @@ fn check(
599599

600600
let rewriter = insert_use(&file, path, mb);
601601
let result = rewriter.rewrite(file.as_syntax_node()).to_string();
602-
assert_eq_text!(&result, ra_fixture_after);
602+
assert_eq_text!(ra_fixture_after, &result);
603603
}
604604

605605
fn check_full(path: &str, ra_fixture_before: &str, ra_fixture_after: &str) {

crates/mbe/src/tests.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,6 @@ fn test_expr_order() {
261261

262262
let dump = format!("{:#?}", expanded);
263263
assert_eq_text!(
264-
dump.trim(),
265264
r#"MACRO_ITEMS@0..15
266265
FN@0..15
267266
FN_KW@0..2 "fn"
@@ -285,6 +284,7 @@ fn test_expr_order() {
285284
INT_NUMBER@12..13 "2"
286285
SEMICOLON@13..14 ";"
287286
R_CURLY@14..15 "}""#,
287+
dump.trim()
288288
);
289289
}
290290

@@ -989,7 +989,6 @@ fn test_tt_composite2() {
989989

990990
let res = format!("{:#?}", &node);
991991
assert_eq_text!(
992-
res.trim(),
993992
r###"MACRO_ITEMS@0..10
994993
MACRO_CALL@0..10
995994
PATH@0..3
@@ -1003,7 +1002,8 @@ fn test_tt_composite2() {
10031002
R_ANGLE@6..7 ">"
10041003
WHITESPACE@7..8 " "
10051004
POUND@8..9 "#"
1006-
R_PAREN@9..10 ")""###
1005+
R_PAREN@9..10 ")""###,
1006+
res.trim()
10071007
);
10081008
}
10091009

@@ -1742,7 +1742,7 @@ impl MacroFixture {
17421742
fn assert_expand(&self, invocation: &str, expected: &str) {
17431743
let expansion = self.expand_tt(invocation);
17441744
let actual = format!("{:?}", expansion);
1745-
test_utils::assert_eq_text!(&actual.trim(), &expected.trim());
1745+
test_utils::assert_eq_text!(&expected.trim(), &actual.trim());
17461746
}
17471747

17481748
fn assert_expand_items(&self, invocation: &str, expected: &str) -> &MacroFixture {
@@ -1941,7 +1941,6 @@ fn test_no_space_after_semi_colon() {
19411941

19421942
let dump = format!("{:#?}", expanded);
19431943
assert_eq_text!(
1944-
dump.trim(),
19451944
r###"MACRO_ITEMS@0..52
19461945
MODULE@0..26
19471946
ATTR@0..21
@@ -1981,6 +1980,7 @@ fn test_no_space_after_semi_colon() {
19811980
NAME@50..51
19821981
IDENT@50..51 "f"
19831982
SEMICOLON@51..52 ";""###,
1983+
dump.trim()
19841984
);
19851985
}
19861986

crates/proc_macro_srv/src/tests/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ fn test_derive_proc_macro_list() {
3838
let res = list("serde_derive", "1").join("\n");
3939

4040
assert_eq_text!(
41-
&res,
4241
r#"Serialize [CustomDerive]
43-
Deserialize [CustomDerive]"#
42+
Deserialize [CustomDerive]"#,
43+
&res
4444
);
4545
}
4646

@@ -50,9 +50,9 @@ fn list_test_macros() {
5050
let res = list("proc_macro_test", "0.0.0").join("\n");
5151

5252
assert_eq_text!(
53-
&res,
5453
r#"function_like_macro [FuncLike]
5554
attribute_macro [Attr]
56-
DummyTrait [CustomDerive]"#
55+
DummyTrait [CustomDerive]"#,
56+
&res
5757
);
5858
}

crates/proc_macro_srv/src/tests/utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ pub fn assert_expand(
5252
let fixture = parse_string(ra_fixture).unwrap();
5353

5454
let res = expander.expand(macro_name, &fixture.subtree, None).unwrap();
55-
assert_eq_text!(&format!("{:?}", res), &expect.trim());
55+
assert_eq_text!(&expect.trim(), &format!("{:?}", res));
5656
}
5757

5858
pub fn list(crate_name: &str, version: &str) -> Vec<String> {

0 commit comments

Comments
 (0)