2018-02-02 15:14:30 -07:00
|
|
|
|
|
|
|
" Test for insert expansion
|
|
|
|
func Test_ins_complete()
|
2018-02-03 04:11:07 -07:00
|
|
|
edit test_ins_complete.vim
|
2018-02-11 16:05:54 -07:00
|
|
|
" The files in the current directory interferes with the files
|
|
|
|
" used by this test. So use a separate directory for the test.
|
|
|
|
call mkdir('Xdir')
|
|
|
|
cd Xdir
|
|
|
|
|
2018-02-02 15:14:30 -07:00
|
|
|
set ff=unix
|
|
|
|
call writefile(["test11\t36Gepeto\t/Tag/",
|
|
|
|
\ "asd\ttest11file\t36G",
|
|
|
|
\ "Makefile\tto\trun"], 'Xtestfile')
|
|
|
|
call writefile(['', 'start of testfile',
|
|
|
|
\ 'ru',
|
|
|
|
\ 'run1',
|
|
|
|
\ 'run2',
|
|
|
|
\ 'STARTTEST',
|
|
|
|
\ 'ENDTEST',
|
|
|
|
\ 'end of testfile'], 'Xtestdata')
|
|
|
|
set ff&
|
|
|
|
|
|
|
|
enew!
|
|
|
|
edit Xtestdata
|
|
|
|
new
|
|
|
|
call append(0, ['#include "Xtestfile"', ''])
|
|
|
|
call cursor(2, 1)
|
|
|
|
|
|
|
|
set cot=
|
|
|
|
set cpt=.,w
|
|
|
|
" add-expands (word from next line) from other window
|
|
|
|
exe "normal iru\<C-N>\<C-N>\<C-X>\<C-N>\<Esc>\<C-A>"
|
|
|
|
call assert_equal('run1 run3', getline('.'))
|
|
|
|
" add-expands (current buffer first)
|
|
|
|
exe "normal o\<C-P>\<C-X>\<C-N>"
|
|
|
|
call assert_equal('run3 run3', getline('.'))
|
|
|
|
" Local expansion, ends in an empty line (unless it becomes a global
|
|
|
|
" expansion)
|
|
|
|
exe "normal o\<C-X>\<C-P>\<C-P>\<C-P>\<C-P>\<C-P>"
|
|
|
|
call assert_equal('', getline('.'))
|
|
|
|
" starts Local and switches to global add-expansion
|
|
|
|
exe "normal o\<C-X>\<C-P>\<C-P>\<C-X>\<C-X>\<C-N>\<C-X>\<C-N>\<C-N>"
|
|
|
|
call assert_equal('run1 run2', getline('.'))
|
|
|
|
|
|
|
|
set cpt=.,w,i
|
|
|
|
" i-add-expands and switches to local
|
|
|
|
exe "normal OM\<C-N>\<C-X>\<C-N>\<C-X>\<C-N>\<C-X>\<C-X>\<C-X>\<C-P>"
|
|
|
|
call assert_equal("Makefile\tto\trun3", getline('.'))
|
|
|
|
" add-expands lines (it would end in an empty line if it didn't ignored
|
|
|
|
" itself)
|
|
|
|
exe "normal o\<C-X>\<C-L>\<C-X>\<C-L>\<C-P>\<C-P>"
|
|
|
|
call assert_equal("Makefile\tto\trun3", getline('.'))
|
|
|
|
call assert_equal("Makefile\tto\trun3", getline(line('.') - 1))
|
|
|
|
|
|
|
|
set cpt=kXtestfile
|
|
|
|
" checks k-expansion, and file expansion (use Xtest11 instead of test11,
|
|
|
|
" because TEST11.OUT may match first on DOS)
|
|
|
|
write Xtest11.one
|
|
|
|
write Xtest11.two
|
|
|
|
exe "normal o\<C-N>\<Esc>IX\<Esc>A\<C-X>\<C-F>\<C-N>"
|
|
|
|
call assert_equal('Xtest11.two', getline('.'))
|
|
|
|
|
|
|
|
" use CTRL-X CTRL-F to complete Xtest11.one, remove it and then use CTRL-X
|
|
|
|
" CTRL-F again to verify this doesn't cause trouble.
|
|
|
|
exe "normal oXt\<C-X>\<C-F>\<BS>\<BS>\<BS>\<BS>\<BS>\<BS>\<BS>\<BS>\<C-X>\<C-F>"
|
|
|
|
call assert_equal('Xtest11.one', getline('.'))
|
|
|
|
normal ddk
|
|
|
|
|
|
|
|
set cpt=w
|
|
|
|
" checks make_cyclic in other window
|
|
|
|
exe "normal oST\<C-N>\<C-P>\<C-P>\<C-P>\<C-P>"
|
|
|
|
call assert_equal('STARTTEST', getline('.'))
|
|
|
|
|
|
|
|
set cpt=u nohid
|
|
|
|
" checks unloaded buffer expansion
|
|
|
|
only
|
|
|
|
exe "normal oEN\<C-N>"
|
|
|
|
call assert_equal('ENDTEST', getline('.'))
|
|
|
|
" checks adding mode abortion
|
|
|
|
exe "normal ounl\<C-N>\<C-X>\<C-X>\<C-P>"
|
|
|
|
call assert_equal('unless', getline('.'))
|
|
|
|
|
|
|
|
set cpt=t,d def=^\\k* tags=Xtestfile notagbsearch
|
|
|
|
" tag expansion, define add-expansion interrupted
|
|
|
|
exe "normal o\<C-X>\<C-]>\<C-X>\<C-D>\<C-X>\<C-D>\<C-X>\<C-X>\<C-D>\<C-X>\<C-D>\<C-X>\<C-D>\<C-X>\<C-D>"
|
|
|
|
call assert_equal('test11file 36Gepeto /Tag/ asd', getline('.'))
|
|
|
|
" t-expansion
|
|
|
|
exe "normal oa\<C-N>\<Esc>"
|
|
|
|
call assert_equal('asd', getline('.'))
|
|
|
|
|
|
|
|
%bw!
|
|
|
|
call delete('Xtestfile')
|
|
|
|
call delete('Xtest11.one')
|
|
|
|
call delete('Xtest11.two')
|
|
|
|
call delete('Xtestdata')
|
|
|
|
set cpt& cot& def& tags& tagbsearch& hidden&
|
2018-02-11 16:05:54 -07:00
|
|
|
cd ..
|
|
|
|
call delete('Xdir', 'rf')
|
2018-02-02 15:14:30 -07:00
|
|
|
endfunc
|