[test262] Add staging test for RegExp named groups (replace)

This CL adds a staging test for testing test262 bot.

Bug: v8:13173
Change-Id: Id24a5b5665bbc491acd59c16ede80d6780bbd4b2
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/5293730
Commit-Queue: Liviu Rau <liviurau@google.com>
Reviewed-by: Liviu Rau <liviurau@chromium.org>
Cr-Commit-Position: refs/heads/main@{#92363}
This commit is contained in:
Rezvan Mahdavi Hezaveh 2024-02-16 06:25:10 -08:00 committed by test262-merge-bot
parent 6f7ae1f311
commit 903f7fc74d
1 changed files with 28 additions and 0 deletions

View File

@ -0,0 +1,28 @@
// Copyright (C) 2024 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: Test replace function with duplicate names in alteration.
features: [regexp-duplicate-named-groups]
includes: [compareArray.js]
---*/
assert.compareArray(
'2xyy', 'xxyy'.replace(/(?:(?:(?<a>x)|(?<a>y))\k<a>)/, '2$<a>'));
assert.compareArray(
'x2zyyxxy',
'xzzyyxxy'.replace(
/(?:(?:(?<a>x)|(?<a>y)|(a)|(?<b>b)|(?<a>z))\k<a>)/, '2$<a>'));
assert.compareArray(
'2x(x,)yy', 'xxyy'.replace(/(?:(?:(?<a>x)|(?<a>y))\k<a>)/, '2$<a>($1,$2)'));
assert.compareArray(
'x2z(,,,,z)yyxxy',
'xzzyyxxy'.replace(
/(?:(?:(?<a>x)|(?<a>y)|(a)|(?<b>b)|(?<a>z))\k<a>)/,
'2$<a>($1,$2,$3,$4,$5)'));
assert.compareArray(
'2x2y', 'xxyy'.replace(/(?:(?:(?<a>x)|(?<a>y))\k<a>)/g, '2$<a>'));
assert.compareArray(
'x2z2y2xy',
'xzzyyxxy'.replace(
/(?:(?:(?<a>x)|(?<a>y)|(a)|(?<b>b)|(?<a>z))\k<a>)/g, '2$<a>'));