aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_mbe/src/tests.rs
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-12-31 19:57:26 +0000
committerGitHub <[email protected]>2019-12-31 19:57:26 +0000
commitc3a86325daabcabcff72d9eb00040c55ca90a483 (patch)
tree405355b7f8df139992428386bc4395b21c11f9a4 /crates/ra_mbe/src/tests.rs
parente4d217074d1f2c922cf8c5a247ca05fa06b0b7ed (diff)
parentdc989309655a5a587a1d3ea154bbc21d67fea423 (diff)
Merge pull request #2672 from Speedy37/master
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.rs48
1 files changed, 48 insertions, 0 deletions
diff --git a/crates/ra_mbe/src/tests.rs b/crates/ra_mbe/src/tests.rs
index e640d115b..e0d689704 100644
--- a/crates/ra_mbe/src/tests.rs
+++ b/crates/ra_mbe/src/tests.rs
@@ -1491,3 +1491,51 @@ 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 // FIXME: the second rule of the macro should be removed and an error about
1527 // `$( $c )+` raised
1528 parse_macro(
1529 r#"
1530 macro_rules! foo {
1531 ($( $b:ident )+) => {
1532 $( $c )+
1533 };
1534 ($( $b:ident )+) => {
1535 $( $b )+
1536 }
1537 }
1538 "#,
1539 )
1540 .assert_expand_items("foo!(b0 b1);", "b0 b1");
1541}