Skip to content

Commit 1d983a0

Browse files
committed
add a test for \w regex under /iu flags
1 parent 742f32f commit 1d983a0

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Copyright (C) 2026 Nikita Skovoroda. All rights reserved.
2+
// This code is governed by the BSD license found in the LICENSE file.
3+
4+
/*---
5+
esid: sec-wordcharacters
6+
description: >
7+
\w with case-insensitive flag behaves differently in Unicode patterns.
8+
info: |
9+
WordCharacters ( rer )
10+
The abstract operation WordCharacters takes argument rer (a RegExp Record) and returns a CharSet. Returns a CharSet containing the characters considered "word characters" for the purposes of \b, \B, \w, and \W It performs the following steps when called:
11+
12+
1. Let basicWordChars be the CharSet containing every character in the ASCII word characters.
13+
2. Let extraWordChars be the CharSet containing all characters c such that c is not in basicWordChars but Canonicalize(rer, c) is in basicWordChars.
14+
3. Assert: extraWordChars is empty unless HasEitherUnicodeFlag(rer) is true and rer.[[IgnoreCase]] is true.
15+
4. Return the union of basicWordChars and extraWordChars.
16+
---*/
17+
18+
assert.sameValue(/\w/.test('\u212a'), false);
19+
assert.sameValue(/\w/u.test('\u212a'), false);
20+
assert.sameValue(/\w/i.test('\u212a'), false);
21+
assert.sameValue(/\w/ui.test('\u212a'), true);

0 commit comments

Comments
 (0)