1" Utility functions for testing vim9 script 2 3" Check that "lines" inside ":def" has no error. 4func CheckDefSuccess(lines) 5 call writefile(['def Func()'] + a:lines + ['enddef', 'defcompile'], 'Xdef') 6 so Xdef 7 call Func() 8 call delete('Xdef') 9endfunc 10 11" Check that "lines" inside ":def" results in an "error" message. 12" If "lnum" is given check that the error is reported for this line. 13" Add a line before and after to make it less likely that the line number is 14" accidentally correct. 15func CheckDefFailure(lines, error, lnum = -3) 16 call writefile(['def Func()', '# comment'] + a:lines + ['#comment', 'enddef', 'defcompile'], 'Xdef') 17 call assert_fails('so Xdef', a:error, a:lines, a:lnum + 1) 18 call delete('Xdef') 19endfunc 20 21" Check that "lines" inside ":def" results in an "error" message when executed. 22" If "lnum" is given check that the error is reported for this line. 23" Add a line before and after to make it less likely that the line number is 24" accidentally correct. 25func CheckDefExecFailure(lines, error, lnum = -3) 26 call writefile(['def Func()', '# comment'] + a:lines + ['#comment', 'enddef'], 'Xdef') 27 so Xdef 28 call assert_fails('call Func()', a:error, a:lines, a:lnum + 1) 29 call delete('Xdef') 30endfunc 31 32def CheckScriptFailure(lines: list<string>, error: string, lnum = -3) 33 writefile(lines, 'Xdef') 34 assert_fails('so Xdef', error, lines, lnum) 35 delete('Xdef') 36enddef 37 38def CheckScriptSuccess(lines: list<string>) 39 writefile(lines, 'Xdef') 40 so Xdef 41 delete('Xdef') 42enddef 43