1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* array.c (recursive_join): use obj to tell if recursion occurs.

[ruby-core:24150]

* enum.c (enum_join): reverted r23966.  [ruby-core:24196]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24017 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2009-07-10 07:30:08 +00:00
parent 5e2a28d13d
commit af8f8e5b0e
5 changed files with 33 additions and 39 deletions

View file

@ -295,14 +295,23 @@ class TestEnumerable < Test::Unit::TestCase
assert_equal("123", (1..3).join())
assert_raise(TypeError, '[ruby-core:24172]') {("a".."c").join(1)}
class << (e = Object.new.extend(Enumerable))
def to_s
"e"
end
def each
yield self
end
end
assert_equal("e", e.join(""))
assert_equal("[...]", e.join(""), '[ruby-core:24150]')
assert_equal("[...]", [e].join(""), '[ruby-core:24150]')
e = Class.new {
include Enumerable
def initialize(*args)
@e = args
end
def each
@e.each {|e| yield e}
end
}
e = e.new(1, e.new(2, e.new(3, e.new(4, 5))))
assert_equal("1:2:3:4:5", e.join(':'), '[ruby-core:24196]')
ensure
$, = ofs
end