1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Add test case of ArithmeticSequence#sum

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66518 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
mrkn 2018-12-23 18:54:51 +00:00
parent 325f9890de
commit 5c3be90ae0

View file

@ -430,4 +430,10 @@ class TestArithmeticSequence < Test::Unit::TestCase
assert_num_equal_type([0.0, 0.0+1.0i, 0.0+2.0i], (0.0..).step(1.0i).take(3))
assert_num_equal_type([0.0+0.0i, 0.0+1.0i, 0.0+2.0i], (0.0i..).step(1.0i).take(3))
end
def test_sum
assert_equal([1, 3, 5, 7, 9].sum, (1..10).step(2).sum)
assert_equal([1.0, 2.5, 4.0, 5.5, 7.0, 8.5, 10.0].sum, (1.0..10.0).step(1.5).sum)
assert_equal([1/2r, 1r, 3/2r, 2, 5/2r, 3, 7/2r, 4].sum, ((1/2r)...(9/2r)).step(1/2r).sum)
end
end