summaryrefslogtreecommitdiff
path: root/jni/ruby/test/-ext-/win32
diff options
context:
space:
mode:
Diffstat (limited to 'jni/ruby/test/-ext-/win32')
-rw-r--r--jni/ruby/test/-ext-/win32/test_console_attr.rb43
-rw-r--r--jni/ruby/test/-ext-/win32/test_dln.rb34
-rw-r--r--jni/ruby/test/-ext-/win32/test_fd_setsize.rb24
3 files changed, 101 insertions, 0 deletions
diff --git a/jni/ruby/test/-ext-/win32/test_console_attr.rb b/jni/ruby/test/-ext-/win32/test_console_attr.rb
new file mode 100644
index 0000000..3afb2d9
--- /dev/null
+++ b/jni/ruby/test/-ext-/win32/test_console_attr.rb
@@ -0,0 +1,43 @@
+if /mswin|mingw/ =~ RUBY_PLATFORM and STDOUT.tty?
+ require '-test-/win32/console'
+ require 'io/console'
+ require 'test/unit'
+
+ class Test_Win32Console < Test::Unit::TestCase
+ def reset
+ STDOUT.console_attribute(7)
+ end
+
+ alias setup reset
+ alias teardown reset
+
+ def test_default
+ info = STDOUT.console_info
+ assert_equal(7, info.attr);
+ end
+
+ def test_reverse
+ print "\e[7m"
+ info = STDOUT.console_info
+ assert_equal(0x70, info.attr);
+ end
+
+ def test_bold
+ print "\e[1m"
+ info = STDOUT.console_info
+ assert_equal(0x8, info.attr&0x8);
+ end
+
+ def test_bold_reverse
+ print "\e[1;7m"
+ info = STDOUT.console_info
+ assert_equal(0xf0, info.attr);
+ end
+
+ def test_reverse_bold
+ print "\e[7;1m"
+ info = STDOUT.console_info
+ assert_equal(0xf0, info.attr);
+ end
+ end
+end
diff --git a/jni/ruby/test/-ext-/win32/test_dln.rb b/jni/ruby/test/-ext-/win32/test_dln.rb
new file mode 100644
index 0000000..2801ebe
--- /dev/null
+++ b/jni/ruby/test/-ext-/win32/test_dln.rb
@@ -0,0 +1,34 @@
+require 'test/unit'
+require 'tmpdir'
+require 'rbconfig'
+
+module Bug
+ module Win32
+ class TestDln < Test::Unit::TestCase
+ def test_check_imported
+ bug = '[Bug #6303]'
+ assert_in_out_err(['-r-test-/win32/dln', '-eexit'], '', [], [], bug, timeout: 10)
+ end
+
+ def test_nonascii_load
+ bug9699 = '[ruby-core:61845] [Bug #9699]'
+ so = "-test-/win32/dln/empty." + RbConfig::CONFIG["DLEXT"]
+ so = $:.find {|d| d = ::File.join(d, so); break d if ::File.exist?(d)}
+ assert_not_nil(so)
+ Dir.mkdir(dir = ::File.join(testdir = Dir.mktmpdir("test"), "\u{30c6 30b9 30c8}"))
+ ::File.copy_stream(so, ::File.join(dir, ::File.basename(so)))
+ assert_separately(['-', bug9699, testdir, ::File.basename(so)], <<-'end;')
+ bug, dir, so = *ARGV
+ assert_nothing_raised(LoadError, bug) do
+ require ::File.join(dir, "\u{30c6 30b9 30c8}", so)
+ end
+ end;
+ ensure
+ ::File.unlink(::File.join(dir, ::File.basename(so))) rescue nil
+ Dir.rmdir(dir) rescue nil
+ Dir.rmdir(testdir) rescue nil
+ end
+
+ end
+ end
+end if /mswin|mingw/ =~ RUBY_PLATFORM
diff --git a/jni/ruby/test/-ext-/win32/test_fd_setsize.rb b/jni/ruby/test/-ext-/win32/test_fd_setsize.rb
new file mode 100644
index 0000000..6fe889c
--- /dev/null
+++ b/jni/ruby/test/-ext-/win32/test_fd_setsize.rb
@@ -0,0 +1,24 @@
+require 'test/unit'
+
+module Bug
+ module Win32
+ class TestFdSetSize < Test::Unit::TestCase
+ def test_select_with_unmatched_fd_setsize
+ bug6532 = '[ruby-core:44588]'
+ assert_in_out_err([], <<-INPUT, %w(:ok), [], bug6532)
+ require '-test-/win32/fd_setsize'
+ Bug::Win32.test_select
+ p :ok
+ INPUT
+ end
+
+ def test_fdset_with_unmatched_fd_setsize
+ bug6532 = '[ruby-core:44588]'
+ assert_in_out_err([], <<-INPUT, %w(:ok), [], bug6532)
+ require '-test-/win32/fd_setsize'
+ p :ok if Bug::Win32.test_fdset
+ INPUT
+ end
+ end
+ end
+end if /mswin|mingw/ =~ RUBY_PLATFORM