From 5c8cb56506646637e45a646657baf12fa9a8f49a Mon Sep 17 00:00:00 2001 From: gfreezy Date: Wed, 16 Jan 2019 21:39:01 +0800 Subject: move rename to a new mod --- crates/ra_ide_api/tests/test/main.rs | 20 +++++++++--- .../tests/test/snapshots/test__rename_mod.snap | 36 ++++++++++++++++++++++ .../test/snapshots/test__rename_mod_in_dir.snap | 36 ++++++++++++++++++++++ 3 files changed, 87 insertions(+), 5 deletions(-) create mode 100644 crates/ra_ide_api/tests/test/snapshots/test__rename_mod.snap create mode 100644 crates/ra_ide_api/tests/test/snapshots/test__rename_mod_in_dir.snap (limited to 'crates/ra_ide_api/tests/test') diff --git a/crates/ra_ide_api/tests/test/main.rs b/crates/ra_ide_api/tests/test/main.rs index 4aa13b0e7..2077a89ce 100644 --- a/crates/ra_ide_api/tests/test/main.rs +++ b/crates/ra_ide_api/tests/test/main.rs @@ -7,8 +7,6 @@ use ra_syntax::TextRange; use test_utils::assert_eq_text; use insta::assert_debug_snapshot_matches; -mod runnables; - #[test] fn test_unresolved_module_diagnostic() { let (analysis, file_id) = single_file("mod foo;"); @@ -182,10 +180,22 @@ fn test_rename_mod() { ); let new_name = "foo2"; let source_change = analysis.rename(position, new_name).unwrap(); - assert_eq_dbg( - 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: "bar/foo2.rs" }], cursor_position: None })"#, - &source_change, + assert_debug_snapshot_matches!("rename_mod", &source_change); +} + +#[test] +fn test_rename_mod_in_dir() { + let (analysis, position) = analysis_and_position( + " + //- /lib.rs + mod fo<|>o; + //- /foo/mod.rs + // emtpy + ", ); + let new_name = "foo2"; + let source_change = analysis.rename(position, new_name).unwrap(); + assert_debug_snapshot_matches!("rename_mod_in_dir", &source_change); } fn test_rename(text: &str, new_name: &str, expected: &str) { diff --git a/crates/ra_ide_api/tests/test/snapshots/test__rename_mod.snap b/crates/ra_ide_api/tests/test/snapshots/test__rename_mod.snap new file mode 100644 index 000000000..54f622b95 --- /dev/null +++ b/crates/ra_ide_api/tests/test/snapshots/test__rename_mod.snap @@ -0,0 +1,36 @@ +Created: 2019-01-16T14:12:39.379431+00:00 +Creator: insta@0.1.4 +Source: crates/ra_ide_api/tests/test/main.rs + +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: "bar/foo2.rs" + } + ], + cursor_position: None + } +) diff --git a/crates/ra_ide_api/tests/test/snapshots/test__rename_mod_in_dir.snap b/crates/ra_ide_api/tests/test/snapshots/test__rename_mod_in_dir.snap new file mode 100644 index 000000000..aac30e89f --- /dev/null +++ b/crates/ra_ide_api/tests/test/snapshots/test__rename_mod_in_dir.snap @@ -0,0 +1,36 @@ +Created: 2019-01-16T14:12:39.379358+00:00 +Creator: insta@0.1.4 +Source: crates/ra_ide_api/tests/test/main.rs + +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 + } +) -- cgit v1.2.3