internal: move test

This commit is contained in:
Aleksey Kladov 2021-10-09 18:51:26 +03:00
parent 0a32c20142
commit 0dc87badd7
2 changed files with 66 additions and 50 deletions

View File

@ -496,3 +496,69 @@ fn foo() {
"#]],
);
}
#[test]
fn test_tt_to_stmts() {
check(
r#"
macro_rules! m {
() => {
let a = 0;
a = 10 + 1;
a
}
}
fn f() -> i32 {
// +tree
m!{}
}
"#,
expect![[r#"
macro_rules! m {
() => {
let a = 0;
a = 10 + 1;
a
}
}
fn f() -> i32 {
let a = 0;
a = 10+1;
a
// MACRO_STMTS@0..15
// LET_STMT@0..7
// LET_KW@0..3 "let"
// IDENT_PAT@3..4
// NAME@3..4
// IDENT@3..4 "a"
// EQ@4..5 "="
// LITERAL@5..6
// INT_NUMBER@5..6 "0"
// SEMICOLON@6..7 ";"
// EXPR_STMT@7..14
// BIN_EXPR@7..13
// PATH_EXPR@7..8
// PATH@7..8
// PATH_SEGMENT@7..8
// NAME_REF@7..8
// IDENT@7..8 "a"
// EQ@8..9 "="
// BIN_EXPR@9..13
// LITERAL@9..11
// INT_NUMBER@9..11 "10"
// PLUS@11..12 "+"
// LITERAL@12..13
// INT_NUMBER@12..13 "1"
// SEMICOLON@13..14 ";"
// PATH_EXPR@14..15
// PATH@14..15
// PATH_SEGMENT@14..15
// NAME_REF@14..15
// IDENT@14..15 "a"
}
"#]],
);
}

View File

@ -107,56 +107,6 @@ fn test_attr_to_token_tree() {
);
}
#[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(),
r#"MACRO_STMTS@0..15
LET_STMT@0..7
LET_KW@0..3 "let"
IDENT_PAT@3..4
NAME@3..4
IDENT@3..4 "a"
EQ@4..5 "="
LITERAL@5..6
INT_NUMBER@5..6 "0"
SEMICOLON@6..7 ";"
EXPR_STMT@7..14
BIN_EXPR@7..13
PATH_EXPR@7..8
PATH@7..8
PATH_SEGMENT@7..8
NAME_REF@7..8
IDENT@7..8 "a"
EQ@8..9 "="
BIN_EXPR@9..13
LITERAL@9..11
INT_NUMBER@9..11 "10"
PLUS@11..12 "+"
LITERAL@12..13
INT_NUMBER@12..13 "1"
SEMICOLON@13..14 ";"
PATH_EXPR@14..15
PATH@14..15
PATH_SEGMENT@14..15
NAME_REF@14..15
IDENT@14..15 "a""#,
);
}
#[test]
fn test_match_literal() {
parse_macro(