Make "length" coercion test more precise

This commit is contained in:
Alexey Shvayka 2020-02-08 23:26:48 +02:00 committed by Rick Waldron
parent 3f6b961428
commit 807afd9120
1 changed files with 10 additions and 11 deletions

View File

@ -2,32 +2,31 @@
// This code is governed by the BSD license found in the LICENSE file. // This code is governed by the BSD license found in the LICENSE file.
/*--- /*---
esid: sec-regexp.prototype-@@replace
description: > description: >
Type coercion of `length` property of result Type coercion of "length" property of the value returned by RegExpExec.
es6id: 21.2.5.8
info: | info: |
RegExp.prototype [ @@replace ] ( string, replaceValue )
[...]
14. For each result in results, do
a. Let nCaptures be ? LengthOfArrayLike(result).
[...] [...]
13. Repeat, while done is false
a. Let result be RegExpExec(rx, S).
[...]
16. Repeat, for each result in results,
a. Let nCaptures be ToLength(Get(result, "length")).
[...]
features: [Symbol.replace] features: [Symbol.replace]
---*/ ---*/
var r = /./; var r = /./;
var counter = 0;
var coercibleIndex = { var coercibleIndex = {
length: { length: {
valueOf: function() { valueOf: function() {
return 3.9; return 3.9;
} },
}, },
0: '', 0: '',
1: 'foo', 1: 'foo',
2: 'bar', 2: 'bar',
3: 'baz' 3: 'baz',
index: 0,
}; };
r.exec = function() { r.exec = function() {
return coercibleIndex; return coercibleIndex;