diff options
author | shugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-12-02 01:54:13 +0000 |
---|---|---|
committer | shugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-12-02 01:54:13 +0000 |
commit | 7a3b2fe531e71ab035226f469ff3a659a6687438 (patch) | |
tree | 407e20658ef1e83b3b581109b896a5ddc66e4524 /test | |
parent | 120a473f4f1a5146e4e49db1a61f2854d609df03 (diff) | |
download | ruby-7a3b2fe531e71ab035226f469ff3a659a6687438.tar.gz ruby-7a3b2fe531e71ab035226f469ff3a659a6687438.tar.xz ruby-7a3b2fe531e71ab035226f469ff3a659a6687438.zip |
* test/readline/test_readline.rb: fix for NetBSD.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@7437 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/readline/test_readline.rb | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/test/readline/test_readline.rb b/test/readline/test_readline.rb index 80c007c06..e7093f7bd 100644 --- a/test/readline/test_readline.rb +++ b/test/readline/test_readline.rb @@ -14,24 +14,27 @@ class TestReadline < Test::Unit::TestCase stdout = Tempfile.new("test_readline_stdout") begin stdin.write("hello\n") - stdin.rewind - line = replace_stdio(stdin, stdout) { Readline.readline("> ") } + stdin.close + stdout.close + line = replace_stdio(stdin.path, stdout.path) { Readline.readline("> ") } assert_equal("hello", line) assert_equal(true, line.tainted?) + stdout.open + assert_equal("> ", stdout.read(2)) assert_raises(SecurityError) do Thread.start { $SAFE = 1 - replace_stdio(stdin, stdout) { Readline.readline("> ".taint) } + replace_stdio(stdin.path, stdout.path) do + Readline.readline("> ".taint) + end }.join end assert_raises(SecurityError) do Thread.start { $SAFE = 4 - replace_stdio(stdin, stdout) { Readline.readline("> ") } + replace_stdio(stdin.path, stdout.path) { Readline.readline("> ") } }.join end - stdout.rewind - assert_equal("> ", stdout.read(2)) ensure stdin.close(true) stdout.close(true) @@ -39,26 +42,30 @@ class TestReadline < Test::Unit::TestCase end def test_completion_append_character - Readline.completion_append_character = nil - assert_equal(nil, Readline.completion_append_character) Readline.completion_append_character = "x" assert_equal("x", Readline.completion_append_character) Readline.completion_append_character = "xyz" assert_equal("x", Readline.completion_append_character) + Readline.completion_append_character = nil + assert_equal(nil, Readline.completion_append_character) + Readline.completion_append_character = "" + assert_equal(nil, Readline.completion_append_character) end private - def replace_stdio(stdin, stdout) + def replace_stdio(stdin_path, stdout_path) orig_stdin = STDIN.dup orig_stdout = STDOUT.dup - STDIN.reopen(stdin) - STDOUT.reopen(stdout) + 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 end end |