summaryrefslogtreecommitdiff
path: root/test/win32ole/test_win32ole.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/win32ole/test_win32ole.rb')
-rw-r--r--test/win32ole/test_win32ole.rb45
1 files changed, 26 insertions, 19 deletions
diff --git a/test/win32ole/test_win32ole.rb b/test/win32ole/test_win32ole.rb
index 3941780528..e6347e89b4 100644
--- a/test/win32ole/test_win32ole.rb
+++ b/test/win32ole/test_win32ole.rb
@@ -34,23 +34,23 @@ if defined?(WIN32OLE)
assert_equal(1, @dict2.item("one"))
end
def test_non_exist_property
- assert_raise(WIN32OLERuntimeError) {
+ assert_raise(WIN32OLE::RuntimeError) {
@dict1.unknown_property = 1
}
end
def test_raise_message
- exc = assert_raise(WIN32OLERuntimeError) {
+ exc = assert_raise(WIN32OLE::RuntimeError) {
@dict1.add
}
assert_match(/^\(in OLE method `add': \)/, exc.message) #`
- exc = assert_raise(WIN32OLERuntimeError) {
+ exc = assert_raise(WIN32OLE::RuntimeError) {
@dict1._invoke(1, [], [])
}
assert_match(/^\(in OLE method `<dispatch id:1>': \)/, exc.message) #`
- exc = assert_raise(WIN32OLERuntimeError) {
+ exc = assert_raise(WIN32OLE::RuntimeError) {
@dict1.compareMode = -1
}
assert_match(/^\(in setting property `compareMode': \)/, exc.message) #`
@@ -101,7 +101,7 @@ if defined?(WIN32OLE)
assert_include(mnames, 'Count')
end
- def test_ole_mehtod_help
+ def test_ole_method_help
minfo = @dict1.ole_method_help("Add")
assert_equal(2, minfo.size_params)
end
@@ -167,6 +167,11 @@ if defined?(WIN32OLE)
assert_instance_of(WIN32OLE, @dict2)
end
+ def test_toplevel_constants_backward_compatibility
+ assert_equal(WIN32OLE::RuntimeError, ::WIN32OLERuntimeError)
+ assert_equal(WIN32OLE::QueryInterfaceError, ::WIN32OLEQueryInterfaceError)
+ end
+
def test_s_new_exc
assert_raise(TypeError) {
WIN32OLE.new(1)
@@ -184,7 +189,7 @@ if defined?(WIN32OLE)
def test_s_new_from_clsid
shell = WIN32OLE.new("{13709620-C279-11CE-A49E-444553540000}")
assert_instance_of(WIN32OLE, shell)
- exc = assert_raise(WIN32OLERuntimeError) {
+ exc = assert_raise(WIN32OLE::RuntimeError) {
WIN32OLE.new("{000}")
}
assert_match(/unknown OLE server: `\{000\}'/, exc.message) #`
@@ -335,17 +340,19 @@ if defined?(WIN32OLE)
end
def test_s_codepage_changed
+ omit if RUBY_PLATFORM.match("mswin")
+
cp = WIN32OLE.codepage
fso = WIN32OLE.new("Scripting.FileSystemObject")
fname = fso.getTempName
begin
- obj = WIN32OLE_VARIANT.new([0x3042].pack("U*").force_encoding("UTF-8"))
+ obj = WIN32OLE::Variant.new([0x3042].pack("U*").force_encoding("UTF-8"))
WIN32OLE.codepage = WIN32OLE::CP_UTF8
assert_equal("\xE3\x81\x82".force_encoding("CP65001"), obj.value)
begin
WIN32OLE.codepage = 932 # Windows-31J
- rescue WIN32OLERuntimeError
+ rescue WIN32OLE::RuntimeError
end
if (WIN32OLE.codepage == 932)
assert_equal("\x82\xA0".force_encoding("CP932"), obj.value)
@@ -353,7 +360,7 @@ if defined?(WIN32OLE)
begin
WIN32OLE.codepage = 20932 # MS EUC-JP
- rescue WIN32OLERuntimeError
+ rescue WIN32OLE::RuntimeError
end
if (WIN32OLE.codepage == 20932)
assert_equal("\xA4\xA2".force_encoding("CP20932"), obj.value)
@@ -376,7 +383,7 @@ if defined?(WIN32OLE)
# This test fail if codepage 20932 (euc) is not installed.
begin
WIN32OLE.codepage = 20932
- rescue WIN32OLERuntimeError
+ rescue WIN32OLE::RuntimeError
end
if (WIN32OLE.codepage == 20932)
WIN32OLE.codepage = cp
@@ -403,7 +410,7 @@ if defined?(WIN32OLE)
def test_cp51932
cp = WIN32OLE.codepage
begin
- obj = WIN32OLE_VARIANT.new([0x3042].pack("U*").force_encoding("UTF-8"))
+ obj = WIN32OLE::Variant.new([0x3042].pack("U*").force_encoding("UTF-8"))
begin
WIN32OLE.codepage = 51932
rescue
@@ -424,13 +431,13 @@ if defined?(WIN32OLE)
begin
begin
WIN32OLE.locale = 1041
- rescue WIN32OLERuntimeError
+ rescue WIN32OLE::RuntimeError
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) {
+ assert_raise(WIN32OLE::RuntimeError) {
WIN32OLE.locale = 111
}
assert_equal(WIN32OLE::LOCALE_SYSTEM_DEFAULT, WIN32OLE.locale)
@@ -443,13 +450,13 @@ if defined?(WIN32OLE)
begin
begin
WIN32OLE.locale = 0x0411
- rescue WIN32OLERuntimeError
+ rescue WIN32OLE::RuntimeError
end
if WIN32OLE.locale == 0x0411
- obj = WIN32OLE_VARIANT.new("\\100,000", WIN32OLE::VARIANT::VT_CY)
+ 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)
+ assert_raise(WIN32OLE::RuntimeError) {
+ 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)")
@@ -457,10 +464,10 @@ if defined?(WIN32OLE)
begin
WIN32OLE.locale = 1033
- rescue WIN32OLERuntimeError
+ rescue WIN32OLE::RuntimeError
end
if WIN32OLE.locale == 1033
- obj = WIN32OLE_VARIANT.new("$100,000", WIN32OLE::VARIANT::VT_CY)
+ 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)")