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 6324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6335 "{'hi' : x = 42}", | 6335 "{'hi' : x = 42}", |
6336 "{var: x}", | 6336 "{var: x}", |
6337 "{var: x = 42}", | 6337 "{var: x = 42}", |
6338 "{[x] : z}", | 6338 "{[x] : z}", |
6339 "{[1+1] : z}", | 6339 "{[1+1] : z}", |
6340 "{[foo()] : z}", | 6340 "{[foo()] : z}", |
6341 "{}", | 6341 "{}", |
6342 "[...rest]", | 6342 "[...rest]", |
6343 "[a,b,...rest]", | 6343 "[a,b,...rest]", |
6344 "[a,,...rest]", | 6344 "[a,,...rest]", |
| 6345 "{arguments: x}", |
| 6346 "{eval: x}", |
6345 NULL}; | 6347 NULL}; |
6346 // clang-format on | 6348 // clang-format on |
6347 RunParserSyncTest(context_data, data, kSuccess); | 6349 RunParserSyncTest(context_data, data, kSuccess); |
| 6350 |
| 6351 // v8:5201 |
| 6352 // TODO(lpy): The two test sets below should be merged once |
| 6353 // we fix https://bugs.chromium.org/p/v8/issues/detail?id=4577 |
| 6354 { |
| 6355 const char* sloppy_context_data1[][2] = { |
| 6356 {"var ", " = {};"}, |
| 6357 {"function f(", ") {}"}, |
| 6358 {"function f(argument1, ", ") {}"}, |
| 6359 {"var f = (", ") => {};"}, |
| 6360 {"var f = (argument1,", ") => {};"}, |
| 6361 {"try {} catch(", ") {}"}, |
| 6362 {NULL, NULL} |
| 6363 }; |
| 6364 const char* data1[] = { |
| 6365 "{eval}", |
| 6366 "{x: eval}", |
| 6367 "{eval = false}", |
| 6368 NULL |
| 6369 }; |
| 6370 RunParserSyncTest(sloppy_context_data1, data1, kSuccess); |
| 6371 |
| 6372 const char* sloppy_context_data2[][2] = { |
| 6373 {"var ", " = {};"}, |
| 6374 {"try {} catch(", ") {}"}, |
| 6375 {NULL, NULL} |
| 6376 }; |
| 6377 const char* data2[] = { |
| 6378 "{arguments}", |
| 6379 "{x: arguments}", |
| 6380 "{arguments = false}", |
| 6381 NULL, |
| 6382 }; |
| 6383 RunParserSyncTest(sloppy_context_data2, data2, kSuccess); |
| 6384 } |
6348 } | 6385 } |
6349 | 6386 |
6350 | 6387 |
6351 TEST(DestructuringNegativeTests) { | 6388 TEST(DestructuringNegativeTests) { |
6352 { // All modes. | 6389 { // All modes. |
6353 const char* context_data[][2] = {{"'use strict'; let ", " = {};"}, | 6390 const char* context_data[][2] = {{"'use strict'; let ", " = {};"}, |
6354 {"var ", " = {};"}, | 6391 {"var ", " = {};"}, |
6355 {"'use strict'; const ", " = {};"}, | 6392 {"'use strict'; const ", " = {};"}, |
6356 {"function f(", ") {}"}, | 6393 {"function f(", ") {}"}, |
6357 {"function f(argument1, ", ") {}"}, | 6394 {"function f(argument1, ", ") {}"}, |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6450 const char* data[] = { | 6487 const char* data[] = { |
6451 "x => x", | 6488 "x => x", |
6452 "() => x", | 6489 "() => x", |
6453 NULL}; | 6490 NULL}; |
6454 // clang-format on | 6491 // clang-format on |
6455 RunParserSyncTest(context_data, data, kError); | 6492 RunParserSyncTest(context_data, data, kError); |
6456 } | 6493 } |
6457 | 6494 |
6458 { // Strict mode. | 6495 { // Strict mode. |
6459 const char* context_data[][2] = { | 6496 const char* context_data[][2] = { |
| 6497 {"'use strict'; var ", " = {};"}, |
6460 {"'use strict'; let ", " = {};"}, | 6498 {"'use strict'; let ", " = {};"}, |
6461 {"'use strict'; const ", " = {};"}, | 6499 {"'use strict'; const ", " = {};"}, |
6462 {"'use strict'; function f(", ") {}"}, | 6500 {"'use strict'; function f(", ") {}"}, |
6463 {"'use strict'; function f(argument1, ", ") {}"}, | 6501 {"'use strict'; function f(argument1, ", ") {}"}, |
6464 {NULL, NULL}}; | 6502 {NULL, NULL}}; |
6465 | 6503 |
6466 // clang-format off | 6504 // clang-format off |
6467 const char* data[] = { | 6505 const char* data[] = { |
| 6506 "[arguments]", |
6468 "[eval]", | 6507 "[eval]", |
6469 "{ a : arguments }", | 6508 "{ a : arguments }", |
| 6509 "{ a : eval }", |
6470 "[public]", | 6510 "[public]", |
6471 "{ x : private }", | 6511 "{ x : private }", |
| 6512 "{ x : arguments }", |
| 6513 "{ x : eval }", |
| 6514 "{ arguments }", |
| 6515 "{ eval }", |
| 6516 "{ arguments = false }" |
| 6517 "{ eval = false }", |
6472 NULL}; | 6518 NULL}; |
6473 // clang-format on | 6519 // clang-format on |
6474 RunParserSyncTest(context_data, data, kError); | 6520 RunParserSyncTest(context_data, data, kError); |
6475 } | 6521 } |
6476 | 6522 |
6477 { // 'yield' in generators. | 6523 { // 'yield' in generators. |
6478 const char* context_data[][2] = { | 6524 const char* context_data[][2] = { |
6479 {"function*() { var ", " = {};"}, | 6525 {"function*() { var ", " = {};"}, |
6480 {"function*() { 'use strict'; let ", " = {};"}, | 6526 {"function*() { 'use strict'; let ", " = {};"}, |
6481 {"function*() { 'use strict'; const ", " = {};"}, | 6527 {"function*() { 'use strict'; const ", " = {};"}, |
(...skipping 1659 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8141 "(a,);", | 8187 "(a,);", |
8142 "(a,b,c,);", | 8188 "(a,b,c,);", |
8143 NULL | 8189 NULL |
8144 }; | 8190 }; |
8145 // clang-format on | 8191 // clang-format on |
8146 | 8192 |
8147 static const ParserFlag always_flags[] = {kAllowHarmonyTrailingCommas}; | 8193 static const ParserFlag always_flags[] = {kAllowHarmonyTrailingCommas}; |
8148 RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags, | 8194 RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags, |
8149 arraysize(always_flags)); | 8195 arraysize(always_flags)); |
8150 } | 8196 } |
OLD | NEW |