// Copyright 2017 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- description: Named backreferences in non-Unicode RegExps esid: prod-GroupSpecifier features: [regexp-named-groups] includes: [compareArray.js] ---*/ // Named references. assert.compareArray(["bab", "b"], "bab".match(/(?.).\k/)); assert.sameValue(null, "baa".match(/(?.).\k/)); // Reference inside group. assert.compareArray(["bab", "b"], "bab".match(/(?\k\w)../)); assert.sameValue("b", "bab".match(/(?\k\w)../).groups.a); // Reference before group. assert.compareArray(["bab", "b"], "bab".match(/\k(?b)\w\k/)); assert.sameValue("b", "bab".match(/\k(?b)\w\k/).groups.a); assert.compareArray(["bab", "b", "a"], "bab".match(/(?b)\k(?a)\k/)); let {a, b} = "bab".match(/(?b)\k(?a)\k/).groups; assert.sameValue(a, "a"); assert.sameValue(b, "b"); assert.compareArray(["bab", "b"], "bab".match(/\k(?b)\w\k/)); assert.compareArray(["bab", "b", "a"], "bab".match(/(?b)\k(?a)\k/)); // Reference properties. assert.sameValue("a", /(?a)(?b)\k/.exec("aba").groups.a); assert.sameValue("b", /(?a)(?b)\k/.exec("aba").groups.b); assert.sameValue(undefined, /(?a)(?b)\k/.exec("aba").groups.c); assert.sameValue(undefined, /(?a)(?b)\k|(?c)/.exec("aba").groups.c); reportCompare(0, 0);