Skip to content

Commit dbb940f

Browse files
committed
Colorize more test fixtures
1 parent 87d24e7 commit dbb940f

File tree

6 files changed

+71
-71
lines changed

6 files changed

+71
-71
lines changed

crates/ra_ide/src/completion.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,8 @@ mod tests {
137137
documentation: &'a str,
138138
}
139139

140-
fn check_detail_and_documentation(fixture: &str, expected: DetailAndDocumentation) {
141-
let (analysis, position) = analysis_and_position(fixture);
140+
fn check_detail_and_documentation(ra_fixture: &str, expected: DetailAndDocumentation) {
141+
let (analysis, position) = analysis_and_position(ra_fixture);
142142
let config = CompletionConfig::default();
143143
let completions = analysis.completions(&config, position).unwrap().unwrap();
144144
for item in completions {

crates/ra_ide/src/diagnostics.rs

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -324,10 +324,10 @@ mod tests {
324324
/// * a diagnostic is produced
325325
/// * this diagnostic touches the input cursor position
326326
/// * that the contents of the file containing the cursor match `after` after the diagnostic fix is applied
327-
fn check_apply_diagnostic_fix_from_position(fixture: &str, after: &str) {
327+
fn check_apply_diagnostic_fix_from_position(ra_fixture: &str, after: &str) {
328328
let after = trim_indent(after);
329329

330-
let (analysis, file_position) = analysis_and_position(fixture);
330+
let (analysis, file_position) = analysis_and_position(ra_fixture);
331331
let diagnostic = analysis.diagnostics(file_position.file_id).unwrap().pop().unwrap();
332332
let mut fix = diagnostic.fix.unwrap();
333333
let edit = fix.source_change.source_file_edits.pop().unwrap().edit;
@@ -365,14 +365,14 @@ mod tests {
365365

366366
/// Takes a multi-file input fixture with annotated cursor position and checks that no diagnostics
367367
/// apply to the file containing the cursor.
368-
fn check_no_diagnostic_for_target_file(fixture: &str) {
369-
let (analysis, file_position) = analysis_and_position(fixture);
368+
fn check_no_diagnostic_for_target_file(ra_fixture: &str) {
369+
let (analysis, file_position) = analysis_and_position(ra_fixture);
370370
let diagnostics = analysis.diagnostics(file_position.file_id).unwrap();
371371
assert_eq!(diagnostics.len(), 0);
372372
}
373373

374-
fn check_no_diagnostic(content: &str) {
375-
let (analysis, file_id) = single_file(content);
374+
fn check_no_diagnostic(ra_fixture: &str) {
375+
let (analysis, file_id) = single_file(ra_fixture);
376376
let diagnostics = analysis.diagnostics(file_id).unwrap();
377377
assert_eq!(diagnostics.len(), 0, "expected no diagnostic, found one");
378378
}
@@ -473,7 +473,8 @@ mod tests {
473473

474474
#[test]
475475
fn test_wrap_return_type_not_applicable_when_expr_type_does_not_match_ok_type() {
476-
let content = r#"
476+
check_no_diagnostic_for_target_file(
477+
r"
477478
//- /main.rs
478479
use core::result::Result::{self, Ok, Err};
479480
@@ -485,13 +486,14 @@ mod tests {
485486
pub mod result {
486487
pub enum Result<T, E> { Ok(T), Err(E) }
487488
}
488-
"#;
489-
check_no_diagnostic_for_target_file(content);
489+
",
490+
);
490491
}
491492

492493
#[test]
493494
fn test_wrap_return_type_not_applicable_when_return_type_is_not_result() {
494-
let content = r#"
495+
check_no_diagnostic_for_target_file(
496+
r"
495497
//- /main.rs
496498
use core::result::Result::{self, Ok, Err};
497499
@@ -508,8 +510,8 @@ mod tests {
508510
pub mod result {
509511
pub enum Result<T, E> { Ok(T), Err(E) }
510512
}
511-
"#;
512-
check_no_diagnostic_for_target_file(content);
513+
",
514+
);
513515
}
514516

515517
#[test]
@@ -618,7 +620,8 @@ mod tests {
618620

619621
#[test]
620622
fn test_fill_struct_fields_no_diagnostic() {
621-
let content = r"
623+
check_no_diagnostic(
624+
r"
622625
struct TestStruct {
623626
one: i32,
624627
two: i64,
@@ -628,14 +631,14 @@ mod tests {
628631
let one = 1;
629632
let s = TestStruct{ one, two: 2 };
630633
}
631-
";
632-
633-
check_no_diagnostic(content);
634+
",
635+
);
634636
}
635637

636638
#[test]
637639
fn test_fill_struct_fields_no_diagnostic_on_spread() {
638-
let content = r"
640+
check_no_diagnostic(
641+
r"
639642
struct TestStruct {
640643
one: i32,
641644
two: i64,
@@ -645,9 +648,8 @@ mod tests {
645648
let one = 1;
646649
let s = TestStruct{ ..a };
647650
}
648-
";
649-
650-
check_no_diagnostic(content);
651+
",
652+
);
651653
}
652654

653655
#[test]

crates/ra_ide/src/goto_type_definition.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ fn pick_best(tokens: TokenAtOffset<SyntaxToken>) -> Option<SyntaxToken> {
5555
mod tests {
5656
use crate::mock_analysis::analysis_and_position;
5757

58-
fn check_goto(fixture: &str, expected: &str) {
59-
let (analysis, pos) = analysis_and_position(fixture);
58+
fn check_goto(ra_fixture: &str, expected: &str) {
59+
let (analysis, pos) = analysis_and_position(ra_fixture);
6060

6161
let mut navs = analysis.goto_type_definition(pos).unwrap().unwrap().info;
6262
assert_eq!(navs.len(), 1);
@@ -67,7 +67,7 @@ mod tests {
6767
#[test]
6868
fn goto_type_definition_works_simple() {
6969
check_goto(
70-
"
70+
r"
7171
//- /lib.rs
7272
struct Foo;
7373
fn foo() {
@@ -82,7 +82,7 @@ mod tests {
8282
#[test]
8383
fn goto_type_definition_works_simple_ref() {
8484
check_goto(
85-
"
85+
r"
8686
//- /lib.rs
8787
struct Foo;
8888
fn foo() {
@@ -97,7 +97,7 @@ mod tests {
9797
#[test]
9898
fn goto_type_definition_works_through_macro() {
9999
check_goto(
100-
"
100+
r"
101101
//- /lib.rs
102102
macro_rules! id {
103103
($($tt:tt)*) => { $($tt)* }
@@ -116,7 +116,7 @@ mod tests {
116116
#[test]
117117
fn goto_type_definition_for_param() {
118118
check_goto(
119-
"
119+
r"
120120
//- /lib.rs
121121
struct Foo;
122122
fn foo(<|>f: Foo) {}
@@ -128,7 +128,7 @@ mod tests {
128128
#[test]
129129
fn goto_type_definition_for_tuple_field() {
130130
check_goto(
131-
"
131+
r"
132132
//- /lib.rs
133133
struct Foo;
134134
struct Bar(Foo);

0 commit comments

Comments
 (0)