From 6ff613fc091549f3bcd3e49ee9f6dc8222f62147 Mon Sep 17 00:00:00 2001 From: usa Date: Wed, 21 Jan 2009 05:43:04 +0000 Subject: * array.c (take_items): to_ary() raises ArgumentError if cannot to convert to Array. [ruby-dev:37797] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21713 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_array.rb | 7 +++++-- test/ruby/test_enum.rb | 5 ++++- 2 files changed, 9 insertions(+), 3 deletions(-) (limited to 'test/ruby') diff --git a/test/ruby/test_array.rb b/test/ruby/test_array.rb index 04ed13892b..1cd018be85 100644 --- a/test/ruby/test_array.rb +++ b/test/ruby/test_array.rb @@ -1505,8 +1505,11 @@ class TestArray < Test::Unit::TestCase ary = Object.new def ary.to_a; [1, 2]; end - def ary.to_ary; [3, 4]; end - assert_equal([[5, 3], [6, 4]], [5, 6].zip(ary)) + 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 diff --git a/test/ruby/test_enum.rb b/test/ruby/test_enum.rb index 973b7cb420..a8a88640bd 100644 --- a/test/ruby/test_enum.rb +++ b/test/ruby/test_enum.rb @@ -214,8 +214,11 @@ class TestEnumerable < Test::Unit::TestCase ary = Object.new def ary.to_a; [1, 2]; end - def ary.to_ary; [3, 4]; 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 v1.2.3