Index: test/cctest/test-parsing.cc |
diff --git a/test/cctest/test-parsing.cc b/test/cctest/test-parsing.cc |
index a239dfa81bcd446aceda6a81e801df9c2c7d0530..f2e90ae259902619df96b46725597579bbd395c0 100644 |
--- a/test/cctest/test-parsing.cc |
+++ b/test/cctest/test-parsing.cc |
@@ -1263,6 +1263,7 @@ enum ParserFlag { |
kAllowHarmonyObjectRestSpread, |
kAllowHarmonyDynamicImport, |
kAllowHarmonyAsyncIteration, |
+ kAllowHarmonyTemplateEscapes, |
}; |
enum ParserSyncTestResult { |
@@ -1282,6 +1283,8 @@ void SetGlobalFlags(i::EnumSet<ParserFlag> flags) { |
flags.Contains(kAllowHarmonyObjectRestSpread); |
i::FLAG_harmony_dynamic_import = flags.Contains(kAllowHarmonyDynamicImport); |
i::FLAG_harmony_async_iteration = flags.Contains(kAllowHarmonyAsyncIteration); |
+ i::FLAG_harmony_template_escapes = |
+ flags.Contains(kAllowHarmonyTemplateEscapes); |
} |
void SetParserFlags(i::PreParser* parser, i::EnumSet<ParserFlag> flags) { |
@@ -1300,6 +1303,8 @@ void SetParserFlags(i::PreParser* parser, i::EnumSet<ParserFlag> flags) { |
flags.Contains(kAllowHarmonyDynamicImport)); |
parser->set_allow_harmony_async_iteration( |
flags.Contains(kAllowHarmonyAsyncIteration)); |
+ parser->set_allow_harmony_template_escapes( |
+ flags.Contains(kAllowHarmonyTemplateEscapes)); |
} |
void TestParserSyncWithFlags(i::Handle<i::String> source, |
@@ -7067,6 +7072,7 @@ TEST(ObjectSpreadPositiveTests) { |
"{ ...async () => { }}", |
"{ ...new Foo()}", |
NULL}; |
+ // clang-format on |
static const ParserFlag flags[] = {kAllowHarmonyObjectRestSpread}; |
RunParserSyncTest(context_data, data, kSuccess, NULL, 0, flags, |
@@ -7090,6 +7096,161 @@ TEST(ObjectSpreadNegativeTests) { |
arraysize(flags)); |
} |
+TEST(TemplateEscapesPositiveTests) { |
+ // clang-format off |
+ const char* context_data[][2] = { |
+ {"", ""}, |
+ {"'use strict';", ""}, |
+ {NULL, NULL}}; |
+ |
+ // clang-format off |
+ const char* data[] = { |
+ "tag`\\01`", |
+ "tag`\\01${0}right`", |
+ "tag`left${0}\\01`", |
+ "tag`left${0}\\01${1}right`", |
+ "tag`\\1`", |
+ "tag`\\1${0}right`", |
+ "tag`left${0}\\1`", |
+ "tag`left${0}\\1${1}right`", |
+ "tag`\\xg`", |
+ "tag`\\xg${0}right`", |
+ "tag`left${0}\\xg`", |
+ "tag`left${0}\\xg${1}right`", |
+ "tag`\\xAg`", |
+ "tag`\\xAg${0}right`", |
+ "tag`left${0}\\xAg`", |
+ "tag`left${0}\\xAg${1}right`", |
+ "tag`\\u0`", |
+ "tag`\\u0${0}right`", |
+ "tag`left${0}\\u0`", |
+ "tag`left${0}\\u0${1}right`", |
+ "tag`\\u0g`", |
+ "tag`\\u0g${0}right`", |
+ "tag`left${0}\\u0g`", |
+ "tag`left${0}\\u0g${1}right`", |
+ "tag`\\u00g`", |
+ "tag`\\u00g${0}right`", |
+ "tag`left${0}\\u00g`", |
+ "tag`left${0}\\u00g${1}right`", |
+ "tag`\\u000g`", |
+ "tag`\\u000g${0}right`", |
+ "tag`left${0}\\u000g`", |
+ "tag`left${0}\\u000g${1}right`", |
+ "tag`\\u{}`", |
+ "tag`\\u{}${0}right`", |
+ "tag`left${0}\\u{}`", |
+ "tag`left${0}\\u{}${1}right`", |
+ "tag`\\u{-0}`", |
+ "tag`\\u{-0}${0}right`", |
+ "tag`left${0}\\u{-0}`", |
+ "tag`left${0}\\u{-0}${1}right`", |
+ "tag`\\u{g}`", |
+ "tag`\\u{g}${0}right`", |
+ "tag`left${0}\\u{g}`", |
+ "tag`left${0}\\u{g}${1}right`", |
+ "tag`\\u{0`", |
+ "tag`\\u{0${0}right`", |
+ "tag`left${0}\\u{0`", |
+ "tag`left${0}\\u{0${1}right`", |
+ "tag`\\u{\\u{0}`", |
+ "tag`\\u{\\u{0}${0}right`", |
+ "tag`left${0}\\u{\\u{0}`", |
+ "tag`left${0}\\u{\\u{0}${1}right`", |
+ "tag`\\u{110000}`", |
+ "tag`\\u{110000}${0}right`", |
+ "tag`left${0}\\u{110000}`", |
+ "tag`left${0}\\u{110000}${1}right`", |
+ NULL}; |
+ // clang-format on |
+ |
+ // No error with flag |
+ static const ParserFlag flags[] = {kAllowHarmonyTemplateEscapes}; |
+ RunParserSyncTest(context_data, data, kSuccess, NULL, 0, flags, |
+ arraysize(flags)); |
+ |
+ // Still an error without flag |
+ RunParserSyncTest(context_data, data, kError); |
+} |
+ |
+TEST(TemplateEscapesNegativeTests) { |
+ // clang-format off |
+ const char* context_data[][2] = { |
+ {"", ""}, |
+ {"'use strict';", ""}, |
+ {NULL, NULL}}; |
+ |
+ // clang-format off |
+ const char* data[] = { |
+ "`\\01`", |
+ "`\\01${0}right`", |
+ "`left${0}\\01`", |
+ "`left${0}\\01${1}right`", |
+ "`\\1`", |
+ "`\\1${0}right`", |
+ "`left${0}\\1`", |
+ "`left${0}\\1${1}right`", |
+ "`\\xg`", |
+ "`\\xg${0}right`", |
+ "`left${0}\\xg`", |
+ "`left${0}\\xg${1}right`", |
+ "`\\xAg`", |
+ "`\\xAg${0}right`", |
+ "`left${0}\\xAg`", |
+ "`left${0}\\xAg${1}right`", |
+ "`\\u0`", |
+ "`\\u0${0}right`", |
+ "`left${0}\\u0`", |
+ "`left${0}\\u0${1}right`", |
+ "`\\u0g`", |
+ "`\\u0g${0}right`", |
+ "`left${0}\\u0g`", |
+ "`left${0}\\u0g${1}right`", |
+ "`\\u00g`", |
+ "`\\u00g${0}right`", |
+ "`left${0}\\u00g`", |
+ "`left${0}\\u00g${1}right`", |
+ "`\\u000g`", |
+ "`\\u000g${0}right`", |
+ "`left${0}\\u000g`", |
+ "`left${0}\\u000g${1}right`", |
+ "`\\u{}`", |
+ "`\\u{}${0}right`", |
+ "`left${0}\\u{}`", |
+ "`left${0}\\u{}${1}right`", |
+ "`\\u{-0}`", |
+ "`\\u{-0}${0}right`", |
+ "`left${0}\\u{-0}`", |
+ "`left${0}\\u{-0}${1}right`", |
+ "`\\u{g}`", |
+ "`\\u{g}${0}right`", |
+ "`left${0}\\u{g}`", |
+ "`left${0}\\u{g}${1}right`", |
+ "`\\u{0`", |
+ "`\\u{0${0}right`", |
+ "`left${0}\\u{0`", |
+ "`left${0}\\u{0${1}right`", |
+ "`\\u{\\u{0}`", |
+ "`\\u{\\u{0}${0}right`", |
+ "`left${0}\\u{\\u{0}`", |
+ "`left${0}\\u{\\u{0}${1}right`", |
+ "`\\u{110000}`", |
+ "`\\u{110000}${0}right`", |
+ "`left${0}\\u{110000}`", |
+ "`left${0}\\u{110000}${1}right`", |
+ "`\\1``\\2`", |
+ NULL}; |
+ // clang-format on |
+ |
+ // Error with flag |
+ static const ParserFlag flags[] = {kAllowHarmonyTemplateEscapes}; |
+ RunParserSyncTest(context_data, data, kError, NULL, 0, flags, |
+ arraysize(flags)); |
+ |
+ // Still an error without flag |
+ RunParserSyncTest(context_data, data, kError); |
+} |
+ |
TEST(DestructuringPositiveTests) { |
const char* context_data[][2] = {{"'use strict'; let ", " = {};"}, |
{"var ", " = {};"}, |