File tree Expand file tree Collapse file tree 3 files changed +11
-3
lines changed Expand file tree Collapse file tree 3 files changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -30,7 +30,8 @@ function resolveJavascriptFunction(data) {
30
30
if ( ast . type !== 'Program' ||
31
31
ast . body . length !== 1 ||
32
32
ast . body [ 0 ] . type !== 'ExpressionStatement' ||
33
- ast . body [ 0 ] . expression . type !== 'FunctionExpression' ) {
33
+ ( ast . body [ 0 ] . expression . type !== 'ArrowFunctionExpression' &&
34
+ ast . body [ 0 ] . expression . type !== 'FunctionExpression' ) ) {
34
35
return false ;
35
36
}
36
37
@@ -51,7 +52,8 @@ function constructJavascriptFunction(data) {
51
52
if ( ast . type !== 'Program' ||
52
53
ast . body . length !== 1 ||
53
54
ast . body [ 0 ] . type !== 'ExpressionStatement' ||
54
- ast . body [ 0 ] . expression . type !== 'FunctionExpression' ) {
55
+ ( ast . body [ 0 ] . expression . type !== 'ArrowFunctionExpression' &&
56
+ ast . body [ 0 ] . expression . type !== 'FunctionExpression' ) ) {
55
57
throw new Error ( 'Failed to resolve function' ) ;
56
58
}
57
59
Original file line number Diff line number Diff line change @@ -9,6 +9,8 @@ function testHandler(actual) {
9
9
10
10
assert . strictEqual ( actual . length , expected . length ) ;
11
11
12
+ assert . strictEqual ( actual . length , expected . length ) ;
13
+
12
14
assert . strictEqual (
13
15
actual [ 0 ] ( ) ,
14
16
expected [ 0 ] ( ) ) ;
@@ -26,6 +28,9 @@ testHandler.expected = [
26
28
function ( ) {
27
29
return 42 ;
28
30
} ,
31
+ function ( ) {
32
+ return 72 ;
33
+ } ,
29
34
function ( x , y ) {
30
35
return x + y ;
31
36
} ,
Original file line number Diff line number Diff line change 1
1
- !!js/function 'function () { return 42 }'
2
+ - !!js/function '() => { return 72 }'
2
3
- !!js/function 'function (x, y) { return x + y; } '
3
4
- !!js/function |
4
5
function (foo) {
9
10
second : ' sum' ,
10
11
third : result
11
12
};
12
- }
13
+ }
You can’t perform that action at this time.
0 commit comments