| 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 6348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6359 | 6359 |
| 6360 const char* context_data[][2] = {{"'use strict'; let ", " = {};"}, | 6360 const char* context_data[][2] = {{"'use strict'; let ", " = {};"}, |
| 6361 {"var ", " = {};"}, | 6361 {"var ", " = {};"}, |
| 6362 {"'use strict'; const ", " = {};"}, | 6362 {"'use strict'; const ", " = {};"}, |
| 6363 {NULL, NULL}}; | 6363 {NULL, NULL}}; |
| 6364 | 6364 |
| 6365 // clang-format off | 6365 // clang-format off |
| 6366 const char* data[] = { | 6366 const char* data[] = { |
| 6367 "a", | 6367 "a", |
| 6368 "{ x : y }", | 6368 "{ x : y }", |
| 6369 "{ x : y = 1 }", |
| 6369 "[a]", | 6370 "[a]", |
| 6371 "[a = 1]", |
| 6370 "[a,b,c]", | 6372 "[a,b,c]", |
| 6373 "[a, b = 42, c]", |
| 6371 "{ x : x, y : y }", | 6374 "{ x : x, y : y }", |
| 6375 "{ x : x = 1, y : y }", |
| 6376 "{ x : x, y : y = 42 }", |
| 6372 "[]", | 6377 "[]", |
| 6373 "{}", | 6378 "{}", |
| 6374 "[{x:x, y:y}, [a,b,c]]", | 6379 "[{x:x, y:y}, [a,b,c]]", |
| 6380 "[{x:x = 1, y:y = 2}, [a = 3, b = 4, c = 5]]", |
| 6381 "{x}", |
| 6382 "{x, y}", |
| 6383 "{x = 42, y = 15}", |
| 6375 "[a,,b]", | 6384 "[a,,b]", |
| 6376 "{42 : x}", | 6385 "{42 : x}", |
| 6386 "{42 : x = 42}", |
| 6377 "{42e-2 : x}", | 6387 "{42e-2 : x}", |
| 6388 "{42e-2 : x = 42}", |
| 6378 "{'hi' : x}", | 6389 "{'hi' : x}", |
| 6390 "{'hi' : x = 42}", |
| 6379 "{var: x}", | 6391 "{var: x}", |
| 6392 "{var: x = 42}", |
| 6380 "{}", | 6393 "{}", |
| 6381 NULL}; | 6394 NULL}; |
| 6382 // clang-format on | 6395 // clang-format on |
| 6383 static const ParserFlag always_flags[] = {kAllowHarmonyDestructuring}; | 6396 static const ParserFlag always_flags[] = {kAllowHarmonyObjectLiterals, |
| 6397 kAllowHarmonyDestructuring}; |
| 6384 RunParserSyncTest(context_data, data, kSuccess, NULL, 0, always_flags, | 6398 RunParserSyncTest(context_data, data, kSuccess, NULL, 0, always_flags, |
| 6385 arraysize(always_flags)); | 6399 arraysize(always_flags)); |
| 6386 } | 6400 } |
| 6387 | 6401 |
| 6388 | 6402 |
| 6389 TEST(DestructuringNegativeTests) { | 6403 TEST(DestructuringNegativeTests) { |
| 6390 i::FLAG_harmony_destructuring = true; | 6404 i::FLAG_harmony_destructuring = true; |
| 6391 static const ParserFlag always_flags[] = {kAllowHarmonyDestructuring}; | 6405 static const ParserFlag always_flags[] = {kAllowHarmonyObjectLiterals, |
| 6406 kAllowHarmonyDestructuring}; |
| 6392 | 6407 |
| 6393 { // All modes. | 6408 { // All modes. |
| 6394 const char* context_data[][2] = {{"'use strict'; let ", " = {};"}, | 6409 const char* context_data[][2] = {{"'use strict'; let ", " = {};"}, |
| 6395 {"var ", " = {};"}, | 6410 {"var ", " = {};"}, |
| 6396 {"'use strict'; const ", " = {};"}, | 6411 {"'use strict'; const ", " = {};"}, |
| 6397 {NULL, NULL}}; | 6412 {NULL, NULL}}; |
| 6398 | 6413 |
| 6399 // clang-format off | 6414 // clang-format off |
| 6400 const char* data[] = { | 6415 const char* data[] = { |
| 6401 "a++", | 6416 "a++", |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6433 "false", | 6448 "false", |
| 6434 "1", | 6449 "1", |
| 6435 "'abc'", | 6450 "'abc'", |
| 6436 "class {}", | 6451 "class {}", |
| 6437 "() => x", | 6452 "() => x", |
| 6438 "{+2 : x}", | 6453 "{+2 : x}", |
| 6439 "{-2 : x}", | 6454 "{-2 : x}", |
| 6440 "var", | 6455 "var", |
| 6441 "[var]", | 6456 "[var]", |
| 6442 "{x : {y : var}}", | 6457 "{x : {y : var}}", |
| 6458 "{x : x = a+}", |
| 6459 "{x : x = (a+)}", |
| 6460 "{x : x += a}", |
| 6461 "{m() {} = 0}", |
| 6443 NULL}; | 6462 NULL}; |
| 6444 // clang-format on | 6463 // clang-format on |
| 6445 RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags, | 6464 RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags, |
| 6446 arraysize(always_flags)); | 6465 arraysize(always_flags)); |
| 6447 } | 6466 } |
| 6448 | 6467 |
| 6449 { // Strict mode. | 6468 { // Strict mode. |
| 6450 const char* context_data[][2] = {{"'use strict'; let ", " = {};"}, | 6469 const char* context_data[][2] = {{"'use strict'; let ", " = {};"}, |
| 6451 {"'use strict'; const ", " = {};"}, | 6470 {"'use strict'; const ", " = {};"}, |
| 6452 {NULL, NULL}}; | 6471 {NULL, NULL}}; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 6474 const char* data[] = { | 6493 const char* data[] = { |
| 6475 "yield", | 6494 "yield", |
| 6476 "[yield]", | 6495 "[yield]", |
| 6477 "{ x : yield }", | 6496 "{ x : yield }", |
| 6478 NULL}; | 6497 NULL}; |
| 6479 // clang-format on | 6498 // clang-format on |
| 6480 RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags, | 6499 RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags, |
| 6481 arraysize(always_flags)); | 6500 arraysize(always_flags)); |
| 6482 } | 6501 } |
| 6483 } | 6502 } |
| OLD | NEW |