From 3ef48ef9c8fb3c19d64b4bcf41ed10edb0bfeecc Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Mon, 18 May 2026 11:08:25 +0900 Subject: [PATCH] pathname: Improve `absolute?` tests along with `relative?` tests Check that these two methods opposite always. --- test/pathname/test_pathname.rb | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/test/pathname/test_pathname.rb b/test/pathname/test_pathname.rb index 8646b20de57..6354e6a9b5d 100644 --- a/test/pathname/test_pathname.rb +++ b/test/pathname/test_pathname.rb @@ -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/')