summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/lib/minitest/unit.rb12
-rw-r--r--test/ruby/test_io.rb7
2 files changed, 13 insertions, 6 deletions
diff --git a/test/lib/minitest/unit.rb b/test/lib/minitest/unit.rb
index 2516034..5847da7 100644
--- a/test/lib/minitest/unit.rb
+++ b/test/lib/minitest/unit.rb
@@ -1009,19 +1009,20 @@ module MiniTest
h = {}
ObjectSpace.each_object(IO) {|io|
begin
+ autoclose = io.autoclose?
fd = io.fileno
rescue IOError # closed IO object
next
end
- (h[fd] ||= []) << io
+ (h[fd] ||= []) << [io, autoclose]
}
fd_leaked.each {|fd|
str = ''
if h[fd]
str << ' :'
- h[fd].map {|io|
+ h[fd].map {|io, autoclose|
s = ' ' + io.inspect
- s << "(not-autoclose)" if !io.autoclose?
+ s << "(not-autoclose)" if !autoclose
s
}.each {|s|
str << s
@@ -1029,9 +1030,8 @@ module MiniTest
end
puts "Leaked file descriptor: #{name}: #{fd}#{str}"
}
- h.each {|fd, ios|
- next if ios.length <= 1
- list = ios.map {|io| [io, io.autoclose?] }
+ h.each {|fd, list|
+ next if list.length <= 1
if 1 < list.count {|io, autoclose| autoclose }
str = list.map {|io, autoclose| " #{io.inspect}" + (autoclose ? "(autoclose)" : "") }.sort.join
puts "Multiple autoclose IO object for a file descriptor:#{str}"
diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb
index 0d5671a..4cfd873 100644
--- a/test/ruby/test_io.rb
+++ b/test/ruby/test_io.rb
@@ -2796,6 +2796,13 @@ End
end
end
+ def test_frozen_autoclose
+ with_pipe do |r,w|
+ fd = r.fileno
+ assert_equal(true, r.freeze.autoclose?)
+ end
+ end
+
def test_sysread_locktmp
bug6099 = '[ruby-dev:45297]'
buf = " " * 100