* 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.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41271 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
shugo 2013-06-13 05:41:44 +00:00
Родитель 90026ab53f
Коммит 1474dd064b
9 изменённых файлов: 82 добавлений и 149 удалений

Просмотреть файл

@ -1,3 +1,12 @@
Thu Jun 13 14:39:08 2013 Shugo Maeda <shugo@ruby-lang.org>
* 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@ruby-lang.org>
* bootstraptest/test_autoload.rb, bootstraptest/test_method.rb:

Просмотреть файл

@ -37,13 +37,4 @@ class Test_SPrintf < Test::Unit::TestCase
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

Просмотреть файл

@ -18,7 +18,7 @@ EOR
@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

Просмотреть файл

@ -476,23 +476,19 @@ class TestArray < Test::Unit::TestCase
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
end
end
end
def test_collect
a = @cls[ 1, 'cat', 1..1 ]
@ -756,10 +752,8 @@ class TestArray < Test::Unit::TestCase
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
$, = ""
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
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

Просмотреть файл

@ -226,23 +226,19 @@ class TestHash < Test::Unit::TestCase
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
end
end
end
def test_default
assert_nil(@h.default)
@ -319,7 +315,6 @@ class TestHash < Test::Unit::TestCase
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
@ -330,8 +325,6 @@ class TestHash < Test::Unit::TestCase
assert_not_same(a, b)
assert_equal(false, b.frozen?)
assert_equal(a.tainted?, b.tainted?)
assert_equal(a.untrusted?, b.untrusted?)
end
end
end
end
@ -651,10 +644,8 @@ class TestHash < Test::Unit::TestCase
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

Просмотреть файл

@ -1486,8 +1486,6 @@ class TestM17N < Test::Unit::TestCase
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

Просмотреть файл

@ -187,80 +187,55 @@ class TestMarshal < Test::Unit::TestCase
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
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

Просмотреть файл

@ -652,6 +652,9 @@ class TestObject < Test::Unit::TestCase
end
def test_untrusted
verbose = $VERBOSE
$VERBOSE = false
begin
obj = Object.new
assert_equal(false, obj.untrusted?)
assert_equal(false, obj.tainted?)
@ -667,14 +670,15 @@ class TestObject < Test::Unit::TestCase
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)

Просмотреть файл

@ -451,22 +451,18 @@ class TestString < Test::Unit::TestCase
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
end
end
null = File.exist?("/dev/null") ? "/dev/null" : "NUL" # maybe DOSISH
assert_equal("", File.read(null).clone, '[ruby-dev:32819] reported by Kazuhiro NISHIYAMA')
@ -588,11 +584,9 @@ class TestString < Test::Unit::TestCase
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
@ -600,8 +594,6 @@ class TestString < Test::Unit::TestCase
assert(a.__id__ != b.__id__)
assert(!b.frozen?)
assert_equal(a.tainted?, b.tainted?)
assert_equal(a.untrusted?, b.untrusted?)
end
end
end
end
@ -817,9 +809,7 @@ class TestString < Test::Unit::TestCase
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
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
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
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
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
r = S('X')
r.taint
r.untrust
a.sub!(/./, r)
assert(a.tainted?)
assert(a.untrusted?)
end
def test_succ