1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Add tests for File.absolute_path?

[Feature #15868]
This commit is contained in:
David Rodríguez 2019-05-23 11:40:27 +02:00 committed by Nobuyoshi Nakada
parent 2a166cfea2
commit 1c4af1a77f
No known key found for this signature in database
GPG key ID: 4BC7D6DF58D8DF60

View file

@ -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