aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_mbe/src/tests.rs
diff options
context:
space:
mode:
authorVincent RouillĂ© <[email protected]>2019-12-28 21:26:24 +0000
committerVincent RouillĂ© <[email protected]>2019-12-28 21:48:49 +0000
commit6d84dee4e7d70f329df71365f98b2421652b2432 (patch)
treee3c58befd8d46c5f994126313ca7daf41b82dd69 /crates/ra_mbe/src/tests.rs
parentc5a48bea1218afb63d7932a6816f34c810bbab6b (diff)
fix #2520: change expand_repeat loop stop condition
Diffstat (limited to 'crates/ra_mbe/src/tests.rs')
-rw-r--r--crates/ra_mbe/src/tests.rs46
1 files changed, 46 insertions, 0 deletions
diff --git a/crates/ra_mbe/src/tests.rs b/crates/ra_mbe/src/tests.rs
index e640d115b..288366cca 100644
--- a/crates/ra_mbe/src/tests.rs
+++ b/crates/ra_mbe/src/tests.rs
@@ -1491,3 +1491,49 @@ fn debug_dump_ignore_spaces(node: &ra_syntax::SyntaxNode) -> String {
1491 1491
1492 buf 1492 buf
1493} 1493}
1494
1495#[test]
1496fn test_issue_2520() {
1497 let macro_fixture = parse_macro(
1498 r#"
1499 macro_rules! my_macro {
1500 {
1501 ( $(
1502 $( [] $sname:ident : $stype:ty )?
1503 $( [$expr:expr] $nname:ident : $ntype:ty )?
1504 ),* )
1505 } => {
1506 Test {
1507 $(
1508 $( $sname, )?
1509 )*
1510 }
1511 };
1512 }
1513 "#,
1514 );
1515
1516 macro_fixture.assert_expand_items(
1517 r#"my_macro ! {
1518 ([] p1 : u32 , [|_| S0K0] s : S0K0 , [] k0 : i32)
1519 }"#,
1520 "Test {p1 , k0 ,}",
1521 );
1522}
1523
1524#[test]
1525fn test_repeat_bad_var() {
1526 parse_macro(
1527 r#"
1528 macro_rules! foo {
1529 ($( $b:ident )+) => {
1530 $( $c )+
1531 };
1532 ($( $b:ident )+) => {
1533 $( $b )+
1534 }
1535 }
1536 "#,
1537 )
1538 .assert_expand_items("foo!(b0 b1);", "b0 b1");
1539}