diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-04-20 23:03:52 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-04-20 23:03:52 +0000 |
commit | 8f671120f1d99b47f28d67183855d634d006389a (patch) | |
tree | 5a6a943efb8bfb690d7cf5a5f05d2aa701d114ac /test/readline/test_readline.rb | |
parent | 65261bda4d964c081fc3a510bfaa094a7647e8bc (diff) | |
download | ruby-8f671120f1d99b47f28d67183855d634d006389a.tar.gz |
* test/csv/test_features.rb, test/logger/test_logger.rb
test/mkmf/test_have_macro.rb, test/net/http/test_http.rb,
test/openssl/test_config.rb, test/psych/test_encoding.rb,
test/psych/test_exception.rb, test/psych/test_psych.rb,
test/psych/test_tainted.rb, test/readline/test_readline.rb,
test/rexml/test_contrib.rb, test/ruby/test_autoload.rb,
test/ruby/test_beginendblock.rb, test/ruby/test_exception.rb,
test/ruby/test_file.rb, test/ruby/test_io.rb,
test/ruby/test_marshal.rb, test/ruby/test_process.rb,
test/ruby/test_require.rb, test/ruby/test_rubyoptions.rb,
test/syslog/test_syslog_logger.rb, test/webrick/test_httpauth.rb,
test/zlib/test_zlib.rb: Use Tempfile.create.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40400 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/readline/test_readline.rb')
-rw-r--r-- | test/readline/test_readline.rb | 65 |
1 files changed, 31 insertions, 34 deletions
diff --git a/test/readline/test_readline.rb b/test/readline/test_readline.rb index 88ad10195b..a4c8e581a3 100644 --- a/test/readline/test_readline.rb +++ b/test/readline/test_readline.rb @@ -72,13 +72,13 @@ class TestReadline < Test::Unit::TestCase with_temp_stdio do |stdin, stdout| stdin.write("hello\n") stdin.close - stdout.close + stdout.flush line = replace_stdio(stdin.path, stdout.path) { Readline.readline("> ", true) } assert_equal("hello", line) assert_equal(true, line.tainted?) - stdout.open + stdout.rewind assert_equal("> ", stdout.read(2)) assert_equal(1, Readline::HISTORY.length) assert_equal("hello", Readline::HISTORY[0]) @@ -118,8 +118,8 @@ class TestReadline < Test::Unit::TestCase actual_point = Readline.point actual_line_buffer = Readline.line_buffer stdin.write(" finish\n") - stdin.close - stdout.close + stdin.flush + stdout.flush return ["complete"] } @@ -137,8 +137,8 @@ class TestReadline < Test::Unit::TestCase assert_equal(true, Readline.line_buffer.tainted?) assert_equal(22, Readline.point) - stdin.open - stdout.open + stdin.rewind + stdout.rewind stdin.write("first second\t") stdin.flush @@ -377,31 +377,29 @@ class TestReadline < Test::Unit::TestCase end if !/EditLine/n.match(Readline::VERSION) def test_modify_text_in_pre_input_hook - begin - stdin = Tempfile.new("readline_redisplay_stdin") - stdout = Tempfile.new("readline_redisplay_stdout") - stdin.write("world\n") - stdin.close - Readline.pre_input_hook = proc do - assert_equal("", Readline.line_buffer) - Readline.insert_text("hello ") - Readline.redisplay - end - replace_stdio(stdin.path, stdout.path) do - line = Readline.readline("> ") - assert_equal("hello world", line) - end - assert_equal("> hello world\n", stdout.read) - stdout.close - rescue NotImplementedError - ensure + with_temp_stdio {|stdin, stdout| begin - Readline.pre_input_hook = nil + stdin.write("world\n") + stdin.close + Readline.pre_input_hook = proc do + assert_equal("", Readline.line_buffer) + Readline.insert_text("hello ") + Readline.redisplay + end + replace_stdio(stdin.path, stdout.path) do + line = Readline.readline("> ") + assert_equal("hello world", line) + end + assert_equal("> hello world\n", stdout.read) + stdout.close rescue NotImplementedError + ensure + begin + Readline.pre_input_hook = nil + rescue NotImplementedError + end end - stdin.close(true) - stdout.close(true) - end + } end if !/EditLine|\A4\.3\z/n.match(Readline::VERSION) def test_input_metachar @@ -472,12 +470,11 @@ class TestReadline < Test::Unit::TestCase end def with_temp_stdio - stdin = Tempfile.new("test_readline_stdin") - stdout = Tempfile.new("test_readline_stdout") - yield stdin, stdout - ensure - stdin.close(true) if stdin - stdout.close(true) if stdout + Tempfile.create("test_readline_stdin") {|stdin| + Tempfile.create("test_readline_stdout") {|stdout| + yield stdin, stdout + } + } end def with_pipe |