diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-12-14 06:40:55 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-12-14 06:40:55 +0000 |
commit | c81b224edca453ed8ea3030cc74b2ede5ac9e63a (patch) | |
tree | 91fad68f293185c4ac2ee01e568b91896ae04bb9 /test/ruby | |
parent | fcb4ab8d1c917b3f2a998f9b6eab3d9cec27670a (diff) |
test: use String#b instead of dup.force_encoding
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53109 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby')
-rw-r--r-- | test/ruby/test_dir_m17n.rb | 2 | ||||
-rw-r--r-- | test/ruby/test_econv.rb | 12 | ||||
-rw-r--r-- | test/ruby/test_io_m17n.rb | 5 | ||||
-rw-r--r-- | test/ruby/test_m17n.rb | 6 | ||||
-rw-r--r-- | test/ruby/test_m17n_comb.rb | 4 |
5 files changed, 12 insertions, 17 deletions
diff --git a/test/ruby/test_dir_m17n.rb b/test/ruby/test_dir_m17n.rb index 4063c834de..bb60b0af76 100644 --- a/test/ruby/test_dir_m17n.rb +++ b/test/ruby/test_dir_m17n.rb @@ -208,7 +208,7 @@ class TestDir_M17N < Test::Unit::TestCase when /darwin/ filename = filename.encode("utf-8", "euc-jp").b when /mswin|mingw/ - if ents.include?(win_expected_filename.dup.force_encoding("ASCII-8BIT")) + if ents.include?(win_expected_filename.b) ents = Dir.entries(".", {:encoding => Encoding.find("filesystem")}) filename = win_expected_filename end diff --git a/test/ruby/test_econv.rb b/test/ruby/test_econv.rb index f423ebfc9e..073355f319 100644 --- a/test/ruby/test_econv.rb +++ b/test/ruby/test_econv.rb @@ -3,12 +3,8 @@ require 'test/unit' class TestEncodingConverter < Test::Unit::TestCase def check_ec(edst, esrc, eres, dst, src, ec, off, len, opts=nil) res = ec.primitive_convert(src, dst, off, len, opts) - assert_equal([edst.dup.force_encoding("ASCII-8BIT"), - esrc.dup.force_encoding("ASCII-8BIT"), - eres], - [dst.dup.force_encoding("ASCII-8BIT"), - src.dup.force_encoding("ASCII-8BIT"), - res]) + assert_equal([edst.b, esrc.b, eres], + [dst.b, src.b, res]) end def assert_econv(converted, eres, obuf_bytesize, ec, consumed, rest, opts=nil) @@ -22,8 +18,8 @@ class TestEncodingConverter < Test::Unit::TestCase def assert_errinfo(e_res, e_enc1, e_enc2, e_error_bytes, e_readagain_bytes, ec) assert_equal([e_res, e_enc1, e_enc2, - e_error_bytes && e_error_bytes.dup.force_encoding("ASCII-8BIT"), - e_readagain_bytes && e_readagain_bytes.dup.force_encoding("ASCII-8BIT")], + e_error_bytes && e_error_bytes.b, + e_readagain_bytes && e_readagain_bytes.b], ec.primitive_errinfo) end diff --git a/test/ruby/test_io_m17n.rb b/test/ruby/test_io_m17n.rb index a91fccee5f..ed8ac99946 100644 --- a/test/ruby/test_io_m17n.rb +++ b/test/ruby/test_io_m17n.rb @@ -1711,8 +1711,7 @@ EOT args.each {|arg| f.print arg } } content = File.read("t", :mode=>"rb:ascii-8bit") - assert_equal(expected.dup.force_encoding("ascii-8bit"), - content.force_encoding("ascii-8bit")) + assert_equal(expected.b, content.b) } end @@ -1892,7 +1891,7 @@ EOT with_tmpdir { src = "\u3042\r\n" generate_file("t.txt", src) - srcbin = src.dup.force_encoding("ascii-8bit") + srcbin = src.b open("t.txt", "rt:utf-8:euc-jp") {|f| f.binmode result = f.read diff --git a/test/ruby/test_m17n.rb b/test/ruby/test_m17n.rb index 4efe18187b..a9cb86a5c8 100644 --- a/test/ruby/test_m17n.rb +++ b/test/ruby/test_m17n.rb @@ -8,7 +8,7 @@ class TestM17N < Test::Unit::TestCase module AESU def ua(str) str.dup.force_encoding("US-ASCII") end - def a(str) str.dup.force_encoding("ASCII-8BIT") end + def a(str) str.b end def e(str) str.dup.force_encoding("EUC-JP") end def s(str) str.dup.force_encoding("Windows-31J") end def u(str) str.dup.force_encoding("UTF-8") end @@ -1130,7 +1130,7 @@ class TestM17N < Test::Unit::TestCase def test_dup_scan s1 = e("\xa4\xa2")*100 - s2 = s1.dup.force_encoding("ascii-8bit") + s2 = s1.b s2.scan(/\A./n) {|f| assert_equal(Encoding::ASCII_8BIT, f.encoding) } @@ -1138,7 +1138,7 @@ class TestM17N < Test::Unit::TestCase def test_dup_aref s1 = e("\xa4\xa2")*100 - s2 = s1.dup.force_encoding("ascii-8bit") + s2 = s1.b assert_equal(Encoding::ASCII_8BIT, s2[10..-1].encoding) end diff --git a/test/ruby/test_m17n_comb.rb b/test/ruby/test_m17n_comb.rb index 83c3f8aa95..cf00e52157 100644 --- a/test/ruby/test_m17n_comb.rb +++ b/test/ruby/test_m17n_comb.rb @@ -1575,8 +1575,8 @@ class TestM17NComb < Test::Unit::TestCase assert_raise(Encoding::CompatibilityError, desc) { s1.start_with?(s2) } next end - s1 = s1.dup.force_encoding("ASCII-8BIT") - s2 = s2.dup.force_encoding("ASCII-8BIT") + s1 = s1.b + s2 = s2.b if s1.length < s2.length assert_equal(false, enccall(s1, :start_with?, s2), desc) next |