diff options
author | Yusuke Endoh <mame@ruby-lang.org> | 2022-11-11 09:05:51 +0900 |
---|---|---|
committer | Yusuke Endoh <mame@ruby-lang.org> | 2022-11-11 09:07:00 +0900 |
commit | adfbee85e07494d42e54b1c616e5fa62a207fb8f (patch) | |
tree | c0e5421e6dd98f5e166a9d3d1d68c70d1097ee37 /test/ruby/test_regexp.rb | |
parent | 4c554096bfc08939e9eb1fb1773514b62b8b95b5 (diff) | |
download | ruby-adfbee85e07494d42e54b1c616e5fa62a207fb8f.tar.gz |
Allow a float error for Regexp.timeout
The tests failed on windows
https://github.com/ruby/ruby/actions/runs/3440997073/jobs/5740085169#step:18:62
```
1) Failure:
TestRegexp#test_s_timeout [D:/a/ruby/ruby/src/test/ruby/test_regexp.rb:1586]:
<0.30000000000000004> expected but was
<0.3>.
2) Failure:
TestRegexp#test_timeout_shorter_than_global [D:/a/ruby/ruby/src/test/ruby/test_regexp.rb:1631]:
<0.30000000000000004> expected but was
<0.3>.
```
Diffstat (limited to 'test/ruby/test_regexp.rb')
-rw-r--r-- | test/ruby/test_regexp.rb | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/test/ruby/test_regexp.rb b/test/ruby/test_regexp.rb index 87ce6987e3..3479a9f212 100644 --- a/test/ruby/test_regexp.rb +++ b/test/ruby/test_regexp.rb @@ -1583,7 +1583,7 @@ class TestRegexp < Test::Unit::TestCase timeout = #{ EnvUtil.apply_timeout_scale(0.2).inspect } begin; Regexp.timeout = timeout - assert_equal(timeout, Regexp.timeout) + assert_in_delta(timeout, Regexp.timeout, timeout * 2 * Float::EPSILON) t = Time.now assert_raise_with_message(Regexp::TimeoutError, "regexp match timeout") do @@ -1628,7 +1628,11 @@ class TestRegexp < Test::Unit::TestCase Regexp.timeout = global_timeout re = Regexp.new("^(a*)\\1b?a*$", timeout: per_instance_timeout) - assert_equal(per_instance_timeout, re.timeout) + if per_instance_timeout + assert_in_delta(per_instance_timeout, re.timeout, per_instance_timeout * 2 * Float::EPSILON) + else + assert_nil(re.timeout) + end t = Time.now assert_raise_with_message(Regexp::TimeoutError, "regexp match timeout") do |