| 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));
|
| +}
|
|
|