From 7ab47751068c6480e7e44fc9265a7e690dd4af3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Tue, 20 Dec 2011 18:22:21 +0100 Subject: Initial pass at removing dead 1.8.x code from Active Support. There are a bunch of other implicit branches that adds 1.8.x specific code that still needs to be removed. Pull requests for those cases are welcome. --- activesupport/test/multibyte_utils_test.rb | 54 ++++++------------------------ 1 file changed, 10 insertions(+), 44 deletions(-) (limited to 'activesupport/test/multibyte_utils_test.rb') diff --git a/activesupport/test/multibyte_utils_test.rb b/activesupport/test/multibyte_utils_test.rb index 0a2f20d282..9a8f7050fe 100644 --- a/activesupport/test/multibyte_utils_test.rb +++ b/activesupport/test/multibyte_utils_test.rb @@ -56,37 +56,9 @@ class MultibyteUtilsTest < ActiveSupport::TestCase end end - if RUBY_VERSION < '1.9' - test "clean leaves ASCII strings intact" do - with_encoding('None') do - [ - 'word', "\270\236\010\210\245" - ].each do |string| - assert_equal string, ActiveSupport::Multibyte.clean(string) - end - end - end - - test "clean cleans invalid characters from UTF-8 encoded strings" do - with_encoding('UTF8') do - cleaned_utf8 = [8].pack('C*') - assert_equal example('valid UTF-8'), ActiveSupport::Multibyte.clean(example('valid UTF-8')) - assert_equal cleaned_utf8, ActiveSupport::Multibyte.clean(example('invalid UTF-8')) - end - end - - test "clean cleans invalid characters from Shift-JIS encoded strings" do - with_encoding('SJIS') do - cleaned_sjis = [184, 0, 136, 165].pack('C*') - assert_equal example('valid Shift-JIS'), ActiveSupport::Multibyte.clean(example('valid Shift-JIS')) - assert_equal cleaned_sjis, ActiveSupport::Multibyte.clean(example('invalid Shift-JIS')) - end - end - else - test "clean is a no-op" do - with_encoding('UTF8') do - assert_equal example('invalid Shift-JIS'), ActiveSupport::Multibyte.clean(example('invalid Shift-JIS')) - end + test "clean is a no-op" do + with_encoding('UTF8') do + assert_equal example('invalid Shift-JIS'), ActiveSupport::Multibyte.clean(example('invalid Shift-JIS')) end end @@ -119,19 +91,13 @@ class MultibyteUtilsTest < ActiveSupport::TestCase end end - if 'string'.respond_to?(:encoding) - KCODE_TO_ENCODING = Hash.new(Encoding::BINARY). - update('UTF8' => Encoding::UTF_8, 'SJIS' => Encoding::Shift_JIS) - - def with_encoding(enc) - before = Encoding.default_external - silence_warnings { Encoding.default_external = KCODE_TO_ENCODING[enc] } + KCODE_TO_ENCODING = Hash.new(Encoding::BINARY). + update('UTF8' => Encoding::UTF_8, 'SJIS' => Encoding::Shift_JIS) - yield - - silence_warnings { Encoding.default_external = before } - end - else - alias with_encoding with_kcode + def with_encoding(enc) + before = Encoding.default_external + silence_warnings { Encoding.default_external = KCODE_TO_ENCODING[enc] } + yield + silence_warnings { Encoding.default_external = before } end end -- cgit v1.2.3