Chromium Code Reviews| Index: test/cctest/test-parsing.cc |
| diff --git a/test/cctest/test-parsing.cc b/test/cctest/test-parsing.cc |
| index d0a516a7df4f8e5b2e60f6dead67905314e2c721..8eb07b2bcf7fa4318ecc51b150172df69d153c39 100644 |
| --- a/test/cctest/test-parsing.cc |
| +++ b/test/cctest/test-parsing.cc |
| @@ -3502,20 +3502,23 @@ TEST(ErrorsArrowFunctions) { |
| "(x, (y, z)) => 0", |
| "((x, y), z) => 0", |
| - // Parameter lists are always validated as strict, so those are errors. |
| - "eval => {}", |
| - "arguments => {}", |
| - "yield => {}", |
| - "interface => {}", |
| - "(eval) => {}", |
| - "(arguments) => {}", |
| - "(yield) => {}", |
| - "(interface) => {}", |
| - "(eval, bar) => {}", |
| - "(bar, eval) => {}", |
| - "(bar, arguments) => {}", |
| - "(bar, yield) => {}", |
| - "(bar, interface) => {}", |
| + // Arrow function formal parameters are parsed as StrictFormalParameters, |
| + // which confusingly only implies that there are no duplicates. Words |
| + // reserved in strict mode, and eval or arguments, are indeed valid in |
| + // sloppy mode. |
| + "eval => { \"use strict\"; 0 }", |
|
arv (Not doing code reviews)
2015/04/13 18:26:38
\" -> ' for readability
|
| + "arguments => { \"use strict\"; 0 }", |
| + "yield => { \"use strict\"; 0 }", |
| + "interface => { \"use strict\"; 0 }", |
| + "(eval) => { \"use strict\"; 0 }", |
| + "(arguments) => { \"use strict\"; 0 }", |
| + "(yield) => { \"use strict\"; 0 }", |
| + "(interface) => { \"use strict\"; 0 }", |
| + "(eval, bar) => { \"use strict\"; 0 }", |
| + "(bar, eval) => { \"use strict\"; 0 }", |
| + "(bar, arguments) => { \"use strict\"; 0 }", |
| + "(bar, yield) => { \"use strict\"; 0 }", |
| + "(bar, interface) => { \"use strict\"; 0 }", |
| // TODO(aperez): Detecting duplicates does not work in PreParser. |
| // "(bar, bar) => {}", |
| @@ -3622,6 +3625,62 @@ TEST(NoErrorsArrowFunctions) { |
| } |
| +TEST(ArrowFunctionsSloppyParameterNames) { |
| + const char* strong_context_data[][2] = { |
| + {"\"use strong\"; ", ";"}, |
| + {"\"use strong\"; bar ? (", ") : baz;"}, |
| + {"\"use strong\"; bar ? baz : (", ");"}, |
| + {"\"use strong\"; bar, ", ";"}, |
| + {"\"use strong\"; ", ", bar;"}, |
| + {NULL, NULL} |
| + }; |
| + |
| + const char* strict_context_data[][2] = { |
| + {"\"use strict\"; ", ";"}, |
| + {"\"use strict\"; bar ? (", ") : baz;"}, |
| + {"\"use strict\"; bar ? baz : (", ");"}, |
| + {"\"use strict\"; bar, ", ";"}, |
| + {"\"use strict\"; ", ", bar;"}, |
| + {NULL, NULL} |
| + }; |
| + |
| + const char* sloppy_context_data[][2] = { |
| + {"", ";"}, |
| + {"bar ? (", ") : baz;"}, |
| + {"bar ? baz : (", ");"}, |
| + {"bar, ", ";"}, |
| + {"", ", bar;"}, |
| + {NULL, NULL} |
| + }; |
| + |
| + const char* statement_data[] = { |
| + "eval => {}", |
| + "arguments => {}", |
| + "yield => {}", |
| + "interface => {}", |
| + "(eval) => {}", |
| + "(arguments) => {}", |
| + "(yield) => {}", |
| + "(interface) => {}", |
| + "(eval, bar) => {}", |
| + "(bar, eval) => {}", |
| + "(bar, arguments) => {}", |
| + "(bar, yield) => {}", |
| + "(bar, interface) => {}", |
| + NULL |
| + }; |
| + |
| + static const ParserFlag always_flags[] = { kAllowHarmonyArrowFunctions, |
| + kAllowStrongMode}; |
| + RunParserSyncTest(strong_context_data, statement_data, kError, NULL, 0, |
| + always_flags, arraysize(always_flags)); |
| + RunParserSyncTest(strict_context_data, statement_data, kError, NULL, 0, |
| + always_flags, arraysize(always_flags)); |
| + RunParserSyncTest(sloppy_context_data, statement_data, kSuccess, NULL, 0, |
| + always_flags, arraysize(always_flags)); |
| +} |
| + |
| + |
| TEST(SuperNoErrors) { |
| // Tests that parser and preparser accept 'super' keyword in right places. |
| const char* context_data[][2] = { |