summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--test/zlib/test_zlib.rb24
1 files changed, 13 insertions, 11 deletions
diff --git a/test/zlib/test_zlib.rb b/test/zlib/test_zlib.rb
index 42ee5c6638..e6d61ca79f 100644
--- a/test/zlib/test_zlib.rb
+++ b/test/zlib/test_zlib.rb
@@ -510,22 +510,24 @@ if defined? Zlib
gz = Zlib::GzipWriter.new(t)
gz.print("foo")
gz.close
- t = File.open(t.path, 'ab')
- gz = Zlib::GzipWriter.new(t)
- gz.print("bar")
- gz.close
+ File.open(t.path, 'ab') do |f|
+ gz = Zlib::GzipWriter.new(f)
+ gz.print("bar")
+ gz.close
+ end
results = []
- t = File.open(t.path, 'rb')
- Zlib::GzipReader.zcat(t) do |str|
- results << str
+ File.open(t.path, 'rb') do |f|
+ Zlib::GzipReader.zcat(f) do |str|
+ results << str
+ end
end
assert_equal(["foo", "bar"], results)
- t.close
- t = File.open(t.path, 'rb')
- assert_equal("foobar", Zlib::GzipReader.zcat(t))
- t.close
+ results = File.open(t.path, 'rb') do |f|
+ Zlib::GzipReader.zcat(f)
+ end
+ assert_equal("foobar", results)
}
end