135 lines
2.7 KiB
JavaScript
135 lines
2.7 KiB
JavaScript
arrow_functions: {
|
|
input: {
|
|
(a) => b; // 1 args
|
|
(a, b) => c; // n args
|
|
() => b; // 0 args
|
|
(a) => (b) => c; // func returns func returns func
|
|
(a) => ((b) => c); // So these parens are dropped
|
|
() => (b,c) => d; // func returns func returns func
|
|
a=>{return b;}
|
|
a => 'lel'; // Dropping the parens
|
|
}
|
|
expect_exact: "a=>b;(a,b)=>c;()=>b;a=>b=>c;a=>b=>c;()=>(b,c)=>d;a=>{return b};a=>\"lel\";"
|
|
}
|
|
|
|
arrow_function_parens: {
|
|
input: {
|
|
something && (() => {});
|
|
}
|
|
expect_exact: "something&&(()=>{});"
|
|
}
|
|
arrow_function_parens_2: {
|
|
input: {
|
|
(() => null)();
|
|
}
|
|
expect_exact: "(()=>null)();"
|
|
}
|
|
|
|
regression_arrow_functions_and_hoist: {
|
|
options = {
|
|
hoist_vars: true,
|
|
hoist_funs: true
|
|
}
|
|
input: {
|
|
(a) => b;
|
|
}
|
|
expect_exact: "a=>b;"
|
|
}
|
|
|
|
typeof_arrow_functions: {
|
|
options = {
|
|
evaluate: true
|
|
}
|
|
input: {
|
|
typeof (x) => null;
|
|
}
|
|
expect_exact: "\"function\";"
|
|
}
|
|
|
|
template_strings: {
|
|
input: {
|
|
``;
|
|
`xx\`x`;
|
|
`${ foo + 2 }`;
|
|
` foo ${ bar + `baz ${ qux }` }`;
|
|
}
|
|
expect_exact: "``;`xx\\`x`;`${foo+2}`;` foo ${bar+`baz ${qux}`}`;";
|
|
}
|
|
|
|
destructuring_arguments: {
|
|
input: {
|
|
(function ( a ) { });
|
|
(function ( [ a ] ) { });
|
|
(function ( [ a, b ] ) { });
|
|
(function ( [ [ a ] ] ) { });
|
|
(function ( [ [ a, b ] ] ) { });
|
|
(function ( [ a, [ b ] ] ) { });
|
|
(function ( [ [ b ], a ] ) { });
|
|
|
|
(function ( { a } ) { });
|
|
(function ( { a, b } ) { });
|
|
|
|
(function ( [ { a } ] ) { });
|
|
(function ( [ { a, b } ] ) { });
|
|
(function ( [ a, { b } ] ) { });
|
|
(function ( [ { b }, a ] ) { });
|
|
|
|
( [ a ] ) => { };
|
|
( [ a, b ] ) => { };
|
|
|
|
( { a } ) => { };
|
|
( { a, b, c, d, e } ) => { };
|
|
|
|
( [ a ] ) => b;
|
|
( [ a, b ] ) => c;
|
|
|
|
( { a } ) => b;
|
|
( { a, b } ) => c;
|
|
}
|
|
expect: {
|
|
(function(a){});
|
|
(function([a]){});
|
|
(function([a,b]){});
|
|
(function([[a]]){});
|
|
(function([[a,b]]){});
|
|
(function([a,[b]]){});
|
|
(function([[b],a]){});
|
|
|
|
(function({a}){});
|
|
(function({a,b}){});
|
|
|
|
(function([{a}]){});
|
|
(function([{a,b}]){});
|
|
(function([a,{b}]){});
|
|
(function([{b},a]){});
|
|
|
|
([a])=>{};
|
|
([a,b])=>{};
|
|
|
|
({a})=>{};
|
|
({a,b,c,d,e})=>{};
|
|
|
|
([a])=>b;
|
|
([a,b])=>c;
|
|
|
|
({a})=>b;
|
|
({a,b})=>c;
|
|
}
|
|
}
|
|
|
|
number_literals: {
|
|
input: {
|
|
0b1001;
|
|
0B1001;
|
|
0o11;
|
|
0O11;
|
|
}
|
|
|
|
expect: {
|
|
9;
|
|
9;
|
|
9;
|
|
9;
|
|
}
|
|
}
|