Skip to content

Commit 3ef48ef

Browse files
committed
pathname: Improve absolute? tests along with relative? tests
Check that these two methods opposite always.
1 parent 67e14b1 commit 3ef48ef

1 file changed

Lines changed: 6 additions & 7 deletions

File tree

test/pathname/test_pathname.rb

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -260,13 +260,12 @@ def test_join
260260
assert_equal(Pathname("/foo/var"), r)
261261
end
262262

263-
def test_absolute
264-
assert_equal(true, Pathname("/").absolute?)
265-
assert_equal(false, Pathname("a").absolute?)
266-
end
267-
268263
def relative?(path)
269-
Pathname.new(path).relative?
264+
path = Pathname.new(path)
265+
relative = path.relative?
266+
absolute = path.absolute?
267+
assert_equal(!relative, absolute)
268+
relative
270269
end
271270

272271
defassert(:relative?, true, '')
@@ -281,7 +280,7 @@ def relative?(path)
281280
defassert(:relative?, !DOSISH_DRIVE_LETTER, 'A:/')
282281
defassert(:relative?, !DOSISH_DRIVE_LETTER, 'A:/a')
283282

284-
if File.dirname('//') == '//'
283+
if DOSISH_UNC
285284
defassert(:relative?, false, '//')
286285
defassert(:relative?, false, '//a')
287286
defassert(:relative?, false, '//a/')

0 commit comments

Comments
 (0)