diff options
Diffstat (limited to 'crates/ra_hir/src/nameres/tests.rs')
-rw-r--r-- | crates/ra_hir/src/nameres/tests.rs | 97 |
1 files changed, 1 insertions, 96 deletions
diff --git a/crates/ra_hir/src/nameres/tests.rs b/crates/ra_hir/src/nameres/tests.rs index bd2d855cf..8b0887fb5 100644 --- a/crates/ra_hir/src/nameres/tests.rs +++ b/crates/ra_hir/src/nameres/tests.rs | |||
@@ -2,6 +2,7 @@ mod macros; | |||
2 | mod globs; | 2 | mod globs; |
3 | mod incremental; | 3 | mod incremental; |
4 | mod primitives; | 4 | mod primitives; |
5 | mod mods; | ||
5 | 6 | ||
6 | use std::sync::Arc; | 7 | use std::sync::Arc; |
7 | 8 | ||
@@ -313,83 +314,6 @@ fn edition_2015_imports() { | |||
313 | } | 314 | } |
314 | 315 | ||
315 | #[test] | 316 | #[test] |
316 | fn module_resolution_works_for_non_standard_filenames() { | ||
317 | let map = def_map_with_crate_graph( | ||
318 | " | ||
319 | //- /my_library.rs | ||
320 | mod foo; | ||
321 | use self::foo::Bar; | ||
322 | |||
323 | //- /foo/mod.rs | ||
324 | pub struct Bar; | ||
325 | ", | ||
326 | crate_graph! { | ||
327 | "my_library": ("/my_library.rs", []), | ||
328 | }, | ||
329 | ); | ||
330 | |||
331 | assert_snapshot_matches!(map, @r###" | ||
332 | ⋮crate | ||
333 | ⋮Bar: t v | ||
334 | ⋮foo: t | ||
335 | ⋮ | ||
336 | ⋮crate::foo | ||
337 | ⋮Bar: t v | ||
338 | "###); | ||
339 | } | ||
340 | |||
341 | #[test] | ||
342 | fn module_resolution_works_for_raw_modules() { | ||
343 | let map = def_map_with_crate_graph( | ||
344 | " | ||
345 | //- /library.rs | ||
346 | mod r#async; | ||
347 | use self::r#async::Bar; | ||
348 | |||
349 | //- /async.rs | ||
350 | pub struct Bar; | ||
351 | ", | ||
352 | crate_graph! { | ||
353 | "library": ("/library.rs", []), | ||
354 | }, | ||
355 | ); | ||
356 | |||
357 | assert_snapshot_matches!(map, @r###" | ||
358 | ⋮crate | ||
359 | ⋮Bar: t v | ||
360 | ⋮async: t | ||
361 | ⋮ | ||
362 | ⋮crate::async | ||
363 | ⋮Bar: t v | ||
364 | "###); | ||
365 | } | ||
366 | |||
367 | #[test] | ||
368 | fn name_res_works_for_broken_modules() { | ||
369 | covers!(name_res_works_for_broken_modules); | ||
370 | let map = def_map( | ||
371 | " | ||
372 | //- /lib.rs | ||
373 | mod foo // no `;`, no body | ||
374 | |||
375 | use self::foo::Baz; | ||
376 | |||
377 | //- /foo/mod.rs | ||
378 | pub mod bar; | ||
379 | |||
380 | pub use self::bar::Baz; | ||
381 | |||
382 | //- /foo/bar.rs | ||
383 | pub struct Baz; | ||
384 | ", | ||
385 | ); | ||
386 | assert_snapshot_matches!(map, @r###" | ||
387 | ⋮crate | ||
388 | ⋮Baz: _ | ||
389 | "###); | ||
390 | } | ||
391 | |||
392 | #[test] | ||
393 | fn item_map_using_self() { | 317 | fn item_map_using_self() { |
394 | let map = def_map( | 318 | let map = def_map( |
395 | " | 319 | " |
@@ -581,22 +505,3 @@ fn values_dont_shadow_extern_crates() { | |||
581 | ⋮foo: v | 505 | ⋮foo: v |
582 | "###); | 506 | "###); |
583 | } | 507 | } |
584 | |||
585 | #[test] | ||
586 | fn unresolved_module_diagnostics() { | ||
587 | let diagnostics = MockDatabase::with_files( | ||
588 | r" | ||
589 | //- /lib.rs | ||
590 | mod foo; | ||
591 | mod bar; | ||
592 | mod baz {} | ||
593 | //- /foo.rs | ||
594 | ", | ||
595 | ) | ||
596 | .diagnostics(); | ||
597 | |||
598 | assert_snapshot_matches!(diagnostics, @r###" | ||
599 | "mod bar;": unresolved module | ||
600 | "### | ||
601 | ); | ||
602 | } | ||