summaryrefslogtreecommitdiff
path: root/test/ruby/test_regexp.rb
diff options
context:
space:
mode:
authorNobuyoshi Nakada <[email protected]>2023-03-12 18:50:39 +0900
committerNobuyoshi Nakada <[email protected]>2023-03-12 18:50:39 +0900
commit7ce4b716bdb5bcfc8b30ffcd034ce7aded1f72b9 (patch)
tree500ecd184564fb4ae62ab6ff37e56d1fcadadb65 /test/ruby/test_regexp.rb
parent781222a8bc61597a72d6f64b15734a5fae38146a (diff)
Add test for linear performance
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/7506
Diffstat (limited to 'test/ruby/test_regexp.rb')
-rw-r--r--test/ruby/test_regexp.rb7
1 files changed, 7 insertions, 0 deletions
diff --git a/test/ruby/test_regexp.rb b/test/ruby/test_regexp.rb
index 37375c0e3a..ae2bf82bb8 100644
--- a/test/ruby/test_regexp.rb
+++ b/test/ruby/test_regexp.rb
@@ -1765,4 +1765,11 @@ class TestRegexp < Test::Unit::TestCase
assert_raise(TypeError) {Regexp.linear_time?(nil)}
assert_raise(TypeError) {Regexp.linear_time?(Regexp.allocate)}
end
+
+ def test_linear_performance
+ pre = ->(n) {[Regexp.new("a?" * n + "a" * n), "a" * n]}
+ assert_linear_performance(factor: 29, first: 10, max: 1, pre: pre) do |re, s|
+ re =~ s
+ end
+ end
end