From 970e90dd1572994d3d9229725e12d47b3674fcbf Mon Sep 17 00:00:00 2001 From: matz Date: Tue, 2 Feb 2010 08:54:52 +0000 Subject: * enum.c (enum_each_entry): new method #each_entry to pack values from yield into an array. * lib/set.rb (Set#merge): use Enumerable#each_entry to implement Set compatible to 1.8 behavior. [ruby-core:27985] * lib/set.rb: replace is_a?(Enumerable) with respond_to?(:each) for duck typing. * lib/set.rb (SortedSet#add): typo fixed. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26540 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_enum.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'test') diff --git a/test/ruby/test_enum.rb b/test/ruby/test_enum.rb index d252cef426..945661f4b9 100644 --- a/test/ruby/test_enum.rb +++ b/test/ruby/test_enum.rb @@ -219,6 +219,18 @@ class TestEnumerable < Test::Unit::TestCase assert_equal([55, 3628800], ret) end + class Foo + include Enumerable + def each + yield 1 + yield 1,2 + end + end + + def test_each_entry + assert_equal([1, [1, 2]], Foo.new.each_entry.to_a) + end + def test_zip assert_equal([[1,1],[2,2],[3,3],[1,1],[2,2]], @obj.zip(@obj)) a = [] -- cgit v1.2.3