| 1 |
// Copyright 2017 the V8 project authors. All rights reserved. |
| 2 |
// This code is governed by the BSD license found in the LICENSE file. |
| 3 |
|
| 4 |
/*--- |
| 5 |
description: > |
| 6 |
Named groups in Unicode RegExps have some syntax errors and some |
| 7 |
compatibility escape fallback behavior. |
| 8 |
esid: prod-GroupSpecifier |
| 9 |
features: [regexp-named-groups, regexp-lookbehind] |
| 10 |
includes: [compareArray.js] |
| 11 |
---*/ |
| 12 |
|
| 13 |
assert(/\k<a>/.test("k<a>")); |
| 14 |
assert(/\k<4>/.test("k<4>")); |
| 15 |
assert(/\k<a/.test("k<a")); |
| 16 |
assert(/\k/.test("k")); |
| 17 |
|
| 18 |
assert(/(?<a>\a)/.test("a")); |
| 19 |
|
| 20 |
assert(compareArray(["k<a>"], "xxxk<a>xxx".match(/\k<a>/))); |
| 21 |
assert(compareArray(["k<a"], "xxxk<a>xxx".match(/\k<a/))); |
| 22 |
|
| 23 |
// A couple of corner cases around '\k' as named back-references vs. identity |
| 24 |
// escapes. |
| 25 |
assert(/\k<a>(?<=>)a/.test("k<a>a")); |
| 26 |
assert(/\k<a>(?<!a)a/.test("k<a>a")); |
| 27 |
assert(/\k<a>(<a>x)/.test("k<a><a>x")); |