diff options
author | TSUYUSATO Kitsune <make.just.on@gmail.com> | 2023-04-19 13:08:28 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-19 13:08:28 +0900 |
commit | a1c2c274eebcc2a5275b677ebf94a8dbff380770 (patch) | |
tree | b3ae0486cccb292ecd43226ac599943fa5b165b2 /test | |
parent | 8023da746c7cee630cbb12ca0c60083127af885a (diff) | |
download | ruby-a1c2c274eebcc2a5275b677ebf94a8dbff380770.tar.gz |
Refactor `Regexp#match` cache implementation (#7724)
* Refactor Regexp#match cache implementation
Improved variable and function names
Fixed [Bug 19537] (Maybe fixed in https://github.com/ruby/ruby/pull/7694)
* Add a comment of the glossary for "match cache"
* Skip to reset match cache when no cache point on null check
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_regexp.rb | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/test/ruby/test_regexp.rb b/test/ruby/test_regexp.rb index d50e481d2d..83dcb69530 100644 --- a/test/ruby/test_regexp.rb +++ b/test/ruby/test_regexp.rb @@ -1733,7 +1733,7 @@ class TestRegexp < Test::Unit::TestCase end; end - def test_cache_optimization_exponential + def test_match_cache_exponential assert_separately([], "#{<<-"begin;"}\n#{<<-'end;'}") timeout = #{ EnvUtil.apply_timeout_scale(10).inspect } begin; @@ -1743,7 +1743,7 @@ class TestRegexp < Test::Unit::TestCase end; end - def test_cache_optimization_square + def test_match_cache_square assert_separately([], "#{<<-"begin;"}\n#{<<-'end;'}") timeout = #{ EnvUtil.apply_timeout_scale(10).inspect } begin; @@ -1753,7 +1753,7 @@ class TestRegexp < Test::Unit::TestCase end; end - def test_cache_index_initialize + def test_cache_opcodes_initialize str = 'test1-test2-test3-test4-test_5' re = '^([0-9a-zA-Z\-/]*){1,256}$' 100.times do @@ -1781,6 +1781,14 @@ class TestRegexp < Test::Unit::TestCase assert_equal("123456789".match(/(?:x?\dx?){2,}/)[0], "123456789") end + def test_bug_19537 + str = 'aac' + re = '^([ab]{1,3})(a?)*$' + 100.times do + assert !Regexp.new(re).match?(str) + end + end + def test_linear_time_p assert_send [Regexp, :linear_time?, /a/] assert_send [Regexp, :linear_time?, 'a'] |