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* context_data[][2] = { | |
6352 {"", ""}, | |
6353 {NULL, NULL} | |
6354 }; | |
6355 | |
6356 const char* data[] = { | |
6357 "var {eval} = {}", | |
6358 "var {arguments} = {}", | |
6359 "'use strict'; var {eval: x} = {eval: 5};", | |
6360 "'use strict'; var {arguments: x} = {arguments: 5};", | |
6361 "(() => { function f({eval = false } = {}) {} })()", | |
6362 NULL, | |
6363 }; | |
6364 | |
6365 RunParserSyncTest(context_data, data, kSuccess); | |
6366 } | |
6348 } | 6367 } |
6349 | 6368 |
6350 | 6369 |
6351 TEST(DestructuringNegativeTests) { | 6370 TEST(DestructuringNegativeTests) { |
6352 { // All modes. | 6371 { // All modes. |
6353 const char* context_data[][2] = {{"'use strict'; let ", " = {};"}, | 6372 const char* context_data[][2] = {{"'use strict'; let ", " = {};"}, |
6354 {"var ", " = {};"}, | 6373 {"var ", " = {};"}, |
6355 {"'use strict'; const ", " = {};"}, | 6374 {"'use strict'; const ", " = {};"}, |
6356 {"function f(", ") {}"}, | 6375 {"function f(", ") {}"}, |
6357 {"function f(argument1, ", ") {}"}, | 6376 {"function f(argument1, ", ") {}"}, |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6462 {"'use strict'; function f(", ") {}"}, | 6481 {"'use strict'; function f(", ") {}"}, |
6463 {"'use strict'; function f(argument1, ", ") {}"}, | 6482 {"'use strict'; function f(argument1, ", ") {}"}, |
6464 {NULL, NULL}}; | 6483 {NULL, NULL}}; |
6465 | 6484 |
6466 // clang-format off | 6485 // clang-format off |
6467 const char* data[] = { | 6486 const char* data[] = { |
6468 "[eval]", | 6487 "[eval]", |
6469 "{ a : arguments }", | 6488 "{ a : arguments }", |
6470 "[public]", | 6489 "[public]", |
6471 "{ x : private }", | 6490 "{ x : private }", |
6491 "{eval}", | |
6492 "{arguments}", | |
adamk
2016/08/17 19:32:51
Can you flesh out this test coverage while you're
lpy
2016/08/19 17:00:40
Done.
| |
6472 NULL}; | 6493 NULL}; |
6473 // clang-format on | 6494 // clang-format on |
6474 RunParserSyncTest(context_data, data, kError); | 6495 RunParserSyncTest(context_data, data, kError); |
6475 } | 6496 } |
6476 | 6497 |
6477 { // 'yield' in generators. | 6498 { // 'yield' in generators. |
6478 const char* context_data[][2] = { | 6499 const char* context_data[][2] = { |
6479 {"function*() { var ", " = {};"}, | 6500 {"function*() { var ", " = {};"}, |
6480 {"function*() { 'use strict'; let ", " = {};"}, | 6501 {"function*() { 'use strict'; let ", " = {};"}, |
6481 {"function*() { 'use strict'; const ", " = {};"}, | 6502 {"function*() { 'use strict'; const ", " = {};"}, |
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6865 "[ (arguments) = 0 ]", | 6886 "[ (arguments) = 0 ]", |
6866 "[ ...(eval) ]", | 6887 "[ ...(eval) ]", |
6867 "[ ...(arguments) ]", | 6888 "[ ...(arguments) ]", |
6868 "[ ...(eval = 0) ]", | 6889 "[ ...(eval = 0) ]", |
6869 "[ ...(arguments = 0) ]", | 6890 "[ ...(arguments = 0) ]", |
6870 "[ ...(eval) = 0 ]", | 6891 "[ ...(eval) = 0 ]", |
6871 "[ ...(arguments) = 0 ]", | 6892 "[ ...(arguments) = 0 ]", |
6872 | 6893 |
6873 NULL}; | 6894 NULL}; |
6874 RunParserSyncTest(strict_context_data, strict_data, kError); | 6895 RunParserSyncTest(strict_context_data, strict_data, kError); |
6896 | |
6897 // v8:5201 | |
adamk
2016/08/17 19:32:51
Isn't this block now redundant with the tests you
lpy
2016/08/19 17:00:40
Done.
| |
6898 { | |
6899 // clang-format off | |
6900 const char* context_data[][2] = { | |
6901 {"'use strict'; var {", "} = {};"}, | |
6902 {"(() => { 'use strict'; function a({", " = false } = {}) {} })()"}, | |
6903 {NULL, NULL} | |
6904 }; | |
6905 | |
6906 const char* data[] = { | |
6907 "eval", | |
6908 "arguments", | |
6909 NULL | |
6910 }; | |
6911 | |
6912 // clang-format on | |
6913 RunParserSyncTest(context_data, data, kError); | |
6914 } | |
6875 } | 6915 } |
6876 | 6916 |
6877 | 6917 |
6878 TEST(DestructuringDisallowPatternsInForVarIn) { | 6918 TEST(DestructuringDisallowPatternsInForVarIn) { |
6879 const char* context_data[][2] = { | 6919 const char* context_data[][2] = { |
6880 {"", ""}, {"function f() {", "}"}, {NULL, NULL}}; | 6920 {"", ""}, {"function f() {", "}"}, {NULL, NULL}}; |
6881 // clang-format off | 6921 // clang-format off |
6882 const char* error_data[] = { | 6922 const char* error_data[] = { |
6883 "for (let x = {} in null);", | 6923 "for (let x = {} in null);", |
6884 "for (let x = {} of null);", | 6924 "for (let x = {} of null);", |
(...skipping 1256 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 |