summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-01-21 05:43:04 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-01-21 05:43:04 +0000
commit6ff613fc091549f3bcd3e49ee9f6dc8222f62147 (patch)
tree80822262aa351aa758989ba72939d86b09123a5c /test
parent3b817f834a7a5e7d49642ab1b7576174b104dd50 (diff)
* 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
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_array.rb7
-rw-r--r--test/ruby/test_enum.rb5
2 files changed, 9 insertions, 3 deletions
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