ruby-changes:49736
From: nobu <ko1@a...>
Date: Mon, 15 Jan 2018 21:25:29 +0900 (JST)
Subject: [ruby-changes:49736] nobu:r61853 (trunk): test_console_attr.rb: fix test
nobu 2018-01-15 21:25:24 +0900 (Mon, 15 Jan 2018) New Revision: 61853 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=61853 Log: test_console_attr.rb: fix test * test/-ext-/win32/test_console_attr.rb (reverse_video): fix test when reverse video is set. Modified files: trunk/ext/-test-/win32/console/attribute.c trunk/test/-ext-/win32/test_console_attr.rb Index: test/-ext-/win32/test_console_attr.rb =================================================================== --- test/-ext-/win32/test_console_attr.rb (revision 61852) +++ test/-ext-/win32/test_console_attr.rb (revision 61853) @@ -5,6 +5,17 @@ if /mswin|mingw/ =~ RUBY_PLATFORM and ST https://github.com/ruby/ruby/blob/trunk/test/-ext-/win32/test_console_attr.rb#L5 require 'test/unit' class Test_Win32Console < Test::Unit::TestCase + REVERSE_VIDEO = Bug::Win32::REVERSE_VIDEO + + def reverse_video(fore, back = 0x0) + info = STDOUT.console_info + if (info.attr & REVERSE_VIDEO) == 0 + (fore << 4) | back + else + (back << 4) | fore | REVERSE_VIDEO + end + end + def reset STDOUT.console_attribute(7) end @@ -20,7 +31,7 @@ if /mswin|mingw/ =~ RUBY_PLATFORM and ST https://github.com/ruby/ruby/blob/trunk/test/-ext-/win32/test_console_attr.rb#L31 def test_reverse print "\e[7m" info = STDOUT.console_info - assert_equal(0x70, info.attr); + assert_equal(reverse_video(0x7), info.attr); end def test_bold @@ -32,13 +43,13 @@ if /mswin|mingw/ =~ RUBY_PLATFORM and ST https://github.com/ruby/ruby/blob/trunk/test/-ext-/win32/test_console_attr.rb#L43 def test_bold_reverse print "\e[1;7m" info = STDOUT.console_info - assert_equal(0xf0, info.attr); + assert_equal(reverse_video(0xf), info.attr); end def test_reverse_bold print "\e[7;1m" info = STDOUT.console_info - assert_equal(0xf0, info.attr); + assert_equal(reverse_video(0xf), info.attr); end end end Index: ext/-test-/win32/console/attribute.c =================================================================== --- ext/-test-/win32/console/attribute.c (revision 61852) +++ ext/-test-/win32/console/attribute.c (revision 61853) @@ -61,4 +61,9 @@ Init_attribute(VALUE m) https://github.com/ruby/ruby/blob/trunk/ext/-test-/win32/console/attribute.c#L61 rb_define_const(m, "BACKGROUND_GREEN", INT2FIX(BACKGROUND_GREEN)); rb_define_const(m, "BACKGROUND_RED", INT2FIX(BACKGROUND_RED)); rb_define_const(m, "BACKGROUND_INTENSITY", INT2FIX(BACKGROUND_INTENSITY)); + +#ifndef COMMON_LVB_REVERSE_VIDEO +#define COMMON_LVB_REVERSE_VIDEO 0x4000 +#endif + rb_define_const(m, "REVERSE_VIDEO", INT2FIX(COMMON_LVB_REVERSE_VIDEO)); } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/