diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /js/src/tests/test262/built-ins/RegExp/prototype/Symbol.replace/result-coerce-capture.js | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/tests/test262/built-ins/RegExp/prototype/Symbol.replace/result-coerce-capture.js')
-rw-r--r-- | js/src/tests/test262/built-ins/RegExp/prototype/Symbol.replace/result-coerce-capture.js | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.replace/result-coerce-capture.js b/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.replace/result-coerce-capture.js new file mode 100644 index 0000000000..8ad783902e --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.replace/result-coerce-capture.js @@ -0,0 +1,46 @@ +// 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: > + String coercion of "3" property of the value returned by RegExpExec. +info: | + RegExp.prototype [ @@replace ] ( string, replaceValue ) + + [...] + 11. Repeat, while done is false + a. Let result be ? RegExpExec(rx, S). + [...] + 14. For each result in results, do + [...] + i. Repeat, while n ≤ nCaptures + i. Let capN be ? Get(result, ! ToString(n)). + ii. If capN is not undefined, then + 1. Set capN to ? ToString(capN). + [...] +features: [Symbol.replace] +---*/ + +var r = /./; +var coercibleValue = { + length: 4, + index: 0, + 3: { + toString: function() { + return 'toString value'; + }, + valueOf: function() { + throw new Test262Error('This method should not be invoked.'); + }, + }, +}; +r.exec = function() { + return coercibleValue; +}; + +assert.sameValue( + r[Symbol.replace]('', 'foo[$3]bar'), 'foo[toString value]bar' +); + +reportCompare(0, 0); |