From 175229ab3d3243991aebfad6cf7052c1b5bc4ecf Mon Sep 17 00:00:00 2001 From: Edwin Cheng Date: Fri, 11 Dec 2020 17:59:04 +0800 Subject: negative sign matching in mbe matching for literal --- crates/mbe/src/tests.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'crates/mbe/src/tests.rs') diff --git a/crates/mbe/src/tests.rs b/crates/mbe/src/tests.rs index 0796ceee1..843054fe8 100644 --- a/crates/mbe/src/tests.rs +++ b/crates/mbe/src/tests.rs @@ -1008,11 +1008,20 @@ fn test_literal() { parse_macro( r#" macro_rules! foo { - ($ type:ty $ lit:literal) => { const VALUE: $ type = $ lit;}; + ($ type:ty , $ lit:literal) => { const VALUE: $ type = $ lit;}; } "#, ) - .assert_expand_items(r#"foo!(u8 0);"#, r#"const VALUE : u8 = 0 ;"#); + .assert_expand_items(r#"foo!(u8,0);"#, r#"const VALUE : u8 = 0 ;"#); + + parse_macro( + r#" + macro_rules! foo { + ($ type:ty , $ lit:literal) => { const VALUE: $ type = $ lit;}; + } +"#, + ) + .assert_expand_items(r#"foo!(i32,-1);"#, r#"const VALUE : i32 = - 1 ;"#); } #[test] -- cgit v1.2.3