diff options
Diffstat (limited to 'crates/ra_mbe/src/tests.rs')
-rw-r--r-- | crates/ra_mbe/src/tests.rs | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/crates/ra_mbe/src/tests.rs b/crates/ra_mbe/src/tests.rs index 1dba82915..304867881 100644 --- a/crates/ra_mbe/src/tests.rs +++ b/crates/ra_mbe/src/tests.rs | |||
@@ -825,6 +825,50 @@ fn test_tt_group() { | |||
825 | ) | 825 | ) |
826 | .assert_expand_items(r#"foo! { fn foo() {} }"#, r#"fn foo () {}"#); | 826 | .assert_expand_items(r#"foo! { fn foo() {} }"#, r#"fn foo () {}"#); |
827 | } | 827 | } |
828 | |||
829 | #[test] | ||
830 | fn test_tt_composite() { | ||
831 | parse_macro( | ||
832 | r#" | ||
833 | macro_rules! foo { | ||
834 | ($i:tt) => { 0 } | ||
835 | } | ||
836 | "#, | ||
837 | ) | ||
838 | .assert_expand_items(r#"foo! { => }"#, r#"0"#); | ||
839 | } | ||
840 | |||
841 | #[test] | ||
842 | fn test_tt_composite2() { | ||
843 | let node = parse_macro( | ||
844 | r#" | ||
845 | macro_rules! foo { | ||
846 | ($($tt:tt)*) => { abs!(=> $($tt)*) } | ||
847 | } | ||
848 | "#, | ||
849 | ) | ||
850 | .expand_items(r#"foo!{#}"#); | ||
851 | |||
852 | let res = format!("{:#?}", &node); | ||
853 | assert_eq_text!( | ||
854 | res.trim(), | ||
855 | r###"MACRO_ITEMS@[0; 10) | ||
856 | MACRO_CALL@[0; 10) | ||
857 | PATH@[0; 3) | ||
858 | PATH_SEGMENT@[0; 3) | ||
859 | NAME_REF@[0; 3) | ||
860 | IDENT@[0; 3) "abs" | ||
861 | EXCL@[3; 4) "!" | ||
862 | TOKEN_TREE@[4; 10) | ||
863 | L_PAREN@[4; 5) "(" | ||
864 | EQ@[5; 6) "=" | ||
865 | R_ANGLE@[6; 7) ">" | ||
866 | WHITESPACE@[7; 8) " " | ||
867 | POUND@[8; 9) "#" | ||
868 | R_PAREN@[9; 10) ")""### | ||
869 | ); | ||
870 | } | ||
871 | |||
828 | #[test] | 872 | #[test] |
829 | fn test_lifetime() { | 873 | fn test_lifetime() { |
830 | parse_macro( | 874 | parse_macro( |