diff options
author | Aleksey Kladov <[email protected]> | 2019-12-19 13:43:19 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-12-19 13:43:19 +0000 |
commit | 5c3c2b869085a26187c0f7c7bcd4ee58bc1075a9 (patch) | |
tree | 15bfa093d9decc4425d5763a4f912a5ecd07d482 /crates/ra_mbe | |
parent | 8dd0e0086fc07422c9b1044b1db021cff6563214 (diff) |
Fix parsing of interpolated expressions
Diffstat (limited to 'crates/ra_mbe')
-rw-r--r-- | crates/ra_mbe/src/tests.rs | 18 |
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] | ||
1454 | fn 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 | |||
1453 | pub(crate) fn create_rules(macro_definition: &str) -> MacroRules { | 1471 | pub(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 = |