diff options
author | shugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-08-13 07:25:05 +0000 |
---|---|---|
committer | shugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-08-13 07:25:05 +0000 |
commit | f433d710d0ab3b367cc4a851cdfb81c5405bb7f8 (patch) | |
tree | 5d6a14de43873b9ddaec533051b942cf89c201ce /test/ruby/test_string.rb | |
parent | 55c141c6247a4d8c052c0d57f59ddaa29e3e523a (diff) | |
download | ruby-f433d710d0ab3b367cc4a851cdfb81c5405bb7f8.tar.gz |
* 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
Diffstat (limited to 'test/ruby/test_string.rb')
-rw-r--r-- | test/ruby/test_string.rb | 61 |
1 files changed, 40 insertions, 21 deletions
diff --git a/test/ruby/test_string.rb b/test/ruby/test_string.rb index 6dd46895eb..cd32709658 100644 --- a/test/ruby/test_string.rb +++ b/test/ruby/test_string.rb @@ -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 - - assert_equal(a, b) - assert(a.__id__ != b.__id__) - assert_equal(a.frozen?, b.frozen?) - assert_equal(a.tainted?, b.tainted?) + 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 @@ -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 - - assert_equal(a, b) - assert(a.__id__ != b.__id__) - assert(!b.frozen?) - assert_equal(a.tainted?, b.tainted?) + 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 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 |