patch 8.2.1420: test 49 is old style

Problem:    Test 49 is old style.
Solution:   Convert remaining parts to new style. Remove obsolete items.
            (Yegappan Lakshmanan, closes #6683)
This commit is contained in:
Bram Moolenaar
2020-08-11 20:42:19 +02:00
parent 59eccb92e3
commit f7c4d83609
17 changed files with 561 additions and 1682 deletions

View File

@ -158,7 +158,9 @@ SRC_ALL = \
src/testdir/gen_opt_test.vim \
src/testdir/README.txt \
src/testdir/Make_all.mak \
src/testdir/*.in \
src/testdir/dotest.in \
src/testdir/test1.in \
src/testdir/test77a.in \
src/testdir/*.py \
src/testdir/lsan-suppress.txt \
src/testdir/sautest/autoload/*.vim \
@ -177,9 +179,8 @@ SRC_ALL = \
src/testdir/summarize.vim \
src/testdir/term_util.vim \
src/testdir/view_util.vim \
src/testdir/test[0-9]*.ok \
src/testdir/test[0-9]*a.ok \
src/testdir/test49.vim \
- src/testdir/test1.ok \
src/testdir/test77a.ok \
src/testdir/test83-tags? \
src/testdir/test77a.com \
src/testdir/test_*.vim \

View File

@ -20,18 +20,11 @@ and for testing plugins.
Vim can be tested after building it, usually with "make test".
The tests are located in the directory "src/testdir".
There are several types of tests added over time:
test33.in oldest, don't add any of these
test_something.in old style tests
test_something.vim new style tests
*new-style-testing*
New tests should be added as new style tests. These use functions such as
|assert_equal()| to keep the test commands and the expected result in one
place.
*old-style-testing*
In some cases an old style test needs to be used. E.g. when testing Vim
without the |+eval| feature.
New tests should be added as new style tests. The test scripts are named
test_<feature>.vim (replace <feature> with the feature under test). These use
functions such as |assert_equal()| to keep the test commands and the expected
result in one place.
Find more information in the file src/testdir/README.txt.

View File

@ -1326,14 +1326,6 @@ MAIN_TARGET = $(VIM).exe
# Target to run individual tests.
VIMTESTTARGET = $(VIM).exe
OLD_TEST_OUTFILES = \
$(SCRIPTS_FIRST) \
$(SCRIPTS_ALL) \
$(SCRIPTS_MORE1) \
$(SCRIPTS_MORE4) \
$(SCRIPTS_WIN32) \
$(SCRIPTS_GUI)
all: $(MAIN_TARGET) \
vimrun.exe \
install.exe \
@ -1485,9 +1477,9 @@ testclean:
$(MAKE) /NOLOGO -f Make_dos.mak clean
cd ..
# Run individual OLD style test.
# Run test1 to bootstrap tests
# These do not depend on the executable, compile it when needed.
$(OLD_TEST_OUTFILES:.out=):
$(SCRIPTS_FIRST:.out=):
cd testdir
- if exist $@.out del $@.out
$(MAKE) /NOLOGO -f Make_dos.mak VIMPROG=..\$(VIMTESTTARGET) nolog

View File

@ -2259,8 +2259,6 @@ test check: unittests $(TERM_TEST) scripttests
#
# This will produce a lot of garbage on your screen, including a few error
# messages. Don't worry about that.
# If there is a real error, there will be a difference between "testXX.out" and
# a "testXX.ok" file.
# If everything is alright, the final message will be "ALL DONE". If not you
# get "TEST FAILURE".
#
@ -2311,9 +2309,9 @@ test_libvterm:
CC="$(CC)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)"; \
fi
# Run individual OLD style test.
# These do not depend on the executable, compile it when needed.
test1 test49:
# Run test1, used to bootstrap tests.
# This does not depend on the executable, compile first it when needed.
test1:
cd testdir; rm -f $@.out; $(MAKE) -f Makefile $@.out VIMPROG=../$(VIMTESTTARGET) $(GUI_TESTARG) SCRIPTSOURCE=../$(SCRIPTSOURCE)
# Run individual NEW style test.

View File

@ -10,24 +10,6 @@ NO_INITS = -U NONE $(NO_PLUGINS)
# The first script creates small.vim.
SCRIPTS_FIRST = test1.out
# Tests that run on all systems.
SCRIPTS_ALL =
# Tests that run on most systems, but not on Amiga.
SCRIPTS_MORE1 =
# Tests that run on most systems, but not on Amiga and DOS/Windows.
SCRIPTS_MORE2 = test49.out
# Tests that run on most systems, but not on VMS
SCRIPTS_MORE4 =
# Tests specifically for MS-Windows.
SCRIPTS_WIN32 =
# Tests for the GUI.
SCRIPTS_GUI =
# Tests for Vim9 script.
TEST_VIM9 = \
test_vim9_cmd \

View File

@ -9,14 +9,9 @@ default: nongui
include Make_all.mak
SCRIPTS = $(SCRIPTS_ALL) $(SCRIPTS_MORE4)
.SUFFIXES: .in .out .res .vim
# Must run test1 first to create small.vim.
$(SCRIPTS) $(SCRIPTS_GUI) $(NEW_TESTS_RES): $(SCRIPTS_FIRST)
.SUFFIXES: .in .out
nongui: /tmp $(SCRIPTS_FIRST) $(SCRIPTS)
nongui: /tmp $(SCRIPTS_FIRST)
csh -c echo ALL DONE
clean:

View File

@ -9,25 +9,20 @@ default: nongui
!include Make_all.mak
# Omitted:
# test49 fails in various ways
SCRIPTS = $(SCRIPTS_ALL) $(SCRIPTS_MORE1) $(SCRIPTS_MORE4)
TEST_OUTFILES = $(SCRIPTS_FIRST) $(SCRIPTS) $(SCRIPTS_WIN32) $(SCRIPTS_GUI)
TEST_OUTFILES = $(SCRIPTS_FIRST)
DOSTMP = dostmp
DOSTMP_OUTFILES = $(TEST_OUTFILES:test=dostmp\test)
DOSTMP_INFILES = $(DOSTMP_OUTFILES:.out=.in)
.SUFFIXES: .in .out .res .vim
nongui: nolog $(SCRIPTS_FIRST) $(SCRIPTS) newtests report
nongui: nolog $(SCRIPTS_FIRST) newtests report
small: nolog report
gui: nolog $(SCRIPTS_FIRST) $(SCRIPTS) $(SCRIPTS_GUI) newtests report
gui: nolog $(SCRIPTS_FIRST) newtests report
win32: nolog $(SCRIPTS_FIRST) $(SCRIPTS) $(SCRIPTS_WIN32) newtests report
win32: nolog $(SCRIPTS_FIRST) newtests report
# Copy the input files to dostmp, changing the fileformat to dos.
$(DOSTMP_INFILES): $(*B).in

View File

@ -28,19 +28,17 @@ default: vimall
include Make_all.mak
SCRIPTS = $(SCRIPTS_ALL) $(SCRIPTS_MORE1) $(SCRIPTS_MORE4) $(SCRIPTS_WIN32)
SCRIPTS_BENCH = test_bench_regexp.res
# Must run test1 first to create small.vim.
$(SCRIPTS) $(SCRIPTS_GUI) $(SCRIPTS_WIN32) $(NEW_TESTS_RES): $(SCRIPTS_FIRST)
$(NEW_TESTS_RES): $(SCRIPTS_FIRST)
.SUFFIXES: .in .out .res .vim
vimall: fixff $(SCRIPTS_FIRST) $(SCRIPTS) $(SCRIPTS_GUI) $(SCRIPTS_WIN32) newtests
vimall: fixff $(SCRIPTS_FIRST) newtests
@echo ALL DONE
nongui: fixff nolog $(SCRIPTS_FIRST) $(SCRIPTS) newtests
nongui: fixff nolog $(SCRIPTS_FIRST) newtests
@echo ALL DONE
benchmark: $(SCRIPTS_BENCH)
@ -48,10 +46,10 @@ benchmark: $(SCRIPTS_BENCH)
small: nolog
@echo ALL DONE
gui: fixff nolog $(SCRIPTS_FIRST) $(SCRIPTS) $(SCRIPTS_GUI) newtests
gui: fixff nolog $(SCRIPTS_FIRST) newtests
@echo ALL DONE
win32: fixff nolog $(SCRIPTS_FIRST) $(SCRIPTS) $(SCRIPTS_WIN32) newtests
win32: fixff nolog $(SCRIPTS_FIRST) newtests
@echo ALL DONE
# TODO: find a way to avoid changing the distributed files.
@ -88,19 +86,6 @@ test1.out: test1.in
-@if exist test.out $(DEL) test.out
-@if exist viminfo $(DEL) viminfo
.in.out:
-@if exist $*.ok $(CP) $*.ok test.ok
$(VIMPROG) -u dos.vim $(NO_INITS) -s dotest.in $*.in
@diff test.out $*.ok
-@if exist $*.out $(DEL) $*.out
@$(MV) test.out $*.out
-@if exist Xdir1 $(DELDIR) Xdir1
-@if exist Xfind $(DELDIR) Xfind
-@if exist XfakeHOME $(DELDIR) XfakeHOME
-@if exist X* $(DEL) X*
-@if exist test.ok $(DEL) test.ok
-@if exist viminfo $(DEL) viminfo
nolog:
-@if exist test.log $(DEL) test.log
-@if exist messages $(DEL) messages

View File

@ -27,26 +27,6 @@
# Uncomment if you want tests in GUI mode. Terminal mode is default.
# WANT_GUI = YES
# Comment out if you want to run Unix specific tests as well, but please
# be aware, that on OpenVMS will fail, because of cat, rm, etc commands
# and directory handling.
# WANT_UNIX = YES
# Comment out if you have gzip on your system
# HAVE_GZIP = YES
# Comment out if you have GNU compatible diff on your system
# HAVE_GDIFF = YES
# Comment out if you have ICONV support
# HAVE_ICONV = YES
# Comment out if you have LUA support
# HAVE_LUA = YES
# Comment out if you have PYTHON support
# HAVE_PYTHON = YES
#######################################################################
# End of configuration section.
#
@ -57,16 +37,12 @@ VIMPROG = <->vim.exe
.SUFFIXES : .out .in
SCRIPT = test1.out test49.out test77a.out
SCRIPT = test1.out test77a.out
.IFDEF WANT_GUI
GUI_OPTION = -g
.ENDIF
.IFDEF WANT_UNIX
SCRIPT_UNIX = test49.out
.ENDIF
.in.out :
-@ !clean up before doing the test
-@ if "''F$SEARCH("test.out.*")'" .NES. "" then delete/noconfirm/nolog test.out.*
@ -87,7 +63,7 @@ SCRIPT_UNIX = test49.out
-@ if "''F$SEARCH("Xdotest.*")'" .NES. "" then delete/noconfirm/nolog Xdotest.*.*
-@ if "''F$SEARCH("Xtest.*")'" .NES. "" then delete/noconfirm/nolog Xtest.*.*
all : clean nolog $(START_WITH) $(SCRIPT) $(SCRIPT_UNIX) nolog
all : clean nolog $(START_WITH) $(SCRIPT) nolog
-@ write sys$output " "
-@ write sys$output "-----------------------------------------------"
-@ write sys$output " All done"
@ -111,12 +87,6 @@ nolog :
-@ write sys$output "-----------------------------------------------"
-@ write sys$output "MAKE_VMS.MMS options:"
-@ write sys$output " WANT_GUI = ""$(WANT_GUI)"" "
-@ write sys$output " WANT_UNIX = ""$(WANT_UNIX)"" "
-@ write sys$output " HAVE_GZIP = ""$(HAVE_GZIP)"" "
-@ write sys$output " HAVE_GDIFF = ""$(HAVE_GDIFF)"" "
-@ write sys$output " HAVE_ICONV = ""$(HAVE_ICONV)"" "
-@ write sys$output " HAVE_LUA = ""$(HAVE_LUA)"" "
-@ write sys$output " HAVE_PYTHON= ""$(HAVE_PYTHON)"" "
-@ write sys$output "Default vimrc file is VMS.VIM:"
-@ write sys$output "-----------------------------------------------"
-@ type VMS.VIM

View File

@ -23,28 +23,19 @@ REDIR_TEST_TO_NULL = --cmd 'au SwapExists * let v:swapchoice = "e"' > /dev/null
default: nongui
# The list of tests is common to all systems.
# This defines NEW_TESTS, NEW_TESTS_RES, SCRIPTS_ALL, SCRIPTS_MORE* and
# SCRIPTS_GUI.
# This defines SCRIPTS_FIRST, NEW_TESTS and NEW_TESTS_RES
include Make_all.mak
SCRIPTS = $(SCRIPTS_ALL) \
$(SCRIPTS_MORE1) \
$(SCRIPTS_MORE2) \
$(SCRIPTS_MORE4)
# Explicit dependencies.
test49.out: test49.vim
test_options.res test_alot.res: opt_test.vim
SCRIPTS_BENCH = test_bench_regexp.res
.SUFFIXES: .in .out .res .vim
nongui: nolog $(SCRIPTS_FIRST) $(SCRIPTS) newtests report
nongui: nolog $(SCRIPTS_FIRST) newtests report
gui: nolog $(SCRIPTS_FIRST) $(SCRIPTS) $(SCRIPTS_GUI) newtests report
gui: nolog $(SCRIPTS_FIRST) newtests report
benchmark: $(SCRIPTS_BENCH)
@ -63,10 +54,10 @@ report:
else echo ALL DONE; \
fi"
$(SCRIPTS_FIRST) $(SCRIPTS) $(SCRIPTS_GUI) $(NEW_TESTS_RES): $(VIMPROG)
$(SCRIPTS_FIRST) $(NEW_TESTS_RES): $(VIMPROG)
# Must run test1 first to create small.vim.
$(SCRIPTS) $(SCRIPTS_GUI) $(NEW_TESTS_RES): $(SCRIPTS_FIRST)
$(NEW_TESTS_RES): $(SCRIPTS_FIRST)
# Execute an individual new style test, e.g.:
@ -116,37 +107,6 @@ test1.out: test1.in
echo; exit 1; fi"
-rm -rf X* viminfo
.in.out:
-rm -rf $*.failed test.ok $(RM_ON_RUN)
cp $*.ok test.ok
# Sleep a moment to avoid that the xterm title is messed up.
# 200 msec is sufficient, but only modern sleep supports a fraction of
# a second, fall back to a second if it fails.
@-/bin/sh -c "sleep .2 > /dev/null 2>&1 || sleep 1"
$(RUN_VIM) $*.in $(REDIR_TEST_TO_NULL)
# For flaky tests retry one time. No tests at the moment.
#@/bin/sh -c "if test -f test.out -a $* = test61; then \
# if diff test.out $*.ok; \
# then echo flaky test ok first time; \
# else rm -rf $*.failed $(RM_ON_RUN); \
# $(RUN_VIM) $*.in; \
# fi \
# fi"
# Check if the test.out file matches test.ok.
@/bin/sh -c "if test -f test.out; then \
if diff test.out $*.ok; \
then mv -f test.out $*.out; \
else echo $* FAILED >>test.log; mv -f test.out $*.failed; \
fi \
else echo $* NO OUTPUT >>test.log; \
fi"
@/bin/sh -c "if test -f valgrind; then\
mv -f valgrind valgrind.$*; \
fi"
-rm -rf X* test.ok viminfo
nolog:
-rm -f test.log messages

View File

@ -4,14 +4,6 @@ For testing an indent script see runtime/indent/testdir/README.txt.
If it makes sense, add a new test method to an already existing file. You may
want to separate it from other tests with comment lines.
The numbered tests are older, we have switched to named tests. Don't add any
more numbered tests.
And then you can choose between a new style test, which is a Vim script, or an
old style test, which uses Normal mode commands. Use a new style test if you
can. Use an old style test when it needs to run without the +eval feature.
TO ADD A NEW STYLE TEST:
1) Create a test_<subject>.vim file.
@ -57,16 +49,3 @@ TO ADD A SCREEN DUMP TEST:
Mostly the same as writing a new style test. Additionally, see help on
"terminal-dumptest". Put the reference dump in "dumps/Test_func_name.dump".
TO ADD AN OLD STYLE TEST:
1) Create test_<subject>.in and test_<subject>.ok files.
2) Add test_<subject>.out to SCRIPTS_ALL in Make_all.mak in alphabetical order.
3) Use make test_<subject>.out to run a single test in src/testdir/.
Use make test_<subject> to run a single test in src/.
4) Also add an entry in src/Makefile.
Keep in mind that the files are used as if everything was typed:
- To add comments use: :" (that's an Ex command comment)
- A line break is like pressing Enter. If that happens on the last line
you'll hear a beep!

View File

@ -1,32 +0,0 @@
This is a test of the script language.
If after adding a new test, the test output doesn't appear properly in
test49.failed, try to add one or more "G"s at the line ending in "test.out"
STARTTEST
:so small.vim
:se nocp nomore viminfo+=nviminfo
:lang mess C
:so test49.vim
:" Go back to this file and append the results from register r.
:buf test49.in
G"rp:/^Results/,$w! test.out
:"
:" make valgrind happy
:redir => funclist
:silent func
:redir END
:for line in split(funclist, "\n")
: let name = matchstr(line, 'function \zs[A-Z]\w*\ze(')
: if name != ''
: exe "delfunc " . name
: endif
:endfor
:for v in keys(g:)
: silent! exe "unlet " . v
:endfor
:unlet v
:qa!
ENDTEST
Results of test49.vim:

View File

@ -1,12 +0,0 @@
Results of test49.vim:
*** Test 82: OK (8454401)
*** Test 83: OK (2835)
*** Test 84: OK (934782101)
*** Test 85: OK (198689)
--- Test 86: No Crash for vimgrep on BufUnload
*** Test 86: OK (0)
--- Test 88: All tests were run with throwing exceptions on error.
The $VIMNOERRTHROW control is not configured.
--- Test 88: All tests were run with throwing exceptions on interrupt.
The $VIMNOINTTHROW control is not configured.
*** Test 88: OK (50443995)

File diff suppressed because it is too large Load Diff

View File

@ -5040,4 +5040,27 @@ func Test_lhelpgrep_from_help_window()
new | only!
endfunc
" Test for the crash fixed by 7.3.715
func Test_setloclist_crash()
%bw!
let g:BufNum = bufnr()
augroup QF_Test
au!
au BufUnload * call setloclist(0, [{'bufnr':g:BufNum, 'lnum':1, 'col':1, 'text': 'tango down'}])
augroup END
try
lvimgrep /.*/ *.mak
catch /E926:/
endtry
call assert_equal('tango down', getloclist(0, {'items' : 0}).items[0].text)
call assert_equal(1, getloclist(0, {'size' : 0}).size)
augroup QF_Test
au!
augroup END
unlet g:BufNum
%bw!
endfunc
" vim: shiftwidth=2 sts=2 expandtab

View File

@ -1,5 +1,6 @@
" Test various aspects of the Vim script language.
" Most of this was formerly in test49.
" Most of this was formerly in test49.vim (developed by Servatius Brandt
" <Servatius.Brandt@fujitsu-siemens.com>)
source check.vim
source shared.vim
@ -5868,7 +5869,7 @@ func Test_discard_exception_after_error_1()
call RunInNewVim(test, verify)
endfunc
" TODO: Not able inject an interrupt after throwing an exception
" TODO: Need to interrupt the code before the endtry is invoked
func Disable_Test_discard_exception_after_error_2()
let test =<< trim [CODE]
try
@ -5891,6 +5892,507 @@ func Disable_Test_discard_exception_after_error_2()
call RunInNewVim(test, verify)
endfunc
"-------------------------------------------------------------------------------
" Test 82: Ignoring :catch clauses after an error or interrupt {{{1
"
" When an exception is thrown and an error or interrupt occurs before
" the matching :catch clause is reached, the exception is discarded
" and the :catch clause is ignored (also for the error or interrupt
" exception being thrown then).
"-------------------------------------------------------------------------------
func Test_ignore_catch_after_error_1()
let test =<< trim [CODE]
try
try
Xpath 'a'
throw "arrgh"
call assert_report('should not get here')
if 1
call assert_report('should not get here')
" error after :throw: missing :endif
catch /.*/
call assert_report('should not get here')
catch /.*/
call assert_report('should not get here')
endtry
call assert_report('should not get here')
catch /arrgh/
call assert_report('should not get here')
endtry
call assert_report('should not get here')
[CODE]
let verify =<< trim [CODE]
call assert_equal('a', g:Xpath)
[CODE]
call RunInNewVim(test, verify)
endfunc
func Test_ignore_catch_after_error_2()
let test =<< trim [CODE]
func E()
try
try
Xpath 'a'
throw "arrgh"
call assert_report('should not get here')
if 1
call assert_report('should not get here')
" error after :throw: missing :endif
catch /.*/
call assert_report('should not get here')
catch /.*/
call assert_report('should not get here')
endtry
call assert_report('should not get here')
catch /arrgh/
call assert_report('should not get here')
endtry
endfunc
call E()
call assert_report('should not get here')
[CODE]
let verify =<< trim [CODE]
call assert_equal('a', g:Xpath)
[CODE]
call RunInNewVim(test, verify)
endfunc
" TODO: Need to interrupt the code right before the catch is invoked
func FIXME_Test_ignore_catch_after_intr_1()
let test =<< trim [CODE]
try
try
Xpath 'a'
throw "arrgh"
call assert_report('should not get here')
catch /.*/ " TODO: Need to interrupt before this catch is
call interrupt() " invoked
call assert_report('should not get here')
catch /.*/
call assert_report('should not get here')
endtry
call assert_report('should not get here')
catch /arrgh/
call assert_report('should not get here')
endtry
call assert_report('should not get here')
[CODE]
let verify =<< trim [CODE]
call assert_equal('a', g:Xpath)
[CODE]
call RunInNewVim(test, verify)
endfunc
" TODO: Need to interrupt the code right before the catch is invoked
func FIXME_Test_ignore_catch_after_intr_2()
let test =<< trim [CODE]
func I()
try
try
Xpath 'a'
throw "arrgh"
call assert_report('should not get here')
catch /.*/ " TODO: Need to interrupt before this catch is
" invoked
call interrupt()
call assert_report('should not get here')
catch /.*/
call assert_report('should not get here')
endtry
call assert_report('should not get here')
catch /arrgh/
call assert_report('should not get here')
endtry
endfunc
call I()
call assert_report('should not get here')
[CODE]
let verify =<< trim [CODE]
call assert_equal('a', g:Xpath)
[CODE]
call RunInNewVim(test, verify)
endfunc
"-------------------------------------------------------------------------------
" Test 83: Executing :finally clauses after an error or interrupt {{{1
"
" When an exception is thrown and an error or interrupt occurs before
" the :finally of the innermost :try is reached, the exception is
" discarded and the :finally clause is executed.
"-------------------------------------------------------------------------------
func Test_finally_after_error()
let test =<< trim [CODE]
try
Xpath 'a'
try
Xpath 'b'
throw "arrgh"
call assert_report('should not get here')
if 1
call assert_report('should not get here')
" error after :throw: missing :endif
finally
Xpath 'c'
endtry
call assert_report('should not get here')
catch /arrgh/
call assert_report('should not get here')
endtry
call assert_report('should not get here')
[CODE]
let verify =<< trim [CODE]
call assert_equal('abc', g:Xpath)
[CODE]
call RunInNewVim(test, verify)
endfunc
" TODO: Need to interrupt the code right before the finally is invoked
func FIXME_Test_finally_after_intr()
let test =<< trim [CODE]
try
Xpath 'a'
try
Xpath 'b'
throw "arrgh"
call assert_report('should not get here')
finally " TODO: Need to interrupt before the finally is invoked
Xpath 'c'
endtry
call assert_report('should not get here')
catch /arrgh/
call assert_report('should not get here')
endtry
call assert_report('should not get here')
[CODE]
let verify =<< trim [CODE]
call assert_equal('abc', g:Xpath)
[CODE]
call RunInNewVim(test, verify)
endfunc
"-------------------------------------------------------------------------------
" Test 84: Exceptions in autocommand sequences. {{{1
"
" When an exception occurs in a sequence of autocommands for
" a specific event, the rest of the sequence is not executed. The
" command that triggered the autocommand execution aborts, and the
" exception is propagated to the caller.
"
" For the FuncUndefined event under a function call expression or
" :call command, the function is not executed, even when it has
" been defined by the autocommands before the exception occurred.
"-------------------------------------------------------------------------------
func Test_autocmd_exception()
let test =<< trim [CODE]
func INT()
call interrupt()
endfunc
aug TMP
autocmd!
autocmd User x1 Xpath 'a'
autocmd User x1 throw "x1"
autocmd User x1 call assert_report('should not get here')
autocmd User x2 Xpath 'b'
autocmd User x2 asdf
autocmd User x2 call assert_report('should not get here')
autocmd User x3 Xpath 'c'
autocmd User x3 call INT()
autocmd User x3 call assert_report('should not get here')
autocmd FuncUndefined U1 func U1()
autocmd FuncUndefined U1 call assert_report('should not get here')
autocmd FuncUndefined U1 endfunc
autocmd FuncUndefined U1 Xpath 'd'
autocmd FuncUndefined U1 throw "U1"
autocmd FuncUndefined U1 call assert_report('should not get here')
autocmd FuncUndefined U2 func U2()
autocmd FuncUndefined U2 call assert_report('should not get here')
autocmd FuncUndefined U2 endfunc
autocmd FuncUndefined U2 Xpath 'e'
autocmd FuncUndefined U2 ASDF
autocmd FuncUndefined U2 call assert_report('should not get here')
autocmd FuncUndefined U3 func U3()
autocmd FuncUndefined U3 call assert_report('should not get here')
autocmd FuncUndefined U3 endfunc
autocmd FuncUndefined U3 Xpath 'f'
autocmd FuncUndefined U3 call INT()
autocmd FuncUndefined U3 call assert_report('should not get here')
aug END
try
try
Xpath 'g'
doautocmd User x1
catch /x1/
Xpath 'h'
endtry
while 1
try
Xpath 'i'
doautocmd User x2
catch /asdf/
Xpath 'j'
finally
Xpath 'k'
break
endtry
endwhile
while 1
try
Xpath 'l'
doautocmd User x3
catch /Vim:Interrupt/
Xpath 'm'
finally
Xpath 'n'
" ... but break loop for caught interrupt exception,
" or discard interrupt and break loop if $VIMNOINTTHROW
break
endtry
endwhile
if exists("*U1") | delfunction U1 | endif
if exists("*U2") | delfunction U2 | endif
if exists("*U3") | delfunction U3 | endif
try
Xpath 'o'
call U1()
catch /U1/
Xpath 'p'
endtry
while 1
try
Xpath 'q'
call U2()
catch /ASDF/
Xpath 'r'
finally
Xpath 's'
" ... but break loop for caught error exception,
" or discard error and break loop if $VIMNOERRTHROW
break
endtry
endwhile
while 1
try
Xpath 't'
call U3()
catch /Vim:Interrupt/
Xpath 'u'
finally
Xpath 'v'
" ... but break loop for caught interrupt exception,
" or discard interrupt and break loop if $VIMNOINTTHROW
break
endtry
endwhile
catch /.*/
call assert_report('should not get here')
endtry
Xpath 'w'
[CODE]
let verify =<< trim [CODE]
call assert_equal('gahibjklcmnodpqerstfuvw', g:Xpath)
[CODE]
call RunInNewVim(test, verify)
endfunc
"-------------------------------------------------------------------------------
" Test 85: Error exceptions in autocommands for I/O command events {{{1
"
" When an I/O command is inside :try/:endtry, autocommands to be
" executed after it should be skipped on an error (exception) in the
" command itself or in autocommands to be executed before the command.
" In the latter case, the I/O command should not be executed either.
" Example 1: BufWritePre, :write, BufWritePost
" Example 2: FileReadPre, :read, FileReadPost.
"-------------------------------------------------------------------------------
func Test_autocmd_error_io_exception()
let test =<< trim [CODE]
" Remove the autocommands for the events specified as arguments in all used
" autogroups.
func Delete_autocommands(...)
let augfile = tempname()
while 1
try
exec "redir >" . augfile
aug
redir END
exec "edit" augfile
g/^$/d
norm G$
let wrap = "w"
while search('\%( \|^\)\@<=.\{-}\%( \)\@=', wrap) > 0
let wrap = "W"
exec "norm y/ \n"
let argno = 1
while argno <= a:0
exec "au!" escape(@", " ") a:{argno}
let argno = argno + 1
endwhile
endwhile
catch /.*/
finally
bwipeout!
call delete(augfile)
break
endtry
endwhile
endfunc
call Delete_autocommands("BufWritePre", "BufWritePost")
while 1
try
try
let post = 0
aug TMP
au! BufWritePost * let post = 1
aug END
write /n/o/n/e/x/i/s/t/e/n/t
catch /^Vim(write):/
Xpath 'a'
call assert_match("E212: Can't open file for writing", v:exception)
finally
Xpath 'b'
call assert_equal(0, post)
au! TMP
aug! TMP
endtry
catch /.*/
call assert_report('should not get here')
finally
Xpath 'c'
break
endtry
endwhile
while 1
try
try
let post = 0
aug TMP
au! BufWritePre * asdf
au! BufWritePost * let post = 1
aug END
let tmpfile = tempname()
exec "write" tmpfile
catch /^Vim\((write)\)\=:/
Xpath 'd'
call assert_match('E492: Not an editor command', v:exception)
finally
Xpath 'e'
if filereadable(tmpfile)
call assert_report('should not get here')
endif
call assert_equal(0, post)
au! TMP
aug! TMP
endtry
catch /.*/
call assert_report('should not get here')
finally
Xpath 'f'
break
endtry
endwhile
call delete(tmpfile)
call Delete_autocommands("BufWritePre", "BufWritePost",
\ "BufReadPre", "BufReadPost", "FileReadPre", "FileReadPost")
while 1
try
try
let post = 0
aug TMP
au! FileReadPost * let post = 1
aug END
let caught = 0
read /n/o/n/e/x/i/s/t/e/n/t
catch /^Vim(read):/
Xpath 'g'
call assert_match("E484: Can't open file", v:exception)
finally
Xpath 'h'
call assert_equal(0, post)
au! TMP
aug! TMP
endtry
catch /.*/
call assert_report('should not get here')
finally
Xpath 'i'
break
endtry
endwhile
while 1
try
let infile = tempname()
let tmpfile = tempname()
call writefile(["XYZ"], infile)
exec "edit" tmpfile
try
Xpath 'j'
try
let post = 0
aug TMP
au! FileReadPre * asdf
au! FileReadPost * let post = 1
aug END
exec "0read" infile
catch /^Vim\((read)\)\=:/
Xpath 'k'
call assert_match('E492: Not an editor command', v:exception)
finally
Xpath 'l'
if getline("1") == "XYZ"
call assert_report('should not get here')
endif
call assert_equal(0, post)
au! TMP
aug! TMP
endtry
finally
Xpath 'm'
bwipeout!
endtry
catch /.*/
call assert_report('should not get here')
finally
Xpath 'n'
break
endtry
endwhile
call delete(infile)
call delete(tmpfile)
[CODE]
let verify =<< trim [CODE]
call assert_equal('abcdefghijklmn', g:Xpath)
[CODE]
call RunInNewVim(test, verify)
endfunc
"-------------------------------------------------------------------------------
" Test 87 using (expr) ? funcref : funcref {{{1
"

View File

@ -754,6 +754,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
1420,
/**/
1419,
/**/