Skip to content

Commit f0da190

Browse files
bors[bot]Veykril
andauthored
Merge #9603
9603: internal: Move attribute completion tests r=Veykril a=Veykril bors r+ Co-authored-by: Lukas Wirth <[email protected]>
2 parents 190f37a + 317b0c2 commit f0da190

File tree

12 files changed

+832
-824
lines changed

12 files changed

+832
-824
lines changed

crates/ide_completion/src/completions/attribute.rs

Lines changed: 13 additions & 545 deletions
Large diffs are not rendered by default.

crates/ide_completion/src/completions/attribute/derive.rs

Lines changed: 0 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -77,93 +77,3 @@ const DEFAULT_DERIVE_COMPLETIONS: &[DeriveDependencies] = &[
7777
DeriveDependencies { label: "Ord", dependencies: &["PartialOrd", "Eq", "PartialEq"] },
7878
DeriveDependencies { label: "PartialOrd", dependencies: &["PartialEq"] },
7979
];
80-
81-
#[cfg(test)]
82-
mod tests {
83-
use expect_test::{expect, Expect};
84-
85-
use crate::tests::completion_list;
86-
87-
fn check(ra_fixture: &str, expect: Expect) {
88-
let builtin_derives = r#"
89-
#[rustc_builtin_macro]
90-
pub macro Clone {}
91-
#[rustc_builtin_macro]
92-
pub macro Copy {}
93-
#[rustc_builtin_macro]
94-
pub macro Default {}
95-
#[rustc_builtin_macro]
96-
pub macro Debug {}
97-
#[rustc_builtin_macro]
98-
pub macro Hash {}
99-
#[rustc_builtin_macro]
100-
pub macro PartialEq {}
101-
#[rustc_builtin_macro]
102-
pub macro Eq {}
103-
#[rustc_builtin_macro]
104-
pub macro PartialOrd {}
105-
#[rustc_builtin_macro]
106-
pub macro Ord {}
107-
108-
"#;
109-
let actual = completion_list(&format!("{} {}", builtin_derives, ra_fixture));
110-
expect.assert_eq(&actual);
111-
}
112-
113-
#[test]
114-
fn no_completion_for_incorrect_derive() {
115-
check(r#"#[derive{$0)] struct Test;"#, expect![[]])
116-
}
117-
118-
#[test]
119-
fn empty_derive() {
120-
check(
121-
r#"#[derive($0)] struct Test;"#,
122-
expect![[r#"
123-
at PartialEq
124-
at Default
125-
at PartialEq, Eq
126-
at PartialEq, Eq, PartialOrd, Ord
127-
at Clone, Copy
128-
at Debug
129-
at Clone
130-
at Hash
131-
at PartialEq, PartialOrd
132-
"#]],
133-
);
134-
}
135-
136-
#[test]
137-
fn derive_with_input() {
138-
check(
139-
r#"#[derive(serde::Serialize, PartialEq, $0)] struct Test;"#,
140-
expect![[r#"
141-
at Default
142-
at Eq
143-
at Eq, PartialOrd, Ord
144-
at Clone, Copy
145-
at Debug
146-
at Clone
147-
at Hash
148-
at PartialOrd
149-
"#]],
150-
)
151-
}
152-
153-
#[test]
154-
fn derive_with_input2() {
155-
check(
156-
r#"#[derive($0 serde::Serialize, PartialEq)] struct Test;"#,
157-
expect![[r#"
158-
at Default
159-
at Eq
160-
at Eq, PartialOrd, Ord
161-
at Clone, Copy
162-
at Debug
163-
at Clone
164-
at Hash
165-
at PartialOrd
166-
"#]],
167-
)
168-
}
169-
}

crates/ide_completion/src/completions/attribute/lint.rs

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -30,44 +30,3 @@ pub(super) fn complete_lint(
3030
}
3131
}
3232
}
33-
34-
#[cfg(test)]
35-
mod tests {
36-
use crate::tests::check_edit;
37-
38-
#[test]
39-
fn check_empty() {
40-
check_edit(
41-
"deprecated",
42-
r#"#[allow($0)] struct Test;"#,
43-
r#"#[allow(deprecated)] struct Test;"#,
44-
)
45-
}
46-
47-
#[test]
48-
fn check_with_existing() {
49-
check_edit(
50-
"deprecated",
51-
r#"#[allow(keyword_idents, $0)] struct Test;"#,
52-
r#"#[allow(keyword_idents, deprecated)] struct Test;"#,
53-
)
54-
}
55-
56-
#[test]
57-
fn check_qualified() {
58-
check_edit(
59-
"deprecated",
60-
r#"#[allow(keyword_idents, $0)] struct Test;"#,
61-
r#"#[allow(keyword_idents, deprecated)] struct Test;"#,
62-
)
63-
}
64-
65-
#[test]
66-
fn check_feature() {
67-
check_edit(
68-
"box_syntax",
69-
r#"#[feature(box_$0)] struct Test;"#,
70-
r#"#[feature(box_syntax)] struct Test;"#,
71-
)
72-
}
73-
}

crates/ide_completion/src/completions/attribute/repr.rs

Lines changed: 0 additions & 129 deletions
Original file line numberDiff line numberDiff line change
@@ -68,132 +68,3 @@ const REPR_COMPLETIONS: &[ReprCompletion] = &[
6868
attr("i28", &["transparent", "u8", "u16", "u32", "u64", "u128", "usize", "i8", "i16", "i32", "i64", "isize"]),
6969
attr("isize", &["transparent", "u8", "u16", "u32", "u64", "u128", "usize", "i8", "i16", "i32", "i64", "i128"]),
7070
];
71-
72-
#[cfg(test)]
73-
mod tests {
74-
use expect_test::{expect, Expect};
75-
76-
use crate::tests::completion_list;
77-
78-
fn check(ra_fixture: &str, expect: Expect) {
79-
let actual = completion_list(ra_fixture);
80-
expect.assert_eq(&actual);
81-
}
82-
83-
#[test]
84-
fn no_completion_for_incorrect_repr() {
85-
check(r#"#[repr{$0)] struct Test;"#, expect![[]])
86-
}
87-
88-
#[test]
89-
fn empty() {
90-
check(
91-
r#"#[repr($0)] struct Test;"#,
92-
expect![[r#"
93-
at align($0)
94-
at packed
95-
at transparent
96-
at C
97-
at u8
98-
at u16
99-
at u32
100-
at u64
101-
at u128
102-
at usize
103-
at i8
104-
at i16
105-
at i32
106-
at i64
107-
at i28
108-
at isize
109-
"#]],
110-
);
111-
}
112-
113-
#[test]
114-
fn transparent() {
115-
check(r#"#[repr(transparent, $0)] struct Test;"#, expect![[r#""#]]);
116-
}
117-
118-
#[test]
119-
fn align() {
120-
check(
121-
r#"#[repr(align(1), $0)] struct Test;"#,
122-
expect![[r#"
123-
at align($0)
124-
at transparent
125-
at C
126-
at u8
127-
at u16
128-
at u32
129-
at u64
130-
at u128
131-
at usize
132-
at i8
133-
at i16
134-
at i32
135-
at i64
136-
at i28
137-
at isize
138-
"#]],
139-
);
140-
}
141-
142-
#[test]
143-
fn packed() {
144-
check(
145-
r#"#[repr(packed, $0)] struct Test;"#,
146-
expect![[r#"
147-
at transparent
148-
at C
149-
at u8
150-
at u16
151-
at u32
152-
at u64
153-
at u128
154-
at usize
155-
at i8
156-
at i16
157-
at i32
158-
at i64
159-
at i28
160-
at isize
161-
"#]],
162-
);
163-
}
164-
165-
#[test]
166-
fn c() {
167-
check(
168-
r#"#[repr(C, $0)] struct Test;"#,
169-
expect![[r#"
170-
at align($0)
171-
at packed
172-
at u8
173-
at u16
174-
at u32
175-
at u64
176-
at u128
177-
at usize
178-
at i8
179-
at i16
180-
at i32
181-
at i64
182-
at i28
183-
at isize
184-
"#]],
185-
);
186-
}
187-
188-
#[test]
189-
fn prim() {
190-
check(
191-
r#"#[repr(usize, $0)] struct Test;"#,
192-
expect![[r#"
193-
at align($0)
194-
at packed
195-
at C
196-
"#]],
197-
);
198-
}
199-
}

crates/ide_completion/src/completions/unqualified_path.rs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -601,16 +601,4 @@ fn f() -> m::E { V$0 }
601601
"#]],
602602
)
603603
}
604-
605-
#[test]
606-
fn dont_complete_attr() {
607-
check(
608-
r#"
609-
struct Foo;
610-
#[$0]
611-
fn f() {}
612-
"#,
613-
expect![[""]],
614-
)
615-
}
616604
}

crates/ide_completion/src/tests.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@
44
//! `attributes` or `lifetimes` where the completed concept is a distinct thing.
55
//! Notable examples for completions that are being tested in this module's submodule are paths.
66
7+
mod attribute;
78
mod item_list;
8-
mod use_tree;
9-
mod items;
9+
mod item;
1010
mod pattern;
11-
mod type_pos;
1211
mod predicate;
12+
mod type_pos;
13+
mod use_tree;
14+
1315
mod sourcegen;
1416

1517
use std::mem;

0 commit comments

Comments
 (0)