Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(56)

Unified Diff: test/cctest/test-parsing.cc

Issue 477263002: ES6: Add support for method shorthand in object literals (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: test/cctest/test-parsing.cc
diff --git a/test/cctest/test-parsing.cc b/test/cctest/test-parsing.cc
index 31651904e3a2ca7dc42862bba55188d9de89b1e6..939bd4bb8513bdbabb98890278863f4f6e215001 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;
@@ -3392,3 +3400,29 @@ 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* statement_data[] = {"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[] = {"m", "'m'", "\"m\"", "true", "false",
+ "null", "0", "1.2", "1e1", "1E1",
+ "1e+1", "1e-1", NULL};
+
+ static const ParserFlag always_flags[] = {kAllowHarmonyObjectLiterals};
+ RunParserSyncTest(context_data, statement_data, kSuccess, NULL, 0,
+ always_flags, ARRAY_SIZE(always_flags));
+}

Powered by Google App Engine
This is Rietveld 408576698