aboutsummaryrefslogtreecommitdiffstats
path: root/test/ruby/test_file.rb
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-03-07 04:55:34 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-03-07 04:55:34 +0000
commit785b31bed4fbe10dd8fe92a7ef52782d2d1d1123 (patch)
treee72e793ea4c5bc6bbc4e8dfb4d56c32ac45a5b4d /test/ruby/test_file.rb
parent8a144fdedc2df7ee87e21ad805fcbcbd18209533 (diff)
downloadruby-785b31bed4fbe10dd8fe92a7ef52782d2d1d1123.tar.gz
* file.c: add optional basedir argument for realpath/realdirpath.
(realpath_internal): handle basedir. (rb_file_s_realpath): extract basedir from argument list. (rb_file_s_realdirpath): extract basedir from argument list. * lib/pathname.rb (realpath): pass basedir. (realdirpath): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26841 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_file.rb')
-rw-r--r--test/ruby/test_file.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/test/ruby/test_file.rb b/test/ruby/test_file.rb
index b8ba9a4b19..90f2ec1f53 100644
--- a/test/ruby/test_file.rb
+++ b/test/ruby/test_file.rb
@@ -157,4 +157,24 @@ class TestFile < Test::Unit::TestCase
assert_raise(TypeError) { File::Stat.allocate.readable? }
assert_nothing_raised { File::Stat.allocate.inspect }
end
+
+ def test_realpath
+ Dir.mktmpdir('rubytest-realpath') {|tmpdir|
+ realdir = File.realpath(tmpdir)
+ tst = realdir.sub(/#{Regexp.escape(File::SEPARATOR)}/, '\0\0\0')
+ assert_equal(realdir, File.realpath(tst))
+ assert_equal(realdir, File.realpath(".", tst))
+ }
+ end
+
+ def test_realdirpath
+ Dir.mktmpdir('rubytest-realdirpath') {|tmpdir|
+ realdir = File.realpath(tmpdir)
+ tst = realdir.sub(/#{Regexp.escape(File::SEPARATOR)}/, '\0\0\0')
+ assert_equal(realdir, File.realdirpath(tst))
+ assert_equal(realdir, File.realdirpath(".", tst))
+ assert_equal(File.join(realdir, "foo"), File.realdirpath("foo", tst))
+ }
+ end
+
end