summaryrefslogtreecommitdiff
path: root/test/test_tmpdir.rb
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-10-06 12:40:41 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-10-06 12:40:41 +0000
commit83da44790b0a4099d7ea54bdeee84e605f940cd1 (patch)
tree433c68372259214769f2a3a3f48de4f6908df100 /test/test_tmpdir.rb
parent603210060c08b2693bc9c597cf4200bf51efd362 (diff)
* 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
Diffstat (limited to 'test/test_tmpdir.rb')
-rw-r--r--test/test_tmpdir.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/test/test_tmpdir.rb b/test/test_tmpdir.rb
index 62b4abf..842b2de 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|