| 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 6339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6350 strcmp( | 6350 strcmp( |
| 6351 "ReferenceError: In strong mode, using an undeclared global " | 6351 "ReferenceError: In strong mode, using an undeclared global " |
| 6352 "variable 'not_there3' is not allowed", | 6352 "variable 'not_there3' is not allowed", |
| 6353 *exception)); | 6353 *exception)); |
| 6354 } | 6354 } |
| 6355 } | 6355 } |
| 6356 | 6356 |
| 6357 | 6357 |
| 6358 TEST(DestructuringPositiveTests) { | 6358 TEST(DestructuringPositiveTests) { |
| 6359 i::FLAG_harmony_destructuring = true; | 6359 i::FLAG_harmony_destructuring = true; |
| 6360 i::FLAG_harmony_computed_property_names = true; |
| 6360 | 6361 |
| 6361 const char* context_data[][2] = {{"'use strict'; let ", " = {};"}, | 6362 const char* context_data[][2] = {{"'use strict'; let ", " = {};"}, |
| 6362 {"var ", " = {};"}, | 6363 {"var ", " = {};"}, |
| 6363 {"'use strict'; const ", " = {};"}, | 6364 {"'use strict'; const ", " = {};"}, |
| 6364 {NULL, NULL}}; | 6365 {NULL, NULL}}; |
| 6365 | 6366 |
| 6366 // clang-format off | 6367 // clang-format off |
| 6367 const char* data[] = { | 6368 const char* data[] = { |
| 6368 "a", | 6369 "a", |
| 6369 "{ x : y }", | 6370 "{ x : y }", |
| (...skipping 14 matching lines...) Expand all Loading... |
| 6384 "{x = 42, y = 15}", | 6385 "{x = 42, y = 15}", |
| 6385 "[a,,b]", | 6386 "[a,,b]", |
| 6386 "{42 : x}", | 6387 "{42 : x}", |
| 6387 "{42 : x = 42}", | 6388 "{42 : x = 42}", |
| 6388 "{42e-2 : x}", | 6389 "{42e-2 : x}", |
| 6389 "{42e-2 : x = 42}", | 6390 "{42e-2 : x = 42}", |
| 6390 "{'hi' : x}", | 6391 "{'hi' : x}", |
| 6391 "{'hi' : x = 42}", | 6392 "{'hi' : x = 42}", |
| 6392 "{var: x}", | 6393 "{var: x}", |
| 6393 "{var: x = 42}", | 6394 "{var: x = 42}", |
| 6395 "{[x] : z}", |
| 6396 "{[1+1] : z}", |
| 6397 "{[foo()] : z}", |
| 6394 "{}", | 6398 "{}", |
| 6395 NULL}; | 6399 NULL}; |
| 6396 // clang-format on | 6400 // clang-format on |
| 6397 static const ParserFlag always_flags[] = {kAllowHarmonyObjectLiterals, | 6401 static const ParserFlag always_flags[] = {kAllowHarmonyObjectLiterals, |
| 6402 kAllowHarmonyComputedPropertyNames, |
| 6398 kAllowHarmonyDestructuring}; | 6403 kAllowHarmonyDestructuring}; |
| 6399 RunParserSyncTest(context_data, data, kSuccess, NULL, 0, always_flags, | 6404 RunParserSyncTest(context_data, data, kSuccess, NULL, 0, always_flags, |
| 6400 arraysize(always_flags)); | 6405 arraysize(always_flags)); |
| 6401 } | 6406 } |
| 6402 | 6407 |
| 6403 | 6408 |
| 6404 TEST(DestructuringNegativeTests) { | 6409 TEST(DestructuringNegativeTests) { |
| 6405 i::FLAG_harmony_destructuring = true; | 6410 i::FLAG_harmony_destructuring = true; |
| 6411 i::FLAG_harmony_computed_property_names = true; |
| 6406 static const ParserFlag always_flags[] = {kAllowHarmonyObjectLiterals, | 6412 static const ParserFlag always_flags[] = {kAllowHarmonyObjectLiterals, |
| 6413 kAllowHarmonyComputedPropertyNames, |
| 6407 kAllowHarmonyDestructuring}; | 6414 kAllowHarmonyDestructuring}; |
| 6408 | 6415 |
| 6409 { // All modes. | 6416 { // All modes. |
| 6410 const char* context_data[][2] = {{"'use strict'; let ", " = {};"}, | 6417 const char* context_data[][2] = {{"'use strict'; let ", " = {};"}, |
| 6411 {"var ", " = {};"}, | 6418 {"var ", " = {};"}, |
| 6412 {"'use strict'; const ", " = {};"}, | 6419 {"'use strict'; const ", " = {};"}, |
| 6413 {NULL, NULL}}; | 6420 {NULL, NULL}}; |
| 6414 | 6421 |
| 6415 // clang-format off | 6422 // clang-format off |
| 6416 const char* data[] = { | 6423 const char* data[] = { |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6453 "() => x", | 6460 "() => x", |
| 6454 "{+2 : x}", | 6461 "{+2 : x}", |
| 6455 "{-2 : x}", | 6462 "{-2 : x}", |
| 6456 "var", | 6463 "var", |
| 6457 "[var]", | 6464 "[var]", |
| 6458 "{x : {y : var}}", | 6465 "{x : {y : var}}", |
| 6459 "{x : x = a+}", | 6466 "{x : x = a+}", |
| 6460 "{x : x = (a+)}", | 6467 "{x : x = (a+)}", |
| 6461 "{x : x += a}", | 6468 "{x : x += a}", |
| 6462 "{m() {} = 0}", | 6469 "{m() {} = 0}", |
| 6470 "{[1+1]}", |
| 6463 NULL}; | 6471 NULL}; |
| 6464 // clang-format on | 6472 // clang-format on |
| 6465 RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags, | 6473 RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags, |
| 6466 arraysize(always_flags)); | 6474 arraysize(always_flags)); |
| 6467 } | 6475 } |
| 6468 | 6476 |
| 6469 { // Strict mode. | 6477 { // Strict mode. |
| 6470 const char* context_data[][2] = {{"'use strict'; let ", " = {};"}, | 6478 const char* context_data[][2] = {{"'use strict'; let ", " = {};"}, |
| 6471 {"'use strict'; const ", " = {};"}, | 6479 {"'use strict'; const ", " = {};"}, |
| 6472 {NULL, NULL}}; | 6480 {NULL, NULL}}; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 6494 const char* data[] = { | 6502 const char* data[] = { |
| 6495 "yield", | 6503 "yield", |
| 6496 "[yield]", | 6504 "[yield]", |
| 6497 "{ x : yield }", | 6505 "{ x : yield }", |
| 6498 NULL}; | 6506 NULL}; |
| 6499 // clang-format on | 6507 // clang-format on |
| 6500 RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags, | 6508 RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags, |
| 6501 arraysize(always_flags)); | 6509 arraysize(always_flags)); |
| 6502 } | 6510 } |
| 6503 } | 6511 } |
| OLD | NEW |