1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* object.c (rb_obj_untrusted): new method Object#untrusted?.

(rb_obj_untrust): new method Object#untrust.
  (rb_obj_trust): new method Object#trust.
* array.c, debug.c, time.c, include/ruby/ruby.h, re.c, variable.c,
  string.c, io.c, dir.c, vm_method.c, struct.c, class.c, hash.c,
  ruby.c, marshal.c: fixes for Object#untrusted?.
* test/ruby/test_module.rb, test/ruby/test_array.rb,
  test/ruby/test_object.rb, test/ruby/test_string.rb,
  test/ruby/test_marshal.rb, test/ruby/test_hash.rb: added tests for
  Object#untrusted?.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18568 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
shugo 2008-08-13 07:25:05 +00:00
parent 55c141c624
commit f433d710d0
23 changed files with 364 additions and 88 deletions

View file

@ -427,16 +427,20 @@ class TestString < Test::Unit::TestCase
def test_clone
for taint in [ false, true ]
for frozen in [ false, true ]
a = S("Cool")
a.taint if taint
a.freeze if frozen
b = a.clone
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.tainted?, b.tainted?)
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
@ -532,16 +536,20 @@ class TestString < Test::Unit::TestCase
def test_dup
for taint in [ false, true ]
for frozen in [ false, true ]
a = S("hello")
a.taint if taint
a.freeze if frozen
b = a.dup
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, b)
assert(a.__id__ != b.__id__)
assert(!b.frozen?)
assert_equal(a.tainted?, b.tainted?)
assert_equal(a.untrusted?, b.untrusted?)
end
end
end
end
@ -623,7 +631,9 @@ 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")
@ -651,8 +661,10 @@ 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')))
@ -823,9 +835,11 @@ 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
@ -1170,7 +1184,10 @@ class TestString < Test::Unit::TestCase
a = S("hello")
a.taint
assert(a.sub(/./, S('X')).tainted?)
a.untrust
x = a.sub(/./, S('X'))
assert(x.tainted?)
assert(x.untrusted?)
o = Object.new
def o.to_str; "bar"; end
@ -1211,8 +1228,10 @@ 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