mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
Merge pull request #17410 from zeertzjq/test-old-reorder
test(old): reorder test_functions.vim and test_visual.vim to match Vim
This commit is contained in:
commit
1bd6c0a05c
@ -332,37 +332,6 @@ func Test_simplify()
|
|||||||
call assert_fails('call simplify(1.2)', 'E806:')
|
call assert_fails('call simplify(1.2)', 'E806:')
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_setbufvar_options()
|
|
||||||
" This tests that aucmd_prepbuf() and aucmd_restbuf() properly restore the
|
|
||||||
" window layout.
|
|
||||||
call assert_equal(1, winnr('$'))
|
|
||||||
split dummy_preview
|
|
||||||
resize 2
|
|
||||||
set winfixheight winfixwidth
|
|
||||||
let prev_id = win_getid()
|
|
||||||
|
|
||||||
wincmd j
|
|
||||||
let wh = winheight(0)
|
|
||||||
let dummy_buf = bufnr('dummy_buf1', v:true)
|
|
||||||
call setbufvar(dummy_buf, '&buftype', 'nofile')
|
|
||||||
execute 'belowright vertical split #' . dummy_buf
|
|
||||||
call assert_equal(wh, winheight(0))
|
|
||||||
let dum1_id = win_getid()
|
|
||||||
|
|
||||||
wincmd h
|
|
||||||
let wh = winheight(0)
|
|
||||||
let dummy_buf = bufnr('dummy_buf2', v:true)
|
|
||||||
eval 'nofile'->setbufvar(dummy_buf, '&buftype')
|
|
||||||
execute 'belowright vertical split #' . dummy_buf
|
|
||||||
call assert_equal(wh, winheight(0))
|
|
||||||
|
|
||||||
bwipe!
|
|
||||||
call win_gotoid(prev_id)
|
|
||||||
bwipe!
|
|
||||||
call win_gotoid(dum1_id)
|
|
||||||
bwipe!
|
|
||||||
endfunc
|
|
||||||
|
|
||||||
func Test_pathshorten()
|
func Test_pathshorten()
|
||||||
call assert_equal('', pathshorten(''))
|
call assert_equal('', pathshorten(''))
|
||||||
call assert_equal('foo', pathshorten('foo'))
|
call assert_equal('foo', pathshorten('foo'))
|
||||||
@ -1293,6 +1262,37 @@ func Test_shellescape()
|
|||||||
let &shell = save_shell
|
let &shell = save_shell
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_setbufvar_options()
|
||||||
|
" This tests that aucmd_prepbuf() and aucmd_restbuf() properly restore the
|
||||||
|
" window layout.
|
||||||
|
call assert_equal(1, winnr('$'))
|
||||||
|
split dummy_preview
|
||||||
|
resize 2
|
||||||
|
set winfixheight winfixwidth
|
||||||
|
let prev_id = win_getid()
|
||||||
|
|
||||||
|
wincmd j
|
||||||
|
let wh = winheight(0)
|
||||||
|
let dummy_buf = bufnr('dummy_buf1', v:true)
|
||||||
|
call setbufvar(dummy_buf, '&buftype', 'nofile')
|
||||||
|
execute 'belowright vertical split #' . dummy_buf
|
||||||
|
call assert_equal(wh, winheight(0))
|
||||||
|
let dum1_id = win_getid()
|
||||||
|
|
||||||
|
wincmd h
|
||||||
|
let wh = winheight(0)
|
||||||
|
let dummy_buf = bufnr('dummy_buf2', v:true)
|
||||||
|
eval 'nofile'->setbufvar(dummy_buf, '&buftype')
|
||||||
|
execute 'belowright vertical split #' . dummy_buf
|
||||||
|
call assert_equal(wh, winheight(0))
|
||||||
|
|
||||||
|
bwipe!
|
||||||
|
call win_gotoid(prev_id)
|
||||||
|
bwipe!
|
||||||
|
call win_gotoid(dum1_id)
|
||||||
|
bwipe!
|
||||||
|
endfunc
|
||||||
|
|
||||||
func Test_redo_in_nested_functions()
|
func Test_redo_in_nested_functions()
|
||||||
nnoremap g. :set opfunc=Operator<CR>g@
|
nnoremap g. :set opfunc=Operator<CR>g@
|
||||||
function Operator( type, ... )
|
function Operator( type, ... )
|
||||||
@ -1350,98 +1350,6 @@ func Test_trim()
|
|||||||
call assert_equal("x", trim(chars . "x" . chars))
|
call assert_equal("x", trim(chars . "x" . chars))
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func EditAnotherFile()
|
|
||||||
let word = expand('<cword>')
|
|
||||||
edit Xfuncrange2
|
|
||||||
endfunc
|
|
||||||
|
|
||||||
func Test_func_range_with_edit()
|
|
||||||
" Define a function that edits another buffer, then call it with a range that
|
|
||||||
" is invalid in that buffer.
|
|
||||||
call writefile(['just one line'], 'Xfuncrange2')
|
|
||||||
new
|
|
||||||
eval 10->range()->setline(1)
|
|
||||||
write Xfuncrange1
|
|
||||||
call assert_fails('5,8call EditAnotherFile()', 'E16:')
|
|
||||||
|
|
||||||
call delete('Xfuncrange1')
|
|
||||||
call delete('Xfuncrange2')
|
|
||||||
bwipe!
|
|
||||||
endfunc
|
|
||||||
|
|
||||||
func Test_func_exists_on_reload()
|
|
||||||
call writefile(['func ExistingFunction()', 'echo "yes"', 'endfunc'], 'Xfuncexists')
|
|
||||||
call assert_equal(0, exists('*ExistingFunction'))
|
|
||||||
source Xfuncexists
|
|
||||||
call assert_equal(1, '*ExistingFunction'->exists())
|
|
||||||
" Redefining a function when reloading a script is OK.
|
|
||||||
source Xfuncexists
|
|
||||||
call assert_equal(1, exists('*ExistingFunction'))
|
|
||||||
|
|
||||||
" But redefining in another script is not OK.
|
|
||||||
call writefile(['func ExistingFunction()', 'echo "yes"', 'endfunc'], 'Xfuncexists2')
|
|
||||||
call assert_fails('source Xfuncexists2', 'E122:')
|
|
||||||
|
|
||||||
delfunc ExistingFunction
|
|
||||||
call assert_equal(0, exists('*ExistingFunction'))
|
|
||||||
call writefile([
|
|
||||||
\ 'func ExistingFunction()', 'echo "yes"', 'endfunc',
|
|
||||||
\ 'func ExistingFunction()', 'echo "no"', 'endfunc',
|
|
||||||
\ ], 'Xfuncexists')
|
|
||||||
call assert_fails('source Xfuncexists', 'E122:')
|
|
||||||
call assert_equal(1, exists('*ExistingFunction'))
|
|
||||||
|
|
||||||
call delete('Xfuncexists2')
|
|
||||||
call delete('Xfuncexists')
|
|
||||||
delfunc ExistingFunction
|
|
||||||
endfunc
|
|
||||||
|
|
||||||
func Test_platform_name()
|
|
||||||
" The system matches at most only one name.
|
|
||||||
let names = ['amiga', 'beos', 'bsd', 'hpux', 'linux', 'mac', 'qnx', 'sun', 'vms', 'win32', 'win32unix']
|
|
||||||
call assert_inrange(0, 1, len(filter(copy(names), 'has(v:val)')))
|
|
||||||
|
|
||||||
" Is Unix?
|
|
||||||
call assert_equal(has('beos'), has('beos') && has('unix'))
|
|
||||||
call assert_equal(has('bsd'), has('bsd') && has('unix'))
|
|
||||||
call assert_equal(has('hpux'), has('hpux') && has('unix'))
|
|
||||||
call assert_equal(has('linux'), has('linux') && has('unix'))
|
|
||||||
call assert_equal(has('mac'), has('mac') && has('unix'))
|
|
||||||
call assert_equal(has('qnx'), has('qnx') && has('unix'))
|
|
||||||
call assert_equal(has('sun'), has('sun') && has('unix'))
|
|
||||||
call assert_equal(has('win32'), has('win32') && !has('unix'))
|
|
||||||
call assert_equal(has('win32unix'), has('win32unix') && has('unix'))
|
|
||||||
|
|
||||||
if has('unix') && executable('uname')
|
|
||||||
let uname = system('uname')
|
|
||||||
call assert_equal(uname =~? 'BeOS', has('beos'))
|
|
||||||
" GNU userland on BSD kernels (e.g., GNU/kFreeBSD) don't have BSD defined
|
|
||||||
call assert_equal(uname =~? '\%(GNU/k\w\+\)\@<!BSD\|DragonFly', has('bsd'))
|
|
||||||
call assert_equal(uname =~? 'HP-UX', has('hpux'))
|
|
||||||
call assert_equal(uname =~? 'Linux', has('linux'))
|
|
||||||
call assert_equal(uname =~? 'Darwin', has('mac'))
|
|
||||||
call assert_equal(uname =~? 'QNX', has('qnx'))
|
|
||||||
call assert_equal(uname =~? 'SunOS', has('sun'))
|
|
||||||
call assert_equal(uname =~? 'CYGWIN\|MSYS', has('win32unix'))
|
|
||||||
endif
|
|
||||||
endfunc
|
|
||||||
|
|
||||||
sandbox function Fsandbox()
|
|
||||||
normal ix
|
|
||||||
endfunc
|
|
||||||
|
|
||||||
func Test_func_sandbox()
|
|
||||||
sandbox let F = {-> 'hello'}
|
|
||||||
call assert_equal('hello', F())
|
|
||||||
|
|
||||||
sandbox let F = {-> "normal ix\<Esc>"->execute()}
|
|
||||||
call assert_fails('call F()', 'E48:')
|
|
||||||
unlet F
|
|
||||||
|
|
||||||
call assert_fails('call Fsandbox()', 'E48:')
|
|
||||||
delfunc Fsandbox
|
|
||||||
endfunc
|
|
||||||
|
|
||||||
" Test for reg_recording() and reg_executing()
|
" Test for reg_recording() and reg_executing()
|
||||||
func Test_reg_executing_and_recording()
|
func Test_reg_executing_and_recording()
|
||||||
let s:reg_stat = ''
|
let s:reg_stat = ''
|
||||||
@ -1615,47 +1523,96 @@ func Test_libcall_libcallnr()
|
|||||||
call assert_fails("call libcallnr('Xdoesnotexist_', 'strlen', 'abcd')", 'E364:')
|
call assert_fails("call libcallnr('Xdoesnotexist_', 'strlen', 'abcd')", 'E364:')
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_bufadd_bufload()
|
sandbox function Fsandbox()
|
||||||
call assert_equal(0, bufexists('someName'))
|
normal ix
|
||||||
let buf = bufadd('someName')
|
endfunc
|
||||||
call assert_notequal(0, buf)
|
|
||||||
call assert_equal(1, bufexists('someName'))
|
|
||||||
call assert_equal(0, getbufvar(buf, '&buflisted'))
|
|
||||||
call assert_equal(0, bufloaded(buf))
|
|
||||||
call bufload(buf)
|
|
||||||
call assert_equal(1, bufloaded(buf))
|
|
||||||
call assert_equal([''], getbufline(buf, 1, '$'))
|
|
||||||
|
|
||||||
let curbuf = bufnr('')
|
func Test_func_sandbox()
|
||||||
eval ['some', 'text']->writefile('XotherName')
|
sandbox let F = {-> 'hello'}
|
||||||
let buf = 'XotherName'->bufadd()
|
call assert_equal('hello', F())
|
||||||
call assert_notequal(0, buf)
|
|
||||||
eval 'XotherName'->bufexists()->assert_equal(1)
|
|
||||||
call assert_equal(0, getbufvar(buf, '&buflisted'))
|
|
||||||
call assert_equal(0, bufloaded(buf))
|
|
||||||
eval buf->bufload()
|
|
||||||
call assert_equal(1, bufloaded(buf))
|
|
||||||
call assert_equal(['some', 'text'], getbufline(buf, 1, '$'))
|
|
||||||
call assert_equal(curbuf, bufnr(''))
|
|
||||||
|
|
||||||
let buf1 = bufadd('')
|
sandbox let F = {-> "normal ix\<Esc>"->execute()}
|
||||||
let buf2 = bufadd('')
|
call assert_fails('call F()', 'E48:')
|
||||||
call assert_notequal(0, buf1)
|
unlet F
|
||||||
call assert_notequal(0, buf2)
|
|
||||||
call assert_notequal(buf1, buf2)
|
|
||||||
call assert_equal(1, bufexists(buf1))
|
|
||||||
call assert_equal(1, bufexists(buf2))
|
|
||||||
call assert_equal(0, bufloaded(buf1))
|
|
||||||
exe 'bwipe ' .. buf1
|
|
||||||
call assert_equal(0, bufexists(buf1))
|
|
||||||
call assert_equal(1, bufexists(buf2))
|
|
||||||
exe 'bwipe ' .. buf2
|
|
||||||
call assert_equal(0, bufexists(buf2))
|
|
||||||
|
|
||||||
bwipe someName
|
call assert_fails('call Fsandbox()', 'E48:')
|
||||||
bwipe XotherName
|
delfunc Fsandbox
|
||||||
call assert_equal(0, bufexists('someName'))
|
endfunc
|
||||||
call delete('XotherName')
|
|
||||||
|
func EditAnotherFile()
|
||||||
|
let word = expand('<cword>')
|
||||||
|
edit Xfuncrange2
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
func Test_func_range_with_edit()
|
||||||
|
" Define a function that edits another buffer, then call it with a range that
|
||||||
|
" is invalid in that buffer.
|
||||||
|
call writefile(['just one line'], 'Xfuncrange2')
|
||||||
|
new
|
||||||
|
eval 10->range()->setline(1)
|
||||||
|
write Xfuncrange1
|
||||||
|
call assert_fails('5,8call EditAnotherFile()', 'E16:')
|
||||||
|
|
||||||
|
call delete('Xfuncrange1')
|
||||||
|
call delete('Xfuncrange2')
|
||||||
|
bwipe!
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
func Test_func_exists_on_reload()
|
||||||
|
call writefile(['func ExistingFunction()', 'echo "yes"', 'endfunc'], 'Xfuncexists')
|
||||||
|
call assert_equal(0, exists('*ExistingFunction'))
|
||||||
|
source Xfuncexists
|
||||||
|
call assert_equal(1, '*ExistingFunction'->exists())
|
||||||
|
" Redefining a function when reloading a script is OK.
|
||||||
|
source Xfuncexists
|
||||||
|
call assert_equal(1, exists('*ExistingFunction'))
|
||||||
|
|
||||||
|
" But redefining in another script is not OK.
|
||||||
|
call writefile(['func ExistingFunction()', 'echo "yes"', 'endfunc'], 'Xfuncexists2')
|
||||||
|
call assert_fails('source Xfuncexists2', 'E122:')
|
||||||
|
|
||||||
|
delfunc ExistingFunction
|
||||||
|
call assert_equal(0, exists('*ExistingFunction'))
|
||||||
|
call writefile([
|
||||||
|
\ 'func ExistingFunction()', 'echo "yes"', 'endfunc',
|
||||||
|
\ 'func ExistingFunction()', 'echo "no"', 'endfunc',
|
||||||
|
\ ], 'Xfuncexists')
|
||||||
|
call assert_fails('source Xfuncexists', 'E122:')
|
||||||
|
call assert_equal(1, exists('*ExistingFunction'))
|
||||||
|
|
||||||
|
call delete('Xfuncexists2')
|
||||||
|
call delete('Xfuncexists')
|
||||||
|
delfunc ExistingFunction
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
func Test_platform_name()
|
||||||
|
" The system matches at most only one name.
|
||||||
|
let names = ['amiga', 'beos', 'bsd', 'hpux', 'linux', 'mac', 'qnx', 'sun', 'vms', 'win32', 'win32unix']
|
||||||
|
call assert_inrange(0, 1, len(filter(copy(names), 'has(v:val)')))
|
||||||
|
|
||||||
|
" Is Unix?
|
||||||
|
call assert_equal(has('beos'), has('beos') && has('unix'))
|
||||||
|
call assert_equal(has('bsd'), has('bsd') && has('unix'))
|
||||||
|
call assert_equal(has('hpux'), has('hpux') && has('unix'))
|
||||||
|
call assert_equal(has('linux'), has('linux') && has('unix'))
|
||||||
|
call assert_equal(has('mac'), has('mac') && has('unix'))
|
||||||
|
call assert_equal(has('qnx'), has('qnx') && has('unix'))
|
||||||
|
call assert_equal(has('sun'), has('sun') && has('unix'))
|
||||||
|
call assert_equal(has('win32'), has('win32') && !has('unix'))
|
||||||
|
call assert_equal(has('win32unix'), has('win32unix') && has('unix'))
|
||||||
|
|
||||||
|
if has('unix') && executable('uname')
|
||||||
|
let uname = system('uname')
|
||||||
|
call assert_equal(uname =~? 'BeOS', has('beos'))
|
||||||
|
" GNU userland on BSD kernels (e.g., GNU/kFreeBSD) don't have BSD defined
|
||||||
|
call assert_equal(uname =~? '\%(GNU/k\w\+\)\@<!BSD\|DragonFly', has('bsd'))
|
||||||
|
call assert_equal(uname =~? 'HP-UX', has('hpux'))
|
||||||
|
call assert_equal(uname =~? 'Linux', has('linux'))
|
||||||
|
call assert_equal(uname =~? 'Darwin', has('mac'))
|
||||||
|
call assert_equal(uname =~? 'QNX', has('qnx'))
|
||||||
|
call assert_equal(uname =~? 'SunOS', has('sun'))
|
||||||
|
call assert_equal(uname =~? 'CYGWIN\|MSYS', has('win32unix'))
|
||||||
|
endif
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_readdir()
|
func Test_readdir()
|
||||||
@ -1714,6 +1671,49 @@ func Test_eventhandler()
|
|||||||
call assert_equal(0, eventhandler())
|
call assert_equal(0, eventhandler())
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_bufadd_bufload()
|
||||||
|
call assert_equal(0, bufexists('someName'))
|
||||||
|
let buf = bufadd('someName')
|
||||||
|
call assert_notequal(0, buf)
|
||||||
|
call assert_equal(1, bufexists('someName'))
|
||||||
|
call assert_equal(0, getbufvar(buf, '&buflisted'))
|
||||||
|
call assert_equal(0, bufloaded(buf))
|
||||||
|
call bufload(buf)
|
||||||
|
call assert_equal(1, bufloaded(buf))
|
||||||
|
call assert_equal([''], getbufline(buf, 1, '$'))
|
||||||
|
|
||||||
|
let curbuf = bufnr('')
|
||||||
|
eval ['some', 'text']->writefile('XotherName')
|
||||||
|
let buf = 'XotherName'->bufadd()
|
||||||
|
call assert_notequal(0, buf)
|
||||||
|
eval 'XotherName'->bufexists()->assert_equal(1)
|
||||||
|
call assert_equal(0, getbufvar(buf, '&buflisted'))
|
||||||
|
call assert_equal(0, bufloaded(buf))
|
||||||
|
eval buf->bufload()
|
||||||
|
call assert_equal(1, bufloaded(buf))
|
||||||
|
call assert_equal(['some', 'text'], getbufline(buf, 1, '$'))
|
||||||
|
call assert_equal(curbuf, bufnr(''))
|
||||||
|
|
||||||
|
let buf1 = bufadd('')
|
||||||
|
let buf2 = bufadd('')
|
||||||
|
call assert_notequal(0, buf1)
|
||||||
|
call assert_notequal(0, buf2)
|
||||||
|
call assert_notequal(buf1, buf2)
|
||||||
|
call assert_equal(1, bufexists(buf1))
|
||||||
|
call assert_equal(1, bufexists(buf2))
|
||||||
|
call assert_equal(0, bufloaded(buf1))
|
||||||
|
exe 'bwipe ' .. buf1
|
||||||
|
call assert_equal(0, bufexists(buf1))
|
||||||
|
call assert_equal(1, bufexists(buf2))
|
||||||
|
exe 'bwipe ' .. buf2
|
||||||
|
call assert_equal(0, bufexists(buf2))
|
||||||
|
|
||||||
|
bwipe someName
|
||||||
|
bwipe XotherName
|
||||||
|
call assert_equal(0, bufexists('someName'))
|
||||||
|
call delete('XotherName')
|
||||||
|
endfunc
|
||||||
|
|
||||||
" Test for the eval() function
|
" Test for the eval() function
|
||||||
func Test_eval()
|
func Test_eval()
|
||||||
call assert_fails("call eval('5 a')", 'E488:')
|
call assert_fails("call eval('5 a')", 'E488:')
|
||||||
|
@ -22,6 +22,14 @@ func Test_block_shift_overflow()
|
|||||||
q!
|
q!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_dotregister_paste()
|
||||||
|
new
|
||||||
|
exe "norm! ihello world\<esc>"
|
||||||
|
norm! 0ve".p
|
||||||
|
call assert_equal('hello world world', getline(1))
|
||||||
|
q!
|
||||||
|
endfunc
|
||||||
|
|
||||||
func Test_Visual_ctrl_o()
|
func Test_Visual_ctrl_o()
|
||||||
new
|
new
|
||||||
call setline(1, ['one', 'two', 'three'])
|
call setline(1, ['one', 'two', 'three'])
|
||||||
@ -42,14 +50,6 @@ func Test_Visual_vapo()
|
|||||||
bwipe!
|
bwipe!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_dotregister_paste()
|
|
||||||
new
|
|
||||||
exe "norm! ihello world\<esc>"
|
|
||||||
norm! 0ve".p
|
|
||||||
call assert_equal('hello world world', getline(1))
|
|
||||||
q!
|
|
||||||
endfunc
|
|
||||||
|
|
||||||
func Test_Visual_inner_quote()
|
func Test_Visual_inner_quote()
|
||||||
new
|
new
|
||||||
normal oxX
|
normal oxX
|
||||||
@ -57,6 +57,34 @@ func Test_Visual_inner_quote()
|
|||||||
bwipe!
|
bwipe!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
" Test for Visual mode not being reset causing E315 error.
|
||||||
|
func TriggerTheProblem()
|
||||||
|
" At this point there is no visual selection because :call reset it.
|
||||||
|
" Let's restore the selection:
|
||||||
|
normal gv
|
||||||
|
'<,'>del _
|
||||||
|
try
|
||||||
|
exe "normal \<Esc>"
|
||||||
|
catch /^Vim\%((\a\+)\)\=:E315/
|
||||||
|
echom 'Snap! E315 error!'
|
||||||
|
let g:msg = 'Snap! E315 error!'
|
||||||
|
endtry
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
func Test_visual_mode_reset()
|
||||||
|
enew
|
||||||
|
let g:msg = "Everything's fine."
|
||||||
|
enew
|
||||||
|
setl buftype=nofile
|
||||||
|
call append(line('$'), 'Delete this line.')
|
||||||
|
|
||||||
|
" NOTE: this has to be done by a call to a function because executing :del
|
||||||
|
" the ex-way will require the colon operator which resets the visual mode
|
||||||
|
" thus preventing the problem:
|
||||||
|
exe "normal! GV:call TriggerTheProblem()\<CR>"
|
||||||
|
call assert_equal("Everything's fine.", g:msg)
|
||||||
|
endfunc
|
||||||
|
|
||||||
" Test for visual block shift and tab characters.
|
" Test for visual block shift and tab characters.
|
||||||
func Test_block_shift_tab()
|
func Test_block_shift_tab()
|
||||||
new
|
new
|
||||||
@ -261,34 +289,6 @@ func Test_virtual_replace2()
|
|||||||
set bs&vim
|
set bs&vim
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
" Test for Visual mode not being reset causing E315 error.
|
|
||||||
func TriggerTheProblem()
|
|
||||||
" At this point there is no visual selection because :call reset it.
|
|
||||||
" Let's restore the selection:
|
|
||||||
normal gv
|
|
||||||
'<,'>del _
|
|
||||||
try
|
|
||||||
exe "normal \<Esc>"
|
|
||||||
catch /^Vim\%((\a\+)\)\=:E315/
|
|
||||||
echom 'Snap! E315 error!'
|
|
||||||
let g:msg = 'Snap! E315 error!'
|
|
||||||
endtry
|
|
||||||
endfunc
|
|
||||||
|
|
||||||
func Test_visual_mode_reset()
|
|
||||||
enew
|
|
||||||
let g:msg = "Everything's fine."
|
|
||||||
enew
|
|
||||||
setl buftype=nofile
|
|
||||||
call append(line('$'), 'Delete this line.')
|
|
||||||
|
|
||||||
" NOTE: this has to be done by a call to a function because executing :del
|
|
||||||
" the ex-way will require the colon operator which resets the visual mode
|
|
||||||
" thus preventing the problem:
|
|
||||||
exe "normal! GV:call TriggerTheProblem()\<CR>"
|
|
||||||
call assert_equal("Everything's fine.", g:msg)
|
|
||||||
endfunc
|
|
||||||
|
|
||||||
func Test_Visual_word_textobject()
|
func Test_Visual_word_textobject()
|
||||||
new
|
new
|
||||||
call setline(1, ['First sentence. Second sentence.'])
|
call setline(1, ['First sentence. Second sentence.'])
|
||||||
@ -367,17 +367,6 @@ func Test_Visual_sentence_textobject()
|
|||||||
bwipe!
|
bwipe!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_curswant_not_changed()
|
|
||||||
new
|
|
||||||
call setline(1, ['one', 'two'])
|
|
||||||
au InsertLeave * call getcurpos()
|
|
||||||
call feedkeys("gg0\<C-V>jI123 \<Esc>j", 'xt')
|
|
||||||
call assert_equal([0, 2, 1, 0, 1], getcurpos())
|
|
||||||
|
|
||||||
bwipe!
|
|
||||||
au! InsertLeave
|
|
||||||
endfunc
|
|
||||||
|
|
||||||
func Test_Visual_paragraph_textobject()
|
func Test_Visual_paragraph_textobject()
|
||||||
new
|
new
|
||||||
call setline(1, ['First line.',
|
call setline(1, ['First line.',
|
||||||
@ -427,6 +416,17 @@ func Test_Visual_paragraph_textobject()
|
|||||||
bwipe!
|
bwipe!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_curswant_not_changed()
|
||||||
|
new
|
||||||
|
call setline(1, ['one', 'two'])
|
||||||
|
au InsertLeave * call getcurpos()
|
||||||
|
call feedkeys("gg0\<C-V>jI123 \<Esc>j", 'xt')
|
||||||
|
call assert_equal([0, 2, 1, 0, 1], getcurpos())
|
||||||
|
|
||||||
|
bwipe!
|
||||||
|
au! InsertLeave
|
||||||
|
endfunc
|
||||||
|
|
||||||
" Tests for "vaBiB", end could be wrong.
|
" Tests for "vaBiB", end could be wrong.
|
||||||
func Test_Visual_Block()
|
func Test_Visual_Block()
|
||||||
new
|
new
|
||||||
@ -462,15 +462,6 @@ func Test_visual_block_put()
|
|||||||
bw!
|
bw!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_visual_put_in_block()
|
|
||||||
new
|
|
||||||
call setline(1, ['xxxx', 'y∞yy', 'zzzz'])
|
|
||||||
normal 1G2yl
|
|
||||||
exe "normal 1G2l\<C-V>jjlp"
|
|
||||||
call assert_equal(['xxxx', 'y∞xx', 'zzxx'], getline(1, 3))
|
|
||||||
bwipe!
|
|
||||||
endfunc
|
|
||||||
|
|
||||||
" Visual modes (v V CTRL-V) followed by an operator; count; repeating
|
" Visual modes (v V CTRL-V) followed by an operator; count; repeating
|
||||||
func Test_visual_mode_op()
|
func Test_visual_mode_op()
|
||||||
new
|
new
|
||||||
@ -1109,6 +1100,15 @@ func Test_block_insert_replace_tabs()
|
|||||||
bwipe!
|
bwipe!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_visual_put_in_block()
|
||||||
|
new
|
||||||
|
call setline(1, ['xxxx', 'y∞yy', 'zzzz'])
|
||||||
|
normal 1G2yl
|
||||||
|
exe "normal 1G2l\<C-V>jjlp"
|
||||||
|
call assert_equal(['xxxx', 'y∞xx', 'zzxx'], getline(1, 3))
|
||||||
|
bwipe!
|
||||||
|
endfunc
|
||||||
|
|
||||||
func Test_visual_put_in_block_using_zp()
|
func Test_visual_put_in_block_using_zp()
|
||||||
new
|
new
|
||||||
" paste using zP
|
" paste using zP
|
||||||
|
Loading…
Reference in New Issue
Block a user