[Pkg-javascript-commits] [node-acorn-jsx] 308/484: Add support for computed static mutator class methods
Bastien Roucariès
rouca at moszumanska.debian.org
Sat Aug 19 14:20:48 UTC 2017
This is an automated email from the git hooks/post-receive script.
rouca pushed a commit to branch master
in repository node-acorn-jsx.
commit a18f3d10037c4adba0f0de8b16472ee5feeb9524
Author: Sebastian McKenzie <sebmck at gmail.com>
Date: Tue Nov 4 11:40:49 2014 +1100
Add support for computed static mutator class methods
---
acorn.js | 2 +-
test/tests-harmony.js | 153 ++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 154 insertions(+), 1 deletion(-)
diff --git a/acorn.js b/acorn.js
index 401b942..d94aee2 100644
--- a/acorn.js
+++ b/acorn.js
@@ -2402,7 +2402,7 @@
}
var isGenerator = eat(_star);
parsePropertyName(method);
- if (tokType === _name && !method.computed && method.key.type === "Identifier" &&
+ if (tokType !== _parenL && !method.computed && method.key.type === "Identifier" &&
(method.key.name === "get" || method.key.name === "set")) {
if (isGenerator) unexpected();
method.kind = method.key.name;
diff --git a/test/tests-harmony.js b/test/tests-harmony.js
index 539418f..2302f58 100644
--- a/test/tests-harmony.js
+++ b/test/tests-harmony.js
@@ -8304,6 +8304,159 @@ test("class A { static get foo() {} static set foo(v) {} get foo() {} set foo(v)
locations: true
});
+
+test("class A { static [foo]() {} }", {
+ type: "Program",
+ loc: {
+ start: {line: 1, column: 0},
+ end: {line: 1, column: 29}
+ },
+ body: [{
+ type: "ClassDeclaration",
+ loc: {
+ start: {line: 1, column: 0},
+ end: {line: 1, column: 29}
+ },
+ id: {
+ type: "Identifier",
+ loc: {
+ start: {line: 1, column: 6},
+ end: {line: 1, column: 7}
+ },
+ name: "A"
+ },
+ superClass: null,
+ body: {
+ type: "ClassBody",
+ loc: {
+ start: {line: 1, column: 8},
+ end: {line: 1, column: 29}
+ },
+ body: [{
+ type: "MethodDefinition",
+ loc: {
+ start: {line: 1, column: 10},
+ end: {line: 1, column: 27}
+ },
+ static: true,
+ computed: true,
+ key: {
+ type: "Identifier",
+ loc: {
+ start: {line: 1, column: 18},
+ end: {line: 1, column: 21}
+ },
+ name: "foo"
+ },
+ kind: "",
+ value: {
+ type: "FunctionExpression",
+ loc: {
+ start: {line: 1, column: 22},
+ end: {line: 1, column: 27}
+ },
+ id: null,
+ params: [],
+ defaults: [],
+ rest: null,
+ generator: false,
+ body: {
+ type: "BlockStatement",
+ loc: {
+ start: {line: 1, column: 25},
+ end: {line: 1, column: 27}
+ },
+ body: []
+ },
+ expression: false
+ }
+ }]
+ }
+ }]
+}, {
+ ecmaVersion: 6,
+ ranges: true,
+ locations: true
+});
+
+test("class A { static get [foo]() {} }", {
+ type: "Program",
+ loc: {
+ start: {line: 1, column: 0},
+ end: {line: 1, column: 33}
+ },
+ body: [{
+ type: "ClassDeclaration",
+ loc: {
+ start: {line: 1, column: 0},
+ end: {line: 1, column: 33}
+ },
+ 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: 33}
+ },
+ body: [{
+ type: "MethodDefinition",
+ loc: {
+ start: {line: 1, column: 10},
+ end: {line: 1, column: 31}
+ },
+ static: true,
+ computed: true,
+ key: {
+ type: "Identifier",
+ loc: {
+ start: {line: 1, column: 22},
+ end: {line: 1, column: 25}
+ },
+ name: "foo"
+ },
+ kind: "get",
+ value: {
+ type: "FunctionExpression",
+ loc: {
+ start: {line: 1, column: 26},
+ end: {line: 1, column: 31}
+ },
+ id: null,
+ params: [],
+ defaults: [],
+ rest: null,
+ generator: false,
+ body: {
+ type: "BlockStatement",
+ loc: {
+ start: {line: 1, column: 29},
+ end: {line: 1, column: 31}
+ },
+ body: []
+ },
+ expression: false
+ }
+ }]
+ }
+ }]
+}, {
+ ecmaVersion: 6,
+ ranges: true,
+ locations: true
+});
+
test("class A { set foo(v) {} get foo() {} }", {
type: "Program",
body: [{
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-acorn-jsx.git
More information about the Pkg-javascript-commits
mailing list