Chromium Code Reviews| Index: test/cctest/test-parsing.cc |
| diff --git a/test/cctest/test-parsing.cc b/test/cctest/test-parsing.cc |
| index 5a7809c5862a0aefde1ab7ae76360306b63fc550..312268f6a85168c96eb97ae1ef009f4f9eeb9085 100644 |
| --- a/test/cctest/test-parsing.cc |
| +++ b/test/cctest/test-parsing.cc |
| @@ -1286,6 +1286,7 @@ enum ParserFlag { |
| kAllowHarmonyClassFields, |
| kAllowHarmonyObjectRestSpread, |
| kAllowHarmonyDynamicImport, |
| + kAllowHarmonyTemplateEscapes, |
| }; |
| enum ParserSyncTestResult { |
| @@ -1304,6 +1305,8 @@ void SetGlobalFlags(i::EnumSet<ParserFlag> flags) { |
| i::FLAG_harmony_object_rest_spread = |
| flags.Contains(kAllowHarmonyObjectRestSpread); |
| i::FLAG_harmony_dynamic_import = flags.Contains(kAllowHarmonyDynamicImport); |
| + i::FLAG_harmony_template_escapes = |
| + flags.Contains(kAllowHarmonyTemplateEscapes); |
| } |
| void SetParserFlags(i::PreParser* parser, i::EnumSet<ParserFlag> flags) { |
| @@ -1320,6 +1323,8 @@ void SetParserFlags(i::PreParser* parser, i::EnumSet<ParserFlag> flags) { |
| flags.Contains(kAllowHarmonyObjectRestSpread)); |
| parser->set_allow_harmony_dynamic_import( |
| flags.Contains(kAllowHarmonyDynamicImport)); |
| + parser->set_allow_harmony_template_escapes( |
| + flags.Contains(kAllowHarmonyTemplateEscapes)); |
| } |
| void TestParserSyncWithFlags(i::Handle<i::String> source, |
| @@ -6747,6 +6752,7 @@ TEST(ObjectSpreadPositiveTests) { |
| "{ ...async () => { }}", |
| "{ ...new Foo()}", |
| NULL}; |
| + // clang-format on |
| static const ParserFlag flags[] = {kAllowHarmonyObjectRestSpread}; |
| RunParserSyncTest(context_data, data, kSuccess, NULL, 0, flags, |
| @@ -6770,6 +6776,152 @@ 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 |
| + |
| + static const ParserFlag flags[] = {kAllowHarmonyTemplateEscapes}; |
| + RunParserSyncTest(context_data, data, kSuccess, NULL, 0, flags, |
|
vogelheim
2017/02/13 17:36:06
If I read this correctly, this tests the behaviour
bakkot1
2017/02/13 20:22:24
I was figuring the existing tests would suffice fo
vogelheim
2017/02/17 16:33:53
Well, I was thinking more about also running the n
bakkot1
2017/02/17 20:42:18
Done.
|
| + arraysize(flags)); |
| +} |
| + |
| +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`", |
| + NULL}; |
| + // clang-format on |
| + |
| + static const ParserFlag flags[] = {kAllowHarmonyTemplateEscapes}; |
| + RunParserSyncTest(context_data, data, kError, NULL, 0, flags, |
| + arraysize(flags)); |
| +} |
| + |
| TEST(DestructuringPositiveTests) { |
| const char* context_data[][2] = {{"'use strict'; let ", " = {};"}, |
| {"var ", " = {};"}, |