From 13bce1a1641cbcf57ae24677c238e2c1ca393dea Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 4 May 2020 12:10:26 +0200 Subject: Add test marks --- crates/ra_ide/src/marks.rs | 2 ++ crates/ra_ide/src/references/rename.rs | 13 ++++++++----- 2 files changed, 10 insertions(+), 5 deletions(-) (limited to 'crates/ra_ide/src') diff --git a/crates/ra_ide/src/marks.rs b/crates/ra_ide/src/marks.rs index bea30fe2a..51ca4dde3 100644 --- a/crates/ra_ide/src/marks.rs +++ b/crates/ra_ide/src/marks.rs @@ -11,4 +11,6 @@ test_utils::marks!( self_fulfilling_completion test_struct_field_completion_in_func_call test_struct_field_completion_in_record_lit + test_rename_struct_field_for_shorthand + test_rename_local_for_field_shorthand ); diff --git a/crates/ra_ide/src/references/rename.rs b/crates/ra_ide/src/references/rename.rs index fd17bc9f2..916edaef2 100644 --- a/crates/ra_ide/src/references/rename.rs +++ b/crates/ra_ide/src/references/rename.rs @@ -7,14 +7,13 @@ use ra_syntax::{ algo::find_node_at_offset, ast, lex_single_valid_syntax_kind, AstNode, SyntaxKind, SyntaxNode, }; use ra_text_edit::TextEdit; +use test_utils::tested_by; use crate::{ - FilePosition, FileSystemEdit, RangeInfo, Reference, ReferenceKind, SourceChange, - SourceFileEdit, TextRange, + references::find_all_refs, FilePosition, FileSystemEdit, RangeInfo, Reference, ReferenceKind, + SourceChange, SourceFileEdit, TextRange, }; -use super::find_all_refs; - pub(crate) fn rename( db: &RootDatabase, position: FilePosition, @@ -52,11 +51,13 @@ fn source_edit_from_reference(reference: Reference, new_name: &str) -> SourceFil let file_id = reference.file_range.file_id; let range = match reference.kind { ReferenceKind::FieldShorthandForField => { + tested_by!(test_rename_struct_field_for_shorthand); replacement_text.push_str(new_name); replacement_text.push_str(": "); TextRange::new(reference.file_range.range.start(), reference.file_range.range.start()) } ReferenceKind::FieldShorthandForLocal => { + tested_by!(test_rename_local_for_field_shorthand); replacement_text.push_str(": "); replacement_text.push_str(new_name); TextRange::new(reference.file_range.range.end(), reference.file_range.range.end()) @@ -147,7 +148,7 @@ fn rename_reference( mod tests { use insta::assert_debug_snapshot; use ra_text_edit::TextEditBuilder; - use test_utils::assert_eq_text; + use test_utils::{assert_eq_text, covers}; use crate::{ mock_analysis::analysis_and_position, mock_analysis::single_file_with_position, FileId, @@ -379,6 +380,7 @@ mod tests { #[test] fn test_rename_struct_field_for_shorthand() { + covers!(test_rename_struct_field_for_shorthand); test_rename( r#" struct Foo { @@ -408,6 +410,7 @@ mod tests { #[test] fn test_rename_local_for_field_shorthand() { + covers!(test_rename_local_for_field_shorthand); test_rename( r#" struct Foo { -- cgit v1.2.3