OLD | NEW |
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 // Flags: --harmony-templates --harmony-unicode | 5 // Flags: --harmony-templates --harmony-unicode |
6 | 6 |
7 var num = 5; | 7 var num = 5; |
8 var str = "str"; | 8 var str = "str"; |
9 function fn() { return "result"; } | 9 function fn() { return "result"; } |
10 var obj = { | 10 var obj = { |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 (function(s) { calls++; assertEquals("\u005Cn", s.raw[0]); })`\n`; | 246 (function(s) { calls++; assertEquals("\u005Cn", s.raw[0]); })`\n`; |
247 (function(s) { calls++; assertEquals("\u005Cr", s.raw[0]); })`\r`; | 247 (function(s) { calls++; assertEquals("\u005Cr", s.raw[0]); })`\r`; |
248 (function(s) { calls++; assertEquals("\u005Ct", s.raw[0]); })`\t`; | 248 (function(s) { calls++; assertEquals("\u005Ct", s.raw[0]); })`\t`; |
249 (function(s) { calls++; assertEquals("\u005Cv", s.raw[0]); })`\v`; | 249 (function(s) { calls++; assertEquals("\u005Cv", s.raw[0]); })`\v`; |
250 (function(s) { calls++; assertEquals("\u005C`", s.raw[0]); })`\``; | 250 (function(s) { calls++; assertEquals("\u005C`", s.raw[0]); })`\``; |
251 assertEquals(10, calls); | 251 assertEquals(10, calls); |
252 | 252 |
253 // The TRV of CharacterEscapeSequence :: NonEscapeCharacter is the CV of the | 253 // The TRV of CharacterEscapeSequence :: NonEscapeCharacter is the CV of the |
254 // NonEscapeCharacter. | 254 // NonEscapeCharacter. |
255 calls = 0; | 255 calls = 0; |
256 (function(s) { calls++; assertEquals("\u005Cx", s.raw[0]); })`\x`; | 256 (function(s) { calls++; assertEquals("\u005Cz", s.raw[0]); })`\z`; |
257 assertEquals(1, calls); | 257 assertEquals(1, calls); |
258 | 258 |
259 // The TRV of LineTerminatorSequence :: <LF> is the code unit value 0x000A. | 259 // The TRV of LineTerminatorSequence :: <LF> is the code unit value 0x000A. |
260 // The TRV of LineTerminatorSequence :: <CR> is the code unit value 0x000A. | 260 // The TRV of LineTerminatorSequence :: <CR> is the code unit value 0x000A. |
261 // The TRV of LineTerminatorSequence :: <CR><LF> is the sequence consisting of | 261 // The TRV of LineTerminatorSequence :: <CR><LF> is the sequence consisting of |
262 // the code unit value 0x000A. | 262 // the code unit value 0x000A. |
263 calls = 0; | 263 calls = 0; |
264 function testRawLineNormalization(cs) { | 264 function testRawLineNormalization(cs) { |
265 calls++; | 265 calls++; |
266 assertEquals(cs.raw[0], "\n\n\n"); | 266 assertEquals(cs.raw[0], "\n\n\n"); |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
464 | 464 |
465 { | 465 { |
466 // block | 466 // block |
467 } | 467 } |
468 `ghi`; | 468 `ghi`; |
469 | 469 |
470 { | 470 { |
471 // block | 471 // block |
472 }`jkl`; | 472 }`jkl`; |
473 })(); | 473 })(); |
| 474 |
| 475 |
| 476 (function testLegacyOctal() { |
| 477 assertEquals('\u0000', `\0`); |
| 478 assertEquals('\u0000a', `\0a`); |
| 479 for (var i = 0; i < 10; i++) { |
| 480 var code = "`\\0" + i + "`"; |
| 481 assertThrows(code, SyntaxError); |
| 482 } |
| 483 |
| 484 assertEquals('\\0', String.raw`\0`); |
| 485 })(); |
| 486 |
| 487 |
| 488 (function testSyntaxErrorsNonEscapeCharacter() { |
| 489 assertThrows("`\\x`", SyntaxError); |
| 490 assertThrows("`\\u`", SyntaxError); |
| 491 for (var i = 1; i < 10; i++) { |
| 492 var code = "`\\" + i + "`"; |
| 493 assertThrows(code, SyntaxError); |
| 494 } |
| 495 })(); |
OLD | NEW |