| Index: test/cctest/test-parsing.cc
|
| diff --git a/test/cctest/test-parsing.cc b/test/cctest/test-parsing.cc
|
| index b04fb94d3ac92801f23ef9b44ecade040319e1a8..4e524d4fc04578974d132d6b39f18f9d6f01cdb1 100644
|
| --- a/test/cctest/test-parsing.cc
|
| +++ b/test/cctest/test-parsing.cc
|
| @@ -1511,7 +1511,8 @@ enum ParserFlag {
|
| kAllowHarmonyNewTarget,
|
| kAllowStrongMode,
|
| kNoLegacyConst,
|
| - kAllowHarmonyFunctionSent
|
| + kAllowHarmonyFunctionSent,
|
| + kAllowHarmonyExponentiationOperator
|
| };
|
|
|
| enum ParserSyncTestResult {
|
| @@ -1537,6 +1538,8 @@ void SetParserFlags(i::ParserBase<Traits>* parser,
|
| parser->set_allow_legacy_const(!flags.Contains(kNoLegacyConst));
|
| parser->set_allow_harmony_function_sent(
|
| flags.Contains(kAllowHarmonyFunctionSent));
|
| + parser->set_allow_harmony_exponentiation_operator(
|
| + flags.Contains(kAllowHarmonyExponentiationOperator));
|
| }
|
|
|
|
|
| @@ -7988,3 +7991,89 @@ TEST(NewTargetErrors) {
|
| // clang-format on
|
| RunParserSyncTest(context_data, error_data, kError);
|
| }
|
| +
|
| +TEST(ExponentiationOperator) {
|
| + // clang-format off
|
| + const char* context_data[][2] = {
|
| + { "var O = { p: 1 }, x = 10; ; if (", ") { foo(); }" },
|
| + { "var O = { p: 1 }, x = 10; ; (", ")" },
|
| + { "var O = { p: 1 }, x = 10; foo(", ")" },
|
| + { NULL, NULL }
|
| + };
|
| + const char* data[] = {
|
| + "(delete O.p) ** 10",
|
| + "(delete x) ** 10",
|
| + "(~O.p) ** 10",
|
| + "(~x) ** 10",
|
| + "(!O.p) ** 10",
|
| + "(!x) ** 10",
|
| + "(+O.p) ** 10",
|
| + "(+x) ** 10",
|
| + "(-O.p) ** 10",
|
| + "(-x) ** 10",
|
| + "(typeof O.p) ** 10",
|
| + "(typeof x) ** 10",
|
| + "(void 0) ** 10",
|
| + "(void O.p) ** 10",
|
| + "(void x) ** 10",
|
| + "++O.p ** 10",
|
| + "++x ** 10",
|
| + "--O.p ** 10",
|
| + "--x ** 10",
|
| + "O.p++ ** 10",
|
| + "x++ ** 10",
|
| + "O.p-- ** 10",
|
| + "x-- ** 10",
|
| + NULL
|
| + };
|
| + // clang-format on
|
| +
|
| + static const ParserFlag always_flags[] = {
|
| + kAllowHarmonyExponentiationOperator};
|
| + RunParserSyncTest(context_data, data, kSuccess, NULL, 0, always_flags,
|
| + arraysize(always_flags));
|
| +}
|
| +
|
| +TEST(ExponentiationOperatorErrors) {
|
| + // clang-format off
|
| + const char* context_data[][2] = {
|
| + { "var O = { p: 1 }, x = 10; ; if (", ") { foo(); }" },
|
| + { "var O = { p: 1 }, x = 10; ; (", ")" },
|
| + { "var O = { p: 1 }, x = 10; foo(", ")" },
|
| + { NULL, NULL }
|
| + };
|
| + const char* error_data[] = {
|
| + "delete O.p ** 10",
|
| + "delete x ** 10",
|
| + "~O.p ** 10",
|
| + "~x ** 10",
|
| + "!O.p ** 10",
|
| + "!x ** 10",
|
| + "+O.p ** 10",
|
| + "+x ** 10",
|
| + "-O.p ** 10",
|
| + "-x ** 10",
|
| + "typeof O.p ** 10",
|
| + "typeof x ** 10",
|
| + "void ** 10",
|
| + "void O.p ** 10",
|
| + "void x ** 10",
|
| + "++delete O.p ** 10",
|
| + "--delete O.p ** 10",
|
| + "++~O.p ** 10",
|
| + "++~x ** 10",
|
| + "--!O.p ** 10",
|
| + "--!x ** 10",
|
| + "++-O.p ** 10",
|
| + "++-x ** 10",
|
| + "--+O.p ** 10",
|
| + "--+x ** 10",
|
| + NULL
|
| + };
|
| + // clang-format on
|
| +
|
| + static const ParserFlag always_flags[] = {
|
| + kAllowHarmonyExponentiationOperator};
|
| + RunParserSyncTest(context_data, error_data, kError, NULL, 0, always_flags,
|
| + arraysize(always_flags));
|
| +}
|
|
|