ruby-changes:28984
From: naruse <ko1@a...>
Date: Sun, 2 Jun 2013 23:47:28 +0900 (JST)
Subject: [ruby-changes:28984] naruse:r41036 (trunk): Suppress warnings: setting Encoding.default_internal
naruse 2013-06-02 23:46:43 +0900 (Sun, 02 Jun 2013) New Revision: 41036 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=41036 Log: Suppress warnings: setting Encoding.default_internal Modified files: trunk/test/ruby/test_transcode.rb Index: test/ruby/test_transcode.rb =================================================================== --- test/ruby/test_transcode.rb (revision 41035) +++ test/ruby/test_transcode.rb (revision 41036) @@ -2,6 +2,7 @@ https://github.com/ruby/ruby/blob/trunk/test/ruby/test_transcode.rb#L2 # some of the comments are in UTF-8 require 'test/unit' +require_relative 'envutil' class TestTranscode < Test::Unit::TestCase def test_errors assert_raise(Encoding::ConverterNotFoundError) { 'abc'.encode('foo', 'bar') } @@ -29,16 +30,16 @@ class TestTranscode < Test::Unit::TestCa https://github.com/ruby/ruby/blob/trunk/test/ruby/test_transcode.rb#L30 end def test_noargument - default_default_internal = Encoding.default_internal - Encoding.default_internal = nil - assert_equal("\u3042".encode, "\u3042") - assert_equal("\xE3\x81\x82\x81".force_encoding("utf-8").encode, - "\xE3\x81\x82\x81".force_encoding("utf-8")) - Encoding.default_internal = 'EUC-JP' - assert_equal("\u3042".encode, "\xA4\xA2".force_encoding('EUC-JP')) - assert_equal("\xE3\x81\x82\x81".force_encoding("utf-8").encode, - "\xA4\xA2?".force_encoding('EUC-JP')) - Encoding.default_internal = default_default_internal + EnvUtil.with_default_internal(nil) do + assert_equal("\u3042".encode, "\u3042") + assert_equal("\xE3\x81\x82\x81".force_encoding("utf-8").encode, + "\xE3\x81\x82\x81".force_encoding("utf-8")) + end + EnvUtil.with_default_internal('EUC-JP') do + assert_equal("\u3042".encode, "\xA4\xA2".force_encoding('EUC-JP')) + assert_equal("\xE3\x81\x82\x81".force_encoding("utf-8").encode, + "\xA4\xA2?".force_encoding('EUC-JP')) + end end def test_length -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/