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

ruby-changes:45251

From: nobu <ko1@a...>
Date: Sat, 14 Jan 2017 11:06:29 +0900 (JST)
Subject: [ruby-changes:45251] nobu:r57323 (trunk): StringIO.new makes a RW buffer

nobu	2017-01-14 11:06:22 +0900 (Sat, 14 Jan 2017)

  New Revision: 57323

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

  Log:
    StringIO.new makes a RW buffer

  Modified files:
    trunk/test/net/protocol/test_protocol.rb
    trunk/test/open-uri/test_open-uri.rb
    trunk/test/zlib/test_zlib.rb
Index: test/net/protocol/test_protocol.rb
===================================================================
--- test/net/protocol/test_protocol.rb	(revision 57322)
+++ test/net/protocol/test_protocol.rb	(revision 57323)
@@ -6,7 +6,7 @@ require "stringio" https://github.com/ruby/ruby/blob/trunk/test/net/protocol/test_protocol.rb#L6
 class TestProtocol < Test::Unit::TestCase
   def test_should_properly_dot_stuff_period_with_no_endline
     bug9627 = '[ruby-core:61441] [Bug #9627]'
-    sio = StringIO.new("".dup)
+    sio = StringIO.new
     imio = Net::InternetMessageIO.new(sio)
     email = "To: bob@a...\nlook, a period with no endline\n."
     imio.write_message(email)
@@ -15,12 +15,12 @@ class TestProtocol < Test::Unit::TestCas https://github.com/ruby/ruby/blob/trunk/test/net/protocol/test_protocol.rb#L15
 
   def test_each_crlf_line
     assert_output('', '') do
-      sio = StringIO.new("".dup)
+      sio = StringIO.new
       imio = Net::InternetMessageIO.new(sio)
       assert_equal(23, imio.write_message("\u3042\r\u3044\n\u3046\r\n\u3048"))
       assert_equal("\u3042\r\n\u3044\r\n\u3046\r\n\u3048\r\n.\r\n", sio.string)
 
-      sio = StringIO.new("".dup)
+      sio = StringIO.new
       imio = Net::InternetMessageIO.new(sio)
       assert_equal(8, imio.write_message("\u3042\r"))
       assert_equal("\u3042\r\n.\r\n", sio.string)
Index: test/zlib/test_zlib.rb
===================================================================
--- test/zlib/test_zlib.rb	(revision 57322)
+++ test/zlib/test_zlib.rb	(revision 57323)
@@ -1,5 +1,5 @@ https://github.com/ruby/ruby/blob/trunk/test/zlib/test_zlib.rb#L1
 # coding: us-ascii
-# frozen_string_literal: false
+# frozen_string_literal: true
 require 'test/unit'
 require 'stringio'
 require 'tempfile'
@@ -42,7 +42,7 @@ if defined? Zlib https://github.com/ruby/ruby/blob/trunk/test/zlib/test_zlib.rb#L42
     end
 
     def test_deflate_chunked
-      original = ''
+      original = String.new
       chunks = []
       r = Random.new 0
 
@@ -315,7 +315,7 @@ if defined? Zlib https://github.com/ruby/ruby/blob/trunk/test/zlib/test_zlib.rb#L315
 
       z = Zlib::Inflate.new
 
-      inflated = ""
+      inflated = String.new
 
       deflated.each_char do |byte|
         inflated << z.inflate(byte)
@@ -603,14 +603,13 @@ if defined? Zlib https://github.com/ruby/ruby/blob/trunk/test/zlib/test_zlib.rb#L603
           assert_equal(t.path, f.path)
         end
 
-        s = ""
-        sio = StringIO.new(s)
+        sio = StringIO.new
         gz = Zlib::GzipWriter.new(sio)
         gz.print("foo")
         assert_raise(NoMethodError) { gz.path }
         gz.close
 
-        sio = StringIO.new(s)
+        sio = StringIO.new(sio.string)
         Zlib::GzipReader.new(sio) do |f|
           assert_raise(NoMethodError) { f.path }
         end
@@ -625,11 +624,11 @@ if defined? Zlib https://github.com/ruby/ruby/blob/trunk/test/zlib/test_zlib.rb#L624
     end
 
     def test_ungetc
-      s = ""
-      w = Zlib::GzipWriter.new(StringIO.new(s))
+      sio = StringIO.new
+      w = Zlib::GzipWriter.new(sio)
       w << (1...1000).to_a.inspect
       w.close
-      r = Zlib::GzipReader.new(StringIO.new(s))
+      r = Zlib::GzipReader.new(StringIO.new(sio.string))
       r.read(100)
       r.ungetc ?a
       assert_nothing_raised("[ruby-dev:24060]") {
@@ -640,11 +639,11 @@ if defined? Zlib https://github.com/ruby/ruby/blob/trunk/test/zlib/test_zlib.rb#L639
     end
 
     def test_ungetc_paragraph
-      s = ""
-      w = Zlib::GzipWriter.new(StringIO.new(s))
+      sio = StringIO.new
+      w = Zlib::GzipWriter.new(sio)
       w << "abc"
       w.close
-      r = Zlib::GzipReader.new(StringIO.new(s))
+      r = Zlib::GzipReader.new(StringIO.new(sio.string))
       r.ungetc ?\n
       assert_equal("abc", r.gets(""))
       assert_nothing_raised("[ruby-dev:24065]") {
@@ -778,7 +777,7 @@ if defined? Zlib https://github.com/ruby/ruby/blob/trunk/test/zlib/test_zlib.rb#L777
         end
 
         Zlib::GzipReader.open(t.path) do |f|
-          s = ""
+          s = String.new
           f.readpartial(3, s)
           assert("foo".start_with?(s))
 
@@ -938,7 +937,9 @@ if defined? Zlib https://github.com/ruby/ruby/blob/trunk/test/zlib/test_zlib.rb#L937
     end
 
     def test_corrupted_header
-      gz = Zlib::GzipWriter.new(StringIO.new(s = ""))
+      sio = StringIO.new
+      s = sio.string
+      gz = Zlib::GzipWriter.new(sio)
       gz.orig_name = "X"
       gz.comment = "Y"
       gz.print("foo")
@@ -1120,7 +1121,7 @@ if defined? Zlib https://github.com/ruby/ruby/blob/trunk/test/zlib/test_zlib.rb#L1121
     def test_deflate_stream
       r = Random.new 0
 
-      deflated = ''
+      deflated = String.new
 
       Zlib.deflate(r.bytes(20000)) do |chunk|
         deflated << chunk
Index: test/open-uri/test_open-uri.rb
===================================================================
--- test/open-uri/test_open-uri.rb	(revision 57322)
+++ test/open-uri/test_open-uri.rb	(revision 57323)
@@ -246,7 +246,7 @@ class TestOpenURI < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/open-uri/test_open-uri.rb#L246
 
   def test_proxy
     with_http {|srv, dr, url|
-      proxy_log = StringIO.new(''.dup)
+      proxy_log = StringIO.new
       proxy_logger = WEBrick::Log.new(proxy_log, WEBrick::BasicLog::WARN)
       proxy_auth_log = ''.dup
       proxy = WEBrick::HTTPProxyServer.new({
@@ -300,7 +300,7 @@ class TestOpenURI < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/open-uri/test_open-uri.rb#L300
 
   def test_proxy_http_basic_authentication_failure
     with_http {|srv, dr, url|
-      proxy_log = StringIO.new(''.dup)
+      proxy_log = StringIO.new
       proxy_logger = WEBrick::Log.new(proxy_log, WEBrick::BasicLog::WARN)
       proxy_auth_log = ''.dup
       proxy = WEBrick::HTTPProxyServer.new({
@@ -333,7 +333,7 @@ class TestOpenURI < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/open-uri/test_open-uri.rb#L333
 
   def test_proxy_http_basic_authentication_success
     with_http {|srv, dr, url|
-      proxy_log = StringIO.new(''.dup)
+      proxy_log = StringIO.new
       proxy_logger = WEBrick::Log.new(proxy_log, WEBrick::BasicLog::WARN)
       proxy_auth_log = ''.dup
       proxy = WEBrick::HTTPProxyServer.new({
@@ -374,7 +374,7 @@ class TestOpenURI < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/open-uri/test_open-uri.rb#L374
 
   def test_authenticated_proxy_http_basic_authentication_success
     with_http {|srv, dr, url|
-      proxy_log = StringIO.new(''.dup)
+      proxy_log = StringIO.new
       proxy_logger = WEBrick::Log.new(proxy_log, WEBrick::BasicLog::WARN)
       proxy_auth_log = ''.dup
       proxy = WEBrick::HTTPProxyServer.new({

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

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