diff options
author | Lukas Wirth <[email protected]> | 2021-06-16 16:37:23 +0100 |
---|---|---|
committer | Lukas Wirth <[email protected]> | 2021-06-16 20:51:20 +0100 |
commit | d338a803941c2b0ac83decfcdfac33c09dfaa971 (patch) | |
tree | 6656cf5923aa537bbfba8c1bd267fe8dfafb2c14 /crates/ide_completion/src/tests | |
parent | f38770cd2606148bfe764351849ea7ebea45132c (diff) |
Start refactoring ide_completion tests
Diffstat (limited to 'crates/ide_completion/src/tests')
-rw-r--r-- | crates/ide_completion/src/tests/item_list.rs | 172 |
1 files changed, 172 insertions, 0 deletions
diff --git a/crates/ide_completion/src/tests/item_list.rs b/crates/ide_completion/src/tests/item_list.rs new file mode 100644 index 000000000..bd060a632 --- /dev/null +++ b/crates/ide_completion/src/tests/item_list.rs | |||
@@ -0,0 +1,172 @@ | |||
1 | use expect_test::expect; | ||
2 | |||
3 | use crate::tests::check; | ||
4 | |||
5 | #[test] | ||
6 | fn in_mod_item_list() { | ||
7 | check( | ||
8 | r#"mod tests { | ||
9 | $0 | ||
10 | } | ||
11 | "#, | ||
12 | expect![[r#" | ||
13 | kw pub(crate) | ||
14 | kw pub | ||
15 | kw unsafe | ||
16 | kw fn | ||
17 | kw const | ||
18 | kw type | ||
19 | kw use | ||
20 | kw impl | ||
21 | kw trait | ||
22 | kw static | ||
23 | kw extern | ||
24 | kw mod | ||
25 | kw enum | ||
26 | kw struct | ||
27 | kw union | ||
28 | sn tmod (Test module) | ||
29 | sn tfn (Test function) | ||
30 | sn macro_rules | ||
31 | "#]], | ||
32 | ) | ||
33 | } | ||
34 | |||
35 | #[test] | ||
36 | fn in_source_file_item_list() { | ||
37 | check( | ||
38 | r#" | ||
39 | enum Enum { Variant } | ||
40 | struct MyStruct {} | ||
41 | #[macro_export] | ||
42 | macro_rules! foo {} | ||
43 | mod bar {} | ||
44 | const CONST: () = (); | ||
45 | |||
46 | $0"#, | ||
47 | expect![[r##" | ||
48 | kw pub(crate) | ||
49 | kw pub | ||
50 | kw unsafe | ||
51 | kw fn | ||
52 | kw const | ||
53 | kw type | ||
54 | kw use | ||
55 | kw impl | ||
56 | kw trait | ||
57 | kw static | ||
58 | kw extern | ||
59 | kw mod | ||
60 | kw enum | ||
61 | kw struct | ||
62 | kw union | ||
63 | sn tmod (Test module) | ||
64 | sn tfn (Test function) | ||
65 | sn macro_rules | ||
66 | md bar | ||
67 | ma foo!(…) #[macro_export] macro_rules! foo | ||
68 | ma foo!(…) #[macro_export] macro_rules! foo | ||
69 | "##]], | ||
70 | ) | ||
71 | } | ||
72 | |||
73 | #[test] | ||
74 | fn in_qualified_path() { | ||
75 | check( | ||
76 | r#" | ||
77 | enum Enum { Variant } | ||
78 | struct MyStruct {} | ||
79 | #[macro_export] | ||
80 | macro_rules! foo {} | ||
81 | mod bar {} | ||
82 | const CONST: () = (); | ||
83 | |||
84 | crate::$0"#, | ||
85 | expect![[r##" | ||
86 | kw pub(crate) | ||
87 | kw pub | ||
88 | kw unsafe | ||
89 | kw fn | ||
90 | kw const | ||
91 | kw type | ||
92 | kw use | ||
93 | kw impl | ||
94 | kw trait | ||
95 | kw static | ||
96 | kw extern | ||
97 | kw mod | ||
98 | kw enum | ||
99 | kw struct | ||
100 | kw union | ||
101 | sn tmod (Test module) | ||
102 | sn tfn (Test function) | ||
103 | sn macro_rules | ||
104 | md bar | ||
105 | ma foo!(…) #[macro_export] macro_rules! foo | ||
106 | "##]], | ||
107 | ) | ||
108 | } | ||
109 | |||
110 | #[test] | ||
111 | fn after_unsafe_token() { | ||
112 | check( | ||
113 | r#" | ||
114 | enum Enum { Variant } | ||
115 | struct MyStruct {} | ||
116 | #[macro_export] | ||
117 | macro_rules! foo {} | ||
118 | mod bar {} | ||
119 | const CONST: () = (); | ||
120 | |||
121 | unsafe $0"#, | ||
122 | expect![[r##" | ||
123 | kw fn | ||
124 | kw trait | ||
125 | kw impl | ||
126 | sn tmod (Test module) | ||
127 | sn tfn (Test function) | ||
128 | sn macro_rules | ||
129 | md bar | ||
130 | ma foo!(…) #[macro_export] macro_rules! foo | ||
131 | ma foo!(…) #[macro_export] macro_rules! foo | ||
132 | "##]], | ||
133 | ); | ||
134 | } | ||
135 | |||
136 | #[test] | ||
137 | fn after_visibility() { | ||
138 | check( | ||
139 | r#" | ||
140 | enum Enum { Variant } | ||
141 | struct MyStruct {} | ||
142 | #[macro_export] | ||
143 | macro_rules! foo {} | ||
144 | mod bar {} | ||
145 | const CONST: () = (); | ||
146 | |||
147 | pub $0"#, | ||
148 | expect![[r##" | ||
149 | kw pub(crate) | ||
150 | kw pub | ||
151 | kw unsafe | ||
152 | kw fn | ||
153 | kw const | ||
154 | kw type | ||
155 | kw use | ||
156 | kw impl | ||
157 | kw trait | ||
158 | kw static | ||
159 | kw extern | ||
160 | kw mod | ||
161 | kw enum | ||
162 | kw struct | ||
163 | kw union | ||
164 | sn tmod (Test module) | ||
165 | sn tfn (Test function) | ||
166 | sn macro_rules | ||
167 | md bar | ||
168 | ma foo!(…) #[macro_export] macro_rules! foo | ||
169 | ma foo!(…) #[macro_export] macro_rules! foo | ||
170 | "##]], | ||
171 | ); | ||
172 | } | ||