aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_def/src/nameres/tests/globs.rs
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2020-08-13 15:28:27 +0100
committerAleksey Kladov <[email protected]>2020-08-13 15:29:33 +0100
commitb28c54a2c239acd73f2eea80fda9ee3960d2c046 (patch)
tree1bf0ea193bdb3b16ff42c2c01118b13a4276b2bb /crates/ra_hir_def/src/nameres/tests/globs.rs
parentb7aa4898e0841ab8199643f89a0caa967b698ca8 (diff)
Rename ra_hir_def -> hir_def
Diffstat (limited to 'crates/ra_hir_def/src/nameres/tests/globs.rs')
-rw-r--r--crates/ra_hir_def/src/nameres/tests/globs.rs338
1 files changed, 0 insertions, 338 deletions
diff --git a/crates/ra_hir_def/src/nameres/tests/globs.rs b/crates/ra_hir_def/src/nameres/tests/globs.rs
deleted file mode 100644
index 2ae836e3c..000000000
--- a/crates/ra_hir_def/src/nameres/tests/globs.rs
+++ /dev/null
@@ -1,338 +0,0 @@
1use super::*;
2
3#[test]
4fn glob_1() {
5 check(
6 r#"
7//- /lib.rs
8mod foo;
9use foo::*;
10
11//- /foo/mod.rs
12pub mod bar;
13pub use self::bar::Baz;
14pub struct Foo;
15
16//- /foo/bar.rs
17pub 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]
38fn glob_2() {
39 check(
40 r#"
41//- /lib.rs
42mod foo;
43use foo::*;
44
45//- /foo/mod.rs
46pub mod bar;
47pub use self::bar::*;
48pub struct Foo;
49
50//- /foo/bar.rs
51pub struct Baz;
52pub 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]
75fn glob_privacy_1() {
76 check(
77 r"
78//- /lib.rs
79mod foo;
80use foo::*;
81
82//- /foo/mod.rs
83pub mod bar;
84pub use self::bar::*;
85struct PrivateStructFoo;
86
87//- /foo/bar.rs
88pub struct Baz;
89struct PrivateStructBar;
90pub 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]
113fn glob_privacy_2() {
114 check(
115 r"
116//- /lib.rs
117mod foo;
118use foo::*;
119use foo::bar::*;
120
121//- /foo/mod.rs
122mod bar;
123fn Foo() {};
124pub struct Foo {};
125
126//- /foo/bar.rs
127pub(super) struct PrivateBaz;
128struct PrivateBar;
129pub(crate) struct PubCrateStruct;
130",
131 expect![[r#"
132 crate
133 Foo: t
134 PubCrateStruct: t v
135 foo: t
136
137 crate::foo
138 Foo: t v
139 bar: t
140
141 crate::foo::bar
142 PrivateBar: t v
143 PrivateBaz: t v
144 PubCrateStruct: t v
145 "#]],
146 );
147}
148
149#[test]
150fn glob_across_crates() {
151 mark::check!(glob_across_crates);
152 check(
153 r#"
154//- /main.rs crate:main deps:test_crate
155use test_crate::*;
156
157//- /lib.rs crate:test_crate
158pub struct Baz;
159"#,
160 expect![[r#"
161 crate
162 Baz: t v
163 "#]],
164 );
165}
166
167#[test]
168fn glob_privacy_across_crates() {
169 check(
170 r#"
171//- /main.rs crate:main deps:test_crate
172use test_crate::*;
173
174//- /lib.rs crate:test_crate
175pub struct Baz;
176struct Foo;
177"#,
178 expect![[r#"
179 crate
180 Baz: t v
181 "#]],
182 );
183}
184
185#[test]
186fn glob_enum() {
187 mark::check!(glob_enum);
188 check(
189 r#"
190enum Foo { Bar, Baz }
191use self::Foo::*;
192"#,
193 expect![[r#"
194 crate
195 Bar: t v
196 Baz: t v
197 Foo: t
198 "#]],
199 );
200}
201
202#[test]
203fn glob_enum_group() {
204 mark::check!(glob_enum_group);
205 check(
206 r#"
207enum Foo { Bar, Baz }
208use self::Foo::{*};
209"#,
210 expect![[r#"
211 crate
212 Bar: t v
213 Baz: t v
214 Foo: t
215 "#]],
216 );
217}
218
219#[test]
220fn glob_shadowed_def() {
221 mark::check!(import_shadowed);
222 check(
223 r#"
224//- /lib.rs
225mod foo;
226mod bar;
227use foo::*;
228use bar::baz;
229use baz::Bar;
230
231//- /foo.rs
232pub mod baz { pub struct Foo; }
233
234//- /bar.rs
235pub mod baz { pub struct Bar; }
236"#,
237 expect![[r#"
238 crate
239 Bar: t v
240 bar: t
241 baz: t
242 foo: t
243
244 crate::bar
245 baz: t
246
247 crate::bar::baz
248 Bar: t v
249
250 crate::foo
251 baz: t
252
253 crate::foo::baz
254 Foo: t v
255 "#]],
256 );
257}
258
259#[test]
260fn glob_shadowed_def_reversed() {
261 check(
262 r#"
263//- /lib.rs
264mod foo;
265mod bar;
266use bar::baz;
267use foo::*;
268use baz::Bar;
269
270//- /foo.rs
271pub mod baz { pub struct Foo; }
272
273//- /bar.rs
274pub mod baz { pub struct Bar; }
275"#,
276 expect![[r#"
277 crate
278 Bar: t v
279 bar: t
280 baz: t
281 foo: t
282
283 crate::bar
284 baz: t
285
286 crate::bar::baz
287 Bar: t v
288
289 crate::foo
290 baz: t
291
292 crate::foo::baz
293 Foo: t v
294 "#]],
295 );
296}
297
298#[test]
299fn glob_shadowed_def_dependencies() {
300 check(
301 r#"
302mod a { pub mod foo { pub struct X; } }
303mod b { pub use super::a::foo; }
304mod c { pub mod foo { pub struct Y; } }
305mod d {
306 use super::c::foo;
307 use super::b::*;
308 use foo::Y;
309}
310"#,
311 expect![[r#"
312 crate
313 a: t
314 b: t
315 c: t
316 d: t
317
318 crate::d
319 Y: t v
320 foo: t
321
322 crate::c
323 foo: t
324
325 crate::c::foo
326 Y: t v
327
328 crate::b
329 foo: t
330
331 crate::a
332 foo: t
333
334 crate::a::foo
335 X: t v
336 "#]],
337 );
338}