mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* enum.c (rb_enum_join): non-nil separator must be convertible to
String. [ruby-core:24172] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23979 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
9041ac4289
commit
e895bc3cdb
3 changed files with 15 additions and 0 deletions
|
@ -285,8 +285,15 @@ class TestEnumerable < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
def test_join
|
||||
ofs = $,
|
||||
assert_equal("abc", ("a".."c").join(""))
|
||||
assert_equal("a-b-c", ("a".."c").join("-"))
|
||||
$, = "-"
|
||||
assert_equal("a-b-c", ("a".."c").join())
|
||||
$, = nil
|
||||
assert_equal("abc", ("a".."c").join())
|
||||
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"
|
||||
|
@ -296,5 +303,7 @@ class TestEnumerable < Test::Unit::TestCase
|
|||
end
|
||||
end
|
||||
assert_equal("e", e.join(""))
|
||||
ensure
|
||||
$, = ofs
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue