Skip to content

Commit

Permalink
* test/ruby/test_io.rb (test_reopen, test_reinitialize): should close
Browse files Browse the repository at this point in the history
  the temporay files.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30206 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
unak committed Dec 14, 2010
1 parent 4d25729 commit d627300
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 12 deletions.
5 changes: 5 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
Tue Dec 14 15:03:46 2010 NAKAMURA Usaku <[email protected]>

* test/ruby/test_io.rb (test_reopen, test_reinitialize): should close
the temporay files.

Tue Dec 14 14:24:15 2010 NAKAMURA Usaku <[email protected]>

* test/ruby/test_io.rb (make_tempfile): change the prefix from 'foo'
Expand Down
36 changes: 24 additions & 12 deletions test/ruby/test_io.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1417,20 +1417,28 @@ def test_reopen
open(__FILE__) do |f|
f.gets
f2 = open(t.path)
f2.gets
assert_nothing_raised {
f.reopen(f2)
assert_equal("bar\n", f.gets, '[ruby-core:24240]')
}
begin
f2.gets
assert_nothing_raised {
f.reopen(f2)
assert_equal("bar\n", f.gets, '[ruby-core:24240]')
}
ensure
f2.close
end
end

open(__FILE__) do |f|
f2 = open(t.path)
f.reopen(f2)
assert_equal("foo\n", f.gets)
assert_equal("bar\n", f.gets)
f.reopen(f2)
assert_equal("baz\n", f.gets, '[ruby-dev:39479]')
begin
f.reopen(f2)
assert_equal("foo\n", f.gets)
assert_equal("bar\n", f.gets)
f.reopen(f2)
assert_equal("baz\n", f.gets, '[ruby-dev:39479]')
ensure
f2.close
end
end
end

Expand Down Expand Up @@ -1587,8 +1595,12 @@ def test_initialize
def test_reinitialize
t = make_tempfile
f = open(t.path)
assert_raise(RuntimeError) do
f.instance_eval { initialize }
begin
assert_raise(RuntimeError) do
f.instance_eval { initialize }
end
ensure
f.close
end
end

Expand Down

0 comments on commit d627300

Please sign in to comment.