Reviewers: marja, rossberg,
Description:
Test that trailing commas in object literals are allowed
ES6 will allow trailing commas in object literals. It turns out that V8
already allowed it, too, as does JSC and SpiderMonkey.
[email protected], [email protected]
BUG=
Please review this at https://codereview.chromium.org/350353002/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files (+6, -1 lines):
M src/preparser.h
M test/cctest/test-parsing.cc
Index: src/preparser.h
diff --git a/src/preparser.h b/src/preparser.h
index
753ff1bf3ee0a5b88a90f9d2d10a863f6a4831ec..7994a52eba264b85f62715f6a36bbfbae71b7a4c
100644
--- a/src/preparser.h
+++ b/src/preparser.h
@@ -1543,7 +1543,7 @@ typename ParserBase<Traits>::ExpressionT
ParserBase<Traits>::ParseObjectLiteral(
// ((IdentifierName | String | Number) ':' AssignmentExpression) |
// (('get' | 'set') (IdentifierName | String | Number)
FunctionLiteral)
// ) ',')* '}'
- // (Except that trailing comma is not required and not allowed.)
+ // (Except that the trailing comma is not required.)
int pos = peek_position();
typename Traits::Type::PropertyList properties =
Index: test/cctest/test-parsing.cc
diff --git a/test/cctest/test-parsing.cc b/test/cctest/test-parsing.cc
index
858354dc836e3b087004b8cedefe28fa783a3fb3..857089ea0662ca374051c07ae000c8da59a04a77
100644
--- a/test/cctest/test-parsing.cc
+++ b/test/cctest/test-parsing.cc
@@ -2240,10 +2240,12 @@ TEST(ErrorsNewExpression) {
TEST(StrictObjectLiteralChecking) {
const char* strict_context_data[][2] = {
{"\"use strict\"; var myobject = {", "};"},
+ {"\"use strict\"; var myobject = {", ",};"},
{ NULL, NULL }
};
const char* non_strict_context_data[][2] = {
{"var myobject = {", "};"},
+ {"var myobject = {", ",};"},
{ NULL, NULL }
};
@@ -2272,6 +2274,7 @@ TEST(ErrorsObjectLiteralChecking) {
};
const char* statement_data[] = {
+ ",",
"foo: 1, get foo() {}",
"foo: 1, set foo(v) {}",
"\"foo\": 1, get \"foo\"() {}",
@@ -2307,7 +2310,9 @@ TEST(ErrorsObjectLiteralChecking) {
TEST(NoErrorsObjectLiteralChecking) {
const char* context_data[][2] = {
{"var myobject = {", "};"},
+ {"var myobject = {", ",};"},
{"\"use strict\"; var myobject = {", "};"},
+ {"\"use strict\"; var myobject = {", ",};"},
{ NULL, NULL }
};
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.