|
@@ -998,6 +998,15 @@ BENCHMARK_CASE(fork_performance)
|
|
|
EXPECT_EQ(result.success, true);
|
|
|
}
|
|
|
|
|
|
+BENCHMARK_CASE(anchor_performance)
|
|
|
+{
|
|
|
+ Regex<ECMA262> re("^b");
|
|
|
+ for (auto i = 0; i < 100'000; i++) {
|
|
|
+ auto result = re.match(g_lots_of_a_s);
|
|
|
+ EXPECT_EQ(result.success, false);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
TEST_CASE(optimizer_atomic_groups)
|
|
|
{
|
|
|
Array tests {
|
|
@@ -1078,6 +1087,21 @@ TEST_CASE(optimizer_alternation)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+TEST_CASE(start_anchor)
|
|
|
+{
|
|
|
+ // Ensure that a circumflex at the start only matches the start of the line.
|
|
|
+ {
|
|
|
+ Regex<PosixBasic> re("^abc");
|
|
|
+ EXPECT_EQ(re.match("123abcdef"sv, PosixFlags::Global).success, false);
|
|
|
+ EXPECT_EQ(re.match("abc123"sv, PosixFlags::Global).success, true);
|
|
|
+ EXPECT_EQ(re.match("123^abcdef"sv, PosixFlags::Global).success, false);
|
|
|
+ EXPECT_EQ(re.match("^abc123"sv, PosixFlags::Global).success, false);
|
|
|
+
|
|
|
+ // Multiple lines
|
|
|
+ EXPECT_EQ(re.match("123\nabc"sv, PosixFlags::Multiline).success, true);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
TEST_CASE(posix_basic_dollar_is_end_anchor)
|
|
|
{
|
|
|
// Ensure that a dollar sign at the end only matches the end of the line.
|