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

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

Issue 1125183008: [es6] Spread in array literals (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: cleanup Created 5 years, 7 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/x64/full-codegen-x64.cc ('k') | test/mjsunit/harmony/spread-array.js » ('j') | 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 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));
+}
« no previous file with comments | « src/x64/full-codegen-x64.cc ('k') | test/mjsunit/harmony/spread-array.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698