diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-06-24 10:34:25 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2020-06-24 10:34:25 +0100 |
commit | 7c28d060b5a5c4e7004282aa6827c3023c5b03c8 (patch) | |
tree | 0ed66d422a10a9f192a039565ac70b85dbdf80f8 /crates/ra_ide/src/references/rename.rs | |
parent | 15c71f881607db5ddfd759785f62e4ae44aaf301 (diff) | |
parent | c749fe223bf5a41709a4bc91d0f56dafc4201658 (diff) |
Merge #5021
5021: Reduce code dupication around fixtures r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_ide/src/references/rename.rs')
-rw-r--r-- | crates/ra_ide/src/references/rename.rs | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/crates/ra_ide/src/references/rename.rs b/crates/ra_ide/src/references/rename.rs index 6edf565b5..7ebc0adcf 100644 --- a/crates/ra_ide/src/references/rename.rs +++ b/crates/ra_ide/src/references/rename.rs | |||
@@ -271,11 +271,10 @@ fn rename_reference( | |||
271 | mod tests { | 271 | mod tests { |
272 | use insta::assert_debug_snapshot; | 272 | use insta::assert_debug_snapshot; |
273 | use ra_text_edit::TextEditBuilder; | 273 | use ra_text_edit::TextEditBuilder; |
274 | use stdx::trim_indent; | ||
274 | use test_utils::{assert_eq_text, mark}; | 275 | use test_utils::{assert_eq_text, mark}; |
275 | 276 | ||
276 | use crate::{ | 277 | use crate::{mock_analysis::analysis_and_position, FileId}; |
277 | mock_analysis::analysis_and_position, mock_analysis::single_file_with_position, FileId, | ||
278 | }; | ||
279 | 278 | ||
280 | #[test] | 279 | #[test] |
281 | fn test_rename_to_underscore() { | 280 | fn test_rename_to_underscore() { |
@@ -309,7 +308,7 @@ mod tests { | |||
309 | 308 | ||
310 | #[test] | 309 | #[test] |
311 | fn test_rename_to_invalid_identifier() { | 310 | fn test_rename_to_invalid_identifier() { |
312 | let (analysis, position) = single_file_with_position( | 311 | let (analysis, position) = analysis_and_position( |
313 | " | 312 | " |
314 | fn main() { | 313 | fn main() { |
315 | let i<|> = 1; | 314 | let i<|> = 1; |
@@ -1053,8 +1052,9 @@ pub mod foo<|>; | |||
1053 | ); | 1052 | ); |
1054 | } | 1053 | } |
1055 | 1054 | ||
1056 | fn test_rename(text: &str, new_name: &str, expected: &str) { | 1055 | fn test_rename(ra_fixture_before: &str, new_name: &str, ra_fixture_after: &str) { |
1057 | let (analysis, position) = single_file_with_position(text); | 1056 | let ra_fixture_after = &trim_indent(ra_fixture_after); |
1057 | let (analysis, position) = analysis_and_position(ra_fixture_before); | ||
1058 | let source_change = analysis.rename(position, new_name).unwrap(); | 1058 | let source_change = analysis.rename(position, new_name).unwrap(); |
1059 | let mut text_edit_builder = TextEditBuilder::default(); | 1059 | let mut text_edit_builder = TextEditBuilder::default(); |
1060 | let mut file_id: Option<FileId> = None; | 1060 | let mut file_id: Option<FileId> = None; |
@@ -1068,6 +1068,6 @@ pub mod foo<|>; | |||
1068 | } | 1068 | } |
1069 | let mut result = analysis.file_text(file_id.unwrap()).unwrap().to_string(); | 1069 | let mut result = analysis.file_text(file_id.unwrap()).unwrap().to_string(); |
1070 | text_edit_builder.finish().apply(&mut result); | 1070 | text_edit_builder.finish().apply(&mut result); |
1071 | assert_eq_text!(expected, &*result); | 1071 | assert_eq_text!(ra_fixture_after, &*result); |
1072 | } | 1072 | } |
1073 | } | 1073 | } |