diff --git a/tests/fixtures/ecma-features/classes/class-with-constructor-parameters.result.js b/tests/fixtures/ecma-features/classes/class-with-constructor-parameters.result.js new file mode 100644 index 0000000..0dea27c --- /dev/null +++ b/tests/fixtures/ecma-features/classes/class-with-constructor-parameters.result.js @@ -0,0 +1,413 @@ +module.exports = { + "type": "Program", + "range": [ + 0, + 33 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "body": [ + { + "type": "ClassDeclaration", + "range": [ + 0, + 33 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "id": { + "type": "Identifier", + "range": [ + 6, + 7 + ], + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "name": "A" + }, + "body": { + "type": "ClassBody", + "body": [ + { + "type": "MethodDefinition", + "range": [ + 9, + 32 + ], + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "key": { + "type": "Identifier", + "name": "constructor", + "range": [ + 9, + 20 + ], + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 20 + } + } + }, + "value": { + "type": "FunctionExpression", + "id": null, + "params": [ + { + "type": "Identifier", + "range": [ + 21, + 24 + ], + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "name": "foo", + "decorators": [] + }, + { + "type": "Identifier", + "range": [ + 26, + 29 + ], + "loc": { + "start": { + "line": 1, + "column": 26 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "name": "bar", + "decorators": [] + } + ], + "generator": false, + "expression": false, + "async": false, + "body": { + "type": "BlockStatement", + "range": [ + 30, + 32 + ], + "loc": { + "start": { + "line": 1, + "column": 30 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "body": [] + }, + "range": [ + 20, + 32 + ], + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 32 + } + } + }, + "computed": false, + "accessibility": null, + "static": false, + "kind": "constructor" + } + ], + "range": [ + 8, + 33 + ], + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 33 + } + } + }, + "superClass": null, + "implements": [], + "decorators": [] + } + ], + "sourceType": "script", + "tokens": [ + { + "type": "Keyword", + "value": "class", + "range": [ + 0, + 5 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + } + }, + { + "type": "Identifier", + "value": "A", + "range": [ + 6, + 7 + ], + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + } + } + }, + { + "type": "Punctuator", + "value": "{", + "range": [ + 8, + 9 + ], + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 9 + } + } + }, + { + "type": "Identifier", + "value": "constructor", + "range": [ + 9, + 20 + ], + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 20 + } + } + }, + { + "type": "Punctuator", + "value": "(", + "range": [ + 20, + 21 + ], + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 21 + } + } + }, + { + "type": "Identifier", + "value": "foo", + "range": [ + 21, + 24 + ], + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 24 + } + } + }, + { + "type": "Punctuator", + "value": ",", + "range": [ + 24, + 25 + ], + "loc": { + "start": { + "line": 1, + "column": 24 + }, + "end": { + "line": 1, + "column": 25 + } + } + }, + { + "type": "Identifier", + "value": "bar", + "range": [ + 26, + 29 + ], + "loc": { + "start": { + "line": 1, + "column": 26 + }, + "end": { + "line": 1, + "column": 29 + } + } + }, + { + "type": "Punctuator", + "value": ")", + "range": [ + 29, + 30 + ], + "loc": { + "start": { + "line": 1, + "column": 29 + }, + "end": { + "line": 1, + "column": 30 + } + } + }, + { + "type": "Punctuator", + "value": "{", + "range": [ + 30, + 31 + ], + "loc": { + "start": { + "line": 1, + "column": 30 + }, + "end": { + "line": 1, + "column": 31 + } + } + }, + { + "type": "Punctuator", + "value": "}", + "range": [ + 31, + 32 + ], + "loc": { + "start": { + "line": 1, + "column": 31 + }, + "end": { + "line": 1, + "column": 32 + } + } + }, + { + "type": "Punctuator", + "value": "}", + "range": [ + 32, + 33 + ], + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 33 + } + } + } + ] +}; diff --git a/tests/fixtures/ecma-features/classes/class-with-constructor-parameters.src.js b/tests/fixtures/ecma-features/classes/class-with-constructor-parameters.src.js new file mode 100644 index 0000000..92ffc49 --- /dev/null +++ b/tests/fixtures/ecma-features/classes/class-with-constructor-parameters.src.js @@ -0,0 +1 @@ +class A {constructor(foo, bar){}} diff --git a/tests/fixtures/ecma-features/defaultParams/class-constructor.result.js b/tests/fixtures/ecma-features/defaultParams/class-constructor.result.js new file mode 100644 index 0000000..97b08ad --- /dev/null +++ b/tests/fixtures/ecma-features/defaultParams/class-constructor.result.js @@ -0,0 +1,430 @@ +module.exports = { + "type": "Program", + "range": [ + 0, + 46 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "body": [ + { + "type": "ClassDeclaration", + "range": [ + 0, + 46 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "range": [ + 6, + 7 + ], + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "name": "A" + }, + "body": { + "type": "ClassBody", + "body": [ + { + "type": "MethodDefinition", + "range": [ + 14, + 44 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 3, + "column": 5 + } + }, + "key": { + "type": "Identifier", + "name": "constructor", + "range": [ + 14, + 25 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 15 + } + } + }, + "value": { + "type": "FunctionExpression", + "id": null, + "params": [ + { + "type": "AssignmentPattern", + "range": [ + 26, + 35 + ], + "loc": { + "start": { + "line": 2, + "column": 16 + }, + "end": { + "line": 2, + "column": 25 + } + }, + "left": { + "type": "Identifier", + "range": [ + 26, + 29 + ], + "loc": { + "start": { + "line": 2, + "column": 16 + }, + "end": { + "line": 2, + "column": 19 + } + }, + "name": "foo" + }, + "right": { + "type": "Literal", + "range": [ + 30, + 35 + ], + "loc": { + "start": { + "line": 2, + "column": 20 + }, + "end": { + "line": 2, + "column": 25 + } + }, + "value": "bar", + "raw": "'bar'" + }, + "decorators": [] + } + ], + "generator": false, + "expression": false, + "async": false, + "body": { + "type": "BlockStatement", + "range": [ + 37, + 44 + ], + "loc": { + "start": { + "line": 2, + "column": 27 + }, + "end": { + "line": 3, + "column": 5 + } + }, + "body": [] + }, + "range": [ + 25, + 44 + ], + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 3, + "column": 5 + } + } + }, + "computed": false, + "accessibility": null, + "static": false, + "kind": "constructor" + } + ], + "range": [ + 8, + 46 + ], + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 4, + "column": 1 + } + } + }, + "superClass": null, + "implements": [], + "decorators": [] + } + ], + "sourceType": "script", + "tokens": [ + { + "type": "Keyword", + "value": "class", + "range": [ + 0, + 5 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + } + }, + { + "type": "Identifier", + "value": "A", + "range": [ + 6, + 7 + ], + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + } + } + }, + { + "type": "Punctuator", + "value": "{", + "range": [ + 8, + 9 + ], + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 9 + } + } + }, + { + "type": "Identifier", + "value": "constructor", + "range": [ + 14, + 25 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 15 + } + } + }, + { + "type": "Punctuator", + "value": "(", + "range": [ + 25, + 26 + ], + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 2, + "column": 16 + } + } + }, + { + "type": "Identifier", + "value": "foo", + "range": [ + 26, + 29 + ], + "loc": { + "start": { + "line": 2, + "column": 16 + }, + "end": { + "line": 2, + "column": 19 + } + } + }, + { + "type": "Punctuator", + "value": "=", + "range": [ + 29, + 30 + ], + "loc": { + "start": { + "line": 2, + "column": 19 + }, + "end": { + "line": 2, + "column": 20 + } + } + }, + { + "type": "String", + "value": "'bar'", + "range": [ + 30, + 35 + ], + "loc": { + "start": { + "line": 2, + "column": 20 + }, + "end": { + "line": 2, + "column": 25 + } + } + }, + { + "type": "Punctuator", + "value": ")", + "range": [ + 35, + 36 + ], + "loc": { + "start": { + "line": 2, + "column": 25 + }, + "end": { + "line": 2, + "column": 26 + } + } + }, + { + "type": "Punctuator", + "value": "{", + "range": [ + 37, + 38 + ], + "loc": { + "start": { + "line": 2, + "column": 27 + }, + "end": { + "line": 2, + "column": 28 + } + } + }, + { + "type": "Punctuator", + "value": "}", + "range": [ + 43, + 44 + ], + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 5 + } + } + }, + { + "type": "Punctuator", + "value": "}", + "range": [ + 45, + 46 + ], + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + } + } + ] +}; diff --git a/tests/fixtures/ecma-features/defaultParams/class-constructor.src.js b/tests/fixtures/ecma-features/defaultParams/class-constructor.src.js new file mode 100644 index 0000000..901358c --- /dev/null +++ b/tests/fixtures/ecma-features/defaultParams/class-constructor.src.js @@ -0,0 +1,4 @@ +class A { + constructor(foo='bar') { + } +} diff --git a/tests/fixtures/ecma-features/defaultParams/class-method.result.js b/tests/fixtures/ecma-features/defaultParams/class-method.result.js new file mode 100644 index 0000000..e3d75fe --- /dev/null +++ b/tests/fixtures/ecma-features/defaultParams/class-method.result.js @@ -0,0 +1,431 @@ +module.exports = { + "type": "Program", + "range": [ + 0, + 38 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "body": [ + { + "type": "ClassDeclaration", + "range": [ + 0, + 38 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "range": [ + 6, + 7 + ], + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "name": "A" + }, + "body": { + "type": "ClassBody", + "body": [ + { + "type": "MethodDefinition", + "range": [ + 14, + 36 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 3, + "column": 5 + } + }, + "key": { + "type": "Identifier", + "range": [ + 14, + 17 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 7 + } + }, + "name": "foo" + }, + "value": { + "type": "FunctionExpression", + "id": null, + "generator": false, + "expression": false, + "async": false, + "body": { + "type": "BlockStatement", + "range": [ + 29, + 36 + ], + "loc": { + "start": { + "line": 2, + "column": 19 + }, + "end": { + "line": 3, + "column": 5 + } + }, + "body": [] + }, + "range": [ + 17, + 36 + ], + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 3, + "column": 5 + } + }, + "params": [ + { + "type": "AssignmentPattern", + "range": [ + 18, + 27 + ], + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 17 + } + }, + "left": { + "type": "Identifier", + "range": [ + 18, + 21 + ], + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 11 + } + }, + "name": "bar" + }, + "right": { + "type": "Literal", + "range": [ + 22, + 27 + ], + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 17 + } + }, + "value": "baz", + "raw": "'baz'" + }, + "decorators": [] + } + ] + }, + "computed": false, + "static": false, + "kind": "method", + "accessibility": null, + "decorators": [] + } + ], + "range": [ + 8, + 38 + ], + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 4, + "column": 1 + } + } + }, + "superClass": null, + "implements": [], + "decorators": [] + } + ], + "sourceType": "script", + "tokens": [ + { + "type": "Keyword", + "value": "class", + "range": [ + 0, + 5 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + } + }, + { + "type": "Identifier", + "value": "A", + "range": [ + 6, + 7 + ], + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + } + } + }, + { + "type": "Punctuator", + "value": "{", + "range": [ + 8, + 9 + ], + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 9 + } + } + }, + { + "type": "Identifier", + "value": "foo", + "range": [ + 14, + 17 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 7 + } + } + }, + { + "type": "Punctuator", + "value": "(", + "range": [ + 17, + 18 + ], + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 8 + } + } + }, + { + "type": "Identifier", + "value": "bar", + "range": [ + 18, + 21 + ], + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 11 + } + } + }, + { + "type": "Punctuator", + "value": "=", + "range": [ + 21, + 22 + ], + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 12 + } + } + }, + { + "type": "String", + "value": "'baz'", + "range": [ + 22, + 27 + ], + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 17 + } + } + }, + { + "type": "Punctuator", + "value": ")", + "range": [ + 27, + 28 + ], + "loc": { + "start": { + "line": 2, + "column": 17 + }, + "end": { + "line": 2, + "column": 18 + } + } + }, + { + "type": "Punctuator", + "value": "{", + "range": [ + 29, + 30 + ], + "loc": { + "start": { + "line": 2, + "column": 19 + }, + "end": { + "line": 2, + "column": 20 + } + } + }, + { + "type": "Punctuator", + "value": "}", + "range": [ + 35, + 36 + ], + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 5 + } + } + }, + { + "type": "Punctuator", + "value": "}", + "range": [ + 37, + 38 + ], + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + } + } + ] +}; diff --git a/tests/fixtures/ecma-features/defaultParams/class-method.src.js b/tests/fixtures/ecma-features/defaultParams/class-method.src.js new file mode 100644 index 0000000..cb113e7 --- /dev/null +++ b/tests/fixtures/ecma-features/defaultParams/class-method.src.js @@ -0,0 +1,4 @@ +class A { + foo(bar='baz') { + } +} diff --git a/tests/fixtures/ecma-features/destructuring/class-constructor-params-array.result.js b/tests/fixtures/ecma-features/destructuring/class-constructor-params-array.result.js new file mode 100644 index 0000000..8cacbe9 --- /dev/null +++ b/tests/fixtures/ecma-features/destructuring/class-constructor-params-array.result.js @@ -0,0 +1,468 @@ +module.exports = { + "type": "Program", + "range": [ + 0, + 47 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "body": [ + { + "type": "ClassDeclaration", + "range": [ + 0, + 47 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "range": [ + 6, + 7 + ], + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "name": "A" + }, + "body": { + "type": "ClassBody", + "body": [ + { + "type": "MethodDefinition", + "range": [ + 14, + 45 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 3, + "column": 5 + } + }, + "key": { + "type": "Identifier", + "range": [ + 14, + 25 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 15 + } + }, + "name": "consturctor" + }, + "value": { + "type": "FunctionExpression", + "id": null, + "generator": false, + "expression": false, + "async": false, + "body": { + "type": "BlockStatement", + "range": [ + 38, + 45 + ], + "loc": { + "start": { + "line": 2, + "column": 28 + }, + "end": { + "line": 3, + "column": 5 + } + }, + "body": [] + }, + "range": [ + 25, + 45 + ], + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 3, + "column": 5 + } + }, + "params": [ + { + "type": "ArrayPattern", + "range": [ + 26, + 36 + ], + "loc": { + "start": { + "line": 2, + "column": 16 + }, + "end": { + "line": 2, + "column": 26 + } + }, + "elements": [ + { + "type": "Identifier", + "range": [ + 27, + 30 + ], + "loc": { + "start": { + "line": 2, + "column": 17 + }, + "end": { + "line": 2, + "column": 20 + } + }, + "name": "foo" + }, + { + "type": "Identifier", + "range": [ + 32, + 35 + ], + "loc": { + "start": { + "line": 2, + "column": 22 + }, + "end": { + "line": 2, + "column": 25 + } + }, + "name": "bar" + } + ], + "decorators": [] + } + ] + }, + "computed": false, + "static": false, + "kind": "method", + "accessibility": null, + "decorators": [] + } + ], + "range": [ + 8, + 47 + ], + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 4, + "column": 1 + } + } + }, + "superClass": null, + "implements": [], + "decorators": [] + } + ], + "sourceType": "script", + "tokens": [ + { + "type": "Keyword", + "value": "class", + "range": [ + 0, + 5 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + } + }, + { + "type": "Identifier", + "value": "A", + "range": [ + 6, + 7 + ], + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + } + } + }, + { + "type": "Punctuator", + "value": "{", + "range": [ + 8, + 9 + ], + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 9 + } + } + }, + { + "type": "Identifier", + "value": "consturctor", + "range": [ + 14, + 25 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 15 + } + } + }, + { + "type": "Punctuator", + "value": "(", + "range": [ + 25, + 26 + ], + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 2, + "column": 16 + } + } + }, + { + "type": "Punctuator", + "value": "[", + "range": [ + 26, + 27 + ], + "loc": { + "start": { + "line": 2, + "column": 16 + }, + "end": { + "line": 2, + "column": 17 + } + } + }, + { + "type": "Identifier", + "value": "foo", + "range": [ + 27, + 30 + ], + "loc": { + "start": { + "line": 2, + "column": 17 + }, + "end": { + "line": 2, + "column": 20 + } + } + }, + { + "type": "Punctuator", + "value": ",", + "range": [ + 30, + 31 + ], + "loc": { + "start": { + "line": 2, + "column": 20 + }, + "end": { + "line": 2, + "column": 21 + } + } + }, + { + "type": "Identifier", + "value": "bar", + "range": [ + 32, + 35 + ], + "loc": { + "start": { + "line": 2, + "column": 22 + }, + "end": { + "line": 2, + "column": 25 + } + } + }, + { + "type": "Punctuator", + "value": "]", + "range": [ + 35, + 36 + ], + "loc": { + "start": { + "line": 2, + "column": 25 + }, + "end": { + "line": 2, + "column": 26 + } + } + }, + { + "type": "Punctuator", + "value": ")", + "range": [ + 36, + 37 + ], + "loc": { + "start": { + "line": 2, + "column": 26 + }, + "end": { + "line": 2, + "column": 27 + } + } + }, + { + "type": "Punctuator", + "value": "{", + "range": [ + 38, + 39 + ], + "loc": { + "start": { + "line": 2, + "column": 28 + }, + "end": { + "line": 2, + "column": 29 + } + } + }, + { + "type": "Punctuator", + "value": "}", + "range": [ + 44, + 45 + ], + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 5 + } + } + }, + { + "type": "Punctuator", + "value": "}", + "range": [ + 46, + 47 + ], + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + } + } + ] +}; diff --git a/tests/fixtures/ecma-features/destructuring/class-constructor-params-array.src.js b/tests/fixtures/ecma-features/destructuring/class-constructor-params-array.src.js new file mode 100644 index 0000000..8a926b8 --- /dev/null +++ b/tests/fixtures/ecma-features/destructuring/class-constructor-params-array.src.js @@ -0,0 +1,4 @@ +class A { + consturctor([foo, bar]) { + } +} diff --git a/tests/fixtures/ecma-features/destructuring/class-constructor-params-defaults-array.result.js b/tests/fixtures/ecma-features/destructuring/class-constructor-params-defaults-array.result.js new file mode 100644 index 0000000..8fb598a --- /dev/null +++ b/tests/fixtures/ecma-features/destructuring/class-constructor-params-defaults-array.result.js @@ -0,0 +1,612 @@ +module.exports = { + "type": "Program", + "range": [ + 0, + 51 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "body": [ + { + "type": "ClassDeclaration", + "range": [ + 0, + 51 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "range": [ + 6, + 7 + ], + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "name": "A" + }, + "body": { + "type": "ClassBody", + "body": [ + { + "type": "MethodDefinition", + "range": [ + 14, + 49 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 3, + "column": 5 + } + }, + "key": { + "type": "Identifier", + "range": [ + 14, + 25 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 15 + } + }, + "name": "consturctor" + }, + "value": { + "type": "FunctionExpression", + "id": null, + "generator": false, + "expression": false, + "async": false, + "body": { + "type": "BlockStatement", + "range": [ + 42, + 49 + ], + "loc": { + "start": { + "line": 2, + "column": 32 + }, + "end": { + "line": 3, + "column": 5 + } + }, + "body": [] + }, + "range": [ + 25, + 49 + ], + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 3, + "column": 5 + } + }, + "params": [ + { + "type": "ArrayPattern", + "range": [ + 26, + 40 + ], + "loc": { + "start": { + "line": 2, + "column": 16 + }, + "end": { + "line": 2, + "column": 30 + } + }, + "elements": [ + { + "type": "AssignmentPattern", + "range": [ + 27, + 32 + ], + "loc": { + "start": { + "line": 2, + "column": 17 + }, + "end": { + "line": 2, + "column": 22 + } + }, + "left": { + "type": "Identifier", + "range": [ + 27, + 30 + ], + "loc": { + "start": { + "line": 2, + "column": 17 + }, + "end": { + "line": 2, + "column": 20 + } + }, + "name": "foo" + }, + "right": { + "type": "Literal", + "range": [ + 31, + 32 + ], + "loc": { + "start": { + "line": 2, + "column": 21 + }, + "end": { + "line": 2, + "column": 22 + } + }, + "value": 3, + "raw": "3" + } + }, + { + "type": "AssignmentPattern", + "range": [ + 34, + 39 + ], + "loc": { + "start": { + "line": 2, + "column": 24 + }, + "end": { + "line": 2, + "column": 29 + } + }, + "left": { + "type": "Identifier", + "range": [ + 34, + 37 + ], + "loc": { + "start": { + "line": 2, + "column": 24 + }, + "end": { + "line": 2, + "column": 27 + } + }, + "name": "bar" + }, + "right": { + "type": "Literal", + "range": [ + 38, + 39 + ], + "loc": { + "start": { + "line": 2, + "column": 28 + }, + "end": { + "line": 2, + "column": 29 + } + }, + "value": 4, + "raw": "4" + } + } + ], + "decorators": [] + } + ] + }, + "computed": false, + "static": false, + "kind": "method", + "accessibility": null, + "decorators": [] + } + ], + "range": [ + 8, + 51 + ], + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 4, + "column": 1 + } + } + }, + "superClass": null, + "implements": [], + "decorators": [] + } + ], + "sourceType": "script", + "tokens": [ + { + "type": "Keyword", + "value": "class", + "range": [ + 0, + 5 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + } + }, + { + "type": "Identifier", + "value": "A", + "range": [ + 6, + 7 + ], + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + } + } + }, + { + "type": "Punctuator", + "value": "{", + "range": [ + 8, + 9 + ], + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 9 + } + } + }, + { + "type": "Identifier", + "value": "consturctor", + "range": [ + 14, + 25 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 15 + } + } + }, + { + "type": "Punctuator", + "value": "(", + "range": [ + 25, + 26 + ], + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 2, + "column": 16 + } + } + }, + { + "type": "Punctuator", + "value": "[", + "range": [ + 26, + 27 + ], + "loc": { + "start": { + "line": 2, + "column": 16 + }, + "end": { + "line": 2, + "column": 17 + } + } + }, + { + "type": "Identifier", + "value": "foo", + "range": [ + 27, + 30 + ], + "loc": { + "start": { + "line": 2, + "column": 17 + }, + "end": { + "line": 2, + "column": 20 + } + } + }, + { + "type": "Punctuator", + "value": "=", + "range": [ + 30, + 31 + ], + "loc": { + "start": { + "line": 2, + "column": 20 + }, + "end": { + "line": 2, + "column": 21 + } + } + }, + { + "type": "Numeric", + "value": "3", + "range": [ + 31, + 32 + ], + "loc": { + "start": { + "line": 2, + "column": 21 + }, + "end": { + "line": 2, + "column": 22 + } + } + }, + { + "type": "Punctuator", + "value": ",", + "range": [ + 32, + 33 + ], + "loc": { + "start": { + "line": 2, + "column": 22 + }, + "end": { + "line": 2, + "column": 23 + } + } + }, + { + "type": "Identifier", + "value": "bar", + "range": [ + 34, + 37 + ], + "loc": { + "start": { + "line": 2, + "column": 24 + }, + "end": { + "line": 2, + "column": 27 + } + } + }, + { + "type": "Punctuator", + "value": "=", + "range": [ + 37, + 38 + ], + "loc": { + "start": { + "line": 2, + "column": 27 + }, + "end": { + "line": 2, + "column": 28 + } + } + }, + { + "type": "Numeric", + "value": "4", + "range": [ + 38, + 39 + ], + "loc": { + "start": { + "line": 2, + "column": 28 + }, + "end": { + "line": 2, + "column": 29 + } + } + }, + { + "type": "Punctuator", + "value": "]", + "range": [ + 39, + 40 + ], + "loc": { + "start": { + "line": 2, + "column": 29 + }, + "end": { + "line": 2, + "column": 30 + } + } + }, + { + "type": "Punctuator", + "value": ")", + "range": [ + 40, + 41 + ], + "loc": { + "start": { + "line": 2, + "column": 30 + }, + "end": { + "line": 2, + "column": 31 + } + } + }, + { + "type": "Punctuator", + "value": "{", + "range": [ + 42, + 43 + ], + "loc": { + "start": { + "line": 2, + "column": 32 + }, + "end": { + "line": 2, + "column": 33 + } + } + }, + { + "type": "Punctuator", + "value": "}", + "range": [ + 48, + 49 + ], + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 5 + } + } + }, + { + "type": "Punctuator", + "value": "}", + "range": [ + 50, + 51 + ], + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + } + } + ] +}; diff --git a/tests/fixtures/ecma-features/destructuring/class-constructor-params-defaults-array.src.js b/tests/fixtures/ecma-features/destructuring/class-constructor-params-defaults-array.src.js new file mode 100644 index 0000000..9afe8da --- /dev/null +++ b/tests/fixtures/ecma-features/destructuring/class-constructor-params-defaults-array.src.js @@ -0,0 +1,4 @@ +class A { + consturctor([foo=3, bar=4]) { + } +} diff --git a/tests/fixtures/ecma-features/destructuring/class-constructor-params-defaults-object.result.js b/tests/fixtures/ecma-features/destructuring/class-constructor-params-defaults-object.result.js new file mode 100644 index 0000000..12d9262 --- /dev/null +++ b/tests/fixtures/ecma-features/destructuring/class-constructor-params-defaults-object.result.js @@ -0,0 +1,690 @@ +module.exports = { + "type": "Program", + "range": [ + 0, + 51 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "body": [ + { + "type": "ClassDeclaration", + "range": [ + 0, + 51 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "range": [ + 6, + 7 + ], + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "name": "A" + }, + "body": { + "type": "ClassBody", + "body": [ + { + "type": "MethodDefinition", + "range": [ + 14, + 49 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 3, + "column": 5 + } + }, + "key": { + "type": "Identifier", + "range": [ + 14, + 25 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 15 + } + }, + "name": "consturctor" + }, + "value": { + "type": "FunctionExpression", + "id": null, + "generator": false, + "expression": false, + "async": false, + "body": { + "type": "BlockStatement", + "range": [ + 42, + 49 + ], + "loc": { + "start": { + "line": 2, + "column": 32 + }, + "end": { + "line": 3, + "column": 5 + } + }, + "body": [] + }, + "range": [ + 25, + 49 + ], + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 3, + "column": 5 + } + }, + "params": [ + { + "type": "ObjectPattern", + "range": [ + 26, + 40 + ], + "loc": { + "start": { + "line": 2, + "column": 16 + }, + "end": { + "line": 2, + "column": 30 + } + }, + "properties": [ + { + "type": "Property", + "range": [ + 27, + 32 + ], + "loc": { + "start": { + "line": 2, + "column": 17 + }, + "end": { + "line": 2, + "column": 22 + } + }, + "key": { + "type": "Identifier", + "range": [ + 27, + 30 + ], + "loc": { + "start": { + "line": 2, + "column": 17 + }, + "end": { + "line": 2, + "column": 20 + } + }, + "name": "foo" + }, + "value": { + "type": "AssignmentPattern", + "left": { + "type": "Identifier", + "range": [ + 27, + 30 + ], + "loc": { + "start": { + "line": 2, + "column": 17 + }, + "end": { + "line": 2, + "column": 20 + } + }, + "name": "foo" + }, + "right": { + "type": "Literal", + "range": [ + 31, + 32 + ], + "loc": { + "start": { + "line": 2, + "column": 21 + }, + "end": { + "line": 2, + "column": 22 + } + }, + "value": 3, + "raw": "3" + }, + "range": [ + 27, + 32 + ], + "loc": { + "start": { + "line": 2, + "column": 17 + }, + "end": { + "line": 2, + "column": 22 + } + } + }, + "computed": false, + "method": false, + "shorthand": true, + "kind": "init" + }, + { + "type": "Property", + "range": [ + 34, + 39 + ], + "loc": { + "start": { + "line": 2, + "column": 24 + }, + "end": { + "line": 2, + "column": 29 + } + }, + "key": { + "type": "Identifier", + "range": [ + 34, + 37 + ], + "loc": { + "start": { + "line": 2, + "column": 24 + }, + "end": { + "line": 2, + "column": 27 + } + }, + "name": "bar" + }, + "value": { + "type": "AssignmentPattern", + "left": { + "type": "Identifier", + "range": [ + 34, + 37 + ], + "loc": { + "start": { + "line": 2, + "column": 24 + }, + "end": { + "line": 2, + "column": 27 + } + }, + "name": "bar" + }, + "right": { + "type": "Literal", + "range": [ + 38, + 39 + ], + "loc": { + "start": { + "line": 2, + "column": 28 + }, + "end": { + "line": 2, + "column": 29 + } + }, + "value": 4, + "raw": "4" + }, + "range": [ + 34, + 39 + ], + "loc": { + "start": { + "line": 2, + "column": 24 + }, + "end": { + "line": 2, + "column": 29 + } + } + }, + "computed": false, + "method": false, + "shorthand": true, + "kind": "init" + } + ], + "decorators": [] + } + ] + }, + "computed": false, + "static": false, + "kind": "method", + "accessibility": null, + "decorators": [] + } + ], + "range": [ + 8, + 51 + ], + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 4, + "column": 1 + } + } + }, + "superClass": null, + "implements": [], + "decorators": [] + } + ], + "sourceType": "script", + "tokens": [ + { + "type": "Keyword", + "value": "class", + "range": [ + 0, + 5 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + } + }, + { + "type": "Identifier", + "value": "A", + "range": [ + 6, + 7 + ], + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + } + } + }, + { + "type": "Punctuator", + "value": "{", + "range": [ + 8, + 9 + ], + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 9 + } + } + }, + { + "type": "Identifier", + "value": "consturctor", + "range": [ + 14, + 25 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 15 + } + } + }, + { + "type": "Punctuator", + "value": "(", + "range": [ + 25, + 26 + ], + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 2, + "column": 16 + } + } + }, + { + "type": "Punctuator", + "value": "{", + "range": [ + 26, + 27 + ], + "loc": { + "start": { + "line": 2, + "column": 16 + }, + "end": { + "line": 2, + "column": 17 + } + } + }, + { + "type": "Identifier", + "value": "foo", + "range": [ + 27, + 30 + ], + "loc": { + "start": { + "line": 2, + "column": 17 + }, + "end": { + "line": 2, + "column": 20 + } + } + }, + { + "type": "Punctuator", + "value": "=", + "range": [ + 30, + 31 + ], + "loc": { + "start": { + "line": 2, + "column": 20 + }, + "end": { + "line": 2, + "column": 21 + } + } + }, + { + "type": "Numeric", + "value": "3", + "range": [ + 31, + 32 + ], + "loc": { + "start": { + "line": 2, + "column": 21 + }, + "end": { + "line": 2, + "column": 22 + } + } + }, + { + "type": "Punctuator", + "value": ",", + "range": [ + 32, + 33 + ], + "loc": { + "start": { + "line": 2, + "column": 22 + }, + "end": { + "line": 2, + "column": 23 + } + } + }, + { + "type": "Identifier", + "value": "bar", + "range": [ + 34, + 37 + ], + "loc": { + "start": { + "line": 2, + "column": 24 + }, + "end": { + "line": 2, + "column": 27 + } + } + }, + { + "type": "Punctuator", + "value": "=", + "range": [ + 37, + 38 + ], + "loc": { + "start": { + "line": 2, + "column": 27 + }, + "end": { + "line": 2, + "column": 28 + } + } + }, + { + "type": "Numeric", + "value": "4", + "range": [ + 38, + 39 + ], + "loc": { + "start": { + "line": 2, + "column": 28 + }, + "end": { + "line": 2, + "column": 29 + } + } + }, + { + "type": "Punctuator", + "value": "}", + "range": [ + 39, + 40 + ], + "loc": { + "start": { + "line": 2, + "column": 29 + }, + "end": { + "line": 2, + "column": 30 + } + } + }, + { + "type": "Punctuator", + "value": ")", + "range": [ + 40, + 41 + ], + "loc": { + "start": { + "line": 2, + "column": 30 + }, + "end": { + "line": 2, + "column": 31 + } + } + }, + { + "type": "Punctuator", + "value": "{", + "range": [ + 42, + 43 + ], + "loc": { + "start": { + "line": 2, + "column": 32 + }, + "end": { + "line": 2, + "column": 33 + } + } + }, + { + "type": "Punctuator", + "value": "}", + "range": [ + 48, + 49 + ], + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 5 + } + } + }, + { + "type": "Punctuator", + "value": "}", + "range": [ + 50, + 51 + ], + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + } + } + ] +}; diff --git a/tests/fixtures/ecma-features/destructuring/class-constructor-params-defaults-object.src.js b/tests/fixtures/ecma-features/destructuring/class-constructor-params-defaults-object.src.js new file mode 100644 index 0000000..c840ebe --- /dev/null +++ b/tests/fixtures/ecma-features/destructuring/class-constructor-params-defaults-object.src.js @@ -0,0 +1,4 @@ +class A { + consturctor({foo=3, bar=4}) { + } +} diff --git a/tests/fixtures/ecma-features/destructuring/class-constructor-params-object.result.js b/tests/fixtures/ecma-features/destructuring/class-constructor-params-object.result.js new file mode 100644 index 0000000..83c12f9 --- /dev/null +++ b/tests/fixtures/ecma-features/destructuring/class-constructor-params-object.result.js @@ -0,0 +1,546 @@ +module.exports = { + "type": "Program", + "range": [ + 0, + 47 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "body": [ + { + "type": "ClassDeclaration", + "range": [ + 0, + 47 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "range": [ + 6, + 7 + ], + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "name": "A" + }, + "body": { + "type": "ClassBody", + "body": [ + { + "type": "MethodDefinition", + "range": [ + 14, + 45 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 3, + "column": 5 + } + }, + "key": { + "type": "Identifier", + "range": [ + 14, + 25 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 15 + } + }, + "name": "consturctor" + }, + "value": { + "type": "FunctionExpression", + "id": null, + "generator": false, + "expression": false, + "async": false, + "body": { + "type": "BlockStatement", + "range": [ + 38, + 45 + ], + "loc": { + "start": { + "line": 2, + "column": 28 + }, + "end": { + "line": 3, + "column": 5 + } + }, + "body": [] + }, + "range": [ + 25, + 45 + ], + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 3, + "column": 5 + } + }, + "params": [ + { + "type": "ObjectPattern", + "range": [ + 26, + 36 + ], + "loc": { + "start": { + "line": 2, + "column": 16 + }, + "end": { + "line": 2, + "column": 26 + } + }, + "properties": [ + { + "type": "Property", + "range": [ + 27, + 30 + ], + "loc": { + "start": { + "line": 2, + "column": 17 + }, + "end": { + "line": 2, + "column": 20 + } + }, + "key": { + "type": "Identifier", + "range": [ + 27, + 30 + ], + "loc": { + "start": { + "line": 2, + "column": 17 + }, + "end": { + "line": 2, + "column": 20 + } + }, + "name": "foo" + }, + "value": { + "type": "Identifier", + "range": [ + 27, + 30 + ], + "loc": { + "start": { + "line": 2, + "column": 17 + }, + "end": { + "line": 2, + "column": 20 + } + }, + "name": "foo" + }, + "computed": false, + "method": false, + "shorthand": true, + "kind": "init" + }, + { + "type": "Property", + "range": [ + 32, + 35 + ], + "loc": { + "start": { + "line": 2, + "column": 22 + }, + "end": { + "line": 2, + "column": 25 + } + }, + "key": { + "type": "Identifier", + "range": [ + 32, + 35 + ], + "loc": { + "start": { + "line": 2, + "column": 22 + }, + "end": { + "line": 2, + "column": 25 + } + }, + "name": "bar" + }, + "value": { + "type": "Identifier", + "range": [ + 32, + 35 + ], + "loc": { + "start": { + "line": 2, + "column": 22 + }, + "end": { + "line": 2, + "column": 25 + } + }, + "name": "bar" + }, + "computed": false, + "method": false, + "shorthand": true, + "kind": "init" + } + ], + "decorators": [] + } + ] + }, + "computed": false, + "static": false, + "kind": "method", + "accessibility": null, + "decorators": [] + } + ], + "range": [ + 8, + 47 + ], + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 4, + "column": 1 + } + } + }, + "superClass": null, + "implements": [], + "decorators": [] + } + ], + "sourceType": "script", + "tokens": [ + { + "type": "Keyword", + "value": "class", + "range": [ + 0, + 5 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + } + }, + { + "type": "Identifier", + "value": "A", + "range": [ + 6, + 7 + ], + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + } + } + }, + { + "type": "Punctuator", + "value": "{", + "range": [ + 8, + 9 + ], + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 9 + } + } + }, + { + "type": "Identifier", + "value": "consturctor", + "range": [ + 14, + 25 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 15 + } + } + }, + { + "type": "Punctuator", + "value": "(", + "range": [ + 25, + 26 + ], + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 2, + "column": 16 + } + } + }, + { + "type": "Punctuator", + "value": "{", + "range": [ + 26, + 27 + ], + "loc": { + "start": { + "line": 2, + "column": 16 + }, + "end": { + "line": 2, + "column": 17 + } + } + }, + { + "type": "Identifier", + "value": "foo", + "range": [ + 27, + 30 + ], + "loc": { + "start": { + "line": 2, + "column": 17 + }, + "end": { + "line": 2, + "column": 20 + } + } + }, + { + "type": "Punctuator", + "value": ",", + "range": [ + 30, + 31 + ], + "loc": { + "start": { + "line": 2, + "column": 20 + }, + "end": { + "line": 2, + "column": 21 + } + } + }, + { + "type": "Identifier", + "value": "bar", + "range": [ + 32, + 35 + ], + "loc": { + "start": { + "line": 2, + "column": 22 + }, + "end": { + "line": 2, + "column": 25 + } + } + }, + { + "type": "Punctuator", + "value": "}", + "range": [ + 35, + 36 + ], + "loc": { + "start": { + "line": 2, + "column": 25 + }, + "end": { + "line": 2, + "column": 26 + } + } + }, + { + "type": "Punctuator", + "value": ")", + "range": [ + 36, + 37 + ], + "loc": { + "start": { + "line": 2, + "column": 26 + }, + "end": { + "line": 2, + "column": 27 + } + } + }, + { + "type": "Punctuator", + "value": "{", + "range": [ + 38, + 39 + ], + "loc": { + "start": { + "line": 2, + "column": 28 + }, + "end": { + "line": 2, + "column": 29 + } + } + }, + { + "type": "Punctuator", + "value": "}", + "range": [ + 44, + 45 + ], + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 5 + } + } + }, + { + "type": "Punctuator", + "value": "}", + "range": [ + 46, + 47 + ], + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + } + } + ] +}; diff --git a/tests/fixtures/ecma-features/destructuring/class-constructor-params-object.src.js b/tests/fixtures/ecma-features/destructuring/class-constructor-params-object.src.js new file mode 100644 index 0000000..49bb33c --- /dev/null +++ b/tests/fixtures/ecma-features/destructuring/class-constructor-params-object.src.js @@ -0,0 +1,4 @@ +class A { + consturctor({foo, bar}) { + } +} diff --git a/tests/fixtures/ecma-features/destructuring/class-method-params-array.result.js b/tests/fixtures/ecma-features/destructuring/class-method-params-array.result.js new file mode 100644 index 0000000..1848852 --- /dev/null +++ b/tests/fixtures/ecma-features/destructuring/class-method-params-array.result.js @@ -0,0 +1,468 @@ +module.exports = { + "type": "Program", + "range": [ + 0, + 39 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "body": [ + { + "type": "ClassDeclaration", + "range": [ + 0, + 39 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "range": [ + 6, + 7 + ], + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "name": "A" + }, + "body": { + "type": "ClassBody", + "body": [ + { + "type": "MethodDefinition", + "range": [ + 14, + 37 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 3, + "column": 5 + } + }, + "key": { + "type": "Identifier", + "range": [ + 14, + 17 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 7 + } + }, + "name": "foo" + }, + "value": { + "type": "FunctionExpression", + "id": null, + "generator": false, + "expression": false, + "async": false, + "body": { + "type": "BlockStatement", + "range": [ + 30, + 37 + ], + "loc": { + "start": { + "line": 2, + "column": 20 + }, + "end": { + "line": 3, + "column": 5 + } + }, + "body": [] + }, + "range": [ + 17, + 37 + ], + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 3, + "column": 5 + } + }, + "params": [ + { + "type": "ArrayPattern", + "range": [ + 18, + 28 + ], + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 18 + } + }, + "elements": [ + { + "type": "Identifier", + "range": [ + 19, + 22 + ], + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 12 + } + }, + "name": "bar" + }, + { + "type": "Identifier", + "range": [ + 24, + 27 + ], + "loc": { + "start": { + "line": 2, + "column": 14 + }, + "end": { + "line": 2, + "column": 17 + } + }, + "name": "baz" + } + ], + "decorators": [] + } + ] + }, + "computed": false, + "static": false, + "kind": "method", + "accessibility": null, + "decorators": [] + } + ], + "range": [ + 8, + 39 + ], + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 4, + "column": 1 + } + } + }, + "superClass": null, + "implements": [], + "decorators": [] + } + ], + "sourceType": "script", + "tokens": [ + { + "type": "Keyword", + "value": "class", + "range": [ + 0, + 5 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + } + }, + { + "type": "Identifier", + "value": "A", + "range": [ + 6, + 7 + ], + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + } + } + }, + { + "type": "Punctuator", + "value": "{", + "range": [ + 8, + 9 + ], + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 9 + } + } + }, + { + "type": "Identifier", + "value": "foo", + "range": [ + 14, + 17 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 7 + } + } + }, + { + "type": "Punctuator", + "value": "(", + "range": [ + 17, + 18 + ], + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 8 + } + } + }, + { + "type": "Punctuator", + "value": "[", + "range": [ + 18, + 19 + ], + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 9 + } + } + }, + { + "type": "Identifier", + "value": "bar", + "range": [ + 19, + 22 + ], + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 12 + } + } + }, + { + "type": "Punctuator", + "value": ",", + "range": [ + 22, + 23 + ], + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 13 + } + } + }, + { + "type": "Identifier", + "value": "baz", + "range": [ + 24, + 27 + ], + "loc": { + "start": { + "line": 2, + "column": 14 + }, + "end": { + "line": 2, + "column": 17 + } + } + }, + { + "type": "Punctuator", + "value": "]", + "range": [ + 27, + 28 + ], + "loc": { + "start": { + "line": 2, + "column": 17 + }, + "end": { + "line": 2, + "column": 18 + } + } + }, + { + "type": "Punctuator", + "value": ")", + "range": [ + 28, + 29 + ], + "loc": { + "start": { + "line": 2, + "column": 18 + }, + "end": { + "line": 2, + "column": 19 + } + } + }, + { + "type": "Punctuator", + "value": "{", + "range": [ + 30, + 31 + ], + "loc": { + "start": { + "line": 2, + "column": 20 + }, + "end": { + "line": 2, + "column": 21 + } + } + }, + { + "type": "Punctuator", + "value": "}", + "range": [ + 36, + 37 + ], + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 5 + } + } + }, + { + "type": "Punctuator", + "value": "}", + "range": [ + 38, + 39 + ], + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + } + } + ] +}; diff --git a/tests/fixtures/ecma-features/destructuring/class-method-params-array.src.js b/tests/fixtures/ecma-features/destructuring/class-method-params-array.src.js new file mode 100644 index 0000000..93e433f --- /dev/null +++ b/tests/fixtures/ecma-features/destructuring/class-method-params-array.src.js @@ -0,0 +1,4 @@ +class A { + foo([bar, baz]) { + } +} diff --git a/tests/fixtures/ecma-features/destructuring/class-method-params-defaults-array.result.js b/tests/fixtures/ecma-features/destructuring/class-method-params-defaults-array.result.js new file mode 100644 index 0000000..dee1037 --- /dev/null +++ b/tests/fixtures/ecma-features/destructuring/class-method-params-defaults-array.result.js @@ -0,0 +1,612 @@ +module.exports = { + "type": "Program", + "range": [ + 0, + 43 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "body": [ + { + "type": "ClassDeclaration", + "range": [ + 0, + 43 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "range": [ + 6, + 7 + ], + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "name": "A" + }, + "body": { + "type": "ClassBody", + "body": [ + { + "type": "MethodDefinition", + "range": [ + 14, + 41 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 3, + "column": 5 + } + }, + "key": { + "type": "Identifier", + "range": [ + 14, + 17 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 7 + } + }, + "name": "foo" + }, + "value": { + "type": "FunctionExpression", + "id": null, + "generator": false, + "expression": false, + "async": false, + "body": { + "type": "BlockStatement", + "range": [ + 34, + 41 + ], + "loc": { + "start": { + "line": 2, + "column": 24 + }, + "end": { + "line": 3, + "column": 5 + } + }, + "body": [] + }, + "range": [ + 17, + 41 + ], + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 3, + "column": 5 + } + }, + "params": [ + { + "type": "ArrayPattern", + "range": [ + 18, + 32 + ], + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 22 + } + }, + "elements": [ + { + "type": "AssignmentPattern", + "range": [ + 19, + 24 + ], + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 14 + } + }, + "left": { + "type": "Identifier", + "range": [ + 19, + 22 + ], + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 12 + } + }, + "name": "bar" + }, + "right": { + "type": "Literal", + "range": [ + 23, + 24 + ], + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 14 + } + }, + "value": 3, + "raw": "3" + } + }, + { + "type": "AssignmentPattern", + "range": [ + 26, + 31 + ], + "loc": { + "start": { + "line": 2, + "column": 16 + }, + "end": { + "line": 2, + "column": 21 + } + }, + "left": { + "type": "Identifier", + "range": [ + 26, + 29 + ], + "loc": { + "start": { + "line": 2, + "column": 16 + }, + "end": { + "line": 2, + "column": 19 + } + }, + "name": "baz" + }, + "right": { + "type": "Literal", + "range": [ + 30, + 31 + ], + "loc": { + "start": { + "line": 2, + "column": 20 + }, + "end": { + "line": 2, + "column": 21 + } + }, + "value": 4, + "raw": "4" + } + } + ], + "decorators": [] + } + ] + }, + "computed": false, + "static": false, + "kind": "method", + "accessibility": null, + "decorators": [] + } + ], + "range": [ + 8, + 43 + ], + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 4, + "column": 1 + } + } + }, + "superClass": null, + "implements": [], + "decorators": [] + } + ], + "sourceType": "script", + "tokens": [ + { + "type": "Keyword", + "value": "class", + "range": [ + 0, + 5 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + } + }, + { + "type": "Identifier", + "value": "A", + "range": [ + 6, + 7 + ], + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + } + } + }, + { + "type": "Punctuator", + "value": "{", + "range": [ + 8, + 9 + ], + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 9 + } + } + }, + { + "type": "Identifier", + "value": "foo", + "range": [ + 14, + 17 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 7 + } + } + }, + { + "type": "Punctuator", + "value": "(", + "range": [ + 17, + 18 + ], + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 8 + } + } + }, + { + "type": "Punctuator", + "value": "[", + "range": [ + 18, + 19 + ], + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 9 + } + } + }, + { + "type": "Identifier", + "value": "bar", + "range": [ + 19, + 22 + ], + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 12 + } + } + }, + { + "type": "Punctuator", + "value": "=", + "range": [ + 22, + 23 + ], + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 13 + } + } + }, + { + "type": "Numeric", + "value": "3", + "range": [ + 23, + 24 + ], + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 14 + } + } + }, + { + "type": "Punctuator", + "value": ",", + "range": [ + 24, + 25 + ], + "loc": { + "start": { + "line": 2, + "column": 14 + }, + "end": { + "line": 2, + "column": 15 + } + } + }, + { + "type": "Identifier", + "value": "baz", + "range": [ + 26, + 29 + ], + "loc": { + "start": { + "line": 2, + "column": 16 + }, + "end": { + "line": 2, + "column": 19 + } + } + }, + { + "type": "Punctuator", + "value": "=", + "range": [ + 29, + 30 + ], + "loc": { + "start": { + "line": 2, + "column": 19 + }, + "end": { + "line": 2, + "column": 20 + } + } + }, + { + "type": "Numeric", + "value": "4", + "range": [ + 30, + 31 + ], + "loc": { + "start": { + "line": 2, + "column": 20 + }, + "end": { + "line": 2, + "column": 21 + } + } + }, + { + "type": "Punctuator", + "value": "]", + "range": [ + 31, + 32 + ], + "loc": { + "start": { + "line": 2, + "column": 21 + }, + "end": { + "line": 2, + "column": 22 + } + } + }, + { + "type": "Punctuator", + "value": ")", + "range": [ + 32, + 33 + ], + "loc": { + "start": { + "line": 2, + "column": 22 + }, + "end": { + "line": 2, + "column": 23 + } + } + }, + { + "type": "Punctuator", + "value": "{", + "range": [ + 34, + 35 + ], + "loc": { + "start": { + "line": 2, + "column": 24 + }, + "end": { + "line": 2, + "column": 25 + } + } + }, + { + "type": "Punctuator", + "value": "}", + "range": [ + 40, + 41 + ], + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 5 + } + } + }, + { + "type": "Punctuator", + "value": "}", + "range": [ + 42, + 43 + ], + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + } + } + ] +}; diff --git a/tests/fixtures/ecma-features/destructuring/class-method-params-defaults-array.src.js b/tests/fixtures/ecma-features/destructuring/class-method-params-defaults-array.src.js new file mode 100644 index 0000000..d114585 --- /dev/null +++ b/tests/fixtures/ecma-features/destructuring/class-method-params-defaults-array.src.js @@ -0,0 +1,4 @@ +class A { + foo([bar=3, baz=4]) { + } +} diff --git a/tests/fixtures/ecma-features/destructuring/class-method-params-defaults-object.result.js b/tests/fixtures/ecma-features/destructuring/class-method-params-defaults-object.result.js new file mode 100644 index 0000000..d298fa7 --- /dev/null +++ b/tests/fixtures/ecma-features/destructuring/class-method-params-defaults-object.result.js @@ -0,0 +1,690 @@ +module.exports = { + "type": "Program", + "range": [ + 0, + 43 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "body": [ + { + "type": "ClassDeclaration", + "range": [ + 0, + 43 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "range": [ + 6, + 7 + ], + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "name": "A" + }, + "body": { + "type": "ClassBody", + "body": [ + { + "type": "MethodDefinition", + "range": [ + 14, + 41 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 3, + "column": 5 + } + }, + "key": { + "type": "Identifier", + "range": [ + 14, + 17 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 7 + } + }, + "name": "foo" + }, + "value": { + "type": "FunctionExpression", + "id": null, + "generator": false, + "expression": false, + "async": false, + "body": { + "type": "BlockStatement", + "range": [ + 34, + 41 + ], + "loc": { + "start": { + "line": 2, + "column": 24 + }, + "end": { + "line": 3, + "column": 5 + } + }, + "body": [] + }, + "range": [ + 17, + 41 + ], + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 3, + "column": 5 + } + }, + "params": [ + { + "type": "ObjectPattern", + "range": [ + 18, + 32 + ], + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 22 + } + }, + "properties": [ + { + "type": "Property", + "range": [ + 19, + 24 + ], + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 14 + } + }, + "key": { + "type": "Identifier", + "range": [ + 19, + 22 + ], + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 12 + } + }, + "name": "bar" + }, + "value": { + "type": "AssignmentPattern", + "left": { + "type": "Identifier", + "range": [ + 19, + 22 + ], + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 12 + } + }, + "name": "bar" + }, + "right": { + "type": "Literal", + "range": [ + 23, + 24 + ], + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 14 + } + }, + "value": 3, + "raw": "3" + }, + "range": [ + 19, + 24 + ], + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 14 + } + } + }, + "computed": false, + "method": false, + "shorthand": true, + "kind": "init" + }, + { + "type": "Property", + "range": [ + 26, + 31 + ], + "loc": { + "start": { + "line": 2, + "column": 16 + }, + "end": { + "line": 2, + "column": 21 + } + }, + "key": { + "type": "Identifier", + "range": [ + 26, + 29 + ], + "loc": { + "start": { + "line": 2, + "column": 16 + }, + "end": { + "line": 2, + "column": 19 + } + }, + "name": "baz" + }, + "value": { + "type": "AssignmentPattern", + "left": { + "type": "Identifier", + "range": [ + 26, + 29 + ], + "loc": { + "start": { + "line": 2, + "column": 16 + }, + "end": { + "line": 2, + "column": 19 + } + }, + "name": "baz" + }, + "right": { + "type": "Literal", + "range": [ + 30, + 31 + ], + "loc": { + "start": { + "line": 2, + "column": 20 + }, + "end": { + "line": 2, + "column": 21 + } + }, + "value": 3, + "raw": "3" + }, + "range": [ + 26, + 31 + ], + "loc": { + "start": { + "line": 2, + "column": 16 + }, + "end": { + "line": 2, + "column": 21 + } + } + }, + "computed": false, + "method": false, + "shorthand": true, + "kind": "init" + } + ], + "decorators": [] + } + ] + }, + "computed": false, + "static": false, + "kind": "method", + "accessibility": null, + "decorators": [] + } + ], + "range": [ + 8, + 43 + ], + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 4, + "column": 1 + } + } + }, + "superClass": null, + "implements": [], + "decorators": [] + } + ], + "sourceType": "script", + "tokens": [ + { + "type": "Keyword", + "value": "class", + "range": [ + 0, + 5 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + } + }, + { + "type": "Identifier", + "value": "A", + "range": [ + 6, + 7 + ], + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + } + } + }, + { + "type": "Punctuator", + "value": "{", + "range": [ + 8, + 9 + ], + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 9 + } + } + }, + { + "type": "Identifier", + "value": "foo", + "range": [ + 14, + 17 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 7 + } + } + }, + { + "type": "Punctuator", + "value": "(", + "range": [ + 17, + 18 + ], + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 8 + } + } + }, + { + "type": "Punctuator", + "value": "{", + "range": [ + 18, + 19 + ], + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 9 + } + } + }, + { + "type": "Identifier", + "value": "bar", + "range": [ + 19, + 22 + ], + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 12 + } + } + }, + { + "type": "Punctuator", + "value": "=", + "range": [ + 22, + 23 + ], + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 13 + } + } + }, + { + "type": "Numeric", + "value": "3", + "range": [ + 23, + 24 + ], + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 14 + } + } + }, + { + "type": "Punctuator", + "value": ",", + "range": [ + 24, + 25 + ], + "loc": { + "start": { + "line": 2, + "column": 14 + }, + "end": { + "line": 2, + "column": 15 + } + } + }, + { + "type": "Identifier", + "value": "baz", + "range": [ + 26, + 29 + ], + "loc": { + "start": { + "line": 2, + "column": 16 + }, + "end": { + "line": 2, + "column": 19 + } + } + }, + { + "type": "Punctuator", + "value": "=", + "range": [ + 29, + 30 + ], + "loc": { + "start": { + "line": 2, + "column": 19 + }, + "end": { + "line": 2, + "column": 20 + } + } + }, + { + "type": "Numeric", + "value": "3", + "range": [ + 30, + 31 + ], + "loc": { + "start": { + "line": 2, + "column": 20 + }, + "end": { + "line": 2, + "column": 21 + } + } + }, + { + "type": "Punctuator", + "value": "}", + "range": [ + 31, + 32 + ], + "loc": { + "start": { + "line": 2, + "column": 21 + }, + "end": { + "line": 2, + "column": 22 + } + } + }, + { + "type": "Punctuator", + "value": ")", + "range": [ + 32, + 33 + ], + "loc": { + "start": { + "line": 2, + "column": 22 + }, + "end": { + "line": 2, + "column": 23 + } + } + }, + { + "type": "Punctuator", + "value": "{", + "range": [ + 34, + 35 + ], + "loc": { + "start": { + "line": 2, + "column": 24 + }, + "end": { + "line": 2, + "column": 25 + } + } + }, + { + "type": "Punctuator", + "value": "}", + "range": [ + 40, + 41 + ], + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 5 + } + } + }, + { + "type": "Punctuator", + "value": "}", + "range": [ + 42, + 43 + ], + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + } + } + ] +}; diff --git a/tests/fixtures/ecma-features/destructuring/class-method-params-defaults-object.src.js b/tests/fixtures/ecma-features/destructuring/class-method-params-defaults-object.src.js new file mode 100644 index 0000000..ff1eb4c --- /dev/null +++ b/tests/fixtures/ecma-features/destructuring/class-method-params-defaults-object.src.js @@ -0,0 +1,4 @@ +class A { + foo({bar=3, baz=3}) { + } +} diff --git a/tests/fixtures/ecma-features/destructuring/class-method-params-object.result.js b/tests/fixtures/ecma-features/destructuring/class-method-params-object.result.js new file mode 100644 index 0000000..4782cb4 --- /dev/null +++ b/tests/fixtures/ecma-features/destructuring/class-method-params-object.result.js @@ -0,0 +1,546 @@ +module.exports = { + "type": "Program", + "range": [ + 0, + 39 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "body": [ + { + "type": "ClassDeclaration", + "range": [ + 0, + 39 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "range": [ + 6, + 7 + ], + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "name": "A" + }, + "body": { + "type": "ClassBody", + "body": [ + { + "type": "MethodDefinition", + "range": [ + 14, + 37 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 3, + "column": 5 + } + }, + "key": { + "type": "Identifier", + "range": [ + 14, + 17 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 7 + } + }, + "name": "foo" + }, + "value": { + "type": "FunctionExpression", + "id": null, + "generator": false, + "expression": false, + "async": false, + "body": { + "type": "BlockStatement", + "range": [ + 30, + 37 + ], + "loc": { + "start": { + "line": 2, + "column": 20 + }, + "end": { + "line": 3, + "column": 5 + } + }, + "body": [] + }, + "range": [ + 17, + 37 + ], + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 3, + "column": 5 + } + }, + "params": [ + { + "type": "ObjectPattern", + "range": [ + 18, + 28 + ], + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 18 + } + }, + "properties": [ + { + "type": "Property", + "range": [ + 19, + 22 + ], + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 12 + } + }, + "key": { + "type": "Identifier", + "range": [ + 19, + 22 + ], + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 12 + } + }, + "name": "bar" + }, + "value": { + "type": "Identifier", + "range": [ + 19, + 22 + ], + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 12 + } + }, + "name": "bar" + }, + "computed": false, + "method": false, + "shorthand": true, + "kind": "init" + }, + { + "type": "Property", + "range": [ + 24, + 27 + ], + "loc": { + "start": { + "line": 2, + "column": 14 + }, + "end": { + "line": 2, + "column": 17 + } + }, + "key": { + "type": "Identifier", + "range": [ + 24, + 27 + ], + "loc": { + "start": { + "line": 2, + "column": 14 + }, + "end": { + "line": 2, + "column": 17 + } + }, + "name": "baz" + }, + "value": { + "type": "Identifier", + "range": [ + 24, + 27 + ], + "loc": { + "start": { + "line": 2, + "column": 14 + }, + "end": { + "line": 2, + "column": 17 + } + }, + "name": "baz" + }, + "computed": false, + "method": false, + "shorthand": true, + "kind": "init" + } + ], + "decorators": [] + } + ] + }, + "computed": false, + "static": false, + "kind": "method", + "accessibility": null, + "decorators": [] + } + ], + "range": [ + 8, + 39 + ], + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 4, + "column": 1 + } + } + }, + "superClass": null, + "implements": [], + "decorators": [] + } + ], + "sourceType": "script", + "tokens": [ + { + "type": "Keyword", + "value": "class", + "range": [ + 0, + 5 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + } + }, + { + "type": "Identifier", + "value": "A", + "range": [ + 6, + 7 + ], + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + } + } + }, + { + "type": "Punctuator", + "value": "{", + "range": [ + 8, + 9 + ], + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 9 + } + } + }, + { + "type": "Identifier", + "value": "foo", + "range": [ + 14, + 17 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 7 + } + } + }, + { + "type": "Punctuator", + "value": "(", + "range": [ + 17, + 18 + ], + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 8 + } + } + }, + { + "type": "Punctuator", + "value": "{", + "range": [ + 18, + 19 + ], + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 9 + } + } + }, + { + "type": "Identifier", + "value": "bar", + "range": [ + 19, + 22 + ], + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 12 + } + } + }, + { + "type": "Punctuator", + "value": ",", + "range": [ + 22, + 23 + ], + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 13 + } + } + }, + { + "type": "Identifier", + "value": "baz", + "range": [ + 24, + 27 + ], + "loc": { + "start": { + "line": 2, + "column": 14 + }, + "end": { + "line": 2, + "column": 17 + } + } + }, + { + "type": "Punctuator", + "value": "}", + "range": [ + 27, + 28 + ], + "loc": { + "start": { + "line": 2, + "column": 17 + }, + "end": { + "line": 2, + "column": 18 + } + } + }, + { + "type": "Punctuator", + "value": ")", + "range": [ + 28, + 29 + ], + "loc": { + "start": { + "line": 2, + "column": 18 + }, + "end": { + "line": 2, + "column": 19 + } + } + }, + { + "type": "Punctuator", + "value": "{", + "range": [ + 30, + 31 + ], + "loc": { + "start": { + "line": 2, + "column": 20 + }, + "end": { + "line": 2, + "column": 21 + } + } + }, + { + "type": "Punctuator", + "value": "}", + "range": [ + 36, + 37 + ], + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 5 + } + } + }, + { + "type": "Punctuator", + "value": "}", + "range": [ + 38, + 39 + ], + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + } + } + ] +}; diff --git a/tests/fixtures/ecma-features/destructuring/class-method-params-object.src.js b/tests/fixtures/ecma-features/destructuring/class-method-params-object.src.js new file mode 100644 index 0000000..32683cf --- /dev/null +++ b/tests/fixtures/ecma-features/destructuring/class-method-params-object.src.js @@ -0,0 +1,4 @@ +class A { + foo({bar, baz}) { + } +} diff --git a/tests/fixtures/ecma-features/restParams/class-constructor.result.js b/tests/fixtures/ecma-features/restParams/class-constructor.result.js new file mode 100644 index 0000000..ef7b72e --- /dev/null +++ b/tests/fixtures/ecma-features/restParams/class-constructor.result.js @@ -0,0 +1,393 @@ +module.exports = { + "type": "Program", + "range": [ + 0, + 43 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "body": [ + { + "type": "ClassDeclaration", + "range": [ + 0, + 43 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "range": [ + 6, + 7 + ], + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "name": "A" + }, + "body": { + "type": "ClassBody", + "body": [ + { + "type": "MethodDefinition", + "range": [ + 14, + 41 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 3, + "column": 5 + } + }, + "key": { + "type": "Identifier", + "name": "constructor", + "range": [ + 14, + 25 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 15 + } + } + }, + "value": { + "type": "FunctionExpression", + "id": null, + "params": [ + { + "type": "RestElement", + "range": [ + 26, + 32 + ], + "loc": { + "start": { + "line": 2, + "column": 16 + }, + "end": { + "line": 2, + "column": 22 + } + }, + "argument": { + "type": "Identifier", + "range": [ + 29, + 32 + ], + "loc": { + "start": { + "line": 2, + "column": 19 + }, + "end": { + "line": 2, + "column": 22 + } + }, + "name": "foo" + }, + "decorators": [] + } + ], + "generator": false, + "expression": false, + "async": false, + "body": { + "type": "BlockStatement", + "range": [ + 34, + 41 + ], + "loc": { + "start": { + "line": 2, + "column": 24 + }, + "end": { + "line": 3, + "column": 5 + } + }, + "body": [] + }, + "range": [ + 25, + 41 + ], + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 3, + "column": 5 + } + } + }, + "computed": false, + "accessibility": null, + "static": false, + "kind": "constructor" + } + ], + "range": [ + 8, + 43 + ], + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 4, + "column": 1 + } + } + }, + "superClass": null, + "implements": [], + "decorators": [] + } + ], + "sourceType": "script", + "tokens": [ + { + "type": "Keyword", + "value": "class", + "range": [ + 0, + 5 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + } + }, + { + "type": "Identifier", + "value": "A", + "range": [ + 6, + 7 + ], + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + } + } + }, + { + "type": "Punctuator", + "value": "{", + "range": [ + 8, + 9 + ], + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 9 + } + } + }, + { + "type": "Identifier", + "value": "constructor", + "range": [ + 14, + 25 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 15 + } + } + }, + { + "type": "Punctuator", + "value": "(", + "range": [ + 25, + 26 + ], + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 2, + "column": 16 + } + } + }, + { + "type": "Punctuator", + "value": "...", + "range": [ + 26, + 29 + ], + "loc": { + "start": { + "line": 2, + "column": 16 + }, + "end": { + "line": 2, + "column": 19 + } + } + }, + { + "type": "Identifier", + "value": "foo", + "range": [ + 29, + 32 + ], + "loc": { + "start": { + "line": 2, + "column": 19 + }, + "end": { + "line": 2, + "column": 22 + } + } + }, + { + "type": "Punctuator", + "value": ")", + "range": [ + 32, + 33 + ], + "loc": { + "start": { + "line": 2, + "column": 22 + }, + "end": { + "line": 2, + "column": 23 + } + } + }, + { + "type": "Punctuator", + "value": "{", + "range": [ + 34, + 35 + ], + "loc": { + "start": { + "line": 2, + "column": 24 + }, + "end": { + "line": 2, + "column": 25 + } + } + }, + { + "type": "Punctuator", + "value": "}", + "range": [ + 40, + 41 + ], + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 5 + } + } + }, + { + "type": "Punctuator", + "value": "}", + "range": [ + 42, + 43 + ], + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + } + } + ] +}; diff --git a/tests/fixtures/ecma-features/restParams/class-constructor.src.js b/tests/fixtures/ecma-features/restParams/class-constructor.src.js new file mode 100644 index 0000000..03407bf --- /dev/null +++ b/tests/fixtures/ecma-features/restParams/class-constructor.src.js @@ -0,0 +1,4 @@ +class A { + constructor(...foo) { + } +} diff --git a/tests/fixtures/ecma-features/restParams/class-method.result.js b/tests/fixtures/ecma-features/restParams/class-method.result.js new file mode 100644 index 0000000..ecac0c2 --- /dev/null +++ b/tests/fixtures/ecma-features/restParams/class-method.result.js @@ -0,0 +1,394 @@ +module.exports = { + "type": "Program", + "range": [ + 0, + 35 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "body": [ + { + "type": "ClassDeclaration", + "range": [ + 0, + 35 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "range": [ + 6, + 7 + ], + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "name": "A" + }, + "body": { + "type": "ClassBody", + "body": [ + { + "type": "MethodDefinition", + "range": [ + 14, + 33 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 3, + "column": 5 + } + }, + "key": { + "type": "Identifier", + "range": [ + 14, + 17 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 7 + } + }, + "name": "foo" + }, + "value": { + "type": "FunctionExpression", + "id": null, + "generator": false, + "expression": false, + "async": false, + "body": { + "type": "BlockStatement", + "range": [ + 26, + 33 + ], + "loc": { + "start": { + "line": 2, + "column": 16 + }, + "end": { + "line": 3, + "column": 5 + } + }, + "body": [] + }, + "range": [ + 17, + 33 + ], + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 3, + "column": 5 + } + }, + "params": [ + { + "type": "RestElement", + "range": [ + 18, + 24 + ], + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 14 + } + }, + "argument": { + "type": "Identifier", + "range": [ + 21, + 24 + ], + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 14 + } + }, + "name": "bar" + }, + "decorators": [] + } + ] + }, + "computed": false, + "static": false, + "kind": "method", + "accessibility": null, + "decorators": [] + } + ], + "range": [ + 8, + 35 + ], + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 4, + "column": 1 + } + } + }, + "superClass": null, + "implements": [], + "decorators": [] + } + ], + "sourceType": "script", + "tokens": [ + { + "type": "Keyword", + "value": "class", + "range": [ + 0, + 5 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + } + }, + { + "type": "Identifier", + "value": "A", + "range": [ + 6, + 7 + ], + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + } + } + }, + { + "type": "Punctuator", + "value": "{", + "range": [ + 8, + 9 + ], + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 9 + } + } + }, + { + "type": "Identifier", + "value": "foo", + "range": [ + 14, + 17 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 7 + } + } + }, + { + "type": "Punctuator", + "value": "(", + "range": [ + 17, + 18 + ], + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 8 + } + } + }, + { + "type": "Punctuator", + "value": "...", + "range": [ + 18, + 21 + ], + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 11 + } + } + }, + { + "type": "Identifier", + "value": "bar", + "range": [ + 21, + 24 + ], + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 14 + } + } + }, + { + "type": "Punctuator", + "value": ")", + "range": [ + 24, + 25 + ], + "loc": { + "start": { + "line": 2, + "column": 14 + }, + "end": { + "line": 2, + "column": 15 + } + } + }, + { + "type": "Punctuator", + "value": "{", + "range": [ + 26, + 27 + ], + "loc": { + "start": { + "line": 2, + "column": 16 + }, + "end": { + "line": 2, + "column": 17 + } + } + }, + { + "type": "Punctuator", + "value": "}", + "range": [ + 32, + 33 + ], + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 5 + } + } + }, + { + "type": "Punctuator", + "value": "}", + "range": [ + 34, + 35 + ], + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + } + } + ] +}; diff --git a/tests/fixtures/ecma-features/restParams/class-method.src.js b/tests/fixtures/ecma-features/restParams/class-method.src.js new file mode 100644 index 0000000..4831937 --- /dev/null +++ b/tests/fixtures/ecma-features/restParams/class-method.src.js @@ -0,0 +1,4 @@ +class A { + foo(...bar) { + } +}