aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_mbe/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_mbe/src')
-rw-r--r--crates/ra_mbe/src/tests.rs18
1 files changed, 18 insertions, 0 deletions
diff --git a/crates/ra_mbe/src/tests.rs b/crates/ra_mbe/src/tests.rs
index ff225f0db..b5a10a9d2 100644
--- a/crates/ra_mbe/src/tests.rs
+++ b/crates/ra_mbe/src/tests.rs
@@ -1450,6 +1450,24 @@ macro_rules! delegate_impl {
1450 ); 1450 );
1451} 1451}
1452 1452
1453#[test]
1454fn expr_interpolation() {
1455 let rules = create_rules(
1456 r#"
1457 macro_rules! id {
1458 ($expr:expr) => {
1459 map($expr)
1460 }
1461 }
1462 "#,
1463 );
1464
1465 let expanded = expand(&rules, "id!(x + foo);");
1466 let expanded =
1467 token_tree_to_syntax_node(&expanded, FragmentKind::Expr).unwrap().0.syntax_node();
1468 assert_eq!(expanded.to_string(), "map(x+foo)");
1469}
1470
1453pub(crate) fn create_rules(macro_definition: &str) -> MacroRules { 1471pub(crate) fn create_rules(macro_definition: &str) -> MacroRules {
1454 let source_file = ast::SourceFile::parse(macro_definition).ok().unwrap(); 1472 let source_file = ast::SourceFile::parse(macro_definition).ok().unwrap();
1455 let macro_definition = 1473 let macro_definition =