From 7ce4b716bdb5bcfc8b30ffcd034ce7aded1f72b9 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Sun, 12 Mar 2023 18:50:39 +0900 Subject: Add test for linear performance --- test/ruby/test_regexp.rb | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'test/ruby') 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 -- cgit v1.2.3