[regexp] Rename result.group to result.groups
This is just an update to reflect the current spec proposal. https://tc39.github.io/proposal-regexp-named-groups/ BUG=v8:5437 Review-Url: https://codereview.chromium.org/2769143002 Cr-Commit-Position: refs/heads/master@{#44067}
This commit is contained in:
parent
3cbb2a50c8
commit
8c0f2315fc
@ -165,7 +165,7 @@ Node* RegExpBuiltinsAssembler::ConstructNewResultFromMatchInfo(
|
||||
// Store it on the result as a 'group' property.
|
||||
|
||||
{
|
||||
Node* const name = HeapConstant(isolate()->factory()->group_string());
|
||||
Node* const name = HeapConstant(isolate()->factory()->groups_string());
|
||||
CallRuntime(Runtime::kCreateDataProperty, context, result, name,
|
||||
group_object);
|
||||
}
|
||||
|
@ -80,7 +80,7 @@
|
||||
V(get_string, "get") \
|
||||
V(get_space_string, "get ") \
|
||||
V(global_string, "global") \
|
||||
V(group_string, "group") \
|
||||
V(groups_string, "groups") \
|
||||
V(has_string, "has") \
|
||||
V(hour_string, "hour") \
|
||||
V(ignoreCase_string, "ignoreCase") \
|
||||
|
@ -76,23 +76,23 @@ assertEquals(["bab", "b"], "bab".match(/\k<a>(?<a>b)\w\k<a>/u));
|
||||
assertEquals(["bab", "b", "a"], "bab".match(/(?<b>b)\k<a>(?<a>a)\k<b>/u));
|
||||
|
||||
// Reference properties.
|
||||
assertEquals("a", /(?<a>a)(?<b>b)\k<a>/u.exec("aba").group.a);
|
||||
assertEquals("b", /(?<a>a)(?<b>b)\k<a>/u.exec("aba").group.b);
|
||||
assertEquals(undefined, /(?<a>a)(?<b>b)\k<a>/u.exec("aba").group.c);
|
||||
assertEquals(undefined, /(?<a>a)(?<b>b)\k<a>|(?<c>c)/u.exec("aba").group.c);
|
||||
assertEquals("a", /(?<a>a)(?<b>b)\k<a>/u.exec("aba").groups.a);
|
||||
assertEquals("b", /(?<a>a)(?<b>b)\k<a>/u.exec("aba").groups.b);
|
||||
assertEquals(undefined, /(?<a>a)(?<b>b)\k<a>/u.exec("aba").groups.c);
|
||||
assertEquals(undefined, /(?<a>a)(?<b>b)\k<a>|(?<c>c)/u.exec("aba").groups.c);
|
||||
|
||||
// Unicode names.
|
||||
assertEquals("a", /(?<π>a)/u.exec("bab").group.π);
|
||||
assertEquals("a", /(?<\u{03C0}>a)/u.exec("bab").group.\u03C0);
|
||||
assertEquals("a", /(?<$>a)/u.exec("bab").group.$);
|
||||
assertEquals("a", /(?<_>a)/u.exec("bab").group._);
|
||||
assertEquals("a", /(?<$𐒤>a)/u.exec("bab").group.$𐒤);
|
||||
assertEquals("a", /(?<_\u200C>a)/u.exec("bab").group._\u200C);
|
||||
assertEquals("a", /(?<_\u200D>a)/u.exec("bab").group._\u200D);
|
||||
assertEquals("a", /(?<ಠ_ಠ>a)/u.exec("bab").group.ಠ_ಠ);
|
||||
assertEquals("a", /(?<π>a)/u.exec("bab").groups.π);
|
||||
assertEquals("a", /(?<\u{03C0}>a)/u.exec("bab").groups.\u03C0);
|
||||
assertEquals("a", /(?<$>a)/u.exec("bab").groups.$);
|
||||
assertEquals("a", /(?<_>a)/u.exec("bab").groups._);
|
||||
assertEquals("a", /(?<$𐒤>a)/u.exec("bab").groups.$𐒤);
|
||||
assertEquals("a", /(?<_\u200C>a)/u.exec("bab").groups._\u200C);
|
||||
assertEquals("a", /(?<_\u200D>a)/u.exec("bab").groups._\u200D);
|
||||
assertEquals("a", /(?<ಠ_ಠ>a)/u.exec("bab").groups.ಠ_ಠ);
|
||||
assertThrows('/(?<❤>a)/u', SyntaxError);
|
||||
assertThrows('/(?<𐒤>a)/u', SyntaxError); // ID_Continue but not ID_Start.
|
||||
|
||||
// The '__proto__' property on the groups object.
|
||||
assertEquals(undefined, /(?<a>.)/u.exec("a").group.__proto__);
|
||||
assertEquals("a", /(?<__proto__>a)/u.exec("a").group.__proto__);
|
||||
assertEquals(undefined, /(?<a>.)/u.exec("a").groups.__proto__);
|
||||
assertEquals("a", /(?<__proto__>a)/u.exec("a").groups.__proto__);
|
||||
|
Loading…
Reference in New Issue
Block a user