From: nobu.nokada@... Date: 2004-11-17T11:22:12+09:00 Subject: Re: patch for test/xmlrpc Hi, At Tue, 16 Nov 2004 19:58:43 +0900, Michael Neumann wrote in [ruby-core:03747]: > > Following patch repairs this problem. > > [...] > > > > BTW, test/xmlrpc/test_features.rb says many "warning: already > > initialized constant" message. > > Any ideas? > > I know why this happens, but no easy way to avoid this (without changing > XML-RPC for Ruby). It becomes quiet by removing the constants before setting, but why does it use constants? Index: lib/xmlrpc/parser.rb =================================================================== RCS file: /cvs/ruby/src/ruby/lib/xmlrpc/parser.rb,v retrieving revision 1.6 diff -U2 -p -d -r1.6 parser.rb --- lib/xmlrpc/parser.rb 16 Nov 2004 01:11:49 -0000 1.6 +++ lib/xmlrpc/parser.rb 17 Nov 2004 02:20:40 -0000 @@ -579,10 +579,7 @@ module XMLRPC def initialize require "xmlparser" - eval %{ - class XMLRPCParser < ::XMLParser - include StreamParserMixin - end + @parser_class = Class.new(::XMLParser) { + include StreamParserMixin } - @parser_class = XMLRPCParser end end # class XMLStreamParser Index: test/xmlrpc/test_features.rb =================================================================== RCS file: /cvs/ruby/src/ruby/test/xmlrpc/test_features.rb,v retrieving revision 1.2 diff -U2 -p -d -r1.2 test_features.rb --- test/xmlrpc/test_features.rb 16 Nov 2004 10:55:47 -0000 1.2 +++ test/xmlrpc/test_features.rb 17 Nov 2004 02:13:01 -0000 @@ -14,7 +14,9 @@ class Test_Features < Test::Unit::TestCa c = XMLRPC::Create.new(writer) + XMLRPC::Config.module_eval {remove_const(:ENABLE_NIL_CREATE)} XMLRPC::Config.const_set(:ENABLE_NIL_CREATE, false) assert_raises(RuntimeError) { str = c.methodCall("test", *@params) } + XMLRPC::Config.module_eval {remove_const(:ENABLE_NIL_CREATE)} XMLRPC::Config.const_set(:ENABLE_NIL_CREATE, true) assert_nothing_raised { str = c.methodCall("test", *@params) } @@ -23,4 +25,5 @@ class Test_Features < Test::Unit::TestCa def test_nil_parse + XMLRPC::Config.module_eval {remove_const(:ENABLE_NIL_CREATE)} XMLRPC::Config.const_set(:ENABLE_NIL_CREATE, true) @@ -31,7 +34,9 @@ class Test_Features < Test::Unit::TestCa para = nil + XMLRPC::Config.module_eval {remove_const(:ENABLE_NIL_PARSER)} XMLRPC::Config.const_set(:ENABLE_NIL_PARSER, false) assert_raises(RuntimeError) { para = parser.parseMethodCall(str) } + XMLRPC::Config.module_eval {remove_const(:ENABLE_NIL_PARSER)} XMLRPC::Config.const_set(:ENABLE_NIL_PARSER, true) assert_nothing_raised { para = parser.parseMethodCall(str) } -- Nobu Nakada