mark.lam@apple.com | 7cf9d29 | 2018-11-16 05:12:25 +0000 | [diff] [blame] | 1 | function assertEq(actual, expected) { |
| 2 | if (actual != expected) |
| 3 | throw ("Expected: " + expected + ", actual: " + actual); |
| 4 | } |
| 5 | |
| 6 | function foo(arr, regexp, str) { |
| 7 | regexp[Symbol.match](str); |
| 8 | arr[1] = 3.54484805889626e-310; |
| 9 | return arr[0]; |
| 10 | } |
| 11 | |
| 12 | let arr = [1.1, 2.2, 3.3]; |
| 13 | let regexp = /a/y; |
| 14 | |
| 15 | for (let i = 0; i < 10000; i++) |
| 16 | foo(arr, regexp, "abcd"); |
| 17 | |
| 18 | regexp.lastIndex = { |
| 19 | valueOf: () => { |
| 20 | arr[0] = arr; |
| 21 | return 0; |
| 22 | } |
| 23 | }; |
| 24 | let result = foo(arr, regexp, "abcd"); |
| 25 | |
| 26 | assertEq(arr[1], "3.54484805889626e-310"); |
| 27 | assertEq(result, ",3.54484805889626e-310,3.3"); |