|
|
@ -631,6 +631,28 @@ fn check_function_declarations() { |
|
|
|
))], |
|
|
|
))], |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
check_parser( |
|
|
|
|
|
|
|
"function foo(a) { return; }", |
|
|
|
|
|
|
|
&[Expr::new(ExprDef::FunctionDecl( |
|
|
|
|
|
|
|
Some(String::from("foo")), |
|
|
|
|
|
|
|
vec![Expr::new(ExprDef::Local(String::from("a")))], |
|
|
|
|
|
|
|
Box::new(Expr::new(ExprDef::Block(vec![Expr::new(ExprDef::Return( |
|
|
|
|
|
|
|
None, |
|
|
|
|
|
|
|
))]))), |
|
|
|
|
|
|
|
))], |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
check_parser( |
|
|
|
|
|
|
|
"function foo(a) { return }", |
|
|
|
|
|
|
|
&[Expr::new(ExprDef::FunctionDecl( |
|
|
|
|
|
|
|
Some(String::from("foo")), |
|
|
|
|
|
|
|
vec![Expr::new(ExprDef::Local(String::from("a")))], |
|
|
|
|
|
|
|
Box::new(Expr::new(ExprDef::Block(vec![Expr::new(ExprDef::Return( |
|
|
|
|
|
|
|
None, |
|
|
|
|
|
|
|
))]))), |
|
|
|
|
|
|
|
))], |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
check_parser( |
|
|
|
check_parser( |
|
|
|
"function (a, ...b) {}", |
|
|
|
"function (a, ...b) {}", |
|
|
|
&[Expr::new(ExprDef::FunctionDecl( |
|
|
|
&[Expr::new(ExprDef::FunctionDecl( |
|
|
@ -688,4 +710,30 @@ fn check_function_declarations() { |
|
|
|
))]))), |
|
|
|
))]))), |
|
|
|
))], |
|
|
|
))], |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
check_parser( |
|
|
|
|
|
|
|
"(a, b) => { return; }", |
|
|
|
|
|
|
|
&[Expr::new(ExprDef::ArrowFunctionDecl( |
|
|
|
|
|
|
|
vec![ |
|
|
|
|
|
|
|
Expr::new(ExprDef::Local(String::from("a"))), |
|
|
|
|
|
|
|
Expr::new(ExprDef::Local(String::from("b"))), |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
Box::new(Expr::new(ExprDef::Block(vec![Expr::new(ExprDef::Return( |
|
|
|
|
|
|
|
None, |
|
|
|
|
|
|
|
))]))), |
|
|
|
|
|
|
|
))], |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
check_parser( |
|
|
|
|
|
|
|
"(a, b) => { return }", |
|
|
|
|
|
|
|
&[Expr::new(ExprDef::ArrowFunctionDecl( |
|
|
|
|
|
|
|
vec![ |
|
|
|
|
|
|
|
Expr::new(ExprDef::Local(String::from("a"))), |
|
|
|
|
|
|
|
Expr::new(ExprDef::Local(String::from("b"))), |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
Box::new(Expr::new(ExprDef::Block(vec![Expr::new(ExprDef::Return( |
|
|
|
|
|
|
|
None, |
|
|
|
|
|
|
|
))]))), |
|
|
|
|
|
|
|
))], |
|
|
|
|
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|