diff options
| author | Kouhei Yanagita <yanagi@shakenbu.org> | 2023-08-29 14:49:57 +0900 |
|---|---|---|
| committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2023-08-29 18:00:44 +0900 |
| commit | a28c5151f567cada0d2f5c0c3ec4df7f97b80784 (patch) | |
| tree | c006d837ea1da1928f4d4d239c1262a045ae2e2e /test/ruby | |
| parent | f16c50772c97c9cbc2f9f1eb0087224a92c3c99b (diff) | |
Fix Array#bsearch when block returns a non-integer numeric value
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/8314
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 |
