aboutsummaryrefslogtreecommitdiff
path: root/test/functional/eval/fnamemodify_spec.lua
blob: 21e670c41c431e9e3dc3fd02f69f313d61cbfc78 (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
28
29
30
31
32
33
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()
    local drive_f = io.popen('cd', 'r')
    local drive = string.gsub(drive_f:read('*a'), '[\n\r]', '')
    drive_f:close()

    if iswin() then
      local root = drive..[[\]]
      eq(root, fnamemodify([[\]], ':p:h'))
      eq(root, fnamemodify([[\]], ':p'))
      eq(root, fnamemodify([[/]], ':p:h'))
      eq(root, fnamemodify([[/]], ':p'))
      command('set shellslash')
      root = drive..[[/]]
      eq(root, fnamemodify([[\]], ':p:h'))
      eq(root, fnamemodify([[\]], ':p'))
      eq(root, fnamemodify([[/]], ':p:h'))
      eq(root, fnamemodify([[/]], ':p'))
    else
      eq('/', fnamemodify([[/]], ':p:h'))
      eq('/', fnamemodify([[/]], ':p'))
    end
  end)
end)