Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update the tests to use the new heredoc syntax #4400

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
102 changes: 54 additions & 48 deletions src/testdir/test_autocmd.vim
Expand Up @@ -423,18 +423,20 @@ func Test_autocmd_bufwipe_in_SessLoadPost()
set noswapfile
mksession!

let content = ['set nocp noswapfile',
\ 'let v:swapchoice="e"',
\ 'augroup test_autocmd_sessionload',
\ 'autocmd!',
\ 'autocmd SessionLoadPost * exe bufnr("Xsomething") . "bw!"',
\ 'augroup END',
\ '',
\ 'func WriteErrors()',
\ ' call writefile([execute("messages")], "Xerrors")',
\ 'endfunc',
\ 'au VimLeave * call WriteErrors()',
\ ]
let content =<< trim [CODE]
set nocp noswapfile
let v:swapchoice="e"
augroup test_autocmd_sessionload
autocmd!
autocmd SessionLoadPost * exe bufnr("Xsomething") . "bw!"
augroup END

func WriteErrors()
call writefile([execute("messages")], "Xerrors")
endfunc
au VimLeave * call WriteErrors()
[CODE]

call writefile(content, 'Xvimrc')
call system(v:progpath. ' -u Xvimrc --not-a-term --noplugins -S Session.vim -c cq')
let errors = join(readfile('Xerrors'))
Expand All @@ -452,27 +454,29 @@ func Test_autocmd_bufwipe_in_SessLoadPost2()
set noswapfile
mksession!

let content = ['set nocp noswapfile',
\ 'function! DeleteInactiveBufs()',
\ ' tabfirst',
\ ' let tabblist = []',
\ ' for i in range(1, tabpagenr(''$''))',
\ ' call extend(tabblist, tabpagebuflist(i))',
\ ' endfor',
\ ' for b in range(1, bufnr(''$''))',
\ ' if bufexists(b) && buflisted(b) && (index(tabblist, b) == -1 || bufname(b) =~# ''^$'')',
\ ' exec ''bwipeout '' . b',
\ ' endif',
\ ' endfor',
\ ' echomsg "SessionLoadPost DONE"',
\ 'endfunction',
\ 'au SessionLoadPost * call DeleteInactiveBufs()',
\ '',
\ 'func WriteErrors()',
\ ' call writefile([execute("messages")], "Xerrors")',
\ 'endfunc',
\ 'au VimLeave * call WriteErrors()',
\ ]
let content =<< trim [CODE]
set nocp noswapfile
function! DeleteInactiveBufs()
tabfirst
let tabblist = []
for i in range(1, tabpagenr(''$''))
call extend(tabblist, tabpagebuflist(i))
endfor
for b in range(1, bufnr(''$''))
if bufexists(b) && buflisted(b) && (index(tabblist, b) == -1 || bufname(b) =~# ''^$'')
exec ''bwipeout '' . b
endif
endfor
echomsg "SessionLoadPost DONE"
endfunction
au SessionLoadPost * call DeleteInactiveBufs()

func WriteErrors()
call writefile([execute("messages")], "Xerrors")
endfunc
au VimLeave * call WriteErrors()
[CODE]

call writefile(content, 'Xvimrc')
call system(v:progpath. ' -u Xvimrc --not-a-term --noplugins -S Session.vim -c cq')
let errors = join(readfile('Xerrors'))
Expand Down Expand Up @@ -933,21 +937,23 @@ func Test_bufunload_all()
call writefile(['Test file Xxx1'], 'Xxx1')"
call writefile(['Test file Xxx2'], 'Xxx2')"

let content = [
\ "func UnloadAllBufs()",
\ " let i = 1",
\ " while i <= bufnr('$')",
\ " if i != bufnr('%') && bufloaded(i)",
\ " exe i . 'bunload'",
\ " endif",
\ " let i += 1",
\ " endwhile",
\ "endfunc",
\ "au BufUnload * call UnloadAllBufs()",
\ "au VimLeave * call writefile(['Test Finished'], 'Xout')",
\ "edit Xxx1",
\ "split Xxx2",
\ "q"]
let content =<< trim [CODE]
func UnloadAllBufs()
let i = 1
while i <= bufnr('$')
if i != bufnr('%') && bufloaded(i)
exe i . 'bunload'
endif
let i += 1
endwhile
endfunc
au BufUnload * call UnloadAllBufs()
au VimLeave * call writefile(['Test Finished'], 'Xout')
edit Xxx1
split Xxx2
q
[CODE]

call writefile(content, 'Xtest')

call delete('Xout')
Expand Down
16 changes: 8 additions & 8 deletions src/testdir/test_balloon.vim
Expand Up @@ -8,14 +8,14 @@ if !CanRunVimInTerminal()
finish
endif

let s:common_script = [
\ 'call setline(1, ["one one one", "two tXo two", "three three three"])',
\ 'set balloonevalterm balloonexpr=MyBalloonExpr() balloondelay=100',
\ 'func MyBalloonExpr()',
\ ' return "line " .. v:beval_lnum .. " column " .. v:beval_col .. ": " .. v:beval_text',
\ 'endfun',
\ 'redraw',
\ ]
let s:common_script =<< [CODE]
call setline(1, ["one one one", "two tXo two", "three three three"])
set balloonevalterm balloonexpr=MyBalloonExpr() balloondelay=100
func MyBalloonExpr()
return "line " .. v:beval_lnum .. " column " .. v:beval_col .. ": " .. v:beval_text
endfun
redraw
[CODE]

func Test_balloon_eval_term()
" Use <Ignore> after <MouseMove> to return from vgetc() without removing
Expand Down
35 changes: 18 additions & 17 deletions src/testdir/test_bufline.vim
Expand Up @@ -93,23 +93,24 @@ func Test_appendbufline()
endfunc

func Test_appendbufline_no_E315()
let after = [
\ 'set stl=%f ls=2',
\ 'new',
\ 'let buf = bufnr("%")',
\ 'quit',
\ 'vsp',
\ 'exec "buffer" buf',
\ 'wincmd w',
\ 'call appendbufline(buf, 0, "abc")',
\ 'redraw',
\ 'while getbufline(buf, 1)[0] =~ "^\\s*$"',
\ ' sleep 10m',
\ 'endwhile',
\ 'au VimLeavePre * call writefile([v:errmsg], "Xerror")',
\ 'au VimLeavePre * call writefile(["done"], "Xdone")',
\ 'qall!',
\ ]
let after =<< trim [CODE]
set stl=%f ls=2
new
let buf = bufnr("%")
quit
vsp
exec "buffer" buf
wincmd w
call appendbufline(buf, 0, "abc")
redraw
while getbufline(buf, 1)[0] =~ "^\\s*$"
sleep 10m
endwhile
au VimLeavePre * call writefile([v:errmsg], "Xerror")
au VimLeavePre * call writefile(["done"], "Xdone")
qall!
[CODE]

if !RunVim([], after, '--clean')
return
endif
Expand Down
60 changes: 38 additions & 22 deletions src/testdir/test_cindent.vim
Expand Up @@ -18,25 +18,25 @@ endfunc
func Test_cino_extern_c()
" Test for cino-E

let without_ind = [
\ '#ifdef __cplusplus',
\ 'extern "C" {',
\ '#endif',
\ 'int func_a(void);',
\ '#ifdef __cplusplus',
\ '}',
\ '#endif'
\ ]
let without_ind =<< trim [CODE]
#ifdef __cplusplus
extern "C" {
#endif
int func_a(void);
#ifdef __cplusplus
}
#endif
[CODE]

let with_ind = [
\ '#ifdef __cplusplus',
\ 'extern "C" {',
\ '#endif',
\ "\tint func_a(void);",
\ '#ifdef __cplusplus',
\ '}',
\ '#endif'
\ ]
let with_ind =<< trim [CODE]
#ifdef __cplusplus
extern "C" {
#endif
int func_a(void);
#ifdef __cplusplus
}
#endif
[CODE]
new
setlocal cindent cinoptions=E0
call setline(1, without_ind)
Expand Down Expand Up @@ -89,16 +89,32 @@ func Test_cindent_expr()
return v:lnum == 1 ? shiftwidth() : 0
endfunc
setl expandtab sw=8 indentkeys+=; indentexpr=MyIndentFunction()
call setline(1, ['var_a = something()', 'b = something()'])
let testinput =<< trim [CODE]
var_a = something()
b = something()
[CODE]
call setline(1, testinput)
call cursor(1, 1)
call feedkeys("^\<c-v>j$A;\<esc>", 'tnix')
call assert_equal([' var_a = something();', 'b = something();'], getline(1, '$'))
let expected =<< trim [CODE]
var_a = something();
b = something();
[CODE]
call assert_equal(expected, getline(1, '$'))

%d
call setline(1, [' var_a = something()', ' b = something()'])
let testinput =<< trim [CODE]
var_a = something()
b = something()
[CODE]
call setline(1, testinput)
call cursor(1, 1)
call feedkeys("^\<c-v>j$A;\<esc>", 'tnix')
call assert_equal([' var_a = something();', ' b = something()'], getline(1, '$'))
let expected =<< trim [CODE]
var_a = something();
b = something()
[CODE]
call assert_equal(expected, getline(1, '$'))
bw!
endfunc

Expand Down
50 changes: 27 additions & 23 deletions src/testdir/test_conceal.vim
Expand Up @@ -11,21 +11,23 @@ if !CanRunVimInTerminal()
endif

func Test_conceal_two_windows()
call writefile([
\ 'let lines = ["one one one one one", "two |hidden| here", "three |hidden| three"]',
\ 'call setline(1, lines)',
\ 'syntax match test /|hidden|/ conceal',
\ 'set conceallevel=2',
\ 'set concealcursor=',
\ 'exe "normal /here\r"',
\ 'new',
\ 'call setline(1, lines)',
\ 'call setline(4, "Second window")',
\ 'syntax match test /|hidden|/ conceal',
\ 'set conceallevel=2',
\ 'set concealcursor=nc',
\ 'exe "normal /here\r"',
\ ], 'XTest_conceal')
let code =<< trim [CODE]
let lines = ["one one one one one", "two |hidden| here", "three |hidden| three"]
call setline(1, lines)
syntax match test /|hidden|/ conceal
set conceallevel=2
set concealcursor=
exe "normal /here\r"
new
call setline(1, lines)
call setline(4, "Second window")
syntax match test /|hidden|/ conceal
set conceallevel=2
set concealcursor=nc
exe "normal /here\r"
[CODE]

call writefile(code, 'XTest_conceal')
" Check that cursor line is concealed
let buf = RunVimInTerminal('-S XTest_conceal', {})
call VerifyScreenDump(buf, 'Test_conceal_two_windows_01', {})
Expand Down Expand Up @@ -113,14 +115,16 @@ endfunc
func Test_conceal_with_cursorline()
" Opens a help window, where 'conceal' is set, switches to the other window
" where 'cursorline' needs to be updated when the cursor moves.
call writefile([
\ 'set cursorline',
\ 'normal othis is a test',
\ 'new',
\ 'call setline(1, ["one", "two", "three", "four", "five"])',
\ 'set ft=help',
\ 'normal M',
\ ], 'XTest_conceal_cul')
let code =<< trim [CODE]
set cursorline
normal othis is a test
new
call setline(1, ["one", "two", "three", "four", "five"])
set ft=help
normal M
[CODE]

call writefile(code, 'XTest_conceal_cul')
let buf = RunVimInTerminal('-S XTest_conceal_cul', {})
call VerifyScreenDump(buf, 'Test_conceal_cul_01', {})

Expand Down