summaryrefslogtreecommitdiff
path: root/test/ruby
diff options
context:
space:
mode:
authornagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-08-05 10:59:57 +0000
committernagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-08-05 10:59:57 +0000
commit61cb2958095fe3b05fcec25aea943fa3e06262e6 (patch)
treeb5b285662c21626a6d6e92fbf609af1a80f8a704 /test/ruby
parentfcb4a3d88fa38589239281b1b670b95fba47b277 (diff)
merge revision(s) 61766: [Backport #14350]
vm_insnhelper.c: search in the indexing order * vm_insnhelper.c (vm_opt_newarray_max, vm_opt_newarray_min): search in the indexing order, as well as usual methods. [ruby-core:84821] [Bug #14350] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_5@64195 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby')
-rw-r--r--test/ruby/test_array.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/test/ruby/test_array.rb b/test/ruby/test_array.rb
index 7e63623b7d..955121c0f0 100644
--- a/test/ruby/test_array.rb
+++ b/test/ruby/test_array.rb
@@ -1631,6 +1631,12 @@ class TestArray < Test::Unit::TestCase
ary.min(2) {|a,b| a.length <=> b.length })
assert_equal([13, 14], [20, 32, 32, 21, 30, 25, 29, 13, 14].min(2))
assert_equal([2, 4, 6, 7], [2, 4, 8, 6, 7].min(4))
+
+ class << (obj = Object.new)
+ def <=>(x) 1 <=> x end
+ def coerce(x) [x, 1] end
+ end
+ assert_same(obj, [obj, 1.0].min)
end
def test_max
@@ -1646,6 +1652,12 @@ class TestArray < Test::Unit::TestCase
assert_equal(%w[albatross horse],
ary.max(2) {|a,b| a.length <=> b.length })
assert_equal([3, 2], [0, 0, 0, 0, 0, 0, 1, 3, 2].max(2))
+
+ class << (obj = Object.new)
+ def <=>(x) 1 <=> x end
+ def coerce(x) [x, 1] end
+ end
+ assert_same(obj, [obj, 1.0].max)
end
def test_uniq