summaryrefslogtreecommitdiff
path: root/test/ruby/test_file.rb
diff options
context:
space:
mode:
authornahi <nahi@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-09-26 20:00:03 +0000
committernahi <nahi@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-09-26 20:00:03 +0000
commit11150ba747dc6e86130856a4a9968ba94990fa79 (patch)
tree0528aa41142b0121d4a730a02cb67191f1298f5a /test/ruby/test_file.rb
parent2e0b087b02de40dd7398533522d2cfcf209771df (diff)
* test/ruby/test_file.rb: new file. only asserts unlink-before-close behaviour
now. * test/soap/marshal/test_digraph.rb: should close before unlink. unlink-before-close pattern is not needed here. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4609 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_file.rb')
-rw-r--r--test/ruby/test_file.rb32
1 files changed, 32 insertions, 0 deletions
diff --git a/test/ruby/test_file.rb b/test/ruby/test_file.rb
new file mode 100644
index 0000000000..d0ba276d33
--- /dev/null
+++ b/test/ruby/test_file.rb
@@ -0,0 +1,32 @@
+require 'test/unit'
+
+$KCODE = 'none'
+
+class TestFile < Test::Unit::TestCase
+
+ # I don't know Ruby's spec about "unlink-before-close" exactly.
+ # This test asserts current behaviour.
+ def test_unlink_before_close
+ filename = File.basename(__FILE__) + ".#{$$}"
+ w = File.open(filename, "w")
+ w << "foo"
+ w.close
+ r = File.open(filename, "r")
+ begin
+ if /(mswin|bccwin|mingw)/ =~ RUBY_PLATFORM
+ begin
+ File.unlink(filename)
+ assert(false)
+ rescue Errno::EACCES
+ assert(true)
+ end
+ else
+ File.unlink(filename)
+ assert(true)
+ end
+ ensure
+ r.close
+ File.unlink(filename) if File.exist?(filename)
+ end
+ end
+end