Chromium Code Reviews| Index: test/cctest/test-parsing.cc |
| diff --git a/test/cctest/test-parsing.cc b/test/cctest/test-parsing.cc |
| index 2ee81cf6ce417303425a24b7eef832433d7f9179..35aacdcfeb52865b639f91204ab4a1ab677162ea 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) { |
| } |
|
marja
2015/02/16 09:12:02
Hmm, do we have tests for duplicate params in test
caitp (gmail)
2015/02/16 16:42:53
Done.
|
| +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", |
|
arv (Not doing code reviews)
2015/02/15 21:38:34
Wow, that is terrible. I think this is a spec bug.
|
| + "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] = { |
| {"", ""}, |