summaryrefslogtreecommitdiff
path: root/test/ruby
diff options
context:
space:
mode:
authornagachika <nagachika@ruby-lang.org>2023-08-29 21:06:04 +0900
committernagachika <nagachika@ruby-lang.org>2023-08-29 21:06:04 +0900
commit5d568e18980b2fdec4701b52f2d89833fa20c0a8 (patch)
tree94fa09f70b4632ed8962fdef40a4dc6075f05d89 /test/ruby
parente777064e4b064fd77aca65c123f1919433f6732d (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.rb4
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