" Test for the CursorHold autocmd
func Test_CursorHold_autocmd()
CheckRunVimInTerminal
- call writefile(['one', 'two', 'three'], 'XoneTwoThree')
+ call writefile(['one', 'two', 'three'], 'XoneTwoThree', 'D')
let before =<< trim END
set updatetime=10
au CursorHold * call writefile([line('.')], 'XCHoutput', 'a')
END
- call writefile(before, 'XCHinit')
+ call writefile(before, 'XCHinit', 'D')
let buf = RunVimInTerminal('-S XCHinit XoneTwoThree', {})
call term_sendkeys(buf, "G")
call term_wait(buf, 50)
call WaitForAssert({-> assert_equal(['1', '2', '3'], readfile('XCHoutput')[-3:-1])})
call StopVimInTerminal(buf)
- call delete('XCHinit')
call delete('XCHoutput')
- call delete('XoneTwoThree')
endfunc
if has('timers')
augroup set_tabstop
au OptionSet tabstop call timer_start(1, {-> execute("echo 'Handler called'", "")})
augroup END
- call writefile(['vim: set ts=7 sw=5 :', 'something'], 'XoptionsetModeline')
+ call writefile(['vim: set ts=7 sw=5 :', 'something'], 'XoptionsetModeline', 'D')
set modeline
let v:errmsg = ''
call assert_fails('split XoptionsetModeline', 'E12:')
augroup END
bwipe!
set ts&
- call delete('XoptionsetModeline')
call test_override('starting', 0)
endfunc
func Test_autocmd_dummy_wipeout()
" prepare files
- call writefile([''], 'Xdummywipetest1.txt')
- call writefile([''], 'Xdummywipetest2.txt')
+ call writefile([''], 'Xdummywipetest1.txt', 'D')
+ call writefile([''], 'Xdummywipetest2.txt', 'D')
augroup test_bufunload_group
autocmd!
autocmd BufUnload * call add(s:li, "bufunload")
call assert_equal(["bufunload", "bufwipeout"], s:li)
bwipeout
- call delete('Xdummywipetest1.txt')
- call delete('Xdummywipetest2.txt')
au! test_bufunload_group
augroup! test_bufunload_group
endfunc
au WinScrolled * let g:amatch = str2nr(expand('<amatch>'))
au WinScrolled * let g:afile = str2nr(expand('<afile>'))
END
- call writefile(lines, 'Xtest_winscrolled')
+ call writefile(lines, 'Xtest_winscrolled', 'D')
let buf = RunVimInTerminal('-S Xtest_winscrolled', {'rows': 6})
call term_sendkeys(buf, ":echo g:scrolled\<CR>")
call WaitForAssert({-> assert_match('^v:true ', term_getline(buf, 6))}, 1000)
call StopVimInTerminal(buf)
- call delete('Xtest_winscrolled')
endfunc
func Test_WinScrolled_mouse()
let g:scrolled = 0
au WinScrolled * let g:scrolled += 1
END
- call writefile(lines, 'Xtest_winscrolled_mouse')
+ call writefile(lines, 'Xtest_winscrolled_mouse', 'D')
let buf = RunVimInTerminal('-S Xtest_winscrolled_mouse', {'rows': 10})
" With the upper split focused, send a scroll-down event to the unfocused one.
call WaitForAssert({-> assert_match('^2', term_getline(buf, 10))}, 1000)
call StopVimInTerminal(buf)
- call delete('Xtest_winscrolled_mouse')
endfunc
func Test_WinScrolled_close_curwin()
au WinScrolled * close
au VimLeave * call writefile(['123456'], 'Xtestout')
END
- call writefile(lines, 'Xtest_winscrolled_close_curwin')
+ call writefile(lines, 'Xtest_winscrolled_close_curwin', 'D')
let buf = RunVimInTerminal('-S Xtest_winscrolled_close_curwin', {'rows': 6})
" This was using freed memory
call assert_equal(['123456'], readfile('Xtestout'))
- call delete('Xtest_winscrolled_close_curwin')
call delete('Xtestout')
endfunc
call setline(1, repeat('foo', height * width))
call cursor(1, height * width)
END
- call writefile(lines, 'Xtest_winscrolled_long_wrapped')
+ call writefile(lines, 'Xtest_winscrolled_long_wrapped', 'D')
let buf = RunVimInTerminal('-S Xtest_winscrolled_long_wrapped', {'rows': 6})
call term_sendkeys(buf, ":echo g:scrolled\<CR>")
call term_sendkeys(buf, '$')
call term_sendkeys(buf, ":echo g:scrolled\<CR>")
call WaitForAssert({-> assert_match('^3 ', term_getline(buf, 6))}, 1000)
-
- call delete('Xtest_winscrolled_long_wrapped')
endfunc
func Test_WinClosed()
au VimLeave * call WriteErrors()
[CODE]
- call writefile(content, 'Xvimrc')
+ call writefile(content, 'Xvimrc', 'D')
call system(GetVimCommand('Xvimrc') .. ' --not-a-term --noplugins -S Session.vim -c cq')
let errors = join(readfile('Xerrors'))
call assert_match('E814:', errors)
set swapfile
- for file in ['Session.vim', 'Xvimrc', 'Xerrors']
+ for file in ['Session.vim', 'Xerrors']
call delete(file)
endfor
endfunc
qall
[CODE]
- call writefile(content, 'XblastBall')
+ call writefile(content, 'XblastBall', 'D')
call system(GetVimCommand() .. ' --clean -S XblastBall')
call assert_match('OK', readfile('Xerrors')->join())
- call delete('XblastBall')
call delete('Xerrors')
endfunc
au VimLeave * call WriteErrors()
[CODE]
- call writefile(content, 'Xvimrc')
+ call writefile(content, 'Xvimrc', 'D')
call system(GetVimCommand('Xvimrc') .. ' --not-a-term --noplugins -S Session.vim -c cq')
let errors = join(readfile('Xerrors'))
" This probably only ever matches on unix.
call assert_match('SessionLoadPost DONE', errors)
set swapfile
- for file in ['Session.vim', 'Xvimrc', 'Xerrors']
+ for file in ['Session.vim', 'Xerrors']
call delete(file)
endfor
endfunc
func Test_Acmd_BufAll()
enew!
%bwipe!
- call writefile(['Test file Xxx1'], 'Xxx1')
- call writefile(['Test file Xxx2'], 'Xxx2')
- call writefile(['Test file Xxx3'], 'Xxx3')
+ call writefile(['Test file Xxx1'], 'Xxx1', 'D')
+ call writefile(['Test file Xxx2'], 'Xxx2', 'D')
+ call writefile(['Test file Xxx3'], 'Xxx3', 'D')
" Add three files to the buffer list
split Xxx1
au! BufReadPost
%bwipe!
- call delete('Xxx1')
- call delete('Xxx2')
- call delete('Xxx3')
enew! | only
endfunc
%bwipe!
call writefile(['start of test file Xxx1',
\ "\<Tab>this is a test",
- \ 'end of test file Xxx1'], 'Xxx1')
+ \ 'end of test file Xxx1'], 'Xxx1', 'D')
call writefile(['start of test file Xxx2',
\ 'vim: set noai :',
\ "\<Tab>this is a test",
- \ 'end of test file Xxx2'], 'Xxx2')
+ \ 'end of test file Xxx2'], 'Xxx2', 'D')
au BufEnter Xxx2 brew
set ai modeline modelines=3
call assert_equal(4, line('.'))
%bwipe!
- call delete('Xxx1')
- call delete('Xxx2')
set ai&vim modeline&vim modelines&vim
endfunc
let content = ['start of test file Xxx',
\ 'this is a test',
\ 'end of test file Xxx']
- call writefile(content, 'Xxx1')
- call writefile(content, 'Xxx2')
+ call writefile(content, 'Xxx1', 'D')
+ call writefile(content, 'Xxx2', 'D')
au BufLeave Xxx2 bwipe
edit Xxx1
let g:bufinfo = getbufinfo()
call assert_equal(1, len(g:bufinfo))
- call delete('Xxx1')
- call delete('Xxx2')
call delete('test.out')
%bwipe
au! BufLeave
au BufWritePre Xxx1 bunload
au BufWritePre Xxx2 bwipe
- call writefile(['start of Xxx1', 'test', 'end of Xxx1'], 'Xxx1')
- call writefile(['start of Xxx2', 'test', 'end of Xxx2'], 'Xxx2')
+ call writefile(['start of Xxx1', 'test', 'end of Xxx1'], 'Xxx1', 'D')
+ call writefile(['start of Xxx2', 'test', 'end of Xxx2'], 'Xxx2', 'D')
edit Xtest
e! Xxx2
call assert_fails('w', 'E203:')
call assert_equal('Xxx1', bufname('%'))
au! BufWritePre
- call delete('Xxx1')
- call delete('Xxx2')
endfunc
" Test for BufUnload autocommand that unloads all the other buffers
func Test_bufunload_all()
let g:test_is_flaky = 1
- call writefile(['Test file Xxx1'], 'Xxx1')"
- call writefile(['Test file Xxx2'], 'Xxx2')"
+ call writefile(['Test file Xxx1'], 'Xxx1', 'D')"
+ call writefile(['Test file Xxx2'], 'Xxx2', 'D')"
let content =<< trim [CODE]
func UnloadAllBufs()
q
[CODE]
- call writefile(content, 'Xtest')
+ call writefile(content, 'Xbunloadtest', 'D')
call delete('Xout')
- call system(GetVimCommandClean() .. ' -N --not-a-term -S Xtest')
+ call system(GetVimCommandClean() .. ' -N --not-a-term -S Xbunloadtest')
call assert_true(filereadable('Xout'))
- call delete('Xxx1')
- call delete('Xxx2')
- call delete('Xtest')
call delete('Xout')
endfunc
" Test for "*Cmd" autocommands
func Test_Cmd_Autocmds()
- call writefile(['start of Xxx', "\tabc2", 'end of Xxx'], 'Xxx')
+ call writefile(['start of Xxx', "\tabc2", 'end of Xxx'], 'Xxx', 'D')
enew!
au BufReadCmd XtestA 0r Xxx|$del
au! FileWriteCmd
au! FileAppendCmd
%bwipe!
- call delete('Xxx')
enew!
endfunc
autocmd BufReadCmd *.test call s:ReadFile()
autocmd BufWriteCmd *.test call s:WriteFile()
- call writefile(['one', 'two', 'three'], 'Xcmd.test')
+ call writefile(['one', 'two', 'three'], 'Xcmd.test', 'D')
edit Xcmd.test
call assert_match('Xcmd.test" line 1 of 3', execute('file'))
normal! Gofour
call assert_equal(['one', 'two', 'three', 'four'], readfile('Xcmd.test'))
bwipe!
- call delete('Xcmd.test')
au! BufReadCmd
au! BufWriteCmd
endfunc
let g:test_is_flaky = 1
" Prepare file for TextChanged event.
- call writefile([''], 'Xchanged.txt')
+ call writefile([''], 'Xchanged.txt', 'D')
let buf = term_start([GetVimProg(), '--clean', '-c', 'set noswapfile'], {'term_rows': 3})
call assert_equal('running', term_getstatus(buf))
" Wait for the ruler (in the status line) to be shown.
call assert_equal([''], readfile('Xchanged.txt'))
" clean up
- call delete('Xchanged.txt')
bwipe!
endfunc
autocmd BufReadPost * autocmd SafeState * ++once foldclosed('.')
autocmd WinEnter * matchadd('ErrorMsg', 'pat')
END
- call writefile(lines, 'Xautoscript')
+ call writefile(lines, 'Xautoscript', 'D')
let buf = RunVimInTerminal('-S Xautoscript', {'rows': 10})
call VerifyScreenDump(buf, 'Test_autocmd_nested_switch', {})
call StopVimInTerminal(buf)
call delete('Xautofile')
- call delete('Xautoscript')
endfunc
func Test_autocmd_once()
au FileAppendPost *.out !cat Xtest.c >> test.out
augroup END
- call writefile(['/*', ' * Here is a new .c file', ' */'], 'Xtest.c')
+ call writefile(['/*', ' * Here is a new .c file', ' */'], 'Xtest.c', 'D')
new foo.c " should load Xtest.c
call assert_equal(['/*', ' * Here is a new .c file', ' */'], getline(2, 4))
w! >> test.out " append it to the output file
au! FileChangedShell
call delete('Xtestfile.gz')
- call delete('Xtest.c')
call delete('test.out')
endfunc
call timer_start(10, {id -> execute('let g:again ..= "t"')})
endfunc
END
- call writefile(lines, 'XSafeState')
+ call writefile(lines, 'XSafeState', 'D')
let buf = RunVimInTerminal('-S XSafeState', #{rows: 6})
" Sometimes we loop to handle a K_IGNORE, SafeState may be triggered once or
call WaitForAssert({-> assert_match('xtx', term_getline(buf, 6))}, 1000)
call StopVimInTerminal(buf)
- call delete('XSafeState')
endfunc
func Test_autocmd_CmdWinEnter()
au!
autocmd BufReadPre XbufreadPre call delete('XbufreadPre')
augroup END
- call writefile([], 'XbufreadPre')
+ call writefile([], 'XbufreadPre', 'D')
call assert_fails('new XbufreadPre', 'E200:')
call assert_equal('XbufreadPre', @%)
call assert_equal(1, &readonly)
- call delete('XbufreadPre')
+
augroup TestAuCmd
au!
augroup END
au!
autocmd BufReadPre Xchangebuf edit Xsomeotherfile
augroup END
- call writefile([], 'Xchangebuf')
+ call writefile([], 'Xchangebuf', 'D')
call assert_fails('new Xchangebuf', 'E201:')
call assert_equal('Xsomeotherfile', @%)
call assert_equal(1, &readonly)
- call delete('Xchangebuf')
+
augroup TestAuCmd
au!
augroup END