1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 06:58:11 +00:00

LibRegex: Add basic support for unicode escapes in ECMA262Parser

This parses unicode escapes (and matches them only for utf8 strings).
This commit is contained in:
AnotherTest 2020-12-06 17:04:28 +03:30 committed by Andreas Kling
parent 86811683b0
commit 765d2977bc
2 changed files with 31 additions and 4 deletions

View file

@ -477,6 +477,7 @@ TEST_CASE(ECMA262_parse)
struct _test {
const char* pattern;
regex::Error expected_error { regex::Error::NoError };
regex::ECMAScriptFlags flags {};
};
constexpr _test tests[] {
@ -497,6 +498,8 @@ TEST_CASE(ECMA262_parse)
{ "\\x" }, // Even invalid escapes are allowed if ~unicode.
{ "\\", regex::Error::InvalidTrailingEscape },
{ "(?", regex::Error::InvalidCaptureGroup },
{ "\\u1234", regex::Error::NoError, regex::ECMAScriptFlags::Unicode },
{ "[\\u1234]", regex::Error::NoError, regex::ECMAScriptFlags::Unicode },
};
for (auto& test : tests) {