blob: 78d1ad3e416e3eb7430af4e448a28c70a227b138 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
local path = require 'pl.path'
local test = require 'pl.test'
relpath = path.relpath
path = '/a/b/c'
function slash (p)
return (p:gsub('\\','/'))
end
function try (p,r)
test.asserteq(slash(relpath(p,path)),r)
end
try('/a/b/c/one.lua','one.lua')
try('/a/b/c/bonzo/two.lua','bonzo/two.lua')
try('/a/b/three.lua','../three.lua')
try('/a/four.lua','../../four.lua')
try('one.lua','one.lua')
try('../two.lua','../two.lua')
|