summaryrefslogtreecommitdiff
path: root/test/io/console
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-12-25 01:09:17 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-12-25 01:09:17 +0000
commitd8d326c97a1119dac58063681e2d44c51fd65de1 (patch)
treeaf2938495973f83e18f867d0f0684d626ca8cc72 /test/io/console
parent86693b30c53ea750d0f1e1a7210476ec9c9f8374 (diff)
console.c: get rid of NameError
* ext/io/console/console.c (console_dev): id_console is not a constant name, use rb_const_remove() to get rid of NameError. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48982 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/io/console')
-rw-r--r--test/io/console/test_io_console.rb34
1 files changed, 24 insertions, 10 deletions
diff --git a/test/io/console/test_io_console.rb b/test/io/console/test_io_console.rb
index 8b4fca5064..c4fd08c7eb 100644
--- a/test/io/console/test_io_console.rb
+++ b/test/io/console/test_io_console.rb
@@ -218,21 +218,22 @@ class TestIO_Console < Test::Unit::TestCase
end
if IO.console
+ def test_close
+ IO.console.close
+ assert_kind_of(IO, IO.console)
+ assert_nothing_raised(IOError) {IO.console.fileno}
+ end
+
def test_sync
assert(IO.console.sync, "console should be unbuffered")
end
else
+ def test_close
+ assert_equal(["true"], run_pty("IO.console.close; p IO.console.fileno >= 0"))
+ end
+
def test_sync
- r, w, pid = PTY.spawn(EnvUtil.rubybin, "-rio/console", "-e", "p IO.console.class")
- rescue RuntimeError
- skip $!
- else
- con = r.gets.chomp
- Process.wait(pid)
- assert_match("File", con)
- ensure
- r.close if r
- w.close if w
+ assert_equal(["true"], run_pty("p IO.console.sync"))
end
end
@@ -247,6 +248,19 @@ class TestIO_Console < Test::Unit::TestCase
m.close if m
s.close if s
end
+
+ def run_pty(src)
+ r, w, pid = PTY.spawn(EnvUtil.rubybin, "-rio/console", "-e", src)
+ rescue RuntimeError
+ skip $!
+ else
+ result = r.readlines(&:chomp)
+ Process.wait(pid)
+ yield result
+ ensure
+ r.close if r
+ w.close if w
+ end
end if defined?(PTY) and defined?(IO::console)
class TestIO_Console < Test::Unit::TestCase