diff options
Diffstat (limited to 'crates/ra_mbe/src/lib.rs')
-rw-r--r-- | crates/ra_mbe/src/lib.rs | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/crates/ra_mbe/src/lib.rs b/crates/ra_mbe/src/lib.rs index 6f719acbf..2c8ad4429 100644 --- a/crates/ra_mbe/src/lib.rs +++ b/crates/ra_mbe/src/lib.rs | |||
@@ -256,4 +256,28 @@ impl_froms!(TokenTree: Leaf, Subtree); | |||
256 | assert_expansion(&rules, "foo! { eggs Baz }", "struct Baz ;"); | 256 | assert_expansion(&rules, "foo! { eggs Baz }", "struct Baz ;"); |
257 | } | 257 | } |
258 | 258 | ||
259 | #[test] | ||
260 | fn test_match_group_pattern_by_separator_token() { | ||
261 | let rules = create_rules( | ||
262 | r#" | ||
263 | macro_rules! foo { | ||
264 | ($ ($ i:ident),*) => ($ ( | ||
265 | mod $ i {} | ||
266 | )*); | ||
267 | ($ ($ i:ident)#*) => ($ ( | ||
268 | fn $ i() {} | ||
269 | )*); | ||
270 | ($ i:ident ,# $ j:ident) => ( | ||
271 | struct $ i; | ||
272 | struct $ j; | ||
273 | ) | ||
274 | } | ||
275 | "#, | ||
276 | ); | ||
277 | |||
278 | assert_expansion(&rules, "foo! { foo, bar }", "mod foo {} mod bar {}"); | ||
279 | assert_expansion(&rules, "foo! { foo# bar }", "fn foo () {} fn bar () {}"); | ||
280 | assert_expansion(&rules, "foo! { Foo,# Bar }", "struct Foo ; struct Bar ;"); | ||
281 | } | ||
282 | |||
259 | } | 283 | } |