From 1d14bf2a75d05361566002ead897c996d6cfe71b Mon Sep 17 00:00:00 2001 From: yugui Date: Wed, 28 Jan 2009 09:20:03 +0000 Subject: introduces r21693 again and merges r21713 * array.c (take_items), enum.c (enum_zip): tries to convert to array first. [ruby-core:21442] -- * array.c (take_items): to_ary() raises ArgumentError if cannot to convert to Array. [ruby-dev:37797] git-svn-id: http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_9_1@21814 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_enum.rb | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'test/ruby/test_enum.rb') diff --git a/test/ruby/test_enum.rb b/test/ruby/test_enum.rb index ed82d7787..a8a88640b 100644 --- a/test/ruby/test_enum.rb +++ b/test/ruby/test_enum.rb @@ -211,6 +211,14 @@ class TestEnumerable < Test::Unit::TestCase a = [] @obj.zip([:a, :b, :c]) {|x,y| a << [x, y] } assert_equal([[1,:a],[2,:b],[3,:c],[1,nil],[2,nil]], a) + + ary = Object.new + def ary.to_a; [1, 2]; end + assert_raise(NoMethodError){ %w(a b).zip(ary) } + def ary.each; [3, 4].each{|e|yield e}; end + assert_equal([[1, 3], [2, 4], [3, nil], [1, nil], [2, nil]], @obj.zip(ary)) + def ary.to_ary; [5, 6]; end + assert_equal([[1, 5], [2, 6], [3, nil], [1, nil], [2, nil]], @obj.zip(ary)) end def test_take -- cgit