@ -14,7 +14,10 @@ fn check_basic() {
"function foo(a) { return a; }" ,
vec! [ FunctionDecl ::new (
Box ::from ( "foo" ) ,
vec! [ FormalParameter ::new ( "a" , None , false ) ] ,
vec! [ FormalParameter ::new (
Declaration ::new_with_identifier ( "a" , None ) ,
false ,
) ] ,
vec! [ Return ::new ( Identifier ::from ( "a" ) , None ) . into ( ) ] ,
)
. into ( ) ] ,
@ -29,8 +32,8 @@ fn check_duplicates_strict_off() {
vec! [ FunctionDecl ::new (
Box ::from ( "foo" ) ,
vec! [
FormalParameter ::new ( "a" , None , false ) ,
FormalParameter ::new ( "a" , None , false ) ,
FormalParameter ::new ( Declaration ::new_with_identifier ( "a" , None ) , false ) ,
FormalParameter ::new ( Declaration ::new_with_identifier ( "a" , None ) , false ) ,
] ,
vec! [ Return ::new ( Identifier ::from ( "a" ) , None ) . into ( ) ] ,
)
@ -55,7 +58,10 @@ fn check_basic_semicolon_insertion() {
"function foo(a) { return a }" ,
vec! [ FunctionDecl ::new (
Box ::from ( "foo" ) ,
vec! [ FormalParameter ::new ( "a" , None , false ) ] ,
vec! [ FormalParameter ::new (
Declaration ::new_with_identifier ( "a" , None ) ,
false ,
) ] ,
vec! [ Return ::new ( Identifier ::from ( "a" ) , None ) . into ( ) ] ,
)
. into ( ) ] ,
@ -69,7 +75,10 @@ fn check_empty_return() {
"function foo(a) { return; }" ,
vec! [ FunctionDecl ::new (
Box ::from ( "foo" ) ,
vec! [ FormalParameter ::new ( "a" , None , false ) ] ,
vec! [ FormalParameter ::new (
Declaration ::new_with_identifier ( "a" , None ) ,
false ,
) ] ,
vec! [ Return ::new ::< Node , Option < Node > , Option < _ > > ( None , None ) . into ( ) ] ,
)
. into ( ) ] ,
@ -83,7 +92,10 @@ fn check_empty_return_semicolon_insertion() {
"function foo(a) { return }" ,
vec! [ FunctionDecl ::new (
Box ::from ( "foo" ) ,
vec! [ FormalParameter ::new ( "a" , None , false ) ] ,
vec! [ FormalParameter ::new (
Declaration ::new_with_identifier ( "a" , None ) ,
false ,
) ] ,
vec! [ Return ::new ::< Node , Option < Node > , Option < _ > > ( None , None ) . into ( ) ] ,
)
. into ( ) ] ,
@ -98,8 +110,8 @@ fn check_rest_operator() {
vec! [ FunctionDecl ::new (
Box ::from ( "foo" ) ,
vec! [
FormalParameter ::new ( "a" , None , false ) ,
FormalParameter ::new ( "b" , None , true ) ,
FormalParameter ::new ( Declaration ::new_with_identifier ( "a" , None ) , false ) ,
FormalParameter ::new ( Declaration ::new_with_identifier ( "b" , None ) , true ) ,
] ,
vec! [ ] ,
)
@ -112,7 +124,14 @@ fn check_rest_operator() {
fn check_arrow_only_rest ( ) {
check_parser (
"(...a) => {}" ,
vec! [ ArrowFunctionDecl ::new ( vec! [ FormalParameter ::new ( "a" , None , true ) ] , vec! [ ] ) . into ( ) ] ,
vec! [ ArrowFunctionDecl ::new (
vec! [ FormalParameter ::new (
Declaration ::new_with_identifier ( "a" , None ) ,
true ,
) ] ,
vec! [ ] ,
)
. into ( ) ] ,
) ;
}
@ -123,9 +142,9 @@ fn check_arrow_rest() {
"(a, b, ...c) => {}" ,
vec! [ ArrowFunctionDecl ::new (
vec! [
FormalParameter ::new ( "a" , None , false ) ,
FormalParameter ::new ( "b" , None , false ) ,
FormalParameter ::new ( "c" , None , true ) ,
FormalParameter ::new ( Declaration ::new_with_identifier ( "a" , None ) , false ) ,
FormalParameter ::new ( Declaration ::new_with_identifier ( "b" , None ) , false ) ,
FormalParameter ::new ( Declaration ::new_with_identifier ( "c" , None ) , true ) ,
] ,
vec! [ ] ,
)
@ -140,8 +159,8 @@ fn check_arrow() {
"(a, b) => { return a + b; }" ,
vec! [ ArrowFunctionDecl ::new (
vec! [
FormalParameter ::new ( "a" , None , false ) ,
FormalParameter ::new ( "b" , None , false ) ,
FormalParameter ::new ( Declaration ::new_with_identifier ( "a" , None ) , false ) ,
FormalParameter ::new ( Declaration ::new_with_identifier ( "b" , None ) , false ) ,
] ,
vec! [ Return ::new (
BinOp ::new ( NumOp ::Add , Identifier ::from ( "a" ) , Identifier ::from ( "b" ) ) ,
@ -160,8 +179,8 @@ fn check_arrow_semicolon_insertion() {
"(a, b) => { return a + b }" ,
vec! [ ArrowFunctionDecl ::new (
vec! [
FormalParameter ::new ( "a" , None , false ) ,
FormalParameter ::new ( "b" , None , false ) ,
FormalParameter ::new ( Declaration ::new_with_identifier ( "a" , None ) , false ) ,
FormalParameter ::new ( Declaration ::new_with_identifier ( "b" , None ) , false ) ,
] ,
vec! [ Return ::new (
BinOp ::new ( NumOp ::Add , Identifier ::from ( "a" ) , Identifier ::from ( "b" ) ) ,
@ -180,8 +199,8 @@ fn check_arrow_epty_return() {
"(a, b) => { return; }" ,
vec! [ ArrowFunctionDecl ::new (
vec! [
FormalParameter ::new ( "a" , None , false ) ,
FormalParameter ::new ( "b" , None , false ) ,
FormalParameter ::new ( Declaration ::new_with_identifier ( "a" , None ) , false ) ,
FormalParameter ::new ( Declaration ::new_with_identifier ( "b" , None ) , false ) ,
] ,
vec! [ Return ::new ::< Node , Option < _ > , Option < _ > > ( None , None ) . into ( ) ] ,
)
@ -196,8 +215,8 @@ fn check_arrow_empty_return_semicolon_insertion() {
"(a, b) => { return }" ,
vec! [ ArrowFunctionDecl ::new (
vec! [
FormalParameter ::new ( "a" , None , false ) ,
FormalParameter ::new ( "b" , None , false ) ,
FormalParameter ::new ( Declaration ::new_with_identifier ( "a" , None ) , false ) ,
FormalParameter ::new ( Declaration ::new_with_identifier ( "b" , None ) , false ) ,
] ,
vec! [ Return ::new ::< Node , Option < _ > , Option < _ > > ( None , None ) . into ( ) ] ,
)
@ -214,7 +233,10 @@ fn check_arrow_assignment() {
Identifier ::from ( "foo" ) ,
Some (
ArrowFunctionDecl ::new (
vec! [ FormalParameter ::new ( "a" , None , false ) ] ,
vec! [ FormalParameter ::new (
Declaration ::new_with_identifier ( "a" , None ) ,
false ,
) ] ,
vec! [ Return ::new ::< Node , Option < _ > , Option < _ > > (
Some ( Identifier ::from ( "a" ) . into ( ) ) ,
None ,
@ -239,7 +261,10 @@ fn check_arrow_assignment_nobrackets() {
Identifier ::from ( "foo" ) ,
Some (
ArrowFunctionDecl ::new (
vec! [ FormalParameter ::new ( "a" , None , false ) ] ,
vec! [ FormalParameter ::new (
Declaration ::new_with_identifier ( "a" , None ) ,
false ,
) ] ,
vec! [ Return ::new ::< Node , Option < _ > , Option < _ > > (
Some ( Identifier ::from ( "a" ) . into ( ) ) ,
None ,
@ -264,7 +289,10 @@ fn check_arrow_assignment_noparenthesis() {
Identifier ::from ( "foo" ) ,
Some (
ArrowFunctionDecl ::new (
vec! [ FormalParameter ::new ( "a" , None , false ) ] ,
vec! [ FormalParameter ::new (
Declaration ::new_with_identifier ( "a" , None ) ,
false ,
) ] ,
vec! [ Return ::new ::< Node , Option < _ > , Option < _ > > (
Some ( Identifier ::from ( "a" ) . into ( ) ) ,
None ,
@ -289,7 +317,10 @@ fn check_arrow_assignment_noparenthesis_nobrackets() {
Identifier ::from ( "foo" ) ,
Some (
ArrowFunctionDecl ::new (
vec! [ FormalParameter ::new ( "a" , None , false ) ] ,
vec! [ FormalParameter ::new (
Declaration ::new_with_identifier ( "a" , None ) ,
false ,
) ] ,
vec! [ Return ::new ::< Node , Option < _ > , Option < _ > > (
Some ( Identifier ::from ( "a" ) . into ( ) ) ,
None ,
@ -315,8 +346,14 @@ fn check_arrow_assignment_2arg() {
Some (
ArrowFunctionDecl ::new (
vec! [
FormalParameter ::new ( "a" , None , false ) ,
FormalParameter ::new ( "b" , None , false ) ,
FormalParameter ::new (
Declaration ::new_with_identifier ( "a" , None ) ,
false ,
) ,
FormalParameter ::new (
Declaration ::new_with_identifier ( "b" , None ) ,
false ,
) ,
] ,
vec! [ Return ::new ::< Node , Option < _ > , Option < _ > > (
Some ( Identifier ::from ( "a" ) . into ( ) ) ,
@ -343,8 +380,14 @@ fn check_arrow_assignment_2arg_nobrackets() {
Some (
ArrowFunctionDecl ::new (
vec! [
FormalParameter ::new ( "a" , None , false ) ,
FormalParameter ::new ( "b" , None , false ) ,
FormalParameter ::new (
Declaration ::new_with_identifier ( "a" , None ) ,
false ,
) ,
FormalParameter ::new (
Declaration ::new_with_identifier ( "b" , None ) ,
false ,
) ,
] ,
vec! [ Return ::new ::< Node , Option < _ > , Option < _ > > (
Some ( Identifier ::from ( "a" ) . into ( ) ) ,
@ -371,9 +414,18 @@ fn check_arrow_assignment_3arg() {
Some (
ArrowFunctionDecl ::new (
vec! [
FormalParameter ::new ( "a" , None , false ) ,
FormalParameter ::new ( "b" , None , false ) ,
FormalParameter ::new ( "c" , None , false ) ,
FormalParameter ::new (
Declaration ::new_with_identifier ( "a" , None ) ,
false ,
) ,
FormalParameter ::new (
Declaration ::new_with_identifier ( "b" , None ) ,
false ,
) ,
FormalParameter ::new (
Declaration ::new_with_identifier ( "c" , None ) ,
false ,
) ,
] ,
vec! [ Return ::new ::< Node , Option < _ > , Option < _ > > (
Some ( Identifier ::from ( "a" ) . into ( ) ) ,
@ -400,9 +452,18 @@ fn check_arrow_assignment_3arg_nobrackets() {
Some (
ArrowFunctionDecl ::new (
vec! [
FormalParameter ::new ( "a" , None , false ) ,
FormalParameter ::new ( "b" , None , false ) ,
FormalParameter ::new ( "c" , None , false ) ,
FormalParameter ::new (
Declaration ::new_with_identifier ( "a" , None ) ,
false ,
) ,
FormalParameter ::new (
Declaration ::new_with_identifier ( "b" , None ) ,
false ,
) ,
FormalParameter ::new (
Declaration ::new_with_identifier ( "c" , None ) ,
false ,
) ,
] ,
vec! [ Return ::new ::< Node , Option < _ > , Option < _ > > (
Some ( Identifier ::from ( "a" ) . into ( ) ) ,