From 2eb5e09ea5115ecba93efa38b0662eb28d657c1d Mon Sep 17 00:00:00 2001 From: nobu Date: Mon, 28 Dec 2015 05:56:00 +0000 Subject: [PATCH] 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 --- ChangeLog | 5 +++++ test/ruby/test_string.rb | 16 ++++++++++++++++ 2 files changed, 21 insertions(+) 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 + + * 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 * 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)