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

Unified Diff: test/mjsunit/harmony/templates.js

Issue 812163003: Simplify scanner and generate better error message for legacy octals in templates (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase it Created 6 years 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/scanner.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/harmony/templates.js
diff --git a/test/mjsunit/harmony/templates.js b/test/mjsunit/harmony/templates.js
index e2e89dc67f4cf2e74d411bf8f40ffbf021a6bfdc..c339bb8cc7609f0eff03f84b85c790d036559ef1 100644
--- a/test/mjsunit/harmony/templates.js
+++ b/test/mjsunit/harmony/templates.js
@@ -476,9 +476,11 @@ var obj = {
(function testLegacyOctal() {
assertEquals('\u0000', `\0`);
assertEquals('\u0000a', `\0a`);
- for (var i = 0; i < 10; i++) {
+ for (var i = 0; i < 8; i++) {
var code = "`\\0" + i + "`";
assertThrows(code, SyntaxError);
+ code = "(function(){})" + code;
+ assertThrows(code, SyntaxError);
}
assertEquals('\\0', String.raw`\0`);
@@ -488,8 +490,18 @@ var obj = {
(function testSyntaxErrorsNonEscapeCharacter() {
assertThrows("`\\x`", SyntaxError);
assertThrows("`\\u`", SyntaxError);
- for (var i = 1; i < 10; i++) {
+ for (var i = 1; i < 8; i++) {
var code = "`\\" + i + "`";
assertThrows(code, SyntaxError);
+ code = "(function(){})" + code;
+ assertThrows(code, SyntaxError);
}
})();
+
+
+(function testValidNumericEscapes() {
+ assertEquals("8", `\8`);
+ assertEquals("9", `\9`);
+ assertEquals("\u00008", `\08`);
+ assertEquals("\u00009", `\09`);
+})();
« no previous file with comments | « src/scanner.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698