Index: test/cctest/test-parsing.cc |
diff --git a/test/cctest/test-parsing.cc b/test/cctest/test-parsing.cc |
index 57671c0d9e11907e8bbeaec4f8f5fdb3ab087fee..ec4f2f7ce0093ec1dd92a81b19d09cdd0fab0aeb 100644 |
--- a/test/cctest/test-parsing.cc |
+++ b/test/cctest/test-parsing.cc |
@@ -1211,7 +1211,8 @@ enum ParserFlag { |
kAllowGenerators, |
kAllowHarmonyNumericLiterals, |
kAllowArrowFunctions, |
- kAllowClasses |
+ kAllowClasses, |
+ kAllowHarmonyObjectLiterals |
}; |
@@ -1231,6 +1232,8 @@ void SetParserFlags(i::ParserBase<Traits>* parser, |
parser->set_allow_generators(flags.Contains(kAllowGenerators)); |
parser->set_allow_harmony_numeric_literals( |
flags.Contains(kAllowHarmonyNumericLiterals)); |
+ parser->set_allow_harmony_object_literals( |
+ flags.Contains(kAllowHarmonyObjectLiterals)); |
parser->set_allow_arrow_functions(flags.Contains(kAllowArrowFunctions)); |
parser->set_allow_classes(flags.Contains(kAllowClasses)); |
} |
@@ -1437,9 +1440,11 @@ TEST(ParserSync) { |
CcTest::i_isolate()->stack_guard()->SetStackLimit(GetCurrentStackPosition() - |
128 * 1024); |
- static const ParserFlag flags1[] = {kAllowLazy, kAllowHarmonyScoping, |
- kAllowModules, kAllowGenerators, |
- kAllowArrowFunctions}; |
+ static const ParserFlag flags1[] = { |
+ kAllowLazy, kAllowHarmonyScoping, |
+ kAllowModules, kAllowGenerators, |
+ kAllowArrowFunctions, kAllowHarmonyNumericLiterals, |
+ kAllowHarmonyObjectLiterals}; |
for (int i = 0; context_data[i][0] != NULL; ++i) { |
for (int j = 0; statement_data[j] != NULL; ++j) { |
for (int k = 0; termination_data[k] != NULL; ++k) { |
@@ -1514,9 +1519,12 @@ void RunParserSyncTest(const char* context_data[][2], |
128 * 1024); |
static const ParserFlag default_flags[] = { |
- kAllowLazy, kAllowHarmonyScoping, kAllowModules, |
- kAllowGenerators, kAllowNativesSyntax, kAllowArrowFunctions, |
- kAllowClasses}; |
+ kAllowArrowFunctions, kAllowClasses, |
+ kAllowGenerators, kAllowHarmonyNumericLiterals, |
+ kAllowHarmonyObjectLiterals, kAllowHarmonyScoping, |
+ kAllowLazy, kAllowModules, |
+ kAllowNativesSyntax, |
+ }; |
ParserFlag* generated_flags = NULL; |
if (flags == NULL) { |
flags = default_flags; |
@@ -3380,3 +3388,142 @@ TEST(ErrorsSuper) { |
RunParserSyncTest(context_data, statement_data, kError, NULL, 0, |
always_flags, ARRAY_SIZE(always_flags)); |
} |
+ |
+ |
+TEST(NoErrorsMethodDefinition) { |
+ const char* context_data[][2] = {{"({", "});"}, |
+ {NULL, NULL}}; |
+ |
+ const char* object_literal_data[] = { |
rossberg
2014/08/25 09:39:30
Hm, well, it's not really object literals in there
arv (Not doing code reviews)
2014/09/09 22:24:27
Done.
|
+ "m() {}", |
+ "m(x) { return x; }", |
+ "m(x, y) {}, n() {}", |
+ "set(x, y) {}", |
+ "get(x, y) {}", |
+ NULL |
+ }; |
+ |
+ static const ParserFlag always_flags[] = {kAllowHarmonyObjectLiterals}; |
+ RunParserSyncTest(context_data, object_literal_data, kSuccess, NULL, 0, |
+ always_flags, ARRAY_SIZE(always_flags)); |
+} |
+ |
+ |
+TEST(MethodDefinitionNames) { |
+ const char* context_data[][2] = {{"({", "(x, y) {}});"}, |
+ {"'use strict'; ({", "(x, y) {}});"}, |
rossberg
2014/08/25 09:39:30
Good idea, you should probably add that to your ot
arv (Not doing code reviews)
2014/09/09 22:24:27
Done.
|
+ {NULL, NULL}}; |
+ |
+ const char* name_data[] = { |
+ "m", |
+ "'m'", |
+ "\"m\"", |
+ "\"m n\"", |
+ "true", |
+ "false", |
+ "null", |
+ "0", |
+ "1.2", |
+ "1e1", |
+ "1E1", |
+ "1e+1", |
+ "1e-1", |
+ |
+ // Keywords |
+ "async", |
+ "await", |
+ "break", |
+ "case", |
+ "catch", |
+ "class", |
+ "const", |
+ "continue", |
+ "debugger", |
+ "default", |
+ "delete", |
+ "do", |
+ "else", |
+ "enum", |
+ "export", |
+ "extends", |
+ "finally", |
+ "for", |
+ "function", |
+ "if", |
+ "implements", |
+ "import", |
+ "in", |
+ "instanceof", |
+ "interface", |
+ "let", |
+ "new", |
+ "package", |
+ "private", |
+ "protected", |
+ "public", |
+ "return", |
+ "static", |
+ "super", |
+ "switch", |
+ "this", |
+ "throw", |
+ "try", |
+ "typeof", |
+ "var", |
+ "void", |
+ "while", |
+ "with", |
+ "yield", |
+ NULL |
+ }; |
+ |
+ static const ParserFlag always_flags[] = {kAllowHarmonyObjectLiterals}; |
+ RunParserSyncTest(context_data, name_data, kSuccess, NULL, 0, |
+ always_flags, ARRAY_SIZE(always_flags)); |
+} |
+ |
+ |
+TEST(MethodDefinitionStrictFormalParamereters) { |
+ const char* context_data[][2] = {{"({method(", "){}});"}, |
+ {NULL, NULL}}; |
+ |
+ const char* params_data[] = { |
+ "x, x", |
+ "x, y, x", |
+ "eval", |
+ "arguments", |
+ "var", |
+ "const", |
+ NULL |
+ }; |
+ |
+ static const ParserFlag always_flags[] = {kAllowHarmonyObjectLiterals}; |
+ RunParserSyncTest(context_data, params_data, kError, NULL, 0, |
+ always_flags, ARRAY_SIZE(always_flags)); |
+} |
+ |
+ |
+TEST(MethodDefinitionDuplicateProperty) { |
+ // Duplicate properties are allowed in ES6 but we haven't removed that check |
+ // yet. |
+ const char* context_data[][2] = {{"'use strict'; ({", "});"}, |
+ {NULL, NULL}}; |
+ |
+ const char* params_data[] = { |
+ "x: 1, x() {}", |
+ "x() {}, x: 1", |
+ "x() {}, get x() {}", |
+ "x() {}, set x(_) {}", |
+ "x() {}, x() {}", |
+ "x() {}, y() {}, x() {}", |
+ "x() {}, \"x\"() {}", |
+ "x() {}, 'x'() {}", |
+ "0() {}, '0'() {}", |
+ "1.0() {}, 1: 1", |
+ NULL |
+ }; |
+ |
+ static const ParserFlag always_flags[] = {kAllowHarmonyObjectLiterals}; |
+ RunParserSyncTest(context_data, params_data, kError, NULL, 0, |
+ always_flags, ARRAY_SIZE(always_flags)); |
+} |