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

Side by Side Diff: test/mjsunit/es6/templates.js

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 | « test/cctest/test-parsing.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 var num = 5; 5 var num = 5;
6 var str = "str"; 6 var str = "str";
7 function fn() { return "result"; } 7 function fn() { return "result"; }
8 var obj = { 8 var obj = {
9 num: num, 9 num: num,
10 str: str, 10 str: str,
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 469
470 { 470 {
471 // block 471 // block
472 }`jkl`; 472 }`jkl`;
473 })(); 473 })();
474 474
475 475
476 (function testLegacyOctal() { 476 (function testLegacyOctal() {
477 assertEquals('\u0000', `\0`); 477 assertEquals('\u0000', `\0`);
478 assertEquals('\u0000a', `\0a`); 478 assertEquals('\u0000a', `\0a`);
479 for (var i = 0; i < 8; i++) { 479 for (var i = 0; i < 10; i++) {
480 var code = "`\\0" + i + "`"; 480 var code = "`\\0" + i + "`";
481 assertThrows(code, SyntaxError); 481 assertThrows(code, SyntaxError);
482 code = "(function(){})" + code; 482 code = "(function(){})" + code;
483 assertThrows(code, SyntaxError); 483 assertThrows(code, SyntaxError);
484 } 484 }
485 485
486 assertEquals('\\0', String.raw`\0`); 486 assertEquals('\\0', String.raw`\0`);
487 })(); 487 })();
488 488
489 489
490 (function testSyntaxErrorsNonEscapeCharacter() { 490 (function testSyntaxErrorsNonEscapeCharacter() {
491 assertThrows("`\\x`", SyntaxError); 491 assertThrows("`\\x`", SyntaxError);
492 assertThrows("`\\u`", SyntaxError); 492 assertThrows("`\\u`", SyntaxError);
493 for (var i = 1; i < 8; i++) { 493 for (var i = 1; i < 8; i++) {
494 var code = "`\\" + i + "`"; 494 var code = "`\\" + i + "`";
495 assertThrows(code, SyntaxError); 495 assertThrows(code, SyntaxError);
496 code = "(function(){})" + code; 496 code = "(function(){})" + code;
497 assertThrows(code, SyntaxError); 497 assertThrows(code, SyntaxError);
498 } 498 }
499 })(); 499 })();
500 500
501 501
502 (function testValidNumericEscapes() { 502 (function testValidNumericEscapes() {
503 assertEquals("8", `\8`); 503 assertEquals("8", `\8`);
504 assertEquals("9", `\9`); 504 assertEquals("9", `\9`);
505 assertEquals("\u00008", `\08`);
506 assertEquals("\u00009", `\09`);
507 })(); 505 })();
508 506
509 507
510 (function testLegacyOctalEscapesInExpressions() { 508 (function testLegacyOctalEscapesInExpressions() {
511 // Allowed in sloppy expression 509 // Allowed in sloppy expression
512 assertEquals("\x07", `${"\07"}`); 510 assertEquals("\x07", `${"\07"}`);
513 511
514 // Disallowed in template tail 512 // Disallowed in template tail
515 assertThrows("`${\"\\07\"}\\07`", SyntaxError); 513 assertThrows("`${\"\\07\"}\\07`", SyntaxError);
516 514
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
709 assertSame(result, f()); 707 assertSame(result, f());
710 })(); 708 })();
711 709
712 710
713 (function testEvalTagSloppy() { 711 (function testEvalTagSloppy() {
714 var f = (x) => eval`a${x}b`; 712 var f = (x) => eval`a${x}b`;
715 var result = f(); 713 var result = f();
716 assertEquals(["a", "b"], result); 714 assertEquals(["a", "b"], result);
717 assertSame(result, f()); 715 assertSame(result, f());
718 })(); 716 })();
OLDNEW
« no previous file with comments | « test/cctest/test-parsing.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698