mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 04:47:35 +00:00
LibRegex: Treat inverted Compare entries as disjunctions
[^XYZ] is not(X | Y | Z), we used to translate this to not(X) | not(Y) | not(Z), this commit makes LibRegex interpret this pattern as not(X) & not(Y) & not(Z).
This commit is contained in:
parent
fe46b2c141
commit
d348eaf305
2 changed files with 33 additions and 13 deletions
|
@ -1040,11 +1040,23 @@ TEST_CASE(single_match_flag)
|
|||
|
||||
TEST_CASE(inversion_state_in_char_class)
|
||||
{
|
||||
// #13755, /[\S\s]/.exec("hello") should be [ "h" ], not null.
|
||||
Regex<ECMA262> re("[\\S\\s]", ECMAScriptFlags::Global | (ECMAScriptFlags)regex::AllFlags::SingleMatch);
|
||||
{
|
||||
// #13755, /[\S\s]/.exec("hello") should be [ "h" ], not null.
|
||||
Regex<ECMA262> re("[\\S\\s]", ECMAScriptFlags::Global | (ECMAScriptFlags)regex::AllFlags::SingleMatch);
|
||||
|
||||
auto result = re.match("hello");
|
||||
EXPECT_EQ(result.success, true);
|
||||
EXPECT_EQ(result.matches.size(), 1u);
|
||||
EXPECT_EQ(result.matches.first().view.to_string(), "h"sv);
|
||||
auto result = re.match("hello");
|
||||
EXPECT_EQ(result.success, true);
|
||||
EXPECT_EQ(result.matches.size(), 1u);
|
||||
EXPECT_EQ(result.matches.first().view.to_string(), "h"sv);
|
||||
}
|
||||
{
|
||||
Regex<ECMA262> re("^(?:([^\\s!\"#%-,\\./;->@\\[-\\^`\\{-~]+(?=([=~}\\s/.)|]))))"sv, ECMAScriptFlags::Global);
|
||||
|
||||
auto result = re.match("slideNumbers}}"sv);
|
||||
EXPECT_EQ(result.success, true);
|
||||
EXPECT_EQ(result.matches.size(), 1u);
|
||||
EXPECT_EQ(result.matches.first().view.to_string(), "slideNumbers"sv);
|
||||
EXPECT_EQ(result.capture_group_matches.first()[0].view.to_string(), "slideNumbers"sv);
|
||||
EXPECT_EQ(result.capture_group_matches.first()[1].view.to_string(), "}"sv);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue