Skip to content

Commit 539d86a

Browse files
committed
more make_relative tests
1 parent 2c530fe commit 539d86a

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

lua/plenary/path2.lua

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,6 @@
6767
---
6868
--- - `find_upwards` returns `nil` if file not found rather than an empty string
6969

70-
-- TODO: could probably do with more `make_relative` tests
71-
-- - walk up close to root
72-
-- - add "walk_up" in test name
7370
-- TODO: add windows test for path2_spec only?
7471

7572
local bit = require "plenary.bit"

tests/plenary/path2_spec.lua

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,12 +341,19 @@ describe("Path2", function()
341341
end)
342342
end)
343343

344-
it_cross_plat("can walk upwards out of current subpath", function()
344+
it_cross_plat("can walk_up out of current subpath", function()
345345
local p = Path:new { "foo", "bar", "baz" }
346346
local cwd = Path:new { "foo", "foo_inner" }
347347
local expect = Path:new { "..", "bar", "baz" }
348348
assert.are.same(expect.filename, p:make_relative(cwd, true))
349349
end)
350+
351+
it_cross_plat("can walk_up to root", function()
352+
local p = Path:new { root(), "foo", "bar", "baz" }
353+
local cwd = Path:new { root(), "def" }
354+
local expect = Path:new { "..", "foo", "bar", "baz" }
355+
assert.are.same(expect.filename, p:make_relative(cwd, true))
356+
end)
350357
end)
351358

352359
describe(":shorten", function()

0 commit comments

Comments
 (0)