Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/mbe/src/tests/expand.rs')
-rw-r--r--crates/mbe/src/tests/expand.rs309
1 files changed, 0 insertions, 309 deletions
diff --git a/crates/mbe/src/tests/expand.rs b/crates/mbe/src/tests/expand.rs
index 01b5533522..15a7184029 100644
--- a/crates/mbe/src/tests/expand.rs
+++ b/crates/mbe/src/tests/expand.rs
@@ -102,315 +102,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<u8> }", "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<u8> }",
- "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(
- 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#"
- macro_rules! foo {
- ($ ($ i:item)*) => ($ (
- $ i
- )*)
- }
-"#,
- ).
- assert_expand_items(
- r#"
- foo! {
- extern crate a;
- mod b;
- mod c {}
- use d;
- const E: i32 = 0;
- static F: i32 = 0;
- impl G {}
- struct H;
- enum I { Foo }
- trait J {}
- fn h() {}
- extern {}
- type T = u8;
- }
-"#,
- r#"extern crate a ; mod b ; mod c {} use d ; const E : i32 = 0 ; static F : i32 = 0 ; impl G {} struct H ; enum I {Foo} trait J {} fn h () {} extern {} type T = u8 ;"#,
- );
-}
-
-#[test]
-fn test_block() {
- parse_macro(
- r#"
- macro_rules! foo {
- ($ i:block) => { fn foo() $ i }
- }
-"#,
- )
- .assert_expand_statements("foo! { { 1; } }", "fn foo () {1 ;}");
-}
-
-#[test]
-fn test_meta() {
- parse_macro(
- r#"
- macro_rules! foo {
- ($ i:meta) => (
- #[$ i]
- fn bar() {}
- )
- }
-"#,
- )
- .assert_expand_items(
- r#"foo! { cfg(target_os = "windows") }"#,
- r#"# [cfg (target_os = "windows")] fn bar () {}"#,
- )
- .assert_expand_items(r#"foo! { hello::world }"#, r#"# [hello :: world] fn bar () {}"#);
-}
-
-#[test]
-fn test_meta_doc_comments() {
- parse_macro(
- r#"
- macro_rules! foo {
- ($(#[$ i:meta])+) => (
- $(#[$ i])+
- fn bar() {}
- )
- }
-"#,
- ).
- assert_expand_items(
- r#"foo! {
- /// Single Line Doc 1
- /**
- MultiLines Doc
- */
- }"#,
- "# [doc = \" Single Line Doc 1\"] # [doc = \"\\n MultiLines Doc\\n \"] fn bar () {}",
- );
-}
-
-#[test]
-fn test_meta_extended_key_value_attributes() {
- parse_macro(
- r#"
-macro_rules! foo {
- (#[$i:meta]) => (
- #[$ i]
- fn bar() {}
- )
-}
-"#,
- )
- .assert_expand_items(
- r#"foo! { #[doc = concat!("The `", "bla", "` lang item.")] }"#,
- r#"# [doc = concat ! ("The `" , "bla" , "` lang item.")] fn bar () {}"#,
- );
-}
-
-#[test]
-fn test_meta_doc_comments_non_latin() {
- parse_macro(
- r#"
- macro_rules! foo {
- ($(#[$ i:meta])+) => (
- $(#[$ i])+
- fn bar() {}
- )
- }
-"#,
- ).
- assert_expand_items(
- r#"foo! {
- /// 錦瑟無端五十弦,一弦一柱思華年。
- /**
- 莊生曉夢迷蝴蝶,望帝春心託杜鵑。
- */
- }"#,
- "# [doc = \" 錦瑟無端五十弦,一弦一柱思華年。\"] # [doc = \"\\n 莊生曉夢迷蝴蝶,望帝春心託杜鵑。\\n \"] fn bar () {}",
- );
-}
-
-#[test]
-fn test_meta_doc_comments_escaped_characters() {
- parse_macro(
- r#"
- macro_rules! foo {
- ($(#[$ i:meta])+) => (
- $(#[$ i])+
- fn bar() {}
- )
- }
-"#,
- )
- .assert_expand_items(
- r#"foo! {
- /// \ " '
- }"#,
- r#"# [doc = " \\ \" \'"] fn bar () {}"#,
- );
-}
-
-#[test]
-fn test_tt_block() {
- parse_macro(
- r#"
- macro_rules! foo {
- ($ i:tt) => { fn foo() $ i }
- }
- "#,
- )
- .assert_expand_items(r#"foo! { { 1; } }"#, r#"fn foo () {1 ;}"#);
-}
-
-#[test]
-fn test_tt_group() {
- parse_macro(
- r#"
- macro_rules! foo {
- ($($ i:tt)*) => { $($ i)* }
- }
- "#,
- )
- .assert_expand_items(r#"foo! { fn foo() {} }"#, r#"fn foo () {}"#);
-}
-
-#[test]
-fn test_tt_composite() {
- parse_macro(
- r#"
- macro_rules! foo {
- ($i:tt) => { 0 }
- }
- "#,
- )
- .assert_expand_items(r#"foo! { => }"#, r#"0"#);
-}
-
-#[test]
-fn test_tt_composite2() {
- let node = parse_macro(
- r#"
- macro_rules! foo {
- ($($tt:tt)*) => { abs!(=> $($tt)*) }
- }
- "#,
- )
- .expand_items(r#"foo!{#}"#);
-
- let res = format!("{:#?}", &node);
- assert_eq_text!(
- res.trim()
- );
-}
-
-#[test]
-fn test_tt_with_composite_without_space() {
- parse_macro(
- r#"
- macro_rules! foo {
- ($ op:tt, $j:path) => (
- 0
- )
- }
-"#,
- )
- // Test macro input without any spaces
- // See https://github.com/rust-analyzer/rust-analyzer/issues/6692
- .assert_expand_items("foo!(==,Foo::Bool)", "0");
-}
-
-#[test]
fn test_underscore() {
parse_macro(
r#"