|
4 | 4 | mod tt_conversion; |
5 | 5 | mod matching; |
6 | 6 | mod meta_syntax; |
| 7 | +mod metavar_expr; |
7 | 8 | mod regression; |
8 | 9 |
|
9 | 10 | use expect_test::expect; |
@@ -1614,92 +1615,6 @@ struct Foo; |
1614 | 1615 | ) |
1615 | 1616 | } |
1616 | 1617 |
|
1617 | | -#[test] |
1618 | | -fn test_dollar_dollar() { |
1619 | | - check( |
1620 | | - r#" |
1621 | | -macro_rules! register_struct { ($Struct:ident) => { |
1622 | | - macro_rules! register_methods { ($$($method:ident),*) => { |
1623 | | - macro_rules! implement_methods { ($$$$($$val:expr),*) => { |
1624 | | - struct $Struct; |
1625 | | - impl $Struct { $$(fn $method() -> &'static [u32] { &[$$$$($$$$val),*] })*} |
1626 | | - }} |
1627 | | - }} |
1628 | | -}} |
1629 | | -
|
1630 | | -register_struct!(Foo); |
1631 | | -register_methods!(alpha, beta); |
1632 | | -implement_methods!(1, 2, 3); |
1633 | | -"#, |
1634 | | - expect![[r#" |
1635 | | -macro_rules! register_struct { ($Struct:ident) => { |
1636 | | - macro_rules! register_methods { ($$($method:ident),*) => { |
1637 | | - macro_rules! implement_methods { ($$$$($$val:expr),*) => { |
1638 | | - struct $Struct; |
1639 | | - impl $Struct { $$(fn $method() -> &'static [u32] { &[$$$$($$$$val),*] })*} |
1640 | | - }} |
1641 | | - }} |
1642 | | -}} |
1643 | | -
|
1644 | | -macro_rules !register_methods { |
1645 | | - ($($method: ident), *) = > { |
1646 | | - macro_rules!implement_methods { |
1647 | | - ($$($val: expr), *) = > { |
1648 | | - struct Foo; |
1649 | | - impl Foo { |
1650 | | - $(fn $method()-> &'static[u32] { |
1651 | | - &[$$($$val), *] |
1652 | | - } |
1653 | | - )* |
1654 | | - } |
1655 | | - } |
1656 | | - } |
1657 | | - } |
1658 | | -} |
1659 | | -macro_rules !implement_methods { |
1660 | | - ($($val: expr), *) = > { |
1661 | | - struct Foo; |
1662 | | - impl Foo { |
1663 | | - fn alpha()-> &'static[u32] { |
1664 | | - &[$($val), *] |
1665 | | - } |
1666 | | - fn beta()-> &'static[u32] { |
1667 | | - &[$($val), *] |
1668 | | - } |
1669 | | - } |
1670 | | - } |
1671 | | -} |
1672 | | -struct Foo; |
1673 | | -impl Foo { |
1674 | | - fn alpha() -> &'static[u32] { |
1675 | | - &[1, 2, 3] |
1676 | | - } |
1677 | | - fn beta() -> &'static[u32] { |
1678 | | - &[1, 2, 3] |
1679 | | - } |
1680 | | -} |
1681 | | -"#]], |
1682 | | - ) |
1683 | | -} |
1684 | | - |
1685 | | -#[test] |
1686 | | -fn test_metavar_exprs() { |
1687 | | - check( |
1688 | | - r#" |
1689 | | -macro_rules! m { |
1690 | | - ( $( $t:tt )* ) => ( $( ${ignore(t)} -${index()} )-* ); |
1691 | | -} |
1692 | | -const _: i32 = m!(a b c); |
1693 | | - "#, |
1694 | | - expect![[r#" |
1695 | | -macro_rules! m { |
1696 | | - ( $( $t:tt )* ) => ( $( ${ignore(t)} -${index()} )-* ); |
1697 | | -} |
1698 | | -const _: i32 = -0--1--2; |
1699 | | - "#]], |
1700 | | - ); |
1701 | | -} |
1702 | | - |
1703 | 1618 | #[test] |
1704 | 1619 | fn test_punct_without_space() { |
1705 | 1620 | // Puncts are "glued" greedily. |
|
0 commit comments