From 1c15f47e00184aac1e830e1cfa57a8fff7ba272b Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sun, 10 Oct 2021 11:11:50 +0300 Subject: [PATCH] internal: move tests --- .../hir_def/src/macro_expansion_tests/mbe.rs | 42 +++++++++++++++++++ crates/mbe/src/tests/expand.rs | 37 ---------------- 2 files changed, 42 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 958f2a1c331..0d3d86c8ad6 100644 --- a/crates/hir_def/src/macro_expansion_tests/mbe.rs +++ b/crates/hir_def/src/macro_expansion_tests/mbe.rs @@ -778,3 +778,45 @@ x!(); "#]], ) } + +#[test] +fn test_ty() { + check( + r#" +macro_rules! foo { + ($t:ty) => ( fn bar() -> $t {} ) +} +foo! { Baz } +"#, + expect![[r#" +macro_rules! foo { + ($t:ty) => ( fn bar() -> $t {} ) +} +fn bar() -> Baz {} +"#]], + ) +} + +#[test] +fn test_ty_with_complex_type() { + check( + r#" +macro_rules! foo { + ($t:ty) => ( fn bar() -> $ t {} ) +} + +foo! { &'a Baz } + +foo! { extern "Rust" fn() -> Ret } +"#, + expect![[r#" +macro_rules! foo { + ($t:ty) => ( fn bar() -> $ t {} ) +} + +fn bar() -> & 'a Baz {} + +fn bar() -> extern"Rust"fn() -> Ret {} +"#]], + ); +} diff --git a/crates/mbe/src/tests/expand.rs b/crates/mbe/src/tests/expand.rs index 01b55335226..85283181523 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_ty() { - parse_macro( - r#" - macro_rules! foo { - ($ i:ty) => ( - fn bar() -> $ i { unimplemented!() } - ) - } -"#, - ) - .assert_expand_items("foo! { Baz }", "fn bar () -> Baz < u8 > {unimplemented ! ()}"); -} - -#[test] -fn test_ty_with_complex_type() { - parse_macro( - r#" - macro_rules! foo { - ($ i:ty) => ( - fn bar() -> $ i { unimplemented!() } - ) - } -"#, - ) - // Reference lifetime struct with generic type - .assert_expand_items( - "foo! { &'a Baz }", - "fn bar () -> & 'a Baz < u8 > {unimplemented ! ()}", - ) - // extern "Rust" func type - .assert_expand_items( - r#"foo! { extern "Rust" fn() -> Ret }"#, - r#"fn bar () -> extern "Rust" fn () -> Ret {unimplemented ! ()}"#, - ); -} - #[test] fn test_pat_() { parse_macro(