summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-09-11 20:10:33 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-09-11 20:10:33 +0000
commitb6bc45b9858f83231c9fcf91ab1a32bf7b5b3e0a (patch)
tree1e8a358afbc32293c017cdd03ea68b7d367e08ca
parent3b08df649e2337594f398e7f47b7baea8188ed96 (diff)
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 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59842 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--test/io/console/test_io_console.rb62
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 95917dd..d65a8e7 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)"]