summaryrefslogtreecommitdiff
path: root/test/ruby
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-07-10 07:30:08 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-07-10 07:30:08 +0000
commitaf8f8e5b0e135570f9e5cd2aa8e949ec2e204b31 (patch)
tree627e3a415dba6b7f070bc0c60db0eec60af897ff /test/ruby
parent5e2a28d13de0d44852c7b040c17d80387cc0f058 (diff)
* 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
Diffstat (limited to 'test/ruby')
-rw-r--r--test/ruby/test_array.rb5
-rw-r--r--test/ruby/test_enum.rb17
2 files changed, 18 insertions, 4 deletions
diff --git a/test/ruby/test_array.rb b/test/ruby/test_array.rb
index 7b00393..8a44208 100644
--- a/test/ruby/test_array.rb
+++ b/test/ruby/test_array.rb
@@ -1491,6 +1491,11 @@ class TestArray < Test::Unit::TestCase
a = []
a << a
assert_equal("[...]", a.join)
+
+ def (a = Object.new).to_a
+ [self]
+ end
+ assert_equal("[...]", [a].join, , '[ruby-core:24150]')
end
def test_to_a2
diff --git a/test/ruby/test_enum.rb b/test/ruby/test_enum.rb
index e0e77b4..660c593 100644
--- a/test/ruby/test_enum.rb
+++ b/test/ruby/test_enum.rb
@@ -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