pathname: Improve absolute? tests along with relative? tests

Check that these two methods opposite always.
This commit is contained in:
Nobuyoshi Nakada committed 2026-05-19 20:31:50 +09:00
1 parent 67e14b1a0f
commit 3ef48ef9c8
1 file changed
+6 -7
+6 -7
View File
@@ -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/')