Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/hir_def/src/macro_expansion_tests/mbe/matching.rs')
| -rw-r--r-- | crates/hir_def/src/macro_expansion_tests/mbe/matching.rs | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/crates/hir_def/src/macro_expansion_tests/mbe/matching.rs b/crates/hir_def/src/macro_expansion_tests/mbe/matching.rs new file mode 100644 index 0000000000..11317cfa9d --- /dev/null +++ b/crates/hir_def/src/macro_expansion_tests/mbe/matching.rs @@ -0,0 +1,25 @@ +//! Test that `$var:expr` captures function correctly. + +use expect_test::expect; + +use crate::macro_expansion_tests::check; + +#[test] +fn unary_minus_is_a_literal() { + check( + r#" +macro_rules! m { ($x:literal) => (literal!()); ($x:tt) => (not_a_literal!()); } +m!(92); +m!(-92); +m!(-9.2); +m!(--92); +"#, + expect![[r#" +macro_rules! m { ($x:literal) => (literal!()); ($x:tt) => (not_a_literal!()); } +literal!() +literal!() +literal!() +/* error: leftover tokens */not_a_literal!() +"#]], + ) +} |