diff options
Diffstat (limited to 'crates/ra_hir/src/nameres/tests/globs.rs')
-rw-r--r-- | crates/ra_hir/src/nameres/tests/globs.rs | 118 |
1 files changed, 118 insertions, 0 deletions
diff --git a/crates/ra_hir/src/nameres/tests/globs.rs b/crates/ra_hir/src/nameres/tests/globs.rs new file mode 100644 index 000000000..6e50c7ff6 --- /dev/null +++ b/crates/ra_hir/src/nameres/tests/globs.rs | |||
@@ -0,0 +1,118 @@ | |||
1 | use super::*; | ||
2 | |||
3 | #[test] | ||
4 | fn glob_1() { | ||
5 | let map = def_map( | ||
6 | " | ||
7 | //- /lib.rs | ||
8 | mod foo; | ||
9 | use foo::*; | ||
10 | |||
11 | //- /foo/mod.rs | ||
12 | pub mod bar; | ||
13 | pub use self::bar::Baz; | ||
14 | pub struct Foo; | ||
15 | |||
16 | //- /foo/bar.rs | ||
17 | pub struct Baz; | ||
18 | ", | ||
19 | ); | ||
20 | assert_snapshot_matches!(map, @r###" | ||
21 | crate | ||
22 | bar: t | ||
23 | Foo: t v | ||
24 | Baz: t v | ||
25 | foo: t | ||
26 | |||
27 | crate::foo | ||
28 | bar: t | ||
29 | Foo: t v | ||
30 | Baz: t v | ||
31 | |||
32 | crate::foo::bar | ||
33 | Baz: t v | ||
34 | "### | ||
35 | ); | ||
36 | } | ||
37 | |||
38 | #[test] | ||
39 | fn glob_2() { | ||
40 | let map = def_map( | ||
41 | " | ||
42 | //- /lib.rs | ||
43 | mod foo; | ||
44 | use foo::*; | ||
45 | |||
46 | //- /foo/mod.rs | ||
47 | pub mod bar; | ||
48 | pub use self::bar::*; | ||
49 | pub struct Foo; | ||
50 | |||
51 | //- /foo/bar.rs | ||
52 | pub struct Baz; | ||
53 | pub use super::*; | ||
54 | ", | ||
55 | ); | ||
56 | assert_snapshot_matches!(map, @r###" | ||
57 | crate | ||
58 | bar: t | ||
59 | Foo: t v | ||
60 | Baz: t v | ||
61 | foo: t | ||
62 | |||
63 | crate::foo | ||
64 | bar: t | ||
65 | Foo: t v | ||
66 | Baz: t v | ||
67 | |||
68 | crate::foo::bar | ||
69 | bar: t | ||
70 | Foo: t v | ||
71 | Baz: t v | ||
72 | "### | ||
73 | ); | ||
74 | } | ||
75 | |||
76 | #[test] | ||
77 | fn glob_across_crates() { | ||
78 | covers!(glob_across_crates); | ||
79 | let map = def_map_with_crate_graph( | ||
80 | " | ||
81 | //- /main.rs | ||
82 | use test_crate::*; | ||
83 | |||
84 | //- /lib.rs | ||
85 | pub struct Baz; | ||
86 | ", | ||
87 | crate_graph! { | ||
88 | "main": ("/main.rs", ["test_crate"]), | ||
89 | "test_crate": ("/lib.rs", []), | ||
90 | }, | ||
91 | ); | ||
92 | assert_snapshot_matches!(map, @r###" | ||
93 | crate | ||
94 | Baz: t v | ||
95 | "### | ||
96 | ); | ||
97 | } | ||
98 | |||
99 | #[test] | ||
100 | fn glob_enum() { | ||
101 | covers!(glob_enum); | ||
102 | let map = def_map( | ||
103 | " | ||
104 | //- /lib.rs | ||
105 | enum Foo { | ||
106 | Bar, Baz | ||
107 | } | ||
108 | use self::Foo::*; | ||
109 | ", | ||
110 | ); | ||
111 | assert_snapshot_matches!(map, @r###" | ||
112 | crate | ||
113 | Foo: t | ||
114 | Bar: t v | ||
115 | Baz: t v | ||
116 | "### | ||
117 | ); | ||
118 | } | ||