aboutsummaryrefslogtreecommitdiffstats
path: root/test/ruby/test_range.rb
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-02-14 15:45:11 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-02-14 15:45:11 +0000
commitf526784e1ee21f6d2b5d130673f5c3d96761f2bb (patch)
tree4cda7a4eb87c0458aa5da95825ce428d0db96e17 /test/ruby/test_range.rb
parentab9bc151e828843b9d9170754f4ba4d92ef85750 (diff)
downloadruby-f526784e1ee21f6d2b5d130673f5c3d96761f2bb.tar.gz
* enum.c: Enumerable#{min,min_by,max,max_by} extended to take an
optional argument. (nmin_cmp): New function. (nmin_block_cmp): Ditto (nmin_filter): Ditto. (nmin_i): Ditto. (nmin_run): Ditto. (enum_min): Call nmin_run if the optional argument is given. (nmin_max): Ditto. (nmin_min_by): Ditto. (nmin_max_by): Ditto. * range.c: Range#{min,max} extended to take an optional argument. (range_min): Call range_first if the optional argument is given. (range_max): Call rb_call_super if the optional argument is given. [ruby-core:57111] [Feature #8887] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44958 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_range.rb')
-rw-r--r--test/ruby/test_range.rb6
1 files changed, 6 insertions, 0 deletions
diff --git a/test/ruby/test_range.rb b/test/ruby/test_range.rb
index 41107e094a..69060aa521 100644
--- a/test/ruby/test_range.rb
+++ b/test/ruby/test_range.rb
@@ -60,6 +60,9 @@ class TestRange < Test::Unit::TestCase
assert_equal(0, (0..0).min)
assert_equal(nil, (0...0).min)
+
+ assert_equal([0,1,2], (0..10).min(3))
+ assert_equal([0,1], (0..1).min(3))
end
def test_max
@@ -77,6 +80,9 @@ class TestRange < Test::Unit::TestCase
assert_equal(0, (0..0).max)
assert_equal(nil, (0...0).max)
+
+ assert_equal([8,9,10], (0..10).max(3))
+ assert_equal([7,8,9], (0...10).max(3))
end
def test_initialize_twice