summaryrefslogtreecommitdiff
path: root/test/ruby
diff options
context:
space:
mode:
Diffstat (limited to 'test/ruby')
-rw-r--r--test/ruby/test_array.rb3
1 files changed, 3 insertions, 0 deletions
diff --git a/test/ruby/test_array.rb b/test/ruby/test_array.rb
index a66d2301d0..2b48dcf308 100644
--- a/test/ruby/test_array.rb
+++ b/test/ruby/test_array.rb
@@ -1756,10 +1756,12 @@ class TestArray < Test::Unit::TestCase
end
def test_max
+ assert_equal(1, [1].max)
assert_equal(3, [1, 2, 3, 1, 2].max)
assert_equal(1, [1, 2, 3, 1, 2].max {|a,b| b <=> a })
cond = ->((a, ia), (b, ib)) { (b <=> a).nonzero? or ia <=> ib }
assert_equal([1, 3], [1, 2, 3, 1, 2].each_with_index.max(&cond))
+ assert_equal(3.0, [1.0, 3.0, 2.0].max)
ary = %w(albatross dog horse)
assert_equal("horse", ary.max)
assert_equal("albatross", ary.max {|a,b| a.length <=> b.length })
@@ -1777,6 +1779,7 @@ class TestArray < Test::Unit::TestCase
end
def test_minmax
+ assert_equal([3, 3], [3].minmax)
assert_equal([1, 3], [1, 2, 3, 1, 2].minmax)
assert_equal([3, 1], [1, 2, 3, 1, 2].minmax {|a,b| b <=> a })
cond = ->((a, ia), (b, ib)) { (b <=> a).nonzero? or ia <=> ib }