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 6327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 NULL}; | 6345 NULL}; |
6346 // clang-format on | 6346 // clang-format on |
6347 RunParserSyncTest(context_data, data, kSuccess); | 6347 RunParserSyncTest(context_data, data, kSuccess); |
6348 | |
6349 // v8:5201 | |
6350 { | |
6351 const char* sloppy_context_data[][2] = { | |
6352 {"", ""}, | |
6353 {NULL, NULL} | |
6354 }; | |
6355 const char* data1[] = { | |
6356 "var {arguments} = {}", | |
6357 "var {eval} = {}", | |
6358 "var {x: arguments} = {x: 5}", | |
6359 "var {x: eval} = {x: 5}", | |
6360 "function f({eval = false } = {}) {}", | |
6361 "function f(argument1, {eval = false} = {}) {}", | |
6362 "function f(argument1, {eval} = {}) {}", | |
adamk
2016/08/19 18:14:56
Rather than enumerating different surrounding stuf
lpy
2016/08/19 18:58:17
Done.
| |
6363 NULL, | |
6364 }; | |
6365 RunParserSyncTest(sloppy_context_data, data1, kSuccess); | |
6366 | |
6367 const char* empty_context_data[][2] = { | |
6368 {"'use strict';", ""}, | |
6369 {"", ""}, | |
6370 {NULL, NULL} | |
6371 }; | |
6372 const char* data2[] = { | |
6373 "var {arguments: x} = {argumnets: 1};", | |
6374 "var {eval: x} = {eval: 1};", | |
adamk
2016/08/19 18:14:56
These two tests can just go in the main block of t
lpy
2016/08/19 18:58:17
Done.
| |
6375 NULL | |
6376 }; | |
6377 RunParserSyncTest(empty_context_data, data2, kSuccess); | |
6378 } | |
6348 } | 6379 } |
6349 | 6380 |
6350 | 6381 |
6351 TEST(DestructuringNegativeTests) { | 6382 TEST(DestructuringNegativeTests) { |
6352 { // All modes. | 6383 { // All modes. |
6353 const char* context_data[][2] = {{"'use strict'; let ", " = {};"}, | 6384 const char* context_data[][2] = {{"'use strict'; let ", " = {};"}, |
6354 {"var ", " = {};"}, | 6385 {"var ", " = {};"}, |
6355 {"'use strict'; const ", " = {};"}, | 6386 {"'use strict'; const ", " = {};"}, |
6356 {"function f(", ") {}"}, | 6387 {"function f(", ") {}"}, |
6357 {"function f(argument1, ", ") {}"}, | 6388 {"function f(argument1, ", ") {}"}, |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6450 const char* data[] = { | 6481 const char* data[] = { |
6451 "x => x", | 6482 "x => x", |
6452 "() => x", | 6483 "() => x", |
6453 NULL}; | 6484 NULL}; |
6454 // clang-format on | 6485 // clang-format on |
6455 RunParserSyncTest(context_data, data, kError); | 6486 RunParserSyncTest(context_data, data, kError); |
6456 } | 6487 } |
6457 | 6488 |
6458 { // Strict mode. | 6489 { // Strict mode. |
6459 const char* context_data[][2] = { | 6490 const char* context_data[][2] = { |
6491 {"'use strict'; var ", " = {};"}, | |
6460 {"'use strict'; let ", " = {};"}, | 6492 {"'use strict'; let ", " = {};"}, |
6461 {"'use strict'; const ", " = {};"}, | 6493 {"'use strict'; const ", " = {};"}, |
6462 {"'use strict'; function f(", ") {}"}, | 6494 {"'use strict'; function f(", ") {}"}, |
6463 {"'use strict'; function f(argument1, ", ") {}"}, | 6495 {"'use strict'; function f(argument1, ", ") {}"}, |
6464 {NULL, NULL}}; | 6496 {NULL, NULL}}; |
6465 | 6497 |
6466 // clang-format off | 6498 // clang-format off |
6467 const char* data[] = { | 6499 const char* data[] = { |
6500 "[arguments]", | |
6468 "[eval]", | 6501 "[eval]", |
6469 "{ a : arguments }", | 6502 "{ a : arguments }", |
6503 "{ a : eval }", | |
6470 "[public]", | 6504 "[public]", |
6471 "{ x : private }", | 6505 "{ x : private }", |
6506 "{ x : arguments }", | |
6507 "{ x : eval }", | |
6508 "{ arguments }", | |
6509 "{ eval }", | |
6510 "{ arguments = false }" | |
6511 "{ eval = false }", | |
6472 NULL}; | 6512 NULL}; |
6473 // clang-format on | 6513 // clang-format on |
6474 RunParserSyncTest(context_data, data, kError); | 6514 RunParserSyncTest(context_data, data, kError); |
6475 } | 6515 } |
6476 | 6516 |
6477 { // 'yield' in generators. | 6517 { // 'yield' in generators. |
6478 const char* context_data[][2] = { | 6518 const char* context_data[][2] = { |
6479 {"function*() { var ", " = {};"}, | 6519 {"function*() { var ", " = {};"}, |
6480 {"function*() { 'use strict'; let ", " = {};"}, | 6520 {"function*() { 'use strict'; let ", " = {};"}, |
6481 {"function*() { 'use strict'; const ", " = {};"}, | 6521 {"function*() { 'use strict'; const ", " = {};"}, |
(...skipping 1659 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
8141 "(a,);", | 8181 "(a,);", |
8142 "(a,b,c,);", | 8182 "(a,b,c,);", |
8143 NULL | 8183 NULL |
8144 }; | 8184 }; |
8145 // clang-format on | 8185 // clang-format on |
8146 | 8186 |
8147 static const ParserFlag always_flags[] = {kAllowHarmonyTrailingCommas}; | 8187 static const ParserFlag always_flags[] = {kAllowHarmonyTrailingCommas}; |
8148 RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags, | 8188 RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags, |
8149 arraysize(always_flags)); | 8189 arraysize(always_flags)); |
8150 } | 8190 } |
OLD | NEW |