diff options
| author | knu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-08-26 10:28:57 +0000 |
|---|---|---|
| committer | knu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-08-26 10:28:57 +0000 |
| commit | 0d5fe384c6662c369097c003dd9683925c4e9f28 (patch) | |
| tree | bb089dccab3a73d23ecf886cf08c737cbb7dd781 | |
| parent | 6415fdb24b91eb17c387f76c0079f7a81d7e387b (diff) | |
| download | ruby-0d5fe384c6662c369097c003dd9683925c4e9f28.tar.gz ruby-0d5fe384c6662c369097c003dd9683925c4e9f28.tar.xz ruby-0d5fe384c6662c369097c003dd9683925c4e9f28.zip | |
* test/ruby/test_enum.rb (TestEnumerable#test_each_with_object):
Add a test for Enumerable#each_with_object.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@18868 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
| -rw-r--r-- | ChangeLog | 7 | ||||
| -rw-r--r-- | test/ruby/test_enum.rb | 10 |
2 files changed, 16 insertions, 1 deletions
@@ -1,7 +1,12 @@ +Tue Aug 26 19:27:54 2008 Akinori MUSHA <knu@iDaemons.org> + + * test/ruby/test_enum.rb (TestEnumerable#test_each_with_object): + Add a test for Enumerable#each_with_object. + Tue Aug 26 19:25:44 2008 Akinori MUSHA <knu@iDaemons.org> * test/ruby/test_enumerator.rb (TestEnumerator#test_with_object): - Add (back) the test for Enumerable#with_object. + Add (back) the test for Enumerator#with_object. Tue Aug 26 16:16:43 2008 NARUSE, Yui <naruse@ruby-lang.org> diff --git a/test/ruby/test_enum.rb b/test/ruby/test_enum.rb index a73998296..ed82d7787 100644 --- a/test/ruby/test_enum.rb +++ b/test/ruby/test_enum.rb @@ -196,6 +196,16 @@ class TestEnumerable < Test::Unit::TestCase assert_equal({"cat"=>0, "wombat"=>2, "dog"=>1}, hash) end + def test_each_with_object + obj = [0, 1] + ret = (1..10).each_with_object(obj) {|i, memo| + memo[0] += i + memo[1] *= i + } + assert_same(obj, ret) + assert_equal([55, 3628800], ret) + end + def test_zip assert_equal([[1,1],[2,2],[3,3],[1,1],[2,2]], @obj.zip(@obj)) a = [] |
