diff options
Diffstat (limited to 'crates/ra_hir_def/src/nameres/tests')
-rw-r--r-- | crates/ra_hir_def/src/nameres/tests/globs.rs | 47 | ||||
-rw-r--r-- | crates/ra_hir_def/src/nameres/tests/incremental.rs | 38 | ||||
-rw-r--r-- | crates/ra_hir_def/src/nameres/tests/mod_resolution.rs | 28 |
3 files changed, 69 insertions, 44 deletions
diff --git a/crates/ra_hir_def/src/nameres/tests/globs.rs b/crates/ra_hir_def/src/nameres/tests/globs.rs index 2b12c0daa..2f440975a 100644 --- a/crates/ra_hir_def/src/nameres/tests/globs.rs +++ b/crates/ra_hir_def/src/nameres/tests/globs.rs | |||
@@ -229,3 +229,50 @@ fn glob_enum_group() { | |||
229 | "### | 229 | "### |
230 | ); | 230 | ); |
231 | } | 231 | } |
232 | |||
233 | #[test] | ||
234 | fn glob_shadowed_def() { | ||
235 | mark::check!(import_shadowed); | ||
236 | let map = def_map( | ||
237 | r###" | ||
238 | //- /lib.rs | ||
239 | mod foo; | ||
240 | mod bar; | ||
241 | |||
242 | use foo::*; | ||
243 | use bar::baz; | ||
244 | |||
245 | use baz::Bar; | ||
246 | |||
247 | //- /foo.rs | ||
248 | pub mod baz { | ||
249 | pub struct Foo; | ||
250 | } | ||
251 | |||
252 | //- /bar.rs | ||
253 | pub mod baz { | ||
254 | pub struct Bar; | ||
255 | } | ||
256 | "###, | ||
257 | ); | ||
258 | assert_snapshot!(map, @r###" | ||
259 | ⋮crate | ||
260 | ⋮Bar: t v | ||
261 | ⋮bar: t | ||
262 | ⋮baz: t | ||
263 | ⋮foo: t | ||
264 | ⋮ | ||
265 | ⋮crate::bar | ||
266 | ⋮baz: t | ||
267 | ⋮ | ||
268 | ⋮crate::bar::baz | ||
269 | ⋮Bar: t v | ||
270 | ⋮ | ||
271 | ⋮crate::foo | ||
272 | ⋮baz: t | ||
273 | ⋮ | ||
274 | ⋮crate::foo::baz | ||
275 | ⋮Foo: t v | ||
276 | "### | ||
277 | ); | ||
278 | } | ||
diff --git a/crates/ra_hir_def/src/nameres/tests/incremental.rs b/crates/ra_hir_def/src/nameres/tests/incremental.rs index 87165ac33..0c288a108 100644 --- a/crates/ra_hir_def/src/nameres/tests/incremental.rs +++ b/crates/ra_hir_def/src/nameres/tests/incremental.rs | |||
@@ -58,44 +58,6 @@ fn typing_inside_a_function_should_not_invalidate_def_map() { | |||
58 | } | 58 | } |
59 | 59 | ||
60 | #[test] | 60 | #[test] |
61 | fn adding_inner_items_should_not_invalidate_def_map() { | ||
62 | check_def_map_is_not_recomputed( | ||
63 | r" | ||
64 | //- /lib.rs | ||
65 | struct S { a: i32} | ||
66 | enum E { A } | ||
67 | trait T { | ||
68 | fn a() {} | ||
69 | } | ||
70 | mod foo;<|> | ||
71 | impl S { | ||
72 | fn a() {} | ||
73 | } | ||
74 | use crate::foo::bar::Baz; | ||
75 | //- /foo/mod.rs | ||
76 | pub mod bar; | ||
77 | |||
78 | //- /foo/bar.rs | ||
79 | pub struct Baz; | ||
80 | ", | ||
81 | r" | ||
82 | struct S { a: i32, b: () } | ||
83 | enum E { A, B } | ||
84 | trait T { | ||
85 | fn a() {} | ||
86 | fn b() {} | ||
87 | } | ||
88 | mod foo;<|> | ||
89 | impl S { | ||
90 | fn a() {} | ||
91 | fn b() {} | ||
92 | } | ||
93 | use crate::foo::bar::Baz; | ||
94 | ", | ||
95 | ); | ||
96 | } | ||
97 | |||
98 | #[test] | ||
99 | fn typing_inside_a_macro_should_not_invalidate_def_map() { | 61 | fn typing_inside_a_macro_should_not_invalidate_def_map() { |
100 | let (mut db, pos) = TestDB::with_position( | 62 | let (mut db, pos) = TestDB::with_position( |
101 | r" | 63 | r" |
diff --git a/crates/ra_hir_def/src/nameres/tests/mod_resolution.rs b/crates/ra_hir_def/src/nameres/tests/mod_resolution.rs index b43b294ca..753684201 100644 --- a/crates/ra_hir_def/src/nameres/tests/mod_resolution.rs +++ b/crates/ra_hir_def/src/nameres/tests/mod_resolution.rs | |||
@@ -20,8 +20,11 @@ fn name_res_works_for_broken_modules() { | |||
20 | ", | 20 | ", |
21 | ); | 21 | ); |
22 | assert_snapshot!(map, @r###" | 22 | assert_snapshot!(map, @r###" |
23 | ⋮crate | 23 | crate |
24 | ⋮Baz: _ | 24 | Baz: _ |
25 | foo: t | ||
26 | |||
27 | crate::foo | ||
25 | "###); | 28 | "###); |
26 | } | 29 | } |
27 | 30 | ||
@@ -332,6 +335,22 @@ fn module_resolution_relative_path_2() { | |||
332 | } | 335 | } |
333 | 336 | ||
334 | #[test] | 337 | #[test] |
338 | fn module_resolution_relative_path_outside_root() { | ||
339 | let map = def_map( | ||
340 | r###" | ||
341 | //- /main.rs | ||
342 | |||
343 | #[path="../../../../../outside.rs"] | ||
344 | mod foo; | ||
345 | "###, | ||
346 | ); | ||
347 | |||
348 | assert_snapshot!(map, @r###" | ||
349 | ⋮crate | ||
350 | "###); | ||
351 | } | ||
352 | |||
353 | #[test] | ||
335 | fn module_resolution_explicit_path_mod_rs_2() { | 354 | fn module_resolution_explicit_path_mod_rs_2() { |
336 | let map = def_map( | 355 | let map = def_map( |
337 | r###" | 356 | r###" |
@@ -719,10 +738,7 @@ fn unresolved_module_diagnostics() { | |||
719 | ), | 738 | ), |
720 | ), | 739 | ), |
721 | ), | 740 | ), |
722 | value: FileAstId { | 741 | value: FileAstId::<ra_syntax::ast::generated::nodes::Module>(1), |
723 | raw: Idx::<SyntaxNodePtr>(1), | ||
724 | _ty: PhantomData, | ||
725 | }, | ||
726 | }, | 742 | }, |
727 | candidate: "bar.rs", | 743 | candidate: "bar.rs", |
728 | }, | 744 | }, |