diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-05-12 14:15:30 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-05-12 14:15:30 +0000 |
commit | 54c0e4b76e139af4bdc689089a663df53ae12cb2 (patch) | |
tree | 98f20f37b5d86944e750b7652ba9a20970eae03d /test/io/console | |
parent | dd6b923bf83e4026f26f911156a31b180bbb0a32 (diff) | |
download | ruby-54c0e4b76e139af4bdc689089a663df53ae12cb2.tar.gz |
new test file.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27761 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/io/console')
-rw-r--r-- | test/io/console/test_io_console.rb | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/test/io/console/test_io_console.rb b/test/io/console/test_io_console.rb new file mode 100644 index 0000000000..2e46176616 --- /dev/null +++ b/test/io/console/test_io_console.rb @@ -0,0 +1,73 @@ +require 'io/console' +require 'pty' +require 'test/unit' + +class TestIO_Console < Test::Unit::TestCase + def test_raw + PTY.open {|m, s| + s.print "abc\n" + assert_equal("abc\r\n", m.gets) + s.raw { + s.print "def\n" + assert_equal("def\n", m.gets) + } + s.print "ghi\n" + assert_equal("ghi\r\n", m.gets) + } + end + + def test_noecho + PTY.open {|m, s| + assert(s.echo?) + m.print "a\n" + s.print "b\n" + assert_equal("a\r\nb\r\n", m.readpartial(10)) + assert_equal("a\n", s.readpartial(10)) + s.noecho { + assert(!s.echo?) + m.print "a\n" + s.print "b\n" + assert_equal("b\r\n", m.readpartial(10)) + assert_equal("a\n", s.readpartial(10)) + } + assert(s.echo?) + m.print "a\n" + s.print "b\n" + assert_equal("a\r\nb\r\n", m.readpartial(10)) + assert_equal("a\n", s.readpartial(10)) + } + end + + def test_setecho + PTY.open {|m, s| + assert(s.echo?) + m.print "a\n" + s.print "b\n" + assert_equal("a\r\nb\r\n", m.readpartial(10)) + assert_equal("a\n", s.readpartial(10)) + s.echo = false + assert(!s.echo?) + m.print "a\n" + s.print "b\n" + assert_equal("b\r\n", m.readpartial(10)) + assert_equal("a\n", s.readpartial(10)) + s.echo = true + assert(s.echo?) + m.print "a\n" + s.print "b\n" + assert_equal("a\r\nb\r\n", m.readpartial(10)) + assert_equal("a\n", s.readpartial(10)) + } + end + + def test_iflush + PTY.open {|m, s| + m.print "a\n" + s.iflush + m.print "b\n" + assert_equal("a\r\nb\r\n", m.readpartial(10)) + assert_equal("b\n", s.readpartial(10)) + } + end + +end |