aboutsummaryrefslogtreecommitdiff
path: root/crates/ide_completion/src/completions
diff options
context:
space:
mode:
authorLukas Wirth <[email protected]>2021-06-17 12:13:12 +0100
committerLukas Wirth <[email protected]>2021-06-17 12:13:12 +0100
commite14f5cfff04942f45a4af3b45152df9672b3458a (patch)
tree0ed0353823e6194bc5f940d2033ab2c0788f19fd /crates/ide_completion/src/completions
parentd6b8af44829521a9f925c4d87599efa3fef38edc (diff)
Move out and rewrite UseTree completion tests
Diffstat (limited to 'crates/ide_completion/src/completions')
-rw-r--r--crates/ide_completion/src/completions/keyword.rs35
-rw-r--r--crates/ide_completion/src/completions/qualified_path.rs157
-rw-r--r--crates/ide_completion/src/completions/unqualified_path.rs32
3 files changed, 0 insertions, 224 deletions
diff --git a/crates/ide_completion/src/completions/keyword.rs b/crates/ide_completion/src/completions/keyword.rs
index 73bbc4345..b6f06a44f 100644
--- a/crates/ide_completion/src/completions/keyword.rs
+++ b/crates/ide_completion/src/completions/keyword.rs
@@ -200,41 +200,6 @@ mod tests {
200 } 200 }
201 201
202 #[test] 202 #[test]
203 fn test_keywords_in_use_stmt() {
204 check(
205 r"use $0",
206 expect![[r#"
207 kw crate::
208 kw self
209 kw super::
210 "#]],
211 );
212
213 // FIXME: `self` shouldn't be shown here and the check below
214 check(
215 r"use a::$0",
216 expect![[r#"
217 kw self
218 "#]],
219 );
220
221 check(
222 r"use super::$0",
223 expect![[r#"
224 kw self
225 kw super::
226 "#]],
227 );
228
229 check(
230 r"use a::{b, $0}",
231 expect![[r#"
232 kw self
233 "#]],
234 );
235 }
236
237 #[test]
238 fn test_keywords_in_function() { 203 fn test_keywords_in_function() {
239 check( 204 check(
240 r"fn quux() { $0 }", 205 r"fn quux() { $0 }",
diff --git a/crates/ide_completion/src/completions/qualified_path.rs b/crates/ide_completion/src/completions/qualified_path.rs
index 9432caa22..5b49868e4 100644
--- a/crates/ide_completion/src/completions/qualified_path.rs
+++ b/crates/ide_completion/src/completions/qualified_path.rs
@@ -213,12 +213,6 @@ mod tests {
213 } 213 }
214 214
215 #[test] 215 #[test]
216 fn dont_complete_current_use() {
217 cov_mark::check!(dont_complete_current_use);
218 check(r#"use self::foo$0;"#, expect![[""]]);
219 }
220
221 #[test]
222 fn dont_complete_values_in_type_pos() { 216 fn dont_complete_values_in_type_pos() {
223 check( 217 check(
224 r#" 218 r#"
@@ -249,20 +243,6 @@ fn foo() {
249 } 243 }
250 244
251 #[test] 245 #[test]
252 fn dont_complete_current_use_in_braces_with_glob() {
253 check(
254 r#"
255mod foo { pub struct S; }
256use self::{foo::*, bar$0};
257"#,
258 expect![[r#"
259 st S
260 md foo
261 "#]],
262 );
263 }
264
265 #[test]
266 fn dont_complete_primitive_in_use() { 246 fn dont_complete_primitive_in_use() {
267 check_builtin(r#"use self::$0;"#, expect![[""]]); 247 check_builtin(r#"use self::$0;"#, expect![[""]]);
268 } 248 }
@@ -299,108 +279,6 @@ use self::{foo::*, bar$0};
299 } 279 }
300 280
301 #[test] 281 #[test]
302 fn completes_mod_with_same_name_as_function() {
303 check(
304 r#"
305use self::my::$0;
306
307mod my { pub struct Bar; }
308fn my() {}
309"#,
310 expect![[r#"
311 st Bar
312 "#]],
313 );
314 }
315
316 #[test]
317 fn filters_visibility() {
318 check(
319 r#"
320use self::my::$0;
321
322mod my {
323 struct Bar;
324 pub struct Foo;
325 pub use Bar as PublicBar;
326}
327"#,
328 expect![[r#"
329 st Foo
330 st PublicBar
331 "#]],
332 );
333 }
334
335 #[test]
336 fn completes_use_item_starting_with_self() {
337 check(
338 r#"
339use self::m::$0;
340
341mod m { pub struct Bar; }
342"#,
343 expect![[r#"
344 st Bar
345 "#]],
346 );
347 }
348
349 #[test]
350 fn completes_use_item_starting_with_crate() {
351 check(
352 r#"
353//- /lib.rs
354mod foo;
355struct Spam;
356//- /foo.rs
357use crate::Sp$0
358"#,
359 expect![[r#"
360 md foo
361 st Spam
362 "#]],
363 );
364 }
365
366 #[test]
367 fn completes_nested_use_tree() {
368 check(
369 r#"
370//- /lib.rs
371mod foo;
372struct Spam;
373//- /foo.rs
374use crate::{Sp$0};
375"#,
376 expect![[r#"
377 md foo
378 st Spam
379 "#]],
380 );
381 }
382
383 #[test]
384 fn completes_deeply_nested_use_tree() {
385 check(
386 r#"
387//- /lib.rs
388mod foo;
389pub mod bar {
390 pub mod baz {
391 pub struct Spam;
392 }
393}
394//- /foo.rs
395use crate::{bar::{baz::Sp$0}};
396"#,
397 expect![[r#"
398 st Spam
399 "#]],
400 );
401 }
402
403 #[test]
404 fn completes_enum_variant() { 282 fn completes_enum_variant() {
405 check( 283 check(
406 r#" 284 r#"
@@ -497,22 +375,6 @@ fn foo() { let _ = U::$0 }
497 } 375 }
498 376
499 #[test] 377 #[test]
500 fn completes_use_paths_across_crates() {
501 check(
502 r#"
503//- /main.rs crate:main deps:foo
504use foo::$0;
505
506//- /foo/lib.rs crate:foo
507pub mod bar { pub struct S; }
508"#,
509 expect![[r#"
510 md bar
511 "#]],
512 );
513 }
514
515 #[test]
516 fn completes_trait_associated_method_1() { 378 fn completes_trait_associated_method_1() {
517 check( 379 check(
518 r#" 380 r#"
@@ -714,25 +576,6 @@ impl MyStruct {
714 } 576 }
715 577
716 #[test] 578 #[test]
717 fn test_super_super_completion() {
718 check(
719 r#"
720mod a {
721 const A: usize = 0;
722 mod b {
723 const B: usize = 0;
724 mod c { use super::super::$0 }
725 }
726}
727"#,
728 expect![[r#"
729 md b
730 ct A
731 "#]],
732 );
733 }
734
735 #[test]
736 fn completes_reexported_items_under_correct_name() { 579 fn completes_reexported_items_under_correct_name() {
737 check( 580 check(
738 r#" 581 r#"
diff --git a/crates/ide_completion/src/completions/unqualified_path.rs b/crates/ide_completion/src/completions/unqualified_path.rs
index 2868d9b18..83b9148b3 100644
--- a/crates/ide_completion/src/completions/unqualified_path.rs
+++ b/crates/ide_completion/src/completions/unqualified_path.rs
@@ -130,22 +130,6 @@ fn foo() {
130 } 130 }
131 131
132 #[test] 132 #[test]
133 fn only_completes_modules_in_import() {
134 cov_mark::check!(only_completes_modules_in_import);
135 check(
136 r#"
137use f$0
138
139struct Foo;
140mod foo {}
141"#,
142 expect![[r#"
143 md foo
144 "#]],
145 );
146 }
147
148 #[test]
149 fn bind_pat_and_path_ignore_at() { 133 fn bind_pat_and_path_ignore_at() {
150 check( 134 check(
151 r#" 135 r#"
@@ -359,22 +343,6 @@ fn _alpha() {}
359 } 343 }
360 344
361 #[test] 345 #[test]
362 fn completes_extern_prelude() {
363 check(
364 r#"
365//- /lib.rs crate:main deps:other_crate
366use $0;
367
368//- /other_crate/lib.rs crate:other_crate
369// nothing here
370"#,
371 expect![[r#"
372 md other_crate
373 "#]],
374 );
375 }
376
377 #[test]
378 fn completes_module_items_in_nested_modules() { 346 fn completes_module_items_in_nested_modules() {
379 check( 347 check(
380 r#" 348 r#"