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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « src/parsing/scanner.cc ('k') | test/mjsunit/es6/templates.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 5883 matching lines...) Expand 10 before | Expand all | Expand 10 after
5894 "\"foob\\{uc481}r\"", 5894 "\"foob\\{uc481}r\"",
5895 // This character is a valid unicode character, representable as a surrogate 5895 // This character is a valid unicode character, representable as a surrogate
5896 // pair, not representable as 4 hex digits. 5896 // pair, not representable as 4 hex digits.
5897 "\"foo\\u{10e6d}\"", 5897 "\"foo\\u{10e6d}\"",
5898 // Max value for the unicode escape 5898 // Max value for the unicode escape
5899 "\"\\u{10ffff}\"", 5899 "\"\\u{10ffff}\"",
5900 NULL}; 5900 NULL};
5901 RunParserSyncTest(context_data, data, kSuccess); 5901 RunParserSyncTest(context_data, data, kSuccess);
5902 } 5902 }
5903 5903
5904 TEST(OctalEscapes) {
5905 const char* sloppy_context_data[][2] = {{"", ""}, // as a directive
5906 {"0;", ""}, // as a string literal
5907 {NULL, NULL}};
5908
5909 const char* strict_context_data[][2] = {
5910 {"'use strict';", ""}, // as a directive before 'use strict'
5911 {"", ";'use strict';"}, // as a directive after 'use strict'
5912 {"'use strict'; 0;", ""}, // as a string literal
5913 {NULL, NULL}};
5914
5915 // clang-format off
5916 const char* data[] = {
5917 "'\\1'",
5918 "'\\01'",
5919 "'\\001'",
5920 "'\\08'",
5921 "'\\09'",
5922 NULL};
5923 // clang-format on
5924
5925 // Permitted in sloppy mode
5926 RunParserSyncTest(sloppy_context_data, data, kSuccess);
5927
5928 // Error in strict mode
5929 RunParserSyncTest(strict_context_data, data, kError);
5930 }
5904 5931
5905 TEST(ScanTemplateLiterals) { 5932 TEST(ScanTemplateLiterals) {
5906 const char* context_data[][2] = {{"'use strict';", ""}, 5933 const char* context_data[][2] = {{"'use strict';", ""},
5907 {"function foo(){ 'use strict';" 5934 {"function foo(){ 'use strict';"
5908 " var a, b, c; return ", "}"}, 5935 " var a, b, c; return ", "}"},
5909 {NULL, NULL}}; 5936 {NULL, NULL}};
5910 5937
5911 const char* data[] = { 5938 const char* data[] = {
5912 "``", 5939 "``",
5913 "`no-subst-template`", 5940 "`no-subst-template`",
(...skipping 1191 matching lines...) Expand 10 before | Expand all | Expand 10 after
7105 7132
7106 TEST(TemplateEscapesPositiveTests) { 7133 TEST(TemplateEscapesPositiveTests) {
7107 // clang-format off 7134 // clang-format off
7108 const char* context_data[][2] = { 7135 const char* context_data[][2] = {
7109 {"", ""}, 7136 {"", ""},
7110 {"'use strict';", ""}, 7137 {"'use strict';", ""},
7111 {NULL, NULL}}; 7138 {NULL, NULL}};
7112 7139
7113 // clang-format off 7140 // clang-format off
7114 const char* data[] = { 7141 const char* data[] = {
7142 "tag`\\08`",
7115 "tag`\\01`", 7143 "tag`\\01`",
7116 "tag`\\01${0}right`", 7144 "tag`\\01${0}right`",
7117 "tag`left${0}\\01`", 7145 "tag`left${0}\\01`",
7118 "tag`left${0}\\01${1}right`", 7146 "tag`left${0}\\01${1}right`",
7119 "tag`\\1`", 7147 "tag`\\1`",
7120 "tag`\\1${0}right`", 7148 "tag`\\1${0}right`",
7121 "tag`left${0}\\1`", 7149 "tag`left${0}\\1`",
7122 "tag`left${0}\\1${1}right`", 7150 "tag`left${0}\\1${1}right`",
7123 "tag`\\xg`", 7151 "tag`\\xg`",
7124 "tag`\\xg${0}right`", 7152 "tag`\\xg${0}right`",
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
7188 7216
7189 TEST(TemplateEscapesNegativeTests) { 7217 TEST(TemplateEscapesNegativeTests) {
7190 // clang-format off 7218 // clang-format off
7191 const char* context_data[][2] = { 7219 const char* context_data[][2] = {
7192 {"", ""}, 7220 {"", ""},
7193 {"'use strict';", ""}, 7221 {"'use strict';", ""},
7194 {NULL, NULL}}; 7222 {NULL, NULL}};
7195 7223
7196 // clang-format off 7224 // clang-format off
7197 const char* data[] = { 7225 const char* data[] = {
7226 "`\\08`",
7198 "`\\01`", 7227 "`\\01`",
7199 "`\\01${0}right`", 7228 "`\\01${0}right`",
7200 "`left${0}\\01`", 7229 "`left${0}\\01`",
7201 "`left${0}\\01${1}right`", 7230 "`left${0}\\01${1}right`",
7202 "`\\1`", 7231 "`\\1`",
7203 "`\\1${0}right`", 7232 "`\\1${0}right`",
7204 "`left${0}\\1`", 7233 "`left${0}\\1`",
7205 "`left${0}\\1${1}right`", 7234 "`left${0}\\1${1}right`",
7206 "`\\xg`", 7235 "`\\xg`",
7207 "`\\xg${0}right`", 7236 "`\\xg${0}right`",
(...skipping 3131 matching lines...) Expand 10 before | Expand all | Expand 10 after
10339 CHECK(loop_var->IsStackLocal()); 10368 CHECK(loop_var->IsStackLocal());
10340 CHECK_EQ(loop_block->ContextLocalCount(), 0); 10369 CHECK_EQ(loop_block->ContextLocalCount(), 0);
10341 10370
10342 i::Variable* loop_var2 = loop_block->inner_scope()->LookupLocal(var_name); 10371 i::Variable* loop_var2 = loop_block->inner_scope()->LookupLocal(var_name);
10343 CHECK_NE(loop_var, loop_var2); 10372 CHECK_NE(loop_var, loop_var2);
10344 CHECK(loop_var2->IsContextSlot()); 10373 CHECK(loop_var2->IsContextSlot());
10345 CHECK_EQ(loop_block->inner_scope()->ContextLocalCount(), 1); 10374 CHECK_EQ(loop_block->inner_scope()->ContextLocalCount(), 1);
10346 }); 10375 });
10347 } 10376 }
10348 } 10377 }
OLDNEW
« 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