]> git.lizzy.rs Git - rust.git/commitdiff
internal: move some tests
authorAleksey Kladov <aleksey.kladov@gmail.com>
Sat, 9 Oct 2021 15:18:56 +0000 (18:18 +0300)
committerAleksey Kladov <aleksey.kladov@gmail.com>
Sat, 9 Oct 2021 15:18:56 +0000 (18:18 +0300)
crates/hir_def/src/macro_expansion_tests.rs
crates/hir_def/src/macro_expansion_tests/mbe.rs
crates/mbe/src/tests/expand.rs

index 60c9fd7d0a5e8a7c5981fd30f3b0010181bfeca9..c66c75c1436bbf6b77f83f74425c289b46a52ca6 100644 (file)
@@ -126,6 +126,7 @@ fn pretty_print_macro_expansion(expn: SyntaxNode) -> String {
             (T![>], IDENT) => " ",
             (T![>], _) if curr_kind.is_keyword() => " ",
             (T![->], _) | (_, T![->]) => " ",
+            (T![&&], _) | (_, T![&&]) => " ",
             _ => "",
         };
 
index c7442bade6e598a1f09d654b17bdc8d69023d18d..384c70028df08ccfdafb62f96d5b834f3cb802d4 100644 (file)
@@ -346,3 +346,40 @@ fn bar() {
 "#]],
     )
 }
+
+#[test]
+fn test_match_group_with_multichar_sep() {
+    check(
+        r#"
+macro_rules! m {
+    (fn $name:ident { $($i:literal)* }) => ( fn $name() -> bool { $($i)&&* } );
+}
+m! (fn baz { true false } );
+"#,
+        expect![[r#"
+macro_rules! m {
+    (fn $name:ident { $($i:literal)* }) => ( fn $name() -> bool { $($i)&&* } );
+}
+fn baz() -> bool {
+    true && false
+}
+"#]],
+    );
+
+    check(
+        r#"
+macro_rules! m {
+    (fn $name:ident { $($i:literal)&&* }) => ( fn $name() -> bool { $($i)&&* } );
+}
+m! (fn baz { true && false } );
+"#,
+        expect![[r#"
+macro_rules! m {
+    (fn $name:ident { $($i:literal)&&* }) => ( fn $name() -> bool { $($i)&&* } );
+}
+fn baz() -> bool {
+    true && false
+}
+"#]],
+    );
+}
index d0eb49455b709a85fdf64a76468a39258a61190c..c08788cda1ee9e337daa54ed476f252eb23ccef5 100644 (file)
@@ -71,28 +71,6 @@ macro_rules! foobar {
     assert_eq!(get_text(tt::TokenId(13), T!['{']), "{");
 }
 
-#[test]
-fn test_match_group_with_multichar_sep() {
-    parse_macro(
-        r#"
-        macro_rules! foo {
-            (fn $name:ident {$($i:literal)*} ) => ( fn $name() -> bool { $($i)&&*} );
-        }"#,
-    )
-    .assert_expand_items("foo! (fn baz {true true} );", "fn baz () -> bool {true &&true}");
-}
-
-#[test]
-fn test_match_group_with_multichar_sep2() {
-    parse_macro(
-        r#"
-        macro_rules! foo {
-            (fn $name:ident {$($i:literal)&&*} ) => ( fn $name() -> bool { $($i)&&*} );
-        }"#,
-    )
-    .assert_expand_items("foo! (fn baz {true && true} );", "fn baz () -> bool {true &&true}");
-}
-
 #[test]
 fn test_match_group_zero_match() {
     parse_macro(