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 5277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5288 | 5288 |
5289 | 5289 |
5290 TEST(ParseRestParameters) { | 5290 TEST(ParseRestParameters) { |
5291 const char* context_data[][2] = {{"'use strict';(function(", | 5291 const char* context_data[][2] = {{"'use strict';(function(", |
5292 "){ return args;})(1, [], /regexp/, 'str'," | 5292 "){ return args;})(1, [], /regexp/, 'str'," |
5293 "function(){});"}, | 5293 "function(){});"}, |
5294 {"(function(", "){ return args;})(1, []," | 5294 {"(function(", "){ return args;})(1, []," |
5295 "/regexp/, 'str', function(){});"}, | 5295 "/regexp/, 'str', function(){});"}, |
5296 {NULL, NULL}}; | 5296 {NULL, NULL}}; |
5297 | 5297 |
5298 const char* data[] = { | 5298 const char* data[] = {"...args", |
5299 "...args", | 5299 "a, ...args", |
5300 "a, ...args", | 5300 "... args", |
5301 "... args", | 5301 "a, ... args", |
5302 "a, ... args", | 5302 "...\targs", |
5303 "...\targs", | 5303 "a, ...\targs", |
5304 "a, ...\targs", | 5304 "...\r\nargs", |
5305 "...\r\nargs", | 5305 "a, ...\r\nargs", |
5306 "a, ...\r\nargs", | 5306 "...\rargs", |
5307 "...\rargs", | 5307 "a, ...\rargs", |
5308 "a, ...\rargs", | 5308 "...\t\n\t\t\n args", |
5309 "...\t\n\t\t\n args", | 5309 "a, ... \n \n args", |
5310 "a, ... \n \n args", | 5310 "...{ length, 0: a, 1: b}", |
5311 NULL}; | 5311 "...{}", |
5312 RunParserSyncTest(context_data, data, kSuccess); | 5312 "...[a, b]", |
| 5313 "...[]", |
| 5314 "...[...[a, b, ...c]]", |
| 5315 NULL}; |
| 5316 static const ParserFlag always_flags[] = {kAllowHarmonyDestructuring}; |
| 5317 RunParserSyncTest(context_data, data, kSuccess, nullptr, 0, always_flags, |
| 5318 arraysize(always_flags)); |
5313 } | 5319 } |
5314 | 5320 |
5315 | 5321 |
5316 TEST(ParseRestParametersErrors) { | 5322 TEST(ParseRestParametersErrors) { |
5317 const char* context_data[][2] = {{"'use strict';(function(", | 5323 const char* context_data[][2] = {{"'use strict';(function(", |
5318 "){ return args;}(1, [], /regexp/, 'str'," | 5324 "){ return args;}(1, [], /regexp/, 'str'," |
5319 "function(){});"}, | 5325 "function(){});"}, |
5320 {"(function(", "){ return args;}(1, []," | 5326 {"(function(", "){ return args;}(1, []," |
5321 "/regexp/, 'str', function(){});"}, | 5327 "/regexp/, 'str', function(){});"}, |
5322 {NULL, NULL}}; | 5328 {NULL, NULL}}; |
(...skipping 1872 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7195 const char* error_data[] = { | 7201 const char* error_data[] = { |
7196 "var f = {x} => {};", | 7202 "var f = {x} => {};", |
7197 "var f = {x,y} => {};", | 7203 "var f = {x,y} => {};", |
7198 nullptr}; | 7204 nullptr}; |
7199 // clang-format on | 7205 // clang-format on |
7200 RunParserSyncTest(context_data, error_data, kError, NULL, 0, always_flags, | 7206 RunParserSyncTest(context_data, error_data, kError, NULL, 0, always_flags, |
7201 arraysize(always_flags)); | 7207 arraysize(always_flags)); |
7202 } | 7208 } |
7203 | 7209 |
7204 | 7210 |
7205 TEST(DestructuringDisallowPatternsInRestParams) { | |
7206 i::FLAG_harmony_destructuring_bind = true; | |
7207 static const ParserFlag always_flags[] = {kAllowHarmonyDestructuring}; | |
7208 const char* context_data[][2] = {{"'use strict';", ""}, | |
7209 {"function outer() { 'use strict';", "}"}, | |
7210 {"", ""}, | |
7211 {"function outer() { ", "}"}, | |
7212 {nullptr, nullptr}}; | |
7213 | |
7214 // clang-format off | |
7215 const char* error_data[] = { | |
7216 "function(...{}) {}", | |
7217 "function(...{x}) {}", | |
7218 "function(...[x]) {}", | |
7219 "(...{}) => {}", | |
7220 "(...{x}) => {}", | |
7221 "(...[x]) => {}", | |
7222 nullptr}; | |
7223 // clang-format on | |
7224 RunParserSyncTest(context_data, error_data, kError, NULL, 0, always_flags, | |
7225 arraysize(always_flags)); | |
7226 } | |
7227 | |
7228 | |
7229 TEST(DefaultParametersYieldInInitializers) { | 7211 TEST(DefaultParametersYieldInInitializers) { |
7230 // clang-format off | 7212 // clang-format off |
7231 const char* sloppy_function_context_data[][2] = { | 7213 const char* sloppy_function_context_data[][2] = { |
7232 {"(function f(", ") { });"}, | 7214 {"(function f(", ") { });"}, |
7233 {NULL, NULL} | 7215 {NULL, NULL} |
7234 }; | 7216 }; |
7235 | 7217 |
7236 const char* strict_function_context_data[][2] = { | 7218 const char* strict_function_context_data[][2] = { |
7237 {"'use strong'; (function f(", ") { });"}, | 7219 {"'use strong'; (function f(", ") { });"}, |
7238 {"'use strict'; (function f(", ") { });"}, | 7220 {"'use strict'; (function f(", ") { });"}, |
(...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7788 } | 7770 } |
7789 | 7771 |
7790 | 7772 |
7791 TEST(MiscSyntaxErrors) { | 7773 TEST(MiscSyntaxErrors) { |
7792 const char* context_data[][2] = { | 7774 const char* context_data[][2] = { |
7793 {"'use strict'", ""}, {"", ""}, {NULL, NULL}}; | 7775 {"'use strict'", ""}, {"", ""}, {NULL, NULL}}; |
7794 const char* error_data[] = {"for (();;) {}", NULL}; | 7776 const char* error_data[] = {"for (();;) {}", NULL}; |
7795 | 7777 |
7796 RunParserSyncTest(context_data, error_data, kError, NULL, 0, NULL, 0); | 7778 RunParserSyncTest(context_data, error_data, kError, NULL, 0, NULL, 0); |
7797 } | 7779 } |
OLD | NEW |