aboutsummaryrefslogtreecommitdiff
path: root/test/functional/eval/fnamemodify_spec.lua
blob: f3705d6c9906c83a6f810034e5d6bd5355da60dd (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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
local command = helpers.command

describe('fnamemodify()', function()
  before_each(clear)

  it('works', function()
    if iswin() then
      eq([[C:\]], fnamemodify([[\]], ':p:h'))
      eq([[C:\]], fnamemodify([[\]], ':p'))
      eq([[C:\]], fnamemodify([[/]], ':p:h'))
      eq([[C:\]], fnamemodify([[/]], ':p'))
      command('set shellslash')
      eq([[C:/]], fnamemodify([[\]], ':p:h'))
      eq([[C:/]], fnamemodify([[\]], ':p'))
      eq([[C:/]], fnamemodify([[/]], ':p:h'))
      eq([[C:/]], fnamemodify([[/]], ':p'))
    else
      eq('/', fnamemodify([[/]], ':p:h'))
      eq('/', fnamemodify([[/]], ':p'))
    end
  end)
end)