mirror of
https://github.com/ruby/ruby.git
synced 2025-08-24 21:44:30 +02:00
io/console: unknown key code for names with nul
* ext/io/console/console.c (console_key_pressed_p): raise the same exception, "unknown virtual key code", for names with nul chars. though console_win32_vk() considers the length and can deal with nul chars, rb_sprintf() raised at PRIsVALUE previously, so quote it if it is unprintable. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54589 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
caaf4f2aea
commit
e78beed499
3 changed files with 28 additions and 2 deletions
|
@ -340,6 +340,21 @@ defined?(IO.console) and TestIO_Console.class_eval do
|
|||
end
|
||||
end
|
||||
|
||||
defined?(IO.console) and IO.console and IO.console.respond_to?(:pressed?) and
|
||||
TestIO_Console.class_eval do
|
||||
def test_pressed_valid
|
||||
assert_include([true, false], IO.console.pressed?("HOME"))
|
||||
assert_include([true, false], IO.console.pressed?(:"HOME"))
|
||||
end
|
||||
|
||||
def test_pressed_invalid
|
||||
e = assert_raise(ArgumentError) do
|
||||
IO.console.pressed?("HOME\0")
|
||||
end
|
||||
assert_match(/unknown virtual key code/, e.message)
|
||||
end
|
||||
end
|
||||
|
||||
TestIO_Console.class_eval do
|
||||
def test_stringio_getch
|
||||
assert_separately %w"--disable=gems -rstringio -rio/console", %q{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue