From 645df2b5f5664b7730293d8f7441364799aacbf9 Mon Sep 17 00:00:00 2001 From: Wilco Kusee Date: Fri, 29 Nov 2019 16:03:39 +0100 Subject: Test rename for various identifiers --- crates/ra_ide/src/references/rename.rs | 43 ++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'crates/ra_ide/src') diff --git a/crates/ra_ide/src/references/rename.rs b/crates/ra_ide/src/references/rename.rs index ea6b354c2..c1771edf8 100644 --- a/crates/ra_ide/src/references/rename.rs +++ b/crates/ra_ide/src/references/rename.rs @@ -123,6 +123,49 @@ mod tests { mock_analysis::analysis_and_position, mock_analysis::single_file_with_position, FileId, }; + #[test] + fn test_rename_to_underscore() { + test_rename( + r#" + fn main() { + let i<|> = 1; + }"#, + "_", + r#" + fn main() { + let _ = 1; + }"#, + ); + } + + #[test] + fn test_rename_to_raw_identifier() { + test_rename( + r#" + fn main() { + let i<|> = 1; + }"#, + "r#fn", + r#" + fn main() { + let r#fn = 1; + }"#, + ); + } + + #[test] + fn test_rename_to_invalid_identifier() { + let (analysis, position) = single_file_with_position( + " + fn main() { + let i<|> = 1; + }", + ); + let new_name = "invalid!"; + let source_change = analysis.rename(position, new_name).unwrap(); + assert!(source_change.is_none()); + } + #[test] fn test_rename_for_local() { test_rename( -- cgit v1.2.3