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

ruby-changes:43233

From: duerst <ko1@a...>
Date: Tue, 7 Jun 2016 16:13:43 +0900 (JST)
Subject: [ruby-changes:43233] duerst:r55307 (trunk): * test/ruby/enc/test_case_comprehensive: Add regression tests for

duerst	2016-06-07 16:13:39 +0900 (Tue, 07 Jun 2016)

  New Revision: 55307

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=55307

  Log:
    * test/ruby/enc/test_case_comprehensive: Add regression tests for
      current ASCII-only case conversion.

  Modified files:
    trunk/ChangeLog
    trunk/test/ruby/enc/test_case_comprehensive.rb
Index: test/ruby/enc/test_case_comprehensive.rb
===================================================================
--- test/ruby/enc/test_case_comprehensive.rb	(revision 55306)
+++ test/ruby/enc/test_case_comprehensive.rb	(revision 55307)
@@ -127,6 +127,56 @@ class TestComprehensiveCaseFold < Test:: https://github.com/ruby/ruby/blob/trunk/test/ruby/enc/test_case_comprehensive.rb#L127
     end
   end
 
+  # temporary test to avoid regression when switching to primitives
+  def self.generate_ascii_only_case_mapping_tests (encoding)
+    all_tests
+    # preselect codepoints to speed up testing for small encodings
+    codepoints = @@codepoints.select do |code|
+      begin
+        code.encode(encoding)
+        true
+      rescue Encoding::UndefinedConversionError
+        false
+      end
+    end
+    define_method "test_#{encoding}_upcase" do
+      codepoints.each do |code|
+        begin
+          source = code.encode(encoding) * 5
+          target = source.tr 'a-z', 'A-Z'
+          result = source.upcase
+          assert_equal target, result,
+            "from #{code*5} (#{source.dump}) expected #{target.dump} but was #{result.dump}"
+        rescue Encoding::UndefinedConversionError
+        end
+      end
+    end
+    define_method "test_#{encoding}_downcase" do
+      codepoints.each do |code|
+        begin
+          source = code.encode(encoding) * 5
+          target = source.tr 'A-Z', 'a-z'
+          result = source.downcase
+          assert_equal target, result,
+            "from #{code*5} (#{source.dump}) expected #{target.dump} but was #{result.dump}"
+        rescue Encoding::UndefinedConversionError
+        end
+      end
+    end
+    define_method "test_#{encoding}_capitalize" do
+      codepoints.each do |code|
+        begin
+          source = code.encode(encoding) * 5
+          target = source[0].tr('a-z', 'A-Z') + source[1..-1].tr('A-Z', 'a-z')
+          result = source.capitalize
+          assert_equal target, result,
+            "from #{code*5} (#{source.dump}) expected #{target.dump} but was #{result.dump}"
+        rescue Encoding::UndefinedConversionError
+        end
+      end
+    end
+  end
+
   def check_file_available(filename)
     expanded = self.class.expand_filename(filename)
     assert File.exist?(expanded), "File #{expanded} missing."
@@ -136,6 +186,39 @@ class TestComprehensiveCaseFold < Test:: https://github.com/ruby/ruby/blob/trunk/test/ruby/enc/test_case_comprehensive.rb#L186
     %w[UnicodeData CaseFolding SpecialCasing].each { |f| check_file_available f }
   end
 
+  generate_ascii_only_case_mapping_tests 'ISO-8859-1'
+  generate_ascii_only_case_mapping_tests 'ISO-8859-2'
+  generate_ascii_only_case_mapping_tests 'ISO-8859-3'
+  generate_ascii_only_case_mapping_tests 'ISO-8859-4'
+  generate_ascii_only_case_mapping_tests 'ISO-8859-5'
+  generate_ascii_only_case_mapping_tests 'ISO-8859-6'
+  generate_ascii_only_case_mapping_tests 'ISO-8859-7'
+  generate_ascii_only_case_mapping_tests 'ISO-8859-8'
+  generate_ascii_only_case_mapping_tests 'ISO-8859-9'
+  generate_ascii_only_case_mapping_tests 'ISO-8859-10'
+  generate_ascii_only_case_mapping_tests 'ISO-8859-11'
+  generate_ascii_only_case_mapping_tests 'ISO-8859-13'
+  generate_ascii_only_case_mapping_tests 'ISO-8859-14'
+  generate_ascii_only_case_mapping_tests 'ISO-8859-15'
+  generate_ascii_only_case_mapping_tests 'ISO-8859-16'
+  generate_ascii_only_case_mapping_tests 'KOI8-R'
+  generate_ascii_only_case_mapping_tests 'KOI8-U'
+  generate_ascii_only_case_mapping_tests 'Big5'
+  generate_ascii_only_case_mapping_tests 'EUC-JP'
+  generate_ascii_only_case_mapping_tests 'EUC-KR'
+  generate_ascii_only_case_mapping_tests 'GB18030'
+  generate_ascii_only_case_mapping_tests 'GB2312'
+  generate_ascii_only_case_mapping_tests 'GBK'
+  generate_ascii_only_case_mapping_tests 'Shift_JIS'
+  generate_ascii_only_case_mapping_tests 'Windows-31J'
+  generate_ascii_only_case_mapping_tests 'Windows-1250'
+  generate_ascii_only_case_mapping_tests 'Windows-1251'
+  generate_ascii_only_case_mapping_tests 'Windows-1252'
+  generate_ascii_only_case_mapping_tests 'Windows-1253'
+  generate_ascii_only_case_mapping_tests 'Windows-1254'
+  generate_ascii_only_case_mapping_tests 'Windows-1255'
+  generate_ascii_only_case_mapping_tests 'Windows-1256'
+  generate_ascii_only_case_mapping_tests 'Windows-1257'
   generate_case_mapping_tests 'US-ASCII'
   generate_case_mapping_tests 'ASCII-8BIT'
   generate_case_mapping_tests 'UTF-8'
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 55306)
+++ ChangeLog	(revision 55307)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Tue Jun  7 16:13:36 2016  Martin Duerst  <duerst@i...>
+
+	* test/ruby/enc/test_case_comprehensive: Add regression tests for
+	  current ASCII-only case conversion.
+
 Tue Jun  7 15:28:38 2016  Martin Duerst  <duerst@i...>
 
 	* test/ruby/enc/test_case_comprehensive: Fix method name

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

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