ruby-changes:15828
From: akr <ko1@a...>
Date: Wed, 12 May 2010 23:15:43 +0900 (JST)
Subject: [ruby-changes:15828] Ruby:r27761 (trunk): new test file.
akr 2010-05-12 23:15:30 +0900 (Wed, 12 May 2010) New Revision: 27761 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=27761 Log: new test file. Added directories: trunk/test/io/console/ Added files: trunk/test/io/console/test_io_console.rb Index: test/io/console/test_io_console.rb =================================================================== --- test/io/console/test_io_console.rb (revision 0) +++ test/io/console/test_io_console.rb (revision 27761) @@ -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 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/