]> git.lizzy.rs Git - rust.git/commitdiff
move test
authorAleksey Kladov <aleksey.kladov@gmail.com>
Sat, 9 Oct 2021 13:25:37 +0000 (16:25 +0300)
committerAleksey Kladov <aleksey.kladov@gmail.com>
Sat, 9 Oct 2021 13:25:37 +0000 (16:25 +0300)
crates/hir_def/src/macro_expansion_tests/mbe.rs
crates/mbe/src/tests/expand.rs

index 1e3d554b83ac24272443608c63dae3ccce8b3809..09688e16b6388cd9ad9e08147a0ec7d105ddc39a 100644 (file)
@@ -48,7 +48,7 @@ macro_rules! m {
 }
 
 #[test]
-fn tries_all_branches_matching_token_literally() {
+fn tries_all_branches_matching_first_token_literally() {
     check(
         r#"
 macro_rules! m {
@@ -70,5 +70,31 @@ mod foo {}
 fn bar() {}
 struct Baz;
 "#]],
-    )
+    );
+}
+
+#[test]
+fn tries_all_branches_matching_last_token_literally() {
+    check(
+        r#"
+macro_rules! m {
+    ($ i:ident) => ( mod $ i {} );
+    ($ i:ident =) => ( fn $ i() {} );
+    ($ i:ident +) => ( struct $ i; )
+}
+m! { foo }
+m! { bar = }
+m! { Baz + }
+"#,
+        expect![[r#"
+macro_rules! m {
+    ($ i:ident) => ( mod $ i {} );
+    ($ i:ident =) => ( fn $ i() {} );
+    ($ i:ident +) => ( struct $ i; )
+}
+mod foo {}
+fn bar() {}
+struct Baz;
+"#]],
+    );
 }
index 48143f0a60b091c017551c99b472950432933d4d..f746eb5a1a62bd2e1a12157666b7ce07b91470cb 100644 (file)
@@ -209,28 +209,6 @@ macro_rules! foo {
     );
 }
 
-#[test]
-fn test_fail_match_pattern_by_last_token() {
-    parse_macro(
-        r#"
-        macro_rules! foo {
-            ($ i:ident) => (
-                mod $ i {}
-            );
-            ($ i:ident =) => (
-                fn $ i() {}
-            );
-            ($ i:ident +) => (
-                struct $ i;
-            )
-        }
-"#,
-    )
-    .assert_expand_items("foo! { foo }", "mod foo {}")
-    .assert_expand_items("foo! { bar = }", "fn bar () {}")
-    .assert_expand_items("foo! { Baz + }", "struct Baz ;");
-}
-
 #[test]
 fn test_fail_match_pattern_by_word_token() {
     parse_macro(