ruby-changes:54309
From: mrkn <ko1@a...>
Date: Mon, 24 Dec 2018 03:54:56 +0900 (JST)
Subject: [ruby-changes:54309] mrkn:r66518 (trunk): Add test case of ArithmeticSequence#sum
mrkn 2018-12-24 03:54:51 +0900 (Mon, 24 Dec 2018) New Revision: 66518 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=66518 Log: Add test case of ArithmeticSequence#sum Modified files: trunk/test/ruby/test_arithmetic_sequence.rb Index: test/ruby/test_arithmetic_sequence.rb =================================================================== --- test/ruby/test_arithmetic_sequence.rb (revision 66517) +++ test/ruby/test_arithmetic_sequence.rb (revision 66518) @@ -430,4 +430,10 @@ class TestArithmeticSequence < Test::Uni https://github.com/ruby/ruby/blob/trunk/test/ruby/test_arithmetic_sequence.rb#L430 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 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/