Skip to content

Commit 8de3f7e

Browse files
committed
Move out unqualified_path completion tests
1 parent ea72a51 commit 8de3f7e

File tree

5 files changed

+251
-324
lines changed

5 files changed

+251
-324
lines changed

crates/ide_completion/src/completions/record.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ pub(crate) fn complete_record(acc: &mut Completions, ctx: &CompletionContext) ->
4747

4848
#[cfg(test)]
4949
mod tests {
50-
5150
use crate::tests::check_edit;
5251

5352
#[test]

crates/ide_completion/src/completions/snippet.rs

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -86,26 +86,3 @@ fn ${1:feature}() {
8686
let item = snippet(ctx, cap, "macro_rules", "macro_rules! $1 {\n\t($2) => {\n\t\t$0\n\t};\n}");
8787
item.add_to(acc);
8888
}
89-
90-
#[cfg(test)]
91-
mod tests {
92-
use expect_test::{expect, Expect};
93-
94-
use crate::{tests::filtered_completion_list, CompletionKind};
95-
96-
fn check(ra_fixture: &str, expect: Expect) {
97-
let actual = filtered_completion_list(ra_fixture, CompletionKind::Snippet);
98-
expect.assert_eq(&actual)
99-
}
100-
101-
#[test]
102-
fn completes_snippets_in_expressions() {
103-
check(
104-
r#"fn foo(x: i32) { $0 }"#,
105-
expect![[r#"
106-
sn pd
107-
sn ppd
108-
"#]],
109-
);
110-
}
111-
}

crates/ide_completion/src/completions/unqualified_path.rs

Lines changed: 1 addition & 300 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ pub(crate) fn complete_unqualified_path(acc: &mut Completions, ctx: &CompletionC
8787
if let ScopeDef::GenericParam(hir::GenericParam::LifetimeParam(_)) | ScopeDef::Label(_) =
8888
res
8989
{
90-
cov_mark::hit!(skip_lifetime_completion);
90+
cov_mark::hit!(unqualified_skip_lifetime_completion);
9191
return;
9292
}
9393
let add_resolution = match res {
@@ -155,51 +155,6 @@ fn main() {
155155
)
156156
}
157157

158-
#[test]
159-
fn completes_generic_params() {
160-
check(
161-
r#"fn quux<T>() { $0 }"#,
162-
expect![[r#"
163-
tp T
164-
fn quux() fn()
165-
"#]],
166-
);
167-
check(
168-
r#"fn quux<const C: usize>() { $0 }"#,
169-
expect![[r#"
170-
cp C
171-
fn quux() fn()
172-
"#]],
173-
);
174-
}
175-
176-
#[test]
177-
fn does_not_complete_lifetimes() {
178-
cov_mark::check!(skip_lifetime_completion);
179-
check(
180-
r#"fn quux<'a>() { $0 }"#,
181-
expect![[r#"
182-
fn quux() fn()
183-
"#]],
184-
);
185-
}
186-
187-
#[test]
188-
fn completes_module_items() {
189-
check(
190-
r#"
191-
struct S;
192-
enum E {}
193-
fn quux() { $0 }
194-
"#,
195-
expect![[r#"
196-
st S
197-
fn quux() fn()
198-
en E
199-
"#]],
200-
);
201-
}
202-
203158
/// Regression test for issue #6091.
204159
#[test]
205160
fn correctly_completes_module_items_prefixed_with_underscore() {
@@ -220,55 +175,6 @@ fn _alpha() {}
220175
)
221176
}
222177

223-
#[test]
224-
fn completes_module_items_in_nested_modules() {
225-
check(
226-
r#"
227-
struct Foo;
228-
mod m {
229-
struct Bar;
230-
fn quux() { $0 }
231-
}
232-
"#,
233-
expect![[r#"
234-
fn quux() fn()
235-
st Bar
236-
"#]],
237-
);
238-
}
239-
240-
#[test]
241-
fn dont_show_both_completions_for_shadowing() {
242-
check(
243-
r#"
244-
fn foo() {
245-
let bar = 92;
246-
{
247-
let bar = 62;
248-
drop($0)
249-
}
250-
}
251-
"#,
252-
// FIXME: should be only one bar here
253-
expect![[r#"
254-
lc bar i32
255-
lc bar i32
256-
fn foo() fn()
257-
"#]],
258-
);
259-
}
260-
261-
#[test]
262-
fn completes_self_in_methods() {
263-
check(
264-
r#"impl S { fn foo(&self) { $0 } }"#,
265-
expect![[r#"
266-
lc self &{unknown}
267-
sp Self
268-
"#]],
269-
);
270-
}
271-
272178
#[test]
273179
fn completes_prelude() {
274180
check(
@@ -318,32 +224,6 @@ mod macros {
318224
);
319225
}
320226

321-
#[test]
322-
fn does_not_complete_non_fn_macros() {
323-
check(
324-
r#"
325-
#[rustc_builtin_macro]
326-
pub macro Clone {}
327-
328-
fn f() {$0}
329-
"#,
330-
expect![[r#"
331-
fn f() fn()
332-
"#]],
333-
);
334-
check(
335-
r#"
336-
#[rustc_builtin_macro]
337-
pub macro bench {}
338-
339-
fn f() {$0}
340-
"#,
341-
expect![[r#"
342-
fn f() fn()
343-
"#]],
344-
);
345-
}
346-
347227
#[test]
348228
fn completes_std_prelude_if_core_is_defined() {
349229
check(
@@ -372,183 +252,4 @@ pub mod prelude {
372252
"#]],
373253
);
374254
}
375-
376-
#[test]
377-
fn completes_macros_as_value() {
378-
check(
379-
r#"
380-
macro_rules! foo { () => {} }
381-
382-
#[macro_use]
383-
mod m1 {
384-
macro_rules! bar { () => {} }
385-
}
386-
387-
mod m2 {
388-
macro_rules! nope { () => {} }
389-
390-
#[macro_export]
391-
macro_rules! baz { () => {} }
392-
}
393-
394-
fn main() { let v = $0 }
395-
"#,
396-
expect![[r##"
397-
md m1
398-
ma baz!(…) #[macro_export] macro_rules! baz
399-
fn main() fn()
400-
md m2
401-
ma bar!(…) macro_rules! bar
402-
ma foo!(…) macro_rules! foo
403-
"##]],
404-
);
405-
}
406-
407-
#[test]
408-
fn completes_both_macro_and_value() {
409-
check(
410-
r#"
411-
macro_rules! foo { () => {} }
412-
fn foo() { $0 }
413-
"#,
414-
expect![[r#"
415-
fn foo() fn()
416-
ma foo!(…) macro_rules! foo
417-
"#]],
418-
);
419-
}
420-
421-
#[test]
422-
fn completes_macros_as_stmt() {
423-
check(
424-
r#"
425-
macro_rules! foo { () => {} }
426-
fn main() { $0 }
427-
"#,
428-
expect![[r#"
429-
fn main() fn()
430-
ma foo!(…) macro_rules! foo
431-
"#]],
432-
);
433-
}
434-
435-
#[test]
436-
fn completes_local_item() {
437-
check(
438-
r#"
439-
fn main() {
440-
return f$0;
441-
fn frobnicate() {}
442-
}
443-
"#,
444-
expect![[r#"
445-
fn frobnicate() fn()
446-
fn main() fn()
447-
"#]],
448-
);
449-
}
450-
451-
#[test]
452-
fn completes_in_simple_macro_1() {
453-
check(
454-
r#"
455-
macro_rules! m { ($e:expr) => { $e } }
456-
fn quux(x: i32) {
457-
let y = 92;
458-
m!($0);
459-
}
460-
"#,
461-
expect![[r#"
462-
lc y i32
463-
lc x i32
464-
fn quux(…) fn(i32)
465-
ma m!(…) macro_rules! m
466-
"#]],
467-
);
468-
}
469-
470-
#[test]
471-
fn completes_in_simple_macro_2() {
472-
check(
473-
r"
474-
macro_rules! m { ($e:expr) => { $e } }
475-
fn quux(x: i32) {
476-
let y = 92;
477-
m!(x$0);
478-
}
479-
",
480-
expect![[r#"
481-
lc y i32
482-
lc x i32
483-
fn quux(…) fn(i32)
484-
ma m!(…) macro_rules! m
485-
"#]],
486-
);
487-
}
488-
489-
#[test]
490-
fn completes_in_simple_macro_without_closing_parens() {
491-
check(
492-
r#"
493-
macro_rules! m { ($e:expr) => { $e } }
494-
fn quux(x: i32) {
495-
let y = 92;
496-
m!(x$0
497-
}
498-
"#,
499-
expect![[r#"
500-
lc y i32
501-
lc x i32
502-
fn quux(…) fn(i32)
503-
ma m!(…) macro_rules! m
504-
"#]],
505-
);
506-
}
507-
508-
#[test]
509-
fn completes_unresolved_uses() {
510-
check(
511-
r#"
512-
use spam::Quux;
513-
514-
fn main() { $0 }
515-
"#,
516-
expect![[r#"
517-
fn main() fn()
518-
?? Quux
519-
"#]],
520-
);
521-
}
522-
523-
#[test]
524-
fn completes_enum_variant_basic_expr() {
525-
check(
526-
r#"
527-
enum Foo { Bar, Baz, Quux }
528-
fn main() { let foo: Foo = Q$0 }
529-
"#,
530-
expect![[r#"
531-
ev Foo::Bar ()
532-
ev Foo::Baz ()
533-
ev Foo::Quux ()
534-
en Foo
535-
fn main() fn()
536-
"#]],
537-
)
538-
}
539-
540-
#[test]
541-
fn completes_enum_variant_from_module() {
542-
check(
543-
r#"
544-
mod m { pub enum E { V } }
545-
fn f() -> m::E { V$0 }
546-
"#,
547-
expect![[r#"
548-
ev m::E::V ()
549-
md m
550-
fn f() fn() -> E
551-
"#]],
552-
)
553-
}
554255
}

crates/ide_completion/src/tests.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
//! completed where, not how.
99
1010
mod attribute;
11+
mod expression;
1112
mod fn_param;
1213
mod item_list;
1314
mod item;

0 commit comments

Comments
 (0)