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

ruby-changes:29219

From: shugo <ko1@a...>
Date: Thu, 13 Jun 2013 14:42:00 +0900 (JST)
Subject: [ruby-changes:29219] shugo:r41271 (trunk): * test/-ext-/test_printf.rb, test/rss/test_parser.rb,

shugo	2013-06-13 14:41:44 +0900 (Thu, 13 Jun 2013)

  New Revision: 41271

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

  Log:
    * test/-ext-/test_printf.rb, test/rss/test_parser.rb,
      test/ruby/test_array.rb, test/ruby/test_hash.rb,
      test/ruby/test_m17n.rb, test/ruby/test_marshal.rb,
      test/ruby/test_object.rb, test/ruby/test_string.rb: don't use
      untrusted?, untrust, and trust to avoid warnings in case $VERBOSE is
      true.

  Modified files:
    trunk/ChangeLog
    trunk/test/-ext-/test_printf.rb
    trunk/test/rss/test_parser.rb
    trunk/test/ruby/test_array.rb
    trunk/test/ruby/test_hash.rb
    trunk/test/ruby/test_m17n.rb
    trunk/test/ruby/test_marshal.rb
    trunk/test/ruby/test_object.rb
    trunk/test/ruby/test_string.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 41270)
+++ ChangeLog	(revision 41271)
@@ -1,3 +1,12 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Thu Jun 13 14:39:08 2013  Shugo Maeda  <shugo@r...>
+
+	* test/-ext-/test_printf.rb, test/rss/test_parser.rb,
+	  test/ruby/test_array.rb, test/ruby/test_hash.rb,
+	  test/ruby/test_m17n.rb, test/ruby/test_marshal.rb,
+	  test/ruby/test_object.rb, test/ruby/test_string.rb: don't use
+	  untrusted?, untrust, and trust to avoid warnings in case $VERBOSE is
+	  true.
+
 Thu Jun 13 10:47:16 2013  Shugo Maeda  <shugo@r...>
 
 	* bootstraptest/test_autoload.rb, bootstraptest/test_method.rb:
Index: test/ruby/test_m17n.rb
===================================================================
--- test/ruby/test_m17n.rb	(revision 41270)
+++ test/ruby/test_m17n.rb	(revision 41271)
@@ -1486,8 +1486,6 @@ class TestM17N < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_m17n.rb#L1486
     assert_equal(Encoding::ASCII_8BIT, s.b.encoding)
     s.taint
     assert_equal(true, s.b.tainted?)
-    s.untrust
-    assert_equal(true, s.b.untrusted?)
     s = "abc".b
     assert_equal(true, s.b.ascii_only?)
   end
Index: test/ruby/test_array.rb
===================================================================
--- test/ruby/test_array.rb	(revision 41270)
+++ test/ruby/test_array.rb	(revision 41271)
@@ -476,20 +476,16 @@ class TestArray < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_array.rb#L476
 
   def test_clone
     for taint in [ false, true ]
-      for untrust in [ false, true ]
-        for frozen in [ false, true ]
-          a = @cls[*(0..99).to_a]
-          a.taint  if taint
-          a.untrust  if untrust
-          a.freeze if frozen
-          b = a.clone
-
-          assert_equal(a, b)
-          assert_not_equal(a.__id__, b.__id__)
-          assert_equal(a.frozen?, b.frozen?)
-          assert_equal(a.untrusted?, b.untrusted?)
-          assert_equal(a.tainted?, b.tainted?)
-        end
+      for frozen in [ false, true ]
+        a = @cls[*(0..99).to_a]
+        a.taint  if taint
+        a.freeze if frozen
+        b = a.clone
+
+        assert_equal(a, b)
+        assert_not_equal(a.__id__, b.__id__)
+        assert_equal(a.frozen?, b.frozen?)
+        assert_equal(a.tainted?, b.tainted?)
       end
     end
   end
@@ -756,10 +752,8 @@ class TestArray < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_array.rb#L752
 
     a6 = @cls[[1, 2], 3]
     a6.taint
-    a6.untrust
     a7 = a6.flatten
     assert_equal(true, a7.tainted?)
-    assert_equal(true, a7.untrusted?)
 
     a8 = @cls[[1, 2], 3]
     a9 = a8.flatten(0)
@@ -950,23 +944,18 @@ class TestArray < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_array.rb#L944
     $, = ""
     a = @cls[1, 2, 3]
     a.taint
-    a.untrust
     s = a.join
     assert_equal(true, s.tainted?)
-    assert_equal(true, s.untrusted?)
 
     bug5902 = '[ruby-core:42161]'
-    sep = ":".taint.untrust
+    sep = ":".taint
 
     s = @cls[].join(sep)
     assert_equal(false, s.tainted?, bug5902)
-    assert_equal(false, s.untrusted?, bug5902)
     s = @cls[1].join(sep)
     assert_equal(false, s.tainted?, bug5902)
-    assert_equal(false, s.untrusted?, bug5902)
     s = @cls[1, 2].join(sep)
     assert_equal(true, s.tainted?, bug5902)
-    assert_equal(true, s.untrusted?, bug5902)
 
     e = ''.force_encoding('EUC-JP')
     u = ''.force_encoding('UTF-8')
@@ -2170,10 +2159,8 @@ class TestArray < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_array.rb#L2159
   def test_inspect
     a = @cls[1, 2, 3]
     a.taint
-    a.untrust
     s = a.inspect
     assert_equal(true, s.tainted?)
-    assert_equal(true, s.untrusted?)
   end
 
   def test_initialize2
Index: test/ruby/test_string.rb
===================================================================
--- test/ruby/test_string.rb	(revision 41270)
+++ test/ruby/test_string.rb	(revision 41271)
@@ -451,20 +451,16 @@ class TestString < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_string.rb#L451
 
   def test_clone
     for taint in [ false, true ]
-      for untrust in [ false, true ]
-        for frozen in [ false, true ]
-          a = S("Cool")
-          a.taint  if taint
-          a.untrust  if untrust
-          a.freeze if frozen
-          b = a.clone
-
-          assert_equal(a, b)
-          assert(a.__id__ != b.__id__)
-          assert_equal(a.frozen?, b.frozen?)
-          assert_equal(a.untrusted?, b.untrusted?)
-          assert_equal(a.tainted?, b.tainted?)
-        end
+      for frozen in [ false, true ]
+        a = S("Cool")
+        a.taint  if taint
+        a.freeze if frozen
+        b = a.clone
+
+        assert_equal(a, b)
+        assert(a.__id__ != b.__id__)
+        assert_equal(a.frozen?, b.frozen?)
+        assert_equal(a.tainted?, b.tainted?)
       end
     end
 
@@ -588,20 +584,16 @@ class TestString < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_string.rb#L584
 
   def test_dup
     for taint in [ false, true ]
-      for untrust in [ false, true ]
-        for frozen in [ false, true ]
-          a = S("hello")
-          a.taint  if taint
-          a.untrust  if untrust
-          a.freeze if frozen
-          b = a.dup
-
-          assert_equal(a, b)
-          assert(a.__id__ != b.__id__)
-          assert(!b.frozen?)
-          assert_equal(a.tainted?, b.tainted?)
-          assert_equal(a.untrusted?, b.untrusted?)
-        end
+      for frozen in [ false, true ]
+        a = S("hello")
+        a.taint  if taint
+        a.freeze if frozen
+        b = a.dup
+
+        assert_equal(a, b)
+        assert(a.__id__ != b.__id__)
+        assert(!b.frozen?)
+        assert_equal(a.tainted?, b.tainted?)
       end
     end
   end
@@ -817,9 +809,7 @@ class TestString < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_string.rb#L809
 
     a = S("hello")
     a.taint
-    a.untrust
     assert(a.gsub(/./, S('X')).tainted?)
-    assert(a.gsub(/./, S('X')).untrusted?)
 
     assert_equal("z", "abc".gsub(/./, "a" => "z"), "moved from btest/knownbug")
 
@@ -862,10 +852,8 @@ class TestString < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_string.rb#L852
 
     r = S('X')
     r.taint
-    r.untrust
     a.gsub!(/./, r)
     assert(a.tainted?)
-    assert(a.untrusted?)
 
     a = S("hello")
     assert_nil(a.sub!(S('X'), S('Y')))
@@ -1054,11 +1042,9 @@ class TestString < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_string.rb#L1042
 
     a = S("foo")
     a.taint
-    a.untrust
     b = a.replace(S("xyz"))
     assert_equal(S("xyz"), b)
     assert(b.tainted?)
-    assert(b.untrusted?)
 
     s = "foo" * 100
     s2 = ("bar" * 100).dup
@@ -1152,11 +1138,9 @@ class TestString < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_string.rb#L1138
 
     a = S("hello")
     a.taint
-    a.untrust
     res = []
     a.scan(/./) { |w| res << w }
     assert(res[0].tainted?, '[ruby-core:33338] #4087')
-    assert(res[0].untrusted?, '[ruby-core:33338] #4087')
   end
 
   def test_size
@@ -1439,10 +1423,8 @@ class TestString < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_string.rb#L1423
 
     a = S("hello")
     a.taint
-    a.untrust
     x = a.sub(/./, S('X'))
     assert(x.tainted?)
-    assert(x.untrusted?)
 
     o = Object.new
     def o.to_str; "bar"; end
@@ -1483,10 +1465,8 @@ class TestString < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_string.rb#L1465
 
     r = S('X')
     r.taint
-    r.untrust
     a.sub!(/./, r)
     assert(a.tainted?)
-    assert(a.untrusted?)
   end
 
   def test_succ
Index: test/ruby/test_object.rb
===================================================================
--- test/ruby/test_object.rb	(revision 41270)
+++ test/ruby/test_object.rb	(revision 41271)
@@ -652,29 +652,33 @@ class TestObject < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_object.rb#L652
   end
 
   def test_untrusted
-    obj = Object.new
-    assert_equal(false, obj.untrusted?)
-    assert_equal(false, obj.tainted?)
-    obj.untrust
-    assert_equal(true, obj.untrusted?)
-    assert_equal(true, obj.tainted?)
-    obj.trust
-    assert_equal(false, obj.untrusted?)
-    assert_equal(false, obj.tainted?)
-    obj.taint
-    assert_equal(true, obj.untrusted?)
-    assert_equal(true, obj.tainted?)
-    obj.untaint
-    assert_equal(false, obj.untrusted?)
-    assert_equal(false, obj.tainted?)
+    verbose = $VERBOSE
+    $VERBOSE = false
+    begin
+      obj = Object.new
+      assert_equal(false, obj.untrusted?)
+      assert_equal(false, obj.tainted?)
+      obj.untrust
+      assert_equal(true, obj.untrusted?)
+      assert_equal(true, obj.tainted?)
+      obj.trust
+      assert_equal(false, obj.untrusted?)
+      assert_equal(false, obj.tainted?)
+      obj.taint
+      assert_equal(true, obj.untrusted?)
+      assert_equal(true, obj.tainted?)
+      obj.untaint
+      assert_equal(false, obj.untrusted?)
+      assert_equal(false, obj.tainted?)
+    ensure
+      $VERBOSE = verbose
+    end
   end
 
   def test_to_s
     x = Object.new
     x.taint
-    x.untrust
     s = x.to_s
-    assert_equal(true, s.untrusted?)
     assert_equal(true, s.tainted?)
 
     x = eval(<<-EOS)
Index: test/ruby/test_marshal.rb
===================================================================
--- test/ruby/test_marshal.rb	(revision 41270)
+++ test/ruby/test_marshal.rb	(revision 41271)
@@ -187,80 +187,55 @@ class TestMarshal < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_marshal.rb#L187
     end
   end
 
-  def test_taint_and_untrust
+  def test_taint
     x = Object.new
     x.taint
-    x.untrust
     s = Marshal.dump(x)
     assert_equal(true, s.tainted?)
-    assert_equal(true, s.untrusted?)
     y = Marshal.load(s)
     assert_equal(true, y.tainted?)
-    assert_equal(true, y.untrusted?)
   end
 
-  def test_taint_and_untrust_each_object
+  def test_taint_each_object
     x = Object.new
     obj = [[x]]
 
     # clean object causes crean stream
     assert_equal(false, obj.tainted?)
-    assert_equal(false, obj.untrusted?)
     assert_equal(false, obj.first.tainted?)
-    assert_equal(false, obj.first.untrusted?)
     assert_equal(false, obj.first.first.tainted?)
-    assert_equal(false, obj.first.first.untrusted?)
     s = Marshal.dump(obj)
     assert_equal(false, s.tainted?)
-    assert_equal(false, s.untrusted?)
 
-    # tainted/untrusted object causes tainted/untrusted stream
+    # tainted object causes tainted stream
     x.taint
-    x.untrust
     assert_equal(false, obj.tainted?)
-    assert_equal(false, obj.untrusted?)
     assert_equal(false, obj.first.tainted?)
-    assert_equal(false, obj.first.untrusted?)
     assert_equal(true, obj.first.first.tainted?)
-    assert_equal(true, obj.first.first.untrusted?)
     t = Marshal.dump(obj)
     assert_equal(true, t.tainted?)
-    assert_equal(true, t.untrusted?)
 
     # clean stream causes clean objects
     assert_equal(false, s.tainted?)
-    assert_equal(false, s.untrusted?)
     y = Marshal.load(s)
     assert_equal(false, y.tainted?)
-    assert_equal(false, y.untrusted?)
     assert_equal(false, y.first.tainted?)
-    assert_equal(false, y.first.untrusted?)
     assert_equal(false, y.first.first.tainted?)
-    assert_equal(false, y.first.first.untrusted?)
 
-    # tainted/untrusted stream causes tainted/untrusted objects
+    # tainted stream causes tainted objects
     assert_equal(true, t.tainted?)
-    assert_equal(true, t.untrusted?)
     y = Marshal.load(t)
     assert_equal(true, y.tainted?)
-    assert_equal(true, y.untrusted?)
     assert_equal(true, y.first.tainted?)
-    assert_equal(true, y.first.untrusted?)
     assert_equal(true, y.first.first.tainted?)
-    assert_equal(true, y.first.first.untrusted?)
 
     # same tests by different senario
     s.taint
-    s.untrust
     assert_equal(true, s.tainted?)
-    assert_equal(true, s.untrusted?)
     y = Marshal.load(s)
     assert_equal(true, y.tainted?)
-    assert_equal(true, y.untrusted?)
     assert_equal(true, y.first.tainted?)
-    assert_equal(true, y.first.untrusted?)
     assert_equal(true, y.first.first.tainted?)
-    assert_equal(true, y.first.first.untrusted?)
   end
 
   def test_symbol2
@@ -511,11 +486,9 @@ class TestMarshal < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_marshal.rb#L486
     bug7325 = '[ruby-core:49198]'
     for c in [TestClass, TestModule]
       assert(!c.tainted?)
-      assert(!c.untrusted?)
-      c2 = Marshal.load(Marshal.dump(c).taint.untrust)
+      c2 = Marshal.load(Marshal.dump(c).taint)
       assert_same(c, c2)
       assert(!c.tainted?, bug7325)
-      assert(!c.untrusted?, bug7325)
     end
   end
 
Index: test/ruby/test_hash.rb
===================================================================
--- test/ruby/test_hash.rb	(revision 41270)
+++ test/ruby/test_hash.rb	(revision 41271)
@@ -226,20 +226,16 @@ class TestHash < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_hash.rb#L226
 
   def test_clone
     for taint in [ false, true ]
-      for untrust in [ false, true ]
-        for frozen in [ false, true ]
-          a = @h.clone
-          a.taint  if taint
-          a.untrust if untrust
-          a.freeze if frozen
-          b = a.clone
-
-          assert_equal(a, b)
-          assert_not_same(a, b)
-          assert_equal(a.frozen?, b.frozen?)
-          assert_equal(a.untrusted?, b.untrusted?)
-          assert_equal(a.tainted?, b.tainted?)
-        end
+      for frozen in [ false, true ]
+        a = @h.clone
+        a.taint  if taint
+        a.freeze if frozen
+        b = a.clone
+
+        assert_equal(a, b)
+        assert_not_same(a, b)
+        assert_equal(a.frozen?, b.frozen?)
+        assert_equal(a.tainted?, b.tainted?)
       end
     end
   end
@@ -319,19 +315,16 @@ class TestHash < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_hash.rb#L315
 
   def test_dup
     for taint in [ false, true ]
-      for untrust in [ false, true ]
-        for frozen in [ false, true ]
-          a = @h.dup
-          a.taint  if taint
-          a.freeze if frozen
-          b = a.dup
-
-          assert_equal(a, b)
-          assert_not_same(a, b)
-          assert_equal(false, b.frozen?)
-          assert_equal(a.tainted?, b.tainted?)
-          assert_equal(a.untrusted?, b.untrusted?)
-        end
+      for frozen in [ false, true ]
+        a = @h.dup
+        a.taint  if taint
+        a.freeze if frozen
+        b = a.dup
+
+        assert_equal(a, b)
+        assert_not_same(a, b)
+        assert_equal(false, b.frozen?)
+        assert_equal(a.tainted?, b.tainted?)
       end
     end
   end
@@ -651,10 +644,8 @@ class TestHash < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_hash.rb#L644
 
     h = @cls[ 1=>2, 3=>4, 5=>6 ]
     h.taint
-    h.untrust
     a = h.to_a
     assert_equal(true, a.tainted?)
-    assert_equal(true, a.untrusted?)
   end
 
   def test_to_hash
Index: test/-ext-/test_printf.rb
===================================================================
--- test/-ext-/test_printf.rb	(revision 41270)
+++ test/-ext-/test_printf.rb	(revision 41271)
@@ -37,13 +37,4 @@ class Test_SPrintf < Test::Unit::TestCas https://github.com/ruby/ruby/blob/trunk/test/-ext-/test_printf.rb#L37
                    inspect: Bug::Printf.v(obj).tainted?,
                  })
   end
-
-  def test_untrust
-    obj = Object.new.untrust
-    assert_equal({to_s: true, inspect: true},
-                 {
-                   to_s: Bug::Printf.s(obj).untrusted?,
-                   inspect: Bug::Printf.v(obj).untrusted?,
-                 })
-  end
 end
Index: test/rss/test_parser.rb
===================================================================
--- test/rss/test_parser.rb	(revision 41270)
+++ test/rss/test_parser.rb	(revision 41271)
@@ -18,7 +18,7 @@ EOR https://github.com/ruby/ruby/blob/trunk/test/rss/test_parser.rb#L18
       @rss_tmp = Tempfile.new(%w"rss10- .rdf")
       @rss_tmp.print(@rss10)
       @rss_tmp.close
-      @rss_file = @rss_tmp.path.untaint.trust
+      @rss_file = @rss_tmp.path.untaint
     end
 
     def teardown

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

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