summaryrefslogtreecommitdiff
path: root/test/win32ole
diff options
context:
space:
mode:
Diffstat (limited to 'test/win32ole')
-rw-r--r--test/win32ole/available_ole.rb14
-rw-r--r--test/win32ole/err_in_callback.rb4
-rw-r--r--test/win32ole/test_err_in_callback.rb6
-rw-r--r--test/win32ole/test_folderitem2_invokeverb.rb2
-rw-r--r--test/win32ole/test_nil2vtempty.rb2
-rw-r--r--test/win32ole/test_propertyputref.rb2
-rw-r--r--test/win32ole/test_thread.rb2
-rw-r--r--test/win32ole/test_win32ole.rb43
-rw-r--r--test/win32ole/test_win32ole_event.rb72
-rw-r--r--test/win32ole/test_win32ole_method.rb48
-rw-r--r--test/win32ole/test_win32ole_method_event.rb12
-rw-r--r--test/win32ole/test_win32ole_param.rb42
-rw-r--r--test/win32ole/test_win32ole_param_event.rb4
-rw-r--r--test/win32ole/test_win32ole_record.rb60
-rw-r--r--test/win32ole/test_win32ole_type.rb67
-rw-r--r--test/win32ole/test_win32ole_type_event.rb6
-rw-r--r--test/win32ole/test_win32ole_typelib.rb66
-rw-r--r--test/win32ole/test_win32ole_variable.rb18
-rw-r--r--test/win32ole/test_win32ole_variant.rb310
-rw-r--r--test/win32ole/test_win32ole_variant_m.rb5
-rw-r--r--test/win32ole/test_win32ole_variant_outarg.rb8
-rw-r--r--test/win32ole/test_word.rb4
22 files changed, 423 insertions, 374 deletions
diff --git a/test/win32ole/available_ole.rb b/test/win32ole/available_ole.rb
index ebc9baae66..af397e00b5 100644
--- a/test/win32ole/available_ole.rb
+++ b/test/win32ole/available_ole.rb
@@ -8,7 +8,7 @@ if defined?(WIN32OLE)
module_function
def sysmon_available?
- WIN32OLE_TYPE.new('System Monitor Control', 'SystemMonitor')
+ WIN32OLE::Type.new('System Monitor Control', 'SystemMonitor')
true
rescue
false
@@ -22,18 +22,18 @@ if defined?(WIN32OLE)
end
def msxml_available?
- !WIN32OLE_TYPELIB.typelibs.find { |t| t.name.start_with?('Microsoft XML') }.nil?
+ !WIN32OLE::TypeLib.typelibs.find { |t| t.name.start_with?('Microsoft XML') }.nil?
end
def event_param
method = if msxml_available?
- typelib = WIN32OLE_TYPELIB.typelibs.find { |t| t.name.start_with?('Microsoft XML') }
- ole_type = WIN32OLE_TYPE.new(typelib.name, 'IVBSAXContentHandler')
- WIN32OLE_METHOD.new(ole_type, 'startElement')
+ typelib = WIN32OLE::TypeLib.typelibs.find { |t| t.name.start_with?('Microsoft XML') }
+ ole_type = WIN32OLE::Type.new(typelib.name, 'IVBSAXContentHandler')
+ WIN32OLE::Method.new(ole_type, 'startElement')
elsif ado_available?
typelib = WIN32OLE.new('ADODB.Connection').ole_typelib
- ole_type = WIN32OLE_TYPE.new(typelib.name, 'Connection')
- WIN32OLE_METHOD.new(ole_type, 'WillConnect')
+ ole_type = WIN32OLE::Type.new(typelib.name, 'Connection')
+ WIN32OLE::Method.new(ole_type, 'WillConnect')
end
method && method.params[0]
end
diff --git a/test/win32ole/err_in_callback.rb b/test/win32ole/err_in_callback.rb
index aa6c9c7e3a..baecf780b6 100644
--- a/test/win32ole/err_in_callback.rb
+++ b/test/win32ole/err_in_callback.rb
@@ -2,9 +2,9 @@
require 'win32ole'
db = WIN32OLE.new('ADODB.Connection')
db.connectionString = "Driver={Microsoft Text Driver (*.txt; *.csv)};DefaultDir=.;"
-ev = WIN32OLE_EVENT.new(db)
+ev = WIN32OLE::Event.new(db)
ev.on_event('WillConnect') {|*args|
foo
}
db.open
-WIN32OLE_EVENT.message_loop
+WIN32OLE::Event.message_loop
diff --git a/test/win32ole/test_err_in_callback.rb b/test/win32ole/test_err_in_callback.rb
index 2c2b4a61a1..bea5781bc9 100644
--- a/test/win32ole/test_err_in_callback.rb
+++ b/test/win32ole/test_err_in_callback.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: false
#
# test Win32OLE avoids cfp consistency error when the exception raised
-# in WIN32OLE_EVENT handler block. [ruby-dev:35450]
+# in WIN32OLE::Event handler block. [ruby-dev:35450]
#
begin
@@ -31,14 +31,14 @@ if defined?(WIN32OLE)
def available_adodb?
begin
WIN32OLE.new('ADODB.Connection')
- rescue WIN32OLERuntimeError
+ rescue WIN32OLE::RuntimeError
return false
end
return true
end
def test_err_in_callback
- skip "'ADODB.Connection' is not available" unless available_adodb?
+ omit "'ADODB.Connection' is not available" unless available_adodb?
if @ruby
Dir.mktmpdir do |tmpdir|
logfile = File.join(tmpdir, "test_err_in_callback.log")
diff --git a/test/win32ole/test_folderitem2_invokeverb.rb b/test/win32ole/test_folderitem2_invokeverb.rb
index e11503ca2a..a1c2b2f472 100644
--- a/test/win32ole/test_folderitem2_invokeverb.rb
+++ b/test/win32ole/test_folderitem2_invokeverb.rb
@@ -44,7 +44,7 @@ if defined?(WIN32OLE)
assert_equal(0, links.size)
# Now create shortcut to @dummy_path
- arg = WIN32OLE_VARIANT.new("Link")
+ arg = WIN32OLE::Variant.new("Link")
@fi2.InvokeVerb(arg)
# Now search shortcut to @dummy_path
diff --git a/test/win32ole/test_nil2vtempty.rb b/test/win32ole/test_nil2vtempty.rb
index 49757d61b3..bd86403676 100644
--- a/test/win32ole/test_nil2vtempty.rb
+++ b/test/win32ole/test_nil2vtempty.rb
@@ -28,7 +28,7 @@ if defined?(WIN32OLE)
assert(rs)
assert_equal("_Recordset", rs.ole_type.name)
- rs = con.openSchema(4, [WIN32OLE_VARIANT::Empty, WIN32OLE_VARIANT::Empty, "DUMMY", "TABLE"])
+ rs = con.openSchema(4, [WIN32OLE::Variant::Empty, WIN32OLE::Variant::Empty, "DUMMY", "TABLE"])
assert(rs)
assert_equal("_Recordset", rs.ole_type.name)
end
diff --git a/test/win32ole/test_propertyputref.rb b/test/win32ole/test_propertyputref.rb
index 93edb50835..83418140c2 100644
--- a/test/win32ole/test_propertyputref.rb
+++ b/test/win32ole/test_propertyputref.rb
@@ -11,7 +11,7 @@ if defined?(WIN32OLE)
begin
@sapi = WIN32OLE.new('SAPI.SpVoice')
@sv = @sapi.voice
- rescue WIN32OLERuntimeError
+ rescue WIN32OLE::RuntimeError
@sapi = nil
end
end
diff --git a/test/win32ole/test_thread.rb b/test/win32ole/test_thread.rb
index cb34693064..b30b2349c5 100644
--- a/test/win32ole/test_thread.rb
+++ b/test/win32ole/test_thread.rb
@@ -14,7 +14,7 @@ if defined?(WIN32OLE)
t = Thread.__send__(meth) {
WIN32OLE.new('Scripting.Dictionary')
}
- assert_nothing_raised(WIN32OLERuntimeError, "[Bug #2618] Thread.#{meth}") {
+ assert_nothing_raised(WIN32OLE::RuntimeError, "[Bug #2618] Thread.#{meth}") {
t.join
}
end
diff --git a/test/win32ole/test_win32ole.rb b/test/win32ole/test_win32ole.rb
index e5f9d35e24..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) #`
@@ -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)")
diff --git a/test/win32ole/test_win32ole_event.rb b/test/win32ole/test_win32ole_event.rb
index fa9e7b5b08..d52f8cf9b3 100644
--- a/test/win32ole/test_win32ole_event.rb
+++ b/test/win32ole/test_win32ole_event.rb
@@ -28,17 +28,21 @@ swbemsink_available =
end
end
-if defined?(WIN32OLE_EVENT)
+if defined?(WIN32OLE::Event)
class TestWIN32OLE_EVENT < Test::Unit::TestCase
+ def test_toplevel_constants_backward_compatibility
+ assert_equal(WIN32OLE::Event, ::WIN32OLE_EVENT)
+ end
+
def test_s_new_exception
assert_raise(TypeError) {
- WIN32OLE_EVENT.new("A")
+ WIN32OLE::Event.new("A")
}
end
def test_s_new_non_exist_event
dict = WIN32OLE.new('Scripting.Dictionary')
assert_raise(RuntimeError) {
- WIN32OLE_EVENT.new(dict)
+ WIN32OLE::Event.new(dict)
}
end
end
@@ -58,7 +62,7 @@ if defined?(WIN32OLE_EVENT)
end
2.times do
- WIN32OLE_EVENT.message_loop
+ WIN32OLE::Event.message_loop
sleep 1
end
@@ -68,7 +72,7 @@ if defined?(WIN32OLE_EVENT)
seconds = EnvUtil.apply_timeout_scale(1)
while tries < 5 && instance_variable_get(watch_ivar) == orig_ivar
$stderr.puts "test_win32ole_event.rb: retrying and sleeping #{seconds}s until #{watch_ivar} is changed from #{orig_ivar.inspect}..."
- WIN32OLE_EVENT.message_loop
+ WIN32OLE::Event.message_loop
sleep(seconds)
tries += 1
seconds *= 2 # sleep at most 31s in total
@@ -86,24 +90,24 @@ if defined?(WIN32OLE_EVENT)
def test_s_new_non_exist_event
assert_raise(RuntimeError) {
- WIN32OLE_EVENT.new(@sws, 'XXXXX')
+ WIN32OLE::Event.new(@sws, 'XXXXX')
}
end
def test_s_new
- obj = WIN32OLE_EVENT.new(@sws, 'ISWbemSinkEvents')
- assert_instance_of(WIN32OLE_EVENT, obj)
- obj = WIN32OLE_EVENT.new(@sws)
- assert_instance_of(WIN32OLE_EVENT, obj)
+ obj = WIN32OLE::Event.new(@sws, 'ISWbemSinkEvents')
+ assert_instance_of(WIN32OLE::Event, obj)
+ obj = WIN32OLE::Event.new(@sws)
+ assert_instance_of(WIN32OLE::Event, obj)
end
def test_s_new_loop
exec_notification_query_async
- ev = WIN32OLE_EVENT.new(@sws)
+ ev = WIN32OLE::Event.new(@sws)
ev.on_event {|*args| default_handler(*args)}
message_loop
10.times do |i|
- WIN32OLE_EVENT.new(@sws)
+ WIN32OLE::Event.new(@sws)
message_loop
GC.start
end
@@ -115,7 +119,7 @@ if defined?(WIN32OLE_EVENT)
def test_on_event
exec_notification_query_async
- ev = WIN32OLE_EVENT.new(@sws, 'ISWbemSinkEvents')
+ ev = WIN32OLE::Event.new(@sws, 'ISWbemSinkEvents')
ev.on_event {|*args| default_handler(*args)}
message_loop(:@event)
assert_match(/OnObjectReady/, @event)
@@ -123,7 +127,7 @@ if defined?(WIN32OLE_EVENT)
def test_on_event_symbol
exec_notification_query_async
- ev = WIN32OLE_EVENT.new(@sws)
+ ev = WIN32OLE::Event.new(@sws)
ev.on_event(:OnObjectReady) {|*args|
handler1
}
@@ -136,7 +140,7 @@ if defined?(WIN32OLE_EVENT)
@wmi.ExecNotificationQueryAsync(@sws, @sql)
rescue => e
if /OLE error code:80041008 in SWbemServicesEx/ =~ e.message
- skip "No administrator privilege?"
+ omit "No administrator privilege?"
end
raise
end
@@ -163,7 +167,7 @@ if defined?(WIN32OLE_EVENT)
module ADO
end
def message_loop
- WIN32OLE_EVENT.message_loop
+ WIN32OLE::Event.message_loop
end
def default_handler(event, *args)
@@ -182,7 +186,7 @@ if defined?(WIN32OLE_EVENT)
end
def test_on_event2
- ev = WIN32OLE_EVENT.new(@db, 'ConnectionEvents')
+ ev = WIN32OLE::Event.new(@db, 'ConnectionEvents')
ev.on_event('WillConnect') {|*args| handler1}
ev.on_event('WillConnect') {|*args| handler2}
@db.open
@@ -191,7 +195,7 @@ if defined?(WIN32OLE_EVENT)
end
def test_on_event4
- ev = WIN32OLE_EVENT.new(@db, 'ConnectionEvents')
+ ev = WIN32OLE::Event.new(@db, 'ConnectionEvents')
ev.on_event{|*args| handler1}
ev.on_event{|*args| handler2}
ev.on_event('WillConnect'){|*args| handler3(*args)}
@@ -202,7 +206,7 @@ if defined?(WIN32OLE_EVENT)
end
def test_on_event5
- ev = WIN32OLE_EVENT.new(@db, 'ConnectionEvents')
+ ev = WIN32OLE::Event.new(@db, 'ConnectionEvents')
ev.on_event {|*args| default_handler(*args)}
ev.on_event('WillConnect'){|*args| handler3(*args)}
@db.open
@@ -213,7 +217,7 @@ if defined?(WIN32OLE_EVENT)
end
def test_unadvise
- ev = WIN32OLE_EVENT.new(@db, 'ConnectionEvents')
+ ev = WIN32OLE::Event.new(@db, 'ConnectionEvents')
ev.on_event {|*args| default_handler(*args)}
@db.open
message_loop
@@ -224,16 +228,16 @@ if defined?(WIN32OLE_EVENT)
@db.open
message_loop
assert_equal("", @event);
- assert_raise(WIN32OLERuntimeError) {
+ assert_raise(WIN32OLE::RuntimeError) {
ev.on_event {|*args| default_handler(*args)}
}
end
def test_on_event_with_outargs
- ev = WIN32OLE_EVENT.new(@db)
+ ev = WIN32OLE::Event.new(@db)
@db.connectionString = 'XXX' # set illegal connection string
- assert_raise(WIN32OLERuntimeError) {
+ assert_raise(WIN32OLE::RuntimeError) {
@db.open
}
ev.on_event_with_outargs('WillConnect'){|*args|
@@ -245,7 +249,7 @@ if defined?(WIN32OLE_EVENT)
end
def test_on_event_hash_return
- ev = WIN32OLE_EVENT.new(@db)
+ ev = WIN32OLE::Event.new(@db)
ev.on_event('WillConnect'){|*args|
{:return => 1, :ConnectionString => CONNSTR}
}
@@ -255,7 +259,7 @@ if defined?(WIN32OLE_EVENT)
end
def test_on_event_hash_return2
- ev = WIN32OLE_EVENT.new(@db)
+ ev = WIN32OLE::Event.new(@db)
ev.on_event('WillConnect'){|*args|
{:ConnectionString => CONNSTR}
}
@@ -265,7 +269,7 @@ if defined?(WIN32OLE_EVENT)
end
def test_on_event_hash_return3
- ev = WIN32OLE_EVENT.new(@db)
+ ev = WIN32OLE::Event.new(@db)
ev.on_event('WillConnect'){|*args|
{'ConnectionString' => CONNSTR}
}
@@ -275,7 +279,7 @@ if defined?(WIN32OLE_EVENT)
end
def test_on_event_hash_return4
- ev = WIN32OLE_EVENT.new(@db)
+ ev = WIN32OLE::Event.new(@db)
ev.on_event('WillConnect'){|*args|
{'return' => 1, 'ConnectionString' => CONNSTR}
}
@@ -285,7 +289,7 @@ if defined?(WIN32OLE_EVENT)
end
def test_on_event_hash_return5
- ev = WIN32OLE_EVENT.new(@db)
+ ev = WIN32OLE::Event.new(@db)
ev.on_event('WillConnect'){|*args|
{0 => CONNSTR}
}
@@ -295,7 +299,7 @@ if defined?(WIN32OLE_EVENT)
end
def test_off_event
- ev = WIN32OLE_EVENT.new(@db)
+ ev = WIN32OLE::Event.new(@db)
ev.on_event{handler1}
ev.off_event
@db.open
@@ -304,7 +308,7 @@ if defined?(WIN32OLE_EVENT)
end
def test_off_event_arg
- ev = WIN32OLE_EVENT.new(@db)
+ ev = WIN32OLE::Event.new(@db)
ev.on_event('WillConnect'){handler1}
ev.off_event('WillConnect')
@db.open
@@ -313,7 +317,7 @@ if defined?(WIN32OLE_EVENT)
end
def test_off_event_arg2
- ev = WIN32OLE_EVENT.new(@db)
+ ev = WIN32OLE::Event.new(@db)
ev.on_event('WillConnect'){handler1}
ev.on_event('ConnectComplete'){handler1}
ev.off_event('WillConnect')
@@ -323,7 +327,7 @@ if defined?(WIN32OLE_EVENT)
end
def test_off_event_sym_arg
- ev = WIN32OLE_EVENT.new(@db)
+ ev = WIN32OLE::Event.new(@db)
ev.on_event('WillConnect'){handler1}
ev.off_event(:WillConnect)
@db.open
@@ -382,7 +386,7 @@ if defined?(WIN32OLE_EVENT)
end
def test_handler1
- ev = WIN32OLE_EVENT.new(@db)
+ ev = WIN32OLE::Event.new(@db)
h1 = Handler1.new
ev.handler = h1
@db.open
@@ -395,7 +399,7 @@ if defined?(WIN32OLE_EVENT)
end
def test_handler2
- ev = WIN32OLE_EVENT.new(@db)
+ ev = WIN32OLE::Event.new(@db)
h2 = Handler2.new
ev.handler = h2
@db.open
diff --git a/test/win32ole/test_win32ole_method.rb b/test/win32ole/test_win32ole_method.rb
index a0e113e7f0..c84c4027ff 100644
--- a/test/win32ole/test_win32ole_method.rb
+++ b/test/win32ole/test_win32ole_method.rb
@@ -5,42 +5,46 @@ rescue LoadError
end
require "test/unit"
-if defined?(WIN32OLE_METHOD)
+if defined?(WIN32OLE::Method)
class TestWIN32OLE_METHOD < Test::Unit::TestCase
def setup
- ole_type = WIN32OLE_TYPE.new("Microsoft Shell Controls And Automation", "Shell")
- @m_open = WIN32OLE_METHOD.new(ole_type, "open")
- @m_namespace = WIN32OLE_METHOD.new(ole_type, "namespace")
- @m_parent = WIN32OLE_METHOD.new(ole_type, "parent")
- @m_invoke = WIN32OLE_METHOD.new(ole_type, "invoke")
- @m_browse_for_folder = WIN32OLE_METHOD.new(ole_type, "BrowseForFolder")
+ ole_type = WIN32OLE::Type.new("Microsoft Shell Controls And Automation", "Shell")
+ @m_open = WIN32OLE::Method.new(ole_type, "open")
+ @m_namespace = WIN32OLE::Method.new(ole_type, "namespace")
+ @m_parent = WIN32OLE::Method.new(ole_type, "parent")
+ @m_invoke = WIN32OLE::Method.new(ole_type, "invoke")
+ @m_browse_for_folder = WIN32OLE::Method.new(ole_type, "BrowseForFolder")
- ole_type = WIN32OLE_TYPE.new("Microsoft Scripting Runtime", "File")
- @m_file_name = WIN32OLE_METHOD.new(ole_type, "name")
+ ole_type = WIN32OLE::Type.new("Microsoft Scripting Runtime", "File")
+ @m_file_name = WIN32OLE::Method.new(ole_type, "name")
+ end
+
+ def test_toplevel_constants_backward_compatibility
+ assert_equal(WIN32OLE::Method, ::WIN32OLE_METHOD)
end
def test_initialize
- ole_type = WIN32OLE_TYPE.new("Microsoft Shell Controls And Automation", "Shell")
+ ole_type = WIN32OLE::Type.new("Microsoft Shell Controls And Automation", "Shell")
assert_raise(TypeError) {
- WIN32OLE_METHOD.new(1, 2)
+ WIN32OLE::Method.new(1, 2)
}
assert_raise(ArgumentError) {
- WIN32OLE_METHOD.new("foo")
+ WIN32OLE::Method.new("foo")
}
assert_raise(ArgumentError) {
- WIN32OLE_METHOD.new(ole_type)
+ WIN32OLE::Method.new(ole_type)
}
- assert_raise(WIN32OLERuntimeError) {
- WIN32OLE_METHOD.new(ole_type, "NonExistMethod")
+ assert_raise(WIN32OLE::RuntimeError) {
+ WIN32OLE::Method.new(ole_type, "NonExistMethod")
}
assert_raise(TypeError) {
- WIN32OLE_METHOD.new(ole_type, 1)
+ WIN32OLE::Method.new(ole_type, 1)
}
- method = WIN32OLE_METHOD.new(ole_type, "Open")
- assert_instance_of(WIN32OLE_METHOD, method)
- method = WIN32OLE_METHOD.new(ole_type, "open")
- assert_instance_of(WIN32OLE_METHOD, method)
+ method = WIN32OLE::Method.new(ole_type, "Open")
+ assert_instance_of(WIN32OLE::Method, method)
+ method = WIN32OLE::Method.new(ole_type, "open")
+ assert_instance_of(WIN32OLE::Method, method)
end
def test_name
@@ -119,7 +123,7 @@ if defined?(WIN32OLE_METHOD)
params = @m_browse_for_folder.params
assert_instance_of(Array, params)
assert_equal(4, params.size)
- assert_instance_of(WIN32OLE_PARAM, params[0])
+ assert_instance_of(WIN32OLE::Param, params[0])
end
def test_to_s
@@ -127,7 +131,7 @@ if defined?(WIN32OLE_METHOD)
end
def test_inspect
- assert_equal("#<WIN32OLE_METHOD:NameSpace>", @m_namespace.inspect)
+ assert_equal("#<WIN32OLE::Method:NameSpace>", @m_namespace.inspect)
end
end
diff --git a/test/win32ole/test_win32ole_method_event.rb b/test/win32ole/test_win32ole_method_event.rb
index 6dad6ff2b4..ab409a1f2d 100644
--- a/test/win32ole/test_win32ole_method_event.rb
+++ b/test/win32ole/test_win32ole_method_event.rb
@@ -5,19 +5,19 @@ end
require 'test/unit'
-if defined?(WIN32OLE_METHOD)
+if defined?(WIN32OLE::Method)
require_relative 'available_ole'
class TestWIN32OLE_METHOD_EVENT < Test::Unit::TestCase
unless AvailableOLE.sysmon_available?
def test_dummy_for_skip_message
- skip 'System Monitor Control is not available'
+ omit 'System Monitor Control is not available'
end
else
def setup
- ole_type = WIN32OLE_TYPE.new('System Monitor Control', 'SystemMonitor')
- @on_dbl_click = WIN32OLE_METHOD.new(ole_type, 'OnDblClick')
- ole_type = WIN32OLE_TYPE.new('Microsoft Shell Controls And Automation', 'Shell')
- @namespace = WIN32OLE_METHOD.new(ole_type, 'namespace')
+ ole_type = WIN32OLE::Type.new('System Monitor Control', 'SystemMonitor')
+ @on_dbl_click = WIN32OLE::Method.new(ole_type, 'OnDblClick')
+ ole_type = WIN32OLE::Type.new('Microsoft Shell Controls And Automation', 'Shell')
+ @namespace = WIN32OLE::Method.new(ole_type, 'namespace')
end
def test_event?
diff --git a/test/win32ole/test_win32ole_param.rb b/test/win32ole/test_win32ole_param.rb
index 09452d1927..13ca9d0cfb 100644
--- a/test/win32ole/test_win32ole_param.rb
+++ b/test/win32ole/test_win32ole_param.rb
@@ -5,45 +5,49 @@ rescue LoadError
end
require "test/unit"
-if defined?(WIN32OLE_PARAM)
+if defined?(WIN32OLE::Param)
class TestWIN32OLE_PARAM < Test::Unit::TestCase
def setup
- ole_type = WIN32OLE_TYPE.new("Microsoft Shell Controls And Automation", "ShellLinkObject")
- m_geticonlocation = WIN32OLE_METHOD.new(ole_type, "GetIconLocation")
+ ole_type = WIN32OLE::Type.new("Microsoft Shell Controls And Automation", "ShellLinkObject")
+ m_geticonlocation = WIN32OLE::Method.new(ole_type, "GetIconLocation")
@param_pbs = m_geticonlocation.params[0]
- ole_type = WIN32OLE_TYPE.new("Microsoft HTML Object Library", "FontNames")
- m_count = WIN32OLE_METHOD.new(ole_type, "Count")
+ ole_type = WIN32OLE::Type.new("Microsoft HTML Object Library", "FontNames")
+ m_count = WIN32OLE::Method.new(ole_type, "Count")
@param_p = m_count.params[0]
- ole_type = WIN32OLE_TYPE.new("Microsoft Scripting Runtime", "FileSystemObject")
- m_copyfile = WIN32OLE_METHOD.new(ole_type, "CopyFile")
+ ole_type = WIN32OLE::Type.new("Microsoft Scripting Runtime", "FileSystemObject")
+ m_copyfile = WIN32OLE::Method.new(ole_type, "CopyFile")
@param_source = m_copyfile.params[0]
@param_overwritefiles = m_copyfile.params[2]
- ole_type = WIN32OLE_TYPE.new("Microsoft Scripting Runtime", "Dictionary")
- m_add = WIN32OLE_METHOD.new(ole_type, "Add")
+ ole_type = WIN32OLE::Type.new("Microsoft Scripting Runtime", "Dictionary")
+ m_add = WIN32OLE::Method.new(ole_type, "Add")
@param_key = m_add.params[0]
end
+ def test_constants_backward_compatibility
+ assert_equal(WIN32OLE::Param, ::WIN32OLE_PARAM)
+ end
+
def test_s_new
assert_raise(ArgumentError) {
- WIN32OLE_PARAM.new("hoge")
+ WIN32OLE::Param.new("hoge")
}
- ole_type = WIN32OLE_TYPE.new("Microsoft Scripting Runtime", "FileSystemObject")
- m_copyfile = WIN32OLE_METHOD.new(ole_type, "CopyFile")
+ ole_type = WIN32OLE::Type.new("Microsoft Scripting Runtime", "FileSystemObject")
+ m_copyfile = WIN32OLE::Method.new(ole_type, "CopyFile")
assert_raise(IndexError) {
- WIN32OLE_PARAM.new(m_copyfile, 4);
+ WIN32OLE::Param.new(m_copyfile, 4);
}
assert_raise(IndexError) {
- WIN32OLE_PARAM.new(m_copyfile, 0);
+ WIN32OLE::Param.new(m_copyfile, 0);
}
- param = WIN32OLE_PARAM.new(m_copyfile, 3)
+ param = WIN32OLE::Param.new(m_copyfile, 3)
assert_equal("OverWriteFiles", param.name)
- assert_equal(WIN32OLE_PARAM, param.class)
+ assert_equal(WIN32OLE::Param, param.class)
assert_equal(true, param.default)
- assert_equal("#<WIN32OLE_PARAM:OverWriteFiles=true>", param.inspect)
+ assert_equal("#<WIN32OLE::Param:OverWriteFiles=true>", param.inspect)
end
def test_name
@@ -91,8 +95,8 @@ if defined?(WIN32OLE_PARAM)
end
def test_inspect
- assert_equal("#<WIN32OLE_PARAM:Source>", @param_source.inspect)
- assert_equal("#<WIN32OLE_PARAM:OverWriteFiles=true>", @param_overwritefiles.inspect)
+ assert_equal("#<WIN32OLE::Param:Source>", @param_source.inspect)
+ assert_equal("#<WIN32OLE::Param:OverWriteFiles=true>", @param_overwritefiles.inspect)
end
end
end
diff --git a/test/win32ole/test_win32ole_param_event.rb b/test/win32ole/test_win32ole_param_event.rb
index 64812e567d..f5a16ead76 100644
--- a/test/win32ole/test_win32ole_param_event.rb
+++ b/test/win32ole/test_win32ole_param_event.rb
@@ -5,7 +5,7 @@ end
require 'test/unit'
-if defined?(WIN32OLE_PARAM)
+if defined?(WIN32OLE::Param)
require_relative 'available_ole'
class TestWIN32OLE_PARAM_EVENT < Test::Unit::TestCase
@@ -23,7 +23,7 @@ if defined?(WIN32OLE_PARAM)
end
else
def test_dummy_for_skip_message
- skip 'ActiveX Data Object Library and MS XML not found'
+ omit 'ActiveX Data Object Library and MS XML not found'
end
end
end
diff --git a/test/win32ole/test_win32ole_record.rb b/test/win32ole/test_win32ole_record.rb
index 7d6c3fb4af..49205ce53d 100644
--- a/test/win32ole/test_win32ole_record.rb
+++ b/test/win32ole/test_win32ole_record.rb
@@ -65,18 +65,24 @@ End Class
=end
-if defined?(WIN32OLE_RECORD)
+if defined?(WIN32OLE::Record)
+ class TestWIN32OLE_RECORD < Test::Unit::TestCase
+ def test_toplevel_constants_backward_compatibility
+ assert_equal(WIN32OLE::Record, ::WIN32OLE_RECORD)
+ end
+ end
+
def rbcomtest_exist?
WIN32OLE.new(PROGID_RBCOMTEST)
true
- rescue WIN32OLERuntimeError
+ rescue WIN32OLE::RuntimeError
false
end
class TestWIN32OLE_RECORD_BY_RBCOMTEST < Test::Unit::TestCase
unless rbcomtest_exist?
def test_dummy_for_skip_message
- skip "#{PROGID_RBCOMTEST} for WIN32OLE_RECORD test is not installed"
+ omit "#{PROGID_RBCOMTEST} for WIN32OLE::Record test is not installed"
end
else
def setup
@@ -84,42 +90,42 @@ if defined?(WIN32OLE_RECORD)
end
def test_s_new_from_win32ole
- rec = WIN32OLE_RECORD.new('Book', @obj)
+ rec = WIN32OLE::Record.new('Book', @obj)
assert(rec)
- assert_instance_of(WIN32OLE_RECORD, rec)
+ assert_instance_of(WIN32OLE::Record, rec)
end
def test_s_new_from_win32ole_typelib
tlib = @obj.ole_typelib
- rec = WIN32OLE_RECORD.new('Book', tlib)
+ rec = WIN32OLE::Record.new('Book', tlib)
assert(rec)
- assert_instance_of(WIN32OLE_RECORD, rec)
+ assert_instance_of(WIN32OLE::Record, rec)
end
def test_s_new_raise
- assert_raise(WIN32OLERuntimeError) {
- WIN32OLE_RECORD.new('NonExistRecordName', @obj)
+ assert_raise(WIN32OLE::RuntimeError) {
+ WIN32OLE::Record.new('NonExistRecordName', @obj)
}
assert_raise(ArgumentError) {
- WIN32OLE_RECORD.new
+ WIN32OLE::Record.new
}
assert_raise(ArgumentError) {
- WIN32OLE_RECORD.new('NonExistRecordName')
+ WIN32OLE::Record.new('NonExistRecordName')
}
end
def test_to_h
- rec = WIN32OLE_RECORD.new('Book', @obj)
+ rec = WIN32OLE::Record.new('Book', @obj)
assert_equal({'title'=>nil, 'cost'=>nil}, rec.to_h)
end
def test_typename
- rec = WIN32OLE_RECORD.new('Book', @obj)
+ rec = WIN32OLE::Record.new('Book', @obj)
assert_equal('Book', rec.typename)
end
def test_method_missing_getter
- rec = WIN32OLE_RECORD.new('Book', @obj)
+ rec = WIN32OLE::Record.new('Book', @obj)
assert_equal(nil, rec.title)
assert_raise(KeyError) {
rec.non_exist_name
@@ -127,14 +133,14 @@ if defined?(WIN32OLE_RECORD)
end
def test_method_missing_setter
- rec = WIN32OLE_RECORD.new('Book', @obj)
+ rec = WIN32OLE::Record.new('Book', @obj)
rec.title = "Ruby Book"
assert_equal("Ruby Book", rec.title)
end
def test_get_record_from_comserver
rec = @obj.getBook
- assert_instance_of(WIN32OLE_RECORD, rec)
+ assert_instance_of(WIN32OLE::Record, rec)
assert_equal("The Ruby Book", rec.title)
assert_equal(20, rec.cost)
end
@@ -143,16 +149,16 @@ if defined?(WIN32OLE_RECORD)
rec = @obj.getBooks
assert_instance_of(Array, rec)
assert_equal(2, rec.size)
- assert_instance_of(WIN32OLE_RECORD, rec[0])
+ assert_instance_of(WIN32OLE::Record, rec[0])
assert_equal("The CRuby Book", rec[0].title)
assert_equal(30, rec[0].cost)
- assert_instance_of(WIN32OLE_RECORD, rec[1])
+ assert_instance_of(WIN32OLE::Record, rec[1])
assert_equal("The JRuby Book", rec[1].title)
assert_equal(40, rec[1].cost)
end
def test_pass_record_parameter
- rec = WIN32OLE_RECORD.new('Book', @obj)
+ rec = WIN32OLE::Record.new('Book', @obj)
rec.title = "Ruby Book"
rec.cost = 60
book = @obj.getVer2BookByValBook(rec)
@@ -161,23 +167,23 @@ if defined?(WIN32OLE_RECORD)
end
def test_pass_variant_parameter_byref
- obj = WIN32OLE_VARIANT.new(nil, WIN32OLE::VARIANT::VT_VARIANT|WIN32OLE::VARIANT::VT_BYREF)
+ obj = WIN32OLE::Variant.new(nil, WIN32OLE::VARIANT::VT_VARIANT|WIN32OLE::VARIANT::VT_BYREF)
@obj.getBookByRefBook(obj)
- assert_instance_of(WIN32OLE_RECORD, obj.value)
+ assert_instance_of(WIN32OLE::Record, obj.value)
book = obj.value
assert_equal("The Ruby Reference Book2", book.title)
assert_equal(44, book.cost)
end
def test_pass_record_parameter_byref
- book = WIN32OLE_RECORD.new('Book', @obj)
+ book = WIN32OLE::Record.new('Book', @obj)
@obj.getBookByRefBook(book)
assert_equal("The Ruby Reference Book2", book.title)
assert_equal(44, book.cost)
end
def test_pass_and_get_record_parameter_byref
- book = WIN32OLE_RECORD.new('Book', @obj)
+ book = WIN32OLE::Record.new('Book', @obj)
book.title = "Ruby Book"
book.cost = 60
@obj.getVer3BookByRefBook(book)
@@ -186,13 +192,13 @@ if defined?(WIN32OLE_RECORD)
end
def test_ole_instance_variable_get
- obj = WIN32OLE_RECORD.new('Book', @obj)
+ obj = WIN32OLE::Record.new('Book', @obj)
assert_equal(nil, obj.ole_instance_variable_get(:title))
assert_equal(nil, obj.ole_instance_variable_get('title'))
end
def test_ole_instance_variable_set
- book = WIN32OLE_RECORD.new('Book', @obj)
+ book = WIN32OLE::Record.new('Book', @obj)
book.ole_instance_variable_set(:title, "Ruby Book")
assert_equal("Ruby Book", book.title)
book.ole_instance_variable_set('title', "Ruby Book2")
@@ -200,8 +206,8 @@ if defined?(WIN32OLE_RECORD)
end
def test_inspect
- book = WIN32OLE_RECORD.new('Book', @obj)
- assert_equal(%q[#<WIN32OLE_RECORD(Book) {"title"=>nil, "cost"=>nil}>], book.inspect)
+ book = WIN32OLE::Record.new('Book', @obj)
+ assert_equal(%q[#<WIN32OLE::Record(Book) {"title"=>nil, "cost"=>nil}>], book.inspect)
end
end
end
diff --git a/test/win32ole/test_win32ole_type.rb b/test/win32ole/test_win32ole_type.rb
index 485b390d5c..9abcd68c9b 100644
--- a/test/win32ole/test_win32ole_type.rb
+++ b/test/win32ole/test_win32ole_type.rb
@@ -5,11 +5,14 @@ rescue LoadError
end
require "test/unit"
-if defined?(WIN32OLE_TYPE)
+if defined?(WIN32OLE::Type)
class TestWIN32OLE_TYPE < Test::Unit::TestCase
+ def test_toplevel_constants_backward_compatibility
+ assert_equal(WIN32OLE::Type, ::WIN32OLE_TYPE)
+ end
def test_s_progids
- progids = WIN32OLE_TYPE.progids
+ progids = WIN32OLE::Type.progids
assert_instance_of(Array, progids)
assert(progids.size > 0)
assert_instance_of(String, progids[0])
@@ -18,25 +21,25 @@ if defined?(WIN32OLE_TYPE)
def test_initialize
assert_raise(ArgumentError) {
- WIN32OLE_TYPE.new
+ WIN32OLE::Type.new
}
assert_raise(ArgumentError) {
- WIN32OLE_TYPE.new("foo")
+ WIN32OLE::Type.new("foo")
}
assert_raise(TypeError) {
- WIN32OLE_TYPE.new(1, 2)
+ WIN32OLE::Type.new(1, 2)
}
assert_raise(TypeError) {
- WIN32OLE_TYPE.new("Microsoft Shell Controls And Automation", 1)
+ WIN32OLE::Type.new("Microsoft Shell Controls And Automation", 1)
}
- assert_raise(WIN32OLERuntimeError) {
- WIN32OLE_TYPE.new("Microsoft Shell Controls And Automation", "foo")
+ assert_raise(WIN32OLE::RuntimeError) {
+ WIN32OLE::Type.new("Microsoft Shell Controls And Automation", "foo")
}
- assert_raise(WIN32OLERuntimeError) {
- WIN32OLE_TYPE.new("Microsoft Shell Controls And Automation", "Application")
+ assert_raise(WIN32OLE::RuntimeError) {
+ WIN32OLE::Type.new("Microsoft Shell Controls And Automation", "Application")
}
- ole_type = WIN32OLE_TYPE.new("Microsoft Shell Controls And Automation", "Shell")
- assert_instance_of(WIN32OLE_TYPE, ole_type)
+ ole_type = WIN32OLE::Type.new("Microsoft Shell Controls And Automation", "Shell")
+ assert_instance_of(WIN32OLE::Type, ole_type)
assert_equal("Shell", ole_type.name)
assert_equal("Class", ole_type.ole_type)
assert_equal("{13709620-C279-11CE-A49E-444553540000}", ole_type.guid)
@@ -53,8 +56,8 @@ if defined?(WIN32OLE_TYPE)
assert_equal([], ole_type.variables)
assert(ole_type.ole_methods.select{|m|/NameSpace/i =~ m.name}.size > 0)
- ole_type2 = WIN32OLE_TYPE.new("{13709620-C279-11CE-A49E-444553540000}", "Shell")
- assert_instance_of(WIN32OLE_TYPE, ole_type)
+ ole_type2 = WIN32OLE::Type.new("{13709620-C279-11CE-A49E-444553540000}", "Shell")
+ assert_instance_of(WIN32OLE::Type, ole_type)
assert_equal(ole_type.name, ole_type2.name)
assert_equal(ole_type.ole_type, ole_type2.ole_type)
assert_equal(ole_type.guid, ole_type2.guid)
@@ -76,7 +79,7 @@ if defined?(WIN32OLE_TYPE)
end
def setup
- @ole_type = WIN32OLE_TYPE.new("Microsoft Shell Controls And Automation", "Shell")
+ @ole_type = WIN32OLE::Type.new("Microsoft Shell Controls And Automation", "Shell")
end
def test_name
@@ -97,7 +100,7 @@ if defined?(WIN32OLE_TYPE)
def test_visible?
assert(@ole_type.visible?)
- ole_type = WIN32OLE_TYPE.new("Microsoft Shell Controls And Automation", "IShellDispatch")
+ ole_type = WIN32OLE::Type.new("Microsoft Shell Controls And Automation", "IShellDispatch")
assert(!ole_type.visible?)
end
@@ -107,13 +110,13 @@ if defined?(WIN32OLE_TYPE)
def test_major_version
assert_equal(0, @ole_type.major_version)
- # ole_type = WIN32OLE_TYPE.new("Microsoft Word 11.0 Object Library", "Documents")
+ # ole_type = WIN32OLE::Type.new("Microsoft Word 11.0 Object Library", "Documents")
# assert_equal(8, ole_type.major_version)
end
def test_minor_version
assert_equal(0, @ole_type.minor_version)
- # ole_type = WIN32OLE_TYPE.new("Microsoft Word 11.0 Object Library", "Documents")
+ # ole_type = WIN32OLE::Type.new("Microsoft Word 11.0 Object Library", "Documents")
# assert_equal(3, ole_type.minor_version)
end
@@ -126,20 +129,20 @@ if defined?(WIN32OLE_TYPE)
end
def test_src_type
- ole_type = WIN32OLE_TYPE.new("Microsoft Scripting Runtime", "DriveTypeConst")
+ ole_type = WIN32OLE::Type.new("Microsoft Scripting Runtime", "DriveTypeConst")
assert_match(/__MIDL___MIDL_itf_scrrun_/, ole_type.src_type)
assert_equal(nil, @ole_type.src_type)
end
def test_helpfile
assert_equal("", @ole_type.helpfile)
- ole_type = WIN32OLE_TYPE.new("Microsoft Scripting Runtime", "Folders")
+ ole_type = WIN32OLE::Type.new("Microsoft Scripting Runtime", "Folders")
assert_match(/VBENLR98\.CHM$/i, ole_type.helpfile)
end
def test_helpcontext
assert_equal(0, @ole_type.helpcontext)
- ole_type = WIN32OLE_TYPE.new("Microsoft Scripting Runtime", "Folders")
+ ole_type = WIN32OLE::Type.new("Microsoft Scripting Runtime", "Folders")
assert_equal(2181929, ole_type.helpcontext)
end
@@ -148,25 +151,25 @@ if defined?(WIN32OLE_TYPE)
assert_instance_of(Array, variables)
assert(variables.size == 0)
- ole_type = WIN32OLE_TYPE.new("Microsoft Shell Controls And Automation", "ShellSpecialFolderConstants")
+ ole_type = WIN32OLE::Type.new("Microsoft Shell Controls And Automation", "ShellSpecialFolderConstants")
variables = ole_type.variables
assert_instance_of(Array, variables)
assert(variables.size > 0)
- assert_instance_of(WIN32OLE_VARIABLE, variables[0])
+ assert_instance_of(WIN32OLE::Variable, variables[0])
end
def test_ole_methods
methods = @ole_type.ole_methods
assert_instance_of(Array, methods)
assert(methods.size > 0)
- assert_instance_of(WIN32OLE_METHOD, methods[0]);
+ assert_instance_of(WIN32OLE::Method, methods[0]);
assert(methods.collect{|m| m.name}.include?("Application"))
end
def test_ole_typelib
tlib = @ole_type.ole_typelib
- assert_instance_of(WIN32OLE_TYPELIB, tlib)
+ assert_instance_of(WIN32OLE::TypeLib, tlib)
assert_equal("Microsoft Shell Controls And Automation", tlib.name)
end
@@ -178,20 +181,20 @@ if defined?(WIN32OLE_TYPE)
end
def test_inspect
- assert_equal("#<WIN32OLE_TYPE:Shell>", @ole_type.inspect)
+ assert_equal("#<WIN32OLE::Type:Shell>", @ole_type.inspect)
end
- # WIN32OLE_TYPE.typelibs will be obsoleted.
+ # WIN32OLE::Type.typelibs will be obsoleted.
def test_s_typelibs
- tlibs = WIN32OLE_TYPE.typelibs.sort
- tlibs2 = WIN32OLE_TYPELIB.typelibs.collect{|t|t.name}.sort
+ tlibs = WIN32OLE::Type.typelibs.sort
+ tlibs2 = WIN32OLE::TypeLib.typelibs.collect{|t|t.name}.sort
assert_equal(tlibs2, tlibs)
end
- # WIN32OLE_TYPE.ole_classes will be obsoleted.
+ # WIN32OLE::Type.ole_classes will be obsoleted.
def test_s_ole_classes
- ots1 = WIN32OLE_TYPE.ole_classes("Microsoft Shell Controls And Automation")
- ots2 = WIN32OLE_TYPELIB.new("Microsoft Shell Controls And Automation").ole_types
+ ots1 = WIN32OLE::Type.ole_classes("Microsoft Shell Controls And Automation")
+ ots2 = WIN32OLE::TypeLib.new("Microsoft Shell Controls And Automation").ole_types
otns1 = ots1.collect{|t| t.name}.sort
otns2 = ots2.collect{|t| t.name}.sort
assert_equal(otns2, otns1)
diff --git a/test/win32ole/test_win32ole_type_event.rb b/test/win32ole/test_win32ole_type_event.rb
index ad2de54e59..5d1c9fc44c 100644
--- a/test/win32ole/test_win32ole_type_event.rb
+++ b/test/win32ole/test_win32ole_type_event.rb
@@ -6,18 +6,18 @@ end
require 'test/unit'
-if defined?(WIN32OLE_TYPE)
+if defined?(WIN32OLE::Type)
require_relative 'available_ole'
class TestWIN32OLE_TYPE_EVENT < Test::Unit::TestCase
unless AvailableOLE.sysmon_available?
def test_dummy_for_skip_message
- skip 'System Monitor Control is not available'
+ omit 'System Monitor Control is not available'
end
else
def setup
- @ole_type = WIN32OLE_TYPE.new('System Monitor Control', 'SystemMonitor')
+ @ole_type = WIN32OLE::Type.new('System Monitor Control', 'SystemMonitor')
end
def test_implemented_ole_types
diff --git a/test/win32ole/test_win32ole_typelib.rb b/test/win32ole/test_win32ole_typelib.rb
index 321c019e53..31d6122756 100644
--- a/test/win32ole/test_win32ole_typelib.rb
+++ b/test/win32ole/test_win32ole_typelib.rb
@@ -5,10 +5,14 @@ rescue LoadError
end
require "test/unit"
-if defined?(WIN32OLE_TYPELIB)
+if defined?(WIN32OLE::TypeLib)
class TestWIN32OLE_TYPELIB < Test::Unit::TestCase
+ def test_toplevel_constants_backward_compatibility
+ assert_equal(WIN32OLE::TypeLib, ::WIN32OLE_TYPELIB)
+ end
+
def test_s_typelibs
- tlibs = WIN32OLE_TYPELIB.typelibs
+ tlibs = WIN32OLE::TypeLib.typelibs
assert_instance_of(Array, tlibs)
assert(tlibs.size > 0)
tlib = tlibs.find {|t| t.name == "Microsoft Shell Controls And Automation"}
@@ -17,100 +21,100 @@ if defined?(WIN32OLE_TYPELIB)
def test_initialize
assert_raise(ArgumentError) {
- WIN32OLE_TYPELIB.new(1,2,3,4)
+ WIN32OLE::TypeLib.new(1,2,3,4)
}
assert_raise(TypeError) {
- WIN32OLE_TYPELIB.new(100)
+ WIN32OLE::TypeLib.new(100)
}
- tlib = WIN32OLE_TYPELIB.new("Microsoft Shell Controls And Automation")
- assert_instance_of(WIN32OLE_TYPELIB, tlib)
+ tlib = WIN32OLE::TypeLib.new("Microsoft Shell Controls And Automation")
+ assert_instance_of(WIN32OLE::TypeLib, tlib)
- tlib = WIN32OLE_TYPELIB.new("Microsoft Shell Controls And Automation", 1.0)
- assert_instance_of(WIN32OLE_TYPELIB, tlib)
+ tlib = WIN32OLE::TypeLib.new("Microsoft Shell Controls And Automation", 1.0)
+ assert_instance_of(WIN32OLE::TypeLib, tlib)
- tlib = WIN32OLE_TYPELIB.new("Microsoft Shell Controls And Automation", 1, 0)
- assert_instance_of(WIN32OLE_TYPELIB, tlib)
+ tlib = WIN32OLE::TypeLib.new("Microsoft Shell Controls And Automation", 1, 0)
+ assert_instance_of(WIN32OLE::TypeLib, tlib)
guid = tlib.guid
- tlib_by_guid = WIN32OLE_TYPELIB.new(guid, 1, 0)
- assert_instance_of(WIN32OLE_TYPELIB, tlib_by_guid)
+ tlib_by_guid = WIN32OLE::TypeLib.new(guid, 1, 0)
+ assert_instance_of(WIN32OLE::TypeLib, tlib_by_guid)
assert_equal("Microsoft Shell Controls And Automation" , tlib_by_guid.name)
path = tlib.path
- tlib_by_path = WIN32OLE_TYPELIB.new(path)
+ tlib_by_path = WIN32OLE::TypeLib.new(path)
assert_equal("Microsoft Shell Controls And Automation" , tlib_by_path.name)
- assert_raise(WIN32OLERuntimeError) {
- WIN32OLE_TYPELIB.new("Non Exist Type Library")
+ assert_raise(WIN32OLE::RuntimeError) {
+ WIN32OLE::TypeLib.new("Non Exist Type Library")
}
end
# #Bug:3907 [ruby-dev:42338]
def test_initialize_with_REG_EXPAND_SZ
- tlib = WIN32OLE_TYPELIB.new("Disk Management Snap-In Object Library")
- assert_instance_of(WIN32OLE_TYPELIB, tlib)
+ tlib = WIN32OLE::TypeLib.new("Disk Management Snap-In Object Library")
+ assert_instance_of(WIN32OLE::TypeLib, tlib)
end
def test_guid
- tlib = WIN32OLE_TYPELIB.new("Microsoft Shell Controls And Automation")
+ tlib = WIN32OLE::TypeLib.new("Microsoft Shell Controls And Automation")
assert_equal("{50A7E9B0-70EF-11D1-B75A-00A0C90564FE}", tlib.guid)
end
def test_name
- tlib = WIN32OLE_TYPELIB.new("Microsoft Shell Controls And Automation")
+ tlib = WIN32OLE::TypeLib.new("Microsoft Shell Controls And Automation")
assert_equal("Microsoft Shell Controls And Automation", tlib.name)
- tlib = WIN32OLE_TYPELIB.new("{50A7E9B0-70EF-11D1-B75A-00A0C90564FE}")
+ tlib = WIN32OLE::TypeLib.new("{50A7E9B0-70EF-11D1-B75A-00A0C90564FE}")
assert_equal("Microsoft Shell Controls And Automation", tlib.name)
end
def test_version
- tlib = WIN32OLE_TYPELIB.new("Microsoft Shell Controls And Automation")
+ tlib = WIN32OLE::TypeLib.new("Microsoft Shell Controls And Automation")
assert_equal("1.0", tlib.version)
end
def test_major_version
- tlib = WIN32OLE_TYPELIB.new("Microsoft Shell Controls And Automation")
+ tlib = WIN32OLE::TypeLib.new("Microsoft Shell Controls And Automation")
assert_equal(1, tlib.major_version)
end
def test_minor_version
- tlib = WIN32OLE_TYPELIB.new("Microsoft Shell Controls And Automation")
+ tlib = WIN32OLE::TypeLib.new("Microsoft Shell Controls And Automation")
assert_equal(0, tlib.minor_version)
end
def test_path
- tlib = WIN32OLE_TYPELIB.new("Microsoft Shell Controls And Automation")
+ tlib = WIN32OLE::TypeLib.new("Microsoft Shell Controls And Automation")
assert_match(/shell32\.dll$/i, tlib.path)
end
def test_visible?
- tlib = WIN32OLE_TYPELIB.new("Microsoft Shell Controls And Automation")
+ tlib = WIN32OLE::TypeLib.new("Microsoft Shell Controls And Automation")
assert(tlib.visible?)
end
def test_library_name
- tlib = WIN32OLE_TYPELIB.new("Microsoft Shell Controls And Automation")
+ tlib = WIN32OLE::TypeLib.new("Microsoft Shell Controls And Automation")
assert_equal("Shell32", tlib.library_name)
end
def test_to_s
- tlib = WIN32OLE_TYPELIB.new("Microsoft Shell Controls And Automation")
+ tlib = WIN32OLE::TypeLib.new("Microsoft Shell Controls And Automation")
assert_equal("Microsoft Shell Controls And Automation", tlib.to_s)
end
def test_ole_types
- tlib = WIN32OLE_TYPELIB.new("Microsoft Shell Controls And Automation")
+ tlib = WIN32OLE::TypeLib.new("Microsoft Shell Controls And Automation")
ole_types = tlib.ole_types
assert_instance_of(Array, ole_types)
assert(ole_types.size > 0)
- assert_instance_of(WIN32OLE_TYPE, ole_types[0])
+ assert_instance_of(WIN32OLE::Type, ole_types[0])
end
def test_inspect
- tlib = WIN32OLE_TYPELIB.new("Microsoft Shell Controls And Automation")
- assert_equal("#<WIN32OLE_TYPELIB:Microsoft Shell Controls And Automation>", tlib.inspect)
+ tlib = WIN32OLE::TypeLib.new("Microsoft Shell Controls And Automation")
+ assert_equal("#<WIN32OLE::TypeLib:Microsoft Shell Controls And Automation>", tlib.inspect)
end
end
diff --git a/test/win32ole/test_win32ole_variable.rb b/test/win32ole/test_win32ole_variable.rb
index 826029e0a8..646cf68915 100644
--- a/test/win32ole/test_win32ole_variable.rb
+++ b/test/win32ole/test_win32ole_variable.rb
@@ -5,17 +5,25 @@ rescue LoadError
end
require "test/unit"
-if defined?(WIN32OLE_VARIABLE)
+if defined?(WIN32OLE::Variable)
class TestWIN32OLE_VARIABLE < Test::Unit::TestCase
def setup
- ole_type = WIN32OLE_TYPE.new("Microsoft Shell Controls And Automation", "ShellSpecialFolderConstants")
+ ole_type = WIN32OLE::Type.new("Microsoft Shell Controls And Automation", "ShellSpecialFolderConstants")
@var1 = ole_type.variables.find {|v| v.name == 'ssfDESKTOP'}
- variables = WIN32OLE_TYPE.new("Microsoft Windows Installer Object Library", "Installer").variables
+ variables = WIN32OLE::Type.new("Microsoft Windows Installer Object Library", "Installer").variables
@var2 = variables.find {|v| v.name == 'UILevel'}
end
+ def test_toplevel_constants_backward_compatibility
+ assert_equal(WIN32OLE::Variable, ::WIN32OLE_VARIABLE)
+ end
+
+ def test_initialize
+ assert_raise(TypeError) {WIN32OLE::Variable.new}
+ end
+
def test_name
assert_equal('ssfDESKTOP', @var1.name)
end
@@ -54,8 +62,8 @@ if defined?(WIN32OLE_VARIABLE)
end
def test_inspect
- assert_equal("#<WIN32OLE_VARIABLE:ssfDESKTOP=0>", @var1.inspect)
- assert_equal("#<WIN32OLE_VARIABLE:UILevel=nil>", @var2.inspect)
+ assert_equal("#<WIN32OLE::Variable:ssfDESKTOP=0>", @var1.inspect)
+ assert_equal("#<WIN32OLE::Variable:UILevel=nil>", @var2.inspect)
end
end
diff --git a/test/win32ole/test_win32ole_variant.rb b/test/win32ole/test_win32ole_variant.rb
index 390534b5e1..13b9a229a5 100644
--- a/test/win32ole/test_win32ole_variant.rb
+++ b/test/win32ole/test_win32ole_variant.rb
@@ -5,7 +5,7 @@ rescue LoadError
end
require "test/unit"
-if defined?(WIN32OLE_VARIANT)
+if defined?(WIN32OLE::Variant)
class TestWIN32OLE_VARIANT < Test::Unit::TestCase
def setup
@@ -17,36 +17,40 @@ if defined?(WIN32OLE_VARIANT)
WIN32OLE.locale = @orglocale
end
+ def test_toplevel_constants_backward_compatibility
+ assert_equal(WIN32OLE::Variant, ::WIN32OLE_VARIANT)
+ end
+
def test_s_new
- obj = WIN32OLE_VARIANT.new('foo')
- assert_instance_of(WIN32OLE_VARIANT, obj)
+ obj = WIN32OLE::Variant.new('foo')
+ assert_instance_of(WIN32OLE::Variant, obj)
end
def test_s_new_exc
assert_raise(TypeError) {
- WIN32OLE_VARIANT.new(/foo/)
+ WIN32OLE::Variant.new(/foo/)
}
end
def test_s_new_ary
- obj = WIN32OLE_VARIANT.new([1])
- assert_instance_of(WIN32OLE_VARIANT, obj)
+ obj = WIN32OLE::Variant.new([1])
+ assert_instance_of(WIN32OLE::Variant, obj)
assert_raise(TypeError) {
- WIN32OLE_VARIANT.new([/foo/])
+ WIN32OLE::Variant.new([/foo/])
}
end
def test_s_new_no_argument
pat = /wrong number of arguments \(.*\b0\b.* 1\.\.3\)/
assert_raise_with_message(ArgumentError, pat) do
- WIN32OLE_VARIANT.new
+ WIN32OLE::Variant.new
end
end
def test_s_new_one_argument
ex = nil
begin
- WIN32OLE_VARIANT.new('foo')
+ WIN32OLE::Variant.new('foo')
rescue
ex = $!
end
@@ -54,247 +58,247 @@ if defined?(WIN32OLE_VARIANT)
end
def test_s_new_with_nil
- obj = WIN32OLE_VARIANT.new(nil, WIN32OLE::VARIANT::VT_I2)
+ obj = WIN32OLE::Variant.new(nil, WIN32OLE::VARIANT::VT_I2)
assert_equal(0, obj.value)
assert_equal(WIN32OLE::VARIANT::VT_I2, obj.vartype)
- obj = WIN32OLE_VARIANT.new(nil, WIN32OLE::VARIANT::VT_I4)
+ obj = WIN32OLE::Variant.new(nil, WIN32OLE::VARIANT::VT_I4)
assert_equal(0, obj.value)
assert_equal(WIN32OLE::VARIANT::VT_I4, obj.vartype)
- obj = WIN32OLE_VARIANT.new(nil, WIN32OLE::VARIANT::VT_R4)
+ obj = WIN32OLE::Variant.new(nil, WIN32OLE::VARIANT::VT_R4)
assert_equal(0, obj.value)
assert_equal(WIN32OLE::VARIANT::VT_R4, obj.vartype)
- obj = WIN32OLE_VARIANT.new(nil, WIN32OLE::VARIANT::VT_R8)
+ obj = WIN32OLE::Variant.new(nil, WIN32OLE::VARIANT::VT_R8)
assert_equal(0, obj.value)
assert_equal(WIN32OLE::VARIANT::VT_R8, obj.vartype)
- obj = WIN32OLE_VARIANT.new(nil, WIN32OLE::VARIANT::VT_CY)
+ obj = WIN32OLE::Variant.new(nil, WIN32OLE::VARIANT::VT_CY)
assert_equal("0", obj.value)
assert_equal(WIN32OLE::VARIANT::VT_CY, obj.vartype)
- obj = WIN32OLE_VARIANT.new(nil, WIN32OLE::VARIANT::VT_DATE)
+ obj = WIN32OLE::Variant.new(nil, WIN32OLE::VARIANT::VT_DATE)
assert_equal(Time.new(1899,12,30), obj.value)
assert_equal(WIN32OLE::VARIANT::VT_DATE, obj.vartype)
- obj = WIN32OLE_VARIANT.new(nil, WIN32OLE::VARIANT::VT_BSTR)
+ obj = WIN32OLE::Variant.new(nil, WIN32OLE::VARIANT::VT_BSTR)
assert_equal("", obj.value)
assert_equal(WIN32OLE::VARIANT::VT_BSTR, obj.vartype)
- obj = WIN32OLE_VARIANT.new(nil, WIN32OLE::VARIANT::VT_DISPATCH)
+ obj = WIN32OLE::Variant.new(nil, WIN32OLE::VARIANT::VT_DISPATCH)
assert_nil(obj.value)
assert_equal(WIN32OLE::VARIANT::VT_DISPATCH, obj.vartype)
- obj = WIN32OLE_VARIANT.new(nil, WIN32OLE::VARIANT::VT_BOOL)
+ obj = WIN32OLE::Variant.new(nil, WIN32OLE::VARIANT::VT_BOOL)
assert_equal(false, obj.value)
assert_equal(WIN32OLE::VARIANT::VT_BOOL, obj.vartype)
- obj = WIN32OLE_VARIANT.new(nil, WIN32OLE::VARIANT::VT_VARIANT)
+ obj = WIN32OLE::Variant.new(nil, WIN32OLE::VARIANT::VT_VARIANT)
assert_nil(obj.value)
assert_equal(WIN32OLE::VARIANT::VT_VARIANT, obj.vartype)
- obj = WIN32OLE_VARIANT.new(nil, WIN32OLE::VARIANT::VT_I1)
+ obj = WIN32OLE::Variant.new(nil, WIN32OLE::VARIANT::VT_I1)
assert_equal(0, obj.value)
assert_equal(WIN32OLE::VARIANT::VT_I1, obj.vartype)
- obj = WIN32OLE_VARIANT.new(nil, WIN32OLE::VARIANT::VT_UI1)
+ obj = WIN32OLE::Variant.new(nil, WIN32OLE::VARIANT::VT_UI1)
assert_equal(0, obj.value)
assert_equal(WIN32OLE::VARIANT::VT_UI1, obj.vartype)
- obj = WIN32OLE_VARIANT.new(nil, WIN32OLE::VARIANT::VT_UI2)
+ obj = WIN32OLE::Variant.new(nil, WIN32OLE::VARIANT::VT_UI2)
assert_equal(0, obj.value)
assert_equal(WIN32OLE::VARIANT::VT_UI2, obj.vartype)
- obj = WIN32OLE_VARIANT.new(nil, WIN32OLE::VARIANT::VT_UI4)
+ obj = WIN32OLE::Variant.new(nil, WIN32OLE::VARIANT::VT_UI4)
assert_equal(0, obj.value)
assert_equal(WIN32OLE::VARIANT::VT_UI4, obj.vartype)
if defined?(WIN32OLE::VARIANT::VT_I8)
- obj = WIN32OLE_VARIANT.new(nil, WIN32OLE::VARIANT::VT_I8)
+ obj = WIN32OLE::Variant.new(nil, WIN32OLE::VARIANT::VT_I8)
assert_equal(0, obj.value)
assert_equal(WIN32OLE::VARIANT::VT_I8, obj.vartype)
end
if defined?(WIN32OLE::VARIANT::VT_UI8)
- obj = WIN32OLE_VARIANT.new(nil, WIN32OLE::VARIANT::VT_UI8)
+ obj = WIN32OLE::Variant.new(nil, WIN32OLE::VARIANT::VT_UI8)
assert_equal(0, obj.value)
assert_equal(WIN32OLE::VARIANT::VT_UI8, obj.vartype)
end
- obj = WIN32OLE_VARIANT.new(nil, WIN32OLE::VARIANT::VT_INT)
+ obj = WIN32OLE::Variant.new(nil, WIN32OLE::VARIANT::VT_INT)
assert_equal(0, obj.value)
assert_equal(WIN32OLE::VARIANT::VT_INT, obj.vartype)
- obj = WIN32OLE_VARIANT.new(nil, WIN32OLE::VARIANT::VT_UINT)
+ obj = WIN32OLE::Variant.new(nil, WIN32OLE::VARIANT::VT_UINT)
assert_equal(0, obj.value)
assert_equal(WIN32OLE::VARIANT::VT_UINT, obj.vartype)
end
def test_s_new_with_non_nil
- obj = WIN32OLE_VARIANT.new(2, WIN32OLE::VARIANT::VT_I2)
+ obj = WIN32OLE::Variant.new(2, WIN32OLE::VARIANT::VT_I2)
assert_equal(2, obj.value)
assert_equal(WIN32OLE::VARIANT::VT_I2, obj.vartype)
- obj = WIN32OLE_VARIANT.new(3, WIN32OLE::VARIANT::VT_I4)
+ obj = WIN32OLE::Variant.new(3, WIN32OLE::VARIANT::VT_I4)
assert_equal(3, obj.value)
assert_equal(WIN32OLE::VARIANT::VT_I4, obj.vartype)
- obj = WIN32OLE_VARIANT.new(4.5, WIN32OLE::VARIANT::VT_R4)
+ obj = WIN32OLE::Variant.new(4.5, WIN32OLE::VARIANT::VT_R4)
assert_equal(4.5, obj.value)
assert_equal(WIN32OLE::VARIANT::VT_R4, obj.vartype)
- obj = WIN32OLE_VARIANT.new(5.5, WIN32OLE::VARIANT::VT_R8)
+ obj = WIN32OLE::Variant.new(5.5, WIN32OLE::VARIANT::VT_R8)
assert_equal(5.5, obj.value)
assert_equal(WIN32OLE::VARIANT::VT_R8, obj.vartype)
- obj = WIN32OLE_VARIANT.new(600, WIN32OLE::VARIANT::VT_CY)
+ obj = WIN32OLE::Variant.new(600, WIN32OLE::VARIANT::VT_CY)
assert_equal("600", obj.value)
assert_equal(WIN32OLE::VARIANT::VT_CY, obj.vartype)
- obj = WIN32OLE_VARIANT.new("2001-06-15 12:17:34", WIN32OLE::VARIANT::VT_DATE)
+ obj = WIN32OLE::Variant.new("2001-06-15 12:17:34", WIN32OLE::VARIANT::VT_DATE)
assert_equal(Time.new(2001,06,15,12,17,34), obj.value)
assert_equal(WIN32OLE::VARIANT::VT_DATE, obj.vartype)
- obj = WIN32OLE_VARIANT.new("foo", WIN32OLE::VARIANT::VT_BSTR)
+ obj = WIN32OLE::Variant.new("foo", WIN32OLE::VARIANT::VT_BSTR)
assert_equal("foo", obj.value)
assert_equal(WIN32OLE::VARIANT::VT_BSTR, obj.vartype)
- obj = WIN32OLE_VARIANT.new(true, WIN32OLE::VARIANT::VT_BOOL)
+ obj = WIN32OLE::Variant.new(true, WIN32OLE::VARIANT::VT_BOOL)
assert_equal(true, obj.value)
assert_equal(WIN32OLE::VARIANT::VT_BOOL, obj.vartype)
- obj = WIN32OLE_VARIANT.new(2, WIN32OLE::VARIANT::VT_I1)
+ obj = WIN32OLE::Variant.new(2, WIN32OLE::VARIANT::VT_I1)
assert_equal(2, obj.value)
assert_equal(WIN32OLE::VARIANT::VT_I1, obj.vartype)
- obj = WIN32OLE_VARIANT.new(3, WIN32OLE::VARIANT::VT_UI1)
+ obj = WIN32OLE::Variant.new(3, WIN32OLE::VARIANT::VT_UI1)
assert_equal(3, obj.value)
assert_equal(WIN32OLE::VARIANT::VT_UI1, obj.vartype)
- obj = WIN32OLE_VARIANT.new(4, WIN32OLE::VARIANT::VT_UI2)
+ obj = WIN32OLE::Variant.new(4, WIN32OLE::VARIANT::VT_UI2)
assert_equal(4, obj.value)
assert_equal(WIN32OLE::VARIANT::VT_UI2, obj.vartype)
- obj = WIN32OLE_VARIANT.new(5, WIN32OLE::VARIANT::VT_UI4)
+ obj = WIN32OLE::Variant.new(5, WIN32OLE::VARIANT::VT_UI4)
assert_equal(5, obj.value)
assert_equal(WIN32OLE::VARIANT::VT_UI4, obj.vartype)
if defined?(WIN32OLE::VARIANT::VT_I8)
- obj = WIN32OLE_VARIANT.new(-123456789012345, WIN32OLE::VARIANT::VT_I8)
+ obj = WIN32OLE::Variant.new(-123456789012345, WIN32OLE::VARIANT::VT_I8)
assert_equal(-123456789012345, obj.value)
assert_equal(WIN32OLE::VARIANT::VT_I8, obj.vartype)
end
if defined?(WIN32OLE::VARIANT::VT_UI8)
- obj = WIN32OLE_VARIANT.new(123456789012345, WIN32OLE::VARIANT::VT_UI8)
+ obj = WIN32OLE::Variant.new(123456789012345, WIN32OLE::VARIANT::VT_UI8)
assert_equal(123456789012345, obj.value)
assert_equal(WIN32OLE::VARIANT::VT_UI8, obj.vartype)
end
- obj = WIN32OLE_VARIANT.new(4, WIN32OLE::VARIANT::VT_INT)
+ obj = WIN32OLE::Variant.new(4, WIN32OLE::VARIANT::VT_INT)
assert_equal(4, obj.value)
assert_equal(WIN32OLE::VARIANT::VT_INT, obj.vartype)
- obj = WIN32OLE_VARIANT.new(5, WIN32OLE::VARIANT::VT_UINT)
+ obj = WIN32OLE::Variant.new(5, WIN32OLE::VARIANT::VT_UINT)
assert_equal(5, obj.value)
assert_equal(WIN32OLE::VARIANT::VT_UINT, obj.vartype)
end
def test_s_new_with_non_nil_byref
- obj = WIN32OLE_VARIANT.new(2, WIN32OLE::VARIANT::VT_I2|WIN32OLE::VARIANT::VT_BYREF)
+ obj = WIN32OLE::Variant.new(2, WIN32OLE::VARIANT::VT_I2|WIN32OLE::VARIANT::VT_BYREF)
assert_equal(2, obj.value)
assert_equal(WIN32OLE::VARIANT::VT_I2|WIN32OLE::VARIANT::VT_BYREF, obj.vartype)
- obj = WIN32OLE_VARIANT.new(3, WIN32OLE::VARIANT::VT_I4|WIN32OLE::VARIANT::VT_BYREF)
+ obj = WIN32OLE::Variant.new(3, WIN32OLE::VARIANT::VT_I4|WIN32OLE::VARIANT::VT_BYREF)
assert_equal(3, obj.value)
assert_equal(WIN32OLE::VARIANT::VT_I4|WIN32OLE::VARIANT::VT_BYREF, obj.vartype)
- obj = WIN32OLE_VARIANT.new(4.5, WIN32OLE::VARIANT::VT_R4|WIN32OLE::VARIANT::VT_BYREF)
+ obj = WIN32OLE::Variant.new(4.5, WIN32OLE::VARIANT::VT_R4|WIN32OLE::VARIANT::VT_BYREF)
assert_equal(4.5, obj.value)
assert_equal(WIN32OLE::VARIANT::VT_R4|WIN32OLE::VARIANT::VT_BYREF, obj.vartype)
- obj = WIN32OLE_VARIANT.new(5.5, WIN32OLE::VARIANT::VT_R8|WIN32OLE::VARIANT::VT_BYREF)
+ obj = WIN32OLE::Variant.new(5.5, WIN32OLE::VARIANT::VT_R8|WIN32OLE::VARIANT::VT_BYREF)
assert_equal(5.5, obj.value)
assert_equal(WIN32OLE::VARIANT::VT_R8|WIN32OLE::VARIANT::VT_BYREF, obj.vartype)
- obj = WIN32OLE_VARIANT.new(600, WIN32OLE::VARIANT::VT_CY|WIN32OLE::VARIANT::VT_BYREF)
+ obj = WIN32OLE::Variant.new(600, WIN32OLE::VARIANT::VT_CY|WIN32OLE::VARIANT::VT_BYREF)
assert_equal("600", obj.value)
assert_equal(WIN32OLE::VARIANT::VT_CY|WIN32OLE::VARIANT::VT_BYREF, obj.vartype)
- obj = WIN32OLE_VARIANT.new("2001-06-15 12:17:34", WIN32OLE::VARIANT::VT_DATE|WIN32OLE::VARIANT::VT_BYREF)
+ obj = WIN32OLE::Variant.new("2001-06-15 12:17:34", WIN32OLE::VARIANT::VT_DATE|WIN32OLE::VARIANT::VT_BYREF)
assert_equal(Time.new(2001,06,15,12,17,34), obj.value)
assert_equal(WIN32OLE::VARIANT::VT_DATE|WIN32OLE::VARIANT::VT_BYREF, obj.vartype)
- obj = WIN32OLE_VARIANT.new("foo", WIN32OLE::VARIANT::VT_BSTR|WIN32OLE::VARIANT::VT_BYREF)
+ obj = WIN32OLE::Variant.new("foo", WIN32OLE::VARIANT::VT_BSTR|WIN32OLE::VARIANT::VT_BYREF)
assert_equal("foo", obj.value)
assert_equal(WIN32OLE::VARIANT::VT_BSTR|WIN32OLE::VARIANT::VT_BYREF, obj.vartype)
- obj = WIN32OLE_VARIANT.new(true, WIN32OLE::VARIANT::VT_BOOL|WIN32OLE::VARIANT::VT_BYREF)
+ obj = WIN32OLE::Variant.new(true, WIN32OLE::VARIANT::VT_BOOL|WIN32OLE::VARIANT::VT_BYREF)
assert_equal(true, obj.value)
assert_equal(WIN32OLE::VARIANT::VT_BOOL|WIN32OLE::VARIANT::VT_BYREF, obj.vartype)
- obj = WIN32OLE_VARIANT.new(2, WIN32OLE::VARIANT::VT_I1|WIN32OLE::VARIANT::VT_BYREF)
+ obj = WIN32OLE::Variant.new(2, WIN32OLE::VARIANT::VT_I1|WIN32OLE::VARIANT::VT_BYREF)
assert_equal(2, obj.value)
assert_equal(WIN32OLE::VARIANT::VT_I1|WIN32OLE::VARIANT::VT_BYREF, obj.vartype)
- obj = WIN32OLE_VARIANT.new(3, WIN32OLE::VARIANT::VT_UI1|WIN32OLE::VARIANT::VT_BYREF)
+ obj = WIN32OLE::Variant.new(3, WIN32OLE::VARIANT::VT_UI1|WIN32OLE::VARIANT::VT_BYREF)
assert_equal(3, obj.value)
assert_equal(WIN32OLE::VARIANT::VT_UI1|WIN32OLE::VARIANT::VT_BYREF, obj.vartype)
- obj = WIN32OLE_VARIANT.new(4, WIN32OLE::VARIANT::VT_UI2|WIN32OLE::VARIANT::VT_BYREF)
+ obj = WIN32OLE::Variant.new(4, WIN32OLE::VARIANT::VT_UI2|WIN32OLE::VARIANT::VT_BYREF)
assert_equal(4, obj.value)
assert_equal(WIN32OLE::VARIANT::VT_UI2|WIN32OLE::VARIANT::VT_BYREF, obj.vartype)
- obj = WIN32OLE_VARIANT.new(5, WIN32OLE::VARIANT::VT_UI4|WIN32OLE::VARIANT::VT_BYREF)
+ obj = WIN32OLE::Variant.new(5, WIN32OLE::VARIANT::VT_UI4|WIN32OLE::VARIANT::VT_BYREF)
assert_equal(5, obj.value)
assert_equal(WIN32OLE::VARIANT::VT_UI4|WIN32OLE::VARIANT::VT_BYREF, obj.vartype)
- obj = WIN32OLE_VARIANT.new(4, WIN32OLE::VARIANT::VT_INT|WIN32OLE::VARIANT::VT_BYREF)
+ obj = WIN32OLE::Variant.new(4, WIN32OLE::VARIANT::VT_INT|WIN32OLE::VARIANT::VT_BYREF)
assert_equal(4, obj.value)
assert_equal(WIN32OLE::VARIANT::VT_INT|WIN32OLE::VARIANT::VT_BYREF, obj.vartype)
- obj = WIN32OLE_VARIANT.new(5, WIN32OLE::VARIANT::VT_UINT|WIN32OLE::VARIANT::VT_BYREF)
+ obj = WIN32OLE::Variant.new(5, WIN32OLE::VARIANT::VT_UINT|WIN32OLE::VARIANT::VT_BYREF)
assert_equal(5, obj.value)
assert_equal(WIN32OLE::VARIANT::VT_UINT|WIN32OLE::VARIANT::VT_BYREF, obj.vartype)
end
def test_s_new_with_i8_byref
- obj = WIN32OLE_VARIANT.new(-123456789012345, WIN32OLE::VARIANT::VT_I8|WIN32OLE::VARIANT::VT_BYREF)
+ obj = WIN32OLE::Variant.new(-123456789012345, WIN32OLE::VARIANT::VT_I8|WIN32OLE::VARIANT::VT_BYREF)
assert_equal(-123456789012345, obj.value)
assert_equal(WIN32OLE::VARIANT::VT_I8|WIN32OLE::VARIANT::VT_BYREF, obj.vartype)
end
def test_s_new_with_ui8_byref
- obj = WIN32OLE_VARIANT.new(123456789012345, WIN32OLE::VARIANT::VT_UI8|WIN32OLE::VARIANT::VT_BYREF)
+ obj = WIN32OLE::Variant.new(123456789012345, WIN32OLE::VARIANT::VT_UI8|WIN32OLE::VARIANT::VT_BYREF)
assert_equal(123456789012345, obj.value)
assert_equal(WIN32OLE::VARIANT::VT_UI8|WIN32OLE::VARIANT::VT_BYREF, obj.vartype)
end
def test_value
- obj = WIN32OLE_VARIANT.new('foo')
+ obj = WIN32OLE::Variant.new('foo')
assert_equal('foo', obj.value)
end
def test_s_new_2_argument
- obj = WIN32OLE_VARIANT.new('foo', WIN32OLE::VARIANT::VT_BSTR|WIN32OLE::VARIANT::VT_BYREF)
+ obj = WIN32OLE::Variant.new('foo', WIN32OLE::VARIANT::VT_BSTR|WIN32OLE::VARIANT::VT_BYREF)
assert_equal('foo', obj.value);
end
def test_s_new_2_argument2
- obj = WIN32OLE_VARIANT.new('foo', WIN32OLE::VARIANT::VT_BSTR)
+ obj = WIN32OLE::Variant.new('foo', WIN32OLE::VARIANT::VT_BSTR)
assert_equal('foo', obj.value);
end
def test_s_new_dispatch_array
vt = WIN32OLE::VARIANT::VT_ARRAY|WIN32OLE::VARIANT::VT_DISPATCH
- obj = WIN32OLE_VARIANT.new(nil, vt)
+ obj = WIN32OLE::Variant.new(nil, vt)
assert_equal(vt, obj.vartype)
assert_nil(obj.value)
vt = WIN32OLE::VARIANT::VT_ARRAY|WIN32OLE::VARIANT::VT_DISPATCH|WIN32OLE::VARIANT::VT_BYREF
- obj = WIN32OLE_VARIANT.new(nil, vt)
+ obj = WIN32OLE::Variant.new(nil, vt)
assert_equal(vt, obj.vartype)
assert_nil(obj.value)
end
@@ -302,29 +306,29 @@ if defined?(WIN32OLE_VARIANT)
def test_s_new_array
# should not occur stack over flow
ar = (1..500000).to_a.map{|i| [i]}
- ar2 = WIN32OLE_VARIANT.new(ar)
+ ar2 = WIN32OLE::Variant.new(ar)
assert_equal(ar, ar2.value)
end
def test_s_new_vt_record_exc
- # VT_RECORD (= 36) should not be allowed in WIN32OLE_VARIANT#new
+ # VT_RECORD (= 36) should not be allowed in WIN32OLE::Variant#new
assert_raise(ArgumentError) {
- WIN32OLE_VARIANT.new(nil, 36)
+ WIN32OLE::Variant.new(nil, 36)
}
end
def test_s_array
- obj = WIN32OLE_VARIANT.array([2,3], WIN32OLE::VARIANT::VT_I4)
- assert_instance_of(WIN32OLE_VARIANT, obj)
+ obj = WIN32OLE::Variant.array([2,3], WIN32OLE::VARIANT::VT_I4)
+ assert_instance_of(WIN32OLE::Variant, obj)
assert_equal(WIN32OLE::VARIANT::VT_I4|WIN32OLE::VARIANT::VT_ARRAY, obj.vartype)
assert_equal([[0, 0, 0],[0, 0, 0]], obj.value)
- obj = WIN32OLE_VARIANT.array([2,3], WIN32OLE::VARIANT::VT_I4|WIN32OLE::VARIANT::VT_BYREF)
+ obj = WIN32OLE::Variant.array([2,3], WIN32OLE::VARIANT::VT_I4|WIN32OLE::VARIANT::VT_BYREF)
assert_equal(WIN32OLE::VARIANT::VT_I4|WIN32OLE::VARIANT::VT_BYREF|WIN32OLE::VARIANT::VT_ARRAY, obj.vartype)
assert_equal([[0, 0, 0],[0, 0, 0]], obj.value)
- obj = WIN32OLE_VARIANT.array([2,3], WIN32OLE::VARIANT::VT_I4|WIN32OLE::VARIANT::VT_ARRAY)
- assert_instance_of(WIN32OLE_VARIANT, obj)
+ obj = WIN32OLE::Variant.array([2,3], WIN32OLE::VARIANT::VT_I4|WIN32OLE::VARIANT::VT_ARRAY)
+ assert_instance_of(WIN32OLE::Variant, obj)
assert_equal(WIN32OLE::VARIANT::VT_I4|WIN32OLE::VARIANT::VT_ARRAY, obj.vartype)
assert_equal([[0, 0, 0],[0, 0, 0]], obj.value)
@@ -334,60 +338,60 @@ if defined?(WIN32OLE_VARIANT)
obj[0,1] = "13.2"
assert_equal([[10, 13, 0],[0, 0, 0]], obj.value)
- obj = WIN32OLE_VARIANT.array([3, 2], WIN32OLE::VARIANT::VT_VARIANT)
+ obj = WIN32OLE::Variant.array([3, 2], WIN32OLE::VARIANT::VT_VARIANT)
obj[0,0] = 10
obj[0,1] = "string"
obj[1,0] = 12.735
assert_equal([[10, "string"],[12.735, nil],[nil,nil]], obj.value)
- obj = WIN32OLE_VARIANT.array([2,3], WIN32OLE::VARIANT::VT_DISPATCH)
+ obj = WIN32OLE::Variant.array([2,3], WIN32OLE::VARIANT::VT_DISPATCH)
assert_equal([[nil, nil, nil],[nil,nil,nil]], obj.value)
end
def test_s_array_exc
assert_raise(TypeError) {
- WIN32OLE_VARIANT.array(2, WIN32OLE::VARIANT::VT_I4)
+ WIN32OLE::Variant.array(2, WIN32OLE::VARIANT::VT_I4)
}
end
def test_conversion_num2str
- obj = WIN32OLE_VARIANT.new(124, WIN32OLE::VARIANT::VT_BSTR)
+ obj = WIN32OLE::Variant.new(124, WIN32OLE::VARIANT::VT_BSTR)
assert_equal("124", obj.value);
end
def test_conversion_float2int
- obj = WIN32OLE_VARIANT.new(12.345, WIN32OLE::VARIANT::VT_I4)
+ obj = WIN32OLE::Variant.new(12.345, WIN32OLE::VARIANT::VT_I4)
assert_equal(12, obj.value)
- obj = WIN32OLE_VARIANT.new(12.345, WIN32OLE::VARIANT::VT_I4|WIN32OLE::VARIANT::VT_BYREF)
+ obj = WIN32OLE::Variant.new(12.345, WIN32OLE::VARIANT::VT_I4|WIN32OLE::VARIANT::VT_BYREF)
assert_equal(12, obj.value)
end
def test_conversion_str2num
- obj = WIN32OLE_VARIANT.new("12.345", WIN32OLE::VARIANT::VT_R8)
+ obj = WIN32OLE::Variant.new("12.345", WIN32OLE::VARIANT::VT_R8)
assert_equal(12.345, obj.value)
end
def test_conversion_ole_variant2ole_variant
- obj = WIN32OLE_VARIANT.new("12.345", WIN32OLE::VARIANT::VT_R4)
- obj = WIN32OLE_VARIANT.new(obj, WIN32OLE::VARIANT::VT_I4)
+ obj = WIN32OLE::Variant.new("12.345", WIN32OLE::VARIANT::VT_R4)
+ obj = WIN32OLE::Variant.new(obj, WIN32OLE::VARIANT::VT_I4)
assert_equal(12, obj.value)
end
def test_conversion_str2date
- obj = WIN32OLE_VARIANT.new("2004-12-24 12:24:45", WIN32OLE::VARIANT::VT_DATE)
+ obj = WIN32OLE::Variant.new("2004-12-24 12:24:45", WIN32OLE::VARIANT::VT_DATE)
assert_equal(Time.new(2004,12,24,12,24,45), obj.value)
end
def test_conversion_time2date
dt = Time.mktime(2004, 12, 24, 12, 24, 45)
- obj = WIN32OLE_VARIANT.new(dt, WIN32OLE::VARIANT::VT_DATE)
+ obj = WIN32OLE::Variant.new(dt, WIN32OLE::VARIANT::VT_DATE)
assert_equal(dt, obj.value)
end
def test_conversion_dbl2date_with_msec
# Date is "2014/8/27 12:34:56.789"
- obj = WIN32OLE_VARIANT.new(41878.524268391200167, WIN32OLE::VARIANT::VT_DATE)
+ obj = WIN32OLE::Variant.new(41878.524268391200167, WIN32OLE::VARIANT::VT_DATE)
t = obj.value
assert_equal("2014-08-27 12:34:56", t.strftime('%Y-%m-%d %H:%M:%S'))
assert_in_delta(0.789, t.nsec / 1000000000.0, 0.001)
@@ -396,7 +400,7 @@ if defined?(WIN32OLE_VARIANT)
def test_conversion_time2date_with_msec
t0 = Time.new(2014, 8, 27, 12, 34, 56)
t0 += 0.789
- t1 = WIN32OLE_VARIANT.new(t0).value
+ t1 = WIN32OLE::Variant.new(t0).value
# The t0.nsec is 789000000 and t1.nsec is 789000465
# because of error range by conversion Time between VT_DATE Variant.
@@ -406,7 +410,7 @@ if defined?(WIN32OLE_VARIANT)
t0 = Time.new(2014, 8, 27, 12, 34, 56)
t0 += 0.999999999
- t1 = WIN32OLE_VARIANT.new(t0).value
+ t1 = WIN32OLE::Variant.new(t0).value
msg = "Expected:#{t0.strftime('%Y-%m-%dT%H:%M:%S.%N')} but was:#{t1.strftime('%Y-%m-%dT%H:%M:%S.%N')}"
# The t0 is "2014/08/27 12:34.56.999999999" and
@@ -414,7 +418,7 @@ if defined?(WIN32OLE_VARIANT)
assert_in_delta(t0, t1, 0.001, msg)
t0 = Time.now
- t1 = WIN32OLE_VARIANT.new(t0).value
+ t1 = WIN32OLE::Variant.new(t0).value
msg = "Expected:#{t0.strftime('%Y-%m-%dT%H:%M:%S.%N')} but was:#{t1.strftime('%Y-%m-%dT%H:%M:%S.%N')}"
assert_in_delta(t0, t1, 0.001, msg)
end
@@ -426,110 +430,110 @@ if defined?(WIN32OLE_VARIANT)
# def test_conversion_time_nsec2date
# dt = Time.new(2004, 12,24, 12, 24, 45)
# dt += 0.1
- # obj = WIN32OLE_VARIANT.new(dt, WIN32OLE::VARIANT::VT_DATE)
+ # obj = WIN32OLE::Variant.new(dt, WIN32OLE::VARIANT::VT_DATE)
# assert_equal(dt, obj.value)
# end
def test_conversion_str2cy
begin
WIN32OLE.locale = 0x0411 # set locale Japanese
- rescue WIN32OLERuntimeError
- skip("Japanese locale is not installed")
+ rescue WIN32OLE::RuntimeError
+ omit("Japanese locale is not installed")
end
if WIN32OLE.locale == 0x0411
- obj = WIN32OLE_VARIANT.new("\\10,000", WIN32OLE::VARIANT::VT_CY)
+ obj = WIN32OLE::Variant.new("\\10,000", WIN32OLE::VARIANT::VT_CY)
assert_equal("10000", obj.value)
end
end
def test_create_vt_array
- obj = WIN32OLE_VARIANT.new([1.2, 2.3], WIN32OLE::VARIANT::VT_ARRAY|WIN32OLE::VARIANT::VT_R8)
+ obj = WIN32OLE::Variant.new([1.2, 2.3], WIN32OLE::VARIANT::VT_ARRAY|WIN32OLE::VARIANT::VT_R8)
assert_equal([1.2, 2.3], obj.value)
assert_equal(WIN32OLE::VARIANT::VT_ARRAY|WIN32OLE::VARIANT::VT_R8, obj.vartype)
- obj = WIN32OLE_VARIANT.new([1.2, 2.3], WIN32OLE::VARIANT::VT_ARRAY|WIN32OLE::VARIANT::VT_R8|WIN32OLE::VARIANT::VT_BYREF)
+ obj = WIN32OLE::Variant.new([1.2, 2.3], WIN32OLE::VARIANT::VT_ARRAY|WIN32OLE::VARIANT::VT_R8|WIN32OLE::VARIANT::VT_BYREF)
assert_equal([1.2, 2.3], obj.value)
assert_equal(WIN32OLE::VARIANT::VT_ARRAY|WIN32OLE::VARIANT::VT_R8|WIN32OLE::VARIANT::VT_BYREF, obj.vartype)
end
def test_create_vt_array2
- obj = WIN32OLE_VARIANT.new([1.2, "a"], WIN32OLE::VARIANT::VT_ARRAY)
+ obj = WIN32OLE::Variant.new([1.2, "a"], WIN32OLE::VARIANT::VT_ARRAY)
assert_equal([1.2, "a"], obj.value)
assert_equal(WIN32OLE::VARIANT::VT_ARRAY|WIN32OLE::VARIANT::VT_VARIANT, obj.vartype)
- obj = WIN32OLE_VARIANT.new([1.2, "a"])
+ obj = WIN32OLE::Variant.new([1.2, "a"])
assert_equal([1.2, "a"], obj.value)
assert_equal(WIN32OLE::VARIANT::VT_ARRAY|WIN32OLE::VARIANT::VT_VARIANT, obj.vartype)
end
def test_create_vt_nested_array
- obj = WIN32OLE_VARIANT.new([[1.2, "a", "b"], [3.4, "C", "D"]], WIN32OLE::VARIANT::VT_ARRAY)
+ obj = WIN32OLE::Variant.new([[1.2, "a", "b"], [3.4, "C", "D"]], WIN32OLE::VARIANT::VT_ARRAY)
assert_equal([[1.2, "a", "b"], [3.4, "C", "D"]], obj.value)
- obj = WIN32OLE_VARIANT.new([[1.2, "a", "b"], [3.4, "C", "D"]])
+ obj = WIN32OLE::Variant.new([[1.2, "a", "b"], [3.4, "C", "D"]])
assert_equal([[1.2, "a", "b"], [3.4, "C", "D"]], obj.value)
- obj = WIN32OLE_VARIANT.new([[1.2, "a", "b"], [3.4, "C", "D"], [5.6, "E", "F"]])
+ obj = WIN32OLE::Variant.new([[1.2, "a", "b"], [3.4, "C", "D"], [5.6, "E", "F"]])
assert_equal([[1.2, "a", "b"], [3.4, "C", "D"], [5.6, "E", "F"]], obj.value)
- obj = WIN32OLE_VARIANT.new([[[1.2], [3.4]], [[5.6], [7.8]], [[9.1],[9.2]]])
+ obj = WIN32OLE::Variant.new([[[1.2], [3.4]], [[5.6], [7.8]], [[9.1],[9.2]]])
assert_equal([[[1.2], [3.4]], [[5.6], [7.8]], [[9.1],[9.2]]], obj.value)
end
def test_create_vt_array3
- obj = WIN32OLE_VARIANT.new([])
+ obj = WIN32OLE::Variant.new([])
assert_equal([], obj.value)
- obj = WIN32OLE_VARIANT.new([[]])
+ obj = WIN32OLE::Variant.new([[]])
assert_equal([[]], obj.value)
- obj = WIN32OLE_VARIANT.new([[],[]])
+ obj = WIN32OLE::Variant.new([[],[]])
assert_equal([[],[]], obj.value)
- obj = WIN32OLE_VARIANT.new([], WIN32OLE::VARIANT::VT_ARRAY|WIN32OLE::VARIANT::VT_BYREF)
+ obj = WIN32OLE::Variant.new([], WIN32OLE::VARIANT::VT_ARRAY|WIN32OLE::VARIANT::VT_BYREF)
assert_equal([], obj.value)
- obj = WIN32OLE_VARIANT.new([[]], WIN32OLE::VARIANT::VT_ARRAY|WIN32OLE::VARIANT::VT_BYREF)
+ obj = WIN32OLE::Variant.new([[]], WIN32OLE::VARIANT::VT_ARRAY|WIN32OLE::VARIANT::VT_BYREF)
assert_equal([[]], obj.value)
- obj = WIN32OLE_VARIANT.new([[],[]], WIN32OLE::VARIANT::VT_ARRAY|WIN32OLE::VARIANT::VT_BYREF)
+ obj = WIN32OLE::Variant.new([[],[]], WIN32OLE::VARIANT::VT_ARRAY|WIN32OLE::VARIANT::VT_BYREF)
assert_equal([[],[]], obj.value)
end
def test_create_vt_array_nil
vartype = WIN32OLE::VARIANT::VT_ARRAY|WIN32OLE::VARIANT::VT_DISPATCH|WIN32OLE::VARIANT::VT_BYREF
- obj = WIN32OLE_VARIANT.new(nil, vartype)
+ obj = WIN32OLE::Variant.new(nil, vartype)
assert_nil(obj.value)
assert_equal(vartype, obj.vartype)
vartype = WIN32OLE::VARIANT::VT_ARRAY|WIN32OLE::VARIANT::VT_DISPATCH
- obj = WIN32OLE_VARIANT.new(nil, vartype)
+ obj = WIN32OLE::Variant.new(nil, vartype)
assert_nil(obj.value)
assert_equal(vartype, obj.vartype)
end
def test_create_vt_array_str
vartype = WIN32OLE::VARIANT::VT_ARRAY|WIN32OLE::VARIANT::VT_BSTR
- obj = WIN32OLE_VARIANT.new(["abc", "123"], vartype)
+ obj = WIN32OLE::Variant.new(["abc", "123"], vartype)
assert_equal(vartype, obj.vartype)
assert_equal(["abc", "123"], obj.value)
vartype = WIN32OLE::VARIANT::VT_ARRAY|WIN32OLE::VARIANT::VT_BYREF|WIN32OLE::VARIANT::VT_BSTR
- obj = WIN32OLE_VARIANT.new(["abc", "123"], vartype)
+ obj = WIN32OLE::Variant.new(["abc", "123"], vartype)
assert_equal(vartype, obj.vartype)
assert_equal(["abc", "123"], obj.value)
end
def test_create_vt_array_exc
exc = assert_raise(TypeError) {
- WIN32OLE_VARIANT.new("", WIN32OLE::VARIANT::VT_ARRAY)
+ WIN32OLE::Variant.new("", WIN32OLE::VARIANT::VT_ARRAY)
}
assert_match(/wrong argument type String \(expected Array\)/, exc.message)
end
def test_create_vt_array_str2ui1array
- obj = WIN32OLE_VARIANT.new("ABC", WIN32OLE::VARIANT::VT_ARRAY|WIN32OLE::VARIANT::VT_UI1)
+ obj = WIN32OLE::Variant.new("ABC", WIN32OLE::VARIANT::VT_ARRAY|WIN32OLE::VARIANT::VT_UI1)
assert_equal("ABC", obj.value)
obj.value = "DEF"
@@ -537,10 +541,10 @@ if defined?(WIN32OLE_VARIANT)
obj[0] = 71
assert_equal("GEF", obj.value)
- obj = WIN32OLE_VARIANT.new([65, 0].pack("C*"), WIN32OLE::VARIANT::VT_ARRAY|WIN32OLE::VARIANT::VT_UI1)
+ obj = WIN32OLE::Variant.new([65, 0].pack("C*"), WIN32OLE::VARIANT::VT_ARRAY|WIN32OLE::VARIANT::VT_UI1)
assert_equal([65, 0].pack("C*"), obj.value)
- obj = WIN32OLE_VARIANT.new("abc", WIN32OLE::VARIANT::VT_ARRAY|WIN32OLE::VARIANT::VT_UI1|WIN32OLE::VARIANT::VT_BYREF)
+ obj = WIN32OLE::Variant.new("abc", WIN32OLE::VARIANT::VT_ARRAY|WIN32OLE::VARIANT::VT_UI1|WIN32OLE::VARIANT::VT_BYREF)
assert_equal("abc", obj.value)
obj.value = "DEF"
assert_equal("DEF", obj.value)
@@ -551,19 +555,19 @@ if defined?(WIN32OLE_VARIANT)
end
def test_create_vt_array_int
- obj = WIN32OLE_VARIANT.new([65, 0], WIN32OLE::VARIANT::VT_ARRAY|WIN32OLE::VARIANT::VT_UI1)
+ obj = WIN32OLE::Variant.new([65, 0], WIN32OLE::VARIANT::VT_ARRAY|WIN32OLE::VARIANT::VT_UI1)
assert_equal([65, 0].pack("C*"), obj.value)
- obj = WIN32OLE_VARIANT.new([65, 0])
+ obj = WIN32OLE::Variant.new([65, 0])
assert_equal([65, 0], obj.value)
- obj = WIN32OLE_VARIANT.new([65, 0], WIN32OLE::VARIANT::VT_I2|WIN32OLE::VARIANT::VT_ARRAY)
+ obj = WIN32OLE::Variant.new([65, 0], WIN32OLE::VARIANT::VT_I2|WIN32OLE::VARIANT::VT_ARRAY)
assert_equal([65, 0], obj.value)
end
def test_vt_array_bracket
- obj = WIN32OLE_VARIANT.new([[1,2,3],[4,5,6]])
+ obj = WIN32OLE::Variant.new([[1,2,3],[4,5,6]])
assert_equal(1, obj[0,0])
assert_equal(2, obj[0,1])
assert_equal(3, obj[0,2])
@@ -571,10 +575,10 @@ if defined?(WIN32OLE_VARIANT)
assert_equal(5, obj[1,1])
assert_equal(6, obj[1,2])
- assert_raise(WIN32OLERuntimeError) {
+ assert_raise(WIN32OLE::RuntimeError) {
obj[0,4]
}
- assert_raise(WIN32OLERuntimeError) {
+ assert_raise(WIN32OLE::RuntimeError) {
obj[0,-1]
}
assert_raise(ArgumentError) {
@@ -585,10 +589,10 @@ if defined?(WIN32OLE_VARIANT)
obj[1,2] = 8
assert_equal([[7,2,3], [4,5,8]], obj.value)
- assert_raise(WIN32OLERuntimeError) {
+ assert_raise(WIN32OLE::RuntimeError) {
obj[0,4] = 9
}
- assert_raise(WIN32OLERuntimeError) {
+ assert_raise(WIN32OLE::RuntimeError) {
obj[0,-1] = 10
}
assert_raise(ArgumentError) {
@@ -597,60 +601,60 @@ if defined?(WIN32OLE_VARIANT)
end
def test_conversion_vt_date
- obj = WIN32OLE_VARIANT.new(-657434, WIN32OLE::VARIANT::VT_DATE)
+ obj = WIN32OLE::Variant.new(-657434, WIN32OLE::VARIANT::VT_DATE)
assert_equal(Time.new(100,1,1), obj.value)
- obj = WIN32OLE_VARIANT.new("1500/12/29 23:59:59", WIN32OLE::VARIANT::VT_DATE)
+ obj = WIN32OLE::Variant.new("1500/12/29 23:59:59", WIN32OLE::VARIANT::VT_DATE)
assert_equal(Time.new(1500,12,29,23,59,59), obj.value)
- obj = WIN32OLE_VARIANT.new("1500/12/30 00:00:00", WIN32OLE::VARIANT::VT_DATE)
+ obj = WIN32OLE::Variant.new("1500/12/30 00:00:00", WIN32OLE::VARIANT::VT_DATE)
assert_equal(Time.new(1500,12,30), obj.value)
- obj = WIN32OLE_VARIANT.new("1500/12/30 00:00:01", WIN32OLE::VARIANT::VT_DATE)
+ obj = WIN32OLE::Variant.new("1500/12/30 00:00:01", WIN32OLE::VARIANT::VT_DATE)
assert_equal(Time.new(1500,12,30,0,0,1), obj.value)
- obj = WIN32OLE_VARIANT.new("1899/12/29 23:59:59", WIN32OLE::VARIANT::VT_DATE)
+ obj = WIN32OLE::Variant.new("1899/12/29 23:59:59", WIN32OLE::VARIANT::VT_DATE)
assert_equal(Time.new(1899,12,29,23,59,59), obj.value)
- obj = WIN32OLE_VARIANT.new("1899/12/30 00:00:00", WIN32OLE::VARIANT::VT_DATE)
+ obj = WIN32OLE::Variant.new("1899/12/30 00:00:00", WIN32OLE::VARIANT::VT_DATE)
assert_equal(Time.new(1899,12,30), obj.value)
- obj = WIN32OLE_VARIANT.new("1899/12/30 00:00:01", WIN32OLE::VARIANT::VT_DATE)
+ obj = WIN32OLE::Variant.new("1899/12/30 00:00:01", WIN32OLE::VARIANT::VT_DATE)
assert_equal(Time.new(1899,12,30,0,0,1), obj.value)
- obj = WIN32OLE_VARIANT.new(0, WIN32OLE::VARIANT::VT_DATE)
+ obj = WIN32OLE::Variant.new(0, WIN32OLE::VARIANT::VT_DATE)
assert_equal(Time.new(1899,12,30), obj.value)
- obj = WIN32OLE_VARIANT.new("2008/12/29 23:59:59", WIN32OLE::VARIANT::VT_DATE)
+ obj = WIN32OLE::Variant.new("2008/12/29 23:59:59", WIN32OLE::VARIANT::VT_DATE)
assert_equal(Time.new(2008,12,29,23,59,59), obj.value)
- obj = WIN32OLE_VARIANT.new("2008/12/30 00:00:00", WIN32OLE::VARIANT::VT_DATE)
+ obj = WIN32OLE::Variant.new("2008/12/30 00:00:00", WIN32OLE::VARIANT::VT_DATE)
assert_equal(Time.new(2008,12,30,0,0,0), obj.value)
- obj = WIN32OLE_VARIANT.new("2008/12/30 00:00:01", WIN32OLE::VARIANT::VT_DATE)
+ obj = WIN32OLE::Variant.new("2008/12/30 00:00:01", WIN32OLE::VARIANT::VT_DATE)
assert_equal(Time.new(2008,12,30,0,0,1), obj.value)
- obj = WIN32OLE_VARIANT.new("9999/12/31 23:59:59", WIN32OLE::VARIANT::VT_DATE)
+ obj = WIN32OLE::Variant.new("9999/12/31 23:59:59", WIN32OLE::VARIANT::VT_DATE)
assert_equal(Time.new(9999,12,31,23,59,59), obj.value)
end
def test_create_nil_dispatch
- var = WIN32OLE_VARIANT.new(nil, WIN32OLE::VARIANT::VT_DISPATCH)
+ var = WIN32OLE::Variant.new(nil, WIN32OLE::VARIANT::VT_DISPATCH)
assert_nil(var.value)
end
def test_create_variant_byref
- obj = WIN32OLE_VARIANT.new("Str", WIN32OLE::VARIANT::VT_VARIANT|WIN32OLE::VARIANT::VT_BYREF);
+ obj = WIN32OLE::Variant.new("Str", WIN32OLE::VARIANT::VT_VARIANT|WIN32OLE::VARIANT::VT_BYREF);
assert_equal("Str", obj.value);
end
def test_vartype
- obj = WIN32OLE_VARIANT.new("Str")
+ obj = WIN32OLE::Variant.new("Str")
assert_equal(WIN32OLE::VARIANT::VT_BSTR, obj.vartype)
end
def test_set_value
- obj = WIN32OLE_VARIANT.new(10)
+ obj = WIN32OLE::Variant.new(10)
obj.value = 12
assert_equal(12, obj.value)
assert_equal(WIN32OLE::VARIANT::VT_I4, obj.vartype)
@@ -661,57 +665,57 @@ if defined?(WIN32OLE_VARIANT)
assert_equal(11, obj.value)
assert_equal(WIN32OLE::VARIANT::VT_I4, obj.vartype)
- obj = WIN32OLE_VARIANT.new([1,2])
- assert_raise(WIN32OLERuntimeError) {
+ obj = WIN32OLE::Variant.new([1,2])
+ assert_raise(WIN32OLE::RuntimeError) {
obj.value = [3,4]
}
- obj = WIN32OLE_VARIANT.new("2007/01/01", WIN32OLE::VARIANT::VT_DATE)
- assert_raise(WIN32OLERuntimeError) {
+ obj = WIN32OLE::Variant.new("2007/01/01", WIN32OLE::VARIANT::VT_DATE)
+ assert_raise(WIN32OLE::RuntimeError) {
obj.value = "hogehoge"
}
assert_equal(Time.new(2007,1,1), obj.value)
- obj2 = WIN32OLE_VARIANT.new("2006/01/01", WIN32OLE::VARIANT::VT_DATE)
+ obj2 = WIN32OLE::Variant.new("2006/01/01", WIN32OLE::VARIANT::VT_DATE)
obj.value = obj2
assert_equal(Time.new(2006,01,01), obj.value)
end
def test_c_nothing
- assert_nil(WIN32OLE_VARIANT::Nothing.value)
+ assert_nil(WIN32OLE::Variant::Nothing.value)
end
def test_c_empty
- assert_nil(WIN32OLE_VARIANT::Empty.value)
+ assert_nil(WIN32OLE::Variant::Empty.value)
end
def test_c_null
- assert_nil(WIN32OLE_VARIANT::Null.value)
+ assert_nil(WIN32OLE::Variant::Null.value)
end
def test_c_noparam
# DISP_E_PARAMNOTFOUND
- assert_equal(-2147352572, WIN32OLE_VARIANT::NoParam.value)
+ assert_equal(-2147352572, WIN32OLE::Variant::NoParam.value)
end
def test_vt_error_noparam
- v = WIN32OLE_VARIANT.new(-1, WIN32OLE::VARIANT::VT_ERROR)
+ v = WIN32OLE::Variant.new(-1, WIN32OLE::VARIANT::VT_ERROR)
assert_equal(-1, v.value)
fso = WIN32OLE.new("Scripting.FileSystemObject")
- exc = assert_raise(WIN32OLERuntimeError) {
+ exc = assert_raise(WIN32OLE::RuntimeError) {
fso.openTextFile("NonExistingFile", v, false)
}
assert_match(/Type mismatch/i, exc.message)
- exc = assert_raise(WIN32OLERuntimeError) {
- fso.openTextFile("NonExistingFile", WIN32OLE_VARIANT::NoParam, false)
+ exc = assert_raise(WIN32OLE::RuntimeError) {
+ fso.openTextFile("NonExistingFile", WIN32OLE::Variant::NoParam, false)
}
# 800A0035 is 'file not found' error.
assert_match(/800A0035/, exc.message)
# -2147352572 is DISP_E_PARAMNOTFOUND
- v = WIN32OLE_VARIANT.new(-2147352572, WIN32OLE::VARIANT::VT_ERROR)
- exc = assert_raise(WIN32OLERuntimeError) {
- fso.openTextFile("NonExistingFile", WIN32OLE_VARIANT::NoParam, false)
+ v = WIN32OLE::Variant.new(-2147352572, WIN32OLE::VARIANT::VT_ERROR)
+ exc = assert_raise(WIN32OLE::RuntimeError) {
+ fso.openTextFile("NonExistingFile", WIN32OLE::Variant::NoParam, false)
}
# 800A0035 is 'file not found' error code.
assert_match(/800A0035/, exc.message)
diff --git a/test/win32ole/test_win32ole_variant_m.rb b/test/win32ole/test_win32ole_variant_m.rb
index 25ad56cc21..3c2884644c 100644
--- a/test/win32ole/test_win32ole_variant_m.rb
+++ b/test/win32ole/test_win32ole_variant_m.rb
@@ -8,6 +8,11 @@ require "test/unit"
if defined?(WIN32OLE::VARIANT)
class TestWin32OLE_VARIANT_MODULE < Test::Unit::TestCase
include WIN32OLE::VARIANT
+
+ def test_toplevel_constants_backward_compatibility
+ assert_equal(WIN32OLE::VariantType, WIN32OLE::VARIANT)
+ end
+
def test_variant
assert_equal(0, VT_EMPTY)
assert_equal(1, VT_NULL)
diff --git a/test/win32ole/test_win32ole_variant_outarg.rb b/test/win32ole/test_win32ole_variant_outarg.rb
index aa5793b84c..9301a76aaa 100644
--- a/test/win32ole/test_win32ole_variant_outarg.rb
+++ b/test/win32ole/test_win32ole_variant_outarg.rb
@@ -23,7 +23,7 @@ def ado_csv_installed?
installed
end
-if defined?(WIN32OLE_VARIANT)
+if defined?(WIN32OLE::Variant)
class TestWIN32OLE_VARIANT_OUTARG < Test::Unit::TestCase
module ADO
end
@@ -42,17 +42,17 @@ if defined?(WIN32OLE_VARIANT)
def test_variant_ref_and_argv
if !ado_csv_installed?
- skip("ActiveX Data Object Library not found")
+ omit("ActiveX Data Object Library not found")
end
sql = "INSERT INTO data.csv VALUES (5, 'E')"
@db.execute(sql, -1)
c = WIN32OLE::ARGV[1]
assert_equal(1, c)
- obj = WIN32OLE_VARIANT.new(nil, WIN32OLE::VARIANT::VT_VARIANT|WIN32OLE::VARIANT::VT_BYREF)
+ obj = WIN32OLE::Variant.new(nil, WIN32OLE::VARIANT::VT_VARIANT|WIN32OLE::VARIANT::VT_BYREF)
assert_equal(nil, obj.value)
@db.execute(sql , obj)
assert_equal(1, obj.value)
- obj = WIN32OLE_VARIANT.new(-100, WIN32OLE::VARIANT::VT_VARIANT|WIN32OLE::VARIANT::VT_BYREF)
+ obj = WIN32OLE::Variant.new(-100, WIN32OLE::VARIANT::VT_VARIANT|WIN32OLE::VARIANT::VT_BYREF)
assert_equal(-100, obj.value)
@db.execute(sql, obj)
assert_equal(1, obj.value)
diff --git a/test/win32ole/test_word.rb b/test/win32ole/test_word.rb
index b1cdb273cc..34cfbbc2a4 100644
--- a/test/win32ole/test_word.rb
+++ b/test/win32ole/test_word.rb
@@ -35,13 +35,13 @@ if defined?(WIN32OLE)
class TestWIN32OLE_WITH_WORD < Test::Unit::TestCase
unless word_installed?
def test_dummy_for_skip_message
- skip "Microsoft Word is not installed"
+ omit "Microsoft Word is not installed"
end
else
def setup
begin
@obj = WIN32OLE.new('Word.Application')
- rescue WIN32OLERuntimeError
+ rescue WIN32OLE::RuntimeError
@obj = nil
end
end