vim-patch:8.1.0025: no test for the undofile() function

Problem:    No test for the undofile() function.
Solution:   Add test. (Dominique Pelle, closes vim/vim#2958)
e5fa11186f
This commit is contained in:
Jan Edmund Lazo 2018-08-09 16:03:35 -04:00
parent 6853690c78
commit 1c1722105c

View File

@ -357,3 +357,35 @@ func Test_undo_append()
norm o norm o
quit quit
endfunc endfunc
funct Test_undofile()
" Test undofile() without setting 'undodir'.
if has('persistent_undo')
call assert_equal(fnamemodify('.Xundofoo.un~', ':p'), undofile('Xundofoo'))
else
call assert_equal('', undofile('Xundofoo'))
endif
call assert_equal('', undofile(''))
" Test undofile() with 'undodir' set to to an existing directory.
call mkdir('Xundodir')
set undodir=Xundodir
let cwd = getcwd()
if has('win32')
" Replace windows drive such as C:... into C%...
let cwd = substitute(cwd, '^\([A-Z]\):', '\1%', 'g')
endif
let cwd = substitute(cwd . '/Xundofoo', '/', '%', 'g')
if has('persistent_undo')
call assert_equal('Xundodir/' . cwd, undofile('Xundofoo'))
else
call assert_equal('', undofile('Xundofoo'))
endif
call assert_equal('', undofile(''))
call delete('Xundodir', 'd')
" Test undofile() with 'undodir' set to a non-existing directory.
call assert_equal('', undofile('Xundofoo'))
set undodir&
endfunc