mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
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:
parent
6853690c78
commit
1c1722105c
@ -195,19 +195,19 @@ func Test_undolist()
|
|||||||
new
|
new
|
||||||
set ul=100
|
set ul=100
|
||||||
|
|
||||||
let a=execute('undolist')
|
let a = execute('undolist')
|
||||||
call assert_equal("\nNothing to undo", a)
|
call assert_equal("\nNothing to undo", a)
|
||||||
|
|
||||||
" 1 leaf (2 changes).
|
" 1 leaf (2 changes).
|
||||||
call feedkeys('achange1', 'xt')
|
call feedkeys('achange1', 'xt')
|
||||||
call feedkeys('achange2', 'xt')
|
call feedkeys('achange2', 'xt')
|
||||||
let a=execute('undolist')
|
let a = execute('undolist')
|
||||||
call assert_match("^\nnumber changes when *saved\n *2 *2 .*$", a)
|
call assert_match("^\nnumber changes when *saved\n *2 *2 .*$", a)
|
||||||
|
|
||||||
" 2 leaves.
|
" 2 leaves.
|
||||||
call feedkeys('u', 'xt')
|
call feedkeys('u', 'xt')
|
||||||
call feedkeys('achange3\<Esc>', 'xt')
|
call feedkeys('achange3\<Esc>', 'xt')
|
||||||
let a=execute('undolist')
|
let a = execute('undolist')
|
||||||
call assert_match("^\nnumber changes when *saved\n *2 *2 *.*\n *3 *2 .*$", a)
|
call assert_match("^\nnumber changes when *saved\n *2 *2 *.*\n *3 *2 .*$", a)
|
||||||
close!
|
close!
|
||||||
endfunc
|
endfunc
|
||||||
@ -330,7 +330,7 @@ endfunc
|
|||||||
" Also test this in an empty buffer.
|
" Also test this in an empty buffer.
|
||||||
func Test_cmd_in_reg_undo()
|
func Test_cmd_in_reg_undo()
|
||||||
enew!
|
enew!
|
||||||
let @a="Ox\<Esc>jAy\<Esc>kdd"
|
let @a = "Ox\<Esc>jAy\<Esc>kdd"
|
||||||
edit +/^$ test_undo.vim
|
edit +/^$ test_undo.vim
|
||||||
normal @au
|
normal @au
|
||||||
call assert_equal(0, &modified)
|
call assert_equal(0, &modified)
|
||||||
@ -339,7 +339,7 @@ func Test_cmd_in_reg_undo()
|
|||||||
normal @au
|
normal @au
|
||||||
call assert_equal(0, &modified)
|
call assert_equal(0, &modified)
|
||||||
only!
|
only!
|
||||||
let @a=''
|
let @a = ''
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_redo_empty_line()
|
func Test_redo_empty_line()
|
||||||
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user