vim-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 vim/vim#6683)

f7c4d83609
This commit is contained in:
zeertzjq
2022-12-03 13:48:51 +08:00
parent aa49212731
commit 8a29d9660e
8 changed files with 533 additions and 1537 deletions

View File

@@ -20,17 +20,11 @@ and for testing plugins.
Vim can be tested after building it, usually with "make test". Vim can be tested after building it, usually with "make test".
The tests are located in the directory "src/testdir". 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-style-testing*
New tests should be added as new style tests. These use functions such as New tests should be added as new style tests. The test scripts are named
|assert_equal()| to keep the test commands and the expected result in one test_<feature>.vim (replace <feature> with the feature under test). These use
place. functions such as |assert_equal()| to keep the test commands and the expected
*old-style-testing* result in one place.
In some cases an old style test needs to be used.
Find more information in the file src/testdir/README.txt. Find more information in the file src/testdir/README.txt.

View File

@@ -0,0 +1 @@
# Tests may depend on the existence of this file.

View File

@@ -13,22 +13,12 @@ export SHELL := sh
export NVIM_PRG := $(NVIM_PRG) export NVIM_PRG := $(NVIM_PRG)
export TMPDIR := $(abspath Xtest-tmpdir) export TMPDIR := $(abspath Xtest-tmpdir)
SCRIPTS_DEFAULT =
ifneq ($(OS),Windows_NT)
SCRIPTS_DEFAULTS := $(SCRIPTS_DEFAULT) \
test49.out \
endif
ifeq ($(OS),Windows_NT) ifeq ($(OS),Windows_NT)
FIXFF = fixff FIXFF = fixff
else else
FIXFF = FIXFF =
endif endif
SCRIPTS ?= $(SCRIPTS_DEFAULT)
# Tests using runtest.vim. # Tests using runtest.vim.
NEW_TESTS_ALOT := test_alot_utf8 test_alot test_alot_latin NEW_TESTS_ALOT := test_alot_utf8 test_alot test_alot_latin
NEW_TESTS_IN_ALOT := $(shell sed -n '/^source/ s/^source //; s/\.vim$$//p' $(addsuffix .vim,$(NEW_TESTS_ALOT))) NEW_TESTS_IN_ALOT := $(shell sed -n '/^source/ s/^source //; s/\.vim$$//p' $(addsuffix .vim,$(NEW_TESTS_ALOT)))
@@ -65,11 +55,7 @@ else
endif endif
endif endif
ifdef TESTNUM nongui: nolog $(FIXFF) newtests report
SCRIPTS := test$(TESTNUM).out
endif
nongui: nolog $(FIXFF) $(SCRIPTS) newtests report
.gdbinit: .gdbinit:
@echo "[OLDTEST-PREP] Setting up .gdbinit" @echo "[OLDTEST-PREP] Setting up .gdbinit"
@@ -87,8 +73,6 @@ report:
test1.out: $(NVIM_PRG) test1.out: $(NVIM_PRG)
$(SCRIPTS): $(NVIM_PRG) test1.out
NO_PLUGINS = --noplugin --headless NO_PLUGINS = --noplugin --headless
# In vim, if the -u command line option is specified, compatible is turned on # In vim, if the -u command line option is specified, compatible is turned on
# and viminfo is not read. Unlike vim, neovim reads viminfo and requires the # and viminfo is not read. Unlike vim, neovim reads viminfo and requires the
@@ -146,17 +130,6 @@ test1.out: .gdbinit test1.in
@rm -f wrongtermsize @rm -f wrongtermsize
@rm -rf X* viminfo @rm -rf X* viminfo
%.out: %.in .gdbinit
@echo "[OLDESTTEST] Running" $*
@rm -rf $*.failed test.ok $(RM_ON_RUN)
@mkdir -p $(TMPDIR)
@cp $*.ok test.ok
@/bin/sh runnvim.sh --oldesttest $(ROOT) $(NVIM_PRG) $* $(RUN_VIM) $*.in
@rm -rf X* test.ok viminfo
# Explicit dependencies.
test49.out: test49.vim
nolog: nolog:
@echo "[OLDTEST-PREP] Removing test.log and messages" @echo "[OLDTEST-PREP] Removing test.log and messages"
@rm -f test.log messages @rm -f test.log messages

View File

@@ -1,31 +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
:se nomore
: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

@@ -5328,6 +5328,29 @@ func Test_lhelpgrep_from_help_window()
new | only! new | only!
endfunc 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
" Test for adding an invalid entry with the quickfix window open and making " Test for adding an invalid entry with the quickfix window open and making
" sure that the window contents are not changed " sure that the window contents are not changed
func Test_add_invalid_entry_with_qf_window() func Test_add_invalid_entry_with_qf_window()

View File

@@ -1,5 +1,6 @@
" Test various aspects of the Vim script language. " 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 check.vim
source shared.vim source shared.vim
@@ -5878,7 +5879,7 @@ func Test_discard_exception_after_error_1()
call RunInNewVim(test, verify) call RunInNewVim(test, verify)
endfunc 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() func Disable_Test_discard_exception_after_error_2()
let test =<< trim [CODE] let test =<< trim [CODE]
try try
@@ -5901,6 +5902,507 @@ func Disable_Test_discard_exception_after_error_2()
call RunInNewVim(test, verify) call RunInNewVim(test, verify)
endfunc 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 " Test 87 using (expr) ? funcref : funcref {{{1
" "