ruby-changes:16542
From: akr <ko1@a...>
Date: Sat, 3 Jul 2010 23:29:37 +0900 (JST)
Subject: [ruby-changes:16542] Ruby:r28534 (trunk): refine tests.
akr 2010-07-03 23:29:26 +0900 (Sat, 03 Jul 2010) New Revision: 28534 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=28534 Log: refine tests. Modified 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 28533) +++ test/io/console/test_io_console.rb (revision 28534) @@ -16,8 +16,28 @@ } end + def test_echo + PTY.open {|m, s| + assert(s.echo?) + m.print "a" + assert_equal("a", m.readpartial(10)) + } + end + def test_noecho PTY.open {|m, s| + s.noecho { + assert(!s.echo?) + m.print "a" + sleep 0.1 + } + m.print "b" + assert_equal("b", m.readpartial(10)) + } + end + + def test_noecho2 + PTY.open {|m, s| assert(s.echo?) m.print "a\n" sleep 0.1 @@ -45,6 +65,18 @@ def test_setecho PTY.open {|m, s| assert(s.echo?) + s.echo = false + m.print "a" + sleep 0.1 + s.echo = true + m.print "b" + assert_equal("b", m.readpartial(10)) + } + end + + def test_setecho2 + PTY.open {|m, s| + assert(s.echo?) m.print "a\n" sleep 0.1 s.print "b\n" @@ -70,24 +102,43 @@ def test_iflush PTY.open {|m, s| - m.print "a\n" - sleep 0.1 + m.print "a" s.iflush - sleep 0.1 m.print "b\n" - sleep 0.1 - assert_equal("a\r\nb\r\n", m.readpartial(10)) assert_equal("b\n", s.readpartial(10)) } end def test_oflush PTY.open {|m, s| - s.print "a\n" - s.oflush - s.print "b\n" - assert_equal("b\r\n", m.readpartial(10)) + s.print "a" + s.oflush # oflush may be issued after "a" is already sent. + s.print "b" + assert_includes(["b", "ab"], m.readpartial(10)) } end + def test_ioflush + PTY.open {|m, s| + m.print "a" + s.ioflush + m.print "b\n" + assert_equal("b\n", s.readpartial(10)) + } + end + + def test_ioflush2 + PTY.open {|m, s| + s.print "a" + s.ioflush # ioflush may be issued after "a" is already sent. + s.print "b" + assert_includes(["b", "ab"], m.readpartial(10)) + } + end + + def test_winsize + PTY.open {|m, s| + assert_equal([0, 0], s.winsize) + } + end end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/