ruby-changes:5357
From: nobu <ko1@a...>
Date: Fri, 6 Jun 2008 18:29:49 +0900 (JST)
Subject: [ruby-changes:5357] Ruby:r16859 (ruby_1_8, trunk): * test/iconv/utils.rb (default_test): override not to croak.
nobu 2008-06-06 18:25:46 +0900 (Fri, 06 Jun 2008) New Revision: 16859 Modified files: branches/ruby_1_8/ChangeLog branches/ruby_1_8/test/iconv/test_basic.rb branches/ruby_1_8/test/iconv/test_option.rb branches/ruby_1_8/test/iconv/test_partial.rb branches/ruby_1_8/test/iconv/utils.rb trunk/ChangeLog trunk/test/iconv/test_basic.rb trunk/test/iconv/test_option.rb trunk/test/iconv/test_partial.rb trunk/test/iconv/utils.rb Log: * test/iconv/utils.rb (default_test): override not to croak. http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/branches/ruby_1_8/test/iconv/test_option.rb?r1=16859&r2=16858&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/test/iconv/utils.rb?r1=16859&r2=16858&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/test/iconv/test_basic.rb?r1=16859&r2=16858&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/branches/ruby_1_8/ChangeLog?r1=16859&r2=16858&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=16859&r2=16858&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/branches/ruby_1_8/test/iconv/test_basic.rb?r1=16859&r2=16858&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/test/iconv/test_partial.rb?r1=16859&r2=16858&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/test/iconv/test_option.rb?r1=16859&r2=16858&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/branches/ruby_1_8/test/iconv/utils.rb?r1=16859&r2=16858&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/branches/ruby_1_8/test/iconv/test_partial.rb?r1=16859&r2=16858&diff_format=u Index: ChangeLog =================================================================== --- ChangeLog (revision 16858) +++ ChangeLog (revision 16859) @@ -1,3 +1,7 @@ +Fri Jun 6 18:25:43 2008 Nobuyoshi Nakada <nobu@r...> + + * test/iconv/utils.rb (default_test): override not to croak. + Fri Jun 6 16:41:45 2008 NAKAMURA Usaku <usa@r...> * include/ruby/win32.h: include ws2tcpip.h. fixed [ruby-Bugs-20528] Index: test/iconv/test_basic.rb =================================================================== --- test/iconv/test_basic.rb (revision 16858) +++ test/iconv/test_basic.rb (revision 16859) @@ -1,6 +1,6 @@ require File.join(File.dirname(__FILE__), "utils.rb") -TestIconv.testcase(:Basic) do +class TestIconv::Basic < TestIconv def test_euc2sjis iconv = Iconv.open('SHIFT_JIS', 'EUC-JP') str = iconv.iconv(EUCJ_STR) @@ -46,4 +46,4 @@ def test_unknown_encoding assert_raise(Iconv::InvalidEncoding) { Iconv.iconv("utf-8", "X-UKNOWN", "heh") } end -end +end if defined?(TestIconv) Index: test/iconv/utils.rb =================================================================== --- test/iconv/utils.rb (revision 16858) +++ test/iconv/utils.rb (revision 16859) @@ -5,21 +5,7 @@ require 'test/unit' end -module TestIconv - if defined?(::Iconv) - def self.testcase(name, &block) - const_set(name, klass = Class.new(::Test::Unit::TestCase)) - klass.name - klass.__send__(:include, self) - klass.class_eval(&block) - end - else - def self.testcase(name) - end - end -end - -module TestIconv +class TestIconv < ::Test::Unit::TestCase if defined?(::Encoding) and String.method_defined?(:force_encoding) def self.encode(str, enc) str.force_encoding(enc) @@ -30,6 +16,10 @@ end end + def default_test + self.class == TestIconv or super + end + ASCII = "ascii" EUCJ_STR = encode("\xa4\xa2\xa4\xa4\xa4\xa6\xa4\xa8\xa4\xaa", "EUC-JP").freeze SJIS_STR = encode("\x82\xa0\x82\xa2\x82\xa4\x82\xa6\x82\xa8", "Shift_JIS").freeze Index: test/iconv/test_option.rb =================================================================== --- test/iconv/test_option.rb (revision 16858) +++ test/iconv/test_option.rb (revision 16859) @@ -1,6 +1,6 @@ require File.join(File.dirname(__FILE__), "utils.rb") -TestIconv.testcase(:Option) do +class TestIconv::Option < TestIconv def test_ignore_option iconv = Iconv.new('SHIFT_JIS', 'EUC-JP//ignore') str = iconv.iconv(EUCJ_STR) @@ -28,4 +28,4 @@ assert_equal(SJIS_STR, str) iconv.close end -end +end if defined?(TestIconv) Index: test/iconv/test_partial.rb =================================================================== --- test/iconv/test_partial.rb (revision 16858) +++ test/iconv/test_partial.rb (revision 16859) @@ -1,6 +1,6 @@ require File.join(File.dirname(__FILE__), "utils.rb") -TestIconv.testcase(:Partial) do +class TestIconv::Partial < TestIconv def test_partial_ascii c = Iconv.open(ASCII, ASCII) ref = '[ruby-core:17092]' @@ -38,4 +38,4 @@ ensure c.close end -end +end if defined?(TestIconv) Index: ruby_1_8/ChangeLog =================================================================== --- ruby_1_8/ChangeLog (revision 16858) +++ ruby_1_8/ChangeLog (revision 16859) @@ -1,3 +1,7 @@ +Fri Jun 6 18:25:43 2008 Nobuyoshi Nakada <nobu@r...> + + * test/iconv/utils.rb (default_test): override not to croak. + Fri Jun 6 16:44:37 2008 NAKAMURA Usaku <usa@r...> * win32/win32.h: include ws2tcpip.h. fixed [ruby-Bugs-20528] Index: ruby_1_8/test/iconv/test_basic.rb =================================================================== --- ruby_1_8/test/iconv/test_basic.rb (revision 16858) +++ ruby_1_8/test/iconv/test_basic.rb (revision 16859) @@ -1,6 +1,6 @@ require File.join(File.dirname(__FILE__), "utils.rb") -TestIconv.testcase(:Basic) do +class TestIconv::Basic < TestIconv def test_euc2sjis iconv = Iconv.open('SHIFT_JIS', 'EUC-JP') str = iconv.iconv(EUCJ_STR) @@ -46,4 +46,4 @@ def test_unknown_encoding assert_raise(Iconv::InvalidEncoding) { Iconv.iconv("utf-8", "X-UKNOWN", "heh") } end -end +end if defined?(TestIconv) Index: ruby_1_8/test/iconv/utils.rb =================================================================== --- ruby_1_8/test/iconv/utils.rb (revision 16858) +++ ruby_1_8/test/iconv/utils.rb (revision 16859) @@ -5,21 +5,7 @@ require 'test/unit' end -module TestIconv - if defined?(::Iconv) - def self.testcase(name, &block) - const_set(name, klass = Class.new(::Test::Unit::TestCase)) - klass.name - klass.__send__(:include, self) - klass.class_eval(&block) - end - else - def self.testcase(name) - end - end -end - -module TestIconv +class TestIconv < ::Test::Unit::TestCase if defined?(::Encoding) and String.method_defined?(:force_encoding) def self.encode(str, enc) str.force_encoding(enc) @@ -30,6 +16,10 @@ end end + def default_test + self.class == TestIconv or super + end + ASCII = "ascii" EUCJ_STR = encode("\xa4\xa2\xa4\xa4\xa4\xa6\xa4\xa8\xa4\xaa", "EUC-JP").freeze SJIS_STR = encode("\x82\xa0\x82\xa2\x82\xa4\x82\xa6\x82\xa8", "Shift_JIS").freeze Index: ruby_1_8/test/iconv/test_option.rb =================================================================== --- ruby_1_8/test/iconv/test_option.rb (revision 16858) +++ ruby_1_8/test/iconv/test_option.rb (revision 16859) @@ -1,6 +1,6 @@ require File.join(File.dirname(__FILE__), "utils.rb") -TestIconv.testcase(:Option) do +class TestIconv::Option < TestIconv def test_ignore_option iconv = Iconv.new('SHIFT_JIS', 'EUC-JP//ignore') str = iconv.iconv(EUCJ_STR) @@ -28,4 +28,4 @@ assert_equal(SJIS_STR, str) iconv.close end -end +end if defined?(TestIconv) Index: ruby_1_8/test/iconv/test_partial.rb =================================================================== --- ruby_1_8/test/iconv/test_partial.rb (revision 16858) +++ ruby_1_8/test/iconv/test_partial.rb (revision 16859) @@ -1,6 +1,6 @@ require File.join(File.dirname(__FILE__), "utils.rb") -TestIconv.testcase(:Partial) do +class TestIconv::Partial < TestIconv def test_partial_ascii c = Iconv.open(ASCII, ASCII) ref = '[ruby-core:17092]' @@ -38,4 +38,4 @@ ensure c.close end -end +end if defined?(TestIconv) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/