[前][次][番号順一覧][スレッド一覧]

ruby-changes:66908

From: Martin <ko1@a...>
Date: Tue, 27 Jul 2021 17:15:20 +0900 (JST)
Subject: [ruby-changes:66908] 3010b40477 (master): Adjust test/ruby/enc/test_emoji_breaks.rb to handle Emoji Version 13.1

https://git.ruby-lang.org/ruby.git/commit/?id=3010b40477

From 3010b4047727a17fe5b09df15ee3ea1b7efc2cc1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Martin=20D=C3=BCrst?= <duerst@i...>
Date: Tue, 27 Jul 2021 17:05:06 +0900
Subject: 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.
---
 test/ruby/enc/test_emoji_breaks.rb | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/test/ruby/enc/test_emoji_breaks.rb b/test/ruby/enc/test_emoji_breaks.rb
index 8f73a72..e765b10 100644
--- a/test/ruby/enc/test_emoji_breaks.rb
+++ b/test/ruby/enc/test_emoji_breaks.rb
@@ -32,12 +32,13 @@ class TestEmojiBreaks::BreakTest https://github.com/ruby/ruby/blob/trunk/test/ruby/enc/test_emoji_breaks.rb#L32
 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 https://github.com/ruby/ruby/blob/trunk/test/ruby/enc/test_emoji_breaks.rb#L54
   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 https://github.com/ruby/ruby/blob/trunk/test/ruby/enc/test_emoji_breaks.rb#L81
       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
-- 
cgit v1.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]