mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Adjust test/ruby/enc/test_emoji_breaks.rb to handle Emoji Version 13.1
Deal with the issue that the emoji files in emoji/13.1 have Unicode Emoji version 13.1, but at the same time the files in 13.0.0/ucd/emoji are still at Emoji version 13.0. Specifically: - Add a version attribute to TestEmojiBreaks::BreakFile - Take the version for emoji-variant-sequences.txt from the Unicode version, removing the last two characters. - Improve information in exceptions for file name and version mismatches.
This commit is contained in:
parent
01e98d8785
commit
3010b40477
1 changed files with 8 additions and 7 deletions
|
@ -32,12 +32,13 @@ class TestEmojiBreaks::BreakTest
|
|||
end
|
||||
|
||||
class TestEmojiBreaks::BreakFile
|
||||
attr_reader :basename, :fullname
|
||||
attr_reader :basename, :fullname, :version
|
||||
FILES = []
|
||||
|
||||
def initialize(basename, path)
|
||||
def initialize(basename, path, version)
|
||||
@basename = basename
|
||||
@fullname = "#{path}/#{basename}.txt" # File.expand_path(path + version, __dir__)
|
||||
@version = version
|
||||
FILES << self
|
||||
end
|
||||
|
||||
|
@ -53,9 +54,9 @@ class TestEmojiBreaks < Test::Unit::TestCase
|
|||
EMOJI_DATA_PATH = File.expand_path("../../../enc/unicode/data/emoji/#{EMOJI_VERSION}", __dir__)
|
||||
|
||||
EMOJI_DATA_FILES = %w[emoji-sequences emoji-test emoji-zwj-sequences].map do |basename|
|
||||
BreakFile.new(basename, EMOJI_DATA_PATH)
|
||||
BreakFile.new(basename, EMOJI_DATA_PATH, EMOJI_VERSION)
|
||||
end
|
||||
UNICODE_DATA_FILE = BreakFile.new('emoji-variation-sequences', UNICODE_DATA_PATH)
|
||||
UNICODE_DATA_FILE = BreakFile.new('emoji-variation-sequences', UNICODE_DATA_PATH, UNICODE_VERSION[0..-3]) # [0..-3] deals with a versioning mismatch problem in Unicode
|
||||
EMOJI_DATA_FILES << UNICODE_DATA_FILE
|
||||
|
||||
def self.data_files_available?
|
||||
|
@ -80,12 +81,12 @@ TestEmojiBreaks.data_files_available? and class TestEmojiBreaks
|
|||
file_tests = []
|
||||
IO.foreach(file.fullname, encoding: Encoding::UTF_8) do |line|
|
||||
line.chomp!
|
||||
raise "File Name Mismatch" if $.==1 and not line=="# #{file.basename}.txt"
|
||||
version_mismatch = false if line=="# Version: #{EMOJI_VERSION}"
|
||||
raise "File Name Mismatch: line: #{line}, expected filename: #{file.basename}.txt" if $.==1 and not line=="# #{file.basename}.txt"
|
||||
version_mismatch = false if line =~ /^# Version: #{file.version}/
|
||||
next if /\A(#|\z)/.match? line
|
||||
file_tests << BreakTest.new(file.basename, $., *line.split('#')) rescue 'whatever'
|
||||
end
|
||||
raise "File Version Mismatch" if version_mismatch
|
||||
raise "File Version Mismatch: file: #{file.fullname}, version: #{file.version}" if version_mismatch
|
||||
tests += file_tests
|
||||
end
|
||||
tests
|
||||
|
|
Loading…
Add table
Reference in a new issue