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_array.rb | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'test/ruby/test_array.rb') diff --git a/test/ruby/test_array.rb b/test/ruby/test_array.rb index 9edd31dfa..1cd018be8 100644 --- a/test/ruby/test_array.rb +++ b/test/ruby/test_array.rb @@ -1502,6 +1502,14 @@ class TestArray < Test::Unit::TestCase a = [] [1, 2, 3].zip([:a, :b], ["a", "b", "c", "d"]) {|x| a << x } assert_equal([[1, :a, "a"], [2, :b, "b"], [3, nil, "c"]], 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([['a', 3], ['b', 4]], %w(a b).zip(ary)) + def ary.to_ary; [5, 6]; end + assert_equal([['a', 5], ['b', 6]], %w(a b).zip(ary)) end def test_transpose -- cgit