summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorshyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-08-27 07:33:19 +0000
committershyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-08-27 07:33:19 +0000
commitcff3c3d52a5406a61be62c81fc6101c4d514731f (patch)
treeede61c893f7d31c2e2f4f452913b39cfd2a48ceb /test
parent0cfe185f39d575f9c620bd14707a81bd5c29fe11 (diff)
* 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
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_string.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/test/ruby/test_string.rb b/test/ruby/test_string.rb
index 02271cefe6..6fc3167f45 100644
--- a/test/ruby/test_string.rb
+++ b/test/ruby/test_string.rb
@@ -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