diff options
Diffstat (limited to 'test/ruby/test_regexp.rb')
-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 c996b1785a..828117f516 100644 --- a/test/ruby/test_regexp.rb +++ b/test/ruby/test_regexp.rb @@ -1783,7 +1783,7 @@ class TestRegexp < Test::Unit::TestCase end t = Time.now - t - assert_in_delta(timeout, t, timeout / 2) + assert_operator(timeout, :<=, [timeout * 1.5, 1].max) end; end @@ -1827,6 +1827,14 @@ class TestRegexp < Test::Unit::TestCase end; end + def test_bug_20453 + re = Regexp.new("^(a*)x$", timeout: 0.001) + + assert_raise(Regexp::TimeoutError) do + re =~ "a" * 1000000 + "x" + end + end + def per_instance_redos_test(global_timeout, per_instance_timeout, expected_timeout) assert_separately([], "#{<<-"begin;"}\n#{<<-'end;'}") global_timeout = #{ EnvUtil.apply_timeout_scale(global_timeout).inspect } @@ -1854,7 +1862,7 @@ class TestRegexp < Test::Unit::TestCase def test_timeout_shorter_than_global omit "timeout test is too unstable on s390x" if RUBY_PLATFORM =~ /s390x/ - per_instance_redos_test(10, 0.2, 0.2) + per_instance_redos_test(10, 0.5, 0.5) end def test_timeout_longer_than_global @@ -1921,7 +1929,7 @@ class TestRegexp < Test::Unit::TestCase end def test_match_cache_positive_look_ahead - assert_separately([], "#{<<-"begin;"}\n#{<<-'end;'}") + assert_separately([], "#{<<-"begin;"}\n#{<<-'end;'}", timeout: 30) timeout = #{ EnvUtil.apply_timeout_scale(10).inspect } begin; Regexp.timeout = timeout |