diff options
author | David RodrÃguez <deivid.rodriguez@riseup.net> | 2019-05-23 11:40:27 +0200 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2019-09-05 20:04:50 +0900 |
commit | 1c4af1a77fb2dad27d523fe5d97ea4a27b145e3c (patch) | |
tree | c3d5a9509cfcf2631e0e683ab3de7184e1aa12bb /test/ruby/test_file.rb | |
parent | 2a166cfea22b90e39e3fe9bafab6b806ed4813f6 (diff) | |
download | ruby-1c4af1a77fb2dad27d523fe5d97ea4a27b145e3c.tar.gz |
Add tests for `File.absolute_path?`
[Feature #15868]
Diffstat (limited to 'test/ruby/test_file.rb')
-rw-r--r-- | test/ruby/test_file.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/test/ruby/test_file.rb b/test/ruby/test_file.rb index ecca8d3e35..f0a8d67a5d 100644 --- a/test/ruby/test_file.rb +++ b/test/ruby/test_file.rb @@ -519,4 +519,22 @@ class TestFile < Test::Unit::TestCase end end if File::Constants.const_defined?(:TMPFILE) + def test_absolute_path? + assert_file.absolute_path?(File.absolute_path(__FILE__)) + assert_file.absolute_path?("//foo/bar\\baz") + assert_file.not_absolute_path?(File.basename(__FILE__)) + assert_file.not_absolute_path?("C:foo\\bar") + assert_file.not_absolute_path?("~") + assert_file.not_absolute_path?("~user") + + if /mswin|mingw/ =~ RUBY_PLATFORM + assert_file.absolute_path?("C:\\foo\\bar") + assert_file.absolute_path?("C:/foo/bar") + assert_file.not_absolute_path?("/foo/bar\\baz") + else + assert_file.not_absolute_path?("C:\\foo\\bar") + assert_file.not_absolute_path?("C:/foo/bar") + assert_file.absolute_path?("/foo/bar\\baz") + end + end end |