| 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 6426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6437 "[a,b,...rest]", | 6437 "[a,b,...rest]", |
| 6438 "[a,,...rest]", | 6438 "[a,,...rest]", |
| 6439 "{ __proto__: x, __proto__: y}", | 6439 "{ __proto__: x, __proto__: y}", |
| 6440 "{arguments: x}", | 6440 "{arguments: x}", |
| 6441 "{eval: x}", | 6441 "{eval: x}", |
| 6442 NULL}; | 6442 NULL}; |
| 6443 // clang-format on | 6443 // clang-format on |
| 6444 RunParserSyncTest(context_data, data, kSuccess); | 6444 RunParserSyncTest(context_data, data, kSuccess); |
| 6445 | 6445 |
| 6446 // v8:5201 | 6446 // v8:5201 |
| 6447 // TODO(lpy): The two test sets below should be merged once |
| 6448 // we fix https://bugs.chromium.org/p/v8/issues/detail?id=4577 |
| 6447 { | 6449 { |
| 6448 // clang-format off | 6450 const char* sloppy_context_data1[][2] = { |
| 6449 const char* sloppy_context_data[][2] = { | |
| 6450 {"var ", " = {};"}, | 6451 {"var ", " = {};"}, |
| 6451 {"function f(", ") {}"}, | 6452 {"function f(", ") {}"}, |
| 6452 {"function f(argument1, ", ") {}"}, | 6453 {"function f(argument1, ", ") {}"}, |
| 6453 {"var f = (", ") => {};"}, | 6454 {"var f = (", ") => {};"}, |
| 6454 {"var f = (argument1,", ") => {};"}, | 6455 {"var f = (argument1,", ") => {};"}, |
| 6455 {"try {} catch(", ") {}"}, | 6456 {"try {} catch(", ") {}"}, |
| 6456 {NULL, NULL} | 6457 {NULL, NULL} |
| 6457 }; | 6458 }; |
| 6458 const char* data[] = { | 6459 const char* data1[] = { |
| 6459 "{arguments}", | |
| 6460 "{eval}", | 6460 "{eval}", |
| 6461 "{x: arguments}", | |
| 6462 "{x: eval}", | 6461 "{x: eval}", |
| 6463 "{arguments = false}", | |
| 6464 "{eval = false}", | 6462 "{eval = false}", |
| 6465 NULL | 6463 NULL |
| 6466 }; | 6464 }; |
| 6467 // clang-format on | 6465 RunParserSyncTest(sloppy_context_data1, data1, kSuccess); |
| 6468 RunParserSyncTest(sloppy_context_data, data, kSuccess); | 6466 |
| 6467 const char* sloppy_context_data2[][2] = { |
| 6468 {"var ", " = {};"}, |
| 6469 {"try {} catch(", ") {}"}, |
| 6470 {NULL, NULL} |
| 6471 }; |
| 6472 const char* data2[] = { |
| 6473 "{arguments}", |
| 6474 "{x: arguments}", |
| 6475 "{arguments = false}", |
| 6476 NULL, |
| 6477 }; |
| 6478 RunParserSyncTest(sloppy_context_data2, data2, kSuccess); |
| 6469 } | 6479 } |
| 6470 } | 6480 } |
| 6471 | 6481 |
| 6472 | 6482 |
| 6473 TEST(DestructuringNegativeTests) { | 6483 TEST(DestructuringNegativeTests) { |
| 6474 { // All modes. | 6484 { // All modes. |
| 6475 const char* context_data[][2] = {{"'use strict'; let ", " = {};"}, | 6485 const char* context_data[][2] = {{"'use strict'; let ", " = {};"}, |
| 6476 {"var ", " = {};"}, | 6486 {"var ", " = {};"}, |
| 6477 {"'use strict'; const ", " = {};"}, | 6487 {"'use strict'; const ", " = {};"}, |
| 6478 {"function f(", ") {}"}, | 6488 {"function f(", ") {}"}, |
| (...skipping 1834 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8313 "(a,);", | 8323 "(a,);", |
| 8314 "(a,b,c,);", | 8324 "(a,b,c,);", |
| 8315 NULL | 8325 NULL |
| 8316 }; | 8326 }; |
| 8317 // clang-format on | 8327 // clang-format on |
| 8318 | 8328 |
| 8319 static const ParserFlag always_flags[] = {kAllowHarmonyTrailingCommas}; | 8329 static const ParserFlag always_flags[] = {kAllowHarmonyTrailingCommas}; |
| 8320 RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags, | 8330 RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags, |
| 8321 arraysize(always_flags)); | 8331 arraysize(always_flags)); |
| 8322 } | 8332 } |
| 8323 | |
| 8324 TEST(ArgumentsRedeclaration) { | |
| 8325 { | |
| 8326 // clang-format off | |
| 8327 const char* context_data[][2] = { | |
| 8328 { "function f(", ") {}" }, | |
| 8329 { NULL, NULL } | |
| 8330 }; | |
| 8331 const char* success_data[] = { | |
| 8332 "{arguments}", | |
| 8333 "{arguments = false}", | |
| 8334 "arg1, arguments", | |
| 8335 "arg1, ...arguments", | |
| 8336 NULL | |
| 8337 }; | |
| 8338 // clang-format on | |
| 8339 RunParserSyncTest(context_data, success_data, kSuccess); | |
| 8340 } | |
| 8341 | |
| 8342 { | |
| 8343 // clang-format off | |
| 8344 const char* context_data[][2] = { | |
| 8345 { "function f() {", "}" }, | |
| 8346 { NULL, NULL } | |
| 8347 }; | |
| 8348 const char* data[] = { | |
| 8349 "const arguments = 1", | |
| 8350 "let arguments", | |
| 8351 "var arguments", | |
| 8352 NULL | |
| 8353 }; | |
| 8354 // clang-format on | |
| 8355 RunParserSyncTest(context_data, data, kSuccess); | |
| 8356 } | |
| 8357 } | |
| OLD | NEW |