mirror of
https://github.com/ruby/ruby.git
synced 2026-10-28 16:36:20 +08:00
pathname: Improve absolute? tests along with relative? tests
Check that these two methods opposite always.
This commit is contained in:
1 file changed
+6
-7
@@ -260,13 +260,12 @@ class TestPathname < Test::Unit::TestCase
|
||||
assert_equal(Pathname("/foo/var"), r)
|
||||
end
|
||||
|
||||
def test_absolute
|
||||
assert_equal(true, Pathname("/").absolute?)
|
||||
assert_equal(false, Pathname("a").absolute?)
|
||||
end
|
||||
|
||||
def relative?(path)
|
||||
Pathname.new(path).relative?
|
||||
path = Pathname.new(path)
|
||||
relative = path.relative?
|
||||
absolute = path.absolute?
|
||||
assert_equal(!relative, absolute)
|
||||
relative
|
||||
end
|
||||
|
||||
defassert(:relative?, true, '')
|
||||
@@ -281,7 +280,7 @@ class TestPathname < Test::Unit::TestCase
|
||||
defassert(:relative?, !DOSISH_DRIVE_LETTER, 'A:/')
|
||||
defassert(:relative?, !DOSISH_DRIVE_LETTER, 'A:/a')
|
||||
|
||||
if File.dirname('//') == '//'
|
||||
if DOSISH_UNC
|
||||
defassert(:relative?, false, '//')
|
||||
defassert(:relative?, false, '//a')
|
||||
defassert(:relative?, false, '//a/')
|
||||
|
||||
Reference in new issue
Block a user