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

Unified Diff: test/cctest/test-parsing.cc

Issue 924403002: [parsing]: eval/arguments parameter names are ok in sloppy mode (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: test fix Created 5 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/scopes.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-parsing.cc
diff --git a/test/cctest/test-parsing.cc b/test/cctest/test-parsing.cc
index 2ee81cf6ce417303425a24b7eef832433d7f9179..7a624cb0bf38f99a55ade2350f72af62986ed960 100644
--- a/test/cctest/test-parsing.cc
+++ b/test/cctest/test-parsing.cc
@@ -3965,8 +3965,6 @@ TEST(MethodDefinitionStrictFormalParamereters) {
const char* params_data[] = {
"x, x",
"x, y, x",
- "eval",
- "arguments",
"var",
"const",
NULL
@@ -3978,6 +3976,57 @@ TEST(MethodDefinitionStrictFormalParamereters) {
}
+TEST(MethodDefinitionEvalArguments) {
+ const char* strict_context_data[][2] =
+ {{"'use strict'; ({method(", "){}});"},
+ {"'use strict'; ({*method(", "){}});"},
+ {NULL, NULL}};
+ const char* sloppy_context_data[][2] =
+ {{"({method(", "){}});"},
+ {"({*method(", "){}});"},
+ {NULL, NULL}};
+
+ const char* data[] = {
+ "eval",
+ "arguments",
+ NULL};
+
+ static const ParserFlag always_flags[] = {kAllowHarmonyObjectLiterals};
+
+ // Fail in strict mode
+ RunParserSyncTest(strict_context_data, data, kError, NULL, 0, always_flags,
+ arraysize(always_flags));
+
+ // OK in sloppy mode
+ RunParserSyncTest(sloppy_context_data, data, kSuccess, NULL, 0, always_flags,
+ arraysize(always_flags));
+}
+
+
+TEST(MethodDefinitionDuplicateEvalArguments) {
+ const char* context_data[][2] =
+ {{"'use strict'; ({method(", "){}});"},
+ {"'use strict'; ({*method(", "){}});"},
+ {"({method(", "){}});"},
+ {"({*method(", "){}});"},
+ {NULL, NULL}};
+
+ const char* data[] = {
+ "eval, eval",
+ "eval, a, eval",
+ "arguments, arguments",
+ "arguments, a, arguments",
+ NULL};
+
+ static const ParserFlag always_flags[] = {kAllowHarmonyObjectLiterals};
+
+ // In strict mode, the error is using "eval" or "arguments" as parameter names
+ // In sloppy mode, the error is that eval / arguments are duplicated
+ RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags,
+ arraysize(always_flags));
+}
+
+
TEST(MethodDefinitionDuplicateProperty) {
const char* context_data[][2] = {{"'use strict'; ({", "});"},
{NULL, NULL}};
@@ -4880,6 +4929,59 @@ TEST(ParseRestParametersErrors) {
}
+TEST(RestParametersEvalArguments) {
+ const char* strict_context_data[][2] =
+ {{"'use strict';(function(",
+ "){ return;})(1, [], /regexp/, 'str',function(){});"},
+ {NULL, NULL}};
+ const char* sloppy_context_data[][2] =
+ {{"(function(",
+ "){ return;})(1, [],/regexp/, 'str', function(){});"},
+ {NULL, NULL}};
+
+ const char* data[] = {
+ "...eval",
+ "eval, ...args",
+ "...arguments",
+ "arguments, ...args",
+ NULL};
+
+ static const ParserFlag always_flags[] = {kAllowHarmonyRestParameters};
+
+ // Fail in strict mode
+ RunParserSyncTest(strict_context_data, data, kError, NULL, 0, always_flags,
+ arraysize(always_flags));
+
+ // OK in sloppy mode
+ RunParserSyncTest(sloppy_context_data, data, kSuccess, NULL, 0, always_flags,
+ arraysize(always_flags));
+}
+
+
+TEST(RestParametersDuplicateEvalArguments) {
+ const char* context_data[][2] =
+ {{"'use strict';(function(",
+ "){ return;})(1, [], /regexp/, 'str',function(){});"},
+ {"(function(",
+ "){ return;})(1, [],/regexp/, 'str', function(){});"},
+ {NULL, NULL}};
+
+ const char* data[] = {
+ "eval, ...eval",
+ "eval, eval, ...args",
+ "arguments, ...arguments",
+ "arguments, arguments, ...args",
+ NULL};
+
+ static const ParserFlag always_flags[] = {kAllowHarmonyRestParameters};
+
+ // In strict mode, the error is using "eval" or "arguments" as parameter names
+ // In sloppy mode, the error is that eval / arguments are duplicated
+ RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags,
+ arraysize(always_flags));
+}
+
+
TEST(LexicalScopingSloppyMode) {
const char* context_data[][2] = {
{"", ""},
@@ -5317,3 +5419,37 @@ TEST(PropertyNameEvalArguments) {
RunParserSyncTest(context_data, statement_data, kSuccess, NULL, 0,
always_flags, arraysize(always_flags));
}
+
+
+TEST(FunctionLiteralDuplicateParameters) {
+ const char* strict_context_data[][2] =
+ {{"'use strict';(function(", "){})();"},
+ {"(function(", ") { 'use strict'; })();"},
+ {"'use strict'; function fn(", ") {}; fn();"},
+ {"function fn(", ") { 'use strict'; }; fn();"},
+ {"'use strong';(function(", "){})();"},
+ {"(function(", ") { 'use strong'; })();"},
+ {"'use strong'; function fn(", ") {}; fn();"},
+ {"function fn(", ") { 'use strong'; }; fn();"},
+ {NULL, NULL}};
+
+ const char* sloppy_context_data[][2] =
+ {{"(function(", "){})();"},
+ {"(function(", ") {})();"},
+ {"function fn(", ") {}; fn();"},
+ {"function fn(", ") {}; fn();"},
+ {NULL, NULL}};
+
+ const char* data[] = {
+ "a, a",
+ "a, a, a",
+ "b, a, a",
+ "a, b, c, c",
+ "a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, w",
+ NULL};
+
+ static const ParserFlag always_flags[] = { kAllowStrongMode };
+ RunParserSyncTest(strict_context_data, data, kError, NULL, 0, always_flags,
+ arraysize(always_flags));
+ RunParserSyncTest(sloppy_context_data, data, kSuccess, NULL, 0, NULL, 0);
+}
« no previous file with comments | « src/scopes.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698