From 6fd2f1d25b807a72660034dd05e80abf3c462594 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sun, 10 Oct 2021 12:45:17 +0300 Subject: [PATCH] internal: move tests --- .../hir_def/src/macro_expansion_tests/mbe.rs | 54 +++++++++++++++++++ crates/mbe/src/tests/expand.rs | 37 ------------- 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 dcd0a8880b8..dc6ab36b761 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 52a218ed116..8dd1f331194 100644 --- a/crates/mbe/src/tests/expand.rs +++ b/crates/mbe/src/tests/expand.rs @@ -101,43 +101,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(