From a4b473226bd185e6a016b175bdee22901fafd7ce Mon Sep 17 00:00:00 2001 From: Jeff Muizelaar Date: Mon, 4 Feb 2019 20:18:53 -0500 Subject: mbe: Ensure repetition separator matches --- crates/ra_mbe/src/lib.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'crates/ra_mbe/src/lib.rs') 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); assert_expansion(&rules, "foo! { eggs Baz }", "struct Baz ;"); } + #[test] + fn test_match_group_pattern_by_separator_token() { + let rules = create_rules( + r#" + macro_rules! foo { + ($ ($ i:ident),*) => ($ ( + mod $ i {} + )*); + ($ ($ i:ident)#*) => ($ ( + fn $ i() {} + )*); + ($ i:ident ,# $ j:ident) => ( + struct $ i; + struct $ j; + ) + } +"#, + ); + + assert_expansion(&rules, "foo! { foo, bar }", "mod foo {} mod bar {}"); + assert_expansion(&rules, "foo! { foo# bar }", "fn foo () {} fn bar () {}"); + assert_expansion(&rules, "foo! { Foo,# Bar }", "struct Foo ; struct Bar ;"); + } + } -- cgit v1.2.3