| 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 | |
| 6449 { | 6447 { |
| 6450 const char* sloppy_context_data1[][2] = { | 6448 const char* sloppy_context_data[][2] = { |
| 6451 {"var ", " = {};"}, | 6449 {"var ", " = {};"}, |
| 6452 {"function f(", ") {}"}, | 6450 {"function f(", ") {}"}, |
| 6453 {"function f(argument1, ", ") {}"}, | 6451 {"function f(argument1, ", ") {}"}, |
| 6454 {"var f = (", ") => {};"}, | 6452 {"var f = (", ") => {};"}, |
| 6455 {"var f = (argument1,", ") => {};"}, | 6453 {"var f = (argument1,", ") => {};"}, |
| 6456 {"try {} catch(", ") {}"}, | 6454 {"try {} catch(", ") {}"}, |
| 6457 {NULL, NULL} | 6455 {NULL, NULL} |
| 6458 }; | 6456 }; |
| 6459 const char* data1[] = { | 6457 const char* data[] = { |
| 6458 "{arguments}", |
| 6460 "{eval}", | 6459 "{eval}", |
| 6460 "{x: arguments}", |
| 6461 "{x: eval}", | 6461 "{x: eval}", |
| 6462 "{arguments = false}", |
| 6462 "{eval = false}", | 6463 "{eval = false}", |
| 6463 NULL | 6464 NULL |
| 6464 }; | 6465 }; |
| 6465 RunParserSyncTest(sloppy_context_data1, data1, kSuccess); | 6466 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); | |
| 6479 } | 6467 } |
| 6480 } | 6468 } |
| 6481 | 6469 |
| 6482 | 6470 |
| 6483 TEST(DestructuringNegativeTests) { | 6471 TEST(DestructuringNegativeTests) { |
| 6484 { // All modes. | 6472 { // All modes. |
| 6485 const char* context_data[][2] = {{"'use strict'; let ", " = {};"}, | 6473 const char* context_data[][2] = {{"'use strict'; let ", " = {};"}, |
| 6486 {"var ", " = {};"}, | 6474 {"var ", " = {};"}, |
| 6487 {"'use strict'; const ", " = {};"}, | 6475 {"'use strict'; const ", " = {};"}, |
| 6488 {"function f(", ") {}"}, | 6476 {"function f(", ") {}"}, |
| (...skipping 1834 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8323 "(a,);", | 8311 "(a,);", |
| 8324 "(a,b,c,);", | 8312 "(a,b,c,);", |
| 8325 NULL | 8313 NULL |
| 8326 }; | 8314 }; |
| 8327 // clang-format on | 8315 // clang-format on |
| 8328 | 8316 |
| 8329 static const ParserFlag always_flags[] = {kAllowHarmonyTrailingCommas}; | 8317 static const ParserFlag always_flags[] = {kAllowHarmonyTrailingCommas}; |
| 8330 RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags, | 8318 RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags, |
| 8331 arraysize(always_flags)); | 8319 arraysize(always_flags)); |
| 8332 } | 8320 } |
| 8321 |
| 8322 TEST(ArgumentsRedeclaration) { |
| 8323 { |
| 8324 const char* context_data[][2] = { |
| 8325 { "function f(", ") {}" }, |
| 8326 { NULL, NULL } |
| 8327 }; |
| 8328 const char* success_data[] = { |
| 8329 "{arguments}", |
| 8330 "{arguments = false}", |
| 8331 "arg1, arguments", |
| 8332 "arg1, ...arguments", |
| 8333 NULL |
| 8334 }; |
| 8335 RunParserSyncTest(context_data, success_data, kSuccess); |
| 8336 } |
| 8337 |
| 8338 { |
| 8339 const char* context_data[][2] = { |
| 8340 { "function f() {", "}" }, |
| 8341 { NULL, NULL } |
| 8342 }; |
| 8343 const char* data[] = { |
| 8344 "const arguments = 1", |
| 8345 "let arguments", |
| 8346 "var arguments", |
| 8347 NULL |
| 8348 }; |
| 8349 RunParserSyncTest(context_data, data, kSuccess); |
| 8350 } |
| 8351 } |
| OLD | NEW |