From 83da44790b0a4099d7ea54bdeee84e605f940cd1 Mon Sep 17 00:00:00 2001 From: akr Date: Tue, 6 Oct 2015 12:40:41 +0000 Subject: * lib/tmpdir.rb (Dir.tmpdir): return duplicated string to be modify safely even when $SAFE > 0. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52062 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/test_tmpdir.rb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'test') diff --git a/test/test_tmpdir.rb b/test/test_tmpdir.rb index 62b4abfa1a..842b2ded90 100644 --- a/test/test_tmpdir.rb +++ b/test/test_tmpdir.rb @@ -2,6 +2,25 @@ require 'test/unit' require 'tmpdir' class TestTmpdir < Test::Unit::TestCase + def test_tmpdir_modifiable + tmpdir = Dir.tmpdir + assert_equal(false, tmpdir.frozen?) + tmpdir_org = tmpdir.dup + tmpdir << "foo" + assert_equal(tmpdir_org, Dir.tmpdir) + end + + def test_tmpdir_modifiable_safe + Thread.new { + $SAFE = 1 + tmpdir = Dir.tmpdir + assert_equal(false, tmpdir.frozen?) + tmpdir_org = tmpdir.dup + tmpdir << "foo" + assert_equal(tmpdir_org, Dir.tmpdir) + }.join + end + def test_world_writable skip "no meaning on this platform" if /mswin|mingw/ =~ RUBY_PLATFORM Dir.mktmpdir do |tmpdir| -- cgit v1.2.3