forked from aniani/vim
patch 8.0.1209: still too many old style tests
Problem: Still too many old style tests. Solution: Convert a few more tests to new style. (Yegappan Lakshmanan, closes #2230)
This commit is contained in:
17
src/Makefile
17
src/Makefile
@@ -2088,9 +2088,9 @@ run_memfile_test: $(MEMFILE_TEST_TARGET)
|
|||||||
run_message_test: $(MESSAGE_TEST_TARGET)
|
run_message_test: $(MESSAGE_TEST_TARGET)
|
||||||
$(VALGRIND) ./$(MESSAGE_TEST_TARGET) || exit 1; echo $* passed;
|
$(VALGRIND) ./$(MESSAGE_TEST_TARGET) || exit 1; echo $* passed;
|
||||||
|
|
||||||
# Run individual OLD style test, assuming that Vim was already compiled.
|
# Run individual OLD style test.
|
||||||
|
# These do not depend on the executable, compile it when needed.
|
||||||
test1 \
|
test1 \
|
||||||
test_autoformat_join \
|
|
||||||
test_changelist \
|
test_changelist \
|
||||||
test_close_count \
|
test_close_count \
|
||||||
test_erasebackword \
|
test_erasebackword \
|
||||||
@@ -2100,20 +2100,19 @@ test1 \
|
|||||||
test_listchars \
|
test_listchars \
|
||||||
test_search_mbyte \
|
test_search_mbyte \
|
||||||
test_wordcount \
|
test_wordcount \
|
||||||
test3 test8 \
|
test3 test11 test12 test14 test15 test17 test19 \
|
||||||
test11 test12 test14 test15 test17 test19 \
|
|
||||||
test20 test25 test28 test29 \
|
test20 test25 test28 test29 \
|
||||||
test30 test32 test34 test36 test37 test38 test39 \
|
test30 test32 test36 test37 test38 test39 \
|
||||||
test40 test42 test44 test45 test48 test49 \
|
test40 test42 test44 test45 test48 test49 \
|
||||||
test50 test52 test54 test55 test59 \
|
test50 test52 test55 test59 \
|
||||||
test64 test66 test68 test69 \
|
test64 test66 test68 test69 \
|
||||||
test70 test72 test73 test77 test79 \
|
test70 test72 test73 test77 test79 \
|
||||||
test83 test85 test86 test87 test88 \
|
test83 test85 test86 test87 test88 \
|
||||||
test94 test95 test99 \
|
test94 test95 test99 test108:
|
||||||
test108:
|
|
||||||
cd testdir; rm -f $@.out; $(MAKE) -f Makefile $@.out VIMPROG=../$(VIMTARGET) $(GUI_TESTARG) SCRIPTSOURCE=../$(SCRIPTSOURCE)
|
cd testdir; rm -f $@.out; $(MAKE) -f Makefile $@.out VIMPROG=../$(VIMTARGET) $(GUI_TESTARG) SCRIPTSOURCE=../$(SCRIPTSOURCE)
|
||||||
|
|
||||||
# Run individual NEW style test, assuming that Vim was already compiled.
|
# Run individual NEW style test.
|
||||||
|
# These do not depend on the executable, compile it when needed.
|
||||||
test_arglist \
|
test_arglist \
|
||||||
test_arabic \
|
test_arabic \
|
||||||
test_assert \
|
test_assert \
|
||||||
|
@@ -14,14 +14,12 @@ SCRIPTS_FIRST = \
|
|||||||
# Tests that run on all systems.
|
# Tests that run on all systems.
|
||||||
SCRIPTS_ALL = \
|
SCRIPTS_ALL = \
|
||||||
test3.out \
|
test3.out \
|
||||||
test8.out \
|
|
||||||
test14.out \
|
test14.out \
|
||||||
test15.out \
|
test15.out \
|
||||||
test19.out \
|
test19.out \
|
||||||
test20.out \
|
test20.out \
|
||||||
test28.out \
|
test28.out \
|
||||||
test29.out \
|
test29.out \
|
||||||
test34.out \
|
|
||||||
test36.out \
|
test36.out \
|
||||||
test37.out \
|
test37.out \
|
||||||
test38.out \
|
test38.out \
|
||||||
@@ -44,7 +42,6 @@ SCRIPTS_ALL = \
|
|||||||
test95.out \
|
test95.out \
|
||||||
test99.out \
|
test99.out \
|
||||||
test108.out \
|
test108.out \
|
||||||
test_autoformat_join.out \
|
|
||||||
test_changelist.out \
|
test_changelist.out \
|
||||||
test_close_count.out \
|
test_close_count.out \
|
||||||
test_erasebackword.out \
|
test_erasebackword.out \
|
||||||
@@ -72,11 +69,6 @@ SCRIPTS_MORE2 = \
|
|||||||
test49.out
|
test49.out
|
||||||
|
|
||||||
|
|
||||||
# Tests that run on most systems, but not MingW and Cygwin.
|
|
||||||
SCRIPTS_MORE3 = \
|
|
||||||
test54.out
|
|
||||||
|
|
||||||
|
|
||||||
# Tests that run on most systems, but not on VMS
|
# Tests that run on most systems, but not on VMS
|
||||||
SCRIPTS_MORE4 = \
|
SCRIPTS_MORE4 = \
|
||||||
test17.out \
|
test17.out \
|
||||||
@@ -187,6 +179,7 @@ NEW_TESTS = test_arabic.res \
|
|||||||
test_textobjects.res \
|
test_textobjects.res \
|
||||||
test_undo.res \
|
test_undo.res \
|
||||||
test_usercommands.res \
|
test_usercommands.res \
|
||||||
|
test_user_func.res \
|
||||||
test_viminfo.res \
|
test_viminfo.res \
|
||||||
test_vimscript.res \
|
test_vimscript.res \
|
||||||
test_visual.res \
|
test_visual.res \
|
||||||
|
@@ -19,7 +19,7 @@ include Make_all.mak
|
|||||||
# test85 no Lua interface
|
# test85 no Lua interface
|
||||||
# test86, 87 no Python interface
|
# test86, 87 no Python interface
|
||||||
|
|
||||||
SCRIPTS = $(SCRIPTS_ALL) $(SCRIPTS_MORE3) $(SCRIPTS_MORE4)
|
SCRIPTS = $(SCRIPTS_ALL) $(SCRIPTS_MORE4)
|
||||||
|
|
||||||
# Must run test1 first to create small.vim.
|
# Must run test1 first to create small.vim.
|
||||||
$(SCRIPTS) $(SCRIPTS_GUI) $(NEW_TESTS): $(SCRIPTS_FIRST)
|
$(SCRIPTS) $(SCRIPTS_GUI) $(NEW_TESTS): $(SCRIPTS_FIRST)
|
||||||
|
@@ -17,7 +17,7 @@ default: nongui
|
|||||||
# test49 fails in various ways
|
# test49 fails in various ways
|
||||||
# test97 \{ and \$ are not escaped characters.
|
# test97 \{ and \$ are not escaped characters.
|
||||||
|
|
||||||
SCRIPTS = $(SCRIPTS_ALL) $(SCRIPTS_MORE1) $(SCRIPTS_MORE3) $(SCRIPTS_MORE4)
|
SCRIPTS = $(SCRIPTS_ALL) $(SCRIPTS_MORE1) $(SCRIPTS_MORE4)
|
||||||
|
|
||||||
TEST_OUTFILES = $(SCRIPTS_FIRST) $(SCRIPTS) $(SCRIPTS_WIN32) $(SCRIPTS_GUI)
|
TEST_OUTFILES = $(SCRIPTS_FIRST) $(SCRIPTS) $(SCRIPTS_WIN32) $(SCRIPTS_GUI)
|
||||||
DOSTMP = dostmp
|
DOSTMP = dostmp
|
||||||
|
@@ -4,8 +4,6 @@
|
|||||||
#
|
#
|
||||||
# Author: Bill McCarthy
|
# Author: Bill McCarthy
|
||||||
#
|
#
|
||||||
# Note that test54 has been removed until it is fixed.
|
|
||||||
#
|
|
||||||
# Requires a set of Unix tools: echo, diff, etc.
|
# Requires a set of Unix tools: echo, diff, etc.
|
||||||
|
|
||||||
ifneq (sh.exe, $(SHELL))
|
ifneq (sh.exe, $(SHELL))
|
||||||
@@ -35,7 +33,6 @@ include Make_all.mak
|
|||||||
# test10 'errorformat' is different
|
# test10 'errorformat' is different
|
||||||
# test12 can't unlink a swap file
|
# test12 can't unlink a swap file
|
||||||
# test25 uses symbolic link
|
# test25 uses symbolic link
|
||||||
# test54 doesn't work yet
|
|
||||||
# test97 \{ and \$ are not escaped characters
|
# test97 \{ and \$ are not escaped characters
|
||||||
|
|
||||||
SCRIPTS = $(SCRIPTS_ALL) $(SCRIPTS_MORE1) $(SCRIPTS_MORE4) $(SCRIPTS_WIN32)
|
SCRIPTS = $(SCRIPTS_ALL) $(SCRIPTS_MORE1) $(SCRIPTS_MORE4) $(SCRIPTS_WIN32)
|
||||||
|
@@ -74,14 +74,13 @@ VIMPROG = <->vim.exe
|
|||||||
.SUFFIXES : .out .in
|
.SUFFIXES : .out .in
|
||||||
|
|
||||||
SCRIPT = test1.out test3.out \
|
SCRIPT = test1.out test3.out \
|
||||||
test8.out \
|
|
||||||
test14.out test15.out \
|
test14.out test15.out \
|
||||||
test19.out test20.out \
|
test19.out test20.out \
|
||||||
test28.out test29.out test30.out test32.out \
|
test28.out test29.out test30.out test32.out \
|
||||||
test34.out test36.out test37.out \
|
test36.out test37.out \
|
||||||
test38.out test39.out test40.out test42.out \
|
test38.out test39.out test40.out test42.out \
|
||||||
test44.out test45.out \
|
test44.out test45.out \
|
||||||
test48.out test49.out test54.out \
|
test48.out test49.out \
|
||||||
test55.out \
|
test55.out \
|
||||||
test64.out \
|
test64.out \
|
||||||
test66.out test68.out test69.out \
|
test66.out test68.out test69.out \
|
||||||
@@ -92,7 +91,6 @@ SCRIPT = test1.out test3.out \
|
|||||||
test95.out test99.out \
|
test95.out test99.out \
|
||||||
test108.out\
|
test108.out\
|
||||||
test_autocmd_option.out \
|
test_autocmd_option.out \
|
||||||
test_autoformat_join.out \
|
|
||||||
test_breakindent.out \
|
test_breakindent.out \
|
||||||
test_changelist.out \
|
test_changelist.out \
|
||||||
test_close_count.out \
|
test_close_count.out \
|
||||||
|
@@ -24,7 +24,6 @@ include Make_all.mak
|
|||||||
SCRIPTS = $(SCRIPTS_ALL) \
|
SCRIPTS = $(SCRIPTS_ALL) \
|
||||||
$(SCRIPTS_MORE1) \
|
$(SCRIPTS_MORE1) \
|
||||||
$(SCRIPTS_MORE2) \
|
$(SCRIPTS_MORE2) \
|
||||||
$(SCRIPTS_MORE3) \
|
|
||||||
$(SCRIPTS_MORE4)
|
$(SCRIPTS_MORE4)
|
||||||
|
|
||||||
SCRIPTS_BENCH = bench_re_freeze.out
|
SCRIPTS_BENCH = bench_re_freeze.out
|
||||||
|
@@ -5,12 +5,12 @@
|
|||||||
VimProg ?= ../vim
|
VimProg ?= ../vim
|
||||||
|
|
||||||
Scripts = test1.out test2.out test3.out test6.out
|
Scripts = test1.out test2.out test3.out test6.out
|
||||||
test8.out test11.out
|
test11.out
|
||||||
test12.out test13.out test14.out test15.out test17.out
|
test12.out test13.out test14.out test15.out test17.out
|
||||||
test18.out test19.out test20.out test21.out
|
test18.out test19.out test20.out test21.out
|
||||||
test25.out test27.out
|
test25.out test27.out
|
||||||
test28.out test29.out test30.out test32.out
|
test28.out test29.out test30.out test32.out
|
||||||
test34.out test36.out test37.out
|
test36.out test37.out
|
||||||
test38.out test39.out test40.out test42.out
|
test38.out test39.out test40.out test42.out
|
||||||
test44.out test45.out test46.out test47.out
|
test44.out test45.out test46.out test47.out
|
||||||
test48.out test49.out test74.out
|
test48.out test49.out test74.out
|
||||||
|
@@ -1,87 +0,0 @@
|
|||||||
Test for user functions.
|
|
||||||
Also test an <expr> mapping calling a function.
|
|
||||||
Also test that a builtin function cannot be replaced.
|
|
||||||
Also test for regression when calling arbitrary expression.
|
|
||||||
|
|
||||||
STARTTEST
|
|
||||||
:so small.vim
|
|
||||||
:function Table(title, ...)
|
|
||||||
: let ret = a:title
|
|
||||||
: let idx = 1
|
|
||||||
: while idx <= a:0
|
|
||||||
: exe "let ret = ret . a:" . idx
|
|
||||||
: let idx = idx + 1
|
|
||||||
: endwhile
|
|
||||||
: return ret
|
|
||||||
:endfunction
|
|
||||||
:function Compute(n1, n2, divname)
|
|
||||||
: if a:n2 == 0
|
|
||||||
: return "fail"
|
|
||||||
: endif
|
|
||||||
: exe "let g:" . a:divname . " = ". a:n1 / a:n2
|
|
||||||
: return "ok"
|
|
||||||
:endfunction
|
|
||||||
:func Expr1()
|
|
||||||
: normal! v
|
|
||||||
: return "111"
|
|
||||||
:endfunc
|
|
||||||
:func Expr2()
|
|
||||||
: call search('XX', 'b')
|
|
||||||
: return "222"
|
|
||||||
:endfunc
|
|
||||||
:func ListItem()
|
|
||||||
: let g:counter += 1
|
|
||||||
: return g:counter . '. '
|
|
||||||
:endfunc
|
|
||||||
:func ListReset()
|
|
||||||
: let g:counter = 0
|
|
||||||
: return ''
|
|
||||||
:endfunc
|
|
||||||
:func FuncWithRef(a)
|
|
||||||
: unlet g:FuncRef
|
|
||||||
: return a:a
|
|
||||||
:endfunc
|
|
||||||
:let g:FuncRef=function("FuncWithRef")
|
|
||||||
:let counter = 0
|
|
||||||
:inoremap <expr> ( ListItem()
|
|
||||||
:inoremap <expr> [ ListReset()
|
|
||||||
:imap <expr> + Expr1()
|
|
||||||
:imap <expr> * Expr2()
|
|
||||||
:let retval = "nop"
|
|
||||||
/^here
|
|
||||||
C=Table("xxx", 4, "asdf")
|
|
||||||
=Compute(45, 0, "retval")
|
|
||||||
=retval
|
|
||||||
=Compute(45, 5, "retval")
|
|
||||||
=retval
|
|
||||||
=g:FuncRef(333)
|
|
||||||
|
|
||||||
XX+-XX
|
|
||||||
---*---
|
|
||||||
(one
|
|
||||||
(two
|
|
||||||
[(one again:call append(line('$'), max([1, 2, 3]))
|
|
||||||
:call extend(g:, {'max': function('min')})
|
|
||||||
:call append(line('$'), max([1, 2, 3]))
|
|
||||||
:try
|
|
||||||
: " Regression: the first line below used to throw ?E110: Missing ')'?
|
|
||||||
: " Second is here just to prove that this line is correct when not skipping
|
|
||||||
: " rhs of &&.
|
|
||||||
: $put =(0&&(function('tr'))(1, 2, 3))
|
|
||||||
: $put =(1&&(function('tr'))(1, 2, 3))
|
|
||||||
:catch
|
|
||||||
: $put ='!!! Unexpected exception:'
|
|
||||||
: $put =v:exception
|
|
||||||
:endtry
|
|
||||||
:$-9,$w! test.out
|
|
||||||
:delfunc Table
|
|
||||||
:delfunc Compute
|
|
||||||
:delfunc Expr1
|
|
||||||
:delfunc Expr2
|
|
||||||
:delfunc ListItem
|
|
||||||
:delfunc ListReset
|
|
||||||
:unlet retval counter
|
|
||||||
:q!
|
|
||||||
ENDTEST
|
|
||||||
|
|
||||||
here
|
|
@@ -1,10 +0,0 @@
|
|||||||
xxx4asdf fail nop ok 9 333
|
|
||||||
XX111-XX
|
|
||||||
---222---
|
|
||||||
1. one
|
|
||||||
2. two
|
|
||||||
1. one again
|
|
||||||
3
|
|
||||||
3
|
|
||||||
0
|
|
||||||
1
|
|
@@ -1,22 +0,0 @@
|
|||||||
Some tests for buffer-local autocommands
|
|
||||||
|
|
||||||
STARTTEST
|
|
||||||
:so small.vim
|
|
||||||
:e xx
|
|
||||||
:if has("vms")
|
|
||||||
: !del test.out.*
|
|
||||||
: au BufLeave <buffer> :!write sys$output "buffer-local autommand in %" > test.out
|
|
||||||
:else
|
|
||||||
: !rm -f test.out
|
|
||||||
: au BufLeave <buffer> :!echo buffer-local autommand in %>> test.out
|
|
||||||
:endif
|
|
||||||
:e somefile " here, autocommand for xx shall write test.out
|
|
||||||
: " but autocommand shall not apply to buffer named <buffer>
|
|
||||||
:bwipe xx " here, autocommand shall be auto-deleted
|
|
||||||
:e xx " nothing shall be written
|
|
||||||
:e somefile " nothing shall be written
|
|
||||||
:qa!
|
|
||||||
ENDTEST
|
|
||||||
|
|
||||||
start of test file xx
|
|
||||||
end of test file xx
|
|
@@ -1 +0,0 @@
|
|||||||
buffer-local autommand in xx
|
|
@@ -1,46 +0,0 @@
|
|||||||
Test for BufWritePre autocommand that deletes or unloads the buffer.
|
|
||||||
Test for BufUnload autocommand that unloads all other buffers.
|
|
||||||
|
|
||||||
STARTTEST
|
|
||||||
:so small.vim
|
|
||||||
:au BufWritePre Xxx1 bunload
|
|
||||||
:au BufWritePre Xxx2 bwipe
|
|
||||||
/^start of
|
|
||||||
A1:.,/end of/w! Xxx1 " write test file Xxx1
|
|
||||||
$r2:.,/end of/w! Xxx2 " write test file Xxx2
|
|
||||||
:e! Xxx2 " edit Xxx2
|
|
||||||
:bdel test8.in " delete this file from the buffer list
|
|
||||||
:e Xxx1 " edit Xxx1
|
|
||||||
:w " write it, will unload it and give an error msg
|
|
||||||
:w! test.out " Write contents of this file
|
|
||||||
:e! Xxx2 " start editing Xxx2
|
|
||||||
:bwipe test.out " remove test.out from the buffer list
|
|
||||||
:w " write it, will delete the buffer and give an error msg
|
|
||||||
:w >>test.out " Append contents of this file
|
|
||||||
:au! BufWritePre
|
|
||||||
:func CloseAll()
|
|
||||||
let i = 0
|
|
||||||
while i <= bufnr('$')
|
|
||||||
if i != bufnr('%') && bufloaded(i)
|
|
||||||
exe i . "bunload"
|
|
||||||
endif
|
|
||||||
let i += 1
|
|
||||||
endwhile
|
|
||||||
endfunc
|
|
||||||
:func WriteToOut()
|
|
||||||
edit! test.out
|
|
||||||
$put ='VimLeave done'
|
|
||||||
write
|
|
||||||
endfunc
|
|
||||||
:set viminfo='100,nviminfo
|
|
||||||
:au BufUnload * call CloseAll()
|
|
||||||
:au VimLeave * call WriteToOut()
|
|
||||||
:e small.vim
|
|
||||||
:sp mbyte.vim
|
|
||||||
:q
|
|
||||||
:qa!
|
|
||||||
ENDTEST
|
|
||||||
|
|
||||||
start of Xxx
|
|
||||||
test
|
|
||||||
end of Xxx
|
|
@@ -1,7 +0,0 @@
|
|||||||
start of Xxx2
|
|
||||||
test
|
|
||||||
end of Xxx
|
|
||||||
start of Xxx1
|
|
||||||
test
|
|
||||||
end of Xxx
|
|
||||||
VimLeave done
|
|
@@ -773,6 +773,7 @@ func Test_BufLeave_Wipe()
|
|||||||
|
|
||||||
call delete('Xxx1')
|
call delete('Xxx1')
|
||||||
call delete('Xxx2')
|
call delete('Xxx2')
|
||||||
|
call delete('test.out')
|
||||||
%bwipe
|
%bwipe
|
||||||
au! BufLeave
|
au! BufLeave
|
||||||
|
|
||||||
@@ -809,9 +810,93 @@ func Test_Cmdline()
|
|||||||
au! CmdlineLeave / let g:left = expand('<afile>')
|
au! CmdlineLeave / let g:left = expand('<afile>')
|
||||||
let g:entered = 0
|
let g:entered = 0
|
||||||
let g:left = 0
|
let g:left = 0
|
||||||
call feedkeys("/hello<CR>", 'xt')
|
new
|
||||||
|
call setline(1, 'hello')
|
||||||
|
call feedkeys("/hello\<CR>", 'xt')
|
||||||
call assert_equal('/', g:entered)
|
call assert_equal('/', g:entered)
|
||||||
call assert_equal('/', g:left)
|
call assert_equal('/', g:left)
|
||||||
|
bwipe!
|
||||||
au! CmdlineEnter
|
au! CmdlineEnter
|
||||||
au! CmdlineLeave
|
au! CmdlineLeave
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
" Test for BufWritePre autocommand that deletes or unloads the buffer.
|
||||||
|
func Test_BufWritePre()
|
||||||
|
%bwipe
|
||||||
|
au BufWritePre Xxx1 bunload
|
||||||
|
au BufWritePre Xxx2 bwipe
|
||||||
|
|
||||||
|
call writefile(['start of Xxx1', 'test', 'end of Xxx1'], 'Xxx1')
|
||||||
|
call writefile(['start of Xxx2', 'test', 'end of Xxx2'], 'Xxx2')
|
||||||
|
|
||||||
|
edit Xtest
|
||||||
|
e! Xxx2
|
||||||
|
bdel Xtest
|
||||||
|
e Xxx1
|
||||||
|
" write it, will unload it and give an error msg
|
||||||
|
call assert_fails('w', 'E203')
|
||||||
|
call assert_equal('Xxx2', bufname('%'))
|
||||||
|
edit Xtest
|
||||||
|
e! Xxx2
|
||||||
|
bwipe Xtest
|
||||||
|
" write it, will delete the buffer and give an error msg
|
||||||
|
call assert_fails('w', 'E203')
|
||||||
|
call assert_equal('Xxx1', bufname('%'))
|
||||||
|
au! BufWritePre
|
||||||
|
call delete('Xxx1')
|
||||||
|
call delete('Xxx2')
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
" Test for BufUnload autocommand that unloads all the other buffers
|
||||||
|
func Test_bufunload_all()
|
||||||
|
call writefile(['Test file Xxx1'], 'Xxx1')"
|
||||||
|
call writefile(['Test file Xxx2'], 'Xxx2')"
|
||||||
|
|
||||||
|
let content = [
|
||||||
|
\ "func UnloadAllBufs()",
|
||||||
|
\ " let i = 1",
|
||||||
|
\ " while i <= bufnr('$')",
|
||||||
|
\ " if i != bufnr('%') && bufloaded(i)",
|
||||||
|
\ " exe i . 'bunload'",
|
||||||
|
\ " endif",
|
||||||
|
\ " let i += 1",
|
||||||
|
\ " endwhile",
|
||||||
|
\ "endfunc",
|
||||||
|
\ "au BufUnload * call UnloadAllBufs()",
|
||||||
|
\ "au VimLeave * call writefile(['Test Finished'], 'Xout')",
|
||||||
|
\ "edit Xxx1",
|
||||||
|
\ "split Xxx2",
|
||||||
|
\ "q"]
|
||||||
|
call writefile(content, 'Xtest')
|
||||||
|
|
||||||
|
call delete('Xout')
|
||||||
|
call system(v:progpath. ' --clean -N --not-a-term -S Xtest')
|
||||||
|
call assert_true(filereadable('Xout'))
|
||||||
|
|
||||||
|
call delete('Xxx1')
|
||||||
|
call delete('Xxx2')
|
||||||
|
call delete('Xtest')
|
||||||
|
call delete('Xout')
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
" Some tests for buffer-local autocommands
|
||||||
|
func Test_buflocal_autocmd()
|
||||||
|
let g:bname = ''
|
||||||
|
edit xx
|
||||||
|
au BufLeave <buffer> let g:bname = expand("%")
|
||||||
|
" here, autocommand for xx should trigger.
|
||||||
|
" but autocommand shall not apply to buffer named <buffer>.
|
||||||
|
edit somefile
|
||||||
|
call assert_equal('xx', g:bname)
|
||||||
|
let g:bname = ''
|
||||||
|
" here, autocommand shall be auto-deleted
|
||||||
|
bwipe xx
|
||||||
|
" autocmd should not trigger
|
||||||
|
edit xx
|
||||||
|
call assert_equal('', g:bname)
|
||||||
|
" autocmd should not trigger
|
||||||
|
edit somefile
|
||||||
|
call assert_equal('', g:bname)
|
||||||
|
enew
|
||||||
|
unlet g:bname
|
||||||
|
endfunc
|
||||||
|
@@ -1,23 +0,0 @@
|
|||||||
Tests for setting the '[,'] marks when joining lines.
|
|
||||||
|
|
||||||
STARTTEST
|
|
||||||
:so small.vim
|
|
||||||
:/^\t\t/
|
|
||||||
0gqj:
|
|
||||||
:let a=string(getpos("'[")).'/'.string(getpos("']"))
|
|
||||||
:/^This line/;'}-join
|
|
||||||
:let b=string(getpos("'[")).'/'.string(getpos("']"))
|
|
||||||
:$put ='First test: Start/End '.string(a)
|
|
||||||
:$put ='Second test: Start/End '.string(b)
|
|
||||||
:/^\t\t/,$wq! test.out
|
|
||||||
ENDTEST
|
|
||||||
|
|
||||||
|
|
||||||
O sodales, ludite, vos qui
|
|
||||||
attamen consulite per voster honur. Tua pulchra facies me fay planszer milies
|
|
||||||
|
|
||||||
This line.
|
|
||||||
Should be joined with the next line
|
|
||||||
and with this line
|
|
||||||
|
|
||||||
Results:
|
|
@@ -1,8 +0,0 @@
|
|||||||
O sodales, ludite, vos qui attamen consulite per voster honur.
|
|
||||||
Tua pulchra facies me fay planszer milies
|
|
||||||
|
|
||||||
This line. Should be joined with the next line and with this line
|
|
||||||
|
|
||||||
Results:
|
|
||||||
First test: Start/End '[0, 16, 1, 0]/[0, 17, 1, 0]'
|
|
||||||
Second test: Start/End '[0, 19, 11, 0]/[0, 19, 67, 0]'
|
|
@@ -11,3 +11,25 @@ func Test_join_with_count()
|
|||||||
call assert_equal('one two three four', getline(1))
|
call assert_equal('one two three four', getline(1))
|
||||||
quit!
|
quit!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
" Tests for setting the '[,'] marks when joining lines.
|
||||||
|
func Test_join_marks()
|
||||||
|
enew
|
||||||
|
call append(0, [
|
||||||
|
\ "\t\tO sodales, ludite, vos qui",
|
||||||
|
\ "attamen consulite per voster honur. Tua pulchra " .
|
||||||
|
\ "facies me fay planszer milies",
|
||||||
|
\ "",
|
||||||
|
\ "This line.",
|
||||||
|
\ "Should be joined with the next line",
|
||||||
|
\ "and with this line"])
|
||||||
|
|
||||||
|
normal gg0gqj
|
||||||
|
call assert_equal([0, 1, 1, 0], getpos("'["))
|
||||||
|
call assert_equal([0, 2, 1, 0], getpos("']"))
|
||||||
|
|
||||||
|
/^This line/;'}-join
|
||||||
|
call assert_equal([0, 4, 11, 0], getpos("'["))
|
||||||
|
call assert_equal([0, 4, 67, 0], getpos("']"))
|
||||||
|
enew!
|
||||||
|
endfunc
|
||||||
|
96
src/testdir/test_user_func.vim
Normal file
96
src/testdir/test_user_func.vim
Normal file
@@ -0,0 +1,96 @@
|
|||||||
|
" Test for user functions.
|
||||||
|
" Also test an <expr> mapping calling a function.
|
||||||
|
" Also test that a builtin function cannot be replaced.
|
||||||
|
" Also test for regression when calling arbitrary expression.
|
||||||
|
|
||||||
|
func Table(title, ...)
|
||||||
|
let ret = a:title
|
||||||
|
let idx = 1
|
||||||
|
while idx <= a:0
|
||||||
|
exe "let ret = ret . a:" . idx
|
||||||
|
let idx = idx + 1
|
||||||
|
endwhile
|
||||||
|
return ret
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
func Compute(n1, n2, divname)
|
||||||
|
if a:n2 == 0
|
||||||
|
return "fail"
|
||||||
|
endif
|
||||||
|
exe "let g:" . a:divname . " = ". a:n1 / a:n2
|
||||||
|
return "ok"
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
func Expr1()
|
||||||
|
silent! normal! v
|
||||||
|
return "111"
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
func Expr2()
|
||||||
|
call search('XX', 'b')
|
||||||
|
return "222"
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
func ListItem()
|
||||||
|
let g:counter += 1
|
||||||
|
return g:counter . '. '
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
func ListReset()
|
||||||
|
let g:counter = 0
|
||||||
|
return ''
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
func FuncWithRef(a)
|
||||||
|
unlet g:FuncRef
|
||||||
|
return a:a
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
func Test_user_func()
|
||||||
|
let g:FuncRef=function("FuncWithRef")
|
||||||
|
let g:counter = 0
|
||||||
|
inoremap <expr> ( ListItem()
|
||||||
|
inoremap <expr> [ ListReset()
|
||||||
|
imap <expr> + Expr1()
|
||||||
|
imap <expr> * Expr2()
|
||||||
|
let g:retval = "nop"
|
||||||
|
|
||||||
|
call assert_equal('xxx4asdf', Table("xxx", 4, "asdf"))
|
||||||
|
call assert_equal('fail', Compute(45, 0, "retval"))
|
||||||
|
call assert_equal('nop', g:retval)
|
||||||
|
call assert_equal('ok', Compute(45, 5, "retval"))
|
||||||
|
call assert_equal(9, g:retval)
|
||||||
|
call assert_equal(333, g:FuncRef(333))
|
||||||
|
|
||||||
|
enew
|
||||||
|
|
||||||
|
normal oXX+-XX
|
||||||
|
call assert_equal('XX111-XX', getline('.'))
|
||||||
|
normal o---*---
|
||||||
|
call assert_equal('---222---', getline('.'))
|
||||||
|
normal o(one
|
||||||
|
call assert_equal('1. one', getline('.'))
|
||||||
|
normal o(two
|
||||||
|
call assert_equal('2. two', getline('.'))
|
||||||
|
normal o[(one again
|
||||||
|
call assert_equal('1. one again', getline('.'))
|
||||||
|
|
||||||
|
call assert_equal(3, max([1, 2, 3]))
|
||||||
|
call assert_fails("call extend(g:, {'max': function('min')})", 'E704')
|
||||||
|
call assert_equal(3, max([1, 2, 3]))
|
||||||
|
|
||||||
|
" Regression: the first line below used to throw ?E110: Missing ')'?
|
||||||
|
" Second is here just to prove that this line is correct when not skipping
|
||||||
|
" rhs of &&.
|
||||||
|
call assert_equal(0, (0 && (function('tr'))(1, 2, 3)))
|
||||||
|
call assert_equal(1, (1 && (function('tr'))(1, 2, 3)))
|
||||||
|
|
||||||
|
delfunc Table
|
||||||
|
delfunc Compute
|
||||||
|
delfunc Expr1
|
||||||
|
delfunc Expr2
|
||||||
|
delfunc ListItem
|
||||||
|
delfunc ListReset
|
||||||
|
unlet g:retval g:counter
|
||||||
|
enew!
|
||||||
|
endfunc
|
@@ -761,6 +761,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1209,
|
||||||
/**/
|
/**/
|
||||||
1208,
|
1208,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user