Unnamed repository; edit this file 'description' to name the repository.
internal: move test
| -rw-r--r-- | crates/hir_def/src/macro_expansion_tests/mbe.rs | 60 | ||||
| -rw-r--r-- | crates/mbe/src/tests/expand.rs | 52 |
2 files changed, 60 insertions, 52 deletions
diff --git a/crates/hir_def/src/macro_expansion_tests/mbe.rs b/crates/hir_def/src/macro_expansion_tests/mbe.rs index 993c7d99b7..eaf04ec6c2 100644 --- a/crates/hir_def/src/macro_expansion_tests/mbe.rs +++ b/crates/hir_def/src/macro_expansion_tests/mbe.rs @@ -415,3 +415,63 @@ x![(a b)]; "#]], ) } + +#[test] +fn test_expand_to_item_list() { + check( + r#" +macro_rules! structs { + ($($i:ident),*) => { $(struct $i { field: u32 } )* } +} + +// +tree +structs!(Foo, Bar); + "#, + expect![[r#" +macro_rules! structs { + ($($i:ident),*) => { $(struct $i { field: u32 } )* } +} + +struct Foo { + field:u32 +} +struct Bar { + field:u32 +} +// [email protected] "struct" +// [email protected] "Foo" +// [email protected] "{" +// [email protected] "field" +// [email protected] ":" +// [email protected] "u32" +// [email protected] "}" +// [email protected] "struct" +// [email protected] "Bar" +// [email protected] "{" +// [email protected] "field" +// [email protected] ":" +// [email protected] "u32" +// [email protected] "}" + + "#]], + ); +} diff --git a/crates/mbe/src/tests/expand.rs b/crates/mbe/src/tests/expand.rs index b3b6fce58d..cb4b73d610 100644 --- a/crates/mbe/src/tests/expand.rs +++ b/crates/mbe/src/tests/expand.rs @@ -71,58 +71,6 @@ macro_rules! foobar { assert_eq!(get_text(tt::TokenId(13), T!['{']), "{"); } -#[test] -fn test_expand_to_item_list() { - let tree = parse_macro( - " - macro_rules! structs { - ($($i:ident),*) => { - $(struct $i { field: u32 } )* - } - } - ", - ) - .expand_items("structs!(Foo, Bar);"); - assert_eq!( - format!("{:#?}", tree).trim(), - r#" - [email protected] "struct" - [email protected] "Foo" - [email protected] "{" - [email protected] "field" - [email protected] ":" - [email protected] "u32" - [email protected] "}" - [email protected] "struct" - [email protected] "Bar" - [email protected] "{" - [email protected] "field" - [email protected] ":" - [email protected] "u32" - [email protected] "}""# - .trim() - ); -} - fn to_subtree(tt: &tt::TokenTree) -> &tt::Subtree { if let tt::TokenTree::Subtree(subtree) = tt { return subtree; |