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

ruby-changes:39049

From: nagachika <ko1@a...>
Date: Sat, 4 Jul 2015 03:55:39 +0900 (JST)
Subject: [ruby-changes:39049] nagachika:r51130 (ruby_2_2): merge revision(s) 50366: [Backport #11045]

nagachika	2015-07-04 03:55:25 +0900 (Sat, 04 Jul 2015)

  New Revision: 51130

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

  Log:
    merge revision(s) 50366: [Backport #11045]
    
    * test/ruby/test_m17n_comb.rb: test_str_crypt split into strict
      and non-strict versions to allow masking out non-strict when
      glibc version cannot be determined (#11045).

  Modified directories:
    branches/ruby_2_2/
  Modified files:
    branches/ruby_2_2/test/ruby/test_m17n_comb.rb
    branches/ruby_2_2/version.h
Index: ruby_2_2/version.h
===================================================================
--- ruby_2_2/version.h	(revision 51129)
+++ ruby_2_2/version.h	(revision 51130)
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_2/version.h#L1
 #define RUBY_VERSION "2.2.3"
 #define RUBY_RELEASE_DATE "2015-07-04"
-#define RUBY_PATCHLEVEL 140
+#define RUBY_PATCHLEVEL 141
 
 #define RUBY_RELEASE_YEAR 2015
 #define RUBY_RELEASE_MONTH 7
Index: ruby_2_2/test/ruby/test_m17n_comb.rb
===================================================================
--- ruby_2_2/test/ruby/test_m17n_comb.rb	(revision 51129)
+++ ruby_2_2/test/ruby/test_m17n_comb.rb	(revision 51130)
@@ -743,28 +743,43 @@ class TestM17NComb < Test::Unit::TestCas https://github.com/ruby/ruby/blob/trunk/ruby_2_2/test/ruby/test_m17n_comb.rb#L743
     }
   end
 
-  def test_str_crypt
-    strict_crypt = nil
-    # glibc 2.16 or later denies salt contained other than [0-9A-Za-z./] #7312
-    if defined? Etc::CS_GNU_LIBC_VERSION
-      glibcver = Etc.confstr(Etc::CS_GNU_LIBC_VERSION).scan(/\d+/).map(&:to_i)
-      strict_crypt = (glibcver <=> [2, 16]) >= 0
-    end
+  # glibc 2.16 or later denies salt contained other than [0-9A-Za-z./] #7312
+  # we use this check to test strict and non-strict behavior separately #11045
+  strict_crypt = if defined? Etc::CS_GNU_LIBC_VERSION
+    glibcver = Etc.confstr(Etc::CS_GNU_LIBC_VERSION).scan(/\d+/).map(&:to_i)
+    (glibcver <=> [2, 16]) >= 0
+  end
 
+  def test_str_crypt
     combination(STRINGS, STRINGS) {|str, salt|
-      if strict_crypt
-        next unless salt.ascii_only? && /\A[0-9a-zA-Z.\/]+\z/ =~ salt
-      end
-      if b(salt).length < 2
-        assert_raise(ArgumentError) { str.crypt(salt) }
-        next
-      end
-      t = str.crypt(salt)
-      assert_equal(b(str).crypt(b(salt)), t, "#{encdump(str)}.crypt(#{encdump(salt)})")
-      assert_encoding('ASCII-8BIT', t.encoding)
+      # skip input other than [0-9A-Za-z./] to confirm strict behavior
+      next unless salt.ascii_only? && /\A[0-9a-zA-Z.\/]+\z/ =~ salt
+
+      confirm_crypt_result(str, salt)
     }
   end
 
+  if !strict_crypt
+    def test_str_crypt_nonstrict
+      combination(STRINGS, STRINGS) {|str, salt|
+        # only test input other than [0-9A-Za-z./] to confirm non-strict behavior
+        next if salt.ascii_only? && /\A[0-9a-zA-Z.\/]+\z/ =~ salt
+
+        confirm_crypt_result(str, salt)
+      }
+    end
+  end
+
+  private def confirm_crypt_result(str, salt)
+    if b(salt).length < 2
+      assert_raise(ArgumentError) { str.crypt(salt) }
+      return
+    end
+    t = str.crypt(salt)
+    assert_equal(b(str).crypt(b(salt)), t, "#{encdump(str)}.crypt(#{encdump(salt)})")
+    assert_encoding('ASCII-8BIT', t.encoding)
+  end
+
   def test_str_delete
     combination(STRINGS, STRINGS) {|s1, s2|
       if s1.empty?

Property changes on: ruby_2_2
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r50366


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

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