diff options
| author | U.Nakamura <usa@ruby-lang.org> | 2023-10-10 20:02:12 +0900 |
|---|---|---|
| committer | U.Nakamura <usa@ruby-lang.org> | 2023-10-10 20:02:12 +0900 |
| commit | eb54ed809f61fb25a0de101a7a6a649e8d4a434c (patch) | |
| tree | ac2fd32d0429dfc7de0af679db7f43e1221b3e55 /test/ruby/test_array.rb | |
| parent | 4153e807c55ec0fc234969ae08a01c1e0c8ed167 (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/test_array.rb')
| -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 ccbe85877f..0ed8ada95c 100644 --- a/test/ruby/test_array.rb +++ b/test/ruby/test_array.rb @@ -3218,6 +3218,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 @@ -3253,6 +3255,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 |
