Unnamed repository; edit this file 'description' to name the repository.
internal: move tests
Aleksey Kladov 2021-10-10
parent 5a854a7 · commit 6fd2f1d
-rw-r--r--crates/hir_def/src/macro_expansion_tests/mbe.rs54
-rw-r--r--crates/mbe/src/tests/expand.rs37
2 files changed, 54 insertions, 37 deletions
diff --git a/crates/hir_def/src/macro_expansion_tests/mbe.rs b/crates/hir_def/src/macro_expansion_tests/mbe.rs
index dcd0a8880b..dc6ab36b76 100644
--- a/crates/hir_def/src/macro_expansion_tests/mbe.rs
+++ b/crates/hir_def/src/macro_expansion_tests/mbe.rs
@@ -1185,3 +1185,57 @@ ok!();
"#]],
);
}
+
+#[test]
+fn test_vertical_bar_with_pat() {
+ check(
+ r#"
+macro_rules! m { (|$pat:pat| ) => { ok!(); } }
+m! { |x| }
+ "#,
+ expect![[r#"
+macro_rules! m { (|$pat:pat| ) => { ok!(); } }
+ok!();
+ "#]],
+ );
+}
+
+#[test]
+fn test_dollar_crate_lhs_is_not_meta() {
+ check(
+ r#"
+macro_rules! m {
+ ($crate) => { err!(); };
+ () => { ok!(); };
+}
+m!{}
+"#,
+ expect![[r#"
+macro_rules! m {
+ ($crate) => { err!(); };
+ () => { ok!(); };
+}
+ok!();
+"#]],
+ );
+}
+
+#[test]
+fn test_lifetime() {
+ check(
+ r#"
+macro_rules! m {
+ ($lt:lifetime) => { struct Ref<$lt>{ s: &$ lt str } }
+}
+m! {'a}
+"#,
+ expect![[r#"
+macro_rules! m {
+ ($lt:lifetime) => { struct Ref<$lt>{ s: &$ lt str } }
+}
+struct Ref<'a> {
+ s: &'a str
+}
+"#]],
+ );
+}
diff --git a/crates/mbe/src/tests/expand.rs b/crates/mbe/src/tests/expand.rs
index 52a218ed11..8dd1f33119 100644
--- a/crates/mbe/src/tests/expand.rs
+++ b/crates/mbe/src/tests/expand.rs
@@ -102,43 +102,6 @@ fn test_attr_to_token_tree() {
}
#[test]
-fn test_vertical_bar_with_pat() {
- parse_macro(
- r#"
- macro_rules! foo {
- (| $pat:pat | ) => { 0 }
- }
- "#,
- )
- .assert_expand_items(r#"foo! { | x | }"#, r#"0"#);
-}
-
-#[test]
-fn test_dollar_crate_lhs_is_not_meta() {
- parse_macro(
- r#"
-macro_rules! foo {
- ($crate) => {};
- () => {0};
-}
- "#,
- )
- .assert_expand_items(r#"foo!{}"#, r#"0"#);
-}
-
-#[test]
-fn test_lifetime() {
- parse_macro(
- r#"
- macro_rules! foo {
- ($ lt:lifetime) => { struct Ref<$ lt>{ s: &$ lt str } }
- }
-"#,
- )
- .assert_expand_items(r#"foo!{'a}"#, r#"struct Ref <'a > {s : &'a str}"#);
-}
-
-#[test]
fn test_literal() {
parse_macro(
r#"