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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/scanner.h ('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 a884f58fb657b31d2cce4e51dd39e7ed831dd73c..c84b5da819e9365832958ca32b9ae772138535d2 100644
--- a/test/mjsunit/harmony/templates.js
+++ b/test/mjsunit/harmony/templates.js
@@ -423,10 +423,12 @@ var obj = {
Object.defineProperty(Array.prototype, 0, {
set: function() {
assertUnreachable();
- }
+ },
+ configurable: true
});
function tag(){}
tag`a${1}b`;
+ delete Array.prototype[0];
})();
@@ -518,3 +520,69 @@ var obj = {
assertThrows("`${(function() { \"use strict\"; return \"\\07\"; })()}`",
SyntaxError);
})();
+
+
+var global = this;
+(function testCallNew() {
+ "use strict";
+ var called = false;
+ var calledWith;
+ global.log = function(x) { called = true; calledWith = x; }
+
+ assertInstanceof(new Function`log("test")`, Object);
+ assertTrue(called);
+ assertSame("test", calledWith);
+ delete global.log;
+})();
+
+
+(function testCallNew2() {
+ "use strict";
+ var log = [];
+ function tag(x) {
+ log.push(x);
+ if (!(this instanceof tag)) {
+ return tag;
+ }
+ this.x = x === void 0 ? null : x;
+ return this;
+ }
+ // No arguments passed to constructor
+ var instance = new tag`x``y``z`;
+ assertInstanceof(instance, tag);
+ assertSame(tag.prototype, Object.getPrototypeOf(instance));
+ assertEquals({ x: null }, instance);
+ assertEquals([["x"], ["y"], ["z"], undefined], log);
+
+ // Arguments passed to constructor
+ log.length = 0;
+ instance = new tag`x2` `y2` `z2` (`test`);
+ assertInstanceof(instance, tag);
+ assertSame(tag.prototype, Object.getPrototypeOf(instance));
+ assertEquals({ x: "test" }, instance);
+ assertEquals([["x2"], ["y2"], ["z2"], "test"], log);
+})();
+
+
+(function testCallResultOfTagFn() {
+ "use strict";
+ var i = 0;
+ var raw = [];
+ function tag(cs) {
+ var args = Array.prototype.slice.call(arguments);
+ var text = String.raw.apply(null, args);
+ if (i++ < 2) {
+ raw.push("tag;" + text);
+ return tag;
+ }
+
+ raw.push("raw;" + text);
+ return text;
+ }
+ assertEquals("test3", tag`test1``test2``test3`);
+ assertEquals([
+ "tag;test1",
+ "tag;test2",
+ "raw;test3"
+ ], raw);
+})();
« 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