]>
Commit | Line | Data |
---|---|---|
064997fb FG |
1 | use super::*; |
2 | ||
3 | #[test] | |
4 | fn glob_1() { | |
5 | check( | |
6 | r#" | |
7 | //- /lib.rs | |
8 | mod foo; | |
9 | use foo::*; | |
10 | ||
11 | //- /foo/mod.rs | |
12 | pub mod bar; | |
13 | pub use self::bar::Baz; | |
14 | pub struct Foo; | |
15 | ||
16 | //- /foo/bar.rs | |
17 | pub struct Baz; | |
18 | "#, | |
19 | expect![[r#" | |
20 | crate | |
21 | Baz: t v | |
22 | Foo: t v | |
23 | bar: t | |
24 | foo: t | |
25 | ||
26 | crate::foo | |
27 | Baz: t v | |
28 | Foo: t v | |
29 | bar: t | |
30 | ||
31 | crate::foo::bar | |
32 | Baz: t v | |
33 | "#]], | |
34 | ); | |
35 | } | |
36 | ||
37 | #[test] | |
38 | fn glob_2() { | |
39 | check( | |
40 | r#" | |
41 | //- /lib.rs | |
42 | mod foo; | |
43 | use foo::*; | |
44 | ||
45 | //- /foo/mod.rs | |
46 | pub mod bar; | |
47 | pub use self::bar::*; | |
48 | pub struct Foo; | |
49 | ||
50 | //- /foo/bar.rs | |
51 | pub struct Baz; | |
52 | pub use super::*; | |
53 | "#, | |
54 | expect![[r#" | |
55 | crate | |
56 | Baz: t v | |
57 | Foo: t v | |
58 | bar: t | |
59 | foo: t | |
60 | ||
61 | crate::foo | |
62 | Baz: t v | |
63 | Foo: t v | |
64 | bar: t | |
65 | ||
66 | crate::foo::bar | |
67 | Baz: t v | |
68 | Foo: t v | |
69 | bar: t | |
70 | "#]], | |
71 | ); | |
72 | } | |
73 | ||
74 | #[test] | |
75 | fn glob_privacy_1() { | |
76 | check( | |
77 | r" | |
78 | //- /lib.rs | |
79 | mod foo; | |
80 | use foo::*; | |
81 | ||
82 | //- /foo/mod.rs | |
83 | pub mod bar; | |
84 | pub use self::bar::*; | |
85 | struct PrivateStructFoo; | |
86 | ||
87 | //- /foo/bar.rs | |
88 | pub struct Baz; | |
89 | struct PrivateStructBar; | |
90 | pub use super::*; | |
91 | ", | |
92 | expect![[r#" | |
93 | crate | |
94 | Baz: t v | |
95 | bar: t | |
96 | foo: t | |
97 | ||
98 | crate::foo | |
99 | Baz: t v | |
100 | PrivateStructFoo: t v | |
101 | bar: t | |
102 | ||
103 | crate::foo::bar | |
104 | Baz: t v | |
105 | PrivateStructBar: t v | |
106 | PrivateStructFoo: t v | |
107 | bar: t | |
108 | "#]], | |
109 | ); | |
110 | } | |
111 | ||
112 | #[test] | |
113 | fn glob_privacy_2() { | |
114 | check( | |
115 | r" | |
116 | //- /lib.rs | |
117 | mod foo; | |
118 | use foo::*; | |
119 | use foo::bar::*; | |
120 | ||
121 | //- /foo/mod.rs | |
487cf647 | 122 | pub mod bar; |
064997fb FG |
123 | fn Foo() {}; |
124 | pub struct Foo {}; | |
125 | ||
126 | //- /foo/bar.rs | |
127 | pub(super) struct PrivateBaz; | |
128 | struct PrivateBar; | |
129 | pub(crate) struct PubCrateStruct; | |
130 | ", | |
131 | expect![[r#" | |
132 | crate | |
133 | Foo: t | |
134 | PubCrateStruct: t v | |
487cf647 | 135 | bar: t |
064997fb FG |
136 | foo: t |
137 | ||
138 | crate::foo | |
139 | Foo: t v | |
140 | bar: t | |
141 | ||
142 | crate::foo::bar | |
143 | PrivateBar: t v | |
144 | PrivateBaz: t v | |
145 | PubCrateStruct: t v | |
146 | "#]], | |
147 | ); | |
148 | } | |
149 | ||
150 | #[test] | |
151 | fn glob_across_crates() { | |
152 | cov_mark::check!(glob_across_crates); | |
153 | check( | |
154 | r#" | |
155 | //- /main.rs crate:main deps:test_crate | |
156 | use test_crate::*; | |
157 | ||
158 | //- /lib.rs crate:test_crate | |
159 | pub struct Baz; | |
160 | "#, | |
161 | expect![[r#" | |
162 | crate | |
163 | Baz: t v | |
164 | "#]], | |
165 | ); | |
166 | } | |
167 | ||
168 | #[test] | |
169 | fn glob_privacy_across_crates() { | |
170 | check( | |
171 | r#" | |
172 | //- /main.rs crate:main deps:test_crate | |
173 | use test_crate::*; | |
174 | ||
175 | //- /lib.rs crate:test_crate | |
176 | pub struct Baz; | |
177 | struct Foo; | |
178 | "#, | |
179 | expect![[r#" | |
180 | crate | |
181 | Baz: t v | |
182 | "#]], | |
183 | ); | |
184 | } | |
185 | ||
186 | #[test] | |
187 | fn glob_enum() { | |
188 | cov_mark::check!(glob_enum); | |
189 | check( | |
190 | r#" | |
191 | enum Foo { Bar, Baz } | |
192 | use self::Foo::*; | |
193 | "#, | |
194 | expect![[r#" | |
195 | crate | |
196 | Bar: t v | |
197 | Baz: t v | |
198 | Foo: t | |
199 | "#]], | |
200 | ); | |
201 | } | |
202 | ||
203 | #[test] | |
204 | fn glob_enum_group() { | |
205 | cov_mark::check!(glob_enum_group); | |
206 | check( | |
207 | r#" | |
208 | enum Foo { Bar, Baz } | |
209 | use self::Foo::{*}; | |
210 | "#, | |
211 | expect![[r#" | |
212 | crate | |
213 | Bar: t v | |
214 | Baz: t v | |
215 | Foo: t | |
216 | "#]], | |
217 | ); | |
218 | } | |
219 | ||
220 | #[test] | |
221 | fn glob_shadowed_def() { | |
222 | cov_mark::check!(import_shadowed); | |
223 | check( | |
224 | r#" | |
225 | //- /lib.rs | |
226 | mod foo; | |
227 | mod bar; | |
228 | use foo::*; | |
229 | use bar::baz; | |
230 | use baz::Bar; | |
231 | ||
232 | //- /foo.rs | |
233 | pub mod baz { pub struct Foo; } | |
234 | ||
235 | //- /bar.rs | |
236 | pub mod baz { pub struct Bar; } | |
237 | "#, | |
238 | expect![[r#" | |
239 | crate | |
240 | Bar: t v | |
241 | bar: t | |
242 | baz: t | |
243 | foo: t | |
244 | ||
245 | crate::bar | |
246 | baz: t | |
247 | ||
248 | crate::bar::baz | |
249 | Bar: t v | |
250 | ||
251 | crate::foo | |
252 | baz: t | |
253 | ||
254 | crate::foo::baz | |
255 | Foo: t v | |
256 | "#]], | |
257 | ); | |
258 | } | |
259 | ||
260 | #[test] | |
261 | fn glob_shadowed_def_reversed() { | |
262 | check( | |
263 | r#" | |
264 | //- /lib.rs | |
265 | mod foo; | |
266 | mod bar; | |
267 | use bar::baz; | |
268 | use foo::*; | |
269 | use baz::Bar; | |
270 | ||
271 | //- /foo.rs | |
272 | pub mod baz { pub struct Foo; } | |
273 | ||
274 | //- /bar.rs | |
275 | pub mod baz { pub struct Bar; } | |
276 | "#, | |
277 | expect![[r#" | |
278 | crate | |
279 | Bar: t v | |
280 | bar: t | |
281 | baz: t | |
282 | foo: t | |
283 | ||
284 | crate::bar | |
285 | baz: t | |
286 | ||
287 | crate::bar::baz | |
288 | Bar: t v | |
289 | ||
290 | crate::foo | |
291 | baz: t | |
292 | ||
293 | crate::foo::baz | |
294 | Foo: t v | |
295 | "#]], | |
296 | ); | |
297 | } | |
298 | ||
299 | #[test] | |
300 | fn glob_shadowed_def_dependencies() { | |
301 | check( | |
302 | r#" | |
303 | mod a { pub mod foo { pub struct X; } } | |
304 | mod b { pub use super::a::foo; } | |
305 | mod c { pub mod foo { pub struct Y; } } | |
306 | mod d { | |
307 | use super::c::foo; | |
308 | use super::b::*; | |
309 | use foo::Y; | |
310 | } | |
311 | "#, | |
312 | expect![[r#" | |
313 | crate | |
314 | a: t | |
315 | b: t | |
316 | c: t | |
317 | d: t | |
318 | ||
319 | crate::a | |
320 | foo: t | |
321 | ||
322 | crate::a::foo | |
323 | X: t v | |
324 | ||
325 | crate::b | |
326 | foo: t | |
327 | ||
328 | crate::c | |
329 | foo: t | |
330 | ||
331 | crate::c::foo | |
332 | Y: t v | |
333 | ||
334 | crate::d | |
335 | Y: t v | |
336 | foo: t | |
337 | "#]], | |
338 | ); | |
339 | } | |
487cf647 FG |
340 | |
341 | #[test] | |
342 | fn glob_name_collision_check_visibility() { | |
343 | check( | |
344 | r#" | |
345 | mod event { | |
346 | mod serenity { | |
347 | pub fn Event() {} | |
348 | } | |
349 | use serenity::*; | |
350 | ||
351 | pub struct Event {} | |
352 | } | |
353 | ||
354 | use event::Event; | |
355 | "#, | |
356 | expect![[r#" | |
357 | crate | |
358 | Event: t | |
359 | event: t | |
360 | ||
361 | crate::event | |
362 | Event: t v | |
363 | serenity: t | |
364 | ||
365 | crate::event::serenity | |
366 | Event: v | |
367 | "#]], | |
368 | ); | |
369 | } |