Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(488)

Side by Side Diff: test/cctest/test-parsing.cc

Issue 2290753003: Allow lexically declared "arguments" in function scope in sloppy mode. (Closed)
Patch Set: update Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 6282 matching lines...) Expand 10 before | Expand all | Expand 10 after
6293 "[a,b,...rest]", 6293 "[a,b,...rest]",
6294 "[a,,...rest]", 6294 "[a,,...rest]",
6295 "{ __proto__: x, __proto__: y}", 6295 "{ __proto__: x, __proto__: y}",
6296 "{arguments: x}", 6296 "{arguments: x}",
6297 "{eval: x}", 6297 "{eval: x}",
6298 NULL}; 6298 NULL};
6299 // clang-format on 6299 // clang-format on
6300 RunParserSyncTest(context_data, data, kSuccess); 6300 RunParserSyncTest(context_data, data, kSuccess);
6301 6301
6302 // v8:5201 6302 // v8:5201
6303 // TODO(lpy): The two test sets below should be merged once
6304 // we fix https://bugs.chromium.org/p/v8/issues/detail?id=4577
6305 { 6303 {
6306 const char* sloppy_context_data1[][2] = { 6304 const char* sloppy_context_data[][2] = {
6307 {"var ", " = {};"}, 6305 {"var ", " = {};"},
6308 {"function f(", ") {}"}, 6306 {"function f(", ") {}"},
6309 {"function f(argument1, ", ") {}"}, 6307 {"function f(argument1, ", ") {}"},
6310 {"var f = (", ") => {};"}, 6308 {"var f = (", ") => {};"},
6311 {"var f = (argument1,", ") => {};"}, 6309 {"var f = (argument1,", ") => {};"},
6312 {"try {} catch(", ") {}"}, 6310 {"try {} catch(", ") {}"},
6313 {NULL, NULL} 6311 {NULL, NULL}
6314 }; 6312 };
6315 const char* data1[] = { 6313 const char* data[] = {
6314 "{arguments}",
6316 "{eval}", 6315 "{eval}",
6316 "{x: arguments}",
6317 "{x: eval}", 6317 "{x: eval}",
6318 "{arguments = false}",
6318 "{eval = false}", 6319 "{eval = false}",
6319 NULL 6320 NULL
6320 }; 6321 };
6321 RunParserSyncTest(sloppy_context_data1, data1, kSuccess); 6322 RunParserSyncTest(sloppy_context_data, data, kSuccess);
6322
6323 const char* sloppy_context_data2[][2] = {
6324 {"var ", " = {};"},
6325 {"try {} catch(", ") {}"},
6326 {NULL, NULL}
6327 };
6328 const char* data2[] = {
6329 "{arguments}",
6330 "{x: arguments}",
6331 "{arguments = false}",
6332 NULL,
6333 };
6334 RunParserSyncTest(sloppy_context_data2, data2, kSuccess);
6335 } 6323 }
6336 } 6324 }
6337 6325
6338 6326
6339 TEST(DestructuringNegativeTests) { 6327 TEST(DestructuringNegativeTests) {
6340 { // All modes. 6328 { // All modes.
6341 const char* context_data[][2] = {{"'use strict'; let ", " = {};"}, 6329 const char* context_data[][2] = {{"'use strict'; let ", " = {};"},
6342 {"var ", " = {};"}, 6330 {"var ", " = {};"},
6343 {"'use strict'; const ", " = {};"}, 6331 {"'use strict'; const ", " = {};"},
6344 {"function f(", ") {}"}, 6332 {"function f(", ") {}"},
(...skipping 1834 matching lines...) Expand 10 before | Expand all | Expand 10 after
8179 "(a,);", 8167 "(a,);",
8180 "(a,b,c,);", 8168 "(a,b,c,);",
8181 NULL 8169 NULL
8182 }; 8170 };
8183 // clang-format on 8171 // clang-format on
8184 8172
8185 static const ParserFlag always_flags[] = {kAllowHarmonyTrailingCommas}; 8173 static const ParserFlag always_flags[] = {kAllowHarmonyTrailingCommas};
8186 RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags, 8174 RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags,
8187 arraysize(always_flags)); 8175 arraysize(always_flags));
8188 } 8176 }
8177
8178 TEST(ArgumentsRedeclaration) {
8179 {
8180 const char* context_data[][2] = {
8181 { "function f(", ") {}" },
8182 { NULL, NULL }
8183 };
8184 const char* success_data[] = {
8185 "{arguments}",
8186 "{arguments = false}",
8187 "arg1, arguments",
8188 "arg1, ...arguments",
8189 NULL
8190 };
8191 RunParserSyncTest(context_data, success_data, kSuccess);
8192 }
8193
8194 {
8195 const char* context_data[][2] = {
8196 { "function f() {", "}" },
8197 { NULL, NULL }
8198 };
8199 const char* data[] = {
8200 "const arguments",
adamk 2016/09/01 17:36:26 This one needs an initializer, as the test failure
lpy 2016/09/01 20:00:55 Done.
8201 "let arguments",
8202 "var arguments",
8203 NULL
8204 };
8205 RunParserSyncTest(context_data, data, kSuccess);
8206 }
8207 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698