Chromium Code Reviews| 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 6345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6356 TEST(DestructuringPositiveTests) { | 6356 TEST(DestructuringPositiveTests) { |
| 6357 i::FLAG_harmony_destructuring = true; | 6357 i::FLAG_harmony_destructuring = true; |
| 6358 | 6358 |
| 6359 const char* context_data[][2] = {{"'use strict'; let ", " = {};"}, | 6359 const char* context_data[][2] = {{"'use strict'; let ", " = {};"}, |
| 6360 {"var ", " = {};"}, | 6360 {"var ", " = {};"}, |
| 6361 {"'use strict'; const ", " = {};"}, | 6361 {"'use strict'; const ", " = {};"}, |
| 6362 {NULL, NULL}}; | 6362 {NULL, NULL}}; |
| 6363 | 6363 |
| 6364 // clang-format off | 6364 // clang-format off |
| 6365 const char* data[] = { | 6365 const char* data[] = { |
| 6366 "x", | |
|
arv (Not doing code reviews)
2015/05/18 14:36:20
this is a duplicate of the next line
Dmitry Lomov (no reviews)
2015/05/18 17:31:23
Done.
| |
| 6366 "a", | 6367 "a", |
| 6367 "{ x : y }", | 6368 "{ x : y }", |
| 6369 "{ x : y = 1 }", | |
| 6368 "[a]", | 6370 "[a]", |
| 6371 "[a = 1]", | |
| 6369 "[a,b,c]", | 6372 "[a,b,c]", |
| 6373 "[a, b = 42, c]", | |
| 6370 "{ x : x, y : y }", | 6374 "{ x : x, y : y }", |
| 6375 "{ x : x = 1, y : y }", | |
| 6376 "{ x : x, y : y = 42 }", | |
| 6371 "[]", | 6377 "[]", |
| 6372 "{}", | 6378 "{}", |
| 6373 "[{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}", | |
| 6374 "[a,,b]", | 6384 "[a,,b]", |
| 6375 "{42 : x}", | 6385 "{42 : x}", |
| 6386 "{42 : x = 42}", | |
| 6376 "{42e-2 : x}", | 6387 "{42e-2 : x}", |
| 6388 "{42e-2 : x = 42}", | |
| 6377 "{'hi' : x}", | 6389 "{'hi' : x}", |
| 6390 "{'hi' : x = 42}", | |
| 6378 "{var: x}", | 6391 "{var: x}", |
| 6392 "{var: x = 42}", | |
|
rossberg
2015/05/18 16:17:19
Add a test with computed property names.
Dmitry Lomov (no reviews)
2015/05/18 17:31:22
I want to cover computed property names in a separ
| |
| 6379 "{}", | 6393 "{}", |
| 6380 NULL}; | 6394 NULL}; |
| 6381 // clang-format on | 6395 // clang-format on |
| 6382 static const ParserFlag always_flags[] = {kAllowHarmonyDestructuring}; | 6396 static const ParserFlag always_flags[] = {kAllowHarmonyObjectLiterals, |
| 6397 kAllowHarmonyDestructuring}; | |
| 6383 RunParserSyncTest(context_data, data, kSuccess, NULL, 0, always_flags, | 6398 RunParserSyncTest(context_data, data, kSuccess, NULL, 0, always_flags, |
| 6384 arraysize(always_flags)); | 6399 arraysize(always_flags)); |
| 6385 } | 6400 } |
| 6386 | 6401 |
| 6387 | 6402 |
| 6388 TEST(DestructuringNegativeTests) { | 6403 TEST(DestructuringNegativeTests) { |
| 6389 i::FLAG_harmony_destructuring = true; | 6404 i::FLAG_harmony_destructuring = true; |
| 6390 static const ParserFlag always_flags[] = {kAllowHarmonyDestructuring}; | 6405 static const ParserFlag always_flags[] = {kAllowHarmonyObjectLiterals, |
| 6406 kAllowHarmonyDestructuring}; | |
| 6391 | 6407 |
| 6392 { // All modes. | 6408 { // All modes. |
| 6393 const char* context_data[][2] = {{"'use strict'; let ", " = {};"}, | 6409 const char* context_data[][2] = {{"'use strict'; let ", " = {};"}, |
| 6394 {"var ", " = {};"}, | 6410 {"var ", " = {};"}, |
| 6395 {"'use strict'; const ", " = {};"}, | 6411 {"'use strict'; const ", " = {};"}, |
| 6396 {NULL, NULL}}; | 6412 {NULL, NULL}}; |
| 6397 | 6413 |
| 6398 // clang-format off | 6414 // clang-format off |
| 6399 const char* data[] = { | 6415 const char* data[] = { |
| 6400 "a++", | 6416 "a++", |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6432 "false", | 6448 "false", |
| 6433 "1", | 6449 "1", |
| 6434 "'abc'", | 6450 "'abc'", |
| 6435 "class {}", | 6451 "class {}", |
| 6436 "() => x", | 6452 "() => x", |
| 6437 "{+2 : x}", | 6453 "{+2 : x}", |
| 6438 "{-2 : x}", | 6454 "{-2 : x}", |
| 6439 "var", | 6455 "var", |
| 6440 "[var]", | 6456 "[var]", |
| 6441 "{x : {y : var}}", | 6457 "{x : {y : var}}", |
| 6458 "{x : x = a+}", | |
| 6459 "{x : x = (a+)}", | |
| 6460 "{x : x += a}", | |
|
rossberg
2015/05/18 16:17:19
Add a test with method syntax, e.g. "{m() {} = 0}"
Dmitry Lomov (no reviews)
2015/05/18 17:31:22
Done.
| |
| 6442 NULL}; | 6461 NULL}; |
| 6443 // clang-format on | 6462 // clang-format on |
| 6444 RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags, | 6463 RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags, |
| 6445 arraysize(always_flags)); | 6464 arraysize(always_flags)); |
| 6446 } | 6465 } |
| 6447 | 6466 |
| 6448 { // Strict mode. | 6467 { // Strict mode. |
| 6449 const char* context_data[][2] = {{"'use strict'; let ", " = {};"}, | 6468 const char* context_data[][2] = {{"'use strict'; let ", " = {};"}, |
| 6450 {"'use strict'; const ", " = {};"}, | 6469 {"'use strict'; const ", " = {};"}, |
| 6451 {NULL, NULL}}; | 6470 {NULL, NULL}}; |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 6473 const char* data[] = { | 6492 const char* data[] = { |
| 6474 "yield", | 6493 "yield", |
| 6475 "[yield]", | 6494 "[yield]", |
| 6476 "{ x : yield }", | 6495 "{ x : yield }", |
| 6477 NULL}; | 6496 NULL}; |
| 6478 // clang-format on | 6497 // clang-format on |
| 6479 RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags, | 6498 RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags, |
| 6480 arraysize(always_flags)); | 6499 arraysize(always_flags)); |
| 6481 } | 6500 } |
| 6482 } | 6501 } |
| OLD | NEW |