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

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

Issue 584993002: ES6: Implement object literal property shorthand (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: git rebase Created 6 years, 3 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
« no previous file with comments | « src/token.h ('k') | test/mjsunit/harmony/object-literals-property-shorthand.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-parsing.cc
diff --git a/test/cctest/test-parsing.cc b/test/cctest/test-parsing.cc
index 72f2298042956d13861f7e319d5e9a971b1acfa1..3556c649f11bcc9bfef78dbc70d1210749e22f97 100644
--- a/test/cctest/test-parsing.cc
+++ b/test/cctest/test-parsing.cc
@@ -3969,3 +3969,121 @@ TEST(ClassesAreStrictErrors) {
RunParserSyncTest(context_data, class_body_data, kError, NULL, 0,
always_flags, arraysize(always_flags));
}
+
+
+TEST(ObjectLiteralPropertyShorthandKeywordsError) {
+ const char* context_data[][2] = {{"({", "});"},
+ {"'use strict'; ({", "});"},
+ {NULL, NULL}};
+
+ const char* name_data[] = {
+ "break",
+ "case",
+ "catch",
+ "class",
+ "const",
+ "continue",
+ "debugger",
+ "default",
+ "delete",
+ "do",
+ "else",
+ "enum",
+ "export",
+ "extends",
+ "false",
+ "finally",
+ "for",
+ "function",
+ "if",
+ "import",
+ "in",
+ "instanceof",
+ "new",
+ "null",
+ "return",
+ "super",
+ "switch",
+ "this",
+ "throw",
+ "true",
+ "try",
+ "typeof",
+ "var",
+ "void",
+ "while",
+ "with",
+ NULL
+ };
+
+ static const ParserFlag always_flags[] = {kAllowHarmonyObjectLiterals};
+ RunParserSyncTest(context_data, name_data, kError, NULL, 0,
+ always_flags, arraysize(always_flags));
+}
+
+
+TEST(ObjectLiteralPropertyShorthandStrictKeywords) {
+ const char* context_data[][2] = {{"({", "});"},
+ {NULL, NULL}};
+
+ const char* name_data[] = {
+ "implements",
+ "interface",
+ "let",
+ "package",
+ "private",
+ "protected",
+ "public",
+ "static",
+ "yield",
+ NULL
+ };
+
+ static const ParserFlag always_flags[] = {kAllowHarmonyObjectLiterals};
+ RunParserSyncTest(context_data, name_data, kSuccess, NULL, 0,
+ always_flags, arraysize(always_flags));
+
+ const char* context_strict_data[][2] = {{"'use strict'; ({", "});"},
+ {NULL, NULL}};
+ RunParserSyncTest(context_strict_data, name_data, kError, NULL, 0,
+ always_flags, arraysize(always_flags));
+}
+
+
+TEST(ObjectLiteralPropertyShorthandError) {
+ const char* context_data[][2] = {{"({", "});"},
+ {"'use strict'; ({", "});"},
+ {NULL, NULL}};
+
+ const char* name_data[] = {
+ "1",
+ "1.2",
+ "0",
+ "0.1",
+ "1.0",
+ "1e1",
+ "0x1",
+ "\"s\"",
+ "'s'",
+ NULL
+ };
+
+ static const ParserFlag always_flags[] = {kAllowHarmonyObjectLiterals};
+ RunParserSyncTest(context_data, name_data, kError, NULL, 0,
+ always_flags, arraysize(always_flags));
+}
+
+
+TEST(ObjectLiteralPropertyShorthandYieldInGeneratorError) {
+ const char* context_data[][2] = {{"", ""},
+ {NULL, NULL}};
+
+ const char* name_data[] = {
+ "function* g() { ({yield}); }",
+ NULL
+ };
+
+ static const ParserFlag always_flags[] = {kAllowHarmonyObjectLiterals};
+ RunParserSyncTest(context_data, name_data, kError, NULL, 0,
+ always_flags, arraysize(always_flags));
+}
« no previous file with comments | « src/token.h ('k') | test/mjsunit/harmony/object-literals-property-shorthand.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698