From 26a029d407be480d791972afb5975cf62c9360a6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 02:47:55 +0200 Subject: Adding upstream version 124.0.1. Signed-off-by: Daniel Baumann --- .../result-coerce-groups-prop-err.js | 69 ++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 js/src/tests/test262/built-ins/RegExp/prototype/Symbol.replace/result-coerce-groups-prop-err.js (limited to 'js/src/tests/test262/built-ins/RegExp/prototype/Symbol.replace/result-coerce-groups-prop-err.js') diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.replace/result-coerce-groups-prop-err.js b/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.replace/result-coerce-groups-prop-err.js new file mode 100644 index 0000000000..bb69475979 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.replace/result-coerce-groups-prop-err.js @@ -0,0 +1,69 @@ +// Copyright (C) 2020 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-regexp.prototype-@@replace +description: > + Abrupt completion during coercion of value of "groups" object. +info: | + RegExp.prototype [ @@replace ] ( string, replaceValue ) + + [...] + 14. For each result in results, do + [...] + j. Let namedCaptures be ? Get(result, "groups"). + k. If functionalReplace is true, then + [...] + l. Else, + [...] + ii. Let replacement be ? GetSubstitution(matched, S, position, captures, namedCaptures, replaceValue). + + Runtime Semantics: GetSubstitution ( matched, str, position, captures, namedCaptures, replacement ) + + [...] + 11. Let result be the String value derived from replacement by copying code unit elements + from replacement to result while performing replacements as specified in Table 54. + These $ replacements are done left-to-right, and, once such a replacement is performed, + the new replacement text is not subject to further replacements. + 12. Return result. + + Table 54: Replacement Text Symbol Substitutions + + $< + + 1. If namedCaptures is undefined, the replacement text is the String "$<". + 2. Else, + a. Assert: Type(namedCaptures) is Object. + b. Scan until the next > U+003E (GREATER-THAN SIGN). + c. If none is found, the replacement text is the String "$<". + d. Else, + i. Let groupName be the enclosed substring. + ii. Let capture be ? Get(namedCaptures, groupName). + iii. If capture is undefined, replace the text through > with the empty String. + iv. Otherwise, replace the text through > with ? ToString(capture). +features: [Symbol.replace, regexp-named-groups] +---*/ + +var r = /./; +var coercibleValue = { + length: 1, + 0: '', + index: 0, + groups: { + foo: { + toString: function() { + throw new Test262Error(); + }, + }, + }, +}; + +r.exec = function() { + return coercibleValue; +}; + +assert.throws(Test262Error, function() { + r[Symbol.replace]('a', '$'); +}); + +reportCompare(0, 0); -- cgit v1.2.3