" Vim script language tests
" Author: Servatius Brandt <Servatius.Brandt@fujitsu-siemens.com>
" Last Change: 2020 Jun 07
"-------------------------------------------------------------------------------
" Test environment {{{1
"-------------------------------------------------------------------------------
" Adding new tests easily. {{{2
"
" Writing new tests is eased considerably with the following functions and
" abbreviations (see "Commands for recording the execution path", "Automatic
" argument generation").
"
" To get the abbreviations, execute the command
"
" :let test49_set_env = 1 | source test49.vim
"
" To get them always (from src/testdir), put a line
"
" au! BufRead test49.vim let test49_set_env = 1 | source test49.vim
"
" into the local .vimrc file in the src/testdir directory.
"
if exists("test49_set_env") && test49_set_env
" Automatic argument generation for the test environment commands.
function! Xsum()
let addend = substitute(getline("."), '^.*"\s*X:\s*\|^.*', '', "")
" Evaluate arithmetic expression.
if addend != ""
exec "let g:Xsum = g:Xsum + " . addend
endif
endfunction
function! Xcheck()
let g:Xsum=0
?XpathINIT?,.call Xsum()
exec "norm A "
return g:Xsum
endfunction
iab Xcheck Xcheck<Space><C-R>=Xcheck()<CR><C-O>x
function! Xcomment(num)
let str = ""
let tabwidth = &sts ? &sts : &ts
let tabs = (48+tabwidth - a:num - virtcol(".")) / tabwidth
while tabs > 0
let str = str . "\t"
let tabs = tabs - 1
endwhile
let str = str . '" X:'
return str
endfunction
function! Xloop()
let back = line(".") . "|norm" . virtcol(".") . "|"
norm 0
let last = search('X\(loop\|path\)INIT\|Xloop\>', "bW")
exec back
let theline = getline(last)
if theline =~ 'X\(loop\|path\)INIT'
let num = 1
else
let num = 2 * substitute(theline, '.*Xloop\s*\(\d\+\).*', '\1', "")
endif
?X\(loop\|