diff options
author | mrkn <mrkn@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-05-17 13:58:46 +0000 |
---|---|---|
committer | mrkn <mrkn@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-05-17 13:58:46 +0000 |
commit | 41ef7ec381338a97d15a6b4b18acd8b426a9ce79 (patch) | |
tree | 7fca575e53a48e43b015df51e43e8fb8e26f6a62 /test/ruby/test_range.rb | |
parent | 341b34d7339c267c51448d35d9e8f47413fbcc53 (diff) | |
download | ruby-41ef7ec381338a97d15a6b4b18acd8b426a9ce79.tar.gz |
Implement Enumerable#sum
* enum.c (enum_sum): Implement Enumerable#sum.
* test/ruby/test_enum.rb (test_sum): Test sum for Enumerable.
* test/ruby/test_hash.rb (test_sum): Test sum for Hash.
* test/ruby/test_range.rb (test_sum): Test sum for Range.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55032 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_range.rb')
-rw-r--r-- | test/ruby/test_range.rb | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/test/ruby/test_range.rb b/test/ruby/test_range.rb index 2bff105936..431ed0dc30 100644 --- a/test/ruby/test_range.rb +++ b/test/ruby/test_range.rb @@ -631,4 +631,9 @@ class TestRange < Test::Unit::TestCase end (a.."c").each {|x, &b| assert_nil(b)} end + + def test_sum + assert_equal(55, (1..10).sum) + assert_equal(110, (1..10).sum {|v| v * 2 }) + end end |