summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_array.rb6
-rw-r--r--test/ruby/test_range.rb6
2 files changed, 12 insertions, 0 deletions
diff --git a/test/ruby/test_array.rb b/test/ruby/test_array.rb
index 6c7f920d79..ae0f76c970 100644
--- a/test/ruby/test_array.rb
+++ b/test/ruby/test_array.rb
@@ -2249,6 +2249,12 @@ class TestArray < Test::Unit::TestCase
assert_raise(ArgumentError) { a.rotate!(1, 1) }
end
+ def test_bsearch_with_no_block
+ enum = [1, 2, 42, 100, 666].bsearch
+ assert_nil enum.size
+ assert_equal 42, enum.each{|x| x >= 33 }
+ end
+
def test_bsearch_in_find_minimum_mode
a = [0, 4, 7, 10, 12]
assert_equal(4, a.bsearch {|x| x >= 4 })
diff --git a/test/ruby/test_range.rb b/test/ruby/test_range.rb
index f8e9658728..c8867cf2ec 100644
--- a/test/ruby/test_range.rb
+++ b/test/ruby/test_range.rb
@@ -356,6 +356,12 @@ class TestRange < Test::Unit::TestCase
assert_equal 42, (1..42).each.size
end
+ def test_bsearch_with_no_block
+ enum = (42...666).bsearch
+ assert_nil enum.size
+ assert_equal 200, enum.each{|x| x >= 200 }
+ end
+
def test_bsearch_for_fixnum
ary = [3, 4, 7, 9, 12]
assert_equal(0, (0...ary.size).bsearch {|i| ary[i] >= 2 })