diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_rubyoptions.rb | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/test/ruby/test_rubyoptions.rb b/test/ruby/test_rubyoptions.rb index 5befa465a3..faa7c5a9df 100644 --- a/test/ruby/test_rubyoptions.rb +++ b/test/ruby/test_rubyoptions.rb @@ -421,4 +421,28 @@ class TestRubyOptions < Test::Unit::TestCase assert_in_out_err(["-we", "a=1"], "", [], ["-e:1: warning: assigned but unused variable - a"], feature3446) assert_in_out_err(["-we", "1.times do\n a=1\nend"], "", [], ["-e:2: warning: assigned but unused variable - a"], feature3446) end + + def test_script_from_stdin + begin + require 'pty' + require 'io/console' + rescue LoadError + return + end + require 'timeout' + result = nil + PTY.spawn(EnvUtil.rubybin) do |s, m| + m.print("\C-d") + assert_nothing_raised('[ruby-dev:37798]') do + Timeout.timeout(3) {s.read} + end + end + PTY.spawn(EnvUtil.rubybin) do |s, m| + m.print("$stdin.read; p $stdin.gets\n\C-d") + m.print("abc\n\C-d") + m.print("zzz\n") + result = s.read + end + assert_match(/zzz\r\n"zzz\\n"\r\n\z/, result, '[ruby-core:30910]') + end end |