Mercurial > vim
diff src/testdir/test_autocmd.vim @ 16720:9c90cf08cfa8 v8.1.1362
patch 8.1.1362: code and data in tests can be hard to read
commit https://github.com/vim/vim/commit/c79745a82faeb5a6058e915ca49a4c69fa60ea01
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon May 20 22:12:34 2019 +0200
patch 8.1.1362: code and data in tests can be hard to read
Problem: Code and data in tests can be hard to read.
Solution: Use the new heredoc style. (Yegappan Lakshmanan, closes https://github.com/vim/vim/issues/4400)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 20 May 2019 22:15:06 +0200 |
parents | ea0f9a2df961 |
children | 620e9011b685 |
line wrap: on
line diff
--- a/src/testdir/test_autocmd.vim +++ b/src/testdir/test_autocmd.vim @@ -423,18 +423,20 @@ func Test_autocmd_bufwipe_in_SessLoadPos 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')) @@ -452,27 +454,29 @@ func Test_autocmd_bufwipe_in_SessLoadPos 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')) @@ -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')