File tree Expand file tree Collapse file tree 1 file changed +43
-0
lines changed
crates/ra_ide/src/references Expand file tree Collapse file tree 1 file changed +43
-0
lines changed Original file line number Diff line number Diff line change @@ -123,6 +123,49 @@ mod tests {
123
123
mock_analysis:: analysis_and_position, mock_analysis:: single_file_with_position, FileId ,
124
124
} ;
125
125
126
+ #[ test]
127
+ fn test_rename_to_underscore ( ) {
128
+ test_rename (
129
+ r#"
130
+ fn main() {
131
+ let i<|> = 1;
132
+ }"# ,
133
+ "_" ,
134
+ r#"
135
+ fn main() {
136
+ let _ = 1;
137
+ }"# ,
138
+ ) ;
139
+ }
140
+
141
+ #[ test]
142
+ fn test_rename_to_raw_identifier ( ) {
143
+ test_rename (
144
+ r#"
145
+ fn main() {
146
+ let i<|> = 1;
147
+ }"# ,
148
+ "r#fn" ,
149
+ r#"
150
+ fn main() {
151
+ let r#fn = 1;
152
+ }"# ,
153
+ ) ;
154
+ }
155
+
156
+ #[ test]
157
+ fn test_rename_to_invalid_identifier ( ) {
158
+ let ( analysis, position) = single_file_with_position (
159
+ "
160
+ fn main() {
161
+ let i<|> = 1;
162
+ }" ,
163
+ ) ;
164
+ let new_name = "invalid!" ;
165
+ let source_change = analysis. rename ( position, new_name) . unwrap ( ) ;
166
+ assert ! ( source_change. is_none( ) ) ;
167
+ }
168
+
126
169
#[ test]
127
170
fn test_rename_for_local ( ) {
128
171
test_rename (
You can’t perform that action at this time.
0 commit comments