Add failing test for trailing commas in methods

This commit is contained in:
Amjad Masad
2015-05-12 13:19:21 -07:00
parent d11099bb2b
commit 462ff572b3

View File

@@ -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 }