summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-12-28 05:56:00 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-12-28 05:56:00 +0000
commit2eb5e09ea5115ecba93efa38b0662eb28d657c1d (patch)
tree3b0e49050154776b836f09a62e8f5072d56d524e
parent4ab3c75bc51508db632de4050ea983a9be0309a1 (diff)
Add test for String#rstrip!
* test/ruby/test_string.rb (TestString#test_rstrip_bang): Add test for String#rstrip!. [Fix GH-1176] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53354 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--test/ruby/test_string.rb16
2 files changed, 21 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 1f7c917979..2473b156f5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Mon Dec 28 14:55:57 2015 Kuniaki IGARASHI <igaiga@gmail.com>
+
+ * test/ruby/test_string.rb (TestString#test_rstrip_bang): Add test
+ for String#rstrip!. [Fix GH-1176]
+
Mon Dec 28 09:18:53 2015 Kuniaki IGARASHI <igaiga@gmail.com>
* test/ruby/test_string.rb (TestString#test_lstrip_bang): Add test
diff --git a/test/ruby/test_string.rb b/test/ruby/test_string.rb
index 778a817fdc..00e1f5f8ff 100644
--- a/test/ruby/test_string.rb
+++ b/test/ruby/test_string.rb
@@ -2142,6 +2142,22 @@ class TestString < Test::Unit::TestCase
assert_raise(Encoding::CompatibilityError) { "\u3042".encode("ISO-2022-JP").rstrip }
end
+ def test_rstrip_bang
+ s1 = S(" hello ")
+ assert_equal(" hello", s1.rstrip!)
+ assert_equal(" hello", s1)
+
+ s2 = S("\u3042 ")
+ assert_equal("\u3042", s2.rstrip!)
+ assert_equal("\u3042", s2)
+
+ s3 = S(" \u3042")
+ assert_equal(nil, s3.rstrip!)
+ assert_equal(" \u3042", s3)
+
+ assert_raise(Encoding::CompatibilityError) { "\u3042".encode("ISO-2022-JP").rstrip! }
+ end
+
def test_lstrip
assert_equal("hello ", " hello ".lstrip)
assert_equal("\u3042", " \u3042".lstrip)