diff options
Diffstat (limited to 'test/built-ins/RegExp/named-groups')
18 files changed, 65 insertions, 97 deletions
diff --git a/test/built-ins/RegExp/named-groups/functional-replace-global.js b/test/built-ins/RegExp/named-groups/functional-replace-global.js index 83d32592c..819045ec1 100644 --- a/test/built-ins/RegExp/named-groups/functional-replace-global.js +++ b/test/built-ins/RegExp/named-groups/functional-replace-global.js @@ -22,34 +22,35 @@ for (let flags of ["g", "gu"]) { let i = 0; let re = new RegExp(source, flags); let result = "abcd".replace(re, - (match, fst, snd, offset, str, groups) => { - if (i == 0) { - assert.sameValue("ab", match); - assert.sameValue("a", groups.fst); - assert.sameValue("b", groups.snd); - assert.sameValue("a", fst); - assert.sameValue("b", snd); - assert.sameValue(0, offset); - assert.sameValue("abcd", str); - } else if (i == 1) { - assert.sameValue("cd", match); - assert.sameValue("c", groups.fst); - assert.sameValue("d", groups.snd); - assert.sameValue("c", fst); - assert.sameValue("d", snd); - assert.sameValue(2, offset); - assert.sameValue("abcd", str); - } else { - assertUnreachable(); - } - i++; - return `${groups.snd}${groups.fst}`; - }); + (match, fst, snd, offset, str, groups) => { + if (i == 0) { + assert.sameValue("ab", match); + assert.sameValue("a", groups.fst); + assert.sameValue("b", groups.snd); + assert.sameValue("a", fst); + assert.sameValue("b", snd); + assert.sameValue(0, offset); + assert.sameValue("abcd", str); + } else if (i == 1) { + assert.sameValue("cd", match); + assert.sameValue("c", groups.fst); + assert.sameValue("d", groups.snd); + assert.sameValue("c", fst); + assert.sameValue("d", snd); + assert.sameValue(2, offset); + assert.sameValue("abcd", str); + } else { + assertUnreachable(); + } + i++; + return `${groups.snd}${groups.fst}`; + }); assert.sameValue("badc", result); assert.sameValue(i, 2); let re2 = new RegExp(alternateSource, flags); assert.sameValue("undefinedundefinedundefinedundefined", - "abcd".replace(re2, - (match, fst, snd, offset, str, groups) => groups.snd)); + "abcd".replace(re2, + (match, fst, snd, offset, str, groups) => groups.snd)); } + diff --git a/test/built-ins/RegExp/named-groups/functional-replace-non-global.js b/test/built-ins/RegExp/named-groups/functional-replace-non-global.js index 54d2a0b7e..0572a0545 100644 --- a/test/built-ins/RegExp/named-groups/functional-replace-non-global.js +++ b/test/built-ins/RegExp/named-groups/functional-replace-non-global.js @@ -22,22 +22,22 @@ for (let flags of ["", "u"]) { let i = 0; let re = new RegExp(source, flags); let result = "abcd".replace(re, - (match, fst, snd, offset, str, groups) => { - assert.sameValue(i++, 0); - assert.sameValue("ab", match); - assert.sameValue("a", groups.fst); - assert.sameValue("b", groups.snd); - assert.sameValue("a", fst); - assert.sameValue("b", snd); - assert.sameValue(0, offset); - assert.sameValue("abcd", str); - return `${groups.snd}${groups.fst}`; - }); + (match, fst, snd, offset, str, groups) => { + assert.sameValue(i++, 0); + assert.sameValue("ab", match); + assert.sameValue("a", groups.fst); + assert.sameValue("b", groups.snd); + assert.sameValue("a", fst); + assert.sameValue("b", snd); + assert.sameValue(0, offset); + assert.sameValue("abcd", str); + return `${groups.snd}${groups.fst}`; + }); assert.sameValue("bacd", result); assert.sameValue(i, 1); let re2 = new RegExp(alternateSource, flags); assert.sameValue("undefinedbcd", - "abcd".replace(re2, - (match, fst, snd, offset, str, groups) => groups.snd)); + "abcd".replace(re2, + (match, fst, snd, offset, str, groups) => groups.snd)); } diff --git a/test/built-ins/RegExp/named-groups/groups-object-subclass-sans.js b/test/built-ins/RegExp/named-groups/groups-object-subclass-sans.js index 1bbc2a9e5..4542868a8 100644 --- a/test/built-ins/RegExp/named-groups/groups-object-subclass-sans.js +++ b/test/built-ins/RegExp/named-groups/groups-object-subclass-sans.js @@ -29,9 +29,7 @@ const result = re.exec("ab"); assert.sameValue(Object.getPrototypeOf(result), Array.prototype); assert.sameValue(false, result.hasOwnProperty("groups")); -Array.prototype.groups = { - a: "b" -}; +Array.prototype.groups = { a: "b" }; Object.getPrototypeOf(Array.prototype.groups).b = "c"; assert.sameValue("b", "ab".replace(re, "$<a>")); assert.sameValue("c", "ab".replace(re, "$<b>")); diff --git a/test/built-ins/RegExp/named-groups/groups-object-subclass.js b/test/built-ins/RegExp/named-groups/groups-object-subclass.js index 88cb12cb2..ab3da38e9 100644 --- a/test/built-ins/RegExp/named-groups/groups-object-subclass.js +++ b/test/built-ins/RegExp/named-groups/groups-object-subclass.js @@ -19,9 +19,7 @@ class FakeRegExp extends RegExp { exec(subject) { const fakeResult = ["ab", "a"]; fakeResult.index = 0; - fakeResult.groups = { - a: "b" - }; + fakeResult.groups = { a: "b" }; Object.getPrototypeOf(fakeResult.groups).b = "c"; return fakeResult; } diff --git a/test/built-ins/RegExp/named-groups/groups-object-undefined.js b/test/built-ins/RegExp/named-groups/groups-object-undefined.js index bf832a217..fea8fd0bf 100644 --- a/test/built-ins/RegExp/named-groups/groups-object-undefined.js +++ b/test/built-ins/RegExp/named-groups/groups-object-undefined.js @@ -28,8 +28,6 @@ verifyProperty(result, "groups", { configurable: true, }); -Array.prototype.groups = { - a: "b" -}; +Array.prototype.groups = { a: "b" }; assert.sameValue("$<a>", "a".replace(re, "$<a>")); Array.prototype.groups = undefined; diff --git a/test/built-ins/RegExp/named-groups/groups-object-unmatched.js b/test/built-ins/RegExp/named-groups/groups-object-unmatched.js index 8b9df648c..fb0bdca8f 100644 --- a/test/built-ins/RegExp/named-groups/groups-object-unmatched.js +++ b/test/built-ins/RegExp/named-groups/groups-object-unmatched.js @@ -28,11 +28,7 @@ assert.sameValue(undefined, result.groups.x); // `a` is a matched named capture, `b` is an unmatched named capture, and `z` // is not a named capture. -Array.prototype.groups = { - a: "b", - x: "y", - z: "z" -}; +Array.prototype.groups = { a: "b", x: "y", z: "z" }; assert.sameValue("a", "ab".replace(re, "$<a>")); assert.sameValue("", "ab".replace(re, "$<x>")); assert.sameValue("", "ab".replace(re, "$<z>")); diff --git a/test/built-ins/RegExp/named-groups/groups-object.js b/test/built-ins/RegExp/named-groups/groups-object.js index 8b3f7da38..32a85bf75 100644 --- a/test/built-ins/RegExp/named-groups/groups-object.js +++ b/test/built-ins/RegExp/named-groups/groups-object.js @@ -18,9 +18,7 @@ info: | // `groups` is created with Define, not Set. let counter = 0; Object.defineProperty(Array.prototype, "groups", { - set() { - counter++; - } + set() { counter++; } }); let match = /(?<x>.)/.exec("a"); @@ -36,8 +34,6 @@ verifyProperty(match, "groups", { // The `__proto__` property on the groups object is not special, // and does not affect the [[Prototype]] of the resulting groups object. -let { - groups -} = /(?<__proto__>.)/.exec("a"); +let {groups} = /(?<__proto__>.)/.exec("a"); assert.sameValue("a", groups.__proto__); assert.sameValue(null, Object.getPrototypeOf(groups)); diff --git a/test/built-ins/RegExp/named-groups/groups-properties.js b/test/built-ins/RegExp/named-groups/groups-properties.js index a0c6ea377..9d7aa66f2 100644 --- a/test/built-ins/RegExp/named-groups/groups-properties.js +++ b/test/built-ins/RegExp/named-groups/groups-properties.js @@ -16,16 +16,12 @@ info: | // Properties created on result.groups in textual order. assert(compareArray(["fst", "snd"], - Object.getOwnPropertyNames( - /(?<fst>.)|(?<snd>.)/u.exec("abcd").groups))); + Object.getOwnPropertyNames( + /(?<fst>.)|(?<snd>.)/u.exec("abcd").groups))); // Properties are created with Define, not Set let counter = 0; -Object.defineProperty(Object.prototype, 'x', { - set() { - counter++; - } -}); +Object.defineProperty(Object.prototype, 'x', {set() { counter++; }}); let match = /(?<x>.)/.exec('a'); let groups = match.groups; assert.sameValue(counter, 0); diff --git a/test/built-ins/RegExp/named-groups/lookbehind.js b/test/built-ins/RegExp/named-groups/lookbehind.js index 1748732ef..e3926bc97 100644 --- a/test/built-ins/RegExp/named-groups/lookbehind.js +++ b/test/built-ins/RegExp/named-groups/lookbehind.js @@ -42,5 +42,5 @@ assert(compareArray(["f", undefined], "abcdef".match(/(?<a>(?<!\D{3}))f|f/))); // Even within a lookbehind, properties are created in left to right order assert(compareArray(["fst", "snd"], - Object.getOwnPropertyNames( - /(?<=(?<fst>.)|(?<snd>.))/u.exec("abcd").groups))); + Object.getOwnPropertyNames( + /(?<=(?<fst>.)|(?<snd>.))/u.exec("abcd").groups))); diff --git a/test/built-ins/RegExp/named-groups/non-unicode-match.js b/test/built-ins/RegExp/named-groups/non-unicode-match.js index 7255c4704..7904c75e4 100644 --- a/test/built-ins/RegExp/named-groups/non-unicode-match.js +++ b/test/built-ins/RegExp/named-groups/non-unicode-match.js @@ -19,11 +19,7 @@ assert(compareArray(["bab", "ab"], "bab".match(/.(?<a>\w\w)/))); assert(compareArray(["bab", "bab"], "bab".match(/(?<a>\w\w\w)/))); assert(compareArray(["bab", "ba", "b"], "bab".match(/(?<a>\w\w)(?<b>\w)/))); -let { - a, - b, - c -} = /(?<a>.)(?<b>.)(?<c>.)\k<c>\k<b>\k<a>/.exec("abccba").groups; +let {a, b, c} = /(?<a>.)(?<b>.)(?<c>.)\k<c>\k<b>\k<a>/.exec("abccba").groups; assert.sameValue(a, "a"); assert.sameValue(b, "b"); assert.sameValue(c, "c"); @@ -42,6 +38,6 @@ assert(compareArray("bab".match(/(\w\w)(\w)/), "bab".match(/(?<a>\w\w)(?<b>\w)/) assert(compareArray(["bab", "b"], "bab".match(/(?<b>b).\1/))); assert(compareArray(["baba", "b", "a"], "baba".match(/(.)(?<a>a)\1\2/))); assert(compareArray(["baba", "b", "a", "b", "a"], - "baba".match(/(.)(?<a>a)(?<b>\1)(\2)/))); + "baba".match(/(.)(?<a>a)(?<b>\1)(\2)/))); assert(compareArray(["<a", "<"], "<a".match(/(?<lt><)a/))); assert(compareArray([">a", ">"], ">a".match(/(?<gt>>)a/))); diff --git a/test/built-ins/RegExp/named-groups/non-unicode-property-names.js b/test/built-ins/RegExp/named-groups/non-unicode-property-names.js index 390f628ca..9c02d0b51 100644 --- a/test/built-ins/RegExp/named-groups/non-unicode-property-names.js +++ b/test/built-ins/RegExp/named-groups/non-unicode-property-names.js @@ -14,8 +14,8 @@ assert.sameValue("a", /(?<π>a)/.exec("bab").groups.\u03C0); assert.sameValue("a", /(?<$>a)/.exec("bab").groups.$); assert.sameValue("a", /(?<_>a)/.exec("bab").groups._); assert.throws(SyntaxError, () => eval('/(?<$𐒤>a)/'), "Individual surrogates not in ID_Continue"); -assert.sameValue("a", /(?<_\u200C>a)/.exec("bab").groups._\ u200C); -assert.sameValue("a", /(?<_\u200D>a)/.exec("bab").groups._\ u200D); +assert.sameValue("a", /(?<_\u200C>a)/.exec("bab").groups._\u200C); +assert.sameValue("a", /(?<_\u200D>a)/.exec("bab").groups._\u200D); assert.sameValue("a", /(?<ಠ_ಠ>a)/.exec("bab").groups.ಠ_ಠ); assert.throws(SyntaxError, () => eval('/(?<❤>a)/')); assert.throws(SyntaxError, () => eval('/(?<𐒤>a)/'), "Individual surrogate not in ID_Start."); diff --git a/test/built-ins/RegExp/named-groups/non-unicode-references.js b/test/built-ins/RegExp/named-groups/non-unicode-references.js index 4a283aa7f..33d62a3f0 100644 --- a/test/built-ins/RegExp/named-groups/non-unicode-references.js +++ b/test/built-ins/RegExp/named-groups/non-unicode-references.js @@ -20,10 +20,7 @@ assert.sameValue("b", "bab".match(/(?<a>\k<a>\w)../).groups.a); assert(compareArray(["bab", "b"], "bab".match(/\k<a>(?<a>b)\w\k<a>/))); assert.sameValue("b", "bab".match(/\k<a>(?<a>b)\w\k<a>/).groups.a); assert(compareArray(["bab", "b", "a"], "bab".match(/(?<b>b)\k<a>(?<a>a)\k<b>/))); -let { - a, - b -} = "bab".match(/(?<b>b)\k<a>(?<a>a)\k<b>/).groups; +let {a, b} = "bab".match(/(?<b>b)\k<a>(?<a>a)\k<b>/).groups; assert.sameValue(a, "a"); assert.sameValue(b, "b"); diff --git a/test/built-ins/RegExp/named-groups/string-replace-nocaptures.js b/test/built-ins/RegExp/named-groups/string-replace-nocaptures.js index 4ae21e7f8..76f134cc8 100644 --- a/test/built-ins/RegExp/named-groups/string-replace-nocaptures.js +++ b/test/built-ins/RegExp/named-groups/string-replace-nocaptures.js @@ -29,3 +29,4 @@ for (let flags of ["", "u"]) { assert.sameValue("$<fth>cd", "abcd".replace(re, "$<fth>")); assert.sameValue("$<a>cd", "abcd".replace(re, "$<$1>")); } + diff --git a/test/built-ins/RegExp/named-groups/string-replace-numbered.js b/test/built-ins/RegExp/named-groups/string-replace-numbered.js index 516624b30..c825df398 100644 --- a/test/built-ins/RegExp/named-groups/string-replace-numbered.js +++ b/test/built-ins/RegExp/named-groups/string-replace-numbered.js @@ -26,3 +26,4 @@ for (let flags of ["", "u"]) { let re = new RegExp(source, flags); assert.sameValue("bacd", "abcd".replace(re, "$2$1")); } + diff --git a/test/built-ins/RegExp/named-groups/unicode-malformed.js b/test/built-ins/RegExp/named-groups/unicode-malformed.js index 87ae6134c..5c9c131a4 100644 --- a/test/built-ins/RegExp/named-groups/unicode-malformed.js +++ b/test/built-ins/RegExp/named-groups/unicode-malformed.js @@ -26,3 +26,4 @@ assert.throws(SyntaxError, () => eval("/(?<a>a)\\k<ab>/u"), "Invalid reference") assert.throws(SyntaxError, () => eval("/(?<ab>a)\\k<a>/u"), "Invalid reference"); assert.throws(SyntaxError, () => eval("/\\k<a>(?<ab>a)/u"), "Invalid reference"); assert.throws(SyntaxError, () => eval("/(?<a>\\a)/u"), "Identity escape in capture"); + diff --git a/test/built-ins/RegExp/named-groups/unicode-match.js b/test/built-ins/RegExp/named-groups/unicode-match.js index c72a292c8..a8e1059bd 100644 --- a/test/built-ins/RegExp/named-groups/unicode-match.js +++ b/test/built-ins/RegExp/named-groups/unicode-match.js @@ -19,11 +19,7 @@ assert(compareArray(["bab", "ab"], "bab".match(/.(?<a>\w\w)/u))); assert(compareArray(["bab", "bab"], "bab".match(/(?<a>\w\w\w)/u))); assert(compareArray(["bab", "ba", "b"], "bab".match(/(?<a>\w\w)(?<b>\w)/u))); -let { - a, - b, - c -} = /(?<a>.)(?<b>.)(?<c>.)\k<c>\k<b>\k<a>/u.exec("abccba").groups; +let {a, b, c} = /(?<a>.)(?<b>.)(?<c>.)\k<c>\k<b>\k<a>/u.exec("abccba").groups; assert.sameValue(a, "a"); assert.sameValue(b, "b"); assert.sameValue(c, "c"); @@ -42,15 +38,11 @@ assert(compareArray("bab".match(/(\w\w)(\w)/u), "bab".match(/(?<a>\w\w)(?<b>\w)/ assert(compareArray(["bab", "b"], "bab".match(/(?<b>b).\1/u))); assert(compareArray(["baba", "b", "a"], "baba".match(/(.)(?<a>a)\1\2/u))); assert(compareArray(["baba", "b", "a", "b", "a"], - "baba".match(/(.)(?<a>a)(?<b>\1)(\2)/u))); + "baba".match(/(.)(?<a>a)(?<b>\1)(\2)/u))); assert(compareArray(["<a", "<"], "<a".match(/(?<lt><)a/u))); assert(compareArray([">a", ">"], ">a".match(/(?<gt>>)a/u))); // Nested groups. assert(compareArray(["bab", "bab", "ab", "b"], "bab".match(/(?<a>.(?<b>.(?<c>.)))/u))); -assert(compareArray({ - a: "bab", - b: "ab", - c: "b" - }, - "bab".match(/(?<a>.(?<b>.(?<c>.)))/u).groups)); +assert(compareArray({a: "bab", b: "ab", c: "b"}, + "bab".match(/(?<a>.(?<b>.(?<c>.)))/u).groups)); diff --git a/test/built-ins/RegExp/named-groups/unicode-property-names.js b/test/built-ins/RegExp/named-groups/unicode-property-names.js index a8007cce0..24e4a6ade 100644 --- a/test/built-ins/RegExp/named-groups/unicode-property-names.js +++ b/test/built-ins/RegExp/named-groups/unicode-property-names.js @@ -14,8 +14,8 @@ assert.sameValue("a", /(?<\u{03C0}>a)/u.exec("bab").groups.\u03C0); assert.sameValue("a", /(?<$>a)/u.exec("bab").groups.$); assert.sameValue("a", /(?<_>a)/u.exec("bab").groups._); assert.sameValue("a", /(?<$𐒤>a)/u.exec("bab").groups.$𐒤); -assert.sameValue("a", /(?<_\u200C>a)/u.exec("bab").groups._\ u200C); -assert.sameValue("a", /(?<_\u200D>a)/u.exec("bab").groups._\ u200D); +assert.sameValue("a", /(?<_\u200C>a)/u.exec("bab").groups._\u200C); +assert.sameValue("a", /(?<_\u200D>a)/u.exec("bab").groups._\u200D); assert.sameValue("a", /(?<ಠ_ಠ>a)/u.exec("bab").groups.ಠ_ಠ); assert.throws(SyntaxError, () => eval('/(?<❤>a)/u')); assert.throws(SyntaxError, () => eval('/(?<𐒤>a)/u'), "ID_Continue but not ID_Start."); diff --git a/test/built-ins/RegExp/named-groups/unicode-references.js b/test/built-ins/RegExp/named-groups/unicode-references.js index 9f8df10f5..1f95a2f40 100644 --- a/test/built-ins/RegExp/named-groups/unicode-references.js +++ b/test/built-ins/RegExp/named-groups/unicode-references.js @@ -33,10 +33,7 @@ assert.sameValue("b", "bab".match(/(?<a>\k<a>\w)../u).groups.a); assert(compareArray(["bab", "b"], "bab".match(/\k<a>(?<a>b)\w\k<a>/u))); assert.sameValue("b", "bab".match(/\k<a>(?<a>b)\w\k<a>/u).groups.a); assert(compareArray(["bab", "b", "a"], "bab".match(/(?<b>b)\k<a>(?<a>a)\k<b>/u))); -let { - a, - b -} = "bab".match(/(?<b>b)\k<a>(?<a>a)\k<b>/u).groups; +let {a, b} = "bab".match(/(?<b>b)\k<a>(?<a>a)\k<b>/u).groups; assert.sameValue(a, "a"); assert.sameValue(b, "b"); |