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

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

Issue 798243004: ES6 computed property names (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Disable test on windows Created 5 years, 11 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/x64/full-codegen-x64.cc ('k') | test/mjsunit/harmony/computed-property-names.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 ef6b5d30c497550b5536b5831ef4d110fe915ab8..f08f9b31d901eb4c1b0483d4f2426d8437a8104f 100644
--- a/test/cctest/test-parsing.cc
+++ b/test/cctest/test-parsing.cc
@@ -1358,7 +1358,8 @@ enum ParserFlag {
kAllowHarmonyObjectLiterals,
kAllowHarmonyTemplates,
kAllowHarmonySloppy,
- kAllowHarmonyUnicode
+ kAllowHarmonyUnicode,
+ kAllowHarmonyComputedPropertyNames
};
@@ -1385,6 +1386,8 @@ void SetParserFlags(i::ParserBase<Traits>* parser,
parser->set_allow_harmony_templates(flags.Contains(kAllowHarmonyTemplates));
parser->set_allow_harmony_sloppy(flags.Contains(kAllowHarmonySloppy));
parser->set_allow_harmony_unicode(flags.Contains(kAllowHarmonyUnicode));
+ parser->set_allow_harmony_computed_property_names(
+ flags.Contains(kAllowHarmonyComputedPropertyNames));
}
@@ -4582,3 +4585,61 @@ TEST(LexicalScopingSloppyMode) {
always_true_flags, arraysize(always_true_flags),
always_false_flags, arraysize(always_false_flags));
}
+
+
+TEST(ComputedPropertyName) {
+ const char* context_data[][2] = {{"({[", "]: 1});"},
+ {"({get [", "]() {}});"},
+ {"({set [", "](_) {}});"},
+ {"({[", "]() {}});"},
+ {"({*[", "]() {}});"},
+ {"(class {get [", "]() {}});"},
+ {"(class {set [", "](_) {}});"},
+ {"(class {[", "]() {}});"},
+ {"(class {*[", "]() {}});"},
+ {NULL, NULL}};
+ const char* error_data[] = {
+ "1, 2",
+ "var name",
+ NULL};
+
+ static const ParserFlag always_flags[] = {
+ kAllowHarmonyClasses,
+ kAllowHarmonyComputedPropertyNames,
+ kAllowHarmonyObjectLiterals,
+ kAllowHarmonySloppy,
+ };
+ RunParserSyncTest(context_data, error_data, kError, NULL, 0,
+ always_flags, arraysize(always_flags));
+
+ const char* name_data[] = {
+ "1",
+ "1 + 2",
+ "'name'",
+ "\"name\"",
+ "[]",
+ "{}",
+ NULL};
+
+ RunParserSyncTest(context_data, name_data, kSuccess, NULL, 0,
+ always_flags, arraysize(always_flags));
+}
+
+
+TEST(ComputedPropertyNameShorthandError) {
+ const char* context_data[][2] = {{"({", "});"},
+ {NULL, NULL}};
+ const char* error_data[] = {
+ "a: 1, [2]",
+ "[1], a: 1",
+ NULL};
+
+ static const ParserFlag always_flags[] = {
+ kAllowHarmonyClasses,
+ kAllowHarmonyComputedPropertyNames,
+ kAllowHarmonyObjectLiterals,
+ kAllowHarmonySloppy,
+ };
+ RunParserSyncTest(context_data, error_data, kError, NULL, 0,
+ always_flags, arraysize(always_flags));
+}
« no previous file with comments | « src/x64/full-codegen-x64.cc ('k') | test/mjsunit/harmony/computed-property-names.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698