summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorknu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-08-26 10:28:57 +0000
committerknu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-08-26 10:28:57 +0000
commit2e248635499284b5dfd63e33e81c2c3dafe405cc (patch)
treebb089dccab3a73d23ecf886cf08c737cbb7dd781
parent0924bcf835596a05cfde5ca87572b8ab0385bd0c (diff)
* test/ruby/test_enum.rb (TestEnumerable#test_each_with_object):
Add a test for Enumerable#each_with_object. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18868 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog7
-rw-r--r--test/ruby/test_enum.rb10
2 files changed, 16 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index d60c6179d9..6b6855e024 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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 a739982963..ed82d7787f 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 = []