Unnamed repository; edit this file 'description' to name the repository.
move test
| -rw-r--r-- | crates/hir_def/src/macro_expansion_tests/mbe.rs | 41 | ||||
| -rw-r--r-- | crates/mbe/src/tests/expand.rs | 96 |
2 files changed, 41 insertions, 96 deletions
diff --git a/crates/hir_def/src/macro_expansion_tests/mbe.rs b/crates/hir_def/src/macro_expansion_tests/mbe.rs index 7600b16ded..b028cf25e0 100644 --- a/crates/hir_def/src/macro_expansion_tests/mbe.rs +++ b/crates/hir_def/src/macro_expansion_tests/mbe.rs @@ -1427,3 +1427,44 @@ macro_rules! foo { "#]], ); } + +// The following tests are based on real world situations +#[test] +fn test_vec() { + check( + r#" +macro_rules! vec { + ($($item:expr),*) => {{ + let mut v = Vec::new(); + $( v.push($item); )* + v + }}; +} +fn main() { + vec!(); + vec![1u32,2]; +} +"#, + expect![[r#" +macro_rules! vec { + ($($item:expr),*) => {{ + let mut v = Vec::new(); + $( v.push($item); )* + v + }}; +} +fn main() { + { + let mut v = Vec::new(); + v + }; + { + let mut v = Vec::new(); + v.push(1u32); + v.push(2); + v + }; +} +"#]], + ); +} diff --git a/crates/mbe/src/tests/expand.rs b/crates/mbe/src/tests/expand.rs index 79f0824b59..9c0f5273f0 100644 --- a/crates/mbe/src/tests/expand.rs +++ b/crates/mbe/src/tests/expand.rs @@ -98,102 +98,6 @@ fn test_attr_to_token_tree() { ); } -// The following tests are based on real world situations -#[test] -fn test_vec() { - let fixture = parse_macro( - r#" - macro_rules! vec { - ($($item:expr),*) => { - { - let mut v = Vec::new(); - $( - v.push($item); - )* - v - } - }; -} -"#, - ); - fixture - .assert_expand_items(r#"vec!();"#, r#"{let mut v = Vec :: new () ; v}"#) - .assert_expand_items( - r#"vec![1u32,2];"#, - r#"{let mut v = Vec :: new () ; v . push (1u32) ; v . push (2) ; v}"#, - ); - - let tree = fixture.expand_expr(r#"vec![1u32,2];"#); - - assert_eq_text!( - &format!("{:#?}", tree), - r#"[email protected] - [email protected] "{" - [email protected] "let" - [email protected] "mut" - [email protected] "v" - [email protected] "=" - [email protected] "Vec" - [email protected] "::" - [email protected] "new" - [email protected] "(" - [email protected] ")" - [email protected] ";" - [email protected] "v" - [email protected] "." - [email protected] "push" - [email protected] "(" - [email protected] "1u32" - [email protected] ")" - [email protected] ";" - [email protected] "v" - [email protected] "." - [email protected] "push" - [email protected] "(" - [email protected] "2" - [email protected] ")" - [email protected] ";" - [email protected] "v" - [email protected] "}" -"# - ); -} - #[test] fn test_winapi_struct() { // from https://github.com/retep998/winapi-rs/blob/a7ef2bca086aae76cf6c4ce4c2552988ed9798ad/src/macros.rs#L366 |