From 6d7ddc3b297bfe6ca9f091c0097722b0422cc7e2 Mon Sep 17 00:00:00 2001 From: suke Date: Thu, 16 Jul 2009 12:06:23 +0000 Subject: [PATCH] * test/win32ole/test_win32ole.rb (test_s_codepage_changed, test_s_locale_set, test_s_locale_change): skip test if Japanese locale is not installed. [ruby-core:23806] * test/win32ole/test_win32ole_variant.rb (test_conversion_str2cy): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24153 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 9 +++++ test/win32ole/test_win32ole.rb | 53 +++++++++++++++++++------- test/win32ole/test_win32ole_variant.rb | 12 ++++-- 3 files changed, 57 insertions(+), 17 deletions(-) diff --git a/ChangeLog b/ChangeLog index 716d7633e3..0919ab7fa4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +Thu Jul 16 20:58:18 2009 Masaki Suketa + + * test/win32ole/test_win32ole.rb (test_s_codepage_changed, + test_s_locale_set, test_s_locale_change): skip test if Japanese + locale is not installed. [ruby-core:23806] + + * test/win32ole/test_win32ole_variant.rb (test_conversion_str2cy): + dito. + Thu Jul 16 19:02:28 2009 NAKAMURA Usaku * ext/socket/lib/socket.rb (Socket.tcp_server_sockets_port0): servers diff --git a/test/win32ole/test_win32ole.rb b/test/win32ole/test_win32ole.rb index 18da3bec7a..8c8528fde3 100644 --- a/test/win32ole/test_win32ole.rb +++ b/test/win32ole/test_win32ole.rb @@ -344,8 +344,11 @@ if defined?(WIN32OLE) WIN32OLE.codepage = cp file = fso.opentextfile(fname, 2, true) - file.write [0x3042].pack("U*").force_encoding("UTF-8") - file.close + begin + file.write [0x3042].pack("U*").force_encoding("UTF-8") + ensure + file.close + end str = "" open(fname, "r:ascii-8bit") {|ifs| str = ifs.read @@ -360,8 +363,11 @@ if defined?(WIN32OLE) if (WIN32OLE.codepage == 20932) WIN32OLE.codepage = cp file = fso.opentextfile(fname, 2, true) - file.write [164, 162].pack("c*").force_encoding("EUC-JP") - file.close + begin + file.write [164, 162].pack("c*").force_encoding("EUC-JP") + ensure + file.close + end open(fname, "r:ascii-8bit") {|ifs| str = ifs.read } @@ -398,7 +404,12 @@ if defined?(WIN32OLE) def test_s_locale_set begin - WIN32OLE.locale = 1041 + begin + WIN32OLE.locale = 1041 + rescue WIN32OLERuntimeError + STDERR.puts("\n#{__FILE__}:#{__LINE__}:#{self.class.name}.test_s_locale_set is skipped(Japanese locale is not installed)") + return + end assert_equal(1041, WIN32OLE.locale) WIN32OLE.locale = WIN32OLE::LOCALE_SYSTEM_DEFAULT assert_raise(WIN32OLERuntimeError) { @@ -412,16 +423,30 @@ if defined?(WIN32OLE) def test_s_locale_change begin - WIN32OLE.locale = 0x0411 - obj = WIN32OLE_VARIANT.new("\\100,000", WIN32OLE::VARIANT::VT_CY) - assert_equal("100000", obj.value) - assert_raise(WIN32OLERuntimeError) { - obj = WIN32OLE_VARIANT.new("$100.000", WIN32OLE::VARIANT::VT_CY) - } + begin + WIN32OLE.locale = 0x0411 + rescue WIN32OLERuntimeError + end + if WIN32OLE.locale == 0x0411 + obj = WIN32OLE_VARIANT.new("\\100,000", WIN32OLE::VARIANT::VT_CY) + assert_equal("100000", obj.value) + assert_raise(WIN32OLERuntimeError) { + obj = WIN32OLE_VARIANT.new("$100.000", WIN32OLE::VARIANT::VT_CY) + } + else + STDERR.puts("\n#{__FILE__}:#{__LINE__}:#{self.class.name}.test_s_locale_change is skipped(Japanese locale is not installed)") + end - WIN32OLE.locale = 1033 - obj = WIN32OLE_VARIANT.new("$100,000", WIN32OLE::VARIANT::VT_CY) - assert_equal("100000", obj.value) + begin + WIN32OLE.locale = 1033 + rescue WIN32OLERuntimeError + end + if WIN32OLE.locale == 1033 + obj = WIN32OLE_VARIANT.new("$100,000", WIN32OLE::VARIANT::VT_CY) + assert_equal("100000", obj.value) + else + STDERR.puts("\n#{__FILE__}:#{__LINE__}:#{self.class.name}.test_s_locale_change is skipped(US English locale is not installed)") + end ensure WIN32OLE.locale = WIN32OLE::LOCALE_SYSTEM_DEFAULT end diff --git a/test/win32ole/test_win32ole_variant.rb b/test/win32ole/test_win32ole_variant.rb index 7bf6caac49..d753fb4fc9 100644 --- a/test/win32ole/test_win32ole_variant.rb +++ b/test/win32ole/test_win32ole_variant.rb @@ -384,9 +384,15 @@ if defined?(WIN32OLE_VARIANT) def test_conversion_str2cy begin - WIN32OLE.locale = 0x0411 # set locale Japanese - obj = WIN32OLE_VARIANT.new("\\10,000", WIN32OLE::VARIANT::VT_CY) - assert_equal("10000", obj.value) + begin + WIN32OLE.locale = 0x0411 # set locale Japanese + rescue WIN32OLERuntimeError + STDERR.puts("\n#{__FILE__}:#{__LINE__}:#{self.class.name}.test_conversion_str2cy is skipped(Japanese locale is not installed)") + end + if WIN32OLE.locale == 0x0411 + obj = WIN32OLE_VARIANT.new("\\10,000", WIN32OLE::VARIANT::VT_CY) + assert_equal("10000", obj.value) + end ensure WIN32OLE.locale = WIN32OLE::LOCALE_SYSTEM_DEFAULT end