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

Unified Diff: test/mjsunit/substr.js

Issue 2109583002: Fix order of conversions in String.prototype.substr. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Get s.length only once. Created 4 years, 6 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/js/string.js ('k') | test/test262/test262.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/substr.js
diff --git a/test/mjsunit/substr.js b/test/mjsunit/substr.js
index cab8b1bf6dec00373ff13723ab71f2281ab0a494..83929362a0036c01ddf28e46f8f10606fc301819 100644
--- a/test/mjsunit/substr.js
+++ b/test/mjsunit/substr.js
@@ -152,3 +152,22 @@ for (var i = 63; i >= 0; i--) {
assertEquals(xl - offset, z.length);
offset -= i;
}
+
+
+// Order of conversions.
+{
+ let log = [];
+ let string = {[Symbol.toPrimitive]() { log.push("this"); return "abc" }};
+ let start = {[Symbol.toPrimitive]() { log.push("start"); return 0 }};
+ let length = {[Symbol.toPrimitive]() { log.push("length"); return 1 }};
+ assertEquals("a", String.prototype.substr.call(string, start, length));
+ assertEquals(["this", "start", "length"], log);
+}
+{
+ let log = [];
+ let string = {[Symbol.toPrimitive]() { log.push("this"); return "abc" }};
+ let start = {[Symbol.toPrimitive]() { log.push("start"); return 0 }};
+ let length = {[Symbol.toPrimitive]() { log.push("length"); return 0 }};
+ assertEquals("", String.prototype.substr.call(string, start, length));
+ assertEquals(["this", "start", "length"], log);
+}
« no previous file with comments | « src/js/string.js ('k') | test/test262/test262.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698