Unnamed repository; edit this file 'description' to name the repository.
move tests
Aleksey Kladov 2021-10-10
parent 1c15f47 · commit 9c819ea
-rw-r--r--crates/hir_def/src/macro_expansion_tests/mbe.rs72
-rw-r--r--crates/mbe/src/tests/expand.rs41
2 files changed, 65 insertions, 48 deletions
diff --git a/crates/hir_def/src/macro_expansion_tests/mbe.rs b/crates/hir_def/src/macro_expansion_tests/mbe.rs
index 0d3d86c8ad..1cabce70fe 100644
--- a/crates/hir_def/src/macro_expansion_tests/mbe.rs
+++ b/crates/hir_def/src/macro_expansion_tests/mbe.rs
@@ -783,13 +783,13 @@ x!();
fn test_ty() {
check(
r#"
-macro_rules! foo {
+macro_rules! m {
($t:ty) => ( fn bar() -> $t {} )
}
-foo! { Baz<u8> }
+m! { Baz<u8> }
"#,
expect![[r#"
-macro_rules! foo {
+macro_rules! m {
($t:ty) => ( fn bar() -> $t {} )
}
fn bar() -> Baz<u8> {}
@@ -801,16 +801,16 @@ fn bar() -> Baz<u8> {}
fn test_ty_with_complex_type() {
check(
r#"
-macro_rules! foo {
+macro_rules! m {
($t:ty) => ( fn bar() -> $ t {} )
}
-foo! { &'a Baz<u8> }
+m! { &'a Baz<u8> }
-foo! { extern "Rust" fn() -> Ret }
+m! { extern "Rust" fn() -> Ret }
"#,
expect![[r#"
-macro_rules! foo {
+macro_rules! m {
($t:ty) => ( fn bar() -> $ t {} )
}
@@ -820,3 +820,61 @@ fn bar() -> extern"Rust"fn() -> Ret {}
"#]],
);
}
+
+#[test]
+fn test_pat_() {
+ check(
+ r#"
+macro_rules! m {
+ ($p:pat) => { fn foo() { let $p; } }
+}
+m! { (a, b) }
+"#,
+ expect![[r#"
+macro_rules! m {
+ ($p:pat) => { fn foo() { let $p; } }
+}
+fn foo() {
+ let(a,b);
+}
+"#]],
+ );
+}
+
+#[test]
+fn test_stmt() {
+ check(
+ r#"
+macro_rules! m {
+ ($s:stmt) => ( fn bar() { $s; } )
+}
+m! { 2 }
+m! { let a = 0 }
+"#,
+ expect![[r#"
+macro_rules! m {
+ ($s:stmt) => ( fn bar() { $s; } )
+}
+fn bar() {
+ 2;
+}
+fn bar() {
+ let a = 0;
+}
+"#]],
+ )
+}
+
+#[test]
+fn test_single_item() {
+ check(
+ r#"
+macro_rules! m { ($i:item) => ( $i ) }
+m! { mod c {} }
+"#,
+ expect![[r#"
+macro_rules! m { ($i:item) => ( $i ) }
+mod c {}
+"#]],
+ )
+}
diff --git a/crates/mbe/src/tests/expand.rs b/crates/mbe/src/tests/expand.rs
index 8528318152..2cb0fc4aad 100644
--- a/crates/mbe/src/tests/expand.rs
+++ b/crates/mbe/src/tests/expand.rs
@@ -102,47 +102,6 @@ fn test_attr_to_token_tree() {
}
#[test]
-fn test_pat_() {
- parse_macro(
- r#"
- macro_rules! foo {
- ($ i:pat) => { fn foo() { let $ i; } }
- }
-"#,
- )
- .assert_expand_items("foo! { (a, b) }", "fn foo () {let (a , b) ;}");
-}
-
-#[test]
-fn test_stmt() {
- parse_macro(
- r#"
- macro_rules! foo {
- ($ i:stmt) => (
- fn bar() { $ i; }
- )
- }
-"#,
- )
- .assert_expand_items("foo! { 2 }", "fn bar () {2 ;}")
- .assert_expand_items("foo! { let a = 0 }", "fn bar () {let a = 0 ;}");
-}
-
-#[test]
-fn test_single_item() {
- parse_macro(
- r#"
- macro_rules! foo {
- ($ i:item) => (
- $ i
- )
- }
-"#,
- )
- .assert_expand_items("foo! {mod c {}}", "mod c {}");
-}
-
-#[test]
fn test_all_items() {
parse_macro(
r#"