aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide_api/src
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-11-20 13:25:00 +0000
committerAleksey Kladov <[email protected]>2019-11-20 13:40:25 +0000
commit3888487ca8af25047351542dbf37b90e0029e230 (patch)
tree5f3bda13836eea505b876628130330439a5676b8 /crates/ra_ide_api/src
parent3d56e3d85516fe9061aea84571ac88c3322a687c (diff)
Remove duplicate tests
Diffstat (limited to 'crates/ra_ide_api/src')
-rw-r--r--crates/ra_ide_api/src/references/rename.rs132
1 files changed, 0 insertions, 132 deletions
diff --git a/crates/ra_ide_api/src/references/rename.rs b/crates/ra_ide_api/src/references/rename.rs
index 4ea372e6f..d58496049 100644
--- a/crates/ra_ide_api/src/references/rename.rs
+++ b/crates/ra_ide_api/src/references/rename.rs
@@ -121,141 +121,9 @@ mod tests {
121 121
122 use crate::{ 122 use crate::{
123 mock_analysis::analysis_and_position, mock_analysis::single_file_with_position, FileId, 123 mock_analysis::analysis_and_position, mock_analysis::single_file_with_position, FileId,
124 ReferenceSearchResult,
125 }; 124 };
126 125
127 #[test] 126 #[test]
128 fn test_find_all_refs_for_local() {
129 let code = r#"
130 fn main() {
131 let mut i = 1;
132 let j = 1;
133 i = i<|> + j;
134
135 {
136 i = 0;
137 }
138
139 i = 5;
140 }"#;
141
142 let refs = get_all_refs(code);
143 assert_eq!(refs.len(), 5);
144 }
145
146 #[test]
147 fn test_find_all_refs_for_param_inside() {
148 let code = r#"
149 fn foo(i : u32) -> u32 {
150 i<|>
151 }"#;
152
153 let refs = get_all_refs(code);
154 assert_eq!(refs.len(), 2);
155 }
156
157 #[test]
158 fn test_find_all_refs_for_fn_param() {
159 let code = r#"
160 fn foo(i<|> : u32) -> u32 {
161 i
162 }"#;
163
164 let refs = get_all_refs(code);
165 assert_eq!(refs.len(), 2);
166 }
167
168 #[test]
169 fn test_find_all_refs_field_name() {
170 let code = r#"
171 //- /lib.rs
172 struct Foo {
173 pub spam<|>: u32,
174 }
175
176 fn main(s: Foo) {
177 let f = s.spam;
178 }
179 "#;
180
181 let refs = get_all_refs(code);
182 assert_eq!(refs.len(), 2);
183 }
184
185 #[test]
186 fn test_find_all_refs_impl_item_name() {
187 let code = r#"
188 //- /lib.rs
189 struct Foo;
190 impl Foo {
191 fn f<|>(&self) { }
192 }
193 "#;
194
195 let refs = get_all_refs(code);
196 assert_eq!(refs.len(), 1);
197 }
198
199 #[test]
200 fn test_find_all_refs_enum_var_name() {
201 let code = r#"
202 //- /lib.rs
203 enum Foo {
204 A,
205 B<|>,
206 C,
207 }
208 "#;
209
210 let refs = get_all_refs(code);
211 assert_eq!(refs.len(), 1);
212 }
213
214 #[test]
215 fn test_find_all_refs_modules() {
216 let code = r#"
217 //- /lib.rs
218 pub mod foo;
219 pub mod bar;
220
221 fn f() {
222 let i = foo::Foo { n: 5 };
223 }
224
225 //- /foo.rs
226 use crate::bar;
227
228 pub struct Foo {
229 pub n: u32,
230 }
231
232 fn f() {
233 let i = bar::Bar { n: 5 };
234 }
235
236 //- /bar.rs
237 use crate::foo;
238
239 pub struct Bar {
240 pub n: u32,
241 }
242
243 fn f() {
244 let i = foo::Foo<|> { n: 5 };
245 }
246 "#;
247
248 let (analysis, pos) = analysis_and_position(code);
249 let refs = analysis.find_all_refs(pos, None).unwrap().unwrap();
250 assert_eq!(refs.len(), 3);
251 }
252
253 fn get_all_refs(text: &str) -> ReferenceSearchResult {
254 let (analysis, position) = single_file_with_position(text);
255 analysis.find_all_refs(position, None).unwrap().unwrap()
256 }
257
258 #[test]
259 fn test_rename_for_local() { 127 fn test_rename_for_local() {
260 test_rename( 128 test_rename(
261 r#" 129 r#"