diff options
author | Ali Mohammad Pur <ali.mpfard@gmail.com> | 2021-07-31 18:47:44 +0430 |
---|---|---|
committer | Ali Mohammad Pur <Ali.mpfard@gmail.com> | 2021-08-02 17:22:50 +0430 |
commit | 85d87cbcc848d3db2fd01aef1967b420c51aa39a (patch) | |
tree | 916a81b25bf4d591e2a8154e8fac37a9392e3bc6 /Tests/LibRegex/Regex.cpp | |
parent | 5f342e4fa967e2cec84f958f3266ff6d51d591ff (diff) | |
download | serenity-85d87cbcc848d3db2fd01aef1967b420c51aa39a.zip |
LibRegex: Add some tests for Fork{Stay,Jump} performance
Without the previous fixes, these will blow up the stack.
Diffstat (limited to 'Tests/LibRegex/Regex.cpp')
-rw-r--r-- | Tests/LibRegex/Regex.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/Tests/LibRegex/Regex.cpp b/Tests/LibRegex/Regex.cpp index 043d520d9c..89ac69de7e 100644 --- a/Tests/LibRegex/Regex.cpp +++ b/Tests/LibRegex/Regex.cpp @@ -726,3 +726,19 @@ TEST_CASE(case_insensitive_match) EXPECT_EQ(result.matches.at(0).column, 4ul); } } + +TEST_CASE(extremely_long_fork_chain) +{ + Regex<ECMA262> re("(?:aa)*"); + auto result = re.match(String::repeated('a', 100'000)); + EXPECT_EQ(result.success, true); +} + +static auto g_lots_of_a_s = String::repeated('a', 10'000'000); + +BENCHMARK_CASE(fork_performance) +{ + Regex<ECMA262> re("(?:aa)*"); + auto result = re.match(g_lots_of_a_s); + EXPECT_EQ(result.success, true); +} |