diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/io/console/test_io_console.rb | 62 |
1 files changed, 35 insertions, 27 deletions
diff --git a/test/io/console/test_io_console.rb b/test/io/console/test_io_console.rb index 95917dd713..d65a8e79ca 100644 --- a/test/io/console/test_io_console.rb +++ b/test/io/console/test_io_console.rb @@ -262,33 +262,7 @@ defined?(PTY) and defined?(IO.console) and TestIO_Console.class_eval do 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?)")) @@ -331,6 +305,40 @@ defined?(PTY) and defined?(IO.console) and TestIO_Console.class_eval do 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) noctty = [EnvUtil.rubybin, "-e", "Process.daemon(true)"] |