diff options
author | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2005-11-18 07:51:19 +0000 |
---|---|---|
committer | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2005-11-18 07:51:19 +0000 |
commit | 7b692e55cde4634209942cca197acf392ca51558 (patch) | |
tree | bf31b7e71dcbb1a4690b7b240c7f6a6b925765e9 /test/ruby/test_path.rb | |
parent | 4378916e95c0dc7ff8452764dfdc690166fbd27a (diff) | |
download | ruby-7b692e55cde4634209942cca197acf392ca51558.tar.gz |
* file.c (file_s_dirname): added checks for some patterns with drive
letter. fixed: [ruby-dev:27738]
* test/ruby/test_path.rb (test_dirname): added tests for above
patterns.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9559 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_path.rb')
-rw-r--r-- | test/ruby/test_path.rb | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/test/ruby/test_path.rb b/test/ruby/test_path.rb index 95a5d5b1d1..f7a45a3712 100644 --- a/test/ruby/test_path.rb +++ b/test/ruby/test_path.rb @@ -43,4 +43,75 @@ class TestPath < Test::Unit::TestCase assert_equal("//", File.expand_path(".", "//")) assert_equal("//sub", File.expand_path("sub", "//")) end + + def test_dirname_special # [ruby-dev:27738] + if /(bcc|ms)win\d|mingw|cygwin|djgpp|human|emx/ =~ RUBY_PLATFORM + # DOSISH_DRIVE_LETTER + assert_equal('C:.', File.dirname('C:')) + assert_equal('C:.', File.dirname('C:a')) + assert_equal('C:.', File.dirname('C:a/')) + assert_equal('C:a', File.dirname('C:a/b')) + assert_equal('C:/', File.dirname('C:/')) + assert_equal('C:/', File.dirname('C://')) + assert_equal('C:/', File.dirname('C:///')) + assert_equal('C:/', File.dirname('C:/a')) + assert_equal('C:/', File.dirname('C://a')) + assert_equal('C:/', File.dirname('C:///a')) + assert_equal('C:/', File.dirname('C:/a/')) + assert_equal('C:/', File.dirname('C://a/')) + assert_equal('C:/', File.dirname('C:///a/')) + assert_equal('C:/a', File.dirname('C:/a/b')) + assert_equal('C:/a', File.dirname('C://a/b')) + assert_equal('C:/a', File.dirname('C:///a/b')) + else + # others + assert_equal('.', File.dirname('C:')) + assert_equal('.', File.dirname('C:a')) + assert_equal('.', File.dirname('C:a/')) + assert_equal('C:a', File.dirname('C:a/b')) + assert_equal('.', File.dirname('C:/')) + assert_equal('.', File.dirname('C://')) + assert_equal('.', File.dirname('C:///')) + assert_equal('C:', File.dirname('C:/a')) + assert_equal('C:', File.dirname('C://a')) + assert_equal('C:', File.dirname('C:///a')) + assert_equal('C:', File.dirname('C:/a/')) + assert_equal('C:', File.dirname('C://a/')) + assert_equal('C:', File.dirname('C:///a/')) + assert_equal('C:/a', File.dirname('C:/a/b')) + # these show current implementation, but they are not spec. + #assert_equal('C://a', File.dirname('C://a/b')) + #assert_equal('C:///a', File.dirname('C:///a/b')) + end + + assert_equal('.', File.dirname('')) + assert_equal('.', File.dirname('a')) + assert_equal('.', File.dirname('a/')) + assert_equal('a', File.dirname('a/b')) + assert_equal('/', File.dirname('/')) + assert_equal('/', File.dirname('/a')) + assert_equal('/', File.dirname('/a/')) + assert_equal('/a', File.dirname('/a/b')) + if /(bcc|ms|cyg)win|mingw|djgpp|human|emx/ =~ RUBY_PLATFORM + # DOSISH_UNC + assert_equal('//', File.dirname('//')) + assert_equal('//', File.dirname('//a')) + assert_equal('//', File.dirname('//a/')) + assert_equal('//a', File.dirname('//a/b')) + assert_equal('//', File.dirname('///')) + assert_equal('//', File.dirname('///a')) + assert_equal('//', File.dirname('///a/')) + assert_equal('//a', File.dirname('///a/b')) + else + # others + assert_equal('/', File.dirname('//')) + assert_equal('/', File.dirname('//a')) + assert_equal('/', File.dirname('//a/')) + assert_equal('/a', File.dirname('//a/b')) + assert_equal('/', File.dirname('///')) + assert_equal('/', File.dirname('///a')) + assert_equal('/', File.dirname('///a/')) + assert_equal('/a', File.dirname('///a/b')) + end + end end |