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

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

Issue 742643003: Cache template literal callSiteObj (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Ensure hash is a valid Smi literal Created 6 years, 1 month 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') | 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 5 // Flags: --harmony-templates
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 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 331
332 332
333 (function testStringRawAsTagFn() { 333 (function testStringRawAsTagFn() {
334 assertEquals("\\u0065\\`\\r\\r\\n\\ntestcheck", 334 assertEquals("\\u0065\\`\\r\\r\\n\\ntestcheck",
335 String.raw`\u0065\`\r\r\n\n${"test"}check`); 335 String.raw`\u0065\`\r\r\n\n${"test"}check`);
336 assertEquals("\\\n\\\n\\\n", eval("String.raw`\\\r\\\r\n\\\n`")); 336 assertEquals("\\\n\\\n\\\n", eval("String.raw`\\\r\\\r\n\\\n`"));
337 assertEquals("", String.raw``); 337 assertEquals("", String.raw``);
338 })(); 338 })();
339 339
340 340
341 (function testCallSiteCaching() {
342 var callSites = [];
343 function tag(cs) { callSites.push(cs); }
344 var a = 1;
345 var b = 2;
346
347 tag`head${a}tail`;
348 tag`head${b}tail`;
349
350 assertEquals(2, callSites.length);
351 assertSame(callSites[0], callSites[1]);
352
353 eval("tag`head${a}tail`");
354 assertEquals(3, callSites.length);
355 assertSame(callSites[1], callSites[2]);
356
357 eval("tag`head${b}tail`");
358 assertEquals(4, callSites.length);
359 assertSame(callSites[2], callSites[3]);
360
361 (new Function("tag", "a", "b", "return tag`head${a}tail`;"))(tag, 1, 2);
362 assertEquals(5, callSites.length);
363 assertSame(callSites[3], callSites[4]);
364
365 (new Function("tag", "a", "b", "return tag`head${b}tail`;"))(tag, 1, 2);
366 assertEquals(6, callSites.length);
367 assertSame(callSites[4], callSites[5]);
368
369 callSites = [];
370
371 tag`foo${a}bar`;
372 tag`foo\${.}bar`;
373 assertEquals(2, callSites.length);
374 assertEquals(2, callSites[0].length);
375 assertEquals(1, callSites[1].length);
376
377 callSites = [];
378
379 eval("tag`\\\r\n\\\n\\\r`");
380 eval("tag`\\\r\n\\\n\\\r`");
381 assertEquals(2, callSites.length);
382 assertSame(callSites[0], callSites[1]);
383 assertEquals("", callSites[0][0]);
384 assertEquals("\\\n\\\n\\\n", callSites[0].raw[0]);
385
386 callSites = [];
387
388 tag`\uc548\ub155`;
389 tag`\uc548\ub155`;
390 assertEquals(2, callSites.length);
391 assertSame(callSites[0], callSites[1]);
392 assertEquals("안녕", callSites[0][0]);
393 assertEquals("\\uc548\\ub155", callSites[0].raw[0]);
394
395 callSites = [];
396
397 tag`\uc548\ub155`;
398 tag`안녕`;
399 assertEquals(2, callSites.length);
400 assertTrue(callSites[0] !== callSites[1]);
401 assertEquals("안녕", callSites[0][0]);
402 assertEquals("\\uc548\\ub155", callSites[0].raw[0]);
403 assertEquals("안녕", callSites[1][0]);
404 // TODO(caitp, arv): blocked on correctly generating raw strings from
405 // multi-byte UTF8.
406 // assertEquals("안녕", callSites[1].raw[0]);
407 })();
408
409
341 (function testExtendedArrayPrototype() { 410 (function testExtendedArrayPrototype() {
342 Object.defineProperty(Array.prototype, 0, { 411 Object.defineProperty(Array.prototype, 0, {
343 set: function() { 412 set: function() {
344 assertUnreachable(); 413 assertUnreachable();
345 } 414 }
346 }); 415 });
347 function tag(){} 416 function tag(){}
348 tag`a${1}b`; 417 tag`a${1}b`;
349 })(); 418 })();
OLDNEW
« no previous file with comments | « src/parser.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698