diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-03-07 04:55:34 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-03-07 04:55:34 +0000 |
commit | 785b31bed4fbe10dd8fe92a7ef52782d2d1d1123 (patch) | |
tree | e72e793ea4c5bc6bbc4e8dfb4d56c32ac45a5b4d /test/ruby | |
parent | 8a144fdedc2df7ee87e21ad805fcbcbd18209533 (diff) | |
download | ruby-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')
-rw-r--r-- | test/ruby/test_file.rb | 20 |
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 |