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

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

Issue 996223003: [es6] support template literals after MemberExpression (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: New tests, delete unneeded code, some comments Created 5 years, 9 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/scanner.h ('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 // 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
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
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 testCallNew2() {
540 "use strict";
541 var log = [];
542 function tag(x) {
543 log.push(x);
544 if (!(this instanceof tag)) {
545 return tag;
546 }
547 this.x = x === void 0 ? null : x;
548 return this;
549 }
550 // No arguments passed to constructor
551 var instance = new tag`x``y``z`;
552 assertInstanceof(instance, tag);
553 assertSame(tag.prototype, Object.getPrototypeOf(instance));
554 assertEquals({ x: null }, instance);
555 assertEquals([["x"], ["y"], ["z"], undefined], log);
556
557 // Arguments passed to constructor
558 log.length = 0;
559 instance = new tag`x2` `y2` `z2` (`test`);
560 assertInstanceof(instance, tag);
561 assertSame(tag.prototype, Object.getPrototypeOf(instance));
562 assertEquals({ x: "test" }, instance);
563 assertEquals([["x2"], ["y2"], ["z2"], "test"], log);
564 })();
565
566
567 (function testCallResultOfTagFn() {
568 "use strict";
569 var i = 0;
570 var raw = [];
571 function tag(cs) {
572 var args = Array.prototype.slice.call(arguments);
573 var text = String.raw.apply(null, args);
574 if (i++ < 2) {
575 raw.push("tag;" + text);
576 return tag;
577 }
578
579 raw.push("raw;" + text);
580 return text;
581 }
582 assertEquals("test3", tag`test1``test2``test3`);
583 assertEquals([
584 "tag;test1",
585 "tag;test2",
586 "raw;test3"
587 ], raw);
588 })();
OLDNEW
« no previous file with comments | « src/scanner.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698