|
7 | 7 | end |
8 | 8 |
|
9 | 9 | class TestIO_Console < Test::Unit::TestCase |
| 10 | + def test_console_namespace |
| 11 | + assert_kind_of(Module, IO::Console) |
| 12 | + end unless RUBY_ENGINE == "jruby" && RbConfig::CONFIG["host_os"] !~ /mswin|mingw/ |
| 13 | + |
10 | 14 | HOST_OS = RbConfig::CONFIG['host_os'] |
11 | 15 |
|
12 | 16 | def test_version |
@@ -720,6 +724,26 @@ def test_pressed_invalid |
720 | 724 | end |
721 | 725 | end |
722 | 726 |
|
| 727 | +RbConfig::CONFIG["host_os"] =~ /mswin|mingw/ and TestIO_Console.class_eval do |
| 728 | + def test_virtual_key_constants |
| 729 | + { |
| 730 | + VK_TAB: 0x09, VK_RETURN: 0x0d, VK_SHIFT: 0x10, |
| 731 | + VK_CONTROL: 0x11, VK_MENU: 0x12, VK_END: 0x23, |
| 732 | + VK_HOME: 0x24, VK_LEFT: 0x25, VK_UP: 0x26, |
| 733 | + VK_RIGHT: 0x27, VK_DOWN: 0x28, VK_DELETE: 0x2e, |
| 734 | + VK_DIVIDE: 0x6f, VK_LMENU: 0xa4, |
| 735 | + RIGHT_ALT_PRESSED: 0x0001, LEFT_ALT_PRESSED: 0x0002, |
| 736 | + RIGHT_CTRL_PRESSED: 0x0004, LEFT_CTRL_PRESSED: 0x0008, |
| 737 | + SHIFT_PRESSED: 0x0010, NUMLOCK_ON: 0x0020, |
| 738 | + SCROLLLOCK_ON: 0x0040, CAPSLOCK_ON: 0x0080, |
| 739 | + ENHANCED_KEY: 0x0100, |
| 740 | + }.each do |name, value| |
| 741 | + assert_equal(value, IO::Console::Windows.const_get(name, false)) |
| 742 | + assert_false(IO::Console.const_defined?(name, false)) |
| 743 | + end |
| 744 | + end |
| 745 | +end |
| 746 | + |
723 | 747 | RbConfig::CONFIG["host_os"] =~ /mswin|mingw/ and defined?(IO.console) and IO.console and \ |
724 | 748 | TestIO_Console.class_eval do |
725 | 749 | def test_output_console_mode |
|
0 commit comments