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 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
416 "Iñtërnâtiônàlizætiøn\\u2603\\uD83D\\uDCA9", callSites[0].raw[0]); | 416 "Iñtërnâtiônàlizætiøn\\u2603\\uD83D\\uDCA9", callSites[0].raw[0]); |
417 assertEquals("Iñtërnâtiônàlizætiøn☃💩", callSites[1][0]); | 417 assertEquals("Iñtërnâtiônàlizætiøn☃💩", callSites[1][0]); |
418 assertEquals("Iñtërnâtiônàlizætiøn☃💩", callSites[1].raw[0]); | 418 assertEquals("Iñtërnâtiônàlizætiøn☃💩", callSites[1].raw[0]); |
419 })(); | 419 })(); |
420 | 420 |
421 | 421 |
422 (function testExtendedArrayPrototype() { | 422 (function testExtendedArrayPrototype() { |
423 Object.defineProperty(Array.prototype, 0, { | 423 Object.defineProperty(Array.prototype, 0, { |
424 set: function() { | 424 set: function() { |
425 assertUnreachable(); | 425 assertUnreachable(); |
426 } | 426 }, |
| 427 configurable: true |
427 }); | 428 }); |
428 function tag(){} | 429 function tag(){} |
429 tag`a${1}b`; | 430 tag`a${1}b`; |
| 431 delete Array.prototype[0]; |
430 })(); | 432 })(); |
431 | 433 |
432 | 434 |
433 (function testRawLineNormalization() { | 435 (function testRawLineNormalization() { |
434 function raw0(callSiteObj) { | 436 function raw0(callSiteObj) { |
435 return callSiteObj.raw[0]; | 437 return callSiteObj.raw[0]; |
436 } | 438 } |
437 assertEquals(eval("raw0`\r`"), "\n"); | 439 assertEquals(eval("raw0`\r`"), "\n"); |
438 assertEquals(eval("raw0`\r\n`"), "\n"); | 440 assertEquals(eval("raw0`\r\n`"), "\n"); |
439 assertEquals(eval("raw0`\r\r\n`"), "\n\n"); | 441 assertEquals(eval("raw0`\r\r\n`"), "\n\n"); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
511 // Allowed in sloppy expression | 513 // Allowed in sloppy expression |
512 assertEquals("\x07", `${"\07"}`); | 514 assertEquals("\x07", `${"\07"}`); |
513 | 515 |
514 // Disallowed in template tail | 516 // Disallowed in template tail |
515 assertThrows("`${\"\\07\"}\\07`", SyntaxError); | 517 assertThrows("`${\"\\07\"}\\07`", SyntaxError); |
516 | 518 |
517 // Disallowed in strict expression | 519 // Disallowed in strict expression |
518 assertThrows("`${(function() { \"use strict\"; return \"\\07\"; })()}`", | 520 assertThrows("`${(function() { \"use strict\"; return \"\\07\"; })()}`", |
519 SyntaxError); | 521 SyntaxError); |
520 })(); | 522 })(); |
| 523 |
| 524 |
| 525 var global = this; |
| 526 (function testCallNew() { |
| 527 "use strict"; |
| 528 var called = false; |
| 529 var calledWith; |
| 530 global.log = function(x) { called = true; calledWith = x; } |
| 531 |
| 532 assertInstanceof(new(Function`log("test")`), Object); |
| 533 assertTrue(called); |
| 534 assertSame("test", calledWith); |
| 535 delete global.log; |
| 536 })(); |
| 537 |
| 538 |
| 539 (function testCallResultOfTagFn() { |
| 540 "use strict"; |
| 541 var i = 0; |
| 542 var raw = []; |
| 543 function tag(cs) { |
| 544 var args = Array.prototype.slice.call(arguments); |
| 545 var text = String.raw.apply(null, args); |
| 546 if (i++ < 2) { |
| 547 raw.push("tag;" + text); |
| 548 return tag; |
| 549 } |
| 550 |
| 551 raw.push("raw;" + text); |
| 552 return text; |
| 553 } |
| 554 assertEquals("test3", tag`test1``test2``test3`); |
| 555 assertEquals([ |
| 556 "tag;test1", |
| 557 "tag;test2", |
| 558 "raw;test3" |
| 559 ], raw); |
| 560 })(); |
OLD | NEW |