mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* test/readline/test_readline.rb: fix for NetBSD.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7437 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
fc0fcec74e
commit
c741090753
2 changed files with 22 additions and 11 deletions
|
@ -1,3 +1,7 @@
|
||||||
|
Thu Dec 2 10:45:02 2004 Shugo Maeda <shugo@ruby-lang.org>
|
||||||
|
|
||||||
|
* test/readline/test_readline.rb: fix for NetBSD.
|
||||||
|
|
||||||
Thu Dec 2 09:30:58 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Thu Dec 2 09:30:58 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* eval.c (thread_mark): mark thread group. [ruby-dev:25020]
|
* eval.c (thread_mark): mark thread group. [ruby-dev:25020]
|
||||||
|
|
|
@ -14,24 +14,27 @@ class TestReadline < Test::Unit::TestCase
|
||||||
stdout = Tempfile.new("test_readline_stdout")
|
stdout = Tempfile.new("test_readline_stdout")
|
||||||
begin
|
begin
|
||||||
stdin.write("hello\n")
|
stdin.write("hello\n")
|
||||||
stdin.rewind
|
stdin.close
|
||||||
line = replace_stdio(stdin, stdout) { Readline.readline("> ") }
|
stdout.close
|
||||||
|
line = replace_stdio(stdin.path, stdout.path) { Readline.readline("> ") }
|
||||||
assert_equal("hello", line)
|
assert_equal("hello", line)
|
||||||
assert_equal(true, line.tainted?)
|
assert_equal(true, line.tainted?)
|
||||||
|
stdout.open
|
||||||
|
assert_equal("> ", stdout.read(2))
|
||||||
assert_raises(SecurityError) do
|
assert_raises(SecurityError) do
|
||||||
Thread.start {
|
Thread.start {
|
||||||
$SAFE = 1
|
$SAFE = 1
|
||||||
replace_stdio(stdin, stdout) { Readline.readline("> ".taint) }
|
replace_stdio(stdin.path, stdout.path) do
|
||||||
|
Readline.readline("> ".taint)
|
||||||
|
end
|
||||||
}.join
|
}.join
|
||||||
end
|
end
|
||||||
assert_raises(SecurityError) do
|
assert_raises(SecurityError) do
|
||||||
Thread.start {
|
Thread.start {
|
||||||
$SAFE = 4
|
$SAFE = 4
|
||||||
replace_stdio(stdin, stdout) { Readline.readline("> ") }
|
replace_stdio(stdin.path, stdout.path) { Readline.readline("> ") }
|
||||||
}.join
|
}.join
|
||||||
end
|
end
|
||||||
stdout.rewind
|
|
||||||
assert_equal("> ", stdout.read(2))
|
|
||||||
ensure
|
ensure
|
||||||
stdin.close(true)
|
stdin.close(true)
|
||||||
stdout.close(true)
|
stdout.close(true)
|
||||||
|
@ -39,26 +42,30 @@ class TestReadline < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_completion_append_character
|
def test_completion_append_character
|
||||||
Readline.completion_append_character = nil
|
|
||||||
assert_equal(nil, Readline.completion_append_character)
|
|
||||||
Readline.completion_append_character = "x"
|
Readline.completion_append_character = "x"
|
||||||
assert_equal("x", Readline.completion_append_character)
|
assert_equal("x", Readline.completion_append_character)
|
||||||
Readline.completion_append_character = "xyz"
|
Readline.completion_append_character = "xyz"
|
||||||
assert_equal("x", Readline.completion_append_character)
|
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
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def replace_stdio(stdin, stdout)
|
def replace_stdio(stdin_path, stdout_path)
|
||||||
orig_stdin = STDIN.dup
|
orig_stdin = STDIN.dup
|
||||||
orig_stdout = STDOUT.dup
|
orig_stdout = STDOUT.dup
|
||||||
STDIN.reopen(stdin)
|
STDIN.reopen(stdin_path, "r")
|
||||||
STDOUT.reopen(stdout)
|
STDOUT.reopen(stdout_path, "w")
|
||||||
begin
|
begin
|
||||||
yield
|
yield
|
||||||
ensure
|
ensure
|
||||||
STDIN.reopen(orig_stdin)
|
STDIN.reopen(orig_stdin)
|
||||||
STDOUT.reopen(orig_stdout)
|
STDOUT.reopen(orig_stdout)
|
||||||
|
orig_stdin.close
|
||||||
|
orig_stdout.close
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue