summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorshugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-06-13 05:41:44 +0000
committershugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-06-13 05:41:44 +0000
commit1474dd064b28e4a813a79342c5523cede60f83c7 (patch)
tree18eed509f9c6e01f993948b733c165f6006a2450 /test
parent90026ab53f89304438d907c0c7cc23afccc6edb7 (diff)
* 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
Diffstat (limited to 'test')
-rw-r--r--test/-ext-/test_printf.rb9
-rw-r--r--test/rss/test_parser.rb2
-rw-r--r--test/ruby/test_array.rb35
-rw-r--r--test/ruby/test_hash.rb49
-rw-r--r--test/ruby/test_m17n.rb2
-rw-r--r--test/ruby/test_marshal.rb37
-rw-r--r--test/ruby/test_object.rb38
-rw-r--r--test/ruby/test_string.rb60
8 files changed, 78 insertions, 154 deletions
diff --git a/test/-ext-/test_printf.rb b/test/-ext-/test_printf.rb
index 4b471ab5d9b..29f384b1d70 100644
--- a/test/-ext-/test_printf.rb
+++ b/test/-ext-/test_printf.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
diff --git a/test/rss/test_parser.rb b/test/rss/test_parser.rb
index 833146b980e..8d8d1e19707 100644
--- a/test/rss/test_parser.rb
+++ b/test/rss/test_parser.rb
@@ -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
diff --git a/test/ruby/test_array.rb b/test/ruby/test_array.rb
index 63db9803576..93ef59a3f58 100644
--- a/test/ruby/test_array.rb
+++ b/test/ruby/test_array.rb
@@ -476,20 +476,16 @@ 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
+ 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
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
diff --git a/test/ruby/test_hash.rb b/test/ruby/test_hash.rb
index 31687606706..75a3a396af9 100644
--- a/test/ruby/test_hash.rb
+++ b/test/ruby/test_hash.rb
@@ -226,20 +226,16 @@ 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
+ 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
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
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
diff --git a/test/ruby/test_m17n.rb b/test/ruby/test_m17n.rb
index edc8e4c28f7..b58cd576cf3 100644
--- a/test/ruby/test_m17n.rb
+++ b/test/ruby/test_m17n.rb
@@ -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
diff --git a/test/ruby/test_marshal.rb b/test/ruby/test_marshal.rb
index b0f066a5a30..f502026cdf4 100644
--- a/test/ruby/test_marshal.rb
+++ b/test/ruby/test_marshal.rb
@@ -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
diff --git a/test/ruby/test_object.rb b/test/ruby/test_object.rb
index 7b660ce87c7..b46403ad6f0 100644
--- a/test/ruby/test_object.rb
+++ b/test/ruby/test_object.rb
@@ -652,29 +652,33 @@ class TestObject < Test::Unit::TestCase
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)
diff --git a/test/ruby/test_string.rb b/test/ruby/test_string.rb
index 651ab7c90c6..9db3d2cb0fe 100644
--- a/test/ruby/test_string.rb
+++ b/test/ruby/test_string.rb
@@ -451,20 +451,16 @@ 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
+ 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
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
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