ruby-changes:19074
From: drbrain <ko1@a...>
Date: Wed, 16 Mar 2011 15:07:12 +0900 (JST)
Subject: [ruby-changes:19074] Ruby:r31113 (trunk): * ext/openssl/lib/openssl/buffering.rb (module OpenSSL): #flush should
drbrain 2011-03-16 15:07:03 +0900 (Wed, 16 Mar 2011) New Revision: 31113 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=31113 Log: * ext/openssl/lib/openssl/buffering.rb (module OpenSSL): #flush should not change sync mode on exception. * test/openssl/test_buffering.rb: added Added files: trunk/test/openssl/test_buffering.rb Modified files: trunk/ChangeLog trunk/ext/openssl/lib/openssl/buffering.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 31112) +++ ChangeLog (revision 31113) @@ -1,3 +1,9 @@ +Wed Mar 16 15:06:21 2011 Eric Hodel <drbrain@s...> + + * ext/openssl/lib/openssl/buffering.rb (module OpenSSL): #flush should + not change sync mode on exception. + * test/openssl/test_buffering.rb: added + Wed Mar 16 13:45:28 2011 Eric Hodel <drbrain@s...> * ext/openss/lib/openssl/bufering.rb: de-nest Buffering module Index: ext/openssl/lib/openssl/buffering.rb =================================================================== --- ext/openssl/lib/openssl/buffering.rb (revision 31112) +++ ext/openssl/lib/openssl/buffering.rb (revision 31113) @@ -436,6 +436,8 @@ osync = @sync @sync = true do_write "" + return self + ensure @sync = osync end Index: test/openssl/test_buffering.rb =================================================================== --- test/openssl/test_buffering.rb (revision 0) +++ test/openssl/test_buffering.rb (revision 31113) @@ -0,0 +1,66 @@ +require_relative 'utils' +require 'stringio' +require 'minitest/unit' + +class OpenSSL::TestBuffering < MiniTest::Unit::TestCase + + class IO + include OpenSSL::Buffering + + attr_accessor :sync + + def initialize + @io = StringIO.new + + super + + @sync = false + end + + def string + @io.string + end + + def sysread *a + @io.sysread *a + end + + def syswrite *a + @io.syswrite *a + end + end + + def setup + @io = IO.new + end + + def test_flush + @io.write 'a' + + refute @io.sync + assert_empty @io.string + + assert_equal @io, @io.flush + + refute @io.sync + assert_equal 'a', @io.string + end + + def test_flush_error + @io.write 'a' + + refute @io.sync + assert_empty @io.string + + def @io.syswrite *a + raise SystemCallError, 'fail' + end + + assert_raises SystemCallError do + @io.flush + end + + refute @io.sync, 'sync must not change' + end + +end if defined?(OpenSSL) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/