aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_def/src/nameres/tests/macros.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir_def/src/nameres/tests/macros.rs')
-rw-r--r--crates/ra_hir_def/src/nameres/tests/macros.rs70
1 files changed, 53 insertions, 17 deletions
diff --git a/crates/ra_hir_def/src/nameres/tests/macros.rs b/crates/ra_hir_def/src/nameres/tests/macros.rs
index b0befdfbd..84480d9f6 100644
--- a/crates/ra_hir_def/src/nameres/tests/macros.rs
+++ b/crates/ra_hir_def/src/nameres/tests/macros.rs
@@ -19,12 +19,12 @@ fn macro_rules_are_globally_visible() {
19 ); 19 );
20 assert_snapshot!(map, @r###" 20 assert_snapshot!(map, @r###"
21 ⋮crate 21 ⋮crate
22 ⋮Foo: t v 22 ⋮Foo: t
23 ⋮nested: t 23 ⋮nested: t
24 24
25 ⋮crate::nested 25 ⋮crate::nested
26 ⋮Bar: t v 26 ⋮Bar: t
27 ⋮Baz: t v 27 ⋮Baz: t
28 "###); 28 "###);
29} 29}
30 30
@@ -91,13 +91,13 @@ fn macro_rules_from_other_crates_are_visible() {
91 ); 91 );
92 assert_snapshot!(map, @r###" 92 assert_snapshot!(map, @r###"
93 ⋮crate 93 ⋮crate
94 ⋮Bar: t v 94 ⋮Bar: t
95 ⋮Foo: t v 95 ⋮Foo: t
96 ⋮bar: t 96 ⋮bar: t
97 97
98 ⋮crate::bar 98 ⋮crate::bar
99 ⋮Bar: t v 99 ⋮Bar: t
100 ⋮Foo: t v 100 ⋮Foo: t
101 ⋮bar: t 101 ⋮bar: t
102 "###); 102 "###);
103} 103}
@@ -124,13 +124,50 @@ fn macro_rules_export_with_local_inner_macros_are_visible() {
124 ); 124 );
125 assert_snapshot!(map, @r###" 125 assert_snapshot!(map, @r###"
126 ⋮crate 126 ⋮crate
127 ⋮Bar: t v 127 ⋮Bar: t
128 ⋮Foo: t v 128 ⋮Foo: t
129 ⋮bar: t 129 ⋮bar: t
130 130
131 ⋮crate::bar 131 ⋮crate::bar
132 ⋮Bar: t v 132 ⋮Bar: t
133 ⋮Foo: t v 133 ⋮Foo: t
134 ⋮bar: t
135 "###);
136}
137
138#[test]
139fn local_inner_macros_makes_local_macros_usable() {
140 let map = def_map(
141 "
142 //- /main.rs crate:main deps:foo
143 foo::structs!(Foo, Bar);
144 mod bar;
145 //- /bar.rs
146 use crate::*;
147 //- /lib.rs crate:foo
148 #[macro_export(local_inner_macros)]
149 macro_rules! structs {
150 ($($i:ident),*) => {
151 inner!($($i),*);
152 }
153 }
154 #[macro_export]
155 macro_rules! inner {
156 ($($i:ident),*) => {
157 $(struct $i { field: u32 } )*
158 }
159 }
160 ",
161 );
162 assert_snapshot!(map, @r###"
163 ⋮crate
164 ⋮Bar: t
165 ⋮Foo: t
166 ⋮bar: t
167
168 ⋮crate::bar
169 ⋮Bar: t
170 ⋮Foo: t
134 ⋮bar: t 171 ⋮bar: t
135 "###); 172 "###);
136} 173}
@@ -167,7 +204,7 @@ fn unexpanded_macro_should_expand_by_fixedpoint_loop() {
167 ); 204 );
168 assert_snapshot!(map, @r###" 205 assert_snapshot!(map, @r###"
169 ⋮crate 206 ⋮crate
170 ⋮Foo: t v 207 ⋮Foo: t
171 ⋮bar: m 208 ⋮bar: m
172 ⋮foo: m 209 ⋮foo: m
173 "###); 210 "###);
@@ -175,7 +212,7 @@ fn unexpanded_macro_should_expand_by_fixedpoint_loop() {
175 212
176#[test] 213#[test]
177fn macro_rules_from_other_crates_are_visible_with_macro_use() { 214fn macro_rules_from_other_crates_are_visible_with_macro_use() {
178 covers!(macro_rules_from_other_crates_are_visible_with_macro_use); 215 mark::check!(macro_rules_from_other_crates_are_visible_with_macro_use);
179 let map = def_map( 216 let map = def_map(
180 " 217 "
181 //- /main.rs crate:main deps:foo 218 //- /main.rs crate:main deps:foo
@@ -225,7 +262,7 @@ fn macro_rules_from_other_crates_are_visible_with_macro_use() {
225 262
226#[test] 263#[test]
227fn prelude_is_macro_use() { 264fn prelude_is_macro_use() {
228 covers!(prelude_is_macro_use); 265 mark::check!(prelude_is_macro_use);
229 let map = def_map( 266 let map = def_map(
230 " 267 "
231 //- /main.rs crate:main deps:foo 268 //- /main.rs crate:main deps:foo
@@ -507,8 +544,7 @@ fn path_qualified_macros() {
507 544
508#[test] 545#[test]
509fn macro_dollar_crate_is_correct_in_item() { 546fn macro_dollar_crate_is_correct_in_item() {
510 covers!(macro_dollar_crate_self); 547 mark::check!(macro_dollar_crate_self);
511 covers!(macro_dollar_crate_other);
512 let map = def_map( 548 let map = def_map(
513 " 549 "
514 //- /main.rs crate:main deps:foo 550 //- /main.rs crate:main deps:foo
@@ -566,7 +602,7 @@ fn macro_dollar_crate_is_correct_in_item() {
566 602
567#[test] 603#[test]
568fn macro_dollar_crate_is_correct_in_indirect_deps() { 604fn macro_dollar_crate_is_correct_in_indirect_deps() {
569 covers!(macro_dollar_crate_other); 605 mark::check!(macro_dollar_crate_other);
570 // From std 606 // From std
571 let map = def_map( 607 let map = def_map(
572 r#" 608 r#"