1601: Inline snapshots for tests r=matklad a=theotherphil

Fixes https://github.com/rust-analyzer/rust-analyzer/issues/1127.

The "cargo format" commits are required to get the formatting tests to pass. However, they actually mess up the formatting.

Co-authored-by: Phil Ellison <phil.j.ellison@gmail.com>
This commit is contained in:
bors[bot] 2019-07-29 12:54:40 +00:00
commit 359b3376b3
38 changed files with 870 additions and 1064 deletions

View file

@ -341,7 +341,39 @@ mod tests {
);
let new_name = "foo2";
let source_change = analysis.rename(position, new_name).unwrap();
assert_debug_snapshot_matches!("rename_mod", &source_change);
assert_debug_snapshot_matches!(&source_change,
@r#"Some(
SourceChange {
label: "rename",
source_file_edits: [
SourceFileEdit {
file_id: FileId(
2,
),
edit: TextEdit {
atoms: [
AtomTextEdit {
delete: [4; 7),
insert: "foo2",
},
],
},
},
],
file_system_edits: [
MoveFile {
src: FileId(
3,
),
dst_source_root: SourceRootId(
0,
),
dst_path: "bar/foo2.rs",
},
],
cursor_position: None,
},
)"#);
}
#[test]
@ -356,7 +388,40 @@ mod tests {
);
let new_name = "foo2";
let source_change = analysis.rename(position, new_name).unwrap();
assert_debug_snapshot_matches!("rename_mod_in_dir", &source_change);
assert_debug_snapshot_matches!(&source_change,
@r###"Some(
SourceChange {
label: "rename",
source_file_edits: [
SourceFileEdit {
file_id: FileId(
1,
),
edit: TextEdit {
atoms: [
AtomTextEdit {
delete: [4; 7),
insert: "foo2",
},
],
},
},
],
file_system_edits: [
MoveFile {
src: FileId(
2,
),
dst_source_root: SourceRootId(
0,
),
dst_path: "foo2/mod.rs",
},
],
cursor_position: None,
},
)"###
);
}
fn test_rename(text: &str, new_name: &str, expected: &str) {