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

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

Issue 2948903002: Reland "[parser] Forbid \08 in strict strings" (Closed)
Patch Set: Created 3 years, 6 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/parsing/scanner.cc ('k') | test/mjsunit/es6/templates.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 7f2a072e21fe6523dda8dc95048f11106807e22e..fa98a2b455ab9fafe0ec4442b932c4da3b6352ea 100644
--- a/test/cctest/test-parsing.cc
+++ b/test/cctest/test-parsing.cc
@@ -5901,6 +5901,33 @@ TEST(UnicodeEscapes) {
RunParserSyncTest(context_data, data, kSuccess);
}
+TEST(OctalEscapes) {
+ const char* sloppy_context_data[][2] = {{"", ""}, // as a directive
+ {"0;", ""}, // as a string literal
+ {NULL, NULL}};
+
+ const char* strict_context_data[][2] = {
+ {"'use strict';", ""}, // as a directive before 'use strict'
+ {"", ";'use strict';"}, // as a directive after 'use strict'
+ {"'use strict'; 0;", ""}, // as a string literal
+ {NULL, NULL}};
+
+ // clang-format off
+ const char* data[] = {
+ "'\\1'",
+ "'\\01'",
+ "'\\001'",
+ "'\\08'",
+ "'\\09'",
+ NULL};
+ // clang-format on
+
+ // Permitted in sloppy mode
+ RunParserSyncTest(sloppy_context_data, data, kSuccess);
+
+ // Error in strict mode
+ RunParserSyncTest(strict_context_data, data, kError);
+}
TEST(ScanTemplateLiterals) {
const char* context_data[][2] = {{"'use strict';", ""},
@@ -7112,6 +7139,7 @@ TEST(TemplateEscapesPositiveTests) {
// clang-format off
const char* data[] = {
+ "tag`\\08`",
"tag`\\01`",
"tag`\\01${0}right`",
"tag`left${0}\\01`",
@@ -7195,6 +7223,7 @@ TEST(TemplateEscapesNegativeTests) {
// clang-format off
const char* data[] = {
+ "`\\08`",
"`\\01`",
"`\\01${0}right`",
"`left${0}\\01`",
« no previous file with comments | « src/parsing/scanner.cc ('k') | test/mjsunit/es6/templates.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698