[前][次][番号順一覧][スレッド一覧]

ruby-changes:12275

From: nobu <ko1@a...>
Date: Mon, 6 Jul 2009 09:10:13 +0900 (JST)
Subject: [ruby-changes:12275] Ruby:r23967 (trunk): * enum.c (enum_join): deals with self recursive objects to get rid

nobu	2009-07-06 09:09:59 +0900 (Mon, 06 Jul 2009)

  New Revision: 23967

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=23967

  Log:
    * enum.c (enum_join): deals with self recursive objects to get rid
      of infinite recursion.  [ruby-core:24150]

  Modified files:
    trunk/test/ruby/test_enum.rb

Index: test/ruby/test_enum.rb
===================================================================
--- test/ruby/test_enum.rb	(revision 23966)
+++ test/ruby/test_enum.rb	(revision 23967)
@@ -283,4 +283,18 @@
   def test_reverse_each
     assert_equal([2,1,3,2,1], @obj.reverse_each.to_a)
   end
+
+  def test_join
+    assert_equal("abc", ("a".."c").join(""))
+    assert_equal("a-b-c", ("a".."c").join("-"))
+    class << (e = Object.new.extend(Enumerable))
+      def to_s
+        "e"
+      end
+      def each
+        yield self
+      end
+    end
+    assert_equal("e", e.join(""))
+  end
 end

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]