mirror of
https://github.com/tc39/test262.git
synced 2025-04-08 19:35:28 +02:00
For each character class escape (\d, \D, \s, \S, \w, \W), check positive cases (the escape matches all characters it's supposed to match) and negative cases (the escape doesn't match any of the characters it should not match). Each of these checks is also done in Unicode mode and with the v flag. This uses regenerate.js from the unicode-property-escapes-tests repo to generate strings that contain exactly the characters that are supposed to be matched or not matched for each escape. Comparison is done with regex test instead of regex replace to optimize the tests. This is part of my work at the SYSTEMF lab at EPFL. Avoid modifying the regenerate library object prototype.
52 lines
1.6 KiB
JavaScript
52 lines
1.6 KiB
JavaScript
export default description => {
|
|
let header = `// Copyright (C) 2018 Leo Balter. All rights reserved.
|
|
// Copyright (C) 2024 Aurèle Barrière. All rights reserved.
|
|
// This code is governed by the BSD license found in the LICENSE file.
|
|
|
|
/*---
|
|
esid: prod-CharacterClassEscape
|
|
description: >
|
|
${description}
|
|
info: |
|
|
This is a generated test. Please check out
|
|
https://github.com/tc39/test262/tree/main/tools/regexp-generator/
|
|
for any changes.
|
|
|
|
CharacterClassEscape[UnicodeMode] ::
|
|
d
|
|
D
|
|
s
|
|
S
|
|
w
|
|
W
|
|
[+UnicodeMode] p{ UnicodePropertyValueExpression }
|
|
[+UnicodeMode] P{ UnicodePropertyValueExpression }
|
|
|
|
22.2.2.9 Runtime Semantics: CompileToCharSet
|
|
|
|
CharacterClassEscape :: d
|
|
1. Return the ten-element CharSet containing the characters 0, 1, 2, 3, 4,
|
|
5, 6, 7, 8, and 9.
|
|
CharacterClassEscape :: D
|
|
1. Let S be the CharSet returned by CharacterClassEscape :: d.
|
|
2. Return CharacterComplement(rer, S).
|
|
CharacterClassEscape :: s
|
|
1. Return the CharSet containing all characters corresponding to a code
|
|
point on the right-hand side of the WhiteSpace or LineTerminator
|
|
productions.
|
|
CharacterClassEscape :: S
|
|
1. Let S be the CharSet returned by CharacterClassEscape :: s.
|
|
2. Return CharacterComplement(rer, S).
|
|
CharacterClassEscape :: w
|
|
1. Return MaybeSimpleCaseFolding(rer, WordCharacters(rer)).
|
|
CharacterClassEscape :: W
|
|
1. Let S be the CharSet returned by CharacterClassEscape :: w.
|
|
2. Return CharacterComplement(rer, S).
|
|
features: [String.fromCodePoint]
|
|
includes: [regExpUtils.js]
|
|
flags: [generated]
|
|
---*/\n`;
|
|
|
|
return header;
|
|
};
|