mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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
This commit is contained in:
parent
0924bcf835
commit
2e24863549
2 changed files with 16 additions and 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>
|
||||
|
||||
|
|
|
@ -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 = []
|
||||
|
|
Loading…
Add table
Reference in a new issue