Chromium Code Reviews| Index: test/cctest/test-parsing.cc |
| diff --git a/test/cctest/test-parsing.cc b/test/cctest/test-parsing.cc |
| index 57671c0d9e11907e8bbeaec4f8f5fdb3ab087fee..cb21f0c0c2b4522af9177bafd1cbe74f1afa2df0 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,114 @@ TEST(ErrorsSuper) { |
| RunParserSyncTest(context_data, statement_data, kError, NULL, 0, |
| always_flags, ARRAY_SIZE(always_flags)); |
| } |
| + |
| + |
| +TEST(NoErrorsMethodDefinition) { |
| + const char* context_data[][2] = {{"({", "});"}, |
|
marja
2014/08/22 08:22:46
Is there a reason why you do
({ stuff });
and no
rossberg
2014/08/22 09:34:31
Yes, because then it would be a block, not an obje
|
| + {NULL, NULL}}; |
| + |
| + const char* statement_data[] = { |
|
rossberg
2014/08/22 09:34:31
Nit: statement_data seems like the wrong name in t
arv (Not doing code reviews)
2014/08/22 23:16:03
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, statement_data, kSuccess, NULL, 0, |
| + always_flags, ARRAY_SIZE(always_flags)); |
| +} |
| + |
| + |
| +TEST(MethodDefinitionNames) { |
| + const char* context_data[][2] = {{"({", "(x, y) {}});"}, |
| + {NULL, NULL}}; |
| + |
| + const char* statement_data[] = { |
|
rossberg
2014/08/22 09:34:31
Nit: name_data?
arv (Not doing code reviews)
2014/08/22 23:16:03
Done.
|
| + "m", |
| + "'m'", |
| + "\"m\"", |
| + "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, statement_data, kSuccess, NULL, 0, |
| + always_flags, ARRAY_SIZE(always_flags)); |
| +} |
| + |
| + |
| +TEST(MethodDefinitionstrictFormalParamereters) { |
| + const char* context_data[][2] = {{"({method(", "){}});"}, |
| + {NULL, NULL}}; |
| + |
| + const char* statement_data[] = { |
|
rossberg
2014/08/22 09:34:31
Nit: parameter_data?
arv (Not doing code reviews)
2014/08/22 23:16:03
Done.
|
| + "x, x", |
| + "x, y, x", |
| + "eval", |
| + "arguments", |
| + "var", |
| + "const", |
| + NULL |
| + }; |
| + |
| + static const ParserFlag always_flags[] = {kAllowHarmonyObjectLiterals}; |
| + RunParserSyncTest(context_data, statement_data, kError, NULL, 0, |
| + always_flags, ARRAY_SIZE(always_flags)); |
| +} |