aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_ty/src/tests
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-01-11 03:51:04 +0000
committerGitHub <[email protected]>2020-01-11 03:51:04 +0000
commit991b62a4f935ce49dafbf0ce252f7fdb467daae8 (patch)
tree4a3f664b0b4337500cf904661597a9169511de85 /crates/ra_hir_ty/src/tests
parenta9ba32e2e659dbbe78f7921f5b0abe7288c83aa9 (diff)
parentdd6ec81d658f7cd06b7ed37174b170f0e8930eed (diff)
Merge #2790
2790: Add test for macro expansion in various expressions r=edwin0cheng a=flodiebold cc @edwin0cheng Co-authored-by: Florian Diebold <[email protected]>
Diffstat (limited to 'crates/ra_hir_ty/src/tests')
-rw-r--r--crates/ra_hir_ty/src/tests/macros.rs81
1 files changed, 81 insertions, 0 deletions
diff --git a/crates/ra_hir_ty/src/tests/macros.rs b/crates/ra_hir_ty/src/tests/macros.rs
index 69c695cc8..9d09d93a7 100644
--- a/crates/ra_hir_ty/src/tests/macros.rs
+++ b/crates/ra_hir_ty/src/tests/macros.rs
@@ -136,6 +136,87 @@ fn main() {
136} 136}
137 137
138#[test] 138#[test]
139fn expr_macro_expanded_in_various_places() {
140 assert_snapshot!(
141 infer(r#"
142macro_rules! spam {
143 () => (1isize);
144}
145
146fn spam() {
147 spam!();
148 (spam!());
149 spam!().spam(spam!());
150 for _ in spam!() {}
151 || spam!();
152 while spam!() {}
153 break spam!();
154 return spam!();
155 match spam!() {
156 _ if spam!() => spam!(),
157 }
158 spam!()(spam!());
159 Spam { spam: spam!() };
160 spam!()[spam!()];
161 await spam!();
162 spam!() as usize;
163 &spam!();
164 -spam!();
165 spam!()..spam!();
166 spam!() + spam!();
167}
168"#),
169 @r###"
170 ![0; 6) '1isize': isize
171 ![0; 6) '1isize': isize
172 ![0; 6) '1isize': isize
173 ![0; 6) '1isize': isize
174 ![0; 6) '1isize': isize
175 ![0; 6) '1isize': isize
176 ![0; 6) '1isize': isize
177 ![0; 6) '1isize': isize
178 ![0; 6) '1isize': isize
179 ![0; 6) '1isize': isize
180 ![0; 6) '1isize': isize
181 ![0; 6) '1isize': isize
182 ![0; 6) '1isize': isize
183 ![0; 6) '1isize': isize
184 ![0; 6) '1isize': isize
185 ![0; 6) '1isize': isize
186 ![0; 6) '1isize': isize
187 ![0; 6) '1isize': isize
188 ![0; 6) '1isize': isize
189 ![0; 6) '1isize': isize
190 ![0; 6) '1isize': isize
191 ![0; 6) '1isize': isize
192 ![0; 6) '1isize': isize
193 ![0; 6) '1isize': isize
194 ![0; 6) '1isize': isize
195 [54; 457) '{ ...!(); }': !
196 [88; 109) 'spam!(...am!())': {unknown}
197 [115; 134) 'for _ ...!() {}': ()
198 [119; 120) '_': {unknown}
199 [132; 134) '{}': ()
200 [139; 149) '|| spam!()': || -> isize
201 [155; 171) 'while ...!() {}': ()
202 [169; 171) '{}': ()
203 [176; 189) 'break spam!()': !
204 [195; 209) 'return spam!()': !
205 [215; 269) 'match ... }': isize
206 [239; 240) '_': isize
207 [274; 290) 'spam!(...am!())': {unknown}
208 [296; 318) 'Spam {...m!() }': {unknown}
209 [324; 340) 'spam!(...am!()]': {unknown}
210 [365; 381) 'spam!(... usize': usize
211 [387; 395) '&spam!()': &isize
212 [401; 409) '-spam!()': isize
213 [415; 431) 'spam!(...pam!()': {unknown}
214 [437; 454) 'spam!(...pam!()': isize
215 "###
216 );
217}
218
219#[test]
139fn infer_type_value_macro_having_same_name() { 220fn infer_type_value_macro_having_same_name() {
140 assert_snapshot!( 221 assert_snapshot!(
141 infer(r#" 222 infer(r#"