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

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

Issue 949763003: WIP: new.target (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 10 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 a62504f23c11585aa6798695ccd2d692e69c5cbb..caad31143de881320098d40361f06b9b207d9ab3 100644
--- a/test/cctest/test-parsing.cc
+++ b/test/cctest/test-parsing.cc
@@ -1384,6 +1384,7 @@ enum ParserFlag {
kAllowHarmonyClasses,
kAllowHarmonyObjectLiterals,
kAllowHarmonyRestParameters,
+ kAllowHarmonyNewTarget,
kAllowHarmonyTemplates,
kAllowHarmonySloppy,
kAllowHarmonyUnicode,
@@ -1415,6 +1416,8 @@ void SetParserFlags(i::ParserBase<Traits>* parser,
parser->set_allow_harmony_templates(flags.Contains(kAllowHarmonyTemplates));
parser->set_allow_harmony_rest_params(
flags.Contains(kAllowHarmonyRestParameters));
+ parser->set_allow_harmony_new_target(
+ flags.Contains(kAllowHarmonyNewTarget));
parser->set_allow_harmony_sloppy(flags.Contains(kAllowHarmonySloppy));
parser->set_allow_harmony_unicode(flags.Contains(kAllowHarmonyUnicode));
parser->set_allow_harmony_computed_property_names(
@@ -5511,3 +5514,55 @@ TEST(StrongForIn) {
RunParserSyncTest(strong_context_data, data, kError, NULL, 0, always_flags,
arraysize(always_flags));
}
+
+
+TEST(NewTarget) {
+ const char* bad_context_data[][2] = {
+ {"", ""},
+ {"'use strict';", ""},
+ {NULL}
+ };
+ const char* good_context_data[][2] = {
+ {"function f() {", "}"},
+ {"'use strict'; function f() {", "}"},
+ {"var f = function() {", "}"},
+ {"'use strict'; var f = function() {", "}"},
+ {"({m: function() {", "}})"},
+ {"'use strict'; ({m: function() {", "}})"},
+ {"({m() {", "}})"},
+ {"'use strict'; ({m() {", "}})"},
+ {"({get x() {", "}})"},
+ {"'use strict'; ({get x() {", "}})"},
+ {"({set x(_) {", "}})"},
+ {"'use strict'; ({set x(_) {", "}})"},
+ {"class C {m() {", "}}"},
+ {"class C {get x() {", "}}"},
+ {"class C {set x(_) {", "}}"},
+ {NULL}
+ };
+
+ const char* data[] = {
+ "new.target",
+ "{ new.target }",
+ "() => { new.target }",
+ "() => new.target",
+ "if (1) { new.target }",
+ "if (1) {} else { new.target }",
+ "while (0) { new.target }",
+ "do { new.target } while (0)",
+ NULL
+ };
+
+ static const ParserFlag always_flags[] = {
+ kAllowHarmonyArrowFunctions,
+ kAllowHarmonyClasses,
+ kAllowHarmonyNewTarget,
+ kAllowHarmonyObjectLiterals,
+ kAllowHarmonySloppy,
+ };
+
+ RunParserSyncTest(bad_context_data, data, kError, NULL, 0, always_flags,
+ arraysize(always_flags));
+ RunParserSyncTest(good_context_data, data, kSuccess, NULL, 0, always_flags,
+ arraysize(always_flags));
+}
« src/scopes.cc ('K') | « src/scopes.cc ('k') | test/mjsunit/harmony/new-target.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698