Skip to content

Commit

Permalink
added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jnyfah committed Jan 16, 2025
1 parent 2ac6cb1 commit b96819c
Show file tree
Hide file tree
Showing 20 changed files with 597 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
SOURCE_FILE
STRUCT
STRUCT_KW "struct"
WHITESPACE " "
NAME
IDENT "X"
WHITESPACE " "
RECORD_FIELD_LIST
L_CURLY "{"
RECORD_FIELD
NAME
IDENT "a"
COLON ":"
WHITESPACE " "
PATH_TYPE
PATH
PATH_SEGMENT
NAME_REF
IDENT "i32"
R_CURLY "}"
WHITESPACE "\r\n"
ERROR
LET_KW "let"
WHITESPACE " "
IDENT_PAT
NAME
IDENT "foo"
WHITESPACE " "
EQ "="
WHITESPACE " "
RECORD_EXPR
PATH
PATH_SEGMENT
NAME_REF
IDENT "X"
WHITESPACE " "
RECORD_EXPR_FIELD_LIST
L_CURLY "{"
WHITESPACE "\r\n "
RECORD_EXPR_FIELD
NAME_REF
IDENT "a"
COLON ":"
WHITESPACE " "
LITERAL
INT_NUMBER "1"
WHITESPACE "\r\n"
R_CURLY "}"
WHITESPACE " "
LET_ELSE
ELSE_KW "else"
WHITESPACE " "
BLOCK_EXPR
STMT_LIST
L_CURLY "{"
WHITESPACE "\r\n "
EXPR_STMT
RETURN_EXPR
RETURN_KW "return"
SEMICOLON ";"
WHITESPACE "\r\n"
R_CURLY "}"
SEMICOLON ";"
WHITESPACE "\r\n"
error 19: expected an item
error 45: right curly brace `}` before `else` in a `let...else` statement not allowed
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
struct X {a: i32}
let foo = X {
a: 1
} else {
return;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
SOURCE_FILE
ERROR
LET_KW "let"
WHITESPACE " "
IDENT_PAT
NAME
IDENT "foo"
WHITESPACE " "
EQ "="
WHITESPACE " "
BIN_EXPR
LITERAL
INT_NUMBER "1"
WHITESPACE " "
PLUS "+"
WHITESPACE " "
BLOCK_EXPR
STMT_LIST
L_CURLY "{"
WHITESPACE "\r\n "
LITERAL
INT_NUMBER "1"
WHITESPACE "\r\n"
R_CURLY "}"
WHITESPACE " "
LET_ELSE
ELSE_KW "else"
WHITESPACE " "
BLOCK_EXPR
STMT_LIST
L_CURLY "{"
WHITESPACE "\r\n "
EXPR_STMT
RETURN_EXPR
RETURN_KW "return"
SEMICOLON ";"
WHITESPACE "\r\n"
R_CURLY "}"
SEMICOLON ";"
WHITESPACE "\r\n"
error 0: expected an item
error 25: right curly brace `}` before `else` in a `let...else` statement not allowed
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
let foo = 1 + {
1
} else {
return;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
SOURCE_FILE
FN
FN_KW "fn"
WHITESPACE " "
NAME
IDENT "r"
PARAM_LIST
L_PAREN "("
R_PAREN ")"
WHITESPACE " "
BLOCK_EXPR
STMT_LIST
L_CURLY "{"
WHITESPACE "\r\n "
LET_STMT
LET_KW "let"
WHITESPACE " "
IDENT_PAT
NAME
IDENT "ok"
WHITESPACE " "
EQ "="
WHITESPACE " "
MACRO_EXPR
MACRO_CALL
PATH
PATH_SEGMENT
NAME_REF
IDENT "format_args"
BANG "!"
TOKEN_TREE
L_PAREN "("
STRING "\"\""
R_PAREN ")"
WHITESPACE " "
LET_ELSE
ELSE_KW "else"
WHITESPACE " "
BLOCK_EXPR
STMT_LIST
L_CURLY "{"
WHITESPACE " "
EXPR_STMT
RETURN_EXPR
RETURN_KW "return"
SEMICOLON ";"
WHITESPACE " "
R_CURLY "}"
SEMICOLON ";"
WHITESPACE "\r\n\r\n "
LET_STMT
LET_KW "let"
WHITESPACE " "
IDENT_PAT
NAME
IDENT "bad"
WHITESPACE " "
EQ "="
WHITESPACE " "
MACRO_EXPR
MACRO_CALL
PATH
PATH_SEGMENT
NAME_REF
IDENT "format_args"
BANG "!"
WHITESPACE " "
TOKEN_TREE
L_CURLY "{"
STRING "\"\""
R_CURLY "}"
WHITESPACE " "
LET_ELSE
ELSE_KW "else"
WHITESPACE " "
BLOCK_EXPR
STMT_LIST
L_CURLY "{"
WHITESPACE " "
EXPR_STMT
RETURN_EXPR
RETURN_KW "return"
SEMICOLON ";"
WHITESPACE " "
R_CURLY "}"
SEMICOLON ";"
WHITESPACE "\r\n"
R_CURLY "}"
WHITESPACE "\r\n"
error 92: right curly brace `}` before `else` in a `let...else` statement not allowed
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
fn r() {
let ok = format_args!("") else { return; };

let bad = format_args! {""} else { return; };
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
SOURCE_FILE
ERROR
LET_KW "let"
WHITESPACE " "
IDENT_PAT
NAME
IDENT "foo"
WHITESPACE " "
EQ "="
WHITESPACE " "
RANGE_EXPR
LITERAL
INT_NUMBER "1"
DOT2 ".."
BLOCK_EXPR
STMT_LIST
L_CURLY "{"
WHITESPACE "\r\n "
LITERAL
INT_NUMBER "1"
WHITESPACE "\r\n"
R_CURLY "}"
WHITESPACE " "
LET_ELSE
ELSE_KW "else"
WHITESPACE " "
BLOCK_EXPR
STMT_LIST
L_CURLY "{"
WHITESPACE "\r\n "
EXPR_STMT
RETURN_EXPR
RETURN_KW "return"
SEMICOLON ";"
WHITESPACE "\r\n"
R_CURLY "}"
SEMICOLON ";"
WHITESPACE "\r\n"
error 0: expected an item
error 24: right curly brace `}` before `else` in a `let...else` statement not allowed
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
let foo = 1..{
1
} else {
return;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
SOURCE_FILE
ERROR
LET_KW "let"
WHITESPACE " "
IDENT_PAT
NAME
IDENT "foo"
WHITESPACE " "
EQ "="
WHITESPACE " "
CLOSURE_EXPR
PARAM_LIST
PIPE "|"
PARAM
IDENT_PAT
NAME
IDENT "x"
COLON ":"
WHITESPACE " "
PATH_TYPE
PATH
PATH_SEGMENT
NAME_REF
IDENT "i32"
PIPE "|"
WHITESPACE " "
BLOCK_EXPR
STMT_LIST
L_CURLY "{"
WHITESPACE "\r\n "
PATH_EXPR
PATH
PATH_SEGMENT
NAME_REF
IDENT "x"
WHITESPACE "\r\n"
R_CURLY "}"
WHITESPACE " "
LET_ELSE
ELSE_KW "else"
WHITESPACE " "
BLOCK_EXPR
STMT_LIST
L_CURLY "{"
WHITESPACE "\r\n "
EXPR_STMT
RETURN_EXPR
RETURN_KW "return"
SEMICOLON ";"
WHITESPACE "\r\n"
R_CURLY "}"
SEMICOLON ";"
WHITESPACE "\r\n"
error 0: expected an item
error 30: right curly brace `}` before `else` in a `let...else` statement not allowed
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
let foo = |x: i32| {
x
} else {
return;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
SOURCE_FILE
ERROR
LET_KW "let"
WHITESPACE " "
IDENT_PAT
NAME
IDENT "foo"
WHITESPACE " "
EQ "="
WHITESPACE " "
PREFIX_EXPR
MINUS "-"
BLOCK_EXPR
STMT_LIST
L_CURLY "{"
WHITESPACE "\r\n "
LITERAL
INT_NUMBER "1"
WHITESPACE "\r\n"
R_CURLY "}"
WHITESPACE " "
LET_ELSE
ELSE_KW "else"
WHITESPACE " "
BLOCK_EXPR
STMT_LIST
L_CURLY "{"
WHITESPACE "\r\n "
EXPR_STMT
RETURN_EXPR
RETURN_KW "return"
SEMICOLON ";"
WHITESPACE "\r\n"
R_CURLY "}"
SEMICOLON ";"
WHITESPACE "\r\n"
error 0: expected an item
error 22: right curly brace `}` before `else` in a `let...else` statement not allowed
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
let foo = -{
1
} else {
return;
};
Loading

0 comments on commit b96819c

Please sign in to comment.