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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/parser.cc ('k') | test/mjsunit/es6/templates.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/es6/string-raw.js
diff --git a/test/mjsunit/es6/string-raw.js b/test/mjsunit/es6/string-raw.js
index 7a7f4c2a40ade49a98b7b0ad57b73012397704bf..2c6bb2ff308a9c7a02fba66337ed120d6cdbbfdc 100644
--- a/test/mjsunit/es6/string-raw.js
+++ b/test/mjsunit/es6/string-raw.js
@@ -254,3 +254,39 @@
assertEquals("12345", String.raw(callSiteObj, arg(2), arg(4), arg(6)));
assertEquals(["length", "raw1", "arg2", "raw3", "arg4", "raw5"], order);
})();
+
+
+(function testStringRawToStringSubstitutionsOrder() {
+ var subs = [];
+ var log = [];
+ function stringify(toString) {
+ var valueOf = "_" + toString + "_";
+ return {
+ toString: function() { return toString; },
+ valueOf: function() { return valueOf; }
+ };
+ }
+ function getter(name, value) {
+ return {
+ get: function() {
+ log.push("get" + name);
+ return value;
+ },
+ set: function(v) {
+ log.push("set" + name);
+ }
+ };
+ }
+ Object.defineProperties(subs, {
+ 0: getter(0, stringify("a")),
+ 1: getter(1, stringify("b")),
+ 2: getter(2, stringify("c"))
+ });
+
+ assertEquals("-a-b-c-", String.raw`-${subs[0]}-${subs[1]}-${subs[2]}-`);
+ assertArrayEquals(["get0", "get1", "get2"], log);
+
+ log.length = 0;
+ assertEquals("-a-", String.raw`-${subs[0]}-`);
+ assertArrayEquals(["get0"], log);
+})();
« 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