diff options
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | enum.c | 4 | ||||
-rw-r--r-- | test/ruby/test_enum.rb | 5 |
3 files changed, 15 insertions, 1 deletions
@@ -1,3 +1,10 @@ +Tue Aug 11 10:48:16 2015 SHIBATA Hiroshi <[email protected]> + + * enum.c: added doc for Enumerable#zip + [fix GH-985] Patch by @yui-knk + * test/ruby/test_enum.rb: added tests for Enumerable#zip + [fix GH-985] Patch @yui-knk + Tue Aug 11 10:33:26 2015 SHIBATA Hiroshi <[email protected]> * vm_method.c: typo fix [fix GH-993][ci skip] Patch by @0x0dea @@ -2454,6 +2454,10 @@ zip_i(RB_BLOCK_CALL_FUNC_ARGLIST(val, memoval)) * [1, 2].zip(a, b) #=> [[1, 4, 7], [2, 5, 8]] * a.zip([1, 2], [8]) #=> [[4, 1, 8], [5, 2, nil], [6, nil, nil]] * + * c = [] + * a.zip(b) { |x, y| c << x + y } #=> nil + * c #=> [11, 13, 15] + * */ static VALUE diff --git a/test/ruby/test_enum.rb b/test/ruby/test_enum.rb index 7a6e15174f..26c8815cfe 100644 --- a/test/ruby/test_enum.rb +++ b/test/ruby/test_enum.rb @@ -434,8 +434,11 @@ class TestEnumerable < Test::Unit::TestCase def test_zip assert_equal([[1,1],[2,2],[3,3],[1,1],[2,2]], @obj.zip(@obj)) + assert_equal([["a",1],["b",2],["c",3]], ["a", "b", "c"].zip(@obj)) + a = [] - @obj.zip([:a, :b, :c]) {|x,y| a << [x, y] } + result = @obj.zip([:a, :b, :c]) {|x,y| a << [x, y] } + assert_nil result assert_equal([[1,:a],[2,:b],[3,:c],[1,nil],[2,nil]], a) a = [] |