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