]> git.lizzy.rs Git - rust.git/blob - crates/hir_def/src/macro_expansion_tests/mbe/matching.rs
get organizized
[rust.git] / crates / hir_def / src / macro_expansion_tests / mbe / matching.rs
1 use expect_test::expect;
2
3 use crate::macro_expansion_tests::check;
4
5 #[test]
6 fn unary_minus_is_a_literal() {
7     check(
8         r#"
9 macro_rules! m { ($x:literal) => (literal!()); ($x:tt) => (not_a_literal!()); }
10 m!(92);
11 m!(-92);
12 m!(-9.2);
13 m!(--92);
14 "#,
15         expect![[r#"
16 macro_rules! m { ($x:literal) => (literal!()); ($x:tt) => (not_a_literal!()); }
17 literal!()
18 literal!()
19 literal!()
20 /* error: leftover tokens */not_a_literal!()
21 "#]],
22     )
23 }
24
25 #[test]
26 fn wrong_nesting_level() {
27     check(
28         r#"
29 macro_rules! m {
30     ($($i:ident);*) => ($i)
31 }
32 m!{a}
33 "#,
34         expect![[r#"
35 macro_rules! m {
36     ($($i:ident);*) => ($i)
37 }
38 /* error: expected simple binding, found nested binding `i` */
39 "#]],
40     );
41 }