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

Side by Side Diff: test/mjsunit/es6/string-raw.js

Issue 1027183002: [es6] call ToString() on template substitutions (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Test ToString behaviour for tagged templates + String.raw 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/parser.cc ('k') | test/mjsunit/es6/templates.js » ('j') | 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 (function testStringRawArity() { 5 (function testStringRawArity() {
6 assertEquals(1, String.raw.length); 6 assertEquals(1, String.raw.length);
7 })(); 7 })();
8 8
9 9
10 (function testStringRawCallSiteToObject() { 10 (function testStringRawCallSiteToObject() {
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 }); 247 });
248 [1, 3, 5].forEach(function(v, i) { 248 [1, 3, 5].forEach(function(v, i) {
249 Object.defineProperty(callSiteObj.raw, i, { 249 Object.defineProperty(callSiteObj.raw, i, {
250 get: function() { order.push("raw" + v); return v; } 250 get: function() { order.push("raw" + v); return v; }
251 }); 251 });
252 }); 252 });
253 253
254 assertEquals("12345", String.raw(callSiteObj, arg(2), arg(4), arg(6))); 254 assertEquals("12345", String.raw(callSiteObj, arg(2), arg(4), arg(6)));
255 assertEquals(["length", "raw1", "arg2", "raw3", "arg4", "raw5"], order); 255 assertEquals(["length", "raw1", "arg2", "raw3", "arg4", "raw5"], order);
256 })(); 256 })();
257
258
259 (function testStringRawToStringSubstitutionsOrder() {
260 var subs = [];
261 var log = [];
262 function stringify(toString) {
263 var valueOf = "_" + toString + "_";
264 return {
265 toString: function() { return toString; },
266 valueOf: function() { return valueOf; }
267 };
268 }
269 function getter(name, value) {
270 return {
271 get: function() {
272 log.push("get" + name);
273 return value;
274 },
275 set: function(v) {
276 log.push("set" + name);
277 }
278 };
279 }
280 Object.defineProperties(subs, {
281 0: getter(0, stringify("a")),
282 1: getter(1, stringify("b")),
283 2: getter(2, stringify("c"))
284 });
285
286 assertEquals("-a-b-c-", String.raw`-${subs[0]}-${subs[1]}-${subs[2]}-`);
287 assertArrayEquals(["get0", "get1", "get2"], log);
288
289 log.length = 0;
290 assertEquals("-a-", String.raw`-${subs[0]}-`);
291 assertArrayEquals(["get0"], log);
292 })();
OLDNEW
« no previous file with comments | « src/parser.cc ('k') | test/mjsunit/es6/templates.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698