ruby-changes:5334
From: nobu <ko1@a...>
Date: Thu, 5 Jun 2008 14:35:18 +0900 (JST)
Subject: [ruby-changes:5334] Ruby:r16835 (ruby_1_8, trunk): * test/iconv/utils.rb (TestIconv.testcase): make test cases conditionally.
nobu 2008-06-05 14:35:00 +0900 (Thu, 05 Jun 2008) New Revision: 16835 Modified files: 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/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 (TestIconv.testcase): make test cases conditionally. http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/branches/ruby_1_8/test/iconv/test_option.rb?r1=16835&r2=16834&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/test/iconv/utils.rb?r1=16835&r2=16834&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/test/iconv/test_basic.rb?r1=16835&r2=16834&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/branches/ruby_1_8/test/iconv/test_basic.rb?r1=16835&r2=16834&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/test/iconv/test_partial.rb?r1=16835&r2=16834&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/test/iconv/test_option.rb?r1=16835&r2=16834&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/branches/ruby_1_8/test/iconv/utils.rb?r1=16835&r2=16834&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/branches/ruby_1_8/test/iconv/test_partial.rb?r1=16835&r2=16834&diff_format=u Index: test/iconv/test_basic.rb =================================================================== --- test/iconv/test_basic.rb (revision 16834) +++ test/iconv/test_basic.rb (revision 16835) @@ -1,6 +1,6 @@ require File.join(File.dirname(__FILE__), "utils.rb") -class TestIconv +TestIconv.testcase(:Basic) do def test_euc2sjis iconv = Iconv.open('SHIFT_JIS', 'EUC-JP') str = iconv.iconv(EUCJ_STR) Index: test/iconv/utils.rb =================================================================== --- test/iconv/utils.rb (revision 16834) +++ test/iconv/utils.rb (revision 16835) @@ -5,7 +5,21 @@ require 'test/unit' end -class TestIconv < Test::Unit::TestCase +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 if defined?(::Encoding) and String.method_defined?(:force_encoding) def self.encode(str, enc) str.force_encoding(enc) Index: test/iconv/test_option.rb =================================================================== --- test/iconv/test_option.rb (revision 16834) +++ test/iconv/test_option.rb (revision 16835) @@ -1,6 +1,6 @@ require File.join(File.dirname(__FILE__), "utils.rb") -class TestIconv +TestIconv.testcase(:Option) do 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 if defined?(::Iconv) +end Index: test/iconv/test_partial.rb =================================================================== --- test/iconv/test_partial.rb (revision 16834) +++ test/iconv/test_partial.rb (revision 16835) @@ -1,6 +1,6 @@ require File.join(File.dirname(__FILE__), "utils.rb") -class TestIconv +TestIconv.testcase(:Partial) do def test_partial_ascii c = Iconv.open(ASCII, ASCII) ref = '[ruby-core:17092]' @@ -38,4 +38,4 @@ ensure c.close end -end if defined?(::Iconv) +end Index: ruby_1_8/test/iconv/test_basic.rb =================================================================== --- ruby_1_8/test/iconv/test_basic.rb (revision 16834) +++ ruby_1_8/test/iconv/test_basic.rb (revision 16835) @@ -1,6 +1,6 @@ require File.join(File.dirname(__FILE__), "utils.rb") -class TestIconv +TestIconv.testcase(:Basic) do def test_euc2sjis iconv = Iconv.open('SHIFT_JIS', 'EUC-JP') str = iconv.iconv(EUCJ_STR) Index: ruby_1_8/test/iconv/utils.rb =================================================================== --- ruby_1_8/test/iconv/utils.rb (revision 16834) +++ ruby_1_8/test/iconv/utils.rb (revision 16835) @@ -5,7 +5,21 @@ require 'test/unit' end -class TestIconv < Test::Unit::TestCase +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 if defined?(::Encoding) and String.method_defined?(:force_encoding) def self.encode(str, enc) str.force_encoding(enc) Index: ruby_1_8/test/iconv/test_option.rb =================================================================== --- ruby_1_8/test/iconv/test_option.rb (revision 16834) +++ ruby_1_8/test/iconv/test_option.rb (revision 16835) @@ -1,6 +1,6 @@ require File.join(File.dirname(__FILE__), "utils.rb") -class TestIconv +TestIconv.testcase(:Option) do 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 if defined?(::Iconv) +end Index: ruby_1_8/test/iconv/test_partial.rb =================================================================== --- ruby_1_8/test/iconv/test_partial.rb (revision 16834) +++ ruby_1_8/test/iconv/test_partial.rb (revision 16835) @@ -1,6 +1,6 @@ require File.join(File.dirname(__FILE__), "utils.rb") -class TestIconv +TestIconv.testcase(:Partial) do def test_partial_ascii c = Iconv.open(ASCII, ASCII) ref = '[ruby-core:17092]' @@ -38,4 +38,4 @@ ensure c.close end -end if defined?(::Iconv) +end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/