add more tests

This commit is contained in:
XFFXFF 2023-03-04 10:14:12 +08:00
parent 995aacfce8
commit 98990affe5
10 changed files with 328 additions and 0 deletions

View File

@ -0,0 +1,58 @@
SOURCE_FILE
FN
FN_KW "fn"
WHITESPACE " "
NAME
IDENT "f"
PARAM_LIST
L_PAREN "("
R_PAREN ")"
WHITESPACE " "
BLOCK_EXPR
STMT_LIST
L_CURLY "{"
WHITESPACE "\n "
LET_STMT
LET_KW "let"
WHITESPACE " "
WILDCARD_PAT
UNDERSCORE "_"
WHITESPACE " "
EQ "="
WHITESPACE " "
FOR_EXPR
FOR_KW "for"
WHITESPACE " "
WILDCARD_PAT
UNDERSCORE "_"
WHITESPACE " "
IN_KW "in"
WHITESPACE " "
RANGE_EXPR
LITERAL
INT_NUMBER "0"
DOT2 ".."
LITERAL
INT_NUMBER "10"
WHITESPACE " "
BLOCK_EXPR
STMT_LIST
L_CURLY "{"
WHITESPACE "\n "
R_CURLY "}"
WHITESPACE " "
LET_ELSE
ELSE_KW "else"
WHITESPACE " "
BLOCK_EXPR
STMT_LIST
L_CURLY "{"
WHITESPACE "\n "
RETURN_EXPR
RETURN_KW "return"
WHITESPACE "\n "
R_CURLY "}"
SEMICOLON ";"
WHITESPACE "\n"
R_CURLY "}"
error 43: right curly brace `}` before `else` in a `let...else` statement not allowed

View File

@ -0,0 +1,6 @@
fn f() {
let _ = for _ in 0..10 {
} else {
return
};
}

View File

@ -0,0 +1,46 @@
SOURCE_FILE
FN
FN_KW "fn"
WHITESPACE " "
NAME
IDENT "f"
PARAM_LIST
L_PAREN "("
R_PAREN ")"
WHITESPACE " "
BLOCK_EXPR
STMT_LIST
L_CURLY "{"
WHITESPACE "\n "
LET_STMT
LET_KW "let"
WHITESPACE " "
WILDCARD_PAT
UNDERSCORE "_"
WHITESPACE " "
EQ "="
WHITESPACE " "
LOOP_EXPR
LOOP_KW "loop"
WHITESPACE " "
BLOCK_EXPR
STMT_LIST
L_CURLY "{"
WHITESPACE "\n "
R_CURLY "}"
WHITESPACE " "
LET_ELSE
ELSE_KW "else"
WHITESPACE " "
BLOCK_EXPR
STMT_LIST
L_CURLY "{"
WHITESPACE "\n "
RETURN_EXPR
RETURN_KW "return"
WHITESPACE "\n "
R_CURLY "}"
SEMICOLON ";"
WHITESPACE "\n"
R_CURLY "}"
error 33: right curly brace `}` before `else` in a `let...else` statement not allowed

View File

@ -0,0 +1,6 @@
fn f() {
let _ = loop {
} else {
return
};
}

View File

@ -0,0 +1,85 @@
SOURCE_FILE
FN
FN_KW "fn"
WHITESPACE " "
NAME
IDENT "f"
PARAM_LIST
L_PAREN "("
R_PAREN ")"
WHITESPACE " "
BLOCK_EXPR
STMT_LIST
L_CURLY "{"
WHITESPACE "\n "
LET_STMT
LET_KW "let"
WHITESPACE " "
WILDCARD_PAT
UNDERSCORE "_"
WHITESPACE " "
EQ "="
WHITESPACE " "
MATCH_EXPR
MATCH_KW "match"
WHITESPACE " "
CALL_EXPR
PATH_EXPR
PATH
PATH_SEGMENT
NAME_REF
IDENT "Some"
ARG_LIST
L_PAREN "("
LITERAL
INT_NUMBER "1"
R_PAREN ")"
WHITESPACE " "
MATCH_ARM_LIST
L_CURLY "{"
WHITESPACE "\n "
MATCH_ARM
TUPLE_STRUCT_PAT
PATH
PATH_SEGMENT
NAME_REF
IDENT "Some"
L_PAREN "("
WILDCARD_PAT
UNDERSCORE "_"
R_PAREN ")"
WHITESPACE " "
FAT_ARROW "=>"
WHITESPACE " "
LITERAL
INT_NUMBER "1"
COMMA ","
WHITESPACE "\n "
MATCH_ARM
IDENT_PAT
NAME
IDENT "None"
WHITESPACE " "
FAT_ARROW "=>"
WHITESPACE " "
LITERAL
INT_NUMBER "2"
COMMA ","
WHITESPACE "\n "
R_CURLY "}"
WHITESPACE " "
LET_ELSE
ELSE_KW "else"
WHITESPACE " "
BLOCK_EXPR
STMT_LIST
L_CURLY "{"
WHITESPACE "\n "
RETURN_EXPR
RETURN_KW "return"
WHITESPACE "\n "
R_CURLY "}"
SEMICOLON ";"
WHITESPACE "\n"
R_CURLY "}"
error 83: right curly brace `}` before `else` in a `let...else` statement not allowed

View File

@ -0,0 +1,8 @@
fn f() {
let _ = match Some(1) {
Some(_) => 1,
None => 2,
} else {
return
};
}

View File

@ -0,0 +1,49 @@
SOURCE_FILE
FN
FN_KW "fn"
WHITESPACE " "
NAME
IDENT "f"
PARAM_LIST
L_PAREN "("
R_PAREN ")"
WHITESPACE " "
BLOCK_EXPR
STMT_LIST
L_CURLY "{"
WHITESPACE "\n "
LET_STMT
LET_KW "let"
WHITESPACE " "
WILDCARD_PAT
UNDERSCORE "_"
WHITESPACE " "
EQ "="
WHITESPACE " "
WHILE_EXPR
WHILE_KW "while"
WHITESPACE " "
LITERAL
TRUE_KW "true"
WHITESPACE " "
BLOCK_EXPR
STMT_LIST
L_CURLY "{"
WHITESPACE "\n "
R_CURLY "}"
WHITESPACE " "
LET_ELSE
ELSE_KW "else"
WHITESPACE " "
BLOCK_EXPR
STMT_LIST
L_CURLY "{"
WHITESPACE "\n "
RETURN_EXPR
RETURN_KW "return"
WHITESPACE "\n "
R_CURLY "}"
SEMICOLON ";"
WHITESPACE "\n"
R_CURLY "}"
error 39: right curly brace `}` before `else` in a `let...else` statement not allowed

View File

@ -0,0 +1,6 @@
fn f() {
let _ = while true {
} else {
return
};
}

View File

@ -0,0 +1,57 @@
SOURCE_FILE
FN
FN_KW "fn"
WHITESPACE " "
NAME
IDENT "f"
PARAM_LIST
L_PAREN "("
R_PAREN ")"
WHITESPACE " "
BLOCK_EXPR
STMT_LIST
L_CURLY "{"
WHITESPACE "\n "
LET_STMT
LET_KW "let"
WHITESPACE " "
WILDCARD_PAT
UNDERSCORE "_"
WHITESPACE " "
EQ "="
WHITESPACE " "
IF_EXPR
IF_KW "if"
WHITESPACE " "
LITERAL
TRUE_KW "true"
WHITESPACE " "
BLOCK_EXPR
STMT_LIST
L_CURLY "{"
WHITESPACE "\n "
R_CURLY "}"
WHITESPACE " "
ELSE_KW "else"
WHITESPACE " "
BLOCK_EXPR
STMT_LIST
L_CURLY "{"
WHITESPACE "\n "
R_CURLY "}"
WHITESPACE " "
LET_ELSE
ELSE_KW "else"
WHITESPACE " "
BLOCK_EXPR
STMT_LIST
L_CURLY "{"
WHITESPACE "\n "
RETURN_EXPR
RETURN_KW "return"
WHITESPACE "\n "
R_CURLY "}"
SEMICOLON ";"
WHITESPACE "\n"
R_CURLY "}"
error 49: right curly brace `}` before `else` in a `let...else` statement not allowed

View File

@ -0,0 +1,7 @@
fn f() {
let _ = if true {
} else {
} else {
return
};
}