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

ruby-changes:43319

From: duerst <ko1@a...>
Date: Mon, 13 Jun 2016 16:59:03 +0900 (JST)
Subject: [ruby-changes:43319] duerst:r55392 (trunk): * test/ruby/enc/test_case_comprehensive.rb: Add tests for full Unicode

duerst	2016-06-13 16:58:57 +0900 (Mon, 13 Jun 2016)

  New Revision: 55392

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

  Log:
    * test/ruby/enc/test_case_comprehensive.rb: Add tests for full Unicode
      swapcase.

  Modified files:
    trunk/ChangeLog
    trunk/test/ruby/enc/test_case_comprehensive.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 55391)
+++ ChangeLog	(revision 55392)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Mon Jun 13 16:58:53 2016  Martin Duerst  <duerst@i...>
+
+	* test/ruby/enc/test_case_comprehensive.rb: Add tests for full Unicode
+	  swapcase.
+
 Sun Jun 12 14:48:00 2016  Martin Duerst  <duerst@i...>
 
 	* test/ruby/enc/test_case_comprehensive.rb: Add tests for ASCII-only
Index: test/ruby/enc/test_case_comprehensive.rb
===================================================================
--- test/ruby/enc/test_case_comprehensive.rb	(revision 55391)
+++ test/ruby/enc/test_case_comprehensive.rb	(revision 55392)
@@ -45,9 +45,11 @@ class TestComprehensiveCaseFold < Test:: https://github.com/ruby/ruby/blob/trunk/test/ruby/enc/test_case_comprehensive.rb#L45
     upcase    = Hash.new { |h, c| h[c] = c }
     titlecase = Hash.new { |h, c| h[c] = c }
     casefold  = Hash.new { |h, c| h[c] = c }
+    swapcase  = Hash.new { |h, c| h[c] = c }
     turkic_upcase    = Hash.new { |h, c| h[c] = upcase[c] }
     turkic_downcase  = Hash.new { |h, c| h[c] = downcase[c] }
     turkic_titlecase = Hash.new { |h, c| h[c] = titlecase[c] }
+    turkic_swapcase  = Hash.new { |h, c| h[c] = swapcase[c] }
     ascii_upcase     = Hash.new { |h, c| h[c] = c =~ /^[a-zA-Z]$/ ? upcase[c] : c }
     ascii_downcase   = Hash.new { |h, c| h[c] = c =~ /^[a-zA-Z]$/ ? downcase[c] : c }
     ascii_titlecase  = Hash.new { |h, c| h[c] = c =~ /^[a-zA-Z]$/ ? titlecase[c] : c }
@@ -78,15 +80,40 @@ class TestComprehensiveCaseFold < Test:: https://github.com/ruby/ruby/blob/trunk/test/ruby/enc/test_case_comprehensive.rb#L80
       end
     end
 
+    @@codepoints.each do |c|
+      if upcase[c] != c
+        if downcase[c] != c
+          swapcase[c] = turkic_swapcase[c] =
+            case c
+            when "\u01C5" then "\u0064\u017D"
+            when "\u01C8" then "\u006C\u004A"
+            when "\u01CB" then "\u006E\u004A"
+            when "\u01F2" then "\u0064\u005A"
+            else # Greek
+              downcase[upcase[c][0]] + "\u0399"
+            end
+        else
+          swapcase[c] = upcase[c]
+          turkic_swapcase[c] = turkic_upcase[c]
+        end
+      else
+        if downcase[c] != c
+          swapcase[c] = downcase[c]
+          turkic_swapcase[c] = turkic_downcase[c]
+        end
+      end
+    end
+
     tests = [
       CaseTest.new(:downcase,   [], downcase),
       CaseTest.new(:upcase,     [], upcase),
       CaseTest.new(:capitalize, [], titlecase, downcase),
-      # swapcase?????!!!!!
+      CaseTest.new(:swapcase,   [], swapcase),
       CaseTest.new(:downcase,   [:fold],       casefold),
       CaseTest.new(:upcase,     [:turkic],     turkic_upcase),
       CaseTest.new(:downcase,   [:turkic],     turkic_downcase),
       CaseTest.new(:capitalize, [:turkic],     turkic_titlecase, turkic_downcase),
+      CaseTest.new(:swapcase,   [:turkic],     turkic_swapcase),
       CaseTest.new(:upcase,     [:ascii],      ascii_upcase),
       CaseTest.new(:downcase,   [:ascii],      ascii_downcase),
       CaseTest.new(:capitalize, [:ascii],      ascii_titlecase, ascii_downcase),

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

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