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.rs217
1 files changed, 0 insertions, 217 deletions
diff --git a/crates/mbe/src/tests/expand.rs b/crates/mbe/src/tests/expand.rs
index c08788cda1..393c2041d9 100644
--- a/crates/mbe/src/tests/expand.rs
+++ b/crates/mbe/src/tests/expand.rs
@@ -71,92 +71,12 @@ macro_rules! foobar {
assert_eq!(get_text(tt::TokenId(13), T!['{']), "{");
}
-#[test]
-fn test_match_group_zero_match() {
- parse_macro(
- r#"
- macro_rules! foo {
- ( $($i:ident)* ) => ();
- }"#,
- )
- .assert_expand_items("foo! ();", "");
-}
-
-#[test]
-fn test_match_group_in_group() {
- parse_macro(
- r#"
- macro_rules! foo {
- { $( ( $($i:ident)* ) )* } => ( $( ( $($i)* ) )* );
- }"#,
- )
- .assert_expand_items("foo! ( (a b) );", "(a b)");
-}
-
-#[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#"
- .trim()
- );
-}
-
fn to_subtree(tt: &tt::TokenTree) -> &tt::Subtree {
if let tt::TokenTree::Subtree(subtree) = tt {
return subtree;
}
unreachable!("It is not a subtree");
}
-fn to_literal(tt: &tt::TokenTree) -> &tt::Literal {
- if let tt::TokenTree::Leaf(tt::Leaf::Literal(lit)) = tt {
- return lit;
- }
- unreachable!("It is not a literal");
-}
fn to_punct(tt: &tt::TokenTree) -> &tt::Punct {
if let tt::TokenTree::Leaf(tt::Leaf::Punct(lit)) = tt {
@@ -166,35 +86,6 @@ fn to_punct(tt: &tt::TokenTree) -> &tt::Punct {
}
#[test]
-fn test_expand_literals_to_token_tree() {
- let expansion = parse_macro(
- r#"
- macro_rules! literals {
- ($i:ident) => {
- {
- let a = 'c';
- let c = 1000;
- let f = 12E+99_f64;
- let s = "rust1";
- }
- }
- }
- "#,
- )
- .expand_tt("literals!(foo);");
- let stm_tokens = &to_subtree(&expansion.token_trees[0]).token_trees;
-
- // [let] [a] [=] ['c'] [;]
- assert_eq!(to_literal(&stm_tokens[3]).text, "'c'");
- // [let] [c] [=] [1000] [;]
- assert_eq!(to_literal(&stm_tokens[5 + 3]).text, "1000");
- // [let] [f] [=] [12E+99_f64] [;]
- assert_eq!(to_literal(&stm_tokens[10 + 3]).text, "12E+99_f64");
- // [let] [s] [=] ["rust1"] [;]
- assert_eq!(to_literal(&stm_tokens[15 + 3]).text, "\"rust1\"");
-}
-
-#[test]
fn test_attr_to_token_tree() {
let expansion = parse_to_token_tree_by_syntax(
r#"
@@ -211,114 +102,6 @@ fn test_attr_to_token_tree() {
}
#[test]
-fn test_two_idents() {
- parse_macro(
- r#"
- macro_rules! foo {
- ($ i:ident, $ j:ident) => {
- fn foo() { let a = $ i; let b = $j; }
- }
- }
-"#,
- )
- .assert_expand_items("foo! { foo, bar }", "fn foo () {let a = foo ; let b = bar ;}");
-}
-
-#[test]
-fn test_tt_to_stmts() {
- let stmts = parse_macro(
- r#"
- macro_rules! foo {
- () => {
- let a = 0;
- a = 10 + 1;
- a
- }
- }
-"#,
- )
- .expand_statements("foo!{}");
-
- assert_eq!(
- format!("{:#?}", stmts).trim(),
- );
-}
-
-#[test]
-fn test_match_literal() {
- parse_macro(
- r#"
- macro_rules! foo {
- ('(') => {
- fn foo() {}
- }
- }
-"#,
- )
- .assert_expand_items("foo! ['('];", "fn foo () {}");
-}
-
-#[test]
-fn test_parse_macro_def_simple() {
- cov_mark::check!(parse_macro_def_simple);
-
- parse_macro2(
- r#"
-macro foo($id:ident) {
- fn $id() {}
-}
-"#,
- )
- .assert_expand_items("foo!(bar);", "fn bar () {}");
-}
-
-#[test]
-fn test_parse_macro_def_rules() {
- cov_mark::check!(parse_macro_def_rules);
-
- parse_macro2(
- r#"
-macro foo {
- ($id:ident) => {
- fn $id() {}
- }
-}
-"#,
- )
- .assert_expand_items("foo!(bar);", "fn bar () {}");
-}
-
-#[test]
fn test_macro_2_0_panic_2015() {
parse_macro2(
r#"