diff options
| author | nagachika <nagachika@ruby-lang.org> | 2023-08-29 21:06:04 +0900 |
|---|---|---|
| committer | nagachika <nagachika@ruby-lang.org> | 2023-08-29 21:06:04 +0900 |
| commit | 5d568e18980b2fdec4701b52f2d89833fa20c0a8 (patch) | |
| tree | 94fa09f70b4632ed8962fdef40a4dc6075f05d89 /test/ruby | |
| parent | e777064e4b064fd77aca65c123f1919433f6732d (diff) | |
merge revision(s) a28c5151f567cada0d2f5c0c3ec4df7f97b80784: [Backport #19855]
Fix Array#bsearch when block returns a non-integer numeric value
---
array.c | 4 ++--
test/ruby/test_array.rb | 4 ++++
2 files changed, 6 insertions(+), 2 deletions(-)
Diffstat (limited to 'test/ruby')
| -rw-r--r-- | test/ruby/test_array.rb | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/test/ruby/test_array.rb b/test/ruby/test_array.rb index f58f8a2778..6c0db0832b 100644 --- a/test/ruby/test_array.rb +++ b/test/ruby/test_array.rb @@ -3336,6 +3336,8 @@ class TestArray < Test::Unit::TestCase assert_equal(nil, a.bsearch {|x| 1 * (2**100) }) assert_equal(nil, a.bsearch {|x| (-1) * (2**100) }) + assert_equal(4, a.bsearch {|x| (4 - x).to_r }) + assert_include([4, 7], a.bsearch {|x| (2**100).coerce((1 - x / 4) * (2**100)).first }) end @@ -3371,6 +3373,8 @@ class TestArray < Test::Unit::TestCase assert_equal(nil, a.bsearch_index {|x| 1 * (2**100) }) assert_equal(nil, a.bsearch_index {|x| (-1) * (2**100) }) + assert_equal(1, a.bsearch_index {|x| (4 - x).to_r }) + assert_include([1, 2], a.bsearch_index {|x| (2**100).coerce((1 - x / 4) * (2**100)).first }) end |
