blob: ce35f50bc84e95665b12d96edaa10b4a58138672 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
// Copyright (C) 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-regexp.prototype-@@replace
description: >
Type coercion of "length" property of the value returned by RegExpExec.
info: |
RegExp.prototype [ @@replace ] ( string, replaceValue )
[...]
14. For each result in results, do
a. Let nCaptures be ? LengthOfArrayLike(result).
[...]
features: [Symbol.replace]
---*/
var r = /./;
var coercibleIndex = {
length: {
valueOf: function() {
return 3.9;
},
},
0: '',
1: 'foo',
2: 'bar',
3: 'baz',
index: 0,
};
r.exec = function() {
return coercibleIndex;
};
assert.sameValue(r[Symbol.replace]('', '$1$2$3'), 'foobar$3');
reportCompare(0, 0);
|