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); |
+} |