[前][次][番号順一覧][スレッド一覧]

ruby-changes:41282

From: nobu <ko1@a...>
Date: Mon, 28 Dec 2015 14:56:16 +0900 (JST)
Subject: [ruby-changes:41282] nobu:r53354 (trunk): Add test for String#rstrip!

nobu	2015-12-28 14:56:00 +0900 (Mon, 28 Dec 2015)

  New Revision: 53354

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=53354

  Log:
    Add test for String#rstrip!
    
    * test/ruby/test_string.rb (TestString#test_rstrip_bang): Add test
      for String#rstrip!.  [Fix GH-1176]

  Modified files:
    trunk/ChangeLog
    trunk/test/ruby/test_string.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 53353)
+++ ChangeLog	(revision 53354)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Mon Dec 28 14:55:57 2015  Kuniaki IGARASHI  <igaiga@g...>
+
+	* 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@g...>
 
 	* test/ruby/test_string.rb (TestString#test_lstrip_bang): Add test
Index: test/ruby/test_string.rb
===================================================================
--- test/ruby/test_string.rb	(revision 53353)
+++ test/ruby/test_string.rb	(revision 53354)
@@ -2142,6 +2142,22 @@ class TestString < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_string.rb#L2142
     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)

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]