From 10b598499b61d2c95a417f145e4cc70d96aeee71 Mon Sep 17 00:00:00 2001 From: akr Date: Mon, 26 Apr 2004 16:27:57 +0000 Subject: [PATCH] add tests. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@6220 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/pathname.rb | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/lib/pathname.rb b/lib/pathname.rb index 118666b194..423b8a0689 100644 --- a/lib/pathname.rb +++ b/lib/pathname.rb @@ -1141,6 +1141,25 @@ if $0 == __FILE__ assert_equal(true, Pathname.new("a".taint) .to_s.tainted?) assert_equal(true, Pathname.new("a".taint).taint .tainted?) assert_equal(true, Pathname.new("a".taint).taint.to_s.tainted?) + + str = "a" + path = Pathname.new(str) + str.taint + assert_equal(false, path .tainted?) + assert_equal(false, path.to_s.tainted?) + end + + def test_untaint + obj = Pathname.new("a"); assert_same(obj, obj.untaint) + + assert_equal(false, Pathname.new("a").taint.untaint .tainted?) + assert_equal(false, Pathname.new("a").taint.untaint.to_s.tainted?) + + str = "a".taint + path = Pathname.new(str) + str.untaint + assert_equal(true, path .tainted?) + assert_equal(true, path.to_s.tainted?) end def test_freeze @@ -1155,5 +1174,13 @@ if $0 == __FILE__ assert_equal(false, Pathname.new("a" ).freeze.to_s.frozen?) assert_equal(false, Pathname.new("a".freeze).freeze.to_s.frozen?) end + + def test_to_s + str = "a" + obj = Pathname.new(str) + assert_equal(str, obj.to_s) + assert_not_same(str, obj.to_s) + assert_not_same(obj.to_s, obj.to_s) + end end end