neovim/test/functional/eval/fnamemodify_spec.lua

33 lines
1019 B
Lua
Raw Normal View History

2018-01-08 17:06:59 -07:00
local helpers = require('test.functional.helpers')(after_each)
local clear = helpers.clear
local eq = helpers.eq
local iswin = helpers.iswin
local fnamemodify = helpers.funcs.fnamemodify
2018-01-11 09:05:15 -07:00
local command = helpers.command
2018-01-08 17:06:59 -07:00
describe('fnamemodify()', function()
before_each(clear)
it('works', function()
if iswin() then
local drive_f = io.popen('for %P in (%CD%) do @echo %~dP', 'r')
local drive = string.gsub(drive_f:read('*a'), '[\n\r]', '')
drive_f:close()
local root = drive..[[\]]
eq(root, fnamemodify([[\]], ':p:h'))
eq(root, fnamemodify([[\]], ':p'))
eq(root, fnamemodify([[/]], ':p:h'))
eq(root, fnamemodify([[/]], ':p'))
2018-01-11 09:05:15 -07:00
command('set shellslash')
root = drive..[[/]]
eq(root, fnamemodify([[\]], ':p:h'))
eq(root, fnamemodify([[\]], ':p'))
eq(root, fnamemodify([[/]], ':p:h'))
eq(root, fnamemodify([[/]], ':p'))
2018-01-08 17:06:59 -07:00
else
eq('/', fnamemodify([[/]], ':p:h'))
eq('/', fnamemodify([[/]], ':p'))
end
end)
end)