1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-01-24 19:20:06 +08:00
SpaceVim/test/api/file.vader

29 lines
1.8 KiB
Plaintext
Raw Normal View History

2020-09-12 19:57:10 +08:00
Execute ( SpaceVim api: file.fticon ):
let &encoding = 'utf-8'
let g:spacevim_filetype_icons = {}
let file = SpaceVim#api#import('file')
AssertEqual file.fticon('foo.md'), ''
2020-09-12 19:57:10 +08:00
Execute ( SpaceVim api: file.unify_path ):
let path = fnamemodify('.SpaceVim.d/init.vim', ':p')
2020-09-12 19:57:10 +08:00
AssertEqual file.unify_path(path, ':p'), fnamemodify('.SpaceVim.d/init.vim', ':p:gs?[\\/]?/?')
2021-02-17 23:15:18 +08:00
let path = '~/.SpaceVim.d'
AssertEqual file.unify_path(path, ':p')[-1:], '/'
2020-09-12 19:57:10 +08:00
Execute ( SpaceVim api: file.findfile ):
let path = fnamemodify('.SpaceVim.d/init.vim', ':p')
" @bug vim-7.4.629, echo findfile('README.md', 'vimrc') return empty string
AssertEqual file.unify_path(file.findfile('README.md', fnamemodify(path, ':p')), ':.'), '.SpaceVim.d/README.md'
AssertEqual map(file.findfile('README.md', fnamemodify(path, ':p'), 0), 'file.unify_path(v:val, ":.")'), ['.SpaceVim.d/README.md', 'README.md']
AssertEqual file.unify_path(file.findfile('README.md', fnamemodify(path, ':p'), 1), ':.'), '.SpaceVim.d/README.md'
AssertEqual file.unify_path(file.findfile('README.md', fnamemodify(path, ':p'), -1), ':.'), 'README.md'
AssertEqual file.unify_path(file.findfile('README.md', fnamemodify(path, ':p'), -2), ':.'), '.SpaceVim.d/README.md'
let path = fnamemodify('bundle/dein.vim/autoload/dein.vim', ':p')
AssertEqual file.unify_path(file.finddir('doc/', fnamemodify(path, ':p')), ':.'), 'bundle/dein.vim/doc/'
AssertEqual map(file.finddir('doc/', fnamemodify(path, ':p'), 0), 'file.unify_path(v:val, ":.")'), ['bundle/dein.vim/doc/', 'doc/']
AssertEqual file.unify_path(file.finddir('doc/', fnamemodify(path, ':p'), -1), ':.'), 'doc/'
2020-09-12 19:57:10 +08:00
let path2 = fnamemodify('ginit.vim', ':p')
" find the file in same directory
AssertEqual file.unify_path(file.findfile('vimrc', fnamemodify(path, ':p'), -1), ':.'), 'vimrc'
unlet file path