| Index: test/cctest/test-parsing.cc
|
| diff --git a/test/cctest/test-parsing.cc b/test/cctest/test-parsing.cc
|
| index d99b2b86aea2d96c1bd16c92d05c7d1f3d5d468d..659680d8288989917b64a7a2cadd9510b7d2e1f4 100644
|
| --- a/test/cctest/test-parsing.cc
|
| +++ b/test/cctest/test-parsing.cc
|
| @@ -1366,6 +1366,7 @@ enum ParserFlag {
|
| kAllowHarmonyComputedPropertyNames,
|
| kAllowHarmonySpreadCalls,
|
| kAllowHarmonyDestructuring,
|
| + kAllowHarmonySpreadArrays,
|
| kAllowStrongMode
|
| };
|
|
|
| @@ -1397,6 +1398,8 @@ void SetParserFlags(i::ParserBase<Traits>* parser,
|
| flags.Contains(kAllowHarmonyComputedPropertyNames));
|
| parser->set_allow_harmony_destructuring(
|
| flags.Contains(kAllowHarmonyDestructuring));
|
| + parser->set_allow_harmony_spread_arrays(
|
| + flags.Contains(kAllowHarmonySpreadArrays));
|
| parser->set_allow_strong_mode(flags.Contains(kAllowStrongMode));
|
| }
|
|
|
| @@ -6520,3 +6523,50 @@ TEST(DestructuringNegativeTests) {
|
| arraysize(always_flags));
|
| }
|
| }
|
| +
|
| +
|
| +TEST(SpreadArray) {
|
| + i::FLAG_harmony_spread_arrays = true;
|
| +
|
| + const char* context_data[][2] = {
|
| + {"'use strict';", ""}, {"", ""}, {NULL, NULL}};
|
| +
|
| + // clang-format off
|
| + const char* data[] = {
|
| + "[...a]",
|
| + "[a, ...b]",
|
| + "[...a,]",
|
| + "[...a, ,]",
|
| + "[, ...a]",
|
| + "[...a, ...b]",
|
| + "[...a, , ...b]",
|
| + "[...[...a]]",
|
| + "[, ...a]",
|
| + "[, , ...a]",
|
| + NULL};
|
| + // clang-format on
|
| + static const ParserFlag always_flags[] = {kAllowHarmonySpreadArrays};
|
| + RunParserSyncTest(context_data, data, kSuccess, NULL, 0, always_flags,
|
| + arraysize(always_flags));
|
| +}
|
| +
|
| +
|
| +TEST(SpreadArrayError) {
|
| + i::FLAG_harmony_spread_arrays = true;
|
| +
|
| + const char* context_data[][2] = {
|
| + {"'use strict';", ""}, {"", ""}, {NULL, NULL}};
|
| +
|
| + // clang-format off
|
| + const char* data[] = {
|
| + "[...]",
|
| + "[a, ...]",
|
| + "[..., ]",
|
| + "[..., ...]",
|
| + "[ (...a)]",
|
| + NULL};
|
| + // clang-format on
|
| + static const ParserFlag always_flags[] = {kAllowHarmonySpreadArrays};
|
| + RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags,
|
| + arraysize(always_flags));
|
| +}
|
|
|