From 2eb5e09ea5115ecba93efa38b0662eb28d657c1d Mon Sep 17 00:00:00 2001 From: nobu Date: Mon, 28 Dec 2015 05:56:00 +0000 Subject: 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 --- test/ruby/test_string.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to '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) -- cgit v1.2.3