mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
ruby/test_arithmetic_sequence.rb: add assertions for beginless and endless ranges
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67434 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
dcb37d0639
commit
53d3fe0643
1 changed files with 20 additions and 0 deletions
|
@ -26,6 +26,11 @@ class TestArithmeticSequence < Test::Unit::TestCase
|
|||
assert_equal(10, 10.step(to: 1, by: -2).begin)
|
||||
assert_equal(10, 10.step(to: -1, by: -2).begin)
|
||||
assert_equal(10.0, 10.0.step(to: -1.0, by: -2.0).begin)
|
||||
|
||||
assert_equal(3, (3..).step(2).begin)
|
||||
assert_equal(4, (4...).step(7).begin)
|
||||
assert_equal(nil, (..10).step(9).begin)
|
||||
assert_equal(nil, (...11).step(5).begin)
|
||||
end
|
||||
|
||||
def test_end
|
||||
|
@ -44,6 +49,11 @@ class TestArithmeticSequence < Test::Unit::TestCase
|
|||
assert_equal(1, 10.step(to: 1, by: -2).end)
|
||||
assert_equal(-1, 10.step(to: -1, by: -2).end)
|
||||
assert_equal(-1.0, 10.0.step(to: -1.0, by: -2.0).end)
|
||||
|
||||
assert_equal(nil, (3..).step(2).end)
|
||||
assert_equal(nil, (4...).step(7).end)
|
||||
assert_equal(10, (..10).step(9).end)
|
||||
assert_equal(11, (...11).step(5).end)
|
||||
end
|
||||
|
||||
def test_exclude_end_p
|
||||
|
@ -61,6 +71,11 @@ class TestArithmeticSequence < Test::Unit::TestCase
|
|||
assert_equal(false, 10.step(to: 1, by: -1).exclude_end?)
|
||||
assert_equal(false, 10.step(to: 1, by: -2).exclude_end?)
|
||||
assert_equal(false, 10.step(to: -1, by: -2).exclude_end?)
|
||||
|
||||
assert_equal(false, (3..).step(2).exclude_end?)
|
||||
assert_equal(true, (4...).step(7).exclude_end?)
|
||||
assert_equal(false, (..10).step(9).exclude_end?)
|
||||
assert_equal(true, (...11).step(5).exclude_end?)
|
||||
end
|
||||
|
||||
def test_step
|
||||
|
@ -79,6 +94,11 @@ class TestArithmeticSequence < Test::Unit::TestCase
|
|||
assert_equal(-2, 10.step(to: 1, by: -2).step)
|
||||
assert_equal(-2, 10.step(to: -1, by: -2).step)
|
||||
assert_equal(-2.0, 10.0.step(to: -1.0, by: -2.0).step)
|
||||
|
||||
assert_equal(2, (3..).step(2).step)
|
||||
assert_equal(7, (4...).step(7).step)
|
||||
assert_equal(9, (..10).step(9).step)
|
||||
assert_equal(5, (...11).step(5).step)
|
||||
end
|
||||
|
||||
def test_eq
|
||||
|
|
Loading…
Add table
Reference in a new issue