aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_mbe/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_mbe/src/lib.rs')
-rw-r--r--crates/ra_mbe/src/lib.rs44
1 files changed, 44 insertions, 0 deletions
diff --git a/crates/ra_mbe/src/lib.rs b/crates/ra_mbe/src/lib.rs
index a1f438906..2f47e32d3 100644
--- a/crates/ra_mbe/src/lib.rs
+++ b/crates/ra_mbe/src/lib.rs
@@ -597,4 +597,48 @@ SOURCE_FILE@[0; 40)
597 assert_expansion(&rules, "foo! { 2 }", "fn bar () {2 ;}"); 597 assert_expansion(&rules, "foo! { 2 }", "fn bar () {2 ;}");
598 assert_expansion(&rules, "foo! { let a = 0 }", "fn bar () {let a = 0 ;}"); 598 assert_expansion(&rules, "foo! { let a = 0 }", "fn bar () {let a = 0 ;}");
599 } 599 }
600
601 #[test]
602 fn test_single_item() {
603 let rules = create_rules(
604 r#"
605 macro_rules! foo {
606 ($ i:item) => (
607 $ i
608 )
609 }
610"#,
611 );
612 assert_expansion(&rules, "foo! {mod c {}}", "mod c {}");
613 }
614
615 #[test]
616 fn test_all_items() {
617 let rules = create_rules(
618 r#"
619 macro_rules! foo {
620 ($ ($ i:item)*) => ($ (
621 $ i
622 )*)
623 }
624"#,
625 );
626 assert_expansion(&rules, r#"
627 foo! {
628 extern crate a;
629 mod b;
630 mod c {}
631 use d;
632 const E: i32 = 0;
633 static F: i32 = 0;
634 impl G {}
635 struct H;
636 enum I { Foo }
637 trait J {}
638 fn h() {}
639 extern {}
640 type T = u8;
641 }
642"#, r#"extern crate a ; mod b ; mod c {} use d ; const E : i32 = 0 ; static F : i32 = 0 ; impl G {} struct H ; enum I {Foo} trait J {} fn h () {} extern {} type T = u8 ;"#);
643 }
600} 644}