diff --git a/README.md b/README.md index 75205cf4..d2b1288b 100644 --- a/README.md +++ b/README.md @@ -149,6 +149,8 @@ There are two ECMAScript 2017 syntax changes: `async` functions, and trailing co Because ECMAScript 2018 is still under development, we are implementing features as they are finalized. Currently, Espree supports: * Invalid escape sequences in tagged template literals +* Rest/spread properties +* Async Iteration ### How do you determine which experimental features to support? diff --git a/package.json b/package.json index 62513e48..9380f7a9 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ }, "license": "BSD-2-Clause", "dependencies": { - "acorn": "^5.3.0", + "acorn": "^5.4.0", "acorn-jsx": "^3.0.0" }, "devDependencies": { diff --git a/tests/fixtures/ecma-version/9/async-generator/invalid-await-in-nested-function-1.module-result.js b/tests/fixtures/ecma-version/9/async-generator/invalid-await-in-nested-function-1.module-result.js new file mode 100644 index 00000000..73e6bb83 --- /dev/null +++ b/tests/fixtures/ecma-version/9/async-generator/invalid-await-in-nested-function-1.module-result.js @@ -0,0 +1,6 @@ +module.exports = { + "index": 28, + "lineNumber": 1, + "column": 29, + "message": "Can not use keyword 'await' outside an async function" +}; diff --git a/tests/fixtures/ecma-version/9/async-generator/invalid-await-in-nested-function-1.result.js b/tests/fixtures/ecma-version/9/async-generator/invalid-await-in-nested-function-1.result.js new file mode 100644 index 00000000..dfbb9f85 --- /dev/null +++ b/tests/fixtures/ecma-version/9/async-generator/invalid-await-in-nested-function-1.result.js @@ -0,0 +1,6 @@ +module.exports = { + "index": 34, + "lineNumber": 1, + "column": 35, + "message": "Unexpected token a" +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/async-generator/invalid-await-in-nested-function-1.src.js b/tests/fixtures/ecma-version/9/async-generator/invalid-await-in-nested-function-1.src.js new file mode 100644 index 00000000..83818717 --- /dev/null +++ b/tests/fixtures/ecma-version/9/async-generator/invalid-await-in-nested-function-1.src.js @@ -0,0 +1 @@ +async function* f() { () => await a; } \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/async-generator/invalid-await-in-nested-function-2.module-result.js b/tests/fixtures/ecma-version/9/async-generator/invalid-await-in-nested-function-2.module-result.js new file mode 100644 index 00000000..cd1b05ca --- /dev/null +++ b/tests/fixtures/ecma-version/9/async-generator/invalid-await-in-nested-function-2.module-result.js @@ -0,0 +1,6 @@ +module.exports = { + "index": 30, + "lineNumber": 1, + "column": 31, + "message": "Can not use keyword 'await' outside an async function" +}; diff --git a/tests/fixtures/ecma-version/9/async-generator/invalid-await-in-nested-function-2.result.js b/tests/fixtures/ecma-version/9/async-generator/invalid-await-in-nested-function-2.result.js new file mode 100644 index 00000000..39426bea --- /dev/null +++ b/tests/fixtures/ecma-version/9/async-generator/invalid-await-in-nested-function-2.result.js @@ -0,0 +1,6 @@ +module.exports = { + "index": 36, + "lineNumber": 1, + "column": 37, + "message": "Unexpected token a" +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/async-generator/invalid-await-in-nested-function-2.src.js b/tests/fixtures/ecma-version/9/async-generator/invalid-await-in-nested-function-2.src.js new file mode 100644 index 00000000..a8643ed6 --- /dev/null +++ b/tests/fixtures/ecma-version/9/async-generator/invalid-await-in-nested-function-2.src.js @@ -0,0 +1 @@ +f = async function*() { () => await a; } \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/async-generator/invalid-await-in-nested-function-3.module-result.js b/tests/fixtures/ecma-version/9/async-generator/invalid-await-in-nested-function-3.module-result.js new file mode 100644 index 00000000..ef1e73e6 --- /dev/null +++ b/tests/fixtures/ecma-version/9/async-generator/invalid-await-in-nested-function-3.module-result.js @@ -0,0 +1,6 @@ +module.exports = { + "index": 27, + "lineNumber": 1, + "column": 28, + "message": "Can not use keyword 'await' outside an async function" +}; diff --git a/tests/fixtures/ecma-version/9/async-generator/invalid-await-in-nested-function-3.result.js b/tests/fixtures/ecma-version/9/async-generator/invalid-await-in-nested-function-3.result.js new file mode 100644 index 00000000..1c25a8b8 --- /dev/null +++ b/tests/fixtures/ecma-version/9/async-generator/invalid-await-in-nested-function-3.result.js @@ -0,0 +1,6 @@ +module.exports = { + "index": 33, + "lineNumber": 1, + "column": 34, + "message": "Unexpected token a" +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/async-generator/invalid-await-in-nested-function-3.src.js b/tests/fixtures/ecma-version/9/async-generator/invalid-await-in-nested-function-3.src.js new file mode 100644 index 00000000..a50d900a --- /dev/null +++ b/tests/fixtures/ecma-version/9/async-generator/invalid-await-in-nested-function-3.src.js @@ -0,0 +1 @@ +obj = { async* f() { () => await a; } } \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/async-generator/invalid-await-in-nested-function-4.module-result.js b/tests/fixtures/ecma-version/9/async-generator/invalid-await-in-nested-function-4.module-result.js new file mode 100644 index 00000000..1daed299 --- /dev/null +++ b/tests/fixtures/ecma-version/9/async-generator/invalid-await-in-nested-function-4.module-result.js @@ -0,0 +1,6 @@ +module.exports = { + "index": 29, + "lineNumber": 1, + "column": 30, + "message": "Can not use keyword 'await' outside an async function" +}; diff --git a/tests/fixtures/ecma-version/9/async-generator/invalid-await-in-nested-function-4.result.js b/tests/fixtures/ecma-version/9/async-generator/invalid-await-in-nested-function-4.result.js new file mode 100644 index 00000000..0bb4116c --- /dev/null +++ b/tests/fixtures/ecma-version/9/async-generator/invalid-await-in-nested-function-4.result.js @@ -0,0 +1,6 @@ +module.exports = { + "index": 35, + "lineNumber": 1, + "column": 36, + "message": "Unexpected token a" +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/async-generator/invalid-await-in-nested-function-4.src.js b/tests/fixtures/ecma-version/9/async-generator/invalid-await-in-nested-function-4.src.js new file mode 100644 index 00000000..2543a313 --- /dev/null +++ b/tests/fixtures/ecma-version/9/async-generator/invalid-await-in-nested-function-4.src.js @@ -0,0 +1 @@ +class A { async* f() { () => await a; } } \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/async-generator/invalid-linebreak-after-async-1.result.js b/tests/fixtures/ecma-version/9/async-generator/invalid-linebreak-after-async-1.result.js new file mode 100644 index 00000000..33102d9d --- /dev/null +++ b/tests/fixtures/ecma-version/9/async-generator/invalid-linebreak-after-async-1.result.js @@ -0,0 +1,6 @@ +module.exports = { + "index": 14, + "lineNumber": 2, + "column": 1, + "message": "Unexpected token *" +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/async-generator/invalid-linebreak-after-async-1.src.js b/tests/fixtures/ecma-version/9/async-generator/invalid-linebreak-after-async-1.src.js new file mode 100644 index 00000000..06d6fe83 --- /dev/null +++ b/tests/fixtures/ecma-version/9/async-generator/invalid-linebreak-after-async-1.src.js @@ -0,0 +1,2 @@ +obj = { async +* f() {} } \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/async-generator/invalid-linebreak-after-async-2.result.js b/tests/fixtures/ecma-version/9/async-generator/invalid-linebreak-after-async-2.result.js new file mode 100644 index 00000000..22e31633 --- /dev/null +++ b/tests/fixtures/ecma-version/9/async-generator/invalid-linebreak-after-async-2.result.js @@ -0,0 +1,6 @@ +module.exports = { + "index": 16, + "lineNumber": 2, + "column": 1, + "message": "Unexpected token *" +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/async-generator/invalid-linebreak-after-async-2.src.js b/tests/fixtures/ecma-version/9/async-generator/invalid-linebreak-after-async-2.src.js new file mode 100644 index 00000000..790c2cb9 --- /dev/null +++ b/tests/fixtures/ecma-version/9/async-generator/invalid-linebreak-after-async-2.src.js @@ -0,0 +1,2 @@ +class A { async +* f() {} } \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/async-generator/invalid-star-before-async-1.result.js b/tests/fixtures/ecma-version/9/async-generator/invalid-star-before-async-1.result.js new file mode 100644 index 00000000..e443bd5e --- /dev/null +++ b/tests/fixtures/ecma-version/9/async-generator/invalid-star-before-async-1.result.js @@ -0,0 +1,6 @@ +module.exports = { + "index": 15, + "lineNumber": 1, + "column": 16, + "message": "Unexpected token f" +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/async-generator/invalid-star-before-async-1.src.js b/tests/fixtures/ecma-version/9/async-generator/invalid-star-before-async-1.src.js new file mode 100644 index 00000000..a5446612 --- /dev/null +++ b/tests/fixtures/ecma-version/9/async-generator/invalid-star-before-async-1.src.js @@ -0,0 +1 @@ +obj = { *async f() {} \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/async-generator/invalid-star-before-async-2.result.js b/tests/fixtures/ecma-version/9/async-generator/invalid-star-before-async-2.result.js new file mode 100644 index 00000000..4035d5f3 --- /dev/null +++ b/tests/fixtures/ecma-version/9/async-generator/invalid-star-before-async-2.result.js @@ -0,0 +1,6 @@ +module.exports = { + "index": 17, + "lineNumber": 1, + "column": 18, + "message": "Unexpected token f" +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/async-generator/invalid-star-before-async-2.src.js b/tests/fixtures/ecma-version/9/async-generator/invalid-star-before-async-2.src.js new file mode 100644 index 00000000..f8ac0b47 --- /dev/null +++ b/tests/fixtures/ecma-version/9/async-generator/invalid-star-before-async-2.src.js @@ -0,0 +1 @@ +class A { *async f() {} } \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/async-generator/invalid-stars-around-async-1.result.js b/tests/fixtures/ecma-version/9/async-generator/invalid-stars-around-async-1.result.js new file mode 100644 index 00000000..54ed161f --- /dev/null +++ b/tests/fixtures/ecma-version/9/async-generator/invalid-stars-around-async-1.result.js @@ -0,0 +1,6 @@ +module.exports = { + "index": 14, + "lineNumber": 1, + "column": 15, + "message": "Unexpected token *" +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/async-generator/invalid-stars-around-async-1.src.js b/tests/fixtures/ecma-version/9/async-generator/invalid-stars-around-async-1.src.js new file mode 100644 index 00000000..75e9e359 --- /dev/null +++ b/tests/fixtures/ecma-version/9/async-generator/invalid-stars-around-async-1.src.js @@ -0,0 +1 @@ +obj = { *async* f() {} \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/async-generator/invalid-stars-around-async-2.result.js b/tests/fixtures/ecma-version/9/async-generator/invalid-stars-around-async-2.result.js new file mode 100644 index 00000000..13663c88 --- /dev/null +++ b/tests/fixtures/ecma-version/9/async-generator/invalid-stars-around-async-2.result.js @@ -0,0 +1,6 @@ +module.exports = { + "index": 16, + "lineNumber": 1, + "column": 17, + "message": "Unexpected token *" +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/async-generator/invalid-stars-around-async-2.src.js b/tests/fixtures/ecma-version/9/async-generator/invalid-stars-around-async-2.src.js new file mode 100644 index 00000000..7087efea --- /dev/null +++ b/tests/fixtures/ecma-version/9/async-generator/invalid-stars-around-async-2.src.js @@ -0,0 +1 @@ +class A { *async* f() {} } \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/async-generator/invalid-yield-in-nested-function-1.module-result.js b/tests/fixtures/ecma-version/9/async-generator/invalid-yield-in-nested-function-1.module-result.js new file mode 100644 index 00000000..8841aeec --- /dev/null +++ b/tests/fixtures/ecma-version/9/async-generator/invalid-yield-in-nested-function-1.module-result.js @@ -0,0 +1,6 @@ +module.exports = { + "index": 28, + "lineNumber": 1, + "column": 29, + "message": "The keyword 'yield' is reserved" +}; diff --git a/tests/fixtures/ecma-version/9/async-generator/invalid-yield-in-nested-function-1.result.js b/tests/fixtures/ecma-version/9/async-generator/invalid-yield-in-nested-function-1.result.js new file mode 100644 index 00000000..dfbb9f85 --- /dev/null +++ b/tests/fixtures/ecma-version/9/async-generator/invalid-yield-in-nested-function-1.result.js @@ -0,0 +1,6 @@ +module.exports = { + "index": 34, + "lineNumber": 1, + "column": 35, + "message": "Unexpected token a" +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/async-generator/invalid-yield-in-nested-function-1.src.js b/tests/fixtures/ecma-version/9/async-generator/invalid-yield-in-nested-function-1.src.js new file mode 100644 index 00000000..e56cd7d6 --- /dev/null +++ b/tests/fixtures/ecma-version/9/async-generator/invalid-yield-in-nested-function-1.src.js @@ -0,0 +1 @@ +async function* f() { () => yield a; } \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/async-generator/invalid-yield-in-nested-function-2.module-result.js b/tests/fixtures/ecma-version/9/async-generator/invalid-yield-in-nested-function-2.module-result.js new file mode 100644 index 00000000..27477920 --- /dev/null +++ b/tests/fixtures/ecma-version/9/async-generator/invalid-yield-in-nested-function-2.module-result.js @@ -0,0 +1,6 @@ +module.exports = { + "index": 30, + "lineNumber": 1, + "column": 31, + "message": "The keyword 'yield' is reserved" +}; diff --git a/tests/fixtures/ecma-version/9/async-generator/invalid-yield-in-nested-function-2.result.js b/tests/fixtures/ecma-version/9/async-generator/invalid-yield-in-nested-function-2.result.js new file mode 100644 index 00000000..39426bea --- /dev/null +++ b/tests/fixtures/ecma-version/9/async-generator/invalid-yield-in-nested-function-2.result.js @@ -0,0 +1,6 @@ +module.exports = { + "index": 36, + "lineNumber": 1, + "column": 37, + "message": "Unexpected token a" +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/async-generator/invalid-yield-in-nested-function-2.src.js b/tests/fixtures/ecma-version/9/async-generator/invalid-yield-in-nested-function-2.src.js new file mode 100644 index 00000000..728454fd --- /dev/null +++ b/tests/fixtures/ecma-version/9/async-generator/invalid-yield-in-nested-function-2.src.js @@ -0,0 +1 @@ +f = async function*() { () => yield a; } \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/async-generator/invalid-yield-in-nested-function-3.module-result.js b/tests/fixtures/ecma-version/9/async-generator/invalid-yield-in-nested-function-3.module-result.js new file mode 100644 index 00000000..eec84a53 --- /dev/null +++ b/tests/fixtures/ecma-version/9/async-generator/invalid-yield-in-nested-function-3.module-result.js @@ -0,0 +1,6 @@ +module.exports = { + "index": 27, + "lineNumber": 1, + "column": 28, + "message": "The keyword 'yield' is reserved" +}; diff --git a/tests/fixtures/ecma-version/9/async-generator/invalid-yield-in-nested-function-3.result.js b/tests/fixtures/ecma-version/9/async-generator/invalid-yield-in-nested-function-3.result.js new file mode 100644 index 00000000..1c25a8b8 --- /dev/null +++ b/tests/fixtures/ecma-version/9/async-generator/invalid-yield-in-nested-function-3.result.js @@ -0,0 +1,6 @@ +module.exports = { + "index": 33, + "lineNumber": 1, + "column": 34, + "message": "Unexpected token a" +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/async-generator/invalid-yield-in-nested-function-3.src.js b/tests/fixtures/ecma-version/9/async-generator/invalid-yield-in-nested-function-3.src.js new file mode 100644 index 00000000..1cb0c727 --- /dev/null +++ b/tests/fixtures/ecma-version/9/async-generator/invalid-yield-in-nested-function-3.src.js @@ -0,0 +1 @@ +obj = { async* f() { () => yield a; } } \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/async-generator/invalid-yield-in-nested-function-4.module-result.js b/tests/fixtures/ecma-version/9/async-generator/invalid-yield-in-nested-function-4.module-result.js new file mode 100644 index 00000000..20483b50 --- /dev/null +++ b/tests/fixtures/ecma-version/9/async-generator/invalid-yield-in-nested-function-4.module-result.js @@ -0,0 +1,6 @@ +module.exports = { + "index": 29, + "lineNumber": 1, + "column": 30, + "message": "The keyword 'yield' is reserved" +}; diff --git a/tests/fixtures/ecma-version/9/async-generator/invalid-yield-in-nested-function-4.result.js b/tests/fixtures/ecma-version/9/async-generator/invalid-yield-in-nested-function-4.result.js new file mode 100644 index 00000000..0bb4116c --- /dev/null +++ b/tests/fixtures/ecma-version/9/async-generator/invalid-yield-in-nested-function-4.result.js @@ -0,0 +1,6 @@ +module.exports = { + "index": 35, + "lineNumber": 1, + "column": 36, + "message": "Unexpected token a" +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/async-generator/invalid-yield-in-nested-function-4.src.js b/tests/fixtures/ecma-version/9/async-generator/invalid-yield-in-nested-function-4.src.js new file mode 100644 index 00000000..fd60fbe2 --- /dev/null +++ b/tests/fixtures/ecma-version/9/async-generator/invalid-yield-in-nested-function-4.src.js @@ -0,0 +1 @@ +class A { async* f() { () => yield a; } } \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/async-generator/valid-class-method.result.js b/tests/fixtures/ecma-version/9/async-generator/valid-class-method.result.js new file mode 100644 index 00000000..1351b645 --- /dev/null +++ b/tests/fixtures/ecma-version/9/async-generator/valid-class-method.result.js @@ -0,0 +1,567 @@ +module.exports = { + "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 44 + } + }, + "range": [ + 0, + 44 + ], + "body": [ + { + "type": "ClassDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 44 + } + }, + "range": [ + 0, + 44 + ], + "id": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "range": [ + 6, + 7 + ], + "name": "A" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 44 + } + }, + "range": [ + 8, + 44 + ], + "body": [ + { + "type": "MethodDefinition", + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 42 + } + }, + "range": [ + 10, + 42 + ], + "kind": "method", + "static": false, + "computed": false, + "key": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "range": [ + 17, + 18 + ], + "name": "f" + }, + "value": { + "type": "FunctionExpression", + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 42 + } + }, + "range": [ + 18, + 42 + ], + "id": null, + "generator": true, + "expression": false, + "async": true, + "params": [], + "body": { + "type": "BlockStatement", + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 42 + } + }, + "range": [ + 21, + 42 + ], + "body": [ + { + "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 23 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "range": [ + 23, + 31 + ], + "expression": { + "type": "AwaitExpression", + "loc": { + "start": { + "line": 1, + "column": 23 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "range": [ + 23, + 30 + ], + "argument": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 29 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "range": [ + 29, + 30 + ], + "name": "a" + } + } + }, + { + "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 40 + } + }, + "range": [ + 32, + 40 + ], + "expression": { + "type": "YieldExpression", + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "range": [ + 32, + 39 + ], + "delegate": false, + "argument": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 38 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "range": [ + 38, + 39 + ], + "name": "b" + } + } + } + ] + } + } + } + ] + } + } + ], + "sourceType": "script", + "tokens": [ + { + "type": "Keyword", + "value": "class", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "range": [ + 0, + 5 + ] + }, + { + "type": "Identifier", + "value": "A", + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "range": [ + 6, + 7 + ] + }, + { + "type": "Punctuator", + "value": "{", + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "range": [ + 8, + 9 + ] + }, + { + "type": "Identifier", + "value": "async", + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "range": [ + 10, + 15 + ] + }, + { + "type": "Punctuator", + "value": "*", + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "range": [ + 15, + 16 + ] + }, + { + "type": "Identifier", + "value": "f", + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "range": [ + 17, + 18 + ] + }, + { + "type": "Punctuator", + "value": "(", + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "range": [ + 18, + 19 + ] + }, + { + "type": "Punctuator", + "value": ")", + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "range": [ + 19, + 20 + ] + }, + { + "type": "Punctuator", + "value": "{", + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "range": [ + 21, + 22 + ] + }, + { + "type": "Identifier", + "value": "await", + "loc": { + "start": { + "line": 1, + "column": 23 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "range": [ + 23, + 28 + ] + }, + { + "type": "Identifier", + "value": "a", + "loc": { + "start": { + "line": 1, + "column": 29 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "range": [ + 29, + 30 + ] + }, + { + "type": "Punctuator", + "value": ";", + "loc": { + "start": { + "line": 1, + "column": 30 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "range": [ + 30, + 31 + ] + }, + { + "type": "Keyword", + "value": "yield", + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 37 + } + }, + "range": [ + 32, + 37 + ] + }, + { + "type": "Identifier", + "value": "b", + "loc": { + "start": { + "line": 1, + "column": 38 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "range": [ + 38, + 39 + ] + }, + { + "type": "Punctuator", + "value": ";", + "loc": { + "start": { + "line": 1, + "column": 39 + }, + "end": { + "line": 1, + "column": 40 + } + }, + "range": [ + 39, + 40 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 1, + "column": 41 + }, + "end": { + "line": 1, + "column": 42 + } + }, + "range": [ + 41, + 42 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 1, + "column": 43 + }, + "end": { + "line": 1, + "column": 44 + } + }, + "range": [ + 43, + 44 + ] + } + ] +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/async-generator/valid-class-method.src.js b/tests/fixtures/ecma-version/9/async-generator/valid-class-method.src.js new file mode 100644 index 00000000..b558a19b --- /dev/null +++ b/tests/fixtures/ecma-version/9/async-generator/valid-class-method.src.js @@ -0,0 +1 @@ +class A { async* f() { await a; yield b; } } \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/async-generator/valid-class-static-method.result.js b/tests/fixtures/ecma-version/9/async-generator/valid-class-static-method.result.js new file mode 100644 index 00000000..6a468cea --- /dev/null +++ b/tests/fixtures/ecma-version/9/async-generator/valid-class-static-method.result.js @@ -0,0 +1,585 @@ +module.exports = { + "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 51 + } + }, + "range": [ + 0, + 51 + ], + "body": [ + { + "type": "ClassDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 51 + } + }, + "range": [ + 0, + 51 + ], + "id": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "range": [ + 6, + 7 + ], + "name": "A" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 51 + } + }, + "range": [ + 8, + 51 + ], + "body": [ + { + "type": "MethodDefinition", + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 49 + } + }, + "range": [ + 10, + 49 + ], + "kind": "method", + "static": true, + "computed": false, + "key": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 24 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "range": [ + 24, + 25 + ], + "name": "f" + }, + "value": { + "type": "FunctionExpression", + "loc": { + "start": { + "line": 1, + "column": 25 + }, + "end": { + "line": 1, + "column": 49 + } + }, + "range": [ + 25, + 49 + ], + "id": null, + "generator": true, + "expression": false, + "async": true, + "params": [], + "body": { + "type": "BlockStatement", + "loc": { + "start": { + "line": 1, + "column": 28 + }, + "end": { + "line": 1, + "column": 49 + } + }, + "range": [ + 28, + 49 + ], + "body": [ + { + "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 30 + }, + "end": { + "line": 1, + "column": 38 + } + }, + "range": [ + 30, + 38 + ], + "expression": { + "type": "AwaitExpression", + "loc": { + "start": { + "line": 1, + "column": 30 + }, + "end": { + "line": 1, + "column": 37 + } + }, + "range": [ + 30, + 37 + ], + "argument": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 36 + }, + "end": { + "line": 1, + "column": 37 + } + }, + "range": [ + 36, + 37 + ], + "name": "a" + } + } + }, + { + "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 39 + }, + "end": { + "line": 1, + "column": 47 + } + }, + "range": [ + 39, + 47 + ], + "expression": { + "type": "YieldExpression", + "loc": { + "start": { + "line": 1, + "column": 39 + }, + "end": { + "line": 1, + "column": 46 + } + }, + "range": [ + 39, + 46 + ], + "delegate": false, + "argument": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 45 + }, + "end": { + "line": 1, + "column": 46 + } + }, + "range": [ + 45, + 46 + ], + "name": "b" + } + } + } + ] + } + } + } + ] + } + } + ], + "sourceType": "script", + "tokens": [ + { + "type": "Keyword", + "value": "class", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "range": [ + 0, + 5 + ] + }, + { + "type": "Identifier", + "value": "A", + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "range": [ + 6, + 7 + ] + }, + { + "type": "Punctuator", + "value": "{", + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "range": [ + 8, + 9 + ] + }, + { + "type": "Keyword", + "value": "static", + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "range": [ + 10, + 16 + ] + }, + { + "type": "Identifier", + "value": "async", + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "range": [ + 17, + 22 + ] + }, + { + "type": "Punctuator", + "value": "*", + "loc": { + "start": { + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "range": [ + 22, + 23 + ] + }, + { + "type": "Identifier", + "value": "f", + "loc": { + "start": { + "line": 1, + "column": 24 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "range": [ + 24, + 25 + ] + }, + { + "type": "Punctuator", + "value": "(", + "loc": { + "start": { + "line": 1, + "column": 25 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "range": [ + 25, + 26 + ] + }, + { + "type": "Punctuator", + "value": ")", + "loc": { + "start": { + "line": 1, + "column": 26 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "range": [ + 26, + 27 + ] + }, + { + "type": "Punctuator", + "value": "{", + "loc": { + "start": { + "line": 1, + "column": 28 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "range": [ + 28, + 29 + ] + }, + { + "type": "Identifier", + "value": "await", + "loc": { + "start": { + "line": 1, + "column": 30 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "range": [ + 30, + 35 + ] + }, + { + "type": "Identifier", + "value": "a", + "loc": { + "start": { + "line": 1, + "column": 36 + }, + "end": { + "line": 1, + "column": 37 + } + }, + "range": [ + 36, + 37 + ] + }, + { + "type": "Punctuator", + "value": ";", + "loc": { + "start": { + "line": 1, + "column": 37 + }, + "end": { + "line": 1, + "column": 38 + } + }, + "range": [ + 37, + 38 + ] + }, + { + "type": "Keyword", + "value": "yield", + "loc": { + "start": { + "line": 1, + "column": 39 + }, + "end": { + "line": 1, + "column": 44 + } + }, + "range": [ + 39, + 44 + ] + }, + { + "type": "Identifier", + "value": "b", + "loc": { + "start": { + "line": 1, + "column": 45 + }, + "end": { + "line": 1, + "column": 46 + } + }, + "range": [ + 45, + 46 + ] + }, + { + "type": "Punctuator", + "value": ";", + "loc": { + "start": { + "line": 1, + "column": 46 + }, + "end": { + "line": 1, + "column": 47 + } + }, + "range": [ + 46, + 47 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 1, + "column": 48 + }, + "end": { + "line": 1, + "column": 49 + } + }, + "range": [ + 48, + 49 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 1, + "column": 50 + }, + "end": { + "line": 1, + "column": 51 + } + }, + "range": [ + 50, + 51 + ] + } + ] +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/async-generator/valid-class-static-method.src.js b/tests/fixtures/ecma-version/9/async-generator/valid-class-static-method.src.js new file mode 100644 index 00000000..3523d747 --- /dev/null +++ b/tests/fixtures/ecma-version/9/async-generator/valid-class-static-method.src.js @@ -0,0 +1 @@ +class A { static async* f() { await a; yield b; } } \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/async-generator/valid-function-declaration.result.js b/tests/fixtures/ecma-version/9/async-generator/valid-function-declaration.result.js new file mode 100644 index 00000000..25cece6c --- /dev/null +++ b/tests/fixtures/ecma-version/9/async-generator/valid-function-declaration.result.js @@ -0,0 +1,437 @@ +module.exports = { + "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 41 + } + }, + "range": [ + 0, + 41 + ], + "body": [ + { + "type": "FunctionDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 41 + } + }, + "range": [ + 0, + 41 + ], + "id": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "range": [ + 16, + 17 + ], + "name": "f" + }, + "generator": true, + "expression": false, + "async": true, + "params": [], + "body": { + "type": "BlockStatement", + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 41 + } + }, + "range": [ + 20, + 41 + ], + "body": [ + { + "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "range": [ + 22, + 30 + ], + "expression": { + "type": "AwaitExpression", + "loc": { + "start": { + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "range": [ + 22, + 29 + ], + "argument": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 28 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "range": [ + 28, + 29 + ], + "name": "a" + } + } + }, + { + "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 31 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "range": [ + 31, + 39 + ], + "expression": { + "type": "YieldExpression", + "loc": { + "start": { + "line": 1, + "column": 31 + }, + "end": { + "line": 1, + "column": 38 + } + }, + "range": [ + 31, + 38 + ], + "delegate": false, + "argument": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 37 + }, + "end": { + "line": 1, + "column": 38 + } + }, + "range": [ + 37, + 38 + ], + "name": "b" + } + } + } + ] + } + } + ], + "sourceType": "script", + "tokens": [ + { + "type": "Identifier", + "value": "async", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "range": [ + 0, + 5 + ] + }, + { + "type": "Keyword", + "value": "function", + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "range": [ + 6, + 14 + ] + }, + { + "type": "Punctuator", + "value": "*", + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "range": [ + 14, + 15 + ] + }, + { + "type": "Identifier", + "value": "f", + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "range": [ + 16, + 17 + ] + }, + { + "type": "Punctuator", + "value": "(", + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "range": [ + 17, + 18 + ] + }, + { + "type": "Punctuator", + "value": ")", + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "range": [ + 18, + 19 + ] + }, + { + "type": "Punctuator", + "value": "{", + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "range": [ + 20, + 21 + ] + }, + { + "type": "Identifier", + "value": "await", + "loc": { + "start": { + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "range": [ + 22, + 27 + ] + }, + { + "type": "Identifier", + "value": "a", + "loc": { + "start": { + "line": 1, + "column": 28 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "range": [ + 28, + 29 + ] + }, + { + "type": "Punctuator", + "value": ";", + "loc": { + "start": { + "line": 1, + "column": 29 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "range": [ + 29, + 30 + ] + }, + { + "type": "Keyword", + "value": "yield", + "loc": { + "start": { + "line": 1, + "column": 31 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "range": [ + 31, + 36 + ] + }, + { + "type": "Identifier", + "value": "b", + "loc": { + "start": { + "line": 1, + "column": 37 + }, + "end": { + "line": 1, + "column": 38 + } + }, + "range": [ + 37, + 38 + ] + }, + { + "type": "Punctuator", + "value": ";", + "loc": { + "start": { + "line": 1, + "column": 38 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "range": [ + 38, + 39 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 1, + "column": 40 + }, + "end": { + "line": 1, + "column": 41 + } + }, + "range": [ + 40, + 41 + ] + } + ] +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/async-generator/valid-function-declaration.src.js b/tests/fixtures/ecma-version/9/async-generator/valid-function-declaration.src.js new file mode 100644 index 00000000..6b1f2bc7 --- /dev/null +++ b/tests/fixtures/ecma-version/9/async-generator/valid-function-declaration.src.js @@ -0,0 +1 @@ +async function* f() { await a; yield b; } \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/async-generator/valid-function-expression.result.js b/tests/fixtures/ecma-version/9/async-generator/valid-function-expression.result.js new file mode 100644 index 00000000..133c73a5 --- /dev/null +++ b/tests/fixtures/ecma-version/9/async-generator/valid-function-expression.result.js @@ -0,0 +1,491 @@ +module.exports = { + "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 43 + } + }, + "range": [ + 0, + 43 + ], + "body": [ + { + "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 43 + } + }, + "range": [ + 0, + 43 + ], + "expression": { + "type": "AssignmentExpression", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 43 + } + }, + "range": [ + 0, + 43 + ], + "operator": "=", + "left": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 1 + } + }, + "range": [ + 0, + 1 + ], + "name": "f" + }, + "right": { + "type": "FunctionExpression", + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 43 + } + }, + "range": [ + 4, + 43 + ], + "id": null, + "generator": true, + "expression": false, + "async": true, + "params": [], + "body": { + "type": "BlockStatement", + "loc": { + "start": { + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 43 + } + }, + "range": [ + 22, + 43 + ], + "body": [ + { + "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 24 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "range": [ + 24, + 32 + ], + "expression": { + "type": "AwaitExpression", + "loc": { + "start": { + "line": 1, + "column": 24 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "range": [ + 24, + 31 + ], + "argument": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 30 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "range": [ + 30, + 31 + ], + "name": "a" + } + } + }, + { + "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 33 + }, + "end": { + "line": 1, + "column": 41 + } + }, + "range": [ + 33, + 41 + ], + "expression": { + "type": "YieldExpression", + "loc": { + "start": { + "line": 1, + "column": 33 + }, + "end": { + "line": 1, + "column": 40 + } + }, + "range": [ + 33, + 40 + ], + "delegate": false, + "argument": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 39 + }, + "end": { + "line": 1, + "column": 40 + } + }, + "range": [ + 39, + 40 + ], + "name": "b" + } + } + } + ] + } + } + } + } + ], + "sourceType": "script", + "tokens": [ + { + "type": "Identifier", + "value": "f", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 1 + } + }, + "range": [ + 0, + 1 + ] + }, + { + "type": "Punctuator", + "value": "=", + "loc": { + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "range": [ + 2, + 3 + ] + }, + { + "type": "Identifier", + "value": "async", + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "range": [ + 4, + 9 + ] + }, + { + "type": "Keyword", + "value": "function", + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "range": [ + 10, + 18 + ] + }, + { + "type": "Punctuator", + "value": "*", + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "range": [ + 18, + 19 + ] + }, + { + "type": "Punctuator", + "value": "(", + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "range": [ + 19, + 20 + ] + }, + { + "type": "Punctuator", + "value": ")", + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "range": [ + 20, + 21 + ] + }, + { + "type": "Punctuator", + "value": "{", + "loc": { + "start": { + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "range": [ + 22, + 23 + ] + }, + { + "type": "Identifier", + "value": "await", + "loc": { + "start": { + "line": 1, + "column": 24 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "range": [ + 24, + 29 + ] + }, + { + "type": "Identifier", + "value": "a", + "loc": { + "start": { + "line": 1, + "column": 30 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "range": [ + 30, + 31 + ] + }, + { + "type": "Punctuator", + "value": ";", + "loc": { + "start": { + "line": 1, + "column": 31 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "range": [ + 31, + 32 + ] + }, + { + "type": "Keyword", + "value": "yield", + "loc": { + "start": { + "line": 1, + "column": 33 + }, + "end": { + "line": 1, + "column": 38 + } + }, + "range": [ + 33, + 38 + ] + }, + { + "type": "Identifier", + "value": "b", + "loc": { + "start": { + "line": 1, + "column": 39 + }, + "end": { + "line": 1, + "column": 40 + } + }, + "range": [ + 39, + 40 + ] + }, + { + "type": "Punctuator", + "value": ";", + "loc": { + "start": { + "line": 1, + "column": 40 + }, + "end": { + "line": 1, + "column": 41 + } + }, + "range": [ + 40, + 41 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 1, + "column": 42 + }, + "end": { + "line": 1, + "column": 43 + } + }, + "range": [ + 42, + 43 + ] + } + ] +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/async-generator/valid-function-expression.src.js b/tests/fixtures/ecma-version/9/async-generator/valid-function-expression.src.js new file mode 100644 index 00000000..dab08248 --- /dev/null +++ b/tests/fixtures/ecma-version/9/async-generator/valid-function-expression.src.js @@ -0,0 +1 @@ +f = async function*() { await a; yield b; } \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/async-generator/valid-object-method.result.js b/tests/fixtures/ecma-version/9/async-generator/valid-object-method.result.js new file mode 100644 index 00000000..c6816981 --- /dev/null +++ b/tests/fixtures/ecma-version/9/async-generator/valid-object-method.result.js @@ -0,0 +1,585 @@ +module.exports = { + "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 42 + } + }, + "range": [ + 0, + 42 + ], + "body": [ + { + "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 42 + } + }, + "range": [ + 0, + 42 + ], + "expression": { + "type": "AssignmentExpression", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 42 + } + }, + "range": [ + 0, + 42 + ], + "operator": "=", + "left": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "range": [ + 0, + 3 + ], + "name": "obj" + }, + "right": { + "type": "ObjectExpression", + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 42 + } + }, + "range": [ + 6, + 42 + ], + "properties": [ + { + "type": "Property", + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 40 + } + }, + "range": [ + 8, + 40 + ], + "method": true, + "shorthand": false, + "computed": false, + "key": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "range": [ + 15, + 16 + ], + "name": "f" + }, + "kind": "init", + "value": { + "type": "FunctionExpression", + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 40 + } + }, + "range": [ + 16, + 40 + ], + "id": null, + "generator": true, + "expression": false, + "async": true, + "params": [], + "body": { + "type": "BlockStatement", + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 40 + } + }, + "range": [ + 19, + 40 + ], + "body": [ + { + "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "range": [ + 21, + 29 + ], + "expression": { + "type": "AwaitExpression", + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "range": [ + 21, + 28 + ], + "argument": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 27 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "range": [ + 27, + 28 + ], + "name": "a" + } + } + }, + { + "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 30 + }, + "end": { + "line": 1, + "column": 38 + } + }, + "range": [ + 30, + 38 + ], + "expression": { + "type": "YieldExpression", + "loc": { + "start": { + "line": 1, + "column": 30 + }, + "end": { + "line": 1, + "column": 37 + } + }, + "range": [ + 30, + 37 + ], + "delegate": false, + "argument": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 36 + }, + "end": { + "line": 1, + "column": 37 + } + }, + "range": [ + 36, + 37 + ], + "name": "b" + } + } + } + ] + } + } + } + ] + } + } + } + ], + "sourceType": "script", + "tokens": [ + { + "type": "Identifier", + "value": "obj", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "range": [ + 0, + 3 + ] + }, + { + "type": "Punctuator", + "value": "=", + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "range": [ + 4, + 5 + ] + }, + { + "type": "Punctuator", + "value": "{", + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "range": [ + 6, + 7 + ] + }, + { + "type": "Identifier", + "value": "async", + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "range": [ + 8, + 13 + ] + }, + { + "type": "Punctuator", + "value": "*", + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "range": [ + 13, + 14 + ] + }, + { + "type": "Identifier", + "value": "f", + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "range": [ + 15, + 16 + ] + }, + { + "type": "Punctuator", + "value": "(", + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "range": [ + 16, + 17 + ] + }, + { + "type": "Punctuator", + "value": ")", + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "range": [ + 17, + 18 + ] + }, + { + "type": "Punctuator", + "value": "{", + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "range": [ + 19, + 20 + ] + }, + { + "type": "Identifier", + "value": "await", + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "range": [ + 21, + 26 + ] + }, + { + "type": "Identifier", + "value": "a", + "loc": { + "start": { + "line": 1, + "column": 27 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "range": [ + 27, + 28 + ] + }, + { + "type": "Punctuator", + "value": ";", + "loc": { + "start": { + "line": 1, + "column": 28 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "range": [ + 28, + 29 + ] + }, + { + "type": "Keyword", + "value": "yield", + "loc": { + "start": { + "line": 1, + "column": 30 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "range": [ + 30, + 35 + ] + }, + { + "type": "Identifier", + "value": "b", + "loc": { + "start": { + "line": 1, + "column": 36 + }, + "end": { + "line": 1, + "column": 37 + } + }, + "range": [ + 36, + 37 + ] + }, + { + "type": "Punctuator", + "value": ";", + "loc": { + "start": { + "line": 1, + "column": 37 + }, + "end": { + "line": 1, + "column": 38 + } + }, + "range": [ + 37, + 38 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 1, + "column": 39 + }, + "end": { + "line": 1, + "column": 40 + } + }, + "range": [ + 39, + 40 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 1, + "column": 41 + }, + "end": { + "line": 1, + "column": 42 + } + }, + "range": [ + 41, + 42 + ] + } + ] +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/async-generator/valid-object-method.src.js b/tests/fixtures/ecma-version/9/async-generator/valid-object-method.src.js new file mode 100644 index 00000000..d491af54 --- /dev/null +++ b/tests/fixtures/ecma-version/9/async-generator/valid-object-method.src.js @@ -0,0 +1 @@ +obj = { async* f() { await a; yield b; } } \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/for-await-of/invalid-in-arrow-function.result.js b/tests/fixtures/ecma-version/9/for-await-of/invalid-in-arrow-function.result.js new file mode 100644 index 00000000..15a30d28 --- /dev/null +++ b/tests/fixtures/ecma-version/9/for-await-of/invalid-in-arrow-function.result.js @@ -0,0 +1,6 @@ +module.exports = { + "index": 16, + "lineNumber": 1, + "column": 17, + "message": "Unexpected token await" +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/for-await-of/invalid-in-arrow-function.src.js b/tests/fixtures/ecma-version/9/for-await-of/invalid-in-arrow-function.src.js new file mode 100644 index 00000000..5618d7fd --- /dev/null +++ b/tests/fixtures/ecma-version/9/for-await-of/invalid-in-arrow-function.src.js @@ -0,0 +1 @@ +f = () => { for await (x of xs); } \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/for-await-of/invalid-in-function-declaration.result.js b/tests/fixtures/ecma-version/9/for-await-of/invalid-in-function-declaration.result.js new file mode 100644 index 00000000..32174d64 --- /dev/null +++ b/tests/fixtures/ecma-version/9/for-await-of/invalid-in-function-declaration.result.js @@ -0,0 +1,6 @@ +module.exports = { + "index": 19, + "lineNumber": 1, + "column": 20, + "message": "Unexpected token await" +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/for-await-of/invalid-in-function-declaration.src.js b/tests/fixtures/ecma-version/9/for-await-of/invalid-in-function-declaration.src.js new file mode 100644 index 00000000..5427b9b0 --- /dev/null +++ b/tests/fixtures/ecma-version/9/for-await-of/invalid-in-function-declaration.src.js @@ -0,0 +1 @@ +function f() { for await (x of xs); } \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/for-await-of/invalid-in-function-expression.result.js b/tests/fixtures/ecma-version/9/for-await-of/invalid-in-function-expression.result.js new file mode 100644 index 00000000..99f5a4c6 --- /dev/null +++ b/tests/fixtures/ecma-version/9/for-await-of/invalid-in-function-expression.result.js @@ -0,0 +1,6 @@ +module.exports = { + "index": 21, + "lineNumber": 1, + "column": 22, + "message": "Unexpected token await" +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/for-await-of/invalid-in-function-expression.src.js b/tests/fixtures/ecma-version/9/for-await-of/invalid-in-function-expression.src.js new file mode 100644 index 00000000..ae813452 --- /dev/null +++ b/tests/fixtures/ecma-version/9/for-await-of/invalid-in-function-expression.src.js @@ -0,0 +1 @@ +f = function() { for await (x of xs); } \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/for-await-of/invalid-in-nested-function.result.js b/tests/fixtures/ecma-version/9/for-await-of/invalid-in-nested-function.result.js new file mode 100644 index 00000000..56c198b2 --- /dev/null +++ b/tests/fixtures/ecma-version/9/for-await-of/invalid-in-nested-function.result.js @@ -0,0 +1,6 @@ +module.exports = { + "index": 33, + "lineNumber": 1, + "column": 34, + "message": "Unexpected token await" +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/for-await-of/invalid-in-nested-function.src.js b/tests/fixtures/ecma-version/9/for-await-of/invalid-in-nested-function.src.js new file mode 100644 index 00000000..e23fa625 --- /dev/null +++ b/tests/fixtures/ecma-version/9/for-await-of/invalid-in-nested-function.src.js @@ -0,0 +1 @@ +async function f() { () => { for await (x of xs); } } \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/for-await-of/invalid-on-top-level.result.js b/tests/fixtures/ecma-version/9/for-await-of/invalid-on-top-level.result.js new file mode 100644 index 00000000..a3c97031 --- /dev/null +++ b/tests/fixtures/ecma-version/9/for-await-of/invalid-on-top-level.result.js @@ -0,0 +1,6 @@ +module.exports = { + "index": 4, + "lineNumber": 1, + "column": 5, + "message": "Unexpected token await" +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/for-await-of/invalid-on-top-level.src.js b/tests/fixtures/ecma-version/9/for-await-of/invalid-on-top-level.src.js new file mode 100644 index 00000000..f3f24e70 --- /dev/null +++ b/tests/fixtures/ecma-version/9/for-await-of/invalid-on-top-level.src.js @@ -0,0 +1 @@ +for await (x of xs); \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/for-await-of/invalid-with-for-1.result.js b/tests/fixtures/ecma-version/9/for-await-of/invalid-with-for-1.result.js new file mode 100644 index 00000000..4e24fdc6 --- /dev/null +++ b/tests/fixtures/ecma-version/9/for-await-of/invalid-with-for-1.result.js @@ -0,0 +1,6 @@ +module.exports = { + "index": 25, + "lineNumber": 1, + "column": 26, + "message": "Unexpected token await" +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/for-await-of/invalid-with-for-1.src.js b/tests/fixtures/ecma-version/9/for-await-of/invalid-with-for-1.src.js new file mode 100644 index 00000000..eb48b6c9 --- /dev/null +++ b/tests/fixtures/ecma-version/9/for-await-of/invalid-with-for-1.src.js @@ -0,0 +1 @@ +async function f() { for await (;;); } \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/for-await-of/invalid-with-for-2.result.js b/tests/fixtures/ecma-version/9/for-await-of/invalid-with-for-2.result.js new file mode 100644 index 00000000..4e24fdc6 --- /dev/null +++ b/tests/fixtures/ecma-version/9/for-await-of/invalid-with-for-2.result.js @@ -0,0 +1,6 @@ +module.exports = { + "index": 25, + "lineNumber": 1, + "column": 26, + "message": "Unexpected token await" +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/for-await-of/invalid-with-for-2.src.js b/tests/fixtures/ecma-version/9/for-await-of/invalid-with-for-2.src.js new file mode 100644 index 00000000..767e986f --- /dev/null +++ b/tests/fixtures/ecma-version/9/for-await-of/invalid-with-for-2.src.js @@ -0,0 +1 @@ +async function f() { for await (x;;); } \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/for-await-of/invalid-with-for-3.result.js b/tests/fixtures/ecma-version/9/for-await-of/invalid-with-for-3.result.js new file mode 100644 index 00000000..4e24fdc6 --- /dev/null +++ b/tests/fixtures/ecma-version/9/for-await-of/invalid-with-for-3.result.js @@ -0,0 +1,6 @@ +module.exports = { + "index": 25, + "lineNumber": 1, + "column": 26, + "message": "Unexpected token await" +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/for-await-of/invalid-with-for-3.src.js b/tests/fixtures/ecma-version/9/for-await-of/invalid-with-for-3.src.js new file mode 100644 index 00000000..a0fdc374 --- /dev/null +++ b/tests/fixtures/ecma-version/9/for-await-of/invalid-with-for-3.src.js @@ -0,0 +1 @@ +async function f() { for await (let x = 0;;); } \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/for-await-of/invalid-with-for-in.result.js b/tests/fixtures/ecma-version/9/for-await-of/invalid-with-for-in.result.js new file mode 100644 index 00000000..4e24fdc6 --- /dev/null +++ b/tests/fixtures/ecma-version/9/for-await-of/invalid-with-for-in.result.js @@ -0,0 +1,6 @@ +module.exports = { + "index": 25, + "lineNumber": 1, + "column": 26, + "message": "Unexpected token await" +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/for-await-of/invalid-with-for-in.src.js b/tests/fixtures/ecma-version/9/for-await-of/invalid-with-for-in.src.js new file mode 100644 index 00000000..6c9f3f04 --- /dev/null +++ b/tests/fixtures/ecma-version/9/for-await-of/invalid-with-for-in.src.js @@ -0,0 +1 @@ +async function f() { for await (x in xs); } \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/for-await-of/valid-in-with-reference.result.js b/tests/fixtures/ecma-version/9/for-await-of/valid-in-with-reference.result.js new file mode 100644 index 00000000..a51b9489 --- /dev/null +++ b/tests/fixtures/ecma-version/9/for-await-of/valid-in-with-reference.result.js @@ -0,0 +1,421 @@ +module.exports = { + "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 43 + } + }, + "range": [ + 0, + 43 + ], + "body": [ + { + "type": "FunctionDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 43 + } + }, + "range": [ + 0, + 43 + ], + "id": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "range": [ + 15, + 16 + ], + "name": "f" + }, + "generator": false, + "expression": false, + "async": true, + "params": [], + "body": { + "type": "BlockStatement", + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 43 + } + }, + "range": [ + 19, + 43 + ], + "body": [ + { + "type": "ForOfStatement", + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 41 + } + }, + "range": [ + 21, + 41 + ], + "await": true, + "left": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "range": [ + 32, + 33 + ], + "name": "x" + }, + "right": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 37 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "range": [ + 37, + 39 + ], + "name": "xs" + }, + "body": { + "type": "EmptyStatement", + "loc": { + "start": { + "line": 1, + "column": 40 + }, + "end": { + "line": 1, + "column": 41 + } + }, + "range": [ + 40, + 41 + ] + } + } + ] + } + } + ], + "sourceType": "script", + "tokens": [ + { + "type": "Identifier", + "value": "async", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "range": [ + 0, + 5 + ] + }, + { + "type": "Keyword", + "value": "function", + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "range": [ + 6, + 14 + ] + }, + { + "type": "Identifier", + "value": "f", + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "range": [ + 15, + 16 + ] + }, + { + "type": "Punctuator", + "value": "(", + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "range": [ + 16, + 17 + ] + }, + { + "type": "Punctuator", + "value": ")", + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "range": [ + 17, + 18 + ] + }, + { + "type": "Punctuator", + "value": "{", + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "range": [ + 19, + 20 + ] + }, + { + "type": "Keyword", + "value": "for", + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "range": [ + 21, + 24 + ] + }, + { + "type": "Identifier", + "value": "await", + "loc": { + "start": { + "line": 1, + "column": 25 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "range": [ + 25, + 30 + ] + }, + { + "type": "Punctuator", + "value": "(", + "loc": { + "start": { + "line": 1, + "column": 31 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "range": [ + 31, + 32 + ] + }, + { + "type": "Identifier", + "value": "x", + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "range": [ + 32, + 33 + ] + }, + { + "type": "Identifier", + "value": "of", + "loc": { + "start": { + "line": 1, + "column": 34 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "range": [ + 34, + 36 + ] + }, + { + "type": "Identifier", + "value": "xs", + "loc": { + "start": { + "line": 1, + "column": 37 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "range": [ + 37, + 39 + ] + }, + { + "type": "Punctuator", + "value": ")", + "loc": { + "start": { + "line": 1, + "column": 39 + }, + "end": { + "line": 1, + "column": 40 + } + }, + "range": [ + 39, + 40 + ] + }, + { + "type": "Punctuator", + "value": ";", + "loc": { + "start": { + "line": 1, + "column": 40 + }, + "end": { + "line": 1, + "column": 41 + } + }, + "range": [ + 40, + 41 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 1, + "column": 42 + }, + "end": { + "line": 1, + "column": 43 + } + }, + "range": [ + 42, + 43 + ] + } + ] +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/for-await-of/valid-in-with-reference.src.js b/tests/fixtures/ecma-version/9/for-await-of/valid-in-with-reference.src.js new file mode 100644 index 00000000..4e72e2a0 --- /dev/null +++ b/tests/fixtures/ecma-version/9/for-await-of/valid-in-with-reference.src.js @@ -0,0 +1 @@ +async function f() { for await (x of xs); } \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/for-await-of/valid-linebreak-before-await.result.js b/tests/fixtures/ecma-version/9/for-await-of/valid-linebreak-before-await.result.js new file mode 100644 index 00000000..e886ebbe --- /dev/null +++ b/tests/fixtures/ecma-version/9/for-await-of/valid-linebreak-before-await.result.js @@ -0,0 +1,421 @@ +module.exports = { + "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 18 + } + }, + "range": [ + 0, + 43 + ], + "body": [ + { + "type": "FunctionDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 18 + } + }, + "range": [ + 0, + 43 + ], + "id": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "range": [ + 15, + 16 + ], + "name": "f" + }, + "generator": false, + "expression": false, + "async": true, + "params": [], + "body": { + "type": "BlockStatement", + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 2, + "column": 18 + } + }, + "range": [ + 19, + 43 + ], + "body": [ + { + "type": "ForOfStatement", + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 2, + "column": 16 + } + }, + "range": [ + 21, + 41 + ], + "await": true, + "left": { + "type": "Identifier", + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 8 + } + }, + "range": [ + 32, + 33 + ], + "name": "x" + }, + "right": { + "type": "Identifier", + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 14 + } + }, + "range": [ + 37, + 39 + ], + "name": "xs" + }, + "body": { + "type": "EmptyStatement", + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 2, + "column": 16 + } + }, + "range": [ + 40, + 41 + ] + } + } + ] + } + } + ], + "sourceType": "script", + "tokens": [ + { + "type": "Identifier", + "value": "async", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "range": [ + 0, + 5 + ] + }, + { + "type": "Keyword", + "value": "function", + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "range": [ + 6, + 14 + ] + }, + { + "type": "Identifier", + "value": "f", + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "range": [ + 15, + 16 + ] + }, + { + "type": "Punctuator", + "value": "(", + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "range": [ + 16, + 17 + ] + }, + { + "type": "Punctuator", + "value": ")", + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "range": [ + 17, + 18 + ] + }, + { + "type": "Punctuator", + "value": "{", + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "range": [ + 19, + 20 + ] + }, + { + "type": "Keyword", + "value": "for", + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "range": [ + 21, + 24 + ] + }, + { + "type": "Identifier", + "value": "await", + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 5 + } + }, + "range": [ + 25, + 30 + ] + }, + { + "type": "Punctuator", + "value": "(", + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 7 + } + }, + "range": [ + 31, + 32 + ] + }, + { + "type": "Identifier", + "value": "x", + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 8 + } + }, + "range": [ + 32, + 33 + ] + }, + { + "type": "Identifier", + "value": "of", + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 11 + } + }, + "range": [ + 34, + 36 + ] + }, + { + "type": "Identifier", + "value": "xs", + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 14 + } + }, + "range": [ + 37, + 39 + ] + }, + { + "type": "Punctuator", + "value": ")", + "loc": { + "start": { + "line": 2, + "column": 14 + }, + "end": { + "line": 2, + "column": 15 + } + }, + "range": [ + 39, + 40 + ] + }, + { + "type": "Punctuator", + "value": ";", + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 2, + "column": 16 + } + }, + "range": [ + 40, + 41 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 2, + "column": 17 + }, + "end": { + "line": 2, + "column": 18 + } + }, + "range": [ + 42, + 43 + ] + } + ] +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/for-await-of/valid-linebreak-before-await.src.js b/tests/fixtures/ecma-version/9/for-await-of/valid-linebreak-before-await.src.js new file mode 100644 index 00000000..982a5e3f --- /dev/null +++ b/tests/fixtures/ecma-version/9/for-await-of/valid-linebreak-before-await.src.js @@ -0,0 +1,2 @@ +async function f() { for +await (x of xs); } \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/for-await-of/valid-no-await-1.result.js b/tests/fixtures/ecma-version/9/for-await-of/valid-no-await-1.result.js new file mode 100644 index 00000000..8b43b83e --- /dev/null +++ b/tests/fixtures/ecma-version/9/for-await-of/valid-no-await-1.result.js @@ -0,0 +1,219 @@ +module.exports = { + "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "range": [ + 0, + 14 + ], + "body": [ + { + "type": "ForOfStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "range": [ + 0, + 14 + ], + "await": false, + "left": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "range": [ + 5, + 6 + ], + "name": "x" + }, + "right": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "range": [ + 10, + 12 + ], + "name": "xs" + }, + "body": { + "type": "EmptyStatement", + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "range": [ + 13, + 14 + ] + } + } + ], + "sourceType": "script", + "tokens": [ + { + "type": "Keyword", + "value": "for", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "range": [ + 0, + 3 + ] + }, + { + "type": "Punctuator", + "value": "(", + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "range": [ + 4, + 5 + ] + }, + { + "type": "Identifier", + "value": "x", + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "range": [ + 5, + 6 + ] + }, + { + "type": "Identifier", + "value": "of", + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "range": [ + 7, + 9 + ] + }, + { + "type": "Identifier", + "value": "xs", + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "range": [ + 10, + 12 + ] + }, + { + "type": "Punctuator", + "value": ")", + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "range": [ + 12, + 13 + ] + }, + { + "type": "Punctuator", + "value": ";", + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "range": [ + 13, + 14 + ] + } + ] +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/for-await-of/valid-no-await-1.src.js b/tests/fixtures/ecma-version/9/for-await-of/valid-no-await-1.src.js new file mode 100644 index 00000000..82c795db --- /dev/null +++ b/tests/fixtures/ecma-version/9/for-await-of/valid-no-await-1.src.js @@ -0,0 +1 @@ +for (x of xs); \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/for-await-of/valid-no-await-2.result.js b/tests/fixtures/ecma-version/9/for-await-of/valid-no-await-2.result.js new file mode 100644 index 00000000..0efea730 --- /dev/null +++ b/tests/fixtures/ecma-version/9/for-await-of/valid-no-await-2.result.js @@ -0,0 +1,218 @@ +module.exports = { + "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "range": [ + 0, + 14 + ], + "body": [ + { + "type": "ForInStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "range": [ + 0, + 14 + ], + "left": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "range": [ + 5, + 6 + ], + "name": "x" + }, + "right": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "range": [ + 10, + 12 + ], + "name": "xs" + }, + "body": { + "type": "EmptyStatement", + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "range": [ + 13, + 14 + ] + } + } + ], + "sourceType": "script", + "tokens": [ + { + "type": "Keyword", + "value": "for", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "range": [ + 0, + 3 + ] + }, + { + "type": "Punctuator", + "value": "(", + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "range": [ + 4, + 5 + ] + }, + { + "type": "Identifier", + "value": "x", + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "range": [ + 5, + 6 + ] + }, + { + "type": "Keyword", + "value": "in", + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "range": [ + 7, + 9 + ] + }, + { + "type": "Identifier", + "value": "xs", + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "range": [ + 10, + 12 + ] + }, + { + "type": "Punctuator", + "value": ")", + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "range": [ + 12, + 13 + ] + }, + { + "type": "Punctuator", + "value": ";", + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "range": [ + 13, + 14 + ] + } + ] +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/for-await-of/valid-no-await-2.src.js b/tests/fixtures/ecma-version/9/for-await-of/valid-no-await-2.src.js new file mode 100644 index 00000000..64ead41a --- /dev/null +++ b/tests/fixtures/ecma-version/9/for-await-of/valid-no-await-2.src.js @@ -0,0 +1 @@ +for (x in xs); \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/for-await-of/valid-with-async-arrow-function.result.js b/tests/fixtures/ecma-version/9/for-await-of/valid-with-async-arrow-function.result.js new file mode 100644 index 00000000..534cdffa --- /dev/null +++ b/tests/fixtures/ecma-version/9/for-await-of/valid-with-async-arrow-function.result.js @@ -0,0 +1,475 @@ +module.exports = { + "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "range": [ + 0, + 39 + ], + "body": [ + { + "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "range": [ + 0, + 39 + ], + "expression": { + "type": "AssignmentExpression", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "range": [ + 0, + 39 + ], + "operator": "=", + "left": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 1 + } + }, + "range": [ + 0, + 1 + ], + "name": "f" + }, + "right": { + "type": "ArrowFunctionExpression", + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "range": [ + 4, + 39 + ], + "id": null, + "generator": false, + "expression": false, + "async": true, + "params": [], + "body": { + "type": "BlockStatement", + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "range": [ + 15, + 39 + ], + "body": [ + { + "type": "ForOfStatement", + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 37 + } + }, + "range": [ + 17, + 37 + ], + "await": true, + "left": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 28 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "range": [ + 28, + 29 + ], + "name": "x" + }, + "right": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 33 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "range": [ + 33, + 35 + ], + "name": "xs" + }, + "body": { + "type": "EmptyStatement", + "loc": { + "start": { + "line": 1, + "column": 36 + }, + "end": { + "line": 1, + "column": 37 + } + }, + "range": [ + 36, + 37 + ] + } + } + ] + } + } + } + } + ], + "sourceType": "script", + "tokens": [ + { + "type": "Identifier", + "value": "f", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 1 + } + }, + "range": [ + 0, + 1 + ] + }, + { + "type": "Punctuator", + "value": "=", + "loc": { + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "range": [ + 2, + 3 + ] + }, + { + "type": "Identifier", + "value": "async", + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "range": [ + 4, + 9 + ] + }, + { + "type": "Punctuator", + "value": "(", + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "range": [ + 9, + 10 + ] + }, + { + "type": "Punctuator", + "value": ")", + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "range": [ + 10, + 11 + ] + }, + { + "type": "Punctuator", + "value": "=>", + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "range": [ + 12, + 14 + ] + }, + { + "type": "Punctuator", + "value": "{", + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "range": [ + 15, + 16 + ] + }, + { + "type": "Keyword", + "value": "for", + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "range": [ + 17, + 20 + ] + }, + { + "type": "Identifier", + "value": "await", + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "range": [ + 21, + 26 + ] + }, + { + "type": "Punctuator", + "value": "(", + "loc": { + "start": { + "line": 1, + "column": 27 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "range": [ + 27, + 28 + ] + }, + { + "type": "Identifier", + "value": "x", + "loc": { + "start": { + "line": 1, + "column": 28 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "range": [ + 28, + 29 + ] + }, + { + "type": "Identifier", + "value": "of", + "loc": { + "start": { + "line": 1, + "column": 30 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "range": [ + 30, + 32 + ] + }, + { + "type": "Identifier", + "value": "xs", + "loc": { + "start": { + "line": 1, + "column": 33 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "range": [ + 33, + 35 + ] + }, + { + "type": "Punctuator", + "value": ")", + "loc": { + "start": { + "line": 1, + "column": 35 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "range": [ + 35, + 36 + ] + }, + { + "type": "Punctuator", + "value": ";", + "loc": { + "start": { + "line": 1, + "column": 36 + }, + "end": { + "line": 1, + "column": 37 + } + }, + "range": [ + 36, + 37 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 1, + "column": 38 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "range": [ + 38, + 39 + ] + } + ] +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/for-await-of/valid-with-async-arrow-function.src.js b/tests/fixtures/ecma-version/9/for-await-of/valid-with-async-arrow-function.src.js new file mode 100644 index 00000000..37e572a9 --- /dev/null +++ b/tests/fixtures/ecma-version/9/for-await-of/valid-with-async-arrow-function.src.js @@ -0,0 +1 @@ +f = async() => { for await (x of xs); } \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/for-await-of/valid-with-async-function-expression.result.js b/tests/fixtures/ecma-version/9/for-await-of/valid-with-async-function-expression.result.js new file mode 100644 index 00000000..8d2d8fce --- /dev/null +++ b/tests/fixtures/ecma-version/9/for-await-of/valid-with-async-function-expression.result.js @@ -0,0 +1,475 @@ +module.exports = { + "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 45 + } + }, + "range": [ + 0, + 45 + ], + "body": [ + { + "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 45 + } + }, + "range": [ + 0, + 45 + ], + "expression": { + "type": "AssignmentExpression", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 45 + } + }, + "range": [ + 0, + 45 + ], + "operator": "=", + "left": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 1 + } + }, + "range": [ + 0, + 1 + ], + "name": "f" + }, + "right": { + "type": "FunctionExpression", + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 45 + } + }, + "range": [ + 4, + 45 + ], + "id": null, + "generator": false, + "expression": false, + "async": true, + "params": [], + "body": { + "type": "BlockStatement", + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 45 + } + }, + "range": [ + 21, + 45 + ], + "body": [ + { + "type": "ForOfStatement", + "loc": { + "start": { + "line": 1, + "column": 23 + }, + "end": { + "line": 1, + "column": 43 + } + }, + "range": [ + 23, + 43 + ], + "await": true, + "left": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 34 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "range": [ + 34, + 35 + ], + "name": "x" + }, + "right": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 39 + }, + "end": { + "line": 1, + "column": 41 + } + }, + "range": [ + 39, + 41 + ], + "name": "xs" + }, + "body": { + "type": "EmptyStatement", + "loc": { + "start": { + "line": 1, + "column": 42 + }, + "end": { + "line": 1, + "column": 43 + } + }, + "range": [ + 42, + 43 + ] + } + } + ] + } + } + } + } + ], + "sourceType": "script", + "tokens": [ + { + "type": "Identifier", + "value": "f", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 1 + } + }, + "range": [ + 0, + 1 + ] + }, + { + "type": "Punctuator", + "value": "=", + "loc": { + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "range": [ + 2, + 3 + ] + }, + { + "type": "Identifier", + "value": "async", + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "range": [ + 4, + 9 + ] + }, + { + "type": "Keyword", + "value": "function", + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "range": [ + 10, + 18 + ] + }, + { + "type": "Punctuator", + "value": "(", + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "range": [ + 18, + 19 + ] + }, + { + "type": "Punctuator", + "value": ")", + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "range": [ + 19, + 20 + ] + }, + { + "type": "Punctuator", + "value": "{", + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "range": [ + 21, + 22 + ] + }, + { + "type": "Keyword", + "value": "for", + "loc": { + "start": { + "line": 1, + "column": 23 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "range": [ + 23, + 26 + ] + }, + { + "type": "Identifier", + "value": "await", + "loc": { + "start": { + "line": 1, + "column": 27 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "range": [ + 27, + 32 + ] + }, + { + "type": "Punctuator", + "value": "(", + "loc": { + "start": { + "line": 1, + "column": 33 + }, + "end": { + "line": 1, + "column": 34 + } + }, + "range": [ + 33, + 34 + ] + }, + { + "type": "Identifier", + "value": "x", + "loc": { + "start": { + "line": 1, + "column": 34 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "range": [ + 34, + 35 + ] + }, + { + "type": "Identifier", + "value": "of", + "loc": { + "start": { + "line": 1, + "column": 36 + }, + "end": { + "line": 1, + "column": 38 + } + }, + "range": [ + 36, + 38 + ] + }, + { + "type": "Identifier", + "value": "xs", + "loc": { + "start": { + "line": 1, + "column": 39 + }, + "end": { + "line": 1, + "column": 41 + } + }, + "range": [ + 39, + 41 + ] + }, + { + "type": "Punctuator", + "value": ")", + "loc": { + "start": { + "line": 1, + "column": 41 + }, + "end": { + "line": 1, + "column": 42 + } + }, + "range": [ + 41, + 42 + ] + }, + { + "type": "Punctuator", + "value": ";", + "loc": { + "start": { + "line": 1, + "column": 42 + }, + "end": { + "line": 1, + "column": 43 + } + }, + "range": [ + 42, + 43 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 1, + "column": 44 + }, + "end": { + "line": 1, + "column": 45 + } + }, + "range": [ + 44, + 45 + ] + } + ] +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/for-await-of/valid-with-async-function-expression.src.js b/tests/fixtures/ecma-version/9/for-await-of/valid-with-async-function-expression.src.js new file mode 100644 index 00000000..9596d5ea --- /dev/null +++ b/tests/fixtures/ecma-version/9/for-await-of/valid-with-async-function-expression.src.js @@ -0,0 +1 @@ +f = async function() { for await (x of xs); } \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/for-await-of/valid-with-async-method-1.result.js b/tests/fixtures/ecma-version/9/for-await-of/valid-with-async-method-1.result.js new file mode 100644 index 00000000..a891b41f --- /dev/null +++ b/tests/fixtures/ecma-version/9/for-await-of/valid-with-async-method-1.result.js @@ -0,0 +1,569 @@ +module.exports = { + "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 44 + } + }, + "range": [ + 0, + 44 + ], + "body": [ + { + "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 44 + } + }, + "range": [ + 0, + 44 + ], + "expression": { + "type": "AssignmentExpression", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 44 + } + }, + "range": [ + 0, + 44 + ], + "operator": "=", + "left": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "range": [ + 0, + 3 + ], + "name": "obj" + }, + "right": { + "type": "ObjectExpression", + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 44 + } + }, + "range": [ + 6, + 44 + ], + "properties": [ + { + "type": "Property", + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 42 + } + }, + "range": [ + 8, + 42 + ], + "method": true, + "shorthand": false, + "computed": false, + "key": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "range": [ + 14, + 15 + ], + "name": "f" + }, + "kind": "init", + "value": { + "type": "FunctionExpression", + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 42 + } + }, + "range": [ + 15, + 42 + ], + "id": null, + "generator": false, + "expression": false, + "async": true, + "params": [], + "body": { + "type": "BlockStatement", + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 42 + } + }, + "range": [ + 18, + 42 + ], + "body": [ + { + "type": "ForOfStatement", + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 40 + } + }, + "range": [ + 20, + 40 + ], + "await": true, + "left": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 31 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "range": [ + 31, + 32 + ], + "name": "x" + }, + "right": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 36 + }, + "end": { + "line": 1, + "column": 38 + } + }, + "range": [ + 36, + 38 + ], + "name": "xs" + }, + "body": { + "type": "EmptyStatement", + "loc": { + "start": { + "line": 1, + "column": 39 + }, + "end": { + "line": 1, + "column": 40 + } + }, + "range": [ + 39, + 40 + ] + } + } + ] + } + } + } + ] + } + } + } + ], + "sourceType": "script", + "tokens": [ + { + "type": "Identifier", + "value": "obj", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "range": [ + 0, + 3 + ] + }, + { + "type": "Punctuator", + "value": "=", + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "range": [ + 4, + 5 + ] + }, + { + "type": "Punctuator", + "value": "{", + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "range": [ + 6, + 7 + ] + }, + { + "type": "Identifier", + "value": "async", + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "range": [ + 8, + 13 + ] + }, + { + "type": "Identifier", + "value": "f", + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "range": [ + 14, + 15 + ] + }, + { + "type": "Punctuator", + "value": "(", + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "range": [ + 15, + 16 + ] + }, + { + "type": "Punctuator", + "value": ")", + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "range": [ + 16, + 17 + ] + }, + { + "type": "Punctuator", + "value": "{", + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "range": [ + 18, + 19 + ] + }, + { + "type": "Keyword", + "value": "for", + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "range": [ + 20, + 23 + ] + }, + { + "type": "Identifier", + "value": "await", + "loc": { + "start": { + "line": 1, + "column": 24 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "range": [ + 24, + 29 + ] + }, + { + "type": "Punctuator", + "value": "(", + "loc": { + "start": { + "line": 1, + "column": 30 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "range": [ + 30, + 31 + ] + }, + { + "type": "Identifier", + "value": "x", + "loc": { + "start": { + "line": 1, + "column": 31 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "range": [ + 31, + 32 + ] + }, + { + "type": "Identifier", + "value": "of", + "loc": { + "start": { + "line": 1, + "column": 33 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "range": [ + 33, + 35 + ] + }, + { + "type": "Identifier", + "value": "xs", + "loc": { + "start": { + "line": 1, + "column": 36 + }, + "end": { + "line": 1, + "column": 38 + } + }, + "range": [ + 36, + 38 + ] + }, + { + "type": "Punctuator", + "value": ")", + "loc": { + "start": { + "line": 1, + "column": 38 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "range": [ + 38, + 39 + ] + }, + { + "type": "Punctuator", + "value": ";", + "loc": { + "start": { + "line": 1, + "column": 39 + }, + "end": { + "line": 1, + "column": 40 + } + }, + "range": [ + 39, + 40 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 1, + "column": 41 + }, + "end": { + "line": 1, + "column": 42 + } + }, + "range": [ + 41, + 42 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 1, + "column": 43 + }, + "end": { + "line": 1, + "column": 44 + } + }, + "range": [ + 43, + 44 + ] + } + ] +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/for-await-of/valid-with-async-method-1.src.js b/tests/fixtures/ecma-version/9/for-await-of/valid-with-async-method-1.src.js new file mode 100644 index 00000000..59355143 --- /dev/null +++ b/tests/fixtures/ecma-version/9/for-await-of/valid-with-async-method-1.src.js @@ -0,0 +1 @@ +obj = { async f() { for await (x of xs); } } \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/for-await-of/valid-with-async-method-2.result.js b/tests/fixtures/ecma-version/9/for-await-of/valid-with-async-method-2.result.js new file mode 100644 index 00000000..7e5d52f6 --- /dev/null +++ b/tests/fixtures/ecma-version/9/for-await-of/valid-with-async-method-2.result.js @@ -0,0 +1,551 @@ +module.exports = { + "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 46 + } + }, + "range": [ + 0, + 46 + ], + "body": [ + { + "type": "ClassDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 46 + } + }, + "range": [ + 0, + 46 + ], + "id": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "range": [ + 6, + 7 + ], + "name": "A" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 46 + } + }, + "range": [ + 8, + 46 + ], + "body": [ + { + "type": "MethodDefinition", + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 44 + } + }, + "range": [ + 10, + 44 + ], + "kind": "method", + "static": false, + "computed": false, + "key": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "range": [ + 16, + 17 + ], + "name": "f" + }, + "value": { + "type": "FunctionExpression", + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 44 + } + }, + "range": [ + 17, + 44 + ], + "id": null, + "generator": false, + "expression": false, + "async": true, + "params": [], + "body": { + "type": "BlockStatement", + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 44 + } + }, + "range": [ + 20, + 44 + ], + "body": [ + { + "type": "ForOfStatement", + "loc": { + "start": { + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 42 + } + }, + "range": [ + 22, + 42 + ], + "await": true, + "left": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 33 + }, + "end": { + "line": 1, + "column": 34 + } + }, + "range": [ + 33, + 34 + ], + "name": "x" + }, + "right": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 38 + }, + "end": { + "line": 1, + "column": 40 + } + }, + "range": [ + 38, + 40 + ], + "name": "xs" + }, + "body": { + "type": "EmptyStatement", + "loc": { + "start": { + "line": 1, + "column": 41 + }, + "end": { + "line": 1, + "column": 42 + } + }, + "range": [ + 41, + 42 + ] + } + } + ] + } + } + } + ] + } + } + ], + "sourceType": "script", + "tokens": [ + { + "type": "Keyword", + "value": "class", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "range": [ + 0, + 5 + ] + }, + { + "type": "Identifier", + "value": "A", + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "range": [ + 6, + 7 + ] + }, + { + "type": "Punctuator", + "value": "{", + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "range": [ + 8, + 9 + ] + }, + { + "type": "Identifier", + "value": "async", + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "range": [ + 10, + 15 + ] + }, + { + "type": "Identifier", + "value": "f", + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "range": [ + 16, + 17 + ] + }, + { + "type": "Punctuator", + "value": "(", + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "range": [ + 17, + 18 + ] + }, + { + "type": "Punctuator", + "value": ")", + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "range": [ + 18, + 19 + ] + }, + { + "type": "Punctuator", + "value": "{", + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "range": [ + 20, + 21 + ] + }, + { + "type": "Keyword", + "value": "for", + "loc": { + "start": { + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "range": [ + 22, + 25 + ] + }, + { + "type": "Identifier", + "value": "await", + "loc": { + "start": { + "line": 1, + "column": 26 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "range": [ + 26, + 31 + ] + }, + { + "type": "Punctuator", + "value": "(", + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "range": [ + 32, + 33 + ] + }, + { + "type": "Identifier", + "value": "x", + "loc": { + "start": { + "line": 1, + "column": 33 + }, + "end": { + "line": 1, + "column": 34 + } + }, + "range": [ + 33, + 34 + ] + }, + { + "type": "Identifier", + "value": "of", + "loc": { + "start": { + "line": 1, + "column": 35 + }, + "end": { + "line": 1, + "column": 37 + } + }, + "range": [ + 35, + 37 + ] + }, + { + "type": "Identifier", + "value": "xs", + "loc": { + "start": { + "line": 1, + "column": 38 + }, + "end": { + "line": 1, + "column": 40 + } + }, + "range": [ + 38, + 40 + ] + }, + { + "type": "Punctuator", + "value": ")", + "loc": { + "start": { + "line": 1, + "column": 40 + }, + "end": { + "line": 1, + "column": 41 + } + }, + "range": [ + 40, + 41 + ] + }, + { + "type": "Punctuator", + "value": ";", + "loc": { + "start": { + "line": 1, + "column": 41 + }, + "end": { + "line": 1, + "column": 42 + } + }, + "range": [ + 41, + 42 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 1, + "column": 43 + }, + "end": { + "line": 1, + "column": 44 + } + }, + "range": [ + 43, + 44 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 1, + "column": 45 + }, + "end": { + "line": 1, + "column": 46 + } + }, + "range": [ + 45, + 46 + ] + } + ] +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/for-await-of/valid-with-async-method-2.src.js b/tests/fixtures/ecma-version/9/for-await-of/valid-with-async-method-2.src.js new file mode 100644 index 00000000..c34b1380 --- /dev/null +++ b/tests/fixtures/ecma-version/9/for-await-of/valid-with-async-method-2.src.js @@ -0,0 +1 @@ +class A { async f() { for await (x of xs); } } \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/for-await-of/valid-with-let.result.js b/tests/fixtures/ecma-version/9/for-await-of/valid-with-let.result.js new file mode 100644 index 00000000..3de22305 --- /dev/null +++ b/tests/fixtures/ecma-version/9/for-await-of/valid-with-let.result.js @@ -0,0 +1,477 @@ +module.exports = { + "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 47 + } + }, + "range": [ + 0, + 47 + ], + "body": [ + { + "type": "FunctionDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 47 + } + }, + "range": [ + 0, + 47 + ], + "id": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "range": [ + 15, + 16 + ], + "name": "f" + }, + "generator": false, + "expression": false, + "async": true, + "params": [], + "body": { + "type": "BlockStatement", + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 47 + } + }, + "range": [ + 19, + 47 + ], + "body": [ + { + "type": "ForOfStatement", + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 45 + } + }, + "range": [ + 21, + 45 + ], + "await": true, + "left": { + "type": "VariableDeclaration", + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 37 + } + }, + "range": [ + 32, + 37 + ], + "declarations": [ + { + "type": "VariableDeclarator", + "loc": { + "start": { + "line": 1, + "column": 36 + }, + "end": { + "line": 1, + "column": 37 + } + }, + "range": [ + 36, + 37 + ], + "id": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 36 + }, + "end": { + "line": 1, + "column": 37 + } + }, + "range": [ + 36, + 37 + ], + "name": "x" + }, + "init": null + } + ], + "kind": "let" + }, + "right": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 41 + }, + "end": { + "line": 1, + "column": 43 + } + }, + "range": [ + 41, + 43 + ], + "name": "xs" + }, + "body": { + "type": "EmptyStatement", + "loc": { + "start": { + "line": 1, + "column": 44 + }, + "end": { + "line": 1, + "column": 45 + } + }, + "range": [ + 44, + 45 + ] + } + } + ] + } + } + ], + "sourceType": "script", + "tokens": [ + { + "type": "Identifier", + "value": "async", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "range": [ + 0, + 5 + ] + }, + { + "type": "Keyword", + "value": "function", + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "range": [ + 6, + 14 + ] + }, + { + "type": "Identifier", + "value": "f", + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "range": [ + 15, + 16 + ] + }, + { + "type": "Punctuator", + "value": "(", + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "range": [ + 16, + 17 + ] + }, + { + "type": "Punctuator", + "value": ")", + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "range": [ + 17, + 18 + ] + }, + { + "type": "Punctuator", + "value": "{", + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "range": [ + 19, + 20 + ] + }, + { + "type": "Keyword", + "value": "for", + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "range": [ + 21, + 24 + ] + }, + { + "type": "Identifier", + "value": "await", + "loc": { + "start": { + "line": 1, + "column": 25 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "range": [ + 25, + 30 + ] + }, + { + "type": "Punctuator", + "value": "(", + "loc": { + "start": { + "line": 1, + "column": 31 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "range": [ + 31, + 32 + ] + }, + { + "type": "Keyword", + "value": "let", + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "range": [ + 32, + 35 + ] + }, + { + "type": "Identifier", + "value": "x", + "loc": { + "start": { + "line": 1, + "column": 36 + }, + "end": { + "line": 1, + "column": 37 + } + }, + "range": [ + 36, + 37 + ] + }, + { + "type": "Identifier", + "value": "of", + "loc": { + "start": { + "line": 1, + "column": 38 + }, + "end": { + "line": 1, + "column": 40 + } + }, + "range": [ + 38, + 40 + ] + }, + { + "type": "Identifier", + "value": "xs", + "loc": { + "start": { + "line": 1, + "column": 41 + }, + "end": { + "line": 1, + "column": 43 + } + }, + "range": [ + 41, + 43 + ] + }, + { + "type": "Punctuator", + "value": ")", + "loc": { + "start": { + "line": 1, + "column": 43 + }, + "end": { + "line": 1, + "column": 44 + } + }, + "range": [ + 43, + 44 + ] + }, + { + "type": "Punctuator", + "value": ";", + "loc": { + "start": { + "line": 1, + "column": 44 + }, + "end": { + "line": 1, + "column": 45 + } + }, + "range": [ + 44, + 45 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 1, + "column": 46 + }, + "end": { + "line": 1, + "column": 47 + } + }, + "range": [ + 46, + 47 + ] + } + ] +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/for-await-of/valid-with-let.src.js b/tests/fixtures/ecma-version/9/for-await-of/valid-with-let.src.js new file mode 100644 index 00000000..1769ebff --- /dev/null +++ b/tests/fixtures/ecma-version/9/for-await-of/valid-with-let.src.js @@ -0,0 +1 @@ +async function f() { for await (let x of xs); } \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/for-await-of/valid-with-var.result.js b/tests/fixtures/ecma-version/9/for-await-of/valid-with-var.result.js new file mode 100644 index 00000000..442d3c9b --- /dev/null +++ b/tests/fixtures/ecma-version/9/for-await-of/valid-with-var.result.js @@ -0,0 +1,477 @@ +module.exports = { + "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 47 + } + }, + "range": [ + 0, + 47 + ], + "body": [ + { + "type": "FunctionDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 47 + } + }, + "range": [ + 0, + 47 + ], + "id": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "range": [ + 15, + 16 + ], + "name": "f" + }, + "generator": false, + "expression": false, + "async": true, + "params": [], + "body": { + "type": "BlockStatement", + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 47 + } + }, + "range": [ + 19, + 47 + ], + "body": [ + { + "type": "ForOfStatement", + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 45 + } + }, + "range": [ + 21, + 45 + ], + "await": true, + "left": { + "type": "VariableDeclaration", + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 37 + } + }, + "range": [ + 32, + 37 + ], + "declarations": [ + { + "type": "VariableDeclarator", + "loc": { + "start": { + "line": 1, + "column": 36 + }, + "end": { + "line": 1, + "column": 37 + } + }, + "range": [ + 36, + 37 + ], + "id": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 36 + }, + "end": { + "line": 1, + "column": 37 + } + }, + "range": [ + 36, + 37 + ], + "name": "x" + }, + "init": null + } + ], + "kind": "var" + }, + "right": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 41 + }, + "end": { + "line": 1, + "column": 43 + } + }, + "range": [ + 41, + 43 + ], + "name": "xs" + }, + "body": { + "type": "EmptyStatement", + "loc": { + "start": { + "line": 1, + "column": 44 + }, + "end": { + "line": 1, + "column": 45 + } + }, + "range": [ + 44, + 45 + ] + } + } + ] + } + } + ], + "sourceType": "script", + "tokens": [ + { + "type": "Identifier", + "value": "async", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "range": [ + 0, + 5 + ] + }, + { + "type": "Keyword", + "value": "function", + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "range": [ + 6, + 14 + ] + }, + { + "type": "Identifier", + "value": "f", + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "range": [ + 15, + 16 + ] + }, + { + "type": "Punctuator", + "value": "(", + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "range": [ + 16, + 17 + ] + }, + { + "type": "Punctuator", + "value": ")", + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "range": [ + 17, + 18 + ] + }, + { + "type": "Punctuator", + "value": "{", + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "range": [ + 19, + 20 + ] + }, + { + "type": "Keyword", + "value": "for", + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "range": [ + 21, + 24 + ] + }, + { + "type": "Identifier", + "value": "await", + "loc": { + "start": { + "line": 1, + "column": 25 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "range": [ + 25, + 30 + ] + }, + { + "type": "Punctuator", + "value": "(", + "loc": { + "start": { + "line": 1, + "column": 31 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "range": [ + 31, + 32 + ] + }, + { + "type": "Keyword", + "value": "var", + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "range": [ + 32, + 35 + ] + }, + { + "type": "Identifier", + "value": "x", + "loc": { + "start": { + "line": 1, + "column": 36 + }, + "end": { + "line": 1, + "column": 37 + } + }, + "range": [ + 36, + 37 + ] + }, + { + "type": "Identifier", + "value": "of", + "loc": { + "start": { + "line": 1, + "column": 38 + }, + "end": { + "line": 1, + "column": 40 + } + }, + "range": [ + 38, + 40 + ] + }, + { + "type": "Identifier", + "value": "xs", + "loc": { + "start": { + "line": 1, + "column": 41 + }, + "end": { + "line": 1, + "column": 43 + } + }, + "range": [ + 41, + 43 + ] + }, + { + "type": "Punctuator", + "value": ")", + "loc": { + "start": { + "line": 1, + "column": 43 + }, + "end": { + "line": 1, + "column": 44 + } + }, + "range": [ + 43, + 44 + ] + }, + { + "type": "Punctuator", + "value": ";", + "loc": { + "start": { + "line": 1, + "column": 44 + }, + "end": { + "line": 1, + "column": 45 + } + }, + "range": [ + 44, + 45 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 1, + "column": 46 + }, + "end": { + "line": 1, + "column": 47 + } + }, + "range": [ + 46, + 47 + ] + } + ] +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/for-await-of/valid-with-var.src.js b/tests/fixtures/ecma-version/9/for-await-of/valid-with-var.src.js new file mode 100644 index 00000000..80add885 --- /dev/null +++ b/tests/fixtures/ecma-version/9/for-await-of/valid-with-var.src.js @@ -0,0 +1 @@ +async function f() { for await (var x of xs); } \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/malformed-template-literal-escape.result.js b/tests/fixtures/ecma-version/9/malformed-template-literal/malformed-template-literal-escape.result.js similarity index 99% rename from tests/fixtures/ecma-version/9/malformed-template-literal-escape.result.js rename to tests/fixtures/ecma-version/9/malformed-template-literal/malformed-template-literal-escape.result.js index 28ddd489..b62bb6c5 100644 --- a/tests/fixtures/ecma-version/9/malformed-template-literal-escape.result.js +++ b/tests/fixtures/ecma-version/9/malformed-template-literal/malformed-template-literal-escape.result.js @@ -149,4 +149,4 @@ module.exports = { ] } ] -} +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/malformed-template-literal-escape.src.js b/tests/fixtures/ecma-version/9/malformed-template-literal/malformed-template-literal-escape.src.js similarity index 100% rename from tests/fixtures/ecma-version/9/malformed-template-literal-escape.src.js rename to tests/fixtures/ecma-version/9/malformed-template-literal/malformed-template-literal-escape.src.js diff --git a/tests/fixtures/ecma-version/9/rest-property/invalid-array-literal-1.result.js b/tests/fixtures/ecma-version/9/rest-property/invalid-array-literal-1.result.js new file mode 100644 index 00000000..b6683de6 --- /dev/null +++ b/tests/fixtures/ecma-version/9/rest-property/invalid-array-literal-1.result.js @@ -0,0 +1,6 @@ +module.exports = { + "index": 8, + "lineNumber": 1, + "column": 9, + "message": "Unexpected token [" +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/rest-property/invalid-array-literal-1.src.js b/tests/fixtures/ecma-version/9/rest-property/invalid-array-literal-1.src.js new file mode 100644 index 00000000..4b6d5d3f --- /dev/null +++ b/tests/fixtures/ecma-version/9/rest-property/invalid-array-literal-1.src.js @@ -0,0 +1 @@ +let {...[a,b]} = foo \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/rest-property/invalid-array-literal-2.result.js b/tests/fixtures/ecma-version/9/rest-property/invalid-array-literal-2.result.js new file mode 100644 index 00000000..28e855c5 --- /dev/null +++ b/tests/fixtures/ecma-version/9/rest-property/invalid-array-literal-2.result.js @@ -0,0 +1,6 @@ +module.exports = { + "index": 5, + "lineNumber": 1, + "column": 6, + "message": "Unexpected token" +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/rest-property/invalid-array-literal-2.src.js b/tests/fixtures/ecma-version/9/rest-property/invalid-array-literal-2.src.js new file mode 100644 index 00000000..716ef3ac --- /dev/null +++ b/tests/fixtures/ecma-version/9/rest-property/invalid-array-literal-2.src.js @@ -0,0 +1 @@ +({...[a,b]} = foo) \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/rest-property/invalid-array-literal-3.result.js b/tests/fixtures/ecma-version/9/rest-property/invalid-array-literal-3.result.js new file mode 100644 index 00000000..28e855c5 --- /dev/null +++ b/tests/fixtures/ecma-version/9/rest-property/invalid-array-literal-3.result.js @@ -0,0 +1,6 @@ +module.exports = { + "index": 5, + "lineNumber": 1, + "column": 6, + "message": "Unexpected token" +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/rest-property/invalid-array-literal-3.src.js b/tests/fixtures/ecma-version/9/rest-property/invalid-array-literal-3.src.js new file mode 100644 index 00000000..89e0c49f --- /dev/null +++ b/tests/fixtures/ecma-version/9/rest-property/invalid-array-literal-3.src.js @@ -0,0 +1 @@ +({...[a,b]}) => {} \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/rest-property/invalid-duo-1.result.js b/tests/fixtures/ecma-version/9/rest-property/invalid-duo-1.result.js new file mode 100644 index 00000000..2b4f6873 --- /dev/null +++ b/tests/fixtures/ecma-version/9/rest-property/invalid-duo-1.result.js @@ -0,0 +1,6 @@ +module.exports = { + "index": 12, + "lineNumber": 1, + "column": 13, + "message": "Comma is not permitted after the rest element" +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/rest-property/invalid-duo-1.src.js b/tests/fixtures/ecma-version/9/rest-property/invalid-duo-1.src.js new file mode 100644 index 00000000..93b6e39f --- /dev/null +++ b/tests/fixtures/ecma-version/9/rest-property/invalid-duo-1.src.js @@ -0,0 +1 @@ +let {...obj1,...obj2} = foo \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/rest-property/invalid-duo-2.result.js b/tests/fixtures/ecma-version/9/rest-property/invalid-duo-2.result.js new file mode 100644 index 00000000..a5a23c22 --- /dev/null +++ b/tests/fixtures/ecma-version/9/rest-property/invalid-duo-2.result.js @@ -0,0 +1,6 @@ +module.exports = { + "index": 9, + "lineNumber": 1, + "column": 10, + "message": "Comma is not permitted after the rest element" +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/rest-property/invalid-duo-2.src.js b/tests/fixtures/ecma-version/9/rest-property/invalid-duo-2.src.js new file mode 100644 index 00000000..a521164d --- /dev/null +++ b/tests/fixtures/ecma-version/9/rest-property/invalid-duo-2.src.js @@ -0,0 +1 @@ +({...obj1,...obj2} = foo) \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/rest-property/invalid-middle-1.result.js b/tests/fixtures/ecma-version/9/rest-property/invalid-middle-1.result.js new file mode 100644 index 00000000..2b4f6873 --- /dev/null +++ b/tests/fixtures/ecma-version/9/rest-property/invalid-middle-1.result.js @@ -0,0 +1,6 @@ +module.exports = { + "index": 12, + "lineNumber": 1, + "column": 13, + "message": "Comma is not permitted after the rest element" +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/rest-property/invalid-middle-1.src.js b/tests/fixtures/ecma-version/9/rest-property/invalid-middle-1.src.js new file mode 100644 index 00000000..16a7b1b4 --- /dev/null +++ b/tests/fixtures/ecma-version/9/rest-property/invalid-middle-1.src.js @@ -0,0 +1 @@ +let {...obj1,a} = foo \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/rest-property/invalid-middle-2.result.js b/tests/fixtures/ecma-version/9/rest-property/invalid-middle-2.result.js new file mode 100644 index 00000000..a5a23c22 --- /dev/null +++ b/tests/fixtures/ecma-version/9/rest-property/invalid-middle-2.result.js @@ -0,0 +1,6 @@ +module.exports = { + "index": 9, + "lineNumber": 1, + "column": 10, + "message": "Comma is not permitted after the rest element" +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/rest-property/invalid-middle-2.src.js b/tests/fixtures/ecma-version/9/rest-property/invalid-middle-2.src.js new file mode 100644 index 00000000..4a6196b9 --- /dev/null +++ b/tests/fixtures/ecma-version/9/rest-property/invalid-middle-2.src.js @@ -0,0 +1 @@ +({...obj1,a} = foo) \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/rest-property/invalid-object-literal-1.result.js b/tests/fixtures/ecma-version/9/rest-property/invalid-object-literal-1.result.js new file mode 100644 index 00000000..49aed28e --- /dev/null +++ b/tests/fixtures/ecma-version/9/rest-property/invalid-object-literal-1.result.js @@ -0,0 +1,6 @@ +module.exports = { + "index": 8, + "lineNumber": 1, + "column": 9, + "message": "Unexpected token {" +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/rest-property/invalid-object-literal-1.src.js b/tests/fixtures/ecma-version/9/rest-property/invalid-object-literal-1.src.js new file mode 100644 index 00000000..dba8c6cb --- /dev/null +++ b/tests/fixtures/ecma-version/9/rest-property/invalid-object-literal-1.src.js @@ -0,0 +1 @@ +let {...{a,b}} = foo \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/rest-property/invalid-object-literal-2.result.js b/tests/fixtures/ecma-version/9/rest-property/invalid-object-literal-2.result.js new file mode 100644 index 00000000..28e855c5 --- /dev/null +++ b/tests/fixtures/ecma-version/9/rest-property/invalid-object-literal-2.result.js @@ -0,0 +1,6 @@ +module.exports = { + "index": 5, + "lineNumber": 1, + "column": 6, + "message": "Unexpected token" +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/rest-property/invalid-object-literal-2.src.js b/tests/fixtures/ecma-version/9/rest-property/invalid-object-literal-2.src.js new file mode 100644 index 00000000..9f1df373 --- /dev/null +++ b/tests/fixtures/ecma-version/9/rest-property/invalid-object-literal-2.src.js @@ -0,0 +1 @@ +({...{a,b}} = foo) \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/rest-property/invalid-object-literal-3.result.js b/tests/fixtures/ecma-version/9/rest-property/invalid-object-literal-3.result.js new file mode 100644 index 00000000..28e855c5 --- /dev/null +++ b/tests/fixtures/ecma-version/9/rest-property/invalid-object-literal-3.result.js @@ -0,0 +1,6 @@ +module.exports = { + "index": 5, + "lineNumber": 1, + "column": 6, + "message": "Unexpected token" +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/rest-property/invalid-object-literal-3.src.js b/tests/fixtures/ecma-version/9/rest-property/invalid-object-literal-3.src.js new file mode 100644 index 00000000..59f35908 --- /dev/null +++ b/tests/fixtures/ecma-version/9/rest-property/invalid-object-literal-3.src.js @@ -0,0 +1 @@ +({...{a,b}}) => {} \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/rest-property/invalid-parenthesized-1.result.js b/tests/fixtures/ecma-version/9/rest-property/invalid-parenthesized-1.result.js new file mode 100644 index 00000000..25a6632c --- /dev/null +++ b/tests/fixtures/ecma-version/9/rest-property/invalid-parenthesized-1.result.js @@ -0,0 +1,6 @@ +module.exports = { + "index": 8, + "lineNumber": 1, + "column": 9, + "message": "Unexpected token (" +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/rest-property/invalid-parenthesized-1.src.js b/tests/fixtures/ecma-version/9/rest-property/invalid-parenthesized-1.src.js new file mode 100644 index 00000000..14f73a33 --- /dev/null +++ b/tests/fixtures/ecma-version/9/rest-property/invalid-parenthesized-1.src.js @@ -0,0 +1 @@ +let {...(obj)} = foo \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/rest-property/invalid-parenthesized-2.result.js b/tests/fixtures/ecma-version/9/rest-property/invalid-parenthesized-2.result.js new file mode 100644 index 00000000..25a6632c --- /dev/null +++ b/tests/fixtures/ecma-version/9/rest-property/invalid-parenthesized-2.result.js @@ -0,0 +1,6 @@ +module.exports = { + "index": 8, + "lineNumber": 1, + "column": 9, + "message": "Unexpected token (" +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/rest-property/invalid-parenthesized-2.src.js b/tests/fixtures/ecma-version/9/rest-property/invalid-parenthesized-2.src.js new file mode 100644 index 00000000..b68ad50a --- /dev/null +++ b/tests/fixtures/ecma-version/9/rest-property/invalid-parenthesized-2.src.js @@ -0,0 +1 @@ +let {...(a,b)} = foo \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/rest-property/invalid-parenthesized-3.result.js b/tests/fixtures/ecma-version/9/rest-property/invalid-parenthesized-3.result.js new file mode 100644 index 00000000..adf58622 --- /dev/null +++ b/tests/fixtures/ecma-version/9/rest-property/invalid-parenthesized-3.result.js @@ -0,0 +1,6 @@ +module.exports = { + "index": 5, + "lineNumber": 1, + "column": 6, + "message": "Parenthesized pattern" +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/rest-property/invalid-parenthesized-3.src.js b/tests/fixtures/ecma-version/9/rest-property/invalid-parenthesized-3.src.js new file mode 100644 index 00000000..3014c2f2 --- /dev/null +++ b/tests/fixtures/ecma-version/9/rest-property/invalid-parenthesized-3.src.js @@ -0,0 +1 @@ +({...(obj)} = foo) \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/rest-property/invalid-parenthesized-4.result.js b/tests/fixtures/ecma-version/9/rest-property/invalid-parenthesized-4.result.js new file mode 100644 index 00000000..adf58622 --- /dev/null +++ b/tests/fixtures/ecma-version/9/rest-property/invalid-parenthesized-4.result.js @@ -0,0 +1,6 @@ +module.exports = { + "index": 5, + "lineNumber": 1, + "column": 6, + "message": "Parenthesized pattern" +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/rest-property/invalid-parenthesized-4.src.js b/tests/fixtures/ecma-version/9/rest-property/invalid-parenthesized-4.src.js new file mode 100644 index 00000000..48dfcd10 --- /dev/null +++ b/tests/fixtures/ecma-version/9/rest-property/invalid-parenthesized-4.src.js @@ -0,0 +1 @@ +({...(a,b)} = foo) \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/rest-property/invalid-parenthesized-5.result.js b/tests/fixtures/ecma-version/9/rest-property/invalid-parenthesized-5.result.js new file mode 100644 index 00000000..adf58622 --- /dev/null +++ b/tests/fixtures/ecma-version/9/rest-property/invalid-parenthesized-5.result.js @@ -0,0 +1,6 @@ +module.exports = { + "index": 5, + "lineNumber": 1, + "column": 6, + "message": "Parenthesized pattern" +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/rest-property/invalid-parenthesized-5.src.js b/tests/fixtures/ecma-version/9/rest-property/invalid-parenthesized-5.src.js new file mode 100644 index 00000000..c742fb7f --- /dev/null +++ b/tests/fixtures/ecma-version/9/rest-property/invalid-parenthesized-5.src.js @@ -0,0 +1 @@ +({...(obj)}) => {} \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/rest-property/invalid-parenthesized-6.result.js b/tests/fixtures/ecma-version/9/rest-property/invalid-parenthesized-6.result.js new file mode 100644 index 00000000..adf58622 --- /dev/null +++ b/tests/fixtures/ecma-version/9/rest-property/invalid-parenthesized-6.result.js @@ -0,0 +1,6 @@ +module.exports = { + "index": 5, + "lineNumber": 1, + "column": 6, + "message": "Parenthesized pattern" +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/rest-property/invalid-parenthesized-6.src.js b/tests/fixtures/ecma-version/9/rest-property/invalid-parenthesized-6.src.js new file mode 100644 index 00000000..8f3ca5fb --- /dev/null +++ b/tests/fixtures/ecma-version/9/rest-property/invalid-parenthesized-6.src.js @@ -0,0 +1 @@ +({...(a,b)}) => {} \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/rest-property/invalid-trailing-comma-1.result.js b/tests/fixtures/ecma-version/9/rest-property/invalid-trailing-comma-1.result.js new file mode 100644 index 00000000..2b4f6873 --- /dev/null +++ b/tests/fixtures/ecma-version/9/rest-property/invalid-trailing-comma-1.result.js @@ -0,0 +1,6 @@ +module.exports = { + "index": 12, + "lineNumber": 1, + "column": 13, + "message": "Comma is not permitted after the rest element" +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/rest-property/invalid-trailing-comma-1.src.js b/tests/fixtures/ecma-version/9/rest-property/invalid-trailing-comma-1.src.js new file mode 100644 index 00000000..c83b3dee --- /dev/null +++ b/tests/fixtures/ecma-version/9/rest-property/invalid-trailing-comma-1.src.js @@ -0,0 +1 @@ +let {...obj1,} = foo \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/rest-property/invalid-trailing-comma-2.result.js b/tests/fixtures/ecma-version/9/rest-property/invalid-trailing-comma-2.result.js new file mode 100644 index 00000000..a5a23c22 --- /dev/null +++ b/tests/fixtures/ecma-version/9/rest-property/invalid-trailing-comma-2.result.js @@ -0,0 +1,6 @@ +module.exports = { + "index": 9, + "lineNumber": 1, + "column": 10, + "message": "Comma is not permitted after the rest element" +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/rest-property/invalid-trailing-comma-2.src.js b/tests/fixtures/ecma-version/9/rest-property/invalid-trailing-comma-2.src.js new file mode 100644 index 00000000..28238e1c --- /dev/null +++ b/tests/fixtures/ecma-version/9/rest-property/invalid-trailing-comma-2.src.js @@ -0,0 +1 @@ +({...obj1,} = foo) \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/rest-property/valid-assignment-1.result.js b/tests/fixtures/ecma-version/9/rest-property/valid-assignment-1.result.js new file mode 100644 index 00000000..b9494631 --- /dev/null +++ b/tests/fixtures/ecma-version/9/rest-property/valid-assignment-1.result.js @@ -0,0 +1,273 @@ +module.exports = { + "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "range": [ + 0, + 16 + ], + "body": [ + { + "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "range": [ + 0, + 16 + ], + "expression": { + "type": "AssignmentExpression", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "range": [ + 1, + 15 + ], + "operator": "=", + "left": { + "type": "ObjectPattern", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "range": [ + 1, + 9 + ], + "properties": [ + { + "type": "RestElement", + "loc": { + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "range": [ + 2, + 8 + ], + "argument": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "range": [ + 5, + 8 + ], + "name": "obj" + } + } + ] + }, + "right": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "range": [ + 12, + 15 + ], + "name": "foo" + } + } + } + ], + "sourceType": "script", + "tokens": [ + { + "type": "Punctuator", + "value": "(", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 1 + } + }, + "range": [ + 0, + 1 + ] + }, + { + "type": "Punctuator", + "value": "{", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 2 + } + }, + "range": [ + 1, + 2 + ] + }, + { + "type": "Punctuator", + "value": "...", + "loc": { + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "range": [ + 2, + 5 + ] + }, + { + "type": "Identifier", + "value": "obj", + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "range": [ + 5, + 8 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "range": [ + 8, + 9 + ] + }, + { + "type": "Punctuator", + "value": "=", + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "range": [ + 10, + 11 + ] + }, + { + "type": "Identifier", + "value": "foo", + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "range": [ + 12, + 15 + ] + }, + { + "type": "Punctuator", + "value": ")", + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "range": [ + 15, + 16 + ] + } + ] +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/rest-property/valid-assignment-1.src.js b/tests/fixtures/ecma-version/9/rest-property/valid-assignment-1.src.js new file mode 100644 index 00000000..4706d5ca --- /dev/null +++ b/tests/fixtures/ecma-version/9/rest-property/valid-assignment-1.src.js @@ -0,0 +1 @@ +({...obj} = foo) \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/rest-property/valid-assignment-2.result.js b/tests/fixtures/ecma-version/9/rest-property/valid-assignment-2.result.js new file mode 100644 index 00000000..7e5c93bc --- /dev/null +++ b/tests/fixtures/ecma-version/9/rest-property/valid-assignment-2.result.js @@ -0,0 +1,366 @@ +module.exports = { + "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "range": [ + 0, + 18 + ], + "body": [ + { + "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "range": [ + 0, + 18 + ], + "expression": { + "type": "AssignmentExpression", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "range": [ + 1, + 17 + ], + "operator": "=", + "left": { + "type": "ObjectPattern", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "range": [ + 1, + 11 + ], + "properties": [ + { + "type": "Property", + "loc": { + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "range": [ + 2, + 3 + ], + "method": false, + "shorthand": true, + "computed": false, + "key": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "range": [ + 2, + 3 + ], + "name": "a" + }, + "kind": "init", + "value": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "range": [ + 2, + 3 + ], + "name": "a" + } + }, + { + "type": "RestElement", + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "range": [ + 4, + 10 + ], + "argument": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "range": [ + 7, + 10 + ], + "name": "obj" + } + } + ] + }, + "right": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "range": [ + 14, + 17 + ], + "name": "foo" + } + } + } + ], + "sourceType": "script", + "tokens": [ + { + "type": "Punctuator", + "value": "(", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 1 + } + }, + "range": [ + 0, + 1 + ] + }, + { + "type": "Punctuator", + "value": "{", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 2 + } + }, + "range": [ + 1, + 2 + ] + }, + { + "type": "Identifier", + "value": "a", + "loc": { + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "range": [ + 2, + 3 + ] + }, + { + "type": "Punctuator", + "value": ",", + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "range": [ + 3, + 4 + ] + }, + { + "type": "Punctuator", + "value": "...", + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "range": [ + 4, + 7 + ] + }, + { + "type": "Identifier", + "value": "obj", + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "range": [ + 7, + 10 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "range": [ + 10, + 11 + ] + }, + { + "type": "Punctuator", + "value": "=", + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "range": [ + 12, + 13 + ] + }, + { + "type": "Identifier", + "value": "foo", + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "range": [ + 14, + 17 + ] + }, + { + "type": "Punctuator", + "value": ")", + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "range": [ + 17, + 18 + ] + } + ] +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/rest-property/valid-assignment-2.src.js b/tests/fixtures/ecma-version/9/rest-property/valid-assignment-2.src.js new file mode 100644 index 00000000..6b460111 --- /dev/null +++ b/tests/fixtures/ecma-version/9/rest-property/valid-assignment-2.src.js @@ -0,0 +1 @@ +({a,...obj} = foo) \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/rest-property/valid-assignment-3.result.js b/tests/fixtures/ecma-version/9/rest-property/valid-assignment-3.result.js new file mode 100644 index 00000000..ed890eb6 --- /dev/null +++ b/tests/fixtures/ecma-version/9/rest-property/valid-assignment-3.result.js @@ -0,0 +1,402 @@ +module.exports = { + "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "range": [ + 0, + 20 + ], + "body": [ + { + "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "range": [ + 0, + 20 + ], + "expression": { + "type": "AssignmentExpression", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "range": [ + 1, + 19 + ], + "operator": "=", + "left": { + "type": "ObjectPattern", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "range": [ + 1, + 13 + ], + "properties": [ + { + "type": "Property", + "loc": { + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "range": [ + 2, + 5 + ], + "method": false, + "shorthand": false, + "computed": false, + "key": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "range": [ + 2, + 3 + ], + "name": "a" + }, + "value": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "range": [ + 4, + 5 + ], + "name": "b" + }, + "kind": "init" + }, + { + "type": "RestElement", + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "range": [ + 6, + 12 + ], + "argument": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "range": [ + 9, + 12 + ], + "name": "obj" + } + } + ] + }, + "right": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "range": [ + 16, + 19 + ], + "name": "foo" + } + } + } + ], + "sourceType": "script", + "tokens": [ + { + "type": "Punctuator", + "value": "(", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 1 + } + }, + "range": [ + 0, + 1 + ] + }, + { + "type": "Punctuator", + "value": "{", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 2 + } + }, + "range": [ + 1, + 2 + ] + }, + { + "type": "Identifier", + "value": "a", + "loc": { + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "range": [ + 2, + 3 + ] + }, + { + "type": "Punctuator", + "value": ":", + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "range": [ + 3, + 4 + ] + }, + { + "type": "Identifier", + "value": "b", + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "range": [ + 4, + 5 + ] + }, + { + "type": "Punctuator", + "value": ",", + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "range": [ + 5, + 6 + ] + }, + { + "type": "Punctuator", + "value": "...", + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "range": [ + 6, + 9 + ] + }, + { + "type": "Identifier", + "value": "obj", + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "range": [ + 9, + 12 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "range": [ + 12, + 13 + ] + }, + { + "type": "Punctuator", + "value": "=", + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "range": [ + 14, + 15 + ] + }, + { + "type": "Identifier", + "value": "foo", + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "range": [ + 16, + 19 + ] + }, + { + "type": "Punctuator", + "value": ")", + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "range": [ + 19, + 20 + ] + } + ] +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/rest-property/valid-assignment-3.src.js b/tests/fixtures/ecma-version/9/rest-property/valid-assignment-3.src.js new file mode 100644 index 00000000..295b4f1a --- /dev/null +++ b/tests/fixtures/ecma-version/9/rest-property/valid-assignment-3.src.js @@ -0,0 +1 @@ +({a:b,...obj} = foo) \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/rest-property/valid-declaration-1.result.js b/tests/fixtures/ecma-version/9/rest-property/valid-declaration-1.result.js new file mode 100644 index 00000000..617f64a2 --- /dev/null +++ b/tests/fixtures/ecma-version/9/rest-property/valid-declaration-1.result.js @@ -0,0 +1,257 @@ +module.exports = { + "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "range": [ + 0, + 18 + ], + "body": [ + { + "type": "VariableDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "range": [ + 0, + 18 + ], + "declarations": [ + { + "type": "VariableDeclarator", + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "range": [ + 4, + 18 + ], + "id": { + "type": "ObjectPattern", + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "range": [ + 4, + 12 + ], + "properties": [ + { + "type": "RestElement", + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "range": [ + 5, + 11 + ], + "argument": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "range": [ + 8, + 11 + ], + "name": "obj" + } + } + ] + }, + "init": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "range": [ + 15, + 18 + ], + "name": "foo" + } + } + ], + "kind": "let" + } + ], + "sourceType": "script", + "tokens": [ + { + "type": "Keyword", + "value": "let", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "range": [ + 0, + 3 + ] + }, + { + "type": "Punctuator", + "value": "{", + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "range": [ + 4, + 5 + ] + }, + { + "type": "Punctuator", + "value": "...", + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "range": [ + 5, + 8 + ] + }, + { + "type": "Identifier", + "value": "obj", + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "range": [ + 8, + 11 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "range": [ + 11, + 12 + ] + }, + { + "type": "Punctuator", + "value": "=", + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "range": [ + 13, + 14 + ] + }, + { + "type": "Identifier", + "value": "foo", + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "range": [ + 15, + 18 + ] + } + ] +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/rest-property/valid-declaration-1.src.js b/tests/fixtures/ecma-version/9/rest-property/valid-declaration-1.src.js new file mode 100644 index 00000000..34e143f4 --- /dev/null +++ b/tests/fixtures/ecma-version/9/rest-property/valid-declaration-1.src.js @@ -0,0 +1 @@ +let {...obj} = foo diff --git a/tests/fixtures/ecma-version/9/rest-property/valid-declaration-2.result.js b/tests/fixtures/ecma-version/9/rest-property/valid-declaration-2.result.js new file mode 100644 index 00000000..52fffa92 --- /dev/null +++ b/tests/fixtures/ecma-version/9/rest-property/valid-declaration-2.result.js @@ -0,0 +1,350 @@ +module.exports = { + "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "range": [ + 0, + 21 + ], + "body": [ + { + "type": "VariableDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "range": [ + 0, + 21 + ], + "declarations": [ + { + "type": "VariableDeclarator", + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "range": [ + 4, + 21 + ], + "id": { + "type": "ObjectPattern", + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "range": [ + 4, + 15 + ], + "properties": [ + { + "type": "Property", + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "range": [ + 5, + 6 + ], + "method": false, + "shorthand": true, + "computed": false, + "key": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "range": [ + 5, + 6 + ], + "name": "a" + }, + "kind": "init", + "value": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "range": [ + 5, + 6 + ], + "name": "a" + } + }, + { + "type": "RestElement", + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "range": [ + 8, + 14 + ], + "argument": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "range": [ + 11, + 14 + ], + "name": "obj" + } + } + ] + }, + "init": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "range": [ + 18, + 21 + ], + "name": "foo" + } + } + ], + "kind": "let" + } + ], + "sourceType": "script", + "tokens": [ + { + "type": "Keyword", + "value": "let", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "range": [ + 0, + 3 + ] + }, + { + "type": "Punctuator", + "value": "{", + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "range": [ + 4, + 5 + ] + }, + { + "type": "Identifier", + "value": "a", + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "range": [ + 5, + 6 + ] + }, + { + "type": "Punctuator", + "value": ",", + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "range": [ + 6, + 7 + ] + }, + { + "type": "Punctuator", + "value": "...", + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "range": [ + 8, + 11 + ] + }, + { + "type": "Identifier", + "value": "obj", + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "range": [ + 11, + 14 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "range": [ + 14, + 15 + ] + }, + { + "type": "Punctuator", + "value": "=", + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "range": [ + 16, + 17 + ] + }, + { + "type": "Identifier", + "value": "foo", + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "range": [ + 18, + 21 + ] + } + ] +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/rest-property/valid-declaration-2.src.js b/tests/fixtures/ecma-version/9/rest-property/valid-declaration-2.src.js new file mode 100644 index 00000000..c8e730e6 --- /dev/null +++ b/tests/fixtures/ecma-version/9/rest-property/valid-declaration-2.src.js @@ -0,0 +1 @@ +let {a, ...obj} = foo diff --git a/tests/fixtures/ecma-version/9/rest-property/valid-declaration-3.result.js b/tests/fixtures/ecma-version/9/rest-property/valid-declaration-3.result.js new file mode 100644 index 00000000..88645dcb --- /dev/null +++ b/tests/fixtures/ecma-version/9/rest-property/valid-declaration-3.result.js @@ -0,0 +1,386 @@ +module.exports = { + "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "range": [ + 0, + 23 + ], + "body": [ + { + "type": "VariableDeclaration", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "range": [ + 0, + 23 + ], + "declarations": [ + { + "type": "VariableDeclarator", + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "range": [ + 4, + 23 + ], + "id": { + "type": "ObjectPattern", + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "range": [ + 4, + 17 + ], + "properties": [ + { + "type": "Property", + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "range": [ + 5, + 8 + ], + "method": false, + "shorthand": false, + "computed": false, + "key": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "range": [ + 5, + 6 + ], + "name": "a" + }, + "value": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "range": [ + 7, + 8 + ], + "name": "b" + }, + "kind": "init" + }, + { + "type": "RestElement", + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "range": [ + 10, + 16 + ], + "argument": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "range": [ + 13, + 16 + ], + "name": "obj" + } + } + ] + }, + "init": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "range": [ + 20, + 23 + ], + "name": "foo" + } + } + ], + "kind": "let" + } + ], + "sourceType": "script", + "tokens": [ + { + "type": "Keyword", + "value": "let", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "range": [ + 0, + 3 + ] + }, + { + "type": "Punctuator", + "value": "{", + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "range": [ + 4, + 5 + ] + }, + { + "type": "Identifier", + "value": "a", + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "range": [ + 5, + 6 + ] + }, + { + "type": "Punctuator", + "value": ":", + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "range": [ + 6, + 7 + ] + }, + { + "type": "Identifier", + "value": "b", + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "range": [ + 7, + 8 + ] + }, + { + "type": "Punctuator", + "value": ",", + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "range": [ + 8, + 9 + ] + }, + { + "type": "Punctuator", + "value": "...", + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "range": [ + 10, + 13 + ] + }, + { + "type": "Identifier", + "value": "obj", + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "range": [ + 13, + 16 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "range": [ + 16, + 17 + ] + }, + { + "type": "Punctuator", + "value": "=", + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "range": [ + 18, + 19 + ] + }, + { + "type": "Identifier", + "value": "foo", + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "range": [ + 20, + 23 + ] + } + ] +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/rest-property/valid-declaration-3.src.js b/tests/fixtures/ecma-version/9/rest-property/valid-declaration-3.src.js new file mode 100644 index 00000000..a574b239 --- /dev/null +++ b/tests/fixtures/ecma-version/9/rest-property/valid-declaration-3.src.js @@ -0,0 +1 @@ +let {a:b, ...obj} = foo diff --git a/tests/fixtures/ecma-version/9/rest-property/valid-parameter-1.result.js b/tests/fixtures/ecma-version/9/rest-property/valid-parameter-1.result.js new file mode 100644 index 00000000..6ac2dd48 --- /dev/null +++ b/tests/fixtures/ecma-version/9/rest-property/valid-parameter-1.result.js @@ -0,0 +1,296 @@ +module.exports = { + "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "range": [ + 0, + 16 + ], + "body": [ + { + "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "range": [ + 0, + 16 + ], + "expression": { + "type": "ArrowFunctionExpression", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "range": [ + 0, + 16 + ], + "id": null, + "generator": false, + "expression": false, + "async": false, + "params": [ + { + "type": "ObjectPattern", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "range": [ + 1, + 9 + ], + "properties": [ + { + "type": "RestElement", + "loc": { + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "range": [ + 2, + 8 + ], + "argument": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "range": [ + 5, + 8 + ], + "name": "obj" + } + } + ] + } + ], + "body": { + "type": "BlockStatement", + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "range": [ + 14, + 16 + ], + "body": [] + } + } + } + ], + "sourceType": "script", + "tokens": [ + { + "type": "Punctuator", + "value": "(", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 1 + } + }, + "range": [ + 0, + 1 + ] + }, + { + "type": "Punctuator", + "value": "{", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 2 + } + }, + "range": [ + 1, + 2 + ] + }, + { + "type": "Punctuator", + "value": "...", + "loc": { + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "range": [ + 2, + 5 + ] + }, + { + "type": "Identifier", + "value": "obj", + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "range": [ + 5, + 8 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "range": [ + 8, + 9 + ] + }, + { + "type": "Punctuator", + "value": ")", + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "range": [ + 9, + 10 + ] + }, + { + "type": "Punctuator", + "value": "=>", + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "range": [ + 11, + 13 + ] + }, + { + "type": "Punctuator", + "value": "{", + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "range": [ + 14, + 15 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "range": [ + 15, + 16 + ] + } + ] +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/rest-property/valid-parameter-1.src.js b/tests/fixtures/ecma-version/9/rest-property/valid-parameter-1.src.js new file mode 100644 index 00000000..16f69e75 --- /dev/null +++ b/tests/fixtures/ecma-version/9/rest-property/valid-parameter-1.src.js @@ -0,0 +1 @@ +({...obj}) => {} \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/rest-property/valid-parameter-2.result.js b/tests/fixtures/ecma-version/9/rest-property/valid-parameter-2.result.js new file mode 100644 index 00000000..02cee422 --- /dev/null +++ b/tests/fixtures/ecma-version/9/rest-property/valid-parameter-2.result.js @@ -0,0 +1,385 @@ +module.exports = { + "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "range": [ + 0, + 21 + ], + "body": [ + { + "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "range": [ + 0, + 21 + ], + "expression": { + "type": "ArrowFunctionExpression", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "range": [ + 0, + 21 + ], + "id": null, + "generator": false, + "expression": false, + "async": false, + "params": [ + { + "type": "AssignmentPattern", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "range": [ + 1, + 14 + ], + "left": { + "type": "ObjectPattern", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "range": [ + 1, + 9 + ], + "properties": [ + { + "type": "RestElement", + "loc": { + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "range": [ + 2, + 8 + ], + "argument": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "range": [ + 5, + 8 + ], + "name": "obj" + } + } + ] + }, + "right": { + "type": "ObjectExpression", + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "range": [ + 12, + 14 + ], + "properties": [] + } + } + ], + "body": { + "type": "BlockStatement", + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "range": [ + 19, + 21 + ], + "body": [] + } + } + } + ], + "sourceType": "script", + "tokens": [ + { + "type": "Punctuator", + "value": "(", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 1 + } + }, + "range": [ + 0, + 1 + ] + }, + { + "type": "Punctuator", + "value": "{", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 2 + } + }, + "range": [ + 1, + 2 + ] + }, + { + "type": "Punctuator", + "value": "...", + "loc": { + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "range": [ + 2, + 5 + ] + }, + { + "type": "Identifier", + "value": "obj", + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "range": [ + 5, + 8 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "range": [ + 8, + 9 + ] + }, + { + "type": "Punctuator", + "value": "=", + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "range": [ + 10, + 11 + ] + }, + { + "type": "Punctuator", + "value": "{", + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "range": [ + 12, + 13 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "range": [ + 13, + 14 + ] + }, + { + "type": "Punctuator", + "value": ")", + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "range": [ + 14, + 15 + ] + }, + { + "type": "Punctuator", + "value": "=>", + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "range": [ + 16, + 18 + ] + }, + { + "type": "Punctuator", + "value": "{", + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "range": [ + 19, + 20 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "range": [ + 20, + 21 + ] + } + ] +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/rest-property/valid-parameter-2.src.js b/tests/fixtures/ecma-version/9/rest-property/valid-parameter-2.src.js new file mode 100644 index 00000000..29c777ff --- /dev/null +++ b/tests/fixtures/ecma-version/9/rest-property/valid-parameter-2.src.js @@ -0,0 +1 @@ +({...obj} = {}) => {} \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/rest-property/valid-parameter-3.result.js b/tests/fixtures/ecma-version/9/rest-property/valid-parameter-3.result.js new file mode 100644 index 00000000..4f68e7d5 --- /dev/null +++ b/tests/fixtures/ecma-version/9/rest-property/valid-parameter-3.result.js @@ -0,0 +1,389 @@ +module.exports = { + "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "range": [ + 0, + 18 + ], + "body": [ + { + "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "range": [ + 0, + 18 + ], + "expression": { + "type": "ArrowFunctionExpression", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "range": [ + 0, + 18 + ], + "id": null, + "generator": false, + "expression": false, + "async": false, + "params": [ + { + "type": "ObjectPattern", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "range": [ + 1, + 11 + ], + "properties": [ + { + "type": "Property", + "loc": { + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "range": [ + 2, + 3 + ], + "method": false, + "shorthand": true, + "computed": false, + "key": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "range": [ + 2, + 3 + ], + "name": "a" + }, + "kind": "init", + "value": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "range": [ + 2, + 3 + ], + "name": "a" + } + }, + { + "type": "RestElement", + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "range": [ + 4, + 10 + ], + "argument": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "range": [ + 7, + 10 + ], + "name": "obj" + } + } + ] + } + ], + "body": { + "type": "BlockStatement", + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "range": [ + 16, + 18 + ], + "body": [] + } + } + } + ], + "sourceType": "script", + "tokens": [ + { + "type": "Punctuator", + "value": "(", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 1 + } + }, + "range": [ + 0, + 1 + ] + }, + { + "type": "Punctuator", + "value": "{", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 2 + } + }, + "range": [ + 1, + 2 + ] + }, + { + "type": "Identifier", + "value": "a", + "loc": { + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "range": [ + 2, + 3 + ] + }, + { + "type": "Punctuator", + "value": ",", + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "range": [ + 3, + 4 + ] + }, + { + "type": "Punctuator", + "value": "...", + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "range": [ + 4, + 7 + ] + }, + { + "type": "Identifier", + "value": "obj", + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "range": [ + 7, + 10 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "range": [ + 10, + 11 + ] + }, + { + "type": "Punctuator", + "value": ")", + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "range": [ + 11, + 12 + ] + }, + { + "type": "Punctuator", + "value": "=>", + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "range": [ + 13, + 15 + ] + }, + { + "type": "Punctuator", + "value": "{", + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "range": [ + 16, + 17 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "range": [ + 17, + 18 + ] + } + ] +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/rest-property/valid-parameter-3.src.js b/tests/fixtures/ecma-version/9/rest-property/valid-parameter-3.src.js new file mode 100644 index 00000000..dfea07f4 --- /dev/null +++ b/tests/fixtures/ecma-version/9/rest-property/valid-parameter-3.src.js @@ -0,0 +1 @@ +({a,...obj}) => {} \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/rest-property/valid-parameter-4.result.js b/tests/fixtures/ecma-version/9/rest-property/valid-parameter-4.result.js new file mode 100644 index 00000000..661f7df8 --- /dev/null +++ b/tests/fixtures/ecma-version/9/rest-property/valid-parameter-4.result.js @@ -0,0 +1,425 @@ +module.exports = { + "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "range": [ + 0, + 20 + ], + "body": [ + { + "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "range": [ + 0, + 20 + ], + "expression": { + "type": "ArrowFunctionExpression", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "range": [ + 0, + 20 + ], + "id": null, + "generator": false, + "expression": false, + "async": false, + "params": [ + { + "type": "ObjectPattern", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "range": [ + 1, + 13 + ], + "properties": [ + { + "type": "Property", + "loc": { + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "range": [ + 2, + 5 + ], + "method": false, + "shorthand": false, + "computed": false, + "key": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "range": [ + 2, + 3 + ], + "name": "a" + }, + "value": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "range": [ + 4, + 5 + ], + "name": "b" + }, + "kind": "init" + }, + { + "type": "RestElement", + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "range": [ + 6, + 12 + ], + "argument": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "range": [ + 9, + 12 + ], + "name": "obj" + } + } + ] + } + ], + "body": { + "type": "BlockStatement", + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "range": [ + 18, + 20 + ], + "body": [] + } + } + } + ], + "sourceType": "script", + "tokens": [ + { + "type": "Punctuator", + "value": "(", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 1 + } + }, + "range": [ + 0, + 1 + ] + }, + { + "type": "Punctuator", + "value": "{", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 2 + } + }, + "range": [ + 1, + 2 + ] + }, + { + "type": "Identifier", + "value": "a", + "loc": { + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "range": [ + 2, + 3 + ] + }, + { + "type": "Punctuator", + "value": ":", + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "range": [ + 3, + 4 + ] + }, + { + "type": "Identifier", + "value": "b", + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "range": [ + 4, + 5 + ] + }, + { + "type": "Punctuator", + "value": ",", + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "range": [ + 5, + 6 + ] + }, + { + "type": "Punctuator", + "value": "...", + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "range": [ + 6, + 9 + ] + }, + { + "type": "Identifier", + "value": "obj", + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "range": [ + 9, + 12 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "range": [ + 12, + 13 + ] + }, + { + "type": "Punctuator", + "value": ")", + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "range": [ + 13, + 14 + ] + }, + { + "type": "Punctuator", + "value": "=>", + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "range": [ + 15, + 17 + ] + }, + { + "type": "Punctuator", + "value": "{", + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "range": [ + 18, + 19 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "range": [ + 19, + 20 + ] + } + ] +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/rest-property/valid-parameter-4.src.js b/tests/fixtures/ecma-version/9/rest-property/valid-parameter-4.src.js new file mode 100644 index 00000000..47b59880 --- /dev/null +++ b/tests/fixtures/ecma-version/9/rest-property/valid-parameter-4.src.js @@ -0,0 +1 @@ +({a:b,...obj}) => {} \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/spread-property/invalid-dots.result.js b/tests/fixtures/ecma-version/9/spread-property/invalid-dots.result.js new file mode 100644 index 00000000..f7180132 --- /dev/null +++ b/tests/fixtures/ecma-version/9/spread-property/invalid-dots.result.js @@ -0,0 +1,6 @@ +module.exports = { + "index": 5, + "lineNumber": 1, + "column": 6, + "message": "Unexpected token }" +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/spread-property/invalid-dots.src.js b/tests/fixtures/ecma-version/9/spread-property/invalid-dots.src.js new file mode 100644 index 00000000..6820f924 --- /dev/null +++ b/tests/fixtures/ecma-version/9/spread-property/invalid-dots.src.js @@ -0,0 +1 @@ +({...}) \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/spread-property/valid-1.result.js b/tests/fixtures/ecma-version/9/spread-property/valid-1.result.js new file mode 100644 index 00000000..4d29adc6 --- /dev/null +++ b/tests/fixtures/ecma-version/9/spread-property/valid-1.result.js @@ -0,0 +1,201 @@ +module.exports = { + "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "range": [ + 0, + 10 + ], + "body": [ + { + "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "range": [ + 0, + 10 + ], + "expression": { + "type": "ObjectExpression", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "range": [ + 1, + 9 + ], + "properties": [ + { + "type": "SpreadElement", + "loc": { + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "range": [ + 2, + 8 + ], + "argument": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "range": [ + 5, + 8 + ], + "name": "obj" + } + } + ] + } + } + ], + "sourceType": "script", + "tokens": [ + { + "type": "Punctuator", + "value": "(", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 1 + } + }, + "range": [ + 0, + 1 + ] + }, + { + "type": "Punctuator", + "value": "{", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 2 + } + }, + "range": [ + 1, + 2 + ] + }, + { + "type": "Punctuator", + "value": "...", + "loc": { + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "range": [ + 2, + 5 + ] + }, + { + "type": "Identifier", + "value": "obj", + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "range": [ + 5, + 8 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "range": [ + 8, + 9 + ] + }, + { + "type": "Punctuator", + "value": ")", + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "range": [ + 9, + 10 + ] + } + ] +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/spread-property/valid-1.src.js b/tests/fixtures/ecma-version/9/spread-property/valid-1.src.js new file mode 100644 index 00000000..557c1953 --- /dev/null +++ b/tests/fixtures/ecma-version/9/spread-property/valid-1.src.js @@ -0,0 +1 @@ +({...obj}) \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/spread-property/valid-2.result.js b/tests/fixtures/ecma-version/9/spread-property/valid-2.result.js new file mode 100644 index 00000000..f4e4361c --- /dev/null +++ b/tests/fixtures/ecma-version/9/spread-property/valid-2.result.js @@ -0,0 +1,290 @@ +module.exports = { + "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "range": [ + 0, + 19 + ], + "body": [ + { + "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "range": [ + 0, + 19 + ], + "expression": { + "type": "ObjectExpression", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "range": [ + 1, + 18 + ], + "properties": [ + { + "type": "SpreadElement", + "loc": { + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "range": [ + 2, + 9 + ], + "argument": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "range": [ + 5, + 9 + ], + "name": "obj1" + } + }, + { + "type": "SpreadElement", + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "range": [ + 10, + 17 + ], + "argument": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "range": [ + 13, + 17 + ], + "name": "obj2" + } + } + ] + } + } + ], + "sourceType": "script", + "tokens": [ + { + "type": "Punctuator", + "value": "(", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 1 + } + }, + "range": [ + 0, + 1 + ] + }, + { + "type": "Punctuator", + "value": "{", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 2 + } + }, + "range": [ + 1, + 2 + ] + }, + { + "type": "Punctuator", + "value": "...", + "loc": { + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "range": [ + 2, + 5 + ] + }, + { + "type": "Identifier", + "value": "obj1", + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "range": [ + 5, + 9 + ] + }, + { + "type": "Punctuator", + "value": ",", + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "range": [ + 9, + 10 + ] + }, + { + "type": "Punctuator", + "value": "...", + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "range": [ + 10, + 13 + ] + }, + { + "type": "Identifier", + "value": "obj2", + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "range": [ + 13, + 17 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "range": [ + 17, + 18 + ] + }, + { + "type": "Punctuator", + "value": ")", + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "range": [ + 18, + 19 + ] + } + ] +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/spread-property/valid-2.src.js b/tests/fixtures/ecma-version/9/spread-property/valid-2.src.js new file mode 100644 index 00000000..77129f90 --- /dev/null +++ b/tests/fixtures/ecma-version/9/spread-property/valid-2.src.js @@ -0,0 +1 @@ +({...obj1,...obj2}) \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/spread-property/valid-a-b-c-parenthesized.result.js b/tests/fixtures/ecma-version/9/spread-property/valid-a-b-c-parenthesized.result.js new file mode 100644 index 00000000..8f58722a --- /dev/null +++ b/tests/fixtures/ecma-version/9/spread-property/valid-a-b-c-parenthesized.result.js @@ -0,0 +1,403 @@ +module.exports = { + "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "range": [ + 0, + 14 + ], + "body": [ + { + "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "range": [ + 0, + 14 + ], + "expression": { + "type": "ObjectExpression", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "range": [ + 1, + 13 + ], + "properties": [ + { + "type": "SpreadElement", + "loc": { + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "range": [ + 2, + 10 + ], + "argument": { + "type": "SequenceExpression", + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "range": [ + 6, + 9 + ], + "expressions": [ + { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "range": [ + 6, + 7 + ], + "name": "a" + }, + { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "range": [ + 8, + 9 + ], + "name": "b" + } + ] + } + }, + { + "type": "Property", + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "range": [ + 11, + 12 + ], + "method": false, + "shorthand": true, + "computed": false, + "key": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "range": [ + 11, + 12 + ], + "name": "c" + }, + "kind": "init", + "value": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "range": [ + 11, + 12 + ], + "name": "c" + } + } + ] + } + } + ], + "sourceType": "script", + "tokens": [ + { + "type": "Punctuator", + "value": "(", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 1 + } + }, + "range": [ + 0, + 1 + ] + }, + { + "type": "Punctuator", + "value": "{", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 2 + } + }, + "range": [ + 1, + 2 + ] + }, + { + "type": "Punctuator", + "value": "...", + "loc": { + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "range": [ + 2, + 5 + ] + }, + { + "type": "Punctuator", + "value": "(", + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "range": [ + 5, + 6 + ] + }, + { + "type": "Identifier", + "value": "a", + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "range": [ + 6, + 7 + ] + }, + { + "type": "Punctuator", + "value": ",", + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "range": [ + 7, + 8 + ] + }, + { + "type": "Identifier", + "value": "b", + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "range": [ + 8, + 9 + ] + }, + { + "type": "Punctuator", + "value": ")", + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "range": [ + 9, + 10 + ] + }, + { + "type": "Punctuator", + "value": ",", + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "range": [ + 10, + 11 + ] + }, + { + "type": "Identifier", + "value": "c", + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "range": [ + 11, + 12 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "range": [ + 12, + 13 + ] + }, + { + "type": "Punctuator", + "value": ")", + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "range": [ + 13, + 14 + ] + } + ] +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/spread-property/valid-a-b-c-parenthesized.src.js b/tests/fixtures/ecma-version/9/spread-property/valid-a-b-c-parenthesized.src.js new file mode 100644 index 00000000..46c87073 --- /dev/null +++ b/tests/fixtures/ecma-version/9/spread-property/valid-a-b-c-parenthesized.src.js @@ -0,0 +1 @@ +({...(a,b),c}) \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/spread-property/valid-a-b-c.result.js b/tests/fixtures/ecma-version/9/spread-property/valid-a-b-c.result.js new file mode 100644 index 00000000..e8a2bf47 --- /dev/null +++ b/tests/fixtures/ecma-version/9/spread-property/valid-a-b-c.result.js @@ -0,0 +1,387 @@ +module.exports = { + "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "range": [ + 0, + 12 + ], + "body": [ + { + "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "range": [ + 0, + 12 + ], + "expression": { + "type": "ObjectExpression", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "range": [ + 1, + 11 + ], + "properties": [ + { + "type": "SpreadElement", + "loc": { + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "range": [ + 2, + 6 + ], + "argument": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "range": [ + 5, + 6 + ], + "name": "a" + } + }, + { + "type": "Property", + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "range": [ + 7, + 8 + ], + "method": false, + "shorthand": true, + "computed": false, + "key": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "range": [ + 7, + 8 + ], + "name": "b" + }, + "kind": "init", + "value": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "range": [ + 7, + 8 + ], + "name": "b" + } + }, + { + "type": "Property", + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "range": [ + 9, + 10 + ], + "method": false, + "shorthand": true, + "computed": false, + "key": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "range": [ + 9, + 10 + ], + "name": "c" + }, + "kind": "init", + "value": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "range": [ + 9, + 10 + ], + "name": "c" + } + } + ] + } + } + ], + "sourceType": "script", + "tokens": [ + { + "type": "Punctuator", + "value": "(", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 1 + } + }, + "range": [ + 0, + 1 + ] + }, + { + "type": "Punctuator", + "value": "{", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 2 + } + }, + "range": [ + 1, + 2 + ] + }, + { + "type": "Punctuator", + "value": "...", + "loc": { + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "range": [ + 2, + 5 + ] + }, + { + "type": "Identifier", + "value": "a", + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "range": [ + 5, + 6 + ] + }, + { + "type": "Punctuator", + "value": ",", + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "range": [ + 6, + 7 + ] + }, + { + "type": "Identifier", + "value": "b", + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "range": [ + 7, + 8 + ] + }, + { + "type": "Punctuator", + "value": ",", + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "range": [ + 8, + 9 + ] + }, + { + "type": "Identifier", + "value": "c", + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "range": [ + 9, + 10 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "range": [ + 10, + 11 + ] + }, + { + "type": "Punctuator", + "value": ")", + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "range": [ + 11, + 12 + ] + } + ] +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/spread-property/valid-a-b-c.src.js b/tests/fixtures/ecma-version/9/spread-property/valid-a-b-c.src.js new file mode 100644 index 00000000..94f50f5f --- /dev/null +++ b/tests/fixtures/ecma-version/9/spread-property/valid-a-b-c.src.js @@ -0,0 +1 @@ +({...a,b,c}) \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/spread-property/valid-complex.result.js b/tests/fixtures/ecma-version/9/spread-property/valid-complex.result.js new file mode 100644 index 00000000..22e27555 --- /dev/null +++ b/tests/fixtures/ecma-version/9/spread-property/valid-complex.result.js @@ -0,0 +1,643 @@ +module.exports = { + "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "range": [ + 0, + 29 + ], + "body": [ + { + "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "range": [ + 0, + 29 + ], + "expression": { + "type": "ObjectExpression", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "range": [ + 1, + 28 + ], + "properties": [ + { + "type": "Property", + "loc": { + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "range": [ + 2, + 3 + ], + "method": false, + "shorthand": true, + "computed": false, + "key": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "range": [ + 2, + 3 + ], + "name": "a" + }, + "kind": "init", + "value": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "range": [ + 2, + 3 + ], + "name": "a" + } + }, + { + "type": "SpreadElement", + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "range": [ + 4, + 11 + ], + "argument": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "range": [ + 7, + 11 + ], + "name": "obj1" + } + }, + { + "type": "Property", + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "range": [ + 12, + 15 + ], + "method": false, + "shorthand": false, + "computed": false, + "key": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "range": [ + 12, + 13 + ], + "name": "b" + }, + "value": { + "type": "Literal", + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "range": [ + 14, + 15 + ], + "value": 1, + "raw": "1" + }, + "kind": "init" + }, + { + "type": "SpreadElement", + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "range": [ + 16, + 23 + ], + "argument": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "range": [ + 19, + 23 + ], + "name": "obj2" + } + }, + { + "type": "Property", + "loc": { + "start": { + "line": 1, + "column": 24 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "range": [ + 24, + 27 + ], + "method": false, + "shorthand": false, + "computed": false, + "key": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 24 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "range": [ + 24, + 25 + ], + "name": "c" + }, + "value": { + "type": "Literal", + "loc": { + "start": { + "line": 1, + "column": 26 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "range": [ + 26, + 27 + ], + "value": 2, + "raw": "2" + }, + "kind": "init" + } + ] + } + } + ], + "sourceType": "script", + "tokens": [ + { + "type": "Punctuator", + "value": "(", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 1 + } + }, + "range": [ + 0, + 1 + ] + }, + { + "type": "Punctuator", + "value": "{", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 2 + } + }, + "range": [ + 1, + 2 + ] + }, + { + "type": "Identifier", + "value": "a", + "loc": { + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 3 + } + }, + "range": [ + 2, + 3 + ] + }, + { + "type": "Punctuator", + "value": ",", + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "range": [ + 3, + 4 + ] + }, + { + "type": "Punctuator", + "value": "...", + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "range": [ + 4, + 7 + ] + }, + { + "type": "Identifier", + "value": "obj1", + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "range": [ + 7, + 11 + ] + }, + { + "type": "Punctuator", + "value": ",", + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "range": [ + 11, + 12 + ] + }, + { + "type": "Identifier", + "value": "b", + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "range": [ + 12, + 13 + ] + }, + { + "type": "Punctuator", + "value": ":", + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "range": [ + 13, + 14 + ] + }, + { + "type": "Numeric", + "value": "1", + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "range": [ + 14, + 15 + ] + }, + { + "type": "Punctuator", + "value": ",", + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "range": [ + 15, + 16 + ] + }, + { + "type": "Punctuator", + "value": "...", + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "range": [ + 16, + 19 + ] + }, + { + "type": "Identifier", + "value": "obj2", + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "range": [ + 19, + 23 + ] + }, + { + "type": "Punctuator", + "value": ",", + "loc": { + "start": { + "line": 1, + "column": 23 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "range": [ + 23, + 24 + ] + }, + { + "type": "Identifier", + "value": "c", + "loc": { + "start": { + "line": 1, + "column": 24 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "range": [ + 24, + 25 + ] + }, + { + "type": "Punctuator", + "value": ":", + "loc": { + "start": { + "line": 1, + "column": 25 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "range": [ + 25, + 26 + ] + }, + { + "type": "Numeric", + "value": "2", + "loc": { + "start": { + "line": 1, + "column": 26 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "range": [ + 26, + 27 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 1, + "column": 27 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "range": [ + 27, + 28 + ] + }, + { + "type": "Punctuator", + "value": ")", + "loc": { + "start": { + "line": 1, + "column": 28 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "range": [ + 28, + 29 + ] + } + ] +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/spread-property/valid-complex.src.js b/tests/fixtures/ecma-version/9/spread-property/valid-complex.src.js new file mode 100644 index 00000000..a3216bcd --- /dev/null +++ b/tests/fixtures/ecma-version/9/spread-property/valid-complex.src.js @@ -0,0 +1 @@ +({a,...obj1,b:1,...obj2,c:2}) \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/spread-property/valid-parenthesized-1.result.js b/tests/fixtures/ecma-version/9/spread-property/valid-parenthesized-1.result.js new file mode 100644 index 00000000..1b5546a9 --- /dev/null +++ b/tests/fixtures/ecma-version/9/spread-property/valid-parenthesized-1.result.js @@ -0,0 +1,237 @@ +module.exports = { + "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "range": [ + 0, + 12 + ], + "body": [ + { + "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "range": [ + 0, + 12 + ], + "expression": { + "type": "ObjectExpression", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "range": [ + 1, + 11 + ], + "properties": [ + { + "type": "SpreadElement", + "loc": { + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "range": [ + 2, + 10 + ], + "argument": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "range": [ + 6, + 9 + ], + "name": "obj" + } + } + ] + } + } + ], + "sourceType": "script", + "tokens": [ + { + "type": "Punctuator", + "value": "(", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 1 + } + }, + "range": [ + 0, + 1 + ] + }, + { + "type": "Punctuator", + "value": "{", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 2 + } + }, + "range": [ + 1, + 2 + ] + }, + { + "type": "Punctuator", + "value": "...", + "loc": { + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "range": [ + 2, + 5 + ] + }, + { + "type": "Punctuator", + "value": "(", + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "range": [ + 5, + 6 + ] + }, + { + "type": "Identifier", + "value": "obj", + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "range": [ + 6, + 9 + ] + }, + { + "type": "Punctuator", + "value": ")", + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "range": [ + 9, + 10 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "range": [ + 10, + 11 + ] + }, + { + "type": "Punctuator", + "value": ")", + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "range": [ + 11, + 12 + ] + } + ] +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/spread-property/valid-parenthesized-1.src.js b/tests/fixtures/ecma-version/9/spread-property/valid-parenthesized-1.src.js new file mode 100644 index 00000000..d35d9d88 --- /dev/null +++ b/tests/fixtures/ecma-version/9/spread-property/valid-parenthesized-1.src.js @@ -0,0 +1 @@ +({...(obj)}) \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/spread-property/valid-trailing-comma.result.js b/tests/fixtures/ecma-version/9/spread-property/valid-trailing-comma.result.js new file mode 100644 index 00000000..1e468a27 --- /dev/null +++ b/tests/fixtures/ecma-version/9/spread-property/valid-trailing-comma.result.js @@ -0,0 +1,219 @@ +module.exports = { + "type": "Program", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "range": [ + 0, + 12 + ], + "body": [ + { + "type": "ExpressionStatement", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "range": [ + 0, + 12 + ], + "expression": { + "type": "ObjectExpression", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "range": [ + 1, + 11 + ], + "properties": [ + { + "type": "SpreadElement", + "loc": { + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "range": [ + 2, + 9 + ], + "argument": { + "type": "Identifier", + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "range": [ + 5, + 9 + ], + "name": "obj1" + } + } + ] + } + } + ], + "sourceType": "script", + "tokens": [ + { + "type": "Punctuator", + "value": "(", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 1 + } + }, + "range": [ + 0, + 1 + ] + }, + { + "type": "Punctuator", + "value": "{", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 2 + } + }, + "range": [ + 1, + 2 + ] + }, + { + "type": "Punctuator", + "value": "...", + "loc": { + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "range": [ + 2, + 5 + ] + }, + { + "type": "Identifier", + "value": "obj1", + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "range": [ + 5, + 9 + ] + }, + { + "type": "Punctuator", + "value": ",", + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "range": [ + 9, + 10 + ] + }, + { + "type": "Punctuator", + "value": "}", + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "range": [ + 10, + 11 + ] + }, + { + "type": "Punctuator", + "value": ")", + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "range": [ + 11, + 12 + ] + } + ] +}; \ No newline at end of file diff --git a/tests/fixtures/ecma-version/9/spread-property/valid-trailing-comma.src.js b/tests/fixtures/ecma-version/9/spread-property/valid-trailing-comma.src.js new file mode 100644 index 00000000..4c8d2d5d --- /dev/null +++ b/tests/fixtures/ecma-version/9/spread-property/valid-trailing-comma.src.js @@ -0,0 +1 @@ +({...obj1,}) \ No newline at end of file diff --git a/tests/lib/ecma-features.js b/tests/lib/ecma-features.js index e3fd4a2b..e1096b6a 100644 --- a/tests/lib/ecma-features.js +++ b/tests/lib/ecma-features.js @@ -83,4 +83,15 @@ describe("ecmaFeatures", function() { }); }); + describe("combination with 'ecmaVersion:2018' and 'ecmaFeatures.experimentalObjectRestSpread:true'", function() { + it("should generate ExperimentalRestProperty/ExperimentalSpreadProperty.", function() { + config.ecmaVersion = 2018; + config.ecmaFeatures.experimentalObjectRestSpread = true; + + var ast = espree.parse("({...rest} = {...spread})", config); + + assert.strictEqual(ast.body[0].expression.left.properties[0].type, "ExperimentalRestProperty"); + assert.strictEqual(ast.body[0].expression.right.properties[0].type, "ExperimentalSpreadProperty"); + }); + }); }); diff --git a/tests/lib/ecma-version.js b/tests/lib/ecma-version.js index 70038309..f15f7e15 100644 --- a/tests/lib/ecma-version.js +++ b/tests/lib/ecma-version.js @@ -83,7 +83,13 @@ describe("ecmaVersion", function() { var code = shelljs.cat(path.resolve(FIXTURES_DIR, filename) + ".src.js"); it("should parse correctly when sourceType is module", function() { - var expected = require(path.resolve(__dirname, "../../", FIXTURES_DIR, filename) + ".result.js"); + var expected; + + try { + expected = require(path.resolve(__dirname, "../../", FIXTURES_DIR, filename) + ".module-result.js"); + } catch (err) { + expected = require(path.resolve(__dirname, "../../", FIXTURES_DIR, filename) + ".result.js"); + } config.ecmaVersion = Number(version); config.sourceType = "module";