summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2020-10-02 10:57:07 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2020-10-02 11:02:45 +0900
commit89ca842dcce7f05942e2d7be3edc404c9556cafd (patch)
tree48fe19bbdabab8a3cb1fc7ec14bdf1488dfddd07 /test
parent4b41ee154f117e18b54c7fb31574f2e314f10f15 (diff)
Ensure that the comparison succeeded [Bug #17205]
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_array.rb21
1 files changed, 21 insertions, 0 deletions
diff --git a/test/ruby/test_array.rb b/test/ruby/test_array.rb
index 64bcf9f1aa..5d1785220e 100644
--- a/test/ruby/test_array.rb
+++ b/test/ruby/test_array.rb
@@ -1648,6 +1648,13 @@ class TestArray < Test::Unit::TestCase
TEST
end
+ def test_sort_uncomparable
+ assert_raise(ArgumentError) {[1, Float::NAN].sort}
+ assert_raise(ArgumentError) {[1.0, Float::NAN].sort}
+ assert_raise(ArgumentError) {[Float::NAN, 1].sort}
+ assert_raise(ArgumentError) {[Float::NAN, 1.0].sort}
+ end
+
def test_to_a
a = @cls[ 1, 2, 3 ]
a_id = a.__id__
@@ -1768,6 +1775,13 @@ class TestArray < Test::Unit::TestCase
assert_same(obj, [obj, 1.0].min)
end
+ def test_min_uncomparable
+ assert_raise(ArgumentError) {[1, Float::NAN].min}
+ assert_raise(ArgumentError) {[1.0, Float::NAN].min}
+ assert_raise(ArgumentError) {[Float::NAN, 1].min}
+ assert_raise(ArgumentError) {[Float::NAN, 1.0].min}
+ end
+
def test_max
assert_equal(1, [1].max)
assert_equal(3, [1, 2, 3, 1, 2].max)
@@ -1791,6 +1805,13 @@ class TestArray < Test::Unit::TestCase
assert_same(obj, [obj, 1.0].max)
end
+ def test_max_uncomparable
+ assert_raise(ArgumentError) {[1, Float::NAN].max}
+ assert_raise(ArgumentError) {[1.0, Float::NAN].max}
+ assert_raise(ArgumentError) {[Float::NAN, 1].max}
+ assert_raise(ArgumentError) {[Float::NAN, 1.0].max}
+ end
+
def test_minmax
assert_equal([3, 3], [3].minmax)
assert_equal([1, 3], [1, 2, 3, 1, 2].minmax)