ruby-changes:32525
From: nobu <ko1@a...>
Date: Wed, 15 Jan 2014 14:03:30 +0900 (JST)
Subject: [ruby-changes:32525] nobu:r44604 (trunk): test_m17n.rb: split tests for inspect
nobu 2014-01-15 14:03:24 +0900 (Wed, 15 Jan 2014) New Revision: 44604 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=44604 Log: test_m17n.rb: split tests for inspect * test/ruby/test_m17n.rb (test_utf_16_32_inspect): split tests for each encodings. Modified files: trunk/test/ruby/test_m17n.rb Index: test/ruby/test_m17n.rb =================================================================== --- test/ruby/test_m17n.rb (revision 44603) +++ test/ruby/test_m17n.rb (revision 44604) @@ -226,24 +226,22 @@ class TestM17N < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_m17n.rb#L226 end end - def test_utf_16_32_inspect - str = "\u3042" - %w/UTF-16 UTF-32/.each do |enc| - %w/BE LE/.each do |endian| - s = str.encode(enc + endian) + STR_WITHOUT_BOM = "\u3042".freeze + STR_WITH_BOM = "\uFEFF\u3042".freeze + %w/UTF-16 UTF-32/.each do |enc| + %w/BE LE/.each do |endian| + define_method("test_utf_16_32_inspect(#{enc}#{endian})") do + s = STR_WITHOUT_BOM.encode(enc + endian) # When a UTF-16/32 string doesn't have a BOM, # inspect as a dummy encoding string. assert_equal(s.dup.force_encoding("ISO-2022-JP").inspect, s.dup.force_encoding(enc).inspect) end - end - str = "\uFEFF\u3042" - %w/UTF-16 UTF-32/.each do |enc| - %w/BE LE/.each do |endian| - s = str.encode(enc + endian) - # When a UTF-16/32 string doesn't have a BOM, - # inspect as a dummy encoding string. + define_method("test_utf_16_32_inspect(#{enc}#{endian}-BOM)") do + s = STR_WITH_BOM.encode(enc + endian) + # When a UTF-16/32 string has a BOM, + # inspect as a particular encoding string. assert_equal(s.inspect, s.dup.force_encoding(enc).inspect) end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/