From 27a41b6321538197152c67f11279dc9b3204113c Mon Sep 17 00:00:00 2001 From: Alexey Shvayka Date: Sat, 11 Apr 2020 01:07:50 +0300 Subject: [PATCH] Improve malformed RegExp named groups coverage (#2568) --- .../non-unicode-malformed-lookbehind.js | 15 +++++++++++++++ .../RegExp/named-groups/non-unicode-malformed.js | 12 +++++------- 2 files changed, 20 insertions(+), 7 deletions(-) create mode 100644 test/annexB/built-ins/RegExp/named-groups/non-unicode-malformed-lookbehind.js diff --git a/test/annexB/built-ins/RegExp/named-groups/non-unicode-malformed-lookbehind.js b/test/annexB/built-ins/RegExp/named-groups/non-unicode-malformed-lookbehind.js new file mode 100644 index 0000000000..2d3aa1d4d9 --- /dev/null +++ b/test/annexB/built-ins/RegExp/named-groups/non-unicode-malformed-lookbehind.js @@ -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/.test("ka")); +assert(/(?<=>)\k/.test(">k")); + +assert(/\k(?a")); +assert(/(?)\k/.test("k")); diff --git a/test/annexB/built-ins/RegExp/named-groups/non-unicode-malformed.js b/test/annexB/built-ins/RegExp/named-groups/non-unicode-malformed.js index 89911e13bf..98c0406287 100644 --- a/test/annexB/built-ins/RegExp/named-groups/non-unicode-malformed.js +++ b/test/annexB/built-ins/RegExp/named-groups/non-unicode-malformed.js @@ -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)/.test("a")); -assert(compareArray(["k"], "xxxkxxx".match(/\k/))); -assert(compareArray(["kxxx".match(/\k"], "xxxkxxx".match(/\k/)); +assert.compareArray(["kxxx".match(/\k(?<=>)a/.test("ka")); -assert(/\k(?a")); assert(/\k(x)/.test("kx")); +assert(/\k\1/.test("k\x01")); +assert(/\1(b)\k/.test("bk"));