зеркало из https://github.com/github/ruby.git
update unicode data files directory
* test/ruby/enc/test_case_comprehensive.rb: search ucd directory first if exists. * test/ruby/enc/test_regex_casefold.rb: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61415 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
52220154a8
Коммит
73bed03128
|
@ -5,7 +5,8 @@ require "test/unit"
|
||||||
|
|
||||||
class TestComprehensiveCaseMapping < Test::Unit::TestCase
|
class TestComprehensiveCaseMapping < Test::Unit::TestCase
|
||||||
UNICODE_VERSION = RbConfig::CONFIG['UNICODE_VERSION']
|
UNICODE_VERSION = RbConfig::CONFIG['UNICODE_VERSION']
|
||||||
UNICODE_DATA_PATH = "../../../enc/unicode/data/#{UNICODE_VERSION}"
|
path = File.expand_path("../../../enc/unicode/data/#{UNICODE_VERSION}", __dir__)
|
||||||
|
UNICODE_DATA_PATH = File.directory?("#{path}/ucd") ? "#{path}/ucd" : path
|
||||||
|
|
||||||
def self.hex2utf8(s)
|
def self.hex2utf8(s)
|
||||||
s.split(' ').map { |c| c.to_i(16) }.pack('U*')
|
s.split(' ').map { |c| c.to_i(16) }.pack('U*')
|
||||||
|
|
|
@ -17,7 +17,11 @@ class TestCaseFold < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def read_tests
|
def read_tests
|
||||||
IO.readlines(File.expand_path("../../../enc/unicode/data/#{UNICODE_VERSION}/CaseFolding.txt", __dir__), encoding: Encoding::ASCII_8BIT)
|
path = "../../../enc/unicode/data/#{UNICODE_VERSION}"
|
||||||
|
name = "CaseFolding.txt"
|
||||||
|
(%w[/ucd/ /].any? do |sub|
|
||||||
|
break IO.readlines(File.expand_path("#{path}#{sub}#{name}", __dir__), encoding: Encoding::ASCII_8BIT) rescue nil
|
||||||
|
end or raise)
|
||||||
.collect.with_index { |linedata, linenumber| [linenumber.to_i+1, linedata.chomp] }
|
.collect.with_index { |linedata, linenumber| [linenumber.to_i+1, linedata.chomp] }
|
||||||
.reject { |number, data| data =~ /^(#|$)/ }
|
.reject { |number, data| data =~ /^(#|$)/ }
|
||||||
.collect do |linenumber, linedata|
|
.collect do |linenumber, linedata|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче