Chromium Code Reviews| Index: test/cctest/test-parsing.cc |
| diff --git a/test/cctest/test-parsing.cc b/test/cctest/test-parsing.cc |
| index ff0026d2bda1f85964df73db61aa642232e2b4c0..50f32620840958275d47eaeb9a312c159faa4e01 100644 |
| --- a/test/cctest/test-parsing.cc |
| +++ b/test/cctest/test-parsing.cc |
| @@ -1509,6 +1509,7 @@ enum ParserFlag { |
| kNoLegacyConst, |
| kAllowHarmonyFunctionSent, |
| kAllowHarmonyRestrictiveDeclarations, |
| + kAllowHarmonyExponentiationOperator |
| }; |
| enum ParserSyncTestResult { |
| @@ -1529,6 +1530,8 @@ void SetParserFlags(i::ParserBase<Traits>* parser, |
| flags.Contains(kAllowHarmonyFunctionSent)); |
| parser->set_allow_harmony_restrictive_declarations( |
| flags.Contains(kAllowHarmonyRestrictiveDeclarations)); |
| + parser->set_allow_harmony_exponentiation_operator( |
| + flags.Contains(kAllowHarmonyExponentiationOperator)); |
| } |
| @@ -7301,3 +7304,89 @@ TEST(FunctionDeclarationError) { |
| RunParserSyncTest(sloppy_context, sloppy_data, kSuccess, restrictive_flags, |
| arraysize(restrictive_flags)); |
| } |
| + |
| +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", |
|
Dan Ehrenberg
2016/03/14 20:48:46
Could you add parsing tests for **=, including in
caitp (gmail)
2016/03/14 21:05:14
Done.
|
| + NULL |
| + }; |
| + // clang-format on |
| + |
| + static const ParserFlag always_flags[] = { |
| + kAllowHarmonyExponentiationOperator}; |
| + RunParserSyncTest(context_data, error_data, kError, NULL, 0, always_flags, |
| + arraysize(always_flags)); |
| +} |