summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormrkn <mrkn@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-12-23 18:54:51 (GMT)
committermrkn <mrkn@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-12-23 18:54:51 (GMT)
commit5c3be90ae09f03f412cde51dc500da51827aafe7 (patch)
tree6aabda09432b22b1aa39faafd578b0f8c2e71767
parent325f9890de97679125a80daf1a038da97cea8adb (diff)
Add test case of ArithmeticSequence#sum
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66518 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--test/ruby/test_arithmetic_sequence.rb6
1 files changed, 6 insertions, 0 deletions
diff --git a/test/ruby/test_arithmetic_sequence.rb b/test/ruby/test_arithmetic_sequence.rb
index 3a353ad..b4c93d4 100644
--- a/test/ruby/test_arithmetic_sequence.rb
+++ b/test/ruby/test_arithmetic_sequence.rb
@@ -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