mirror of
https://github.com/ruby/ruby.git
synced 2025-08-25 22:14:37 +02:00
* numeric.c (num_step): Support for Numeric#step.size
[Feature #6636] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37515 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
f02c29ee4f
commit
34be3a5d90
3 changed files with 56 additions and 2 deletions
|
@ -522,5 +522,20 @@ class TestEnumerator < Test::Unit::TestCase
|
|||
assert_equal 0, @sized.each_cons(70).size
|
||||
assert_raise(ArgumentError){ @obj.each_cons(0).size }
|
||||
end
|
||||
|
||||
def test_size_for_step
|
||||
assert_equal 42, 5.step(46).size
|
||||
assert_equal 4, 1.step(10, 3).size
|
||||
assert_equal 3, 1.step(9, 3).size
|
||||
assert_equal 0, 1.step(-11).size
|
||||
assert_equal 0, 1.step(-11, 2).size
|
||||
assert_equal 7, 1.step(-11, -2).size
|
||||
assert_equal 7, 1.step(-11.1, -2).size
|
||||
assert_equal 0, 42.step(Float::INFINITY, -2).size
|
||||
assert_equal 1, 42.step(55, Float::INFINITY).size
|
||||
assert_equal 1, 42.step(Float::INFINITY, Float::INFINITY).size
|
||||
assert_equal 14, 0.1.step(4.2, 0.3).size
|
||||
assert_equal Float::INFINITY, 42.step(Float::INFINITY, 2).size
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue