rust-analyzer/crates/ra_hir_def/src/nameres/tests/globs.rs

136 lines
2 KiB
Rust
Raw Normal View History

2019-03-14 08:53:40 +00:00
use super::*;
#[test]
fn glob_1() {
let map = def_map(
"
//- /lib.rs
mod foo;
use foo::*;
//- /foo/mod.rs
pub mod bar;
pub use self::bar::Baz;
pub struct Foo;
//- /foo/bar.rs
pub struct Baz;
",
);
2019-08-29 13:49:10 +00:00
assert_snapshot!(map, @r###"
2019-05-21 10:18:30 +00:00
crate
Baz: t v
Foo: t v
bar: t
foo: t
crate::foo
Baz: t v
Foo: t v
bar: t
crate::foo::bar
Baz: t v
"###
2019-03-14 08:53:40 +00:00
);
}
#[test]
fn glob_2() {
let map = def_map(
"
//- /lib.rs
mod foo;
use foo::*;
//- /foo/mod.rs
pub mod bar;
pub use self::bar::*;
pub struct Foo;
//- /foo/bar.rs
pub struct Baz;
pub use super::*;
",
);
2019-08-29 13:49:10 +00:00
assert_snapshot!(map, @r###"
2019-05-21 10:18:30 +00:00
crate
Baz: t v
Foo: t v
bar: t
foo: t
crate::foo
Baz: t v
Foo: t v
bar: t
crate::foo::bar
Baz: t v
Foo: t v
bar: t
"###
2019-03-14 08:53:40 +00:00
);
}
#[test]
fn glob_across_crates() {
2019-11-03 20:44:23 +00:00
covers!(glob_across_crates);
2019-11-03 20:35:48 +00:00
let map = def_map(
2019-03-14 08:53:40 +00:00
"
2019-11-03 20:35:48 +00:00
//- /main.rs crate:main deps:test_crate
2019-03-14 08:53:40 +00:00
use test_crate::*;
2019-11-03 20:35:48 +00:00
//- /lib.rs crate:test_crate
2019-03-14 08:53:40 +00:00
pub struct Baz;
",
);
2019-08-29 13:49:10 +00:00
assert_snapshot!(map, @r###"
2019-05-21 10:18:30 +00:00
crate
Baz: t v
"###
2019-03-14 08:53:40 +00:00
);
}
#[test]
fn glob_enum() {
2019-11-03 20:44:23 +00:00
covers!(glob_enum);
2019-03-14 08:53:40 +00:00
let map = def_map(
"
//- /lib.rs
enum Foo {
Bar, Baz
}
use self::Foo::*;
",
);
2019-08-29 13:49:10 +00:00
assert_snapshot!(map, @r###"
2019-05-21 10:18:30 +00:00
crate
Bar: t v
Baz: t v
Foo: t
"###
2019-03-14 08:53:40 +00:00
);
}
2019-12-19 15:57:22 +00:00
#[test]
fn glob_enum_group() {
covers!(glob_enum_group);
let map = def_map(
"
//- /lib.rs
enum Foo {
Bar, Baz
}
use self::Foo::{*};
",
);
assert_snapshot!(map, @r###"
crate
Bar: t v
Baz: t v
Foo: t
"###
);
}