Improve malformed RegExp named groups coverage (#2568)

This commit is contained in:
Alexey Shvayka 2020-04-11 01:07:50 +03:00 committed by GitHub
parent 6fb6ff6ac5
commit 27a41b6321
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 7 deletions

View File

@ -0,0 +1,15 @@
// Copyright 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: prod-GroupSpecifier
description: >
\k is parsed as IdentityEscape as look-behind assertion is not a GroupName.
features: [regexp-named-groups, regexp-lookbehind]
---*/
assert(/\k<a>(?<=>)a/.test("k<a>a"));
assert(/(?<=>)\k<a>/.test(">k<a>"));
assert(/\k<a>(?<!a)a/.test("k<a>a"));
assert(/(?<!a>)\k<a>/.test("k<a>"));

View File

@ -6,7 +6,7 @@ description: >
Named groups in Unicode RegExps have some syntax errors and some
compatibility escape fallback behavior.
esid: prod-GroupSpecifier
features: [regexp-named-groups, regexp-lookbehind]
features: [regexp-named-groups]
includes: [compareArray.js]
---*/
@ -17,11 +17,9 @@ assert(/\k/.test("k"));
assert(/(?<a>\a)/.test("a"));
assert(compareArray(["k<a>"], "xxxk<a>xxx".match(/\k<a>/)));
assert(compareArray(["k<a"], "xxxk<a>xxx".match(/\k<a/)));
assert.compareArray(["k<a>"], "xxxk<a>xxx".match(/\k<a>/));
assert.compareArray(["k<a"], "xxxk<a>xxx".match(/\k<a/));
// A couple of corner cases around '\k' as named back-references vs. identity
// escapes.
assert(/\k<a>(?<=>)a/.test("k<a>a"));
assert(/\k<a>(?<!a)a/.test("k<a>a"));
assert(/\k<a>(<a>x)/.test("k<a><a>x"));
assert(/\k<a>\1/.test("k<a>\x01"));
assert(/\1(b)\k<a>/.test("bk<a>"));