| Index: test/cctest/test-parsing.cc
|
| diff --git a/test/cctest/test-parsing.cc b/test/cctest/test-parsing.cc
|
| index 6ec9edd672b16d4e1d31e641f873885aeb61eeab..8a1e42986a41d6fa9fee062a925ec82c5bd38074 100644
|
| --- a/test/cctest/test-parsing.cc
|
| +++ b/test/cctest/test-parsing.cc
|
| @@ -286,7 +286,6 @@ TEST(StandAlonePreParser) {
|
| "function foo(x, y) { return x + y; }",
|
| "%ArgleBargle(glop);",
|
| "var x = new new Function('this.x = 42');",
|
| - "var f = (x, y) => x + y;",
|
| NULL
|
| };
|
|
|
| @@ -303,7 +302,6 @@ TEST(StandAlonePreParser) {
|
| i::PreParser preparser(&scanner, &log, stack_limit);
|
| preparser.set_allow_lazy(true);
|
| preparser.set_allow_natives_syntax(true);
|
| - preparser.set_allow_arrow_functions(true);
|
| i::PreParser::PreParseResult result = preparser.PreParseProgram();
|
| CHECK_EQ(i::PreParser::kPreParseSuccess, result);
|
| CHECK(!log.HasError());
|
| @@ -1187,8 +1185,7 @@ enum ParserFlag {
|
| kAllowModules,
|
| kAllowGenerators,
|
| kAllowForOf,
|
| - kAllowHarmonyNumericLiterals,
|
| - kAllowArrowFunctions
|
| + kAllowHarmonyNumericLiterals
|
| };
|
|
|
|
|
| @@ -1209,7 +1206,6 @@ void SetParserFlags(i::ParserBase<Traits>* parser,
|
| parser->set_allow_for_of(flags.Contains(kAllowForOf));
|
| parser->set_allow_harmony_numeric_literals(
|
| flags.Contains(kAllowHarmonyNumericLiterals));
|
| - parser->set_allow_arrow_functions(flags.Contains(kAllowArrowFunctions));
|
| }
|
|
|
|
|
| @@ -1416,7 +1412,7 @@ TEST(ParserSync) {
|
|
|
| static const ParserFlag flags1[] = {
|
| kAllowLazy, kAllowHarmonyScoping, kAllowModules, kAllowGenerators,
|
| - kAllowForOf, kAllowArrowFunctions
|
| + kAllowForOf
|
| };
|
| for (int i = 0; context_data[i][0] != NULL; ++i) {
|
| for (int j = 0; statement_data[j] != NULL; ++j) {
|
| @@ -1493,7 +1489,7 @@ void RunParserSyncTest(const char* context_data[][2],
|
|
|
| static const ParserFlag default_flags[] = {
|
| kAllowLazy, kAllowHarmonyScoping, kAllowModules, kAllowGenerators,
|
| - kAllowForOf, kAllowNativesSyntax, kAllowArrowFunctions
|
| + kAllowForOf, kAllowNativesSyntax
|
| };
|
| ParserFlag* generated_flags = NULL;
|
| if (flags == NULL) {
|
| @@ -1570,10 +1566,6 @@ TEST(ErrorsEvalAndArguments) {
|
| "function foo(arguments) { }",
|
| "function foo(bar, eval) { }",
|
| "function foo(bar, arguments) { }",
|
| - "(eval) => { }",
|
| - "(arguments) => { }",
|
| - "(foo, eval) => { }",
|
| - "(foo, arguments) => { }",
|
| "eval = 1;",
|
| "arguments = 1;",
|
| "var foo = eval = 1;",
|
| @@ -1630,7 +1622,6 @@ TEST(NoErrorsEvalAndArgumentsStrict) {
|
| const char* context_data[][2] = {
|
| { "\"use strict\";", "" },
|
| { "function test_func() { \"use strict\";", "}" },
|
| - { "() => { \"use strict\"; ", "}" },
|
| { NULL, NULL }
|
| };
|
|
|
| @@ -1646,9 +1637,7 @@ TEST(NoErrorsEvalAndArgumentsStrict) {
|
| NULL
|
| };
|
|
|
| - static const ParserFlag always_flags[] = {kAllowArrowFunctions};
|
| - RunParserSyncTest(context_data, statement_data, kSuccess, NULL, 0,
|
| - always_flags, ARRAY_SIZE(always_flags));
|
| + RunParserSyncTest(context_data, statement_data, kSuccess);
|
| }
|
|
|
|
|
| @@ -1660,7 +1649,6 @@ TEST(ErrorsFutureStrictReservedWords) {
|
| const char* context_data[][2] = {
|
| { "\"use strict\";", "" },
|
| { "function test_func() {\"use strict\"; ", "}"},
|
| - { "() => { \"use strict\"; ", "}" },
|
| { NULL, NULL }
|
| };
|
|
|
| @@ -1679,9 +1667,7 @@ TEST(ErrorsFutureStrictReservedWords) {
|
| NULL
|
| };
|
|
|
| - static const ParserFlag always_flags[] = {kAllowArrowFunctions};
|
| - RunParserSyncTest(context_data, statement_data, kError, NULL, 0, always_flags,
|
| - ARRAY_SIZE(always_flags));
|
| + RunParserSyncTest(context_data, statement_data, kError);
|
| }
|
|
|
|
|
| @@ -1689,7 +1675,6 @@ TEST(NoErrorsFutureStrictReservedWords) {
|
| const char* context_data[][2] = {
|
| { "", "" },
|
| { "function test_func() {", "}"},
|
| - { "() => {", "}" },
|
| { NULL, NULL }
|
| };
|
|
|
| @@ -1708,9 +1693,7 @@ TEST(NoErrorsFutureStrictReservedWords) {
|
| NULL
|
| };
|
|
|
| - static const ParserFlag always_flags[] = {kAllowArrowFunctions};
|
| - RunParserSyncTest(context_data, statement_data, kSuccess, NULL, 0,
|
| - always_flags, ARRAY_SIZE(always_flags));
|
| + RunParserSyncTest(context_data, statement_data, kSuccess);
|
| }
|
|
|
|
|
| @@ -1723,8 +1706,6 @@ TEST(ErrorsReservedWords) {
|
| { "\"use strict\";", "" },
|
| { "var eval; function test_func() {", "}"},
|
| { "var eval; function test_func() {\"use strict\"; ", "}"},
|
| - { "var eval; () => {", "}"},
|
| - { "var eval; () => {\"use strict\"; ", "}"},
|
| { NULL, NULL }
|
| };
|
|
|
| @@ -1735,8 +1716,6 @@ TEST(ErrorsReservedWords) {
|
| "function super() { }",
|
| "function foo(super) { }",
|
| "function foo(bar, super) { }",
|
| - "(super) => { }",
|
| - "(bar, super) => { }",
|
| "super = 1;",
|
| "var foo = super = 1;",
|
| "++super;",
|
| @@ -1870,7 +1849,6 @@ TEST(ErrorsYieldStrict) {
|
| { "\"use strict\"; function * gen() { function not_gen() {", "} }" },
|
| { "\"use strict\"; (function not_gen() {", "})" },
|
| { "\"use strict\"; (function * gen() { (function not_gen() {", "}) })" },
|
| - { "() => {\"use strict\"; ", "}" },
|
| { NULL, NULL }
|
| };
|
|
|
| @@ -2081,7 +2059,6 @@ TEST(ErrorsIllegalWordsAsLabelsSloppy) {
|
| const char* context_data[][2] = {
|
| { "", ""},
|
| { "function test_func() {", "}" },
|
| - { "() => {", "}" },
|
| { NULL, NULL }
|
| };
|
|
|
| @@ -2099,7 +2076,6 @@ TEST(ErrorsIllegalWordsAsLabelsStrict) {
|
| const char* context_data[][2] = {
|
| { "\"use strict\";", "" },
|
| { "function test_func() {\"use strict\"; ", "}"},
|
| - { "() => {\"use strict\"; ", "}" },
|
| { NULL, NULL }
|
| };
|
|
|
| @@ -2119,10 +2095,8 @@ TEST(NoErrorsIllegalWordsAsLabels) {
|
| const char* context_data[][2] = {
|
| { "", ""},
|
| { "function test_func() {", "}" },
|
| - { "() => {", "}" },
|
| { "\"use strict\";", "" },
|
| { "\"use strict\"; function test_func() {", "}" },
|
| - { "\"use strict\"; () => {", "}" },
|
| { NULL, NULL }
|
| };
|
|
|
| @@ -2133,9 +2107,7 @@ TEST(NoErrorsIllegalWordsAsLabels) {
|
| NULL
|
| };
|
|
|
| - static const ParserFlag always_flags[] = {kAllowArrowFunctions};
|
| - RunParserSyncTest(context_data, statement_data, kSuccess, NULL, 0,
|
| - always_flags, ARRAY_SIZE(always_flags));
|
| + RunParserSyncTest(context_data, statement_data, kSuccess);
|
| }
|
|
|
|
|
| @@ -2144,7 +2116,6 @@ TEST(ErrorsParenthesizedLabels) {
|
| const char* context_data[][2] = {
|
| { "", ""},
|
| { "function test_func() {", "}" },
|
| - { "() => {", "}" },
|
| { NULL, NULL }
|
| };
|
|
|
| @@ -2985,160 +2956,3 @@ TEST(UseAsmUseCount) {
|
| "function bar() { \"use asm\"; var baz = 1; }");
|
| CHECK_EQ(2, use_counts[v8::Isolate::kUseAsm]);
|
| }
|
| -
|
| -
|
| -TEST(ErrorsArrowFunctions) {
|
| - // Tests that parser and preparser generate the same kind of errors
|
| - // on invalid arrow function syntax.
|
| - const char* context_data[][2] = {
|
| - {"", ";"},
|
| - {"v = ", ";"},
|
| - {"bar ? (", ") : baz;"},
|
| - {"bar ? baz : (", ");"},
|
| - {"bar[", "];"},
|
| - {"bar, ", ";"},
|
| - {"", ", bar;"},
|
| - {NULL, NULL}
|
| - };
|
| -
|
| - const char* statement_data[] = {
|
| - "=> 0",
|
| - "=>",
|
| - "() =>",
|
| - "=> {}",
|
| - ") => {}",
|
| - ", => {}",
|
| - "(,) => {}",
|
| - "return => {}",
|
| - "() => {'value': 42}",
|
| -
|
| - // Check that the early return introduced in ParsePrimaryExpression
|
| - // does not accept stray closing parentheses.
|
| - ")",
|
| - ") => 0",
|
| - "foo[()]",
|
| - "()",
|
| -
|
| - // Parameter lists with extra parens should be recognized as errors.
|
| - "(()) => 0",
|
| - "((x)) => 0",
|
| - "((x, y)) => 0",
|
| - "(x, (y)) => 0",
|
| - "((x, y, z)) => 0",
|
| - "(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) => {}",
|
| - // TODO(aperez): Detecting duplicates does not work in PreParser.
|
| - // "(bar, bar) => {}",
|
| -
|
| - // The parameter list is parsed as an expression, but only
|
| - // a comma-separated list of identifier is valid.
|
| - "32 => {}",
|
| - "(32) => {}",
|
| - "(a, 32) => {}",
|
| - "if => {}",
|
| - "(if) => {}",
|
| - "(a, if) => {}",
|
| - "a + b => {}",
|
| - "(a + b) => {}",
|
| - "(a + b, c) => {}",
|
| - "(a, b - c) => {}",
|
| - "\"a\" => {}",
|
| - "(\"a\") => {}",
|
| - "(\"a\", b) => {}",
|
| - "(a, \"b\") => {}",
|
| - "-a => {}",
|
| - "(-a) => {}",
|
| - "(-a, b) => {}",
|
| - "(a, -b) => {}",
|
| - "{} => {}",
|
| - "({}) => {}",
|
| - "(a, {}) => {}",
|
| - "({}, a) => {}",
|
| - "a++ => {}",
|
| - "(a++) => {}",
|
| - "(a++, b) => {}",
|
| - "(a, b++) => {}",
|
| - "[] => {}",
|
| - "([]) => {}",
|
| - "(a, []) => {}",
|
| - "([], a) => {}",
|
| - "(a = b) => {}",
|
| - "(a = b, c) => {}",
|
| - "(a, b = c) => {}",
|
| - "(foo ? bar : baz) => {}",
|
| - "(a, foo ? bar : baz) => {}",
|
| - "(foo ? bar : baz, a) => {}",
|
| - NULL
|
| - };
|
| -
|
| - RunParserSyncTest(context_data, statement_data, kError);
|
| -}
|
| -
|
| -
|
| -TEST(NoErrorsArrowFunctions) {
|
| - // Tests that parser and preparser accept valid arrow functions syntax.
|
| - const char* context_data[][2] = {
|
| - {"", ";"},
|
| - {"bar ? (", ") : baz;"},
|
| - {"bar ? baz : (", ");"},
|
| - {"bar, ", ";"},
|
| - {"", ", bar;"},
|
| - {NULL, NULL}
|
| - };
|
| -
|
| - const char* statement_data[] = {
|
| - "() => {}",
|
| - "() => { return 42 }",
|
| - "x => { return x; }",
|
| - "(x) => { return x; }",
|
| - "(x, y) => { return x + y; }",
|
| - "(x, y, z) => { return x + y + z; }",
|
| - "(x, y) => { x.a = y; }",
|
| - "() => 42",
|
| - "x => x",
|
| - "x => x * x",
|
| - "(x) => x",
|
| - "(x) => x * x",
|
| - "(x, y) => x + y",
|
| - "(x, y, z) => x, y, z",
|
| - "(x, y) => x.a = y",
|
| - "() => ({'value': 42})",
|
| - "x => y => x + y",
|
| - "(x, y) => (u, v) => x*u + y*v",
|
| - "(x, y) => z => z * (x + y)",
|
| - "x => (y, z) => z * (x + y)",
|
| -
|
| - // Those are comma-separated expressions, with arrow functions as items.
|
| - // They stress the code for validating arrow function parameter lists.
|
| - "a, b => 0",
|
| - "a, b, (c, d) => 0",
|
| - "(a, b, (c, d) => 0)",
|
| - "(a, b) => 0, (c, d) => 1",
|
| - "(a, b => {}, a => a + 1)",
|
| - "((a, b) => {}, (a => a + 1))",
|
| - "(a, (a, (b, c) => 0))",
|
| -
|
| - // Arrow has more precedence, this is the same as: foo ? bar : (baz = {})
|
| - "foo ? bar : baz => {}",
|
| - NULL
|
| - };
|
| -
|
| - static const ParserFlag always_flags[] = {kAllowArrowFunctions};
|
| - RunParserSyncTest(context_data, statement_data, kSuccess, NULL, 0,
|
| - always_flags, ARRAY_SIZE(always_flags));
|
| -}
|
|
|