2020-04-25 20:02:55 +02:00
|
|
|
" Utility functions for testing vim9 script
|
|
|
|
|
2020-08-10 21:57:54 +02:00
|
|
|
" 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
|
|
|
|
|
2020-04-25 20:02:55 +02:00
|
|
|
" Check that "lines" inside ":def" results in an "error" message.
|
2020-08-18 13:41:50 +02:00
|
|
|
" If "lnum" is given check that the error is reported for this line.
|
2020-08-18 20:34:13 +02:00
|
|
|
" 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)
|
2020-04-25 20:02:55 +02:00
|
|
|
call delete('Xdef')
|
|
|
|
endfunc
|
|
|
|
|
2020-05-05 21:25:22 +02:00
|
|
|
" Check that "lines" inside ":def" results in an "error" message when executed.
|
2020-08-18 13:41:50 +02:00
|
|
|
" If "lnum" is given check that the error is reported for this line.
|
2020-08-18 20:34:13 +02:00
|
|
|
" 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')
|
2020-05-05 21:25:22 +02:00
|
|
|
so Xdef
|
2020-08-18 20:34:13 +02:00
|
|
|
call assert_fails('call Func()', a:error, a:lines, a:lnum + 1)
|
2020-05-05 21:25:22 +02:00
|
|
|
call delete('Xdef')
|
|
|
|
endfunc
|
|
|
|
|
2020-08-18 20:34:13 +02:00
|
|
|
def CheckScriptFailure(lines: list<string>, error: string, lnum = -3)
|
2020-04-25 20:02:55 +02:00
|
|
|
writefile(lines, 'Xdef')
|
2020-08-18 20:34:13 +02:00
|
|
|
assert_fails('so Xdef', error, lines, lnum)
|
2020-04-25 20:02:55 +02:00
|
|
|
delete('Xdef')
|
|
|
|
enddef
|
|
|
|
|
|
|
|
def CheckScriptSuccess(lines: list<string>)
|
|
|
|
writefile(lines, 'Xdef')
|
|
|
|
so Xdef
|
|
|
|
delete('Xdef')
|
|
|
|
enddef
|