Index: test/cctest/test-parsing.cc |
diff --git a/test/cctest/test-parsing.cc b/test/cctest/test-parsing.cc |
index 675b48797952dbaf3e0afd23b933c61651ea1998..803a806e57921c32a295f8b058b41ddc4ef540ac 100644 |
--- a/test/cctest/test-parsing.cc |
+++ b/test/cctest/test-parsing.cc |
@@ -6389,7 +6389,6 @@ TEST(DestructuringPositiveTests) { |
{"function f(", ") {}"}, |
{"function f(argument1, ", ") {}"}, |
{"var f = (", ") => {};"}, |
- {"var f = ", " => {};"}, |
{"var f = (argument1,", ") => {};"}, |
{NULL, NULL}}; |
@@ -6605,6 +6604,60 @@ TEST(DestructuringDisallowPatternsInForVarIn) { |
} |
+TEST(DestructuringDuplicateParams) { |
+ i::FLAG_harmony_destructuring = true; |
+ i::FLAG_harmony_arrow_functions = true; |
+ i::FLAG_harmony_computed_property_names = true; |
+ static const ParserFlag always_flags[] = { |
+ kAllowHarmonyObjectLiterals, kAllowHarmonyComputedPropertyNames, |
+ kAllowHarmonyArrowFunctions, kAllowHarmonyDestructuring}; |
+ const char* context_data[][2] = {{"'use strict';", ""}, |
+ {"function outer() { 'use strict';", "}"}, |
+ {nullptr, nullptr}}; |
+ |
+ |
+ // clang-format off |
+ const char* error_data[] = { |
+ "function f(x,x){}", |
+ "function f(x, {x : x}){}", |
+ "function f(x, {x}){}", |
+ "function f({x,x}) {}", |
+ // non-simple parameter list causes duplicates to be errors in sloppy mode. |
+ "function f(x, x, {a}) {}", |
+ "var f = {x,y} => {};", |
rossberg
2015/06/19 16:26:35
{x,x} ? But isn't this a plain syntax error anyway
Dmitry Lomov (no reviews)
2015/06/22 10:14:10
Moved to separate test.
|
+ nullptr}; |
+ // clang-format on |
+ RunParserSyncTest(context_data, error_data, kError, NULL, 0, always_flags, |
+ arraysize(always_flags)); |
+} |
+ |
+ |
+TEST(DestructuringDuplicateParamsSloppy) { |
+ i::FLAG_harmony_destructuring = true; |
+ i::FLAG_harmony_arrow_functions = true; |
+ i::FLAG_harmony_computed_property_names = true; |
+ static const ParserFlag always_flags[] = { |
+ kAllowHarmonyObjectLiterals, kAllowHarmonyComputedPropertyNames, |
+ kAllowHarmonyArrowFunctions, kAllowHarmonyDestructuring}; |
+ const char* context_data[][2] = { |
+ {"", ""}, {"function outer() {", "}"}, {nullptr, nullptr}}; |
+ |
+ |
+ // clang-format off |
+ const char* error_data[] = { |
+ // non-simple parameter list causes duplicates to be errors in sloppy mode. |
+ "function f(x, {x : x}){}", |
+ "function f(x, {x}){}", |
+ "function f({x,x}) {}", |
+ "function f(x, x, {a}) {}", |
+ "var f = {x} => {};", |
rossberg
2015/06/19 16:26:35
Same here, this test is unrelated to duplicates.
Dmitry Lomov (no reviews)
2015/06/22 10:14:10
Moved to separate test.
|
+ nullptr}; |
+ // clang-format on |
+ RunParserSyncTest(context_data, error_data, kError, NULL, 0, always_flags, |
+ arraysize(always_flags)); |
+} |
+ |
+ |
TEST(SpreadArray) { |
i::FLAG_harmony_spread_arrays = true; |