1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Multibyte: String#chars uses passthrough handler for Ruby 1.9

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8459 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
Jeremy Kemper 2007-12-21 11:21:20 +00:00
parent 2556e67403
commit 909b2c1acf
5 changed files with 21 additions and 15 deletions

View file

@ -16,6 +16,7 @@ RUBY_FORGE_USER = "webster132"
task :default => :test task :default => :test
Rake::TestTask.new { |t| Rake::TestTask.new { |t|
t.libs << "test"
t.pattern = 'test/**/*_test.rb' t.pattern = 'test/**/*_test.rb'
t.verbose = true t.verbose = true
t.warning = true t.warning = true

View file

@ -125,7 +125,7 @@ module ActiveSupport::Multibyte #:nodoc:
end end
else else
def utf8_pragma? def utf8_pragma?
!@string.nil? && (Encoding.default_external == Encoding::UTF_8) false
end end
end end
end end

View file

@ -1,6 +1,6 @@
require File.dirname(__FILE__) + '/abstract_unit' require 'abstract_unit'
$KCODE = 'UTF8' $KCODE = 'UTF8' if RUBY_VERSION < '1.9'
class CharsTest < Test::Unit::TestCase class CharsTest < Test::Unit::TestCase
@ -85,16 +85,20 @@ class CharsTest < Test::Unit::TestCase
"Non-matching regular expressions should return nil") "Non-matching regular expressions should return nil")
end end
end end
def test_pragma def test_pragma
with_kcode('UTF8') do if RUBY_VERSION < '1.9'
assert " ".chars.send(:utf8_pragma?), "UTF8 pragma should be on because KCODE is UTF8" with_kcode('UTF8') do
end assert " ".chars.send(:utf8_pragma?), "UTF8 pragma should be on because KCODE is UTF8"
with_kcode('none') do end
assert !" ".chars.send(:utf8_pragma?), "UTF8 pragma should be off" with_kcode('none') do
assert !" ".chars.send(:utf8_pragma?), "UTF8 pragma should be off because KCODE is not UTF8"
end
else
assert !" ".chars.send(:utf8_pragma?), "UTF8 pragma should be off in Ruby 1.9"
end end
end end
def test_handler_setting def test_handler_setting
handler = ''.chars.handler handler = ''.chars.handler

View file

@ -1,7 +1,8 @@
require File.dirname(__FILE__) + '/abstract_unit' require 'abstract_unit'
require 'open-uri' require 'open-uri'
$KCODE = 'UTF8' $KCODE = 'UTF8' if RUBY_VERSION < '1.9'
UNIDATA_URL = "http://www.unicode.org/Public/#{ActiveSupport::Multibyte::UNICODE_VERSION}/ucd" UNIDATA_URL = "http://www.unicode.org/Public/#{ActiveSupport::Multibyte::UNICODE_VERSION}/ucd"
UNIDATA_FILE = '/NormalizationTest.txt' UNIDATA_FILE = '/NormalizationTest.txt'
CACHE_DIR = File.dirname(__FILE__) + '/cache' CACHE_DIR = File.dirname(__FILE__) + '/cache'
@ -138,4 +139,4 @@ class ConformanceTestPure < Test::Unit::TestCase
def setup def setup
@handler = ::ActiveSupport::Multibyte::Handlers::UTF8Handler @handler = ::ActiveSupport::Multibyte::Handlers::UTF8Handler
end end
end end

View file

@ -1,6 +1,6 @@
require File.dirname(__FILE__) + '/abstract_unit' require 'abstract_unit'
$KCODE = 'UTF8' $KCODE = 'UTF8' if RUBY_VERSION < '1.9'
class String class String
# Unicode Inspect returns the codepoints of the string in hex # Unicode Inspect returns the codepoints of the string in hex