mirror of
https://github.com/ruby/ruby.git
synced 2025-08-28 15:36:16 +02:00
* string.c (rb_str_prepend): new method by Sora Harakami
[Feature #3765] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29120 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
0cfe185f39
commit
cff3c3d52a
3 changed files with 42 additions and 0 deletions
|
@ -1882,4 +1882,20 @@ class TestString < Test::Unit::TestCase
|
|||
assert_equal('"\\u3042\\u3044\\u3046"', "\u3042\u3044\u3046".encode(e).inspect)
|
||||
end
|
||||
end
|
||||
|
||||
def test_prepend
|
||||
assert_equal(S("hello world!"), "world!".prepend("hello "))
|
||||
|
||||
foo = Object.new
|
||||
def foo.to_str
|
||||
"b"
|
||||
end
|
||||
assert_equal(S("ba"), "a".prepend(foo))
|
||||
|
||||
a = S("world")
|
||||
b = S("hello ")
|
||||
a.prepend(b)
|
||||
assert_equal(S("hello world"), a)
|
||||
assert_equal(S("hello "), b)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue