From f6f85ad68309508e29f30d6cc4b86d0057aac2c0 Mon Sep 17 00:00:00 2001 From: suke Date: Wed, 27 Aug 2008 14:43:23 +0000 Subject: [PATCH] * ext/win32ole/win32ole.c (ole_invoke): WIN32OLE#[] and WIN32OLE#[]= accepts number argument. * test/win32ole/test_win32ole.rb: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18882 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 7 +++++++ ext/win32ole/win32ole.c | 2 +- test/win32ole/test_win32ole.rb | 8 ++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 702be234ef..c1a2c71340 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Wed Aug 27 23:28:51 2008 Masaki Suketa + + * ext/win32ole/win32ole.c (ole_invoke): WIN32OLE#[] and WIN32OLE#[]= + accepts number argument. + + * test/win32ole/test_win32ole.rb: ditto. + Wed Aug 27 14:45:34 2008 NARUSE, Yui * test/cgi/test_cgi_core.rb: add core test. diff --git a/ext/win32ole/win32ole.c b/ext/win32ole/win32ole.c index bded54f7b6..8b20e62b0c 100644 --- a/ext/win32ole/win32ole.c +++ b/ext/win32ole/win32ole.c @@ -3225,7 +3225,7 @@ ole_invoke(int argc, VALUE *argv, VALUE self, USHORT wFlags, BOOL is_bracket) op.dp.cArgs = 0; rb_scan_args(argc, argv, "1*", &cmd, ¶mS); - if(TYPE(cmd) != T_STRING && TYPE(cmd) != T_SYMBOL) { + if(TYPE(cmd) != T_STRING && TYPE(cmd) != T_SYMBOL && !is_bracket) { rb_raise(rb_eTypeError, "method is wrong type (expected String or Symbol)"); } if (TYPE(cmd) == T_SYMBOL) { diff --git a/test/win32ole/test_win32ole.rb b/test/win32ole/test_win32ole.rb index d9e595347c..914610375c 100644 --- a/test/win32ole/test_win32ole.rb +++ b/test/win32ole/test_win32ole.rb @@ -119,6 +119,14 @@ if defined?(WIN32OLE) assert_equal("BAR", @dict1["foo"]) end + def test_bracket_with_numkey + @dict1.add(1, "ONE") + @dict1.add(2, "two") + assert_equal("ONE", @dict1[1]) + @dict1[2] = "TWO" + assert_equal("TWO", @dict1[2]) + end + def test_invoke_with_array @dict1.add("ary1", [1,2,3]) assert_equal([1,2,3], @dict1["ary1"])