| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 1411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1422 } | 1422 } |
| 1423 | 1423 |
| 1424 | 1424 |
| 1425 enum ParserFlag { | 1425 enum ParserFlag { |
| 1426 kAllowLazy, | 1426 kAllowLazy, |
| 1427 kAllowNatives, | 1427 kAllowNatives, |
| 1428 kAllowHarmonyArrowFunctions, | 1428 kAllowHarmonyArrowFunctions, |
| 1429 kAllowHarmonyRestParameters, | 1429 kAllowHarmonyRestParameters, |
| 1430 kAllowHarmonySloppy, | 1430 kAllowHarmonySloppy, |
| 1431 kAllowHarmonySloppyLet, | 1431 kAllowHarmonySloppyLet, |
| 1432 kAllowHarmonyComputedPropertyNames, | |
| 1433 kAllowHarmonySpreadCalls, | 1432 kAllowHarmonySpreadCalls, |
| 1434 kAllowHarmonyDestructuring, | 1433 kAllowHarmonyDestructuring, |
| 1435 kAllowHarmonySpreadArrays, | 1434 kAllowHarmonySpreadArrays, |
| 1436 kAllowHarmonyNewTarget, | 1435 kAllowHarmonyNewTarget, |
| 1437 kAllowStrongMode, | 1436 kAllowStrongMode, |
| 1438 kNoLegacyConst | 1437 kNoLegacyConst |
| 1439 }; | 1438 }; |
| 1440 | 1439 |
| 1441 | 1440 |
| 1442 enum ParserSyncTestResult { | 1441 enum ParserSyncTestResult { |
| 1443 kSuccessOrError, | 1442 kSuccessOrError, |
| 1444 kSuccess, | 1443 kSuccess, |
| 1445 kError | 1444 kError |
| 1446 }; | 1445 }; |
| 1447 | 1446 |
| 1448 template <typename Traits> | 1447 template <typename Traits> |
| 1449 void SetParserFlags(i::ParserBase<Traits>* parser, | 1448 void SetParserFlags(i::ParserBase<Traits>* parser, |
| 1450 i::EnumSet<ParserFlag> flags) { | 1449 i::EnumSet<ParserFlag> flags) { |
| 1451 parser->set_allow_lazy(flags.Contains(kAllowLazy)); | 1450 parser->set_allow_lazy(flags.Contains(kAllowLazy)); |
| 1452 parser->set_allow_natives(flags.Contains(kAllowNatives)); | 1451 parser->set_allow_natives(flags.Contains(kAllowNatives)); |
| 1453 parser->set_allow_harmony_arrow_functions( | 1452 parser->set_allow_harmony_arrow_functions( |
| 1454 flags.Contains(kAllowHarmonyArrowFunctions)); | 1453 flags.Contains(kAllowHarmonyArrowFunctions)); |
| 1455 parser->set_allow_harmony_rest_parameters( | 1454 parser->set_allow_harmony_rest_parameters( |
| 1456 flags.Contains(kAllowHarmonyRestParameters)); | 1455 flags.Contains(kAllowHarmonyRestParameters)); |
| 1457 parser->set_allow_harmony_spreadcalls( | 1456 parser->set_allow_harmony_spreadcalls( |
| 1458 flags.Contains(kAllowHarmonySpreadCalls)); | 1457 flags.Contains(kAllowHarmonySpreadCalls)); |
| 1459 parser->set_allow_harmony_sloppy(flags.Contains(kAllowHarmonySloppy)); | 1458 parser->set_allow_harmony_sloppy(flags.Contains(kAllowHarmonySloppy)); |
| 1460 parser->set_allow_harmony_sloppy_let(flags.Contains(kAllowHarmonySloppyLet)); | 1459 parser->set_allow_harmony_sloppy_let(flags.Contains(kAllowHarmonySloppyLet)); |
| 1461 parser->set_allow_harmony_computed_property_names( | |
| 1462 flags.Contains(kAllowHarmonyComputedPropertyNames)); | |
| 1463 parser->set_allow_harmony_destructuring( | 1460 parser->set_allow_harmony_destructuring( |
| 1464 flags.Contains(kAllowHarmonyDestructuring)); | 1461 flags.Contains(kAllowHarmonyDestructuring)); |
| 1465 parser->set_allow_harmony_spread_arrays( | 1462 parser->set_allow_harmony_spread_arrays( |
| 1466 flags.Contains(kAllowHarmonySpreadArrays)); | 1463 flags.Contains(kAllowHarmonySpreadArrays)); |
| 1467 parser->set_allow_harmony_new_target(flags.Contains(kAllowHarmonyNewTarget)); | 1464 parser->set_allow_harmony_new_target(flags.Contains(kAllowHarmonyNewTarget)); |
| 1468 parser->set_allow_strong_mode(flags.Contains(kAllowStrongMode)); | 1465 parser->set_allow_strong_mode(flags.Contains(kAllowStrongMode)); |
| 1469 parser->set_allow_legacy_const(!flags.Contains(kNoLegacyConst)); | 1466 parser->set_allow_legacy_const(!flags.Contains(kNoLegacyConst)); |
| 1470 } | 1467 } |
| 1471 | 1468 |
| 1472 | 1469 |
| (...skipping 3784 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5257 {"(class {set [", "](_) {}});"}, | 5254 {"(class {set [", "](_) {}});"}, |
| 5258 {"(class {[", "]() {}});"}, | 5255 {"(class {[", "]() {}});"}, |
| 5259 {"(class {*[", "]() {}});"}, | 5256 {"(class {*[", "]() {}});"}, |
| 5260 {NULL, NULL}}; | 5257 {NULL, NULL}}; |
| 5261 const char* error_data[] = { | 5258 const char* error_data[] = { |
| 5262 "1, 2", | 5259 "1, 2", |
| 5263 "var name", | 5260 "var name", |
| 5264 NULL}; | 5261 NULL}; |
| 5265 | 5262 |
| 5266 static const ParserFlag always_flags[] = { | 5263 static const ParserFlag always_flags[] = { |
| 5267 kAllowHarmonyComputedPropertyNames, | |
| 5268 kAllowHarmonySloppy, | 5264 kAllowHarmonySloppy, |
| 5269 }; | 5265 }; |
| 5270 RunParserSyncTest(context_data, error_data, kError, NULL, 0, | 5266 RunParserSyncTest(context_data, error_data, kError, NULL, 0, |
| 5271 always_flags, arraysize(always_flags)); | 5267 always_flags, arraysize(always_flags)); |
| 5272 | 5268 |
| 5273 const char* name_data[] = { | 5269 const char* name_data[] = { |
| 5274 "1", | 5270 "1", |
| 5275 "1 + 2", | 5271 "1 + 2", |
| 5276 "'name'", | 5272 "'name'", |
| 5277 "\"name\"", | 5273 "\"name\"", |
| 5278 "[]", | 5274 "[]", |
| 5279 "{}", | 5275 "{}", |
| 5280 NULL}; | 5276 NULL}; |
| 5281 | 5277 |
| 5282 RunParserSyncTest(context_data, name_data, kSuccess, NULL, 0, | 5278 RunParserSyncTest(context_data, name_data, kSuccess, NULL, 0, |
| 5283 always_flags, arraysize(always_flags)); | 5279 always_flags, arraysize(always_flags)); |
| 5284 } | 5280 } |
| 5285 | 5281 |
| 5286 | 5282 |
| 5287 TEST(ComputedPropertyNameShorthandError) { | 5283 TEST(ComputedPropertyNameShorthandError) { |
| 5288 const char* context_data[][2] = {{"({", "});"}, | 5284 const char* context_data[][2] = {{"({", "});"}, |
| 5289 {NULL, NULL}}; | 5285 {NULL, NULL}}; |
| 5290 const char* error_data[] = { | 5286 const char* error_data[] = { |
| 5291 "a: 1, [2]", | 5287 "a: 1, [2]", |
| 5292 "[1], a: 1", | 5288 "[1], a: 1", |
| 5293 NULL}; | 5289 NULL}; |
| 5294 | 5290 |
| 5295 static const ParserFlag always_flags[] = { | 5291 static const ParserFlag always_flags[] = { |
| 5296 kAllowHarmonyComputedPropertyNames, | |
| 5297 kAllowHarmonySloppy, | 5292 kAllowHarmonySloppy, |
| 5298 }; | 5293 }; |
| 5299 RunParserSyncTest(context_data, error_data, kError, NULL, 0, | 5294 RunParserSyncTest(context_data, error_data, kError, NULL, 0, |
| 5300 always_flags, arraysize(always_flags)); | 5295 always_flags, arraysize(always_flags)); |
| 5301 } | 5296 } |
| 5302 | 5297 |
| 5303 | 5298 |
| 5304 TEST(BasicImportExportParsing) { | 5299 TEST(BasicImportExportParsing) { |
| 5305 i::FLAG_harmony_modules = true; | 5300 i::FLAG_harmony_modules = true; |
| 5306 | 5301 |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5579 }; | 5574 }; |
| 5580 const char* error_data[] = { | 5575 const char* error_data[] = { |
| 5581 "__proto__: {}, ['__proto__']: {}", | 5576 "__proto__: {}, ['__proto__']: {}", |
| 5582 "__proto__: {}, __proto__() {}", | 5577 "__proto__: {}, __proto__() {}", |
| 5583 "__proto__: {}, get __proto__() {}", | 5578 "__proto__: {}, get __proto__() {}", |
| 5584 "__proto__: {}, set __proto__(v) {}", | 5579 "__proto__: {}, set __proto__(v) {}", |
| 5585 "__proto__: {}, __proto__", | 5580 "__proto__: {}, __proto__", |
| 5586 NULL | 5581 NULL |
| 5587 }; | 5582 }; |
| 5588 | 5583 |
| 5589 static const ParserFlag always_flags[] = { | 5584 RunParserSyncTest(context_data, error_data, kSuccess); |
| 5590 kAllowHarmonyComputedPropertyNames, | |
| 5591 }; | |
| 5592 RunParserSyncTest(context_data, error_data, kSuccess, NULL, 0, | |
| 5593 always_flags, arraysize(always_flags)); | |
| 5594 } | 5585 } |
| 5595 | 5586 |
| 5596 | 5587 |
| 5597 TEST(DeclarationsError) { | 5588 TEST(DeclarationsError) { |
| 5598 const char* context_data[][2] = {{"'use strict'; if (true)", ""}, | 5589 const char* context_data[][2] = {{"'use strict'; if (true)", ""}, |
| 5599 {"'use strict'; if (false) {} else", ""}, | 5590 {"'use strict'; if (false) {} else", ""}, |
| 5600 {"'use strict'; while (false)", ""}, | 5591 {"'use strict'; while (false)", ""}, |
| 5601 {"'use strict'; for (;;)", ""}, | 5592 {"'use strict'; for (;;)", ""}, |
| 5602 {"'use strict'; for (x in y)", ""}, | 5593 {"'use strict'; for (x in y)", ""}, |
| 5603 {"'use strict'; do ", " while (false)"}, | 5594 {"'use strict'; do ", " while (false)"}, |
| (...skipping 718 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6322 "ReferenceError: In strong mode, using an undeclared global " | 6313 "ReferenceError: In strong mode, using an undeclared global " |
| 6323 "variable 'not_there3' is not allowed", | 6314 "variable 'not_there3' is not allowed", |
| 6324 *exception)); | 6315 *exception)); |
| 6325 } | 6316 } |
| 6326 } | 6317 } |
| 6327 | 6318 |
| 6328 | 6319 |
| 6329 TEST(DestructuringPositiveTests) { | 6320 TEST(DestructuringPositiveTests) { |
| 6330 i::FLAG_harmony_destructuring = true; | 6321 i::FLAG_harmony_destructuring = true; |
| 6331 i::FLAG_harmony_arrow_functions = true; | 6322 i::FLAG_harmony_arrow_functions = true; |
| 6332 i::FLAG_harmony_computed_property_names = true; | |
| 6333 | 6323 |
| 6334 const char* context_data[][2] = {{"'use strict'; let ", " = {};"}, | 6324 const char* context_data[][2] = {{"'use strict'; let ", " = {};"}, |
| 6335 {"var ", " = {};"}, | 6325 {"var ", " = {};"}, |
| 6336 {"'use strict'; const ", " = {};"}, | 6326 {"'use strict'; const ", " = {};"}, |
| 6337 {"function f(", ") {}"}, | 6327 {"function f(", ") {}"}, |
| 6338 {"function f(argument1, ", ") {}"}, | 6328 {"function f(argument1, ", ") {}"}, |
| 6339 {"var f = (", ") => {};"}, | 6329 {"var f = (", ") => {};"}, |
| 6340 {"var f = (argument1,", ") => {};"}, | 6330 {"var f = (argument1,", ") => {};"}, |
| 6341 {NULL, NULL}}; | 6331 {NULL, NULL}}; |
| 6342 | 6332 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 6371 "{var: x = 42}", | 6361 "{var: x = 42}", |
| 6372 "{[x] : z}", | 6362 "{[x] : z}", |
| 6373 "{[1+1] : z}", | 6363 "{[1+1] : z}", |
| 6374 "{[foo()] : z}", | 6364 "{[foo()] : z}", |
| 6375 "{}", | 6365 "{}", |
| 6376 "[...rest]", | 6366 "[...rest]", |
| 6377 "[a,b,...rest]", | 6367 "[a,b,...rest]", |
| 6378 "[a,,...rest]", | 6368 "[a,,...rest]", |
| 6379 NULL}; | 6369 NULL}; |
| 6380 // clang-format on | 6370 // clang-format on |
| 6381 static const ParserFlag always_flags[] = {kAllowHarmonyComputedPropertyNames, | 6371 static const ParserFlag always_flags[] = {kAllowHarmonyArrowFunctions, |
| 6382 kAllowHarmonyArrowFunctions, | |
| 6383 kAllowHarmonyDestructuring}; | 6372 kAllowHarmonyDestructuring}; |
| 6384 RunParserSyncTest(context_data, data, kSuccess, NULL, 0, always_flags, | 6373 RunParserSyncTest(context_data, data, kSuccess, NULL, 0, always_flags, |
| 6385 arraysize(always_flags)); | 6374 arraysize(always_flags)); |
| 6386 } | 6375 } |
| 6387 | 6376 |
| 6388 | 6377 |
| 6389 TEST(DestructuringNegativeTests) { | 6378 TEST(DestructuringNegativeTests) { |
| 6390 i::FLAG_harmony_destructuring = true; | 6379 i::FLAG_harmony_destructuring = true; |
| 6391 i::FLAG_harmony_arrow_functions = true; | 6380 i::FLAG_harmony_arrow_functions = true; |
| 6392 i::FLAG_harmony_computed_property_names = true; | 6381 static const ParserFlag always_flags[] = {kAllowHarmonyArrowFunctions, |
| 6393 static const ParserFlag always_flags[] = {kAllowHarmonyComputedPropertyNames, | |
| 6394 kAllowHarmonyArrowFunctions, | |
| 6395 kAllowHarmonyDestructuring}; | 6382 kAllowHarmonyDestructuring}; |
| 6396 | 6383 |
| 6397 { // All modes. | 6384 { // All modes. |
| 6398 const char* context_data[][2] = {{"'use strict'; let ", " = {};"}, | 6385 const char* context_data[][2] = {{"'use strict'; let ", " = {};"}, |
| 6399 {"var ", " = {};"}, | 6386 {"var ", " = {};"}, |
| 6400 {"'use strict'; const ", " = {};"}, | 6387 {"'use strict'; const ", " = {};"}, |
| 6401 {"function f(", ") {}"}, | 6388 {"function f(", ") {}"}, |
| 6402 {"function f(argument1, ", ") {}"}, | 6389 {"function f(argument1, ", ") {}"}, |
| 6403 {"var f = (", ") => {};"}, | 6390 {"var f = (", ") => {};"}, |
| 6404 {"var f = ", " => {};"}, | 6391 {"var f = ", " => {};"}, |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6553 NULL}; | 6540 NULL}; |
| 6554 // clang-format on | 6541 // clang-format on |
| 6555 RunParserSyncTest(context_data, success_data, kSuccess, NULL, 0, always_flags, | 6542 RunParserSyncTest(context_data, success_data, kSuccess, NULL, 0, always_flags, |
| 6556 arraysize(always_flags)); | 6543 arraysize(always_flags)); |
| 6557 } | 6544 } |
| 6558 | 6545 |
| 6559 | 6546 |
| 6560 TEST(DestructuringDuplicateParams) { | 6547 TEST(DestructuringDuplicateParams) { |
| 6561 i::FLAG_harmony_destructuring = true; | 6548 i::FLAG_harmony_destructuring = true; |
| 6562 i::FLAG_harmony_arrow_functions = true; | 6549 i::FLAG_harmony_arrow_functions = true; |
| 6563 i::FLAG_harmony_computed_property_names = true; | 6550 static const ParserFlag always_flags[] = {kAllowHarmonyArrowFunctions, |
| 6564 static const ParserFlag always_flags[] = {kAllowHarmonyComputedPropertyNames, | |
| 6565 kAllowHarmonyArrowFunctions, | |
| 6566 kAllowHarmonyDestructuring}; | 6551 kAllowHarmonyDestructuring}; |
| 6567 const char* context_data[][2] = {{"'use strict';", ""}, | 6552 const char* context_data[][2] = {{"'use strict';", ""}, |
| 6568 {"function outer() { 'use strict';", "}"}, | 6553 {"function outer() { 'use strict';", "}"}, |
| 6569 {nullptr, nullptr}}; | 6554 {nullptr, nullptr}}; |
| 6570 | 6555 |
| 6571 | 6556 |
| 6572 // clang-format off | 6557 // clang-format off |
| 6573 const char* error_data[] = { | 6558 const char* error_data[] = { |
| 6574 "function f(x,x){}", | 6559 "function f(x,x){}", |
| 6575 "function f(x, {x : x}){}", | 6560 "function f(x, {x : x}){}", |
| 6576 "function f(x, {x}){}", | 6561 "function f(x, {x}){}", |
| 6577 "function f({x,x}) {}", | 6562 "function f({x,x}) {}", |
| 6578 "function f([x,x]) {}", | 6563 "function f([x,x]) {}", |
| 6579 "function f(x, [y,{z:x}]) {}", | 6564 "function f(x, [y,{z:x}]) {}", |
| 6580 "function f([x,{y:x}]) {}", | 6565 "function f([x,{y:x}]) {}", |
| 6581 // non-simple parameter list causes duplicates to be errors in sloppy mode. | 6566 // non-simple parameter list causes duplicates to be errors in sloppy mode. |
| 6582 "function f(x, x, {a}) {}", | 6567 "function f(x, x, {a}) {}", |
| 6583 nullptr}; | 6568 nullptr}; |
| 6584 // clang-format on | 6569 // clang-format on |
| 6585 RunParserSyncTest(context_data, error_data, kError, NULL, 0, always_flags, | 6570 RunParserSyncTest(context_data, error_data, kError, NULL, 0, always_flags, |
| 6586 arraysize(always_flags)); | 6571 arraysize(always_flags)); |
| 6587 } | 6572 } |
| 6588 | 6573 |
| 6589 | 6574 |
| 6590 TEST(DestructuringDuplicateParamsSloppy) { | 6575 TEST(DestructuringDuplicateParamsSloppy) { |
| 6591 i::FLAG_harmony_destructuring = true; | 6576 i::FLAG_harmony_destructuring = true; |
| 6592 i::FLAG_harmony_arrow_functions = true; | 6577 i::FLAG_harmony_arrow_functions = true; |
| 6593 i::FLAG_harmony_computed_property_names = true; | 6578 static const ParserFlag always_flags[] = {kAllowHarmonyArrowFunctions, |
| 6594 static const ParserFlag always_flags[] = {kAllowHarmonyComputedPropertyNames, | |
| 6595 kAllowHarmonyArrowFunctions, | |
| 6596 kAllowHarmonyDestructuring}; | 6579 kAllowHarmonyDestructuring}; |
| 6597 const char* context_data[][2] = { | 6580 const char* context_data[][2] = { |
| 6598 {"", ""}, {"function outer() {", "}"}, {nullptr, nullptr}}; | 6581 {"", ""}, {"function outer() {", "}"}, {nullptr, nullptr}}; |
| 6599 | 6582 |
| 6600 | 6583 |
| 6601 // clang-format off | 6584 // clang-format off |
| 6602 const char* error_data[] = { | 6585 const char* error_data[] = { |
| 6603 // non-simple parameter list causes duplicates to be errors in sloppy mode. | 6586 // non-simple parameter list causes duplicates to be errors in sloppy mode. |
| 6604 "function f(x, {x : x}){}", | 6587 "function f(x, {x : x}){}", |
| 6605 "function f(x, {x}){}", | 6588 "function f(x, {x}){}", |
| 6606 "function f({x,x}) {}", | 6589 "function f({x,x}) {}", |
| 6607 "function f(x, x, {a}) {}", | 6590 "function f(x, x, {a}) {}", |
| 6608 nullptr}; | 6591 nullptr}; |
| 6609 // clang-format on | 6592 // clang-format on |
| 6610 RunParserSyncTest(context_data, error_data, kError, NULL, 0, always_flags, | 6593 RunParserSyncTest(context_data, error_data, kError, NULL, 0, always_flags, |
| 6611 arraysize(always_flags)); | 6594 arraysize(always_flags)); |
| 6612 } | 6595 } |
| 6613 | 6596 |
| 6614 | 6597 |
| 6615 TEST(DestructuringDisallowPatternsInSingleParamArrows) { | 6598 TEST(DestructuringDisallowPatternsInSingleParamArrows) { |
| 6616 i::FLAG_harmony_destructuring = true; | 6599 i::FLAG_harmony_destructuring = true; |
| 6617 i::FLAG_harmony_arrow_functions = true; | 6600 i::FLAG_harmony_arrow_functions = true; |
| 6618 i::FLAG_harmony_computed_property_names = true; | 6601 static const ParserFlag always_flags[] = {kAllowHarmonyArrowFunctions, |
| 6619 static const ParserFlag always_flags[] = {kAllowHarmonyComputedPropertyNames, | |
| 6620 kAllowHarmonyArrowFunctions, | |
| 6621 kAllowHarmonyDestructuring}; | 6602 kAllowHarmonyDestructuring}; |
| 6622 const char* context_data[][2] = {{"'use strict';", ""}, | 6603 const char* context_data[][2] = {{"'use strict';", ""}, |
| 6623 {"function outer() { 'use strict';", "}"}, | 6604 {"function outer() { 'use strict';", "}"}, |
| 6624 {"", ""}, | 6605 {"", ""}, |
| 6625 {"function outer() { ", "}"}, | 6606 {"function outer() { ", "}"}, |
| 6626 {nullptr, nullptr}}; | 6607 {nullptr, nullptr}}; |
| 6627 | 6608 |
| 6628 // clang-format off | 6609 // clang-format off |
| 6629 const char* error_data[] = { | 6610 const char* error_data[] = { |
| 6630 "var f = {x} => {};", | 6611 "var f = {x} => {};", |
| 6631 "var f = {x,y} => {};", | 6612 "var f = {x,y} => {};", |
| 6632 nullptr}; | 6613 nullptr}; |
| 6633 // clang-format on | 6614 // clang-format on |
| 6634 RunParserSyncTest(context_data, error_data, kError, NULL, 0, always_flags, | 6615 RunParserSyncTest(context_data, error_data, kError, NULL, 0, always_flags, |
| 6635 arraysize(always_flags)); | 6616 arraysize(always_flags)); |
| 6636 } | 6617 } |
| 6637 | 6618 |
| 6638 | 6619 |
| 6639 TEST(DestructuringDisallowPatternsInRestParams) { | 6620 TEST(DestructuringDisallowPatternsInRestParams) { |
| 6640 i::FLAG_harmony_destructuring = true; | 6621 i::FLAG_harmony_destructuring = true; |
| 6641 i::FLAG_harmony_arrow_functions = true; | 6622 i::FLAG_harmony_arrow_functions = true; |
| 6642 i::FLAG_harmony_rest_parameters = true; | 6623 i::FLAG_harmony_rest_parameters = true; |
| 6643 i::FLAG_harmony_computed_property_names = true; | 6624 static const ParserFlag always_flags[] = {kAllowHarmonyArrowFunctions, |
| 6644 static const ParserFlag always_flags[] = { | 6625 kAllowHarmonyRestParameters, |
| 6645 kAllowHarmonyComputedPropertyNames, kAllowHarmonyArrowFunctions, | 6626 kAllowHarmonyDestructuring}; |
| 6646 kAllowHarmonyRestParameters, kAllowHarmonyDestructuring}; | |
| 6647 const char* context_data[][2] = {{"'use strict';", ""}, | 6627 const char* context_data[][2] = {{"'use strict';", ""}, |
| 6648 {"function outer() { 'use strict';", "}"}, | 6628 {"function outer() { 'use strict';", "}"}, |
| 6649 {"", ""}, | 6629 {"", ""}, |
| 6650 {"function outer() { ", "}"}, | 6630 {"function outer() { ", "}"}, |
| 6651 {nullptr, nullptr}}; | 6631 {nullptr, nullptr}}; |
| 6652 | 6632 |
| 6653 // clang-format off | 6633 // clang-format off |
| 6654 const char* error_data[] = { | 6634 const char* error_data[] = { |
| 6655 "function(...{}) {}", | 6635 "function(...{}) {}", |
| 6656 "function(...{x}) {}", | 6636 "function(...{x}) {}", |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6831 "for (let x of []) {}", | 6811 "for (let x of []) {}", |
| 6832 NULL | 6812 NULL |
| 6833 }; | 6813 }; |
| 6834 // clang-format on | 6814 // clang-format on |
| 6835 | 6815 |
| 6836 static const ParserFlag always_flags[] = {kAllowHarmonySloppy, | 6816 static const ParserFlag always_flags[] = {kAllowHarmonySloppy, |
| 6837 kAllowHarmonySloppyLet}; | 6817 kAllowHarmonySloppyLet}; |
| 6838 RunParserSyncTest(context_data, data, kSuccess, NULL, 0, always_flags, | 6818 RunParserSyncTest(context_data, data, kSuccess, NULL, 0, always_flags, |
| 6839 arraysize(always_flags)); | 6819 arraysize(always_flags)); |
| 6840 } | 6820 } |
| OLD | NEW |