aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/nameres/tests.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir/src/nameres/tests.rs')
-rw-r--r--crates/ra_hir/src/nameres/tests.rs95
1 files changed, 95 insertions, 0 deletions
diff --git a/crates/ra_hir/src/nameres/tests.rs b/crates/ra_hir/src/nameres/tests.rs
index bd2d855cf..5e8ea6780 100644
--- a/crates/ra_hir/src/nameres/tests.rs
+++ b/crates/ra_hir/src/nameres/tests.rs
@@ -365,6 +365,101 @@ fn module_resolution_works_for_raw_modules() {
365} 365}
366 366
367#[test] 367#[test]
368fn module_resolution_decl_path() {
369 let map = def_map_with_crate_graph(
370 "
371 //- /library.rs
372 #[path = \"bar/baz/foo.rs\"]
373 mod foo;
374 use self::foo::Bar;
375
376 //- /bar/baz/foo.rs
377 pub struct Bar;
378 ",
379 crate_graph! {
380 "library": ("/library.rs", []),
381 },
382 );
383
384 assert_snapshot_matches!(map, @r###"
385 ⋮crate
386 ⋮Bar: t v
387 ⋮foo: t
388
389 ⋮crate::foo
390 ⋮Bar: t v
391 "###);
392}
393
394#[test]
395fn module_resolution_module_with_path_in_mod_rs() {
396 let map = def_map_with_crate_graph(
397 "
398 //- /main.rs
399 mod foo;
400
401 //- /foo/mod.rs
402 #[path = \"baz.rs\"]
403 pub mod bar;
404
405 use self::bar::Baz;
406
407 //- /foo/baz.rs
408 pub struct Baz;
409 ",
410 crate_graph! {
411 "main": ("/main.rs", []),
412 },
413 );
414
415 assert_snapshot_matches!(map, @r###"
416 ⋮crate
417 ⋮foo: t
418
419 ⋮crate::foo
420 ⋮Baz: t v
421 ⋮bar: t
422
423 ⋮crate::foo::bar
424 ⋮Baz: t v
425 "###);
426}
427
428#[test]
429fn module_resolution_module_with_path_non_crate_root() {
430 let map = def_map_with_crate_graph(
431 "
432 //- /main.rs
433 mod foo;
434
435 //- /foo.rs
436 #[path = \"baz.rs\"]
437 pub mod bar;
438
439 use self::bar::Baz;
440
441 //- /baz.rs
442 pub struct Baz;
443 ",
444 crate_graph! {
445 "main": ("/main.rs", []),
446 },
447 );
448
449 assert_snapshot_matches!(map, @r###"
450 ⋮crate
451 ⋮foo: t
452
453 ⋮crate::foo
454 ⋮Baz: t v
455 ⋮bar: t
456
457 ⋮crate::foo::bar
458 ⋮Baz: t v
459 "###);
460}
461
462#[test]
368fn name_res_works_for_broken_modules() { 463fn name_res_works_for_broken_modules() {
369 covers!(name_res_works_for_broken_modules); 464 covers!(name_res_works_for_broken_modules);
370 let map = def_map( 465 let map = def_map(