File tree Expand file tree Collapse file tree 1 file changed +22
-8
lines changed Expand file tree Collapse file tree 1 file changed +22
-8
lines changed Original file line number Diff line number Diff line change @@ -45,13 +45,27 @@ def test_attr_methods
4545
4646 def test_sync_close_without_connect
4747 require 'socket'
48- Socket . open ( :INET , :STREAM ) do |socket |
49- assert ! socket . closed?
50- ssl = OpenSSL ::SSL ::SSLSocket . new ( socket )
51- ssl . sync_close = true
52- assert ! ssl . closed?
53- ssl . close
54- assert socket . closed?
48+ if RUBY_VERSION > '2.2'
49+ Socket . open ( :INET , :STREAM ) do |socket |
50+ assert ! socket . closed?
51+ ssl = OpenSSL ::SSL ::SSLSocket . new ( socket )
52+ ssl . sync_close = true
53+ assert ! ssl . closed?
54+ ssl . close
55+ assert socket . closed?
56+ end
57+ else
58+ begin
59+ socket = Socket . new :INET , :STREAM
60+ assert ! socket . closed?
61+ ssl = OpenSSL ::SSL ::SSLSocket . new ( socket )
62+ ssl . sync_close = true
63+ assert ! ssl . closed?
64+ ssl . close
65+ assert socket . closed?
66+ ensure
67+ socket && socket . close rescue nil
68+ end
5569 end
5670 end
5771
@@ -69,6 +83,6 @@ def test_ssl_sysread_blocking_error
6983 assert_equal "abc\n " , buf
7084 end
7185 end
72- end if RUBY_VERSION > '2.0 '
86+ end if RUBY_VERSION > '2.2 '
7387
7488end
You can’t perform that action at this time.
0 commit comments