aboutsummaryrefslogtreecommitdiffstats
path: root/test/test_unicode_normalize.rb
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-06-28 06:56:50 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-06-28 06:56:50 +0000
commit7090726174aecf3657fe21437d6cdddc436f5b71 (patch)
treea80b72df76cf2c1aceec06564c3d219168cdeb40 /test/test_unicode_normalize.rb
parent02f18c0cdb2d4e5478d9a2e810513de4f76706b3 (diff)
downloadruby-7090726174aecf3657fe21437d6cdddc436f5b71.tar.gz
Skip unavailable tests
* test/ruby/enc/test_case_comprehensive.rb: noting to test if Unicode data files are available. [ruby-core:76160] [Bug #12433] * test/test_unicode_normalize.rb: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55521 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/test_unicode_normalize.rb')
-rw-r--r--test/test_unicode_normalize.rb24
1 files changed, 14 insertions, 10 deletions
diff --git a/test/test_unicode_normalize.rb b/test/test_unicode_normalize.rb
index 211f8f5430..be1bf5f49b 100644
--- a/test/test_unicode_normalize.rb
+++ b/test/test_unicode_normalize.rb
@@ -11,15 +11,24 @@ class TestUnicodeNormalize < Test::Unit::TestCase
UNICODE_VERSION = UnicodeNormalize::UNICODE_VERSION
UNICODE_DATA_PATH = "../enc/unicode/data/#{UNICODE_VERSION}"
- def expand_filename(basename)
+ def self.expand_filename(basename)
File.expand_path("#{UNICODE_DATA_PATH}/#{basename}.txt", __dir__)
end
+end
+%w[NormalizationTest].all? {|f|
+ File.exist?(TestUnicodeNormalize.expand_filename(f))
+} and
+class TestUnicodeNormalize
NormTest = Struct.new :source, :NFC, :NFD, :NFKC, :NFKD, :line
- def read_tests
- IO.readlines(expand_filename('NormalizationTest'), encoding: 'utf-8')
- .tap { |lines| assert_include(lines[0], "NormalizationTest-#{UNICODE_VERSION}.txt")}
+ def self.read_tests
+ lines = IO.readlines(expand_filename('NormalizationTest'), encoding: 'utf-8')
+ firstline = lines.shift
+ define_method "test_0_normalizationtest_firstline" do
+ assert_include(firstline, "NormalizationTest-#{UNICODE_VERSION}.txt")
+ end
+ lines
.collect.with_index { |linedata, linenumber| [linedata, linenumber]}
.reject { |line| line[0] =~ /^[\#@]/ }
.collect do |line|
@@ -33,7 +42,7 @@ class TestUnicodeNormalize < Test::Unit::TestCase
string.codepoints.collect { |cp| cp.to_s(16).upcase.rjust(4, '0') }
end
- def setup
+ begin
@@tests ||= read_tests
rescue Errno::ENOENT => e
@@tests ||= []
@@ -137,11 +146,6 @@ class TestUnicodeNormalize < Test::Unit::TestCase
generate_test_check_false :NFD, :NFKC, :nfkc
generate_test_check_false :NFKD, :NFKC, :nfkc
- def test_AAAAA_data_file_available # AAAAA makes sure this test is run first
- expanded = expand_filename 'NormalizationTest'
- assert File.exist?(expanded), "File #{expanded} missing."
- end
-
def test_non_UTF_8
assert_equal "\u1E0A".encode('UTF-16BE'), "D\u0307".encode('UTF-16BE').unicode_normalize(:nfc)
assert_equal true, "\u1E0A".encode('UTF-16BE').unicode_normalized?(:nfc)