summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ext/io/console/console.c2
-rw-r--r--test/io/console/test_io_console.rb4
2 files changed, 5 insertions, 1 deletions
diff --git a/ext/io/console/console.c b/ext/io/console/console.c
index 50baf4f591..11ce699971 100644
--- a/ext/io/console/console.c
+++ b/ext/io/console/console.c
@@ -546,7 +546,7 @@ console_getch(int argc, VALUE *argv, VALUE io)
if (w < 0) rb_eof_error();
if (!(w & RB_WAITFD_IN)) return Qnil;
# else
- VALUE result = RB_NUM2INT(rb_io_wait(io, RUBY_IO_READABLE, timeout));
+ VALUE result = rb_io_wait(io, RUBY_IO_READABLE, timeout);
if (result == Qfalse) return Qnil;
# endif
}
diff --git a/test/io/console/test_io_console.rb b/test/io/console/test_io_console.rb
index 3613a2ce32..3962de3790 100644
--- a/test/io/console/test_io_console.rb
+++ b/test/io/console/test_io_console.rb
@@ -471,6 +471,10 @@ defined?(IO.console) and TestIO_Console.class_eval do
ensure
IO.console(:close)
end
+
+ def test_getch_timeout
+ assert_nil(IO.console.getch(intr: true, time: 0.1, min: 0))
+ end
end
end