ruby-changes:47726
From: nobu <ko1@a...>
Date: Tue, 12 Sep 2017 05:10:39 +0900 (JST)
Subject: [ruby-changes:47726] nobu:r59842 (trunk): test_io_console.rb: test_set_winsize_console
nobu 2017-09-12 05:10:33 +0900 (Tue, 12 Sep 2017) New Revision: 59842 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=59842 Log: test_io_console.rb: test_set_winsize_console * test/io/console/test_io_console.rb (test_set_winsize_console): split from test_get_winsize_console and enable the case when attached to a console already 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 59841) +++ test/io/console/test_io_console.rb (revision 59842) @@ -262,33 +262,7 @@ defined?(PTY) and defined?(IO.console) a https://github.com/ruby/ruby/blob/trunk/test/io/console/test_io_console.rb#L262 end end - if IO.console - def test_set_winsize_console - s = IO.console.winsize - assert_kind_of(Array, s) - assert_equal(2, s.size) - assert_kind_of(Integer, s[0]) - assert_kind_of(Integer, s[1]) - assert_nothing_raised(TypeError) {IO.console.winsize = s} - end - - def test_close - IO.console.close - assert_kind_of(IO, IO.console) - assert_nothing_raised(IOError) {IO.console.fileno} - - IO.console(:close) - assert(IO.console(:tty?)) - ensure - IO.console(:close) - end - - def test_sync - assert(IO.console.sync, "console should be unbuffered") - ensure - IO.console(:close) - end - else + unless IO.console def test_close assert_equal(["true"], run_pty("IO.console.close; p IO.console.fileno >= 0")) assert_equal(["true"], run_pty("IO.console(:close); p IO.console(:tty?)")) @@ -330,6 +304,40 @@ defined?(PTY) and defined?(IO.console) a https://github.com/ruby/ruby/blob/trunk/test/io/console/test_io_console.rb#L304 end end +defined?(IO.console) and TestIO_Console.class_eval do + if IO.console + def test_get_winsize_console + s = IO.console.winsize + assert_kind_of(Array, s) + assert_equal(2, s.size) + assert_kind_of(Integer, s[0]) + assert_kind_of(Integer, s[1]) + end + + def test_set_winsize_console + s = IO.console.winsize + assert_nothing_raised(TypeError) {IO.console.winsize = s} + end + + def test_close + IO.console.close + assert_kind_of(IO, IO.console) + assert_nothing_raised(IOError) {IO.console.fileno} + + IO.console(:close) + assert(IO.console(:tty?)) + ensure + IO.console(:close) + end + + def test_sync + assert(IO.console.sync, "console should be unbuffered") + ensure + IO.console(:close) + end + end +end + defined?(IO.console) and TestIO_Console.class_eval do case when Process.respond_to?(:daemon) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/