From fabb1fd3794dfe18ba4c05de7f803f0d4deb96d6 Mon Sep 17 00:00:00 2001 From: Philip Chimento Date: Fri, 28 Oct 2022 16:09:08 -0700 Subject: [PATCH] Duplicate named capture groups: Fix match arrays Each named capturing group should count as its own parenthesized capturing group, even if it has the same name as another group. So, some of these expectations were missing `undefined` array elements for the variant of the `x` capturing group that didn't match. In the other expectations, we forgot to take into account that the backreference is not inside a capturing group, so the group match should not have doubled letters in it. --- .../built-ins/RegExp/named-groups/duplicate-names.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/built-ins/RegExp/named-groups/duplicate-names.js b/test/built-ins/RegExp/named-groups/duplicate-names.js index c4a02c9484..ac801ed398 100644 --- a/test/built-ins/RegExp/named-groups/duplicate-names.js +++ b/test/built-ins/RegExp/named-groups/duplicate-names.js @@ -8,15 +8,15 @@ features: [regexp-duplicate-named-groups] includes: [compareArray.js] ---*/ -assert.compareArray(["b", "b"], "bab".match(/(?a)|(?b)/)); -assert.compareArray(["b", "b"], "bab".match(/(?b)|(?a)/)); +assert.compareArray(["b", undefined, "b"], "bab".match(/(?a)|(?b)/)); +assert.compareArray(["b", "b", undefined], "bab".match(/(?b)|(?a)/)); -assert.compareArray(["aa", "aa", undefined], "aa".match(/(?:(?a)|(?b))\k/)); -assert.compareArray(["bb", undefined, "bb"], "bb".match(/(?:(?a)|(?b))\k/)); +assert.compareArray(["aa", "a", undefined], "aa".match(/(?:(?a)|(?b))\k/)); +assert.compareArray(["bb", undefined, "b"], "bb".match(/(?:(?a)|(?b))\k/)); let matchResult = "aabb".match(/(?:(?:(?a)|(?b))\k){2}/); -assert.compareArray(["aabb", undefined, "bb"], matchResult); -assert.sameValue(matchResult.groups.x, "bb"); +assert.compareArray(["aabb", undefined, "b"], matchResult); +assert.sameValue(matchResult.groups.x, "b"); let notMatched = "abab".match(/(?:(?:(?a)|(?b))\k){2}/); assert.sameValue(notMatched, null);