diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2020-10-11 01:51:18 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2020-10-11 02:00:24 +0900 |
commit | a79966743c346bfc588022db29229b79bee51d45 (patch) | |
tree | 2e401b4de42898015f466c29fdac216609a52aa7 /test/io | |
parent | e10d4dce1648147347a65f743acc325ab4753b10 (diff) |
[ruby/io-console] Fix timeout type error (#18)
Fixed TypeError when IO#getch timed out
`rb_io_wait` returns a bit-flags Integer representing available
events, or Qfalse if timed out. Also the result of `NUM2INT` is
not a `VALUE`.
```
$ ./bin/ruby -v -rio/console -e "p IO.console.getch(intr: true, time: 0.1)"
ruby 3.0.0dev (2020-10-09T20:27:30Z master 5ea2ea74cc) [x64-mingw32]
-e:1:in `getch': no implicit conversion of false into Integer (TypeError)
from -e:1:in `<main>'
```
https://github.com/ruby/io-console/commit/3bdfaf62df
Diffstat (limited to 'test/io')
-rw-r--r-- | test/io/console/test_io_console.rb | 4 |
1 files changed, 4 insertions, 0 deletions
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 |