summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorshugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-05-25 13:01:56 +0000
committershugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-05-25 13:01:56 +0000
commit01ad1e82b507c27563592145bf32e9a56b3741f0 (patch)
tree091f8d3f6e1eb2ef15329f43f20cb8d6710929c7 /test
parent9130381a8c65c3465e7bebbf9d2f04d714dc6e2c (diff)
* ext/readline/readline.c: supported libedit. (backported from HEAD)
* ext/readline/extconf.rb: ditto. * test/readline/test_readline.rb: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@8522 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/readline/test_readline.rb55
1 files changed, 29 insertions, 26 deletions
diff --git a/test/readline/test_readline.rb b/test/readline/test_readline.rb
index b2c83b4..3041683 100644
--- a/test/readline/test_readline.rb
+++ b/test/readline/test_readline.rb
@@ -3,7 +3,7 @@ begin
rescue LoadError
end
-if defined?(Readline)
+if defined?(Readline) && !/EditLine/n.match(Readline::VERSION)
require "test/unit"
require "tempfile"
@@ -16,11 +16,15 @@ class TestReadline < Test::Unit::TestCase
stdin.write("hello\n")
stdin.close
stdout.close
- line = replace_stdio(stdin.path, stdout.path) { Readline.readline("> ") }
+ line = replace_stdio(stdin.path, stdout.path) {
+ Readline.readline("> ", true)
+ }
assert_equal("hello", line)
assert_equal(true, line.tainted?)
stdout.open
assert_equal("> ", stdout.read(2))
+ assert_equal(1, Readline::HISTORY.length)
+ assert_equal("hello", Readline::HISTORY[0])
assert_raises(SecurityError) do
Thread.start {
$SAFE = 1
@@ -42,35 +46,34 @@ class TestReadline < Test::Unit::TestCase
end
def test_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)
+ begin
+ 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)
+ rescue NotImplementedError
+ end
end
private
def replace_stdio(stdin_path, stdout_path)
- 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
- }
- }
+ 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
end
end