summaryrefslogtreecommitdiff
path: root/test/ruby
diff options
context:
space:
mode:
authorNobuyoshi Nakada <[email protected]>2025-03-07 17:23:33 +0900
committerNobuyoshi Nakada <[email protected]>2025-03-07 17:23:33 +0900
commitcbe3156f82ee8b68e734be58badb9b6a3adc8aa6 (patch)
treea175cd5460bb7cd170d57ec6749f740989940f99 /test/ruby
parent8841f885bde7bbe571d2043830799059870dc70c (diff)
[Bug #21174] [Bug #21175] Fix `Range#max` on beginless integer range
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/12879
Diffstat (limited to 'test/ruby')
-rw-r--r--test/ruby/test_range.rb8
1 files changed, 7 insertions, 1 deletions
diff --git a/test/ruby/test_range.rb b/test/ruby/test_range.rb
index 10d69ea2df..bc73de78d3 100644
--- a/test/ruby/test_range.rb
+++ b/test/ruby/test_range.rb
@@ -121,13 +121,15 @@ class TestRange < Test::Unit::TestCase
assert_equal([10,9,8], (0..10).max(3))
assert_equal([9,8,7], (0...10).max(3))
+ assert_equal([10,9,8], (..10).max(3))
+ assert_equal([9,8,7], (...10).max(3))
assert_raise(RangeError) { (1..).max(3) }
assert_raise(RangeError) { (1...).max(3) }
assert_raise(RangeError) { (..0).min {|a, b| a <=> b } }
assert_equal(2, (..2).max)
- assert_raise(TypeError) { (...2).max }
+ assert_equal(1, (...2).max)
assert_raise(TypeError) { (...2.0).max }
assert_equal(Float::INFINITY, (1..Float::INFINITY).max)
@@ -870,16 +872,20 @@ class TestRange < Test::Unit::TestCase
def test_first_last
assert_equal([0, 1, 2], (0..10).first(3))
assert_equal([8, 9, 10], (0..10).last(3))
+ assert_equal([8, 9, 10], (nil..10).last(3))
assert_equal(0, (0..10).first)
assert_equal(10, (0..10).last)
+ assert_equal(10, (nil..10).last)
assert_equal("a", ("a".."c").first)
assert_equal("c", ("a".."c").last)
assert_equal(0, (2..0).last)
assert_equal([0, 1, 2], (0...10).first(3))
assert_equal([7, 8, 9], (0...10).last(3))
+ assert_equal([7, 8, 9], (nil...10).last(3))
assert_equal(0, (0...10).first)
assert_equal(10, (0...10).last)
+ assert_equal(10, (nil...10).last)
assert_equal("a", ("a"..."c").first)
assert_equal("c", ("a"..."c").last)
assert_equal(0, (2...0).last)