diff options
| author | shugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2005-09-22 07:44:32 +0000 |
|---|---|---|
| committer | shugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2005-09-22 07:44:32 +0000 |
| commit | a13fa65fc7bf7c7f2b6a609dbbe1790b2d83ef65 (patch) | |
| tree | e4da271808a3e88093808d98d6c57c83427c2f55 /test | |
| parent | c79ccf933d7ffa303ee5f4af2727830b59baa838 (diff) | |
| download | ruby-a13fa65fc7bf7c7f2b6a609dbbe1790b2d83ef65.tar.gz ruby-a13fa65fc7bf7c7f2b6a609dbbe1790b2d83ef65.tar.xz ruby-a13fa65fc7bf7c7f2b6a609dbbe1790b2d83ef65.zip | |
* test/readline/test_readline.rb (TestReadline::replace_stdio):
merged the patch of [ruby-dev:25232] instead of [ruby-dev:25223].
git-svn-id: http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_8@9269 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
| -rw-r--r-- | test/readline/test_readline.rb | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/test/readline/test_readline.rb b/test/readline/test_readline.rb index ac2966b48..edc3aa09b 100644 --- a/test/readline/test_readline.rb +++ b/test/readline/test_readline.rb @@ -62,19 +62,22 @@ class TestReadline < Test::Unit::TestCase private def replace_stdio(stdin_path, stdout_path) - STDIN.seek(0, File::SEEK_SET) rescue nil - orig_stdin = STDIN.dup - orig_stdout = STDOUT.dup - STDIN.reopen(stdin_path, "r") - STDOUT.reopen(stdout_path, "w") - begin - yield - ensure - STDIN.reopen(orig_stdin) - STDOUT.reopen(orig_stdout) - orig_stdin.close - orig_stdout.close - end + open(stdin_path, "r"){|stdin| + open(stdout_path, "w"){|stdout| + orig_stdin = STDIN.dup + orig_stdout = STDOUT.dup + STDIN.reopen(stdin) + STDOUT.reopen(stdout) + begin + yield + ensure + STDIN.reopen(orig_stdin) + STDOUT.reopen(orig_stdout) + orig_stdin.close + orig_stdout.close + end + } + } end end |
