" Tests for the Vim script debug commands
source shared.vim
source screendump.vim
source check.vim
func CheckCWD()
" Check that the longer lines don't wrap due to the length of the script name
" in cwd. Need to subtract by 1 since Vim will still wrap the message if it
" just fits.
let script_len = len( getcwd() .. '/Xtest1.vim' )
let longest_line = len( 'Breakpoint in "" line 1' )
if script_len > ( 75 - longest_line - 1 )
throw 'Skipped: Your CWD has too many characters'
endif
endfunc
command! -nargs=0 -bar CheckCWD call CheckCWD()
" "options" argument can contain:
" 'msec' - time to wait for a match
" 'match' - "pattern" to use "lines" as pattern instead of text
func CheckDbgOutput(buf, lines, options = {})
" Verify the expected output
let lnum = 20 - len(a:lines)
let msec = get(a:options, 'msec', 1000)
for l in a:lines
if get(a:options, 'match', 'equal') ==# 'pattern'
call WaitForAssert({-> assert_match(l, term_getline(a:buf, lnum))}, msec)
else
call WaitForAssert({-> assert_equal(l, term_getline(a:buf, lnum))}, msec)
endif
let lnum += 1
endfor
endfunc
" Run a Vim debugger command
" If the expected output argument is supplied, then check for it.
func s:RunDbgCmd(buf, cmd, ...)
call term_sendkeys(a:buf, a:cmd . "\r")
call TermWait(a:buf)
if a:0 != 0
let options = #{match: 'equal'
|