summaryrefslogtreecommitdiffstats
path: root/src/testdir/test_autocmd.vim
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2019-05-20 22:12:34 +0200
committerBram Moolenaar <Bram@vim.org>2019-05-20 22:12:34 +0200
commitc79745a82faeb5a6058e915ca49a4c69fa60ea01 (patch)
treebe7dc4ecffe429763159bfef2f95c06ea7fb8b67 /src/testdir/test_autocmd.vim
parent0b0ad35c339b8ad156df493bebeb77e02b32b120 (diff)
patch 8.1.1362: code and data in tests can be hard to readv8.1.1362
Problem: Code and data in tests can be hard to read. Solution: Use the new heredoc style. (Yegappan Lakshmanan, closes #4400)
Diffstat (limited to 'src/testdir/test_autocmd.vim')
-rw-r--r--src/testdir/test_autocmd.vim102
1 files changed, 54 insertions, 48 deletions
diff --git a/src/testdir/test_autocmd.vim b/src/testdir/test_autocmd.vim
index b22718aee6..0a4177cd77 100644
--- a/src/testdir/test_autocmd.vim
+++ b/src/testdir/test_autocmd.vim
@@ -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'))
@@ -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'))
@@ -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')