Chromium Code Reviews| Index: test/mjsunit/harmony/templates.js |
| diff --git a/test/mjsunit/harmony/templates.js b/test/mjsunit/harmony/templates.js |
| index a884f58fb657b31d2cce4e51dd39e7ed831dd73c..f061cdbf02b08bd9dec483aba00d0a72f3694bb4 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,60 @@ 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; |
|
marja
2015/03/12 11:43:35
What's the added value of storing this.x, since we
caitp (gmail)
2015/03/12 13:34:15
it's distinct because only the one which is actual
|
| + return this; |
| + } |
| + var instance = new tag`x``y``z`; |
| + assertInstanceof(instance, tag); |
| + assertSame(tag.prototype, Object.getPrototypeOf(instance)); |
| + assertEquals([["x"], ["y"], ["z"], undefined], log); |
| + assertSame(null, instance.x); |
| +})(); |
| + |
| + |
| +(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); |
| +})(); |
|
arv (Not doing code reviews)
2015/03/12 15:20:02
One more thing we could test would be:
new tag `x
|