diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-01-31 21:39:00 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-01-31 21:39:00 +0000 |
commit | 0470ce53c5f055a7c5e26f8e7c5ab753820c0950 (patch) | |
tree | ae3cb4ec8b8fcfda3865726863ea4b85c23a8d43 /test | |
parent | a42cc41ba1abacd37e1922965fae641e537a6b5f (diff) | |
download | ruby-0470ce53c5f055a7c5e26f8e7c5ab753820c0950.tar.gz |
* io.c (argf_close): skip stdin, which should be readable again.
[ruby-dev:45160] [Bug #5952]
* io.c (argf_readlines): reinitialize after all read to be
readable again.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34409 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_argf.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/test/ruby/test_argf.rb b/test/ruby/test_argf.rb index a588e07fcb..fe7603490b 100644 --- a/test/ruby/test_argf.rb +++ b/test/ruby/test_argf.rb @@ -741,4 +741,24 @@ class TestArgf < Test::Unit::TestCase end assert_nil(argf.gets, bug4274) end + + def test_readlines_twice + bug5952 = '[ruby-dev:45160]' + assert_ruby_status(["-e", "2.times {STDIN.tty?; readlines}"], "", bug5952) + end + + def test_readlines_twice_tty + bug5952 = '[ruby-dev:45160]' + require 'io/console' + require 'pty' + rescue LoadError + skip $! + else + lines = nil + PTY.spawn(EnvUtil.rubybin, "-e", "2.times{STDIN.tty?; p readlines}") do |slave, master, pid| + master.write("foo\n\C-d""bar\n\C-d") + lines = slave.readlines + end + assert_equal('["bar\n"]', lines.last.chomp, bug5952) + end end |