diff --git a/test/acorn/tests-babel.js b/test/acorn/tests-babel.js index 71cfa9813b..5b429aba26 100644 --- a/test/acorn/tests-babel.js +++ b/test/acorn/tests-babel.js @@ -3255,6 +3255,65 @@ test("function log(n, op, val,) { }", { features: { "es7.trailingFunctionCommas": true } }); +test("class Foo { bar(a,) { } }", { + type: "Program", + start: 0, + end: 25, + body: [{ + type: "ClassDeclaration", + start: 0, + end: 25, + id: { + type: "Identifier", + name: "Foo", + start: 6, + end: 9 + }, + superClass: null, + body: { + type: "ClassBody", + start: 10, + end: 25, + body: [{ + type: "MethodDefinition", + start: 12, + end: 23, + static: false, + key: { + type: "Identifier", + start: 12, + end: 15, + name: "bar" + }, + kind: "method", + value: { + type: "FunctionExpression", + start: 15, + end: 23, + id: null, + params: [{ + type: "Identifier", + name: "a", + start: 16, + end: 17 + }], + generator: false, + body: { + type: "BlockStatement", + start: 20, + end: 23, + body: [] + }, + expression: false + } + }] + } + }] +}, { + ecmaVersion: 7, + features: { "es7.trailingFunctionCommas": true } +}); + testFail("log(,);", "Unexpected token (1:4)", { ecmaVersion: 7, features: { "es7.trailingFunctionCommas": true }