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:
parent
55c141c624
commit
f433d710d0
23 changed files with 364 additions and 88 deletions
|
@ -206,16 +206,20 @@ class TestHash < Test::Unit::TestCase
|
|||
|
||||
def test_clone
|
||||
for taint in [ false, true ]
|
||||
for frozen in [ false, true ]
|
||||
a = @h.clone
|
||||
a.taint if taint
|
||||
a.freeze if frozen
|
||||
b = a.clone
|
||||
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(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
|
||||
end
|
||||
|
@ -288,16 +292,19 @@ class TestHash < Test::Unit::TestCase
|
|||
|
||||
def test_dup
|
||||
for taint in [ false, true ]
|
||||
for frozen in [ false, true ]
|
||||
a = @h.dup
|
||||
a.taint if taint
|
||||
a.freeze if frozen
|
||||
b = a.dup
|
||||
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(a.__id__ != b.__id__)
|
||||
assert_equal(false, b.frozen?)
|
||||
assert_equal(a.tainted?, b.tainted?)
|
||||
assert_equal(a, b)
|
||||
assert(a.__id__ != b.__id__)
|
||||
assert_equal(false, b.frozen?)
|
||||
assert_equal(a.tainted?, b.tainted?)
|
||||
assert_equal(a.untrusted?, b.untrusted?)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -599,6 +606,13 @@ class TestHash < Test::Unit::TestCase
|
|||
assert_equal([3,4], a.delete([3,4]))
|
||||
assert_equal([5,6], a.delete([5,6]))
|
||||
assert_equal(0, a.length)
|
||||
|
||||
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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue