Patch 8.2.2092
Problem: Vim9: unpredictable errors for script tests.
Solution: Use a different script file name for each run.
Files: src/testdir/vim9.vim, src/testdir/test_vim9_script.vim,
src/testdir/test_vim9_func.vim, src/testdir/test_quickfix.vim,
src/testdir/test_vim9_assign.vim
*** ../vim-8.2.2091/src/testdir/vim9.vim 2020-10-04 16:06:00.513884339 +0200
--- src/testdir/vim9.vim 2020-12-05 12:58:12.580924027 +0100
***************
*** 1,11 ****
" Utility functions for testing vim9 script
! " Check that "lines" inside ":def" has no error.
func CheckDefSuccess(lines)
! call writefile(['def Func()'] + a:lines + ['enddef', 'defcompile'], 'Xdef')
! so Xdef
call Func()
! call delete('Xdef')
endfunc
" Check that "lines" inside ":def" results in an "error" message.
--- 1,17 ----
" Utility functions for testing vim9 script
! " Use a different file name for each run.
! let s:sequence = 1
!
! " Check that "lines" inside a ":def" function has no error.
func CheckDefSuccess(lines)
! let fname = 'Xdef' .. s:sequence
! let s:sequence += 1
! call writefile(['def Func()'] + a:lines + ['enddef', 'defcompile'], fname)
! exe 'so ' .. fname
call Func()
! delfunc! Func
! call delete(fname)
endfunc
" Check that "lines" inside ":def" results in an "error" message.
***************
*** 13,21 ****
" Add a line before and after to make it less likely that the line number is
" accidentally correct.
func CheckDefFailure(lines, error, lnum = -3)
! call writefile(['def Func()', '# comment'] + a:lines + ['#comment', 'enddef', 'defcompile'], 'Xdef')
! call assert_fails('so Xdef', a:error, a:lines, a:lnum + 1)
! call delete('Xdef')
endfunc
" Check that "lines" inside ":def" results in an "error" message when executed.
--- 19,30 ----
" Add a line before and after to make it less likely that the line number is
" accidentally correct.
func CheckDefFailure(lines, error, lnum = -3)
! let fname = 'Xdef' .. s:sequence
! call writefile(['def Func()', '# comment'] + a:lines + ['#comment', 'enddef', 'defcompile'], fname)
! call assert_fails('so ' .. fname, a:error, a:lines, a:lnum + 1)
! delfunc! Func
! call delete(fname)
! let s:sequence += 1
endfunc
" Check that "lines" inside ":def" results in an "error" message when executed.
***************
*** 23,44 ****
" Add a line before and after to make it less likely that the line number is
" accidentally correct.
func CheckDefExecFailure(lines, error, lnum = -3)
! call writefile(['def Func()', '# comment'] + a:lines + ['#comment', 'enddef'], 'Xdef')
! so Xdef
call assert_fails('call Func()', a:error, a:lines, a:lnum + 1)
! call delete('Xdef')
endfunc
def CheckScriptFailure(lines: list<string>, error: string, lnum = -3)
! writefile(lines, 'Xdef')
! assert_fails('so Xdef', error, lines, lnum)
! delete('Xdef')
enddef
def CheckScriptSuccess(lines: list<string>)
! writefile(lines, 'Xdef')
! so Xdef
! delete('Xdef')
enddef
def CheckDefAndScriptSuccess(lines: list<string>)
--- 32,60 ----
" Add a line before and after to make it less likely that the line number is
" accidentally correct.
func CheckDefExecFailure(lines, error, lnum = -3)
! let fname = 'Xdef' .. s:sequence
! let s:sequence += 1
! call writefile(['def Func()', '# comment'] + a:lines + ['#comment', 'enddef'], fname)
! exe 'so ' .. fname
call assert_fails('call Func()', a:error, a:lines, a:lnum + 1)
! delfunc! Func
! call delete(fname)
endfunc
def CheckScriptFailure(lines: list<string>, error: string, lnum = -3)
! var fname = 'Xdef' .. s:sequence
! s:sequence += 1
! writefile(lines, fname)
! assert_fails('so ' .. fname, error, lines, lnum)
! delete(fname)
enddef
def CheckScriptSuccess(lines: list<string>)
! var fname = 'Xdef' .. s:sequence
! s:sequence += 1
! writefile(lines, fname)
! exe 'so ' .. fname
! delete(fname)
enddef
def CheckDefAndScriptSuccess(lines: list<string>)
***************
*** 46,60 ****
CheckScriptSuccess(['vim9script'] + lines)
enddef
! " Check that a command fails both when used in a :def function and when used
! " in Vim9 script.
def CheckDefAndScriptFailure(lines: list<string>, error: string, lnum = -3)
CheckDefFailure(lines, error, lnum)
CheckScriptFailure(['vim9script'] + lines, error, lnum + 1)
enddef
! " Check that a command fails both when executed in a :def function and when
! " used in Vim9 script.
def CheckDefExecAndScriptFailure(lines: list<string>, error: string, lnum = -3)
CheckDefExecFailure(lines, error, lnum)
CheckScriptFailure(['vim9script'] + lines, error, lnum + 1)
--- 62,76 ----
CheckScriptSuccess(['vim9script'] + lines)
enddef
! " Check that a command fails with the same error when used in a :def function
! " and when used in Vim9 script.
def CheckDefAndScriptFailure(lines: list<string>, error: string, lnum = -3)
CheckDefFailure(lines, error, lnum)
CheckScriptFailure(['vim9script'] + lines, error, lnum + 1)
enddef
! " Check that a command fails with the same error when executed in a :def
! " function and when used in Vim9 script.
def CheckDefExecAndScriptFailure(lines: list<string>, error: string, lnum = -3)
CheckDefExecFailure(lines, error, lnum)
CheckScriptFailure(['vim9script'] + lines, error, lnum + 1)
*** ../vim-8.2.2091/src/testdir/test_vim9_script.vim 2020-12-04 17:37:56.250324484 +0100
--- src/testdir/test_vim9_script.vim 2020-12-05 13:35:31.772448525 +0100
***************
*** 1878,1883 ****
--- 1878,1884 ----
CheckDefFailure(['for i In range(5)'], 'E690:')
CheckDefFailure(['var x = 5', 'for x in range(5)'], 'E1017:')
CheckScriptFailure(['def Func(arg: any)', 'for arg in range(5)', 'enddef', 'defcompile'], 'E1006:')
+ delfunc! g:Func
CheckDefFailure(['for i in "text"'], 'E1012:')
CheckDefFailure(['for i in xxx'], 'E1001:')
CheckDefFailure(['endfor'], 'E588:')
***************
*** 2360,2371 ****
--- 2361,2374 ----
'vim9script',
'command Echo echo # comment',
'command Echo # comment',
+ 'delcommand Echo',
])
CheckScriptFailure([
'vim9script',
'command Echo echo# comment',
'Echo',
], 'E121:')
+ delcommand Echo
CheckScriptFailure([
'vim9script',
'command Echo# comment',
***************
*** 2375,2380 ****
--- 2378,2384 ----
'command Echo echo',
'command Echo# comment',
], 'E182:')
+ delcommand Echo
CheckScriptSuccess([
'vim9script',
***************
*** 2432,2437 ****
--- 2436,2442 ----
CheckScriptSuccess([
'func Test() " comment',
'endfunc',
+ 'delfunc Test',
])
CheckScriptSuccess([
'vim9script',
*** ../vim-8.2.2091/src/testdir/test_vim9_func.vim 2020-12-02 20:51:17.944731846 +0100
--- src/testdir/test_vim9_func.vim 2020-12-05 13:31:11.721588666 +0100
***************
*** 199,205 ****
--- 199,207 ----
MyDefaultSecond('test', false)->assert_equal('none')
CheckScriptFailure(['def Func(arg: number = asdf)', 'enddef', 'defcompile'], 'E1001:')
+ delfunc g:Func
CheckScriptFailure(['def Func(arg: number = "text")', 'enddef', 'defcompile'], 'E1013: Argument 1: type mismatch, expected number but got string')
+ delfunc g:Func
enddef
def Test_nested_function()
***************
*** 326,331 ****
--- 328,334 ----
enddef
g:Func()->assert_equal('global')
Func()->assert_equal('local')
+ delfunc g:Func
END
CheckScriptSuccess(lines)
***************
*** 605,610 ****
--- 608,614 ----
l[0]->assert_equal('value')
CheckScriptFailure(['def Func(arg: number)', 'arg = 3', 'enddef', 'defcompile'], 'E1090:')
+ delfunc! g:Func
enddef
" These argument names are reserved in legacy functions.
***************
*** 763,795 ****
--- 767,807 ----
'return "a"',
'enddef',
'defcompile'], 'expected number but got string')
+ delfunc! g:Func
CheckScriptFailure([
'def Func(): string',
'return 1',
'enddef',
'defcompile'], 'expected string but got number')
+ delfunc! g:Func
CheckScriptFailure([
'def Func(): void',
'return "a"',
'enddef',
'defcompile'],
'E1096: Returning a value in a function without a return type')
+ delfunc! g:Func
CheckScriptFailure([
'def Func()',
'return "a"',
'enddef',
'defcompile'],
'E1096: Returning a value in a function without a return type')
+ delfunc! g:Func
CheckScriptFailure([
'def Func(): number',
'return',
'enddef',
'defcompile'], 'E1003:')
+ delfunc! g:Func
CheckScriptFailure(['def Func(): list', 'return []', 'enddef'], 'E1008:')
+ delfunc! g:Func
CheckScriptFailure(['def Func(): dict', 'return {}', 'enddef'], 'E1008:')
+ delfunc! g:Func
CheckScriptFailure(['def Func()', 'return 1'], 'E1057:')
+ delfunc! g:Func
CheckScriptFailure([
'vim9script',
***************
*** 1248,1253 ****
--- 1260,1266 ----
v:exception->assert_match('Invalid command: invalid')
v:throwpoint->assert_match(', line 3$')
endtry
+ delfunc! g:Func
# comment lines after the start of the function
lines =<< trim END
***************
*** 1268,1273 ****
--- 1281,1287 ----
v:exception->assert_match('Invalid command: invalid')
v:throwpoint->assert_match(', line 4$')
endtry
+ delfunc! g:Func
lines =<< trim END
vim9script
***************
*** 1286,1291 ****
--- 1300,1306 ----
catch /E716:/
v:throwpoint->assert_match('_Func, line 3$')
endtry
+ delfunc! g:Func
delete('Xdef')
enddef
***************
*** 1766,1771 ****
--- 1781,1787 ----
Func()
END
CheckScriptFailure(lines, 'E492:', 8)
+ delfunc! g:Func
enddef
def Test_abort_even_with_silent()
*** ../vim-8.2.2091/src/testdir/test_quickfix.vim 2020-11-29 14:20:23.677476671 +0100
--- src/testdir/test_quickfix.vim 2020-11-30 17:29:26.070185231 +0100
***************
*** 5253,5259 ****
call delete('XquickfixFails')
endfunc
! " Test for updating the quickfix buffer whenever the assocaited quickfix list
" is changed.
func Xqfbuf_update(cchar)
call s:setup_commands(a:cchar)
--- 5253,5259 ----
call delete('XquickfixFails')
endfunc
! " Test for updating the quickfix buffer whenever the associated quickfix list
" is changed.
func Xqfbuf_update(cchar)
call s:setup_commands(a:cchar)
*** ../vim-8.2.2091/src/testdir/test_vim9_assign.vim 2020-12-02 17:36:49.173409740 +0100
--- src/testdir/test_vim9_assign.vim 2020-12-05 12:59:49.252605780 +0100
***************
*** 953,958 ****
--- 953,959 ----
call Func()
[END]
CheckScriptFailure(lines, 'E990:')
+ delfunc! g:Func
enddef
def Test_let_func_call()
*** ../vim-8.2.2091/src/version.c 2020-12-04 19:42:48.431278293 +0100
--- src/version.c 2020-12-04 21:00:10.881057634 +0100
***************
*** 752,753 ****
--- 752,755 ----
{ /* Add new patch number below this line */
+ /**/
+ 2092,
/**/
--
An indication you must be a manager:
You can explain to somebody the difference between "re-engineering",
"down-sizing", "right-sizing", and "firing people's asses".
/// Bram Moolenaar -- Br...@Moolenaar.net --
http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features --
http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language --
http://www.Zimbu.org ///
\\\ help me help AIDS victims --
http://ICCF-Holland.org ///