1
0
forked from aniani/vim

patch 9.0.0719: too many delete() calls in tests

Problem:    Too many delete() calls in tests.
Solution:   Use deferred delete where possible.
This commit is contained in:
Bram Moolenaar
2022-10-10 22:39:42 +01:00
parent ccf2837a05
commit 56564964e6
22 changed files with 150 additions and 282 deletions

View File

@@ -1,7 +1,7 @@
" Test for the :scriptnames command " Test for the :scriptnames command
func Test_scriptnames() func Test_scriptnames()
call writefile(['let did_load_script = 123'], 'Xscripting') call writefile(['let did_load_script = 123'], 'Xscripting', 'D')
source Xscripting source Xscripting
call assert_equal(123, g:did_load_script) call assert_equal(123, g:did_load_script)
@@ -22,7 +22,6 @@ func Test_scriptnames()
call assert_equal('Xscripting', expand('%:t')) call assert_equal('Xscripting', expand('%:t'))
bwipe bwipe
call delete('Xscripting')
let msgs = execute('messages') let msgs = execute('messages')
scriptnames scriptnames
@@ -47,7 +46,7 @@ func Test_getscriptinfo()
def Xscript_def_func2() def Xscript_def_func2()
enddef enddef
END END
call writefile(lines, 'X22script91') call writefile(lines, 'X22script91', 'D')
source X22script91 source X22script91
let l = getscriptinfo() let l = getscriptinfo()
call assert_match('X22script91$', l[-1].name) call assert_match('X22script91$', l[-1].name)
@@ -92,8 +91,6 @@ func Test_getscriptinfo()
call assert_fails("echo getscriptinfo('foobar')", 'E1206:') call assert_fails("echo getscriptinfo('foobar')", 'E1206:')
call assert_fails("echo getscriptinfo({'sid': []})", 'E745:') call assert_fails("echo getscriptinfo({'sid': []})", 'E745:')
call delete('X22script91')
endfunc endfunc
" vim: shiftwidth=2 sts=2 expandtab " vim: shiftwidth=2 sts=2 expandtab

View File

@@ -724,7 +724,7 @@ func Test_search_cmdline8()
endif endif
" Prepare buffer text " Prepare buffer text
let lines = ['abb vim vim vi', 'vimvivim'] let lines = ['abb vim vim vi', 'vimvivim']
call writefile(lines, 'Xsearch.txt') call writefile(lines, 'Xsearch.txt', 'D')
let buf = term_start([GetVimProg(), '--clean', '-c', 'set noswapfile', 'Xsearch.txt'], {'term_rows': 3}) let buf = term_start([GetVimProg(), '--clean', '-c', 'set noswapfile', 'Xsearch.txt'], {'term_rows': 3})
call WaitForAssert({-> assert_equal(lines, [term_getline(buf, 1), term_getline(buf, 2)])}) call WaitForAssert({-> assert_equal(lines, [term_getline(buf, 1), term_getline(buf, 2)])})
@@ -743,9 +743,8 @@ func Test_search_cmdline8()
call assert_notequal(a1, a2) call assert_notequal(a1, a2)
call assert_equal(a0, a2) call assert_equal(a0, a2)
call assert_equal(a1, a3) call assert_equal(a1, a3)
" clean up
call delete('Xsearch.txt')
" clean up
bwipe! bwipe!
endfunc endfunc
@@ -859,7 +858,7 @@ func Test_search_cmdline_incsearch_highlight_attr()
" Prepare buffer text " Prepare buffer text
let lines = ['abb vim vim vi', 'vimvivim'] let lines = ['abb vim vim vi', 'vimvivim']
call writefile(lines, 'Xsearch.txt') call writefile(lines, 'Xsearch.txt', 'D')
let buf = term_start([GetVimProg(), '--clean', '-c', 'set noswapfile', 'Xsearch.txt'], {'term_rows': 3}) let buf = term_start([GetVimProg(), '--clean', '-c', 'set noswapfile', 'Xsearch.txt'], {'term_rows': 3})
call WaitForAssert({-> assert_equal(lines, [term_getline(buf, 1), term_getline(buf, 2)])}) call WaitForAssert({-> assert_equal(lines, [term_getline(buf, 1), term_getline(buf, 2)])})
@@ -928,9 +927,7 @@ func Test_search_cmdline_incsearch_highlight_attr()
let attr_line2 = [a0,a0,a0,a0,a0,a0,a0,a0] let attr_line2 = [a0,a0,a0,a0,a0,a0,a0,a0]
call assert_equal(attr_line1, map(term_scrape(buf, 1)[:len(attr_line1)-1], 'v:val.attr')) call assert_equal(attr_line1, map(term_scrape(buf, 1)[:len(attr_line1)-1], 'v:val.attr'))
call assert_equal(attr_line2, map(term_scrape(buf, 2)[:len(attr_line2)-1], 'v:val.attr')) call assert_equal(attr_line2, map(term_scrape(buf, 2)[:len(attr_line2)-1], 'v:val.attr'))
call delete('Xsearch.txt')
call delete('Xsearch.txt')
bwipe! bwipe!
endfunc endfunc
@@ -956,7 +953,7 @@ func Test_incsearch_scrolling()
\ 'call setline(1, [dots, dots, dots, "", "target", dots, dots])', \ 'call setline(1, [dots, dots, dots, "", "target", dots, dots])',
\ 'normal gg', \ 'normal gg',
\ 'redraw', \ 'redraw',
\ ], 'Xscript') \ ], 'Xscript', 'D')
let buf = RunVimInTerminal('-S Xscript', {'rows': 9, 'cols': 70}) let buf = RunVimInTerminal('-S Xscript', {'rows': 9, 'cols': 70})
" Need to send one key at a time to force a redraw " Need to send one key at a time to force a redraw
call term_sendkeys(buf, '/') call term_sendkeys(buf, '/')
@@ -972,7 +969,6 @@ func Test_incsearch_scrolling()
call term_sendkeys(buf, "\<Esc>") call term_sendkeys(buf, "\<Esc>")
call StopVimInTerminal(buf) call StopVimInTerminal(buf)
call delete('Xscript')
endfunc endfunc
func Test_incsearch_search_dump() func Test_incsearch_search_dump()
@@ -985,7 +981,7 @@ func Test_incsearch_search_dump()
\ ' call setline(n, "foo " . n)', \ ' call setline(n, "foo " . n)',
\ 'endfor', \ 'endfor',
\ '3', \ '3',
\ ], 'Xis_search_script') \ ], 'Xis_search_script', 'D')
let buf = RunVimInTerminal('-S Xis_search_script', {'rows': 9, 'cols': 70}) let buf = RunVimInTerminal('-S Xis_search_script', {'rows': 9, 'cols': 70})
" Give Vim a chance to redraw to get rid of the spaces in line 2 caused by " Give Vim a chance to redraw to get rid of the spaces in line 2 caused by
" the 'ambiwidth' check. " the 'ambiwidth' check.
@@ -1002,7 +998,6 @@ func Test_incsearch_search_dump()
call term_sendkeys(buf, "\<Esc>") call term_sendkeys(buf, "\<Esc>")
call StopVimInTerminal(buf) call StopVimInTerminal(buf)
call delete('Xis_search_script')
endfunc endfunc
func Test_hlsearch_dump() func Test_hlsearch_dump()
@@ -1014,7 +1009,7 @@ func Test_hlsearch_dump()
\ 'call setline(1, ["xxx", "xxx", "xxx"])', \ 'call setline(1, ["xxx", "xxx", "xxx"])',
\ '/.*', \ '/.*',
\ '2', \ '2',
\ ], 'Xhlsearch_script') \ ], 'Xhlsearch_script', 'D')
let buf = RunVimInTerminal('-S Xhlsearch_script', {'rows': 6, 'cols': 50}) let buf = RunVimInTerminal('-S Xhlsearch_script', {'rows': 6, 'cols': 50})
call VerifyScreenDump(buf, 'Test_hlsearch_1', {}) call VerifyScreenDump(buf, 'Test_hlsearch_1', {})
@@ -1022,7 +1017,6 @@ func Test_hlsearch_dump()
call VerifyScreenDump(buf, 'Test_hlsearch_2', {}) call VerifyScreenDump(buf, 'Test_hlsearch_2', {})
call StopVimInTerminal(buf) call StopVimInTerminal(buf)
call delete('Xhlsearch_script')
endfunc endfunc
func Test_hlsearch_and_visual() func Test_hlsearch_and_visual()
@@ -1035,14 +1029,13 @@ func Test_hlsearch_and_visual()
\ 'hi Search cterm=bold', \ 'hi Search cterm=bold',
\ '/yyy', \ '/yyy',
\ 'call cursor(1, 6)', \ 'call cursor(1, 6)',
\ ], 'Xhlvisual_script') \ ], 'Xhlvisual_script', 'D')
let buf = RunVimInTerminal('-S Xhlvisual_script', {'rows': 6, 'cols': 40}) let buf = RunVimInTerminal('-S Xhlvisual_script', {'rows': 6, 'cols': 40})
call term_sendkeys(buf, "vjj") call term_sendkeys(buf, "vjj")
call VerifyScreenDump(buf, 'Test_hlsearch_visual_1', {}) call VerifyScreenDump(buf, 'Test_hlsearch_visual_1', {})
call term_sendkeys(buf, "\<Esc>") call term_sendkeys(buf, "\<Esc>")
call StopVimInTerminal(buf) call StopVimInTerminal(buf)
call delete('Xhlvisual_script')
endfunc endfunc
func Test_hlsearch_block_visual_match() func Test_hlsearch_block_visual_match()
@@ -1052,7 +1045,7 @@ func Test_hlsearch_block_visual_match()
set hlsearch set hlsearch
call setline(1, ['aa', 'bbbb', 'cccccc']) call setline(1, ['aa', 'bbbb', 'cccccc'])
END END
call writefile(lines, 'Xhlsearch_block') call writefile(lines, 'Xhlsearch_block', 'D')
let buf = RunVimInTerminal('-S Xhlsearch_block', {'rows': 9, 'cols': 60}) let buf = RunVimInTerminal('-S Xhlsearch_block', {'rows': 9, 'cols': 60})
call term_sendkeys(buf, "G\<C-V>$kk\<Esc>") call term_sendkeys(buf, "G\<C-V>$kk\<Esc>")
@@ -1062,7 +1055,6 @@ func Test_hlsearch_block_visual_match()
call VerifyScreenDump(buf, 'Test_hlsearch_block_visual_match', {}) call VerifyScreenDump(buf, 'Test_hlsearch_block_visual_match', {})
call StopVimInTerminal(buf) call StopVimInTerminal(buf)
call delete('Xhlsearch_block')
endfunc endfunc
func Test_incsearch_substitute() func Test_incsearch_substitute()
@@ -1108,7 +1100,7 @@ func Test_hlsearch_cursearch()
hi Search ctermbg=yellow hi Search ctermbg=yellow
hi CurSearch ctermbg=blue hi CurSearch ctermbg=blue
END END
call writefile(lines, 'Xhlsearch_cursearch') call writefile(lines, 'Xhlsearch_cursearch', 'D')
let buf = RunVimInTerminal('-S Xhlsearch_cursearch', {'rows': 9, 'cols': 60}) let buf = RunVimInTerminal('-S Xhlsearch_cursearch', {'rows': 9, 'cols': 60})
call term_sendkeys(buf, "gg/foo\<CR>") call term_sendkeys(buf, "gg/foo\<CR>")
@@ -1146,7 +1138,6 @@ func Test_hlsearch_cursearch()
call VerifyScreenDump(buf, 'Test_hlsearch_cursearch_changed_1', {}) call VerifyScreenDump(buf, 'Test_hlsearch_cursearch_changed_1', {})
call StopVimInTerminal(buf) call StopVimInTerminal(buf)
call delete('Xhlsearch_cursearch')
endfunc endfunc
" Similar to Test_incsearch_substitute() but with a screendump halfway. " Similar to Test_incsearch_substitute() but with a screendump halfway.
@@ -1161,7 +1152,7 @@ func Test_incsearch_substitute_dump()
\ 'endfor', \ 'endfor',
\ 'call setline(11, "bar 11")', \ 'call setline(11, "bar 11")',
\ '3', \ '3',
\ ], 'Xis_subst_script') \ ], 'Xis_subst_script', 'D')
let buf = RunVimInTerminal('-S Xis_subst_script', {'rows': 9, 'cols': 70}) let buf = RunVimInTerminal('-S Xis_subst_script', {'rows': 9, 'cols': 70})
" Give Vim a chance to redraw to get rid of the spaces in line 2 caused by " Give Vim a chance to redraw to get rid of the spaces in line 2 caused by
" the 'ambiwidth' check. " the 'ambiwidth' check.
@@ -1256,7 +1247,6 @@ func Test_incsearch_substitute_dump()
call term_sendkeys(buf, "<Esc>") call term_sendkeys(buf, "<Esc>")
call StopVimInTerminal(buf) call StopVimInTerminal(buf)
call delete('Xis_subst_script')
endfunc endfunc
func Test_incsearch_highlighting() func Test_incsearch_highlighting()
@@ -1266,7 +1256,7 @@ func Test_incsearch_highlighting()
call writefile([ call writefile([
\ 'set incsearch hlsearch', \ 'set incsearch hlsearch',
\ 'call setline(1, "hello/there")', \ 'call setline(1, "hello/there")',
\ ], 'Xis_subst_hl_script') \ ], 'Xis_subst_hl_script', 'D')
let buf = RunVimInTerminal('-S Xis_subst_hl_script', {'rows': 4, 'cols': 20}) let buf = RunVimInTerminal('-S Xis_subst_hl_script', {'rows': 4, 'cols': 20})
" Give Vim a chance to redraw to get rid of the spaces in line 2 caused by " Give Vim a chance to redraw to get rid of the spaces in line 2 caused by
" the 'ambiwidth' check. " the 'ambiwidth' check.
@@ -1279,7 +1269,6 @@ func Test_incsearch_highlighting()
call term_sendkeys(buf, "<Esc>") call term_sendkeys(buf, "<Esc>")
call StopVimInTerminal(buf) call StopVimInTerminal(buf)
call delete('Xis_subst_hl_script')
endfunc endfunc
func Test_incsearch_with_change() func Test_incsearch_with_change()
@@ -1291,7 +1280,7 @@ func Test_incsearch_with_change()
\ 'set incsearch hlsearch scrolloff=0', \ 'set incsearch hlsearch scrolloff=0',
\ 'call setline(1, ["one", "two ------ X", "three"])', \ 'call setline(1, ["one", "two ------ X", "three"])',
\ 'call timer_start(200, { _ -> setline(2, "x")})', \ 'call timer_start(200, { _ -> setline(2, "x")})',
\ ], 'Xis_change_script') \ ], 'Xis_change_script', 'D')
let buf = RunVimInTerminal('-S Xis_change_script', {'rows': 9, 'cols': 70}) let buf = RunVimInTerminal('-S Xis_change_script', {'rows': 9, 'cols': 70})
" Give Vim a chance to redraw to get rid of the spaces in line 2 caused by " Give Vim a chance to redraw to get rid of the spaces in line 2 caused by
" the 'ambiwidth' check. " the 'ambiwidth' check.
@@ -1303,7 +1292,6 @@ func Test_incsearch_with_change()
call term_sendkeys(buf, "\<Esc>") call term_sendkeys(buf, "\<Esc>")
call StopVimInTerminal(buf) call StopVimInTerminal(buf)
call delete('Xis_change_script')
endfunc endfunc
" Similar to Test_incsearch_substitute_dump() for :sort " Similar to Test_incsearch_substitute_dump() for :sort
@@ -1314,7 +1302,7 @@ func Test_incsearch_sort_dump()
call writefile([ call writefile([
\ 'set incsearch hlsearch scrolloff=0', \ 'set incsearch hlsearch scrolloff=0',
\ 'call setline(1, ["another one 2", "that one 3", "the one 1"])', \ 'call setline(1, ["another one 2", "that one 3", "the one 1"])',
\ ], 'Xis_sort_script') \ ], 'Xis_sort_script', 'D')
let buf = RunVimInTerminal('-S Xis_sort_script', {'rows': 9, 'cols': 70}) let buf = RunVimInTerminal('-S Xis_sort_script', {'rows': 9, 'cols': 70})
" Give Vim a chance to redraw to get rid of the spaces in line 2 caused by " Give Vim a chance to redraw to get rid of the spaces in line 2 caused by
" the 'ambiwidth' check. " the 'ambiwidth' check.
@@ -1329,7 +1317,6 @@ func Test_incsearch_sort_dump()
call term_sendkeys(buf, "\<Esc>") call term_sendkeys(buf, "\<Esc>")
call StopVimInTerminal(buf) call StopVimInTerminal(buf)
call delete('Xis_sort_script')
endfunc endfunc
" Similar to Test_incsearch_substitute_dump() for :vimgrep famiry " Similar to Test_incsearch_substitute_dump() for :vimgrep famiry
@@ -1340,7 +1327,7 @@ func Test_incsearch_vimgrep_dump()
call writefile([ call writefile([
\ 'set incsearch hlsearch scrolloff=0', \ 'set incsearch hlsearch scrolloff=0',
\ 'call setline(1, ["another one 2", "that one 3", "the one 1"])', \ 'call setline(1, ["another one 2", "that one 3", "the one 1"])',
\ ], 'Xis_vimgrep_script') \ ], 'Xis_vimgrep_script', 'D')
let buf = RunVimInTerminal('-S Xis_vimgrep_script', {'rows': 9, 'cols': 70}) let buf = RunVimInTerminal('-S Xis_vimgrep_script', {'rows': 9, 'cols': 70})
" Give Vim a chance to redraw to get rid of the spaces in line 2 caused by " Give Vim a chance to redraw to get rid of the spaces in line 2 caused by
" the 'ambiwidth' check. " the 'ambiwidth' check.
@@ -1368,7 +1355,6 @@ func Test_incsearch_vimgrep_dump()
call term_sendkeys(buf, "\<Esc>") call term_sendkeys(buf, "\<Esc>")
call StopVimInTerminal(buf) call StopVimInTerminal(buf)
call delete('Xis_vimgrep_script')
endfunc endfunc
func Test_keep_last_search_pattern() func Test_keep_last_search_pattern()
@@ -1492,11 +1478,9 @@ endfunc
func Test_no_last_substitute_pat() func Test_no_last_substitute_pat()
" Use viminfo to set the last search pattern to a string and make the last " Use viminfo to set the last search pattern to a string and make the last
" substitute pattern the most recent used and make it empty (NULL). " substitute pattern the most recent used and make it empty (NULL).
call writefile(['~MSle0/bar', '~MSle0~&'], 'Xviminfo') call writefile(['~MSle0/bar', '~MSle0~&'], 'Xviminfo', 'D')
rviminfo! Xviminfo rviminfo! Xviminfo
call assert_fails('normal n', 'E35:') call assert_fails('normal n', 'E35:')
call delete('Xviminfo')
endfunc endfunc
func Test_search_Ctrl_L_combining() func Test_search_Ctrl_L_combining()
@@ -1739,12 +1723,11 @@ func Test_search_with_no_last_pat()
call writefile(v:errors, 'Xresult') call writefile(v:errors, 'Xresult')
qall! qall!
[SCRIPT] [SCRIPT]
call writefile(lines, 'Xscript') call writefile(lines, 'Xscript', 'D')
if RunVim([], [], '--clean -S Xscript') if RunVim([], [], '--clean -S Xscript')
call assert_equal([], readfile('Xresult')) call assert_equal([], readfile('Xresult'))
endif endif
call delete('Xscript')
call delete('Xresult') call delete('Xresult')
endfunc endfunc
@@ -1762,11 +1745,10 @@ func Test_search_tilde_pat()
call writefile(v:errors, 'Xresult') call writefile(v:errors, 'Xresult')
qall! qall!
[SCRIPT] [SCRIPT]
call writefile(lines, 'Xscript') call writefile(lines, 'Xscript', 'D')
if RunVim([], [], '--clean -S Xscript') if RunVim([], [], '--clean -S Xscript')
call assert_equal([], readfile('Xresult')) call assert_equal([], readfile('Xresult'))
endif endif
call delete('Xscript')
call delete('Xresult') call delete('Xresult')
endfunc endfunc
@@ -2012,7 +1994,7 @@ func Test_incsearch_highlighting_newline()
set incsearch nohls set incsearch nohls
call setline(1, ['test', 'xxx']) call setline(1, ['test', 'xxx'])
[CODE] [CODE]
call writefile(commands, 'Xincsearch_nl') call writefile(commands, 'Xincsearch_nl', 'D')
let buf = RunVimInTerminal('-S Xincsearch_nl', {'rows': 5, 'cols': 10}) let buf = RunVimInTerminal('-S Xincsearch_nl', {'rows': 5, 'cols': 10})
call term_sendkeys(buf, '/test') call term_sendkeys(buf, '/test')
call VerifyScreenDump(buf, 'Test_incsearch_newline1', {}) call VerifyScreenDump(buf, 'Test_incsearch_newline1', {})
@@ -2028,7 +2010,6 @@ func Test_incsearch_highlighting_newline()
call StopVimInTerminal(buf) call StopVimInTerminal(buf)
" clean up " clean up
call delete('Xincsearch_nl')
call test_override("char_avail", 0) call test_override("char_avail", 0)
bw bw
endfunc endfunc
@@ -2044,7 +2025,7 @@ func Test_incsearch_substitute_dump2()
\ 'endfor', \ 'endfor',
\ 'call setline(5, "abc|def")', \ 'call setline(5, "abc|def")',
\ '3', \ '3',
\ ], 'Xis_subst_script2') \ ], 'Xis_subst_script2', 'D')
let buf = RunVimInTerminal('-S Xis_subst_script2', {'rows': 9, 'cols': 70}) let buf = RunVimInTerminal('-S Xis_subst_script2', {'rows': 9, 'cols': 70})
call term_sendkeys(buf, ':%s/\vabc|') call term_sendkeys(buf, ':%s/\vabc|')
@@ -2059,7 +2040,6 @@ func Test_incsearch_substitute_dump2()
call StopVimInTerminal(buf) call StopVimInTerminal(buf)
call delete('Xis_subst_script2')
endfunc endfunc
func Test_pattern_is_uppercase_smartcase() func Test_pattern_is_uppercase_smartcase()
@@ -2146,11 +2126,10 @@ func Test_search_with_invalid_range()
5/ 5/
c c
END END
call writefile(lines, 'Xrangesearch') call writefile(lines, 'Xrangesearch', 'D')
source Xrangesearch source Xrangesearch
bwipe! bwipe!
call delete('Xrangesearch')
endfunc endfunc

View File

@@ -287,7 +287,7 @@ func Test_searchcount_in_statusline()
set hlsearch set hlsearch
set laststatus=2 statusline+=%{TestSearchCount()} set laststatus=2 statusline+=%{TestSearchCount()}
END END
call writefile(lines, 'Xsearchstatusline') call writefile(lines, 'Xsearchstatusline', 'D')
let buf = RunVimInTerminal('-S Xsearchstatusline', #{rows: 10}) let buf = RunVimInTerminal('-S Xsearchstatusline', #{rows: 10})
call TermWait(buf) call TermWait(buf)
call term_sendkeys(buf, "/something") call term_sendkeys(buf, "/something")
@@ -295,7 +295,6 @@ func Test_searchcount_in_statusline()
call term_sendkeys(buf, "\<Esc>") call term_sendkeys(buf, "\<Esc>")
call StopVimInTerminal(buf) call StopVimInTerminal(buf)
call delete('Xsearchstatusline')
endfunc endfunc
func Test_search_stat_foldopen() func Test_search_stat_foldopen()
@@ -309,7 +308,7 @@ func Test_search_stat_foldopen()
call cursor(1,1) call cursor(1,1)
norm n norm n
END END
call writefile(lines, 'Xsearchstat1') call writefile(lines, 'Xsearchstat1', 'D')
let buf = RunVimInTerminal('-S Xsearchstat1', #{rows: 10}) let buf = RunVimInTerminal('-S Xsearchstat1', #{rows: 10})
call VerifyScreenDump(buf, 'Test_searchstat_3', {}) call VerifyScreenDump(buf, 'Test_searchstat_3', {})
@@ -321,7 +320,6 @@ func Test_search_stat_foldopen()
call VerifyScreenDump(buf, 'Test_searchstat_3', {}) call VerifyScreenDump(buf, 'Test_searchstat_3', {})
call StopVimInTerminal(buf) call StopVimInTerminal(buf)
call delete('Xsearchstat1')
endfunc endfunc
func! Test_search_stat_screendump() func! Test_search_stat_screendump()
@@ -338,7 +336,7 @@ func! Test_search_stat_screendump()
call cursor(1,1) call cursor(1,1)
norm n norm n
END END
call writefile(lines, 'Xsearchstat') call writefile(lines, 'Xsearchstat', 'D')
let buf = RunVimInTerminal('-S Xsearchstat', #{rows: 10}) let buf = RunVimInTerminal('-S Xsearchstat', #{rows: 10})
call VerifyScreenDump(buf, 'Test_searchstat_1', {}) call VerifyScreenDump(buf, 'Test_searchstat_1', {})
@@ -347,7 +345,6 @@ func! Test_search_stat_screendump()
call VerifyScreenDump(buf, 'Test_searchstat_2', {}) call VerifyScreenDump(buf, 'Test_searchstat_2', {})
call StopVimInTerminal(buf) call StopVimInTerminal(buf)
call delete('Xsearchstat')
endfunc endfunc
func Test_search_stat_then_gd() func Test_search_stat_then_gd()
@@ -358,7 +355,7 @@ func Test_search_stat_then_gd()
set shortmess-=S set shortmess-=S
set hlsearch set hlsearch
END END
call writefile(lines, 'Xsearchstatgd') call writefile(lines, 'Xsearchstatgd', 'D')
let buf = RunVimInTerminal('-S Xsearchstatgd', #{rows: 10}) let buf = RunVimInTerminal('-S Xsearchstatgd', #{rows: 10})
call term_sendkeys(buf, "/dog\<CR>") call term_sendkeys(buf, "/dog\<CR>")
@@ -368,7 +365,6 @@ func Test_search_stat_then_gd()
call VerifyScreenDump(buf, 'Test_searchstatgd_2', {}) call VerifyScreenDump(buf, 'Test_searchstatgd_2', {})
call StopVimInTerminal(buf) call StopVimInTerminal(buf)
call delete('Xsearchstatgd')
endfunc endfunc
func Test_search_stat_and_incsearch() func Test_search_stat_and_incsearch()
@@ -392,7 +388,7 @@ func Test_search_stat_and_incsearch()
set tabline=%!MyTabLine() set tabline=%!MyTabLine()
END END
call writefile(lines, 'Xsearchstat_inc') call writefile(lines, 'Xsearchstat_inc', 'D')
let buf = RunVimInTerminal('-S Xsearchstat_inc', #{rows: 10}) let buf = RunVimInTerminal('-S Xsearchstat_inc', #{rows: 10})
call term_sendkeys(buf, "/abc") call term_sendkeys(buf, "/abc")
@@ -411,7 +407,6 @@ func Test_search_stat_and_incsearch()
call TermWait(buf) call TermWait(buf)
call StopVimInTerminal(buf) call StopVimInTerminal(buf)
call delete('Xsearchstat_inc')
endfunc endfunc

View File

@@ -202,7 +202,7 @@ func Test_shellxquote()
let save_sxq = &shellxquote let save_sxq = &shellxquote
let save_sxe = &shellxescape let save_sxe = &shellxescape
call writefile(['#!/bin/sh', 'echo "Cmd: [$*]" > Xlog'], 'Xtestshell') call writefile(['#!/bin/sh', 'echo "Cmd: [$*]" > Xlog'], 'Xtestshell', 'D')
call setfperm('Xtestshell', "r-x------") call setfperm('Xtestshell', "r-x------")
set shell=./Xtestshell set shell=./Xtestshell
@@ -226,7 +226,6 @@ func Test_shellxquote()
let &shell = save_shell let &shell = save_shell
let &shellxquote = save_sxq let &shellxquote = save_sxq
let &shellxescape = save_sxe let &shellxescape = save_sxe
call delete('Xtestshell')
call delete('Xlog') call delete('Xlog')
endfunc endfunc

View File

@@ -42,7 +42,7 @@ func Test_ColonEight()
let file2 = dir2 . '/z.txt' let file2 = dir2 . '/z.txt'
let nofile2 = dir2 . '/zz.txt' let nofile2 = dir2 . '/zz.txt'
call mkdir(dir1) call mkdir(dir1, 'D')
let resdir1 = substitute(fnamemodify(dir1, ':p:8'), '/$', '', '') let resdir1 = substitute(fnamemodify(dir1, ':p:8'), '/$', '', '')
call assert_match('\V\^c:/XX\x\x\x\x~1.Y\$', resdir1) call assert_match('\V\^c:/XX\x\x\x\x~1.Y\$', resdir1)
@@ -52,9 +52,9 @@ func Test_ColonEight()
let resfile2 = resdir2 . '/z.txt' let resfile2 = resdir2 . '/z.txt'
let resnofile2 = resdir2 . '/zz.txt' let resnofile2 = resdir2 . '/zz.txt'
call mkdir(dir2) call mkdir(dir2, 'D')
call writefile([], file1) call writefile([], file1, 'D')
call writefile([], file2) call writefile([], file2, 'D')
call TestIt(file1, ':p:8', resfile1) call TestIt(file1, ':p:8', resfile1)
call TestIt(nofile1, ':p:8', resnofile1) call TestIt(nofile1, ':p:8', resnofile1)
@@ -73,10 +73,6 @@ func Test_ColonEight()
call TestIt(nofile2, ':~:8', '~' . strpart(resnofile2, strlen(resdir1))) call TestIt(nofile2, ':~:8', '~' . strpart(resnofile2, strlen(resdir1)))
cd c:/ cd c:/
call delete(file2)
call delete(file1)
call delete(dir2, 'd')
call delete(dir1, 'd')
call chdir(save_dir) call chdir(save_dir)
endfunc endfunc
@@ -86,16 +82,13 @@ func Test_ColonEight_MultiByte()
let file = dir . '/日本語のファイル.txt' let file = dir . '/日本語のファイル.txt'
call mkdir(dir) call mkdir(dir, 'D')
call writefile([], file) call writefile([], file, 'D')
let sfile = fnamemodify(file, ':8') let sfile = fnamemodify(file, ':8')
call assert_notequal(file, sfile) call assert_notequal(file, sfile)
call assert_match('\~', sfile) call assert_match('\~', sfile)
call delete(file)
call delete(dir, 'd')
endfunc endfunc
func Test_ColonEight_notexists() func Test_ColonEight_notexists()

View File

@@ -117,7 +117,7 @@ func Test_signal_TSTP()
au VimSuspend * call writefile(["VimSuspend triggered"], "XautoOut1", "as") au VimSuspend * call writefile(["VimSuspend triggered"], "XautoOut1", "as")
au VimResume * call writefile(["VimResume triggered"], "XautoOut2", "as") au VimResume * call writefile(["VimResume triggered"], "XautoOut2", "as")
END END
call writefile(lines, 'XsetupAucmd') call writefile(lines, 'XsetupAucmd', 'D')
let buf = RunVimInTerminal('-S XsetupAucmd Xsig_TERM', {'rows': 6}) let buf = RunVimInTerminal('-S XsetupAucmd Xsig_TERM', {'rows': 6})
let pid_vim = term_getjob(buf)->job_info().process let pid_vim = term_getjob(buf)->job_info().process
@@ -147,7 +147,6 @@ func Test_signal_TSTP()
%bwipe! %bwipe!
call delete('.Xsig_TERM.swp') call delete('.Xsig_TERM.swp')
call delete('XsetupAucmd')
call delete('XautoOut1') call delete('XautoOut1')
call delete('XautoOut2') call delete('XautoOut2')
endfunc endfunc
@@ -176,7 +175,7 @@ func Test_deadly_signal_TERM()
au VimLeave * call writefile(["VimLeave triggered"], "XautoOut", "as") au VimLeave * call writefile(["VimLeave triggered"], "XautoOut", "as")
au VimLeavePre * call writefile(["VimLeavePre triggered"], "XautoOut", "as") au VimLeavePre * call writefile(["VimLeavePre triggered"], "XautoOut", "as")
END END
call writefile(lines, 'XsetupAucmd') call writefile(lines, 'XsetupAucmd', 'D')
let buf = RunVimInTerminal('-S XsetupAucmd Xsig_TERM', {'rows': 6}) let buf = RunVimInTerminal('-S XsetupAucmd Xsig_TERM', {'rows': 6})
let pid_vim = term_getjob(buf)->job_info().process let pid_vim = term_getjob(buf)->job_info().process
@@ -200,7 +199,6 @@ func Test_deadly_signal_TERM()
%bwipe! %bwipe!
call delete('.Xsig_TERM.swp') call delete('.Xsig_TERM.swp')
call delete('XsetupAucmd')
call delete('XautoOut') call delete('XautoOut')
endfunc endfunc

View File

@@ -248,8 +248,8 @@ func Test_sign_completion()
\ 'SpellLocal SpellRare', @:) \ 'SpellLocal SpellRare', @:)
endfor endfor
call writefile(repeat(["Sun is shining"], 30), "XsignOne") call writefile(repeat(["Sun is shining"], 30), "XsignOne", 'D')
call writefile(repeat(["Sky is blue"], 30), "XsignTwo") call writefile(repeat(["Sky is blue"], 30), "XsignTwo", 'D')
call feedkeys(":sign define Sign icon=Xsig\<C-A>\<C-B>\"\<CR>", 'tx') call feedkeys(":sign define Sign icon=Xsig\<C-A>\<C-B>\"\<CR>", 'tx')
call assert_equal('"sign define Sign icon=XsignOne XsignTwo', @:) call assert_equal('"sign define Sign icon=XsignOne XsignTwo', @:)
@@ -326,8 +326,6 @@ func Test_sign_completion()
sign undefine Sign1 sign undefine Sign1
sign undefine Sign2 sign undefine Sign2
enew enew
call delete('XsignOne')
call delete('XsignTwo')
endfunc endfunc
func Test_sign_invalid_commands() func Test_sign_invalid_commands()
@@ -470,7 +468,7 @@ func Test_sign_funcs()
call assert_fails('call sign_getdefined({})', 'E731:') call assert_fails('call sign_getdefined({})', 'E731:')
" Tests for sign_place() " Tests for sign_place()
call writefile(repeat(["Sun is shining"], 30), "Xsign") call writefile(repeat(["Sun is shining"], 30), "Xsign", 'D')
edit Xsign edit Xsign
call assert_equal(10, sign_place(10, '', 'sign1', 'Xsign', call assert_equal(10, sign_place(10, '', 'sign1', 'Xsign',
@@ -576,7 +574,6 @@ func Test_sign_funcs()
\ 'priority' : 10}]}], \ 'priority' : 10}]}],
\ sign_getplaced('%', {'lnum' : 22})) \ sign_getplaced('%', {'lnum' : 22}))
call delete("Xsign")
call sign_unplace('*') call sign_unplace('*')
call sign_undefine() call sign_undefine()
enew | only enew | only
@@ -589,7 +586,7 @@ func Test_sign_group()
call sign_unplace('*') call sign_unplace('*')
call sign_undefine() call sign_undefine()
call writefile(repeat(["Sun is shining"], 30), "Xsign") call writefile(repeat(["Sun is shining"], 30), "Xsign", 'D')
let attr = {'text' : '=>', 'linehl' : 'Search', 'texthl' : 'Error'} let attr = {'text' : '=>', 'linehl' : 'Search', 'texthl' : 'Error'}
call assert_equal(0, sign_define("sign1", attr)) call assert_equal(0, sign_define("sign1", attr))
@@ -829,7 +826,6 @@ func Test_sign_group()
" Error cases " Error cases
call assert_fails("sign place 3 group= name=sign1 buffer=" . bnum, 'E474:') call assert_fails("sign place 3 group= name=sign1 buffer=" . bnum, 'E474:')
call delete("Xsign")
call sign_unplace('*') call sign_unplace('*')
call sign_undefine() call sign_undefine()
enew | only enew | only
@@ -872,8 +868,8 @@ func Test_sign_unplace()
call sign_undefine() call sign_undefine()
" Create two files and define signs " Create two files and define signs
call writefile(repeat(["Sun is shining"], 30), "Xsign1") call writefile(repeat(["Sun is shining"], 30), "Xsign1", 'D')
call writefile(repeat(["It is beautiful"], 30), "Xsign2") call writefile(repeat(["It is beautiful"], 30), "Xsign2", 'D')
let attr = {'text' : '=>', 'linehl' : 'Search', 'texthl' : 'Error'} let attr = {'text' : '=>', 'linehl' : 'Search', 'texthl' : 'Error'}
call sign_define("sign1", attr) call sign_define("sign1", attr)
@@ -1182,8 +1178,6 @@ func Test_sign_unplace()
call sign_unplace('*') call sign_unplace('*')
call sign_undefine() call sign_undefine()
enew | only enew | only
call delete("Xsign1")
call delete("Xsign2")
endfunc endfunc
" Tests for auto-generating the sign identifier. " Tests for auto-generating the sign identifier.
@@ -1195,7 +1189,7 @@ func Test_aaa_sign_id_autogen()
let attr = {'text' : '=>', 'linehl' : 'Search', 'texthl' : 'Error'} let attr = {'text' : '=>', 'linehl' : 'Search', 'texthl' : 'Error'}
call assert_equal(0, sign_define("sign1", attr)) call assert_equal(0, sign_define("sign1", attr))
call writefile(repeat(["Sun is shining"], 30), "Xsign") call writefile(repeat(["Sun is shining"], 30), "Xsign", 'D')
edit Xsign edit Xsign
call assert_equal(1, sign_place(0, '', 'sign1', 'Xsign', call assert_equal(1, sign_place(0, '', 'sign1', 'Xsign',
@@ -1217,7 +1211,6 @@ func Test_aaa_sign_id_autogen()
call assert_equal(10, call assert_equal(10,
\ sign_getplaced('Xsign', {'id' : 1})[0].signs[0].lnum) \ sign_getplaced('Xsign', {'id' : 1})[0].signs[0].lnum)
call delete("Xsign")
call sign_unplace('*') call sign_unplace('*')
call sign_undefine() call sign_undefine()
enew | only enew | only
@@ -1235,7 +1228,7 @@ func Test_sign_priority()
call sign_define("sign3", attr) call sign_define("sign3", attr)
" Place three signs with different priority in the same line " Place three signs with different priority in the same line
call writefile(repeat(["Sun is shining"], 30), "Xsign") call writefile(repeat(["Sun is shining"], 30), "Xsign", 'D')
edit Xsign edit Xsign
call sign_place(1, 'g1', 'sign1', 'Xsign', call sign_place(1, 'g1', 'sign1', 'Xsign',
@@ -1590,12 +1583,11 @@ func Test_sign_priority()
call sign_unplace('*') call sign_unplace('*')
call sign_undefine() call sign_undefine()
enew | only enew | only
call delete("Xsign")
endfunc endfunc
" Tests for memory allocation failures in sign functions " Tests for memory allocation failures in sign functions
func Test_sign_memfailures() func Test_sign_memfailures()
call writefile(repeat(["Sun is shining"], 30), "Xsign") call writefile(repeat(["Sun is shining"], 30), "Xsign", 'D')
edit Xsign edit Xsign
call test_alloc_fail(GetAllocId('sign_getdefined'), 0, 0) call test_alloc_fail(GetAllocId('sign_getdefined'), 0, 0)
@@ -1632,7 +1624,6 @@ func Test_sign_memfailures()
call sign_unplace('*') call sign_unplace('*')
call sign_undefine() call sign_undefine()
enew | only enew | only
call delete("Xsign")
endfunc endfunc
" Test for auto-adjusting the line number of a placed sign. " Test for auto-adjusting the line number of a placed sign.
@@ -1789,7 +1780,7 @@ func Test_sign_cursor_position()
redraw redraw
sign place 10 line=2 name=s1 sign place 10 line=2 name=s1
END END
call writefile(lines, 'XtestSigncolumn') call writefile(lines, 'XtestSigncolumn', 'D')
let buf = RunVimInTerminal('-S XtestSigncolumn', {'rows': 6}) let buf = RunVimInTerminal('-S XtestSigncolumn', {'rows': 6})
call VerifyScreenDump(buf, 'Test_sign_cursor_1', {}) call VerifyScreenDump(buf, 'Test_sign_cursor_1', {})
@@ -1823,7 +1814,6 @@ func Test_sign_cursor_position()
" clean up " clean up
call StopVimInTerminal(buf) call StopVimInTerminal(buf)
call delete('XtestSigncolumn')
endfunc endfunc
" Return the 'len' characters in screen starting from (row,col) " Return the 'len' characters in screen starting from (row,col)
@@ -1942,7 +1932,7 @@ endfunc
" Test for managing multiple signs using the sign functions " Test for managing multiple signs using the sign functions
func Test_sign_funcs_multi() func Test_sign_funcs_multi()
call writefile(repeat(["Sun is shining"], 30), "Xsign") call writefile(repeat(["Sun is shining"], 30), "Xsign", 'D')
edit Xsign edit Xsign
let bnum = bufnr('') let bnum = bufnr('')
@@ -2054,7 +2044,6 @@ func Test_sign_funcs_multi()
call sign_unplace('*') call sign_unplace('*')
call sign_undefine() call sign_undefine()
enew! enew!
call delete("Xsign")
endfunc endfunc
func Test_sign_null_list() func Test_sign_null_list()

View File

@@ -1520,11 +1520,10 @@ func Test_sort_with_no_last_search_pat()
call writefile(v:errors, 'Xresult') call writefile(v:errors, 'Xresult')
qall! qall!
[SCRIPT] [SCRIPT]
call writefile(lines, 'Xscript') call writefile(lines, 'Xscript', 'D')
if RunVim([], [], '--clean -S Xscript') if RunVim([], [], '--clean -S Xscript')
call assert_equal([], readfile('Xresult')) call assert_equal([], readfile('Xresult'))
endif endif
call delete('Xscript')
call delete('Xresult') call delete('Xresult')
endfunc endfunc

View File

@@ -51,12 +51,10 @@ endfunc
" When deleting a file and immediately creating a new one the inode may be " When deleting a file and immediately creating a new one the inode may be
" recycled. Vim should not recognize it as the same script. " recycled. Vim should not recognize it as the same script.
func Test_different_script() func Test_different_script()
call writefile(['let s:var = "asdf"'], 'XoneScript') call writefile(['let s:var = "asdf"'], 'XoneScript', 'D')
source XoneScript source XoneScript
call delete('XoneScript') call writefile(['let g:var = s:var'], 'XtwoScript', 'D')
call writefile(['let g:var = s:var'], 'XtwoScript')
call assert_fails('source XtwoScript', 'E121:') call assert_fails('source XtwoScript', 'E121:')
call delete('XtwoScript')
endfunc endfunc
" When sourcing a vim script, shebang should be ignored. " When sourcing a vim script, shebang should be ignored.

View File

@@ -43,7 +43,7 @@ func Test_source_ctrl_v()
\ "map __3 asd\<C-V>\<C-V>", \ "map __3 asd\<C-V>\<C-V>",
\ "map __4 asd\<C-V>\<C-V>\<C-V>", \ "map __4 asd\<C-V>\<C-V>\<C-V>",
\ "map __5 asd\<C-V>\<C-V>\<C-V>", \ "map __5 asd\<C-V>\<C-V>\<C-V>",
\ ], 'Xtestfile') \ ], 'Xtestfile', 'D')
source Xtestfile source Xtestfile
enew! enew!
exe "normal __1\<Esc>\<Esc>__2\<Esc>__3\<Esc>\<Esc>__4\<Esc>__5\<Esc>" exe "normal __1\<Esc>\<Esc>__2\<Esc>__3\<Esc>\<Esc>__4\<Esc>__5\<Esc>"
@@ -53,7 +53,6 @@ func Test_source_ctrl_v()
\ getline(1, 2)) \ getline(1, 2))
enew! enew!
call delete('Xtestfile')
unmap __1 unmap __1
unmap __2 unmap __2
unmap __3 unmap __3

View File

@@ -762,8 +762,8 @@ endfunc
func Test_zz_sal_and_addition() func Test_zz_sal_and_addition()
set enc=latin1 set enc=latin1
set spellfile= set spellfile=
call writefile(g:test_data_dic1, "Xtest.dic") call writefile(g:test_data_dic1, "Xtest.dic", 'D')
call writefile(g:test_data_aff_sal, "Xtest.aff") call writefile(g:test_data_aff_sal, "Xtest.aff", 'D')
mkspell! Xtest Xtest mkspell! Xtest Xtest
set spl=Xtest.latin1.spl spell set spl=Xtest.latin1.spl spell
call assert_equal('kbltykk', soundfold('goobledygoook')) call assert_equal('kbltykk', soundfold('goobledygoook'))
@@ -771,7 +771,7 @@ func Test_zz_sal_and_addition()
call assert_equal('*fls kswts tl', soundfold('oeverloos gezwets edale')) call assert_equal('*fls kswts tl', soundfold('oeverloos gezwets edale'))
"also use an addition file "also use an addition file
call writefile(["/regions=usgbnz", "elequint/2", "elekwint/3"], "Xtest.latin1.add") call writefile(["/regions=usgbnz", "elequint/2", "elekwint/3"], "Xtest.latin1.add", 'D')
mkspell! Xtest.latin1.add.spl Xtest.latin1.add mkspell! Xtest.latin1.add.spl Xtest.latin1.add
bwipe! bwipe!
@@ -808,10 +808,9 @@ endfunc
func Test_region_error() func Test_region_error()
messages clear messages clear
call writefile(["/regions=usgbnz", "elequint/0"], "Xtest.latin1.add") call writefile(["/regions=usgbnz", "elequint/0"], "Xtest.latin1.add", 'D')
mkspell! Xtest.latin1.add.spl Xtest.latin1.add mkspell! Xtest.latin1.add.spl Xtest.latin1.add
call assert_match('Invalid region nr in Xtest.latin1.add line 2: 0', execute('messages')) call assert_match('Invalid region nr in Xtest.latin1.add line 2: 0', execute('messages'))
call delete('Xtest.latin1.add')
call delete('Xtest.latin1.add.spl') call delete('Xtest.latin1.add.spl')
endfunc endfunc

View File

@@ -726,8 +726,8 @@ endfunc
" Test with SAL instead of SOFO items; test automatic reloading " Test with SAL instead of SOFO items; test automatic reloading
func Test_spell_sal_and_addition() func Test_spell_sal_and_addition()
set spellfile= set spellfile=
call writefile(g:test_data_dic1, "Xtest.dic") call writefile(g:test_data_dic1, "Xtest.dic", 'D')
call writefile(g:test_data_aff_sal, "Xtest.aff") call writefile(g:test_data_aff_sal, "Xtest.aff", 'D')
mkspell! Xtest Xtest mkspell! Xtest Xtest
set spl=Xtest.utf-8.spl spell set spl=Xtest.utf-8.spl spell
call assert_equal('kbltykk', soundfold('goobledygoook')) call assert_equal('kbltykk', soundfold('goobledygoook'))
@@ -735,7 +735,7 @@ func Test_spell_sal_and_addition()
call assert_equal('*fls kswts tl', soundfold('oeverloos gezwets edale')) call assert_equal('*fls kswts tl', soundfold('oeverloos gezwets edale'))
"also use an addition file "also use an addition file
call writefile(["/regions=usgbnz", "elequint/2", "elekwint/3"], "Xtest.utf-8.add") call writefile(["/regions=usgbnz", "elequint/2", "elekwint/3"], "Xtest.utf-8.add", 'D')
mkspell! Xtest.utf-8.add.spl Xtest.utf-8.add mkspell! Xtest.utf-8.add.spl Xtest.utf-8.add
bwipe! bwipe!

View File

@@ -212,7 +212,7 @@ endfunc
" The spell file format is described in spellfile.c " The spell file format is described in spellfile.c
func Test_spellfile_format_error() func Test_spellfile_format_error()
let save_rtp = &rtp let save_rtp = &rtp
call mkdir('Xtest/spell', 'p') call mkdir('Xtest/spell', 'pR')
let splfile = './Xtest/spell/Xtest.utf-8.spl' let splfile = './Xtest/spell/Xtest.utf-8.spl'
" empty spell file " empty spell file
@@ -384,13 +384,12 @@ func Test_spellfile_format_error()
call Spellfile_Test(0zFF00000000000000000000000201010000, 'E759:') call Spellfile_Test(0zFF00000000000000000000000201010000, 'E759:')
let &rtp = save_rtp let &rtp = save_rtp
call delete('Xtest', 'rf')
endfunc endfunc
" Test for format errors in suggest file " Test for format errors in suggest file
func Test_sugfile_format_error() func Test_sugfile_format_error()
let save_rtp = &rtp let save_rtp = &rtp
call mkdir('Xtest/spell', 'p') call mkdir('Xtest/spell', 'pR')
let splfile = './Xtest/spell/Xtest.utf-8.spl' let splfile = './Xtest/spell/Xtest.utf-8.spl'
let sugfile = './Xtest/spell/Xtest.utf-8.sug' let sugfile = './Xtest/spell/Xtest.utf-8.sug'
@@ -473,7 +472,6 @@ func Test_sugfile_format_error()
set nospell spelllang& set nospell spelllang&
let &rtp = save_rtp let &rtp = save_rtp
call delete('Xtest', 'rf')
endfunc endfunc
" Test for using :mkspell to create a spell file from a list of words " Test for using :mkspell to create a spell file from a list of words
@@ -486,7 +484,7 @@ func Test_wordlist_dic()
/encoding=latin1 /encoding=latin1
example example
[END] [END]
call writefile(lines, 'Xwordlist.dic') call writefile(lines, 'Xwordlist.dic', 'D')
let output = execute('mkspell Xwordlist.spl Xwordlist.dic') let output = execute('mkspell Xwordlist.spl Xwordlist.dic')
call assert_match('Duplicate /encoding= line ignored in Xwordlist.dic line 4: /encoding=latin1', output) call assert_match('Duplicate /encoding= line ignored in Xwordlist.dic line 4: /encoding=latin1', output)
@@ -559,7 +557,6 @@ func Test_wordlist_dic()
call assert_match('Compressed keep-case:', output) call assert_match('Compressed keep-case:', output)
call delete('Xwordlist.spl') call delete('Xwordlist.spl')
call delete('Xwordlist.dic')
endfunc endfunc
" Test for the :mkspell command " Test for the :mkspell command
@@ -600,8 +597,8 @@ func Test_aff_file_format_error()
CheckNotMSWindows CheckNotMSWindows
" No word count in .dic file " No word count in .dic file
call writefile([], 'Xtest.dic') call writefile([], 'Xtest.dic', 'D')
call writefile([], 'Xtest.aff') call writefile([], 'Xtest.aff', 'D')
call assert_fails('mkspell! Xtest.spl Xtest', 'E760:') call assert_fails('mkspell! Xtest.spl Xtest', 'E760:')
" create a .dic file for the tests below " create a .dic file for the tests below
@@ -822,20 +819,14 @@ func Test_aff_file_format_error()
" use multiple .aff files with different values for COMPOUNDWORDMAX and " use multiple .aff files with different values for COMPOUNDWORDMAX and
" MIDWORD (number and string) " MIDWORD (number and string)
call writefile(['1', 'world'], 'Xtest_US.dic') call writefile(['1', 'world'], 'Xtest_US.dic', 'D')
call writefile(['1', 'world'], 'Xtest_CA.dic') call writefile(['1', 'world'], 'Xtest_CA.dic', 'D')
call writefile(["COMPOUNDWORDMAX 3", "MIDWORD '-"], 'Xtest_US.aff') call writefile(["COMPOUNDWORDMAX 3", "MIDWORD '-"], 'Xtest_US.aff', 'D')
call writefile(["COMPOUNDWORDMAX 4", "MIDWORD '="], 'Xtest_CA.aff') call writefile(["COMPOUNDWORDMAX 4", "MIDWORD '="], 'Xtest_CA.aff', 'D')
let output = execute('mkspell! Xtest.spl Xtest_US Xtest_CA') let output = execute('mkspell! Xtest.spl Xtest_US Xtest_CA')
call assert_match('COMPOUNDWORDMAX value differs from what is used in another .aff file', output) call assert_match('COMPOUNDWORDMAX value differs from what is used in another .aff file', output)
call assert_match('MIDWORD value differs from what is used in another .aff file', output) call assert_match('MIDWORD value differs from what is used in another .aff file', output)
call delete('Xtest_US.dic')
call delete('Xtest_CA.dic')
call delete('Xtest_US.aff')
call delete('Xtest_CA.aff')
call delete('Xtest.dic')
call delete('Xtest.aff')
call delete('Xtest.spl') call delete('Xtest.spl')
call delete('Xtest.sug') call delete('Xtest.sug')
endfunc endfunc
@@ -855,8 +846,8 @@ func Test_spell_add_word()
endfunc endfunc
func Test_spellfile_verbose() func Test_spellfile_verbose()
call writefile(['1', 'one'], 'XtestVerbose.dic') call writefile(['1', 'one'], 'XtestVerbose.dic', 'D')
call writefile([], 'XtestVerbose.aff') call writefile([], 'XtestVerbose.aff', 'D')
mkspell! XtestVerbose-utf8.spl XtestVerbose mkspell! XtestVerbose-utf8.spl XtestVerbose
set spell set spell
@@ -869,15 +860,13 @@ func Test_spellfile_verbose()
call assert_notmatch('Reading spell file "XtestVerbose-utf8.spl"', a) call assert_notmatch('Reading spell file "XtestVerbose-utf8.spl"', a)
set spell& spelllang& set spell& spelllang&
call delete('XtestVerbose.dic')
call delete('XtestVerbose.aff')
call delete('XtestVerbose-utf8.spl') call delete('XtestVerbose-utf8.spl')
endfunc endfunc
" Test NOBREAK (see :help spell-NOBREAK) " Test NOBREAK (see :help spell-NOBREAK)
func Test_NOBREAK() func Test_NOBREAK()
call writefile(['3', 'one', 'two', 'three' ], 'XtestNOBREAK.dic') call writefile(['3', 'one', 'two', 'three' ], 'XtestNOBREAK.dic', 'D')
call writefile(['NOBREAK' ], 'XtestNOBREAK.aff') call writefile(['NOBREAK' ], 'XtestNOBREAK.aff', 'D')
mkspell! XtestNOBREAK-utf8.spl XtestNOBREAK mkspell! XtestNOBREAK-utf8.spl XtestNOBREAK
set spell spelllang=XtestNOBREAK-utf8.spl set spell spelllang=XtestNOBREAK-utf8.spl
@@ -899,8 +888,6 @@ func Test_NOBREAK()
bw! bw!
set spell& spelllang& set spell& spelllang&
call delete('XtestNOBREAK.dic')
call delete('XtestNOBREAK.aff')
call delete('XtestNOBREAK-utf8.spl') call delete('XtestNOBREAK-utf8.spl')
endfunc endfunc
@@ -910,11 +897,11 @@ func Test_spellfile_CHECKCOMPOUNDPATTERN()
\ 'one/c', \ 'one/c',
\ 'two/c', \ 'two/c',
\ 'three/c', \ 'three/c',
\ 'four'], 'XtestCHECKCOMPOUNDPATTERN.dic') \ 'four'], 'XtestCHECKCOMPOUNDPATTERN.dic', 'D')
" Forbid compound words where first word ends with 'wo' and second starts with 'on'. " Forbid compound words where first word ends with 'wo' and second starts with 'on'.
call writefile(['CHECKCOMPOUNDPATTERN 1', call writefile(['CHECKCOMPOUNDPATTERN 1',
\ 'CHECKCOMPOUNDPATTERN wo on', \ 'CHECKCOMPOUNDPATTERN wo on',
\ 'COMPOUNDFLAG c'], 'XtestCHECKCOMPOUNDPATTERN.aff') \ 'COMPOUNDFLAG c'], 'XtestCHECKCOMPOUNDPATTERN.aff', 'D')
mkspell! XtestCHECKCOMPOUNDPATTERN-utf8.spl XtestCHECKCOMPOUNDPATTERN mkspell! XtestCHECKCOMPOUNDPATTERN-utf8.spl XtestCHECKCOMPOUNDPATTERN
set spell spelllang=XtestCHECKCOMPOUNDPATTERN-utf8.spl set spell spelllang=XtestCHECKCOMPOUNDPATTERN-utf8.spl
@@ -938,8 +925,6 @@ func Test_spellfile_CHECKCOMPOUNDPATTERN()
endfor endfor
set spell& spelllang& set spell& spelllang&
call delete('XtestCHECKCOMPOUNDPATTERN.dic')
call delete('XtestCHECKCOMPOUNDPATTERN.aff')
call delete('XtestCHECKCOMPOUNDPATTERN-utf8.spl') call delete('XtestCHECKCOMPOUNDPATTERN-utf8.spl')
endfunc endfunc
@@ -948,15 +933,15 @@ func Test_spellfile_NOCOMPOUNDSUGS()
call writefile(['3', call writefile(['3',
\ 'one/c', \ 'one/c',
\ 'two/c', \ 'two/c',
\ 'three/c'], 'XtestNOCOMPOUNDSUGS.dic') \ 'three/c'], 'XtestNOCOMPOUNDSUGS.dic', 'D')
" pass 0 tests without NOCOMPOUNDSUGS, pass 1 tests with NOCOMPOUNDSUGS " pass 0 tests without NOCOMPOUNDSUGS, pass 1 tests with NOCOMPOUNDSUGS
for pass in [0, 1] for pass in [0, 1]
if pass == 0 if pass == 0
call writefile(['COMPOUNDFLAG c'], 'XtestNOCOMPOUNDSUGS.aff') call writefile(['COMPOUNDFLAG c'], 'XtestNOCOMPOUNDSUGS.aff', 'D')
else else
call writefile(['NOCOMPOUNDSUGS', call writefile(['NOCOMPOUNDSUGS',
\ 'COMPOUNDFLAG c'], 'XtestNOCOMPOUNDSUGS.aff') \ 'COMPOUNDFLAG c'], 'XtestNOCOMPOUNDSUGS.aff', 'D')
endif endif
mkspell! XtestNOCOMPOUNDSUGS-utf8.spl XtestNOCOMPOUNDSUGS mkspell! XtestNOCOMPOUNDSUGS-utf8.spl XtestNOCOMPOUNDSUGS
@@ -984,8 +969,6 @@ func Test_spellfile_NOCOMPOUNDSUGS()
endfor endfor
set spell& spelllang& set spell& spelllang&
call delete('XtestNOCOMPOUNDSUGS.dic')
call delete('XtestNOCOMPOUNDSUGS.aff')
call delete('XtestNOCOMPOUNDSUGS-utf8.spl') call delete('XtestNOCOMPOUNDSUGS-utf8.spl')
endfunc endfunc
@@ -998,8 +981,8 @@ func Test_spellfile_COMMON()
\ 'any', \ 'any',
\ 'tee', \ 'tee',
\ 'the', \ 'the',
\ 'ted'], 'XtestCOMMON.dic') \ 'ted'], 'XtestCOMMON.dic', 'D')
call writefile(['COMMON the and'], 'XtestCOMMON.aff') call writefile(['COMMON the and'], 'XtestCOMMON.aff', 'D')
mkspell! XtestCOMMON-utf8.spl XtestCOMMON mkspell! XtestCOMMON-utf8.spl XtestCOMMON
set spell spelllang=XtestCOMMON-utf8.spl set spell spelllang=XtestCOMMON-utf8.spl
@@ -1011,15 +994,13 @@ func Test_spellfile_COMMON()
call assert_equal(['the', 'tee'], spellsuggest('dhe', 2)) call assert_equal(['the', 'tee'], spellsuggest('dhe', 2))
set spell& spelllang& set spell& spelllang&
call delete('XtestCOMMON.dic')
call delete('XtestCOMMON.aff')
call delete('XtestCOMMON-utf8.spl') call delete('XtestCOMMON-utf8.spl')
endfunc endfunc
" Test NOSUGGEST (see :help spell-COMMON) " Test NOSUGGEST (see :help spell-COMMON)
func Test_spellfile_NOSUGGEST() func Test_spellfile_NOSUGGEST()
call writefile(['2', 'foo/X', 'fog'], 'XtestNOSUGGEST.dic') call writefile(['2', 'foo/X', 'fog'], 'XtestNOSUGGEST.dic', 'D')
call writefile(['NOSUGGEST X'], 'XtestNOSUGGEST.aff') call writefile(['NOSUGGEST X'], 'XtestNOSUGGEST.aff', 'D')
mkspell! XtestNOSUGGEST-utf8.spl XtestNOSUGGEST mkspell! XtestNOSUGGEST-utf8.spl XtestNOSUGGEST
set spell spelllang=XtestNOSUGGEST-utf8.spl set spell spelllang=XtestNOSUGGEST-utf8.spl
@@ -1037,8 +1018,6 @@ func Test_spellfile_NOSUGGEST()
call assert_equal(['fog'], spellsuggest('fogg', 1)) call assert_equal(['fog'], spellsuggest('fogg', 1))
set spell& spelllang& set spell& spelllang&
call delete('XtestNOSUGGEST.dic')
call delete('XtestNOSUGGEST.aff')
call delete('XtestNOSUGGEST-utf8.spl') call delete('XtestNOSUGGEST-utf8.spl')
endfunc endfunc
@@ -1047,7 +1026,7 @@ endfunc
func Test_spellfile_CIRCUMFIX() func Test_spellfile_CIRCUMFIX()
" Example taken verbatim from https://github.com/hunspell/hunspell/tree/master/tests " Example taken verbatim from https://github.com/hunspell/hunspell/tree/master/tests
call writefile(['1', call writefile(['1',
\ 'nagy/C po:adj'], 'XtestCIRCUMFIX.dic') \ 'nagy/C po:adj'], 'XtestCIRCUMFIX.dic', 'D')
call writefile(['# circumfixes: ~ obligate prefix/suffix combinations', call writefile(['# circumfixes: ~ obligate prefix/suffix combinations',
\ '# superlative in Hungarian: leg- (prefix) AND -bb (suffix)', \ '# superlative in Hungarian: leg- (prefix) AND -bb (suffix)',
\ '', \ '',
@@ -1062,7 +1041,7 @@ func Test_spellfile_CIRCUMFIX()
\ 'SFX C Y 3', \ 'SFX C Y 3',
\ 'SFX C 0 obb . is:COMPARATIVE', \ 'SFX C 0 obb . is:COMPARATIVE',
\ 'SFX C 0 obb/AX . is:SUPERLATIVE', \ 'SFX C 0 obb/AX . is:SUPERLATIVE',
\ 'SFX C 0 obb/BX . is:SUPERSUPERLATIVE'], 'XtestCIRCUMFIX.aff') \ 'SFX C 0 obb/BX . is:SUPERSUPERLATIVE'], 'XtestCIRCUMFIX.aff', 'D')
mkspell! XtestCIRCUMFIX-utf8.spl XtestCIRCUMFIX mkspell! XtestCIRCUMFIX-utf8.spl XtestCIRCUMFIX
set spell spelllang=XtestCIRCUMFIX-utf8.spl set spell spelllang=XtestCIRCUMFIX-utf8.spl
@@ -1081,8 +1060,6 @@ func Test_spellfile_CIRCUMFIX()
endfor endfor
set spell& spelllang& set spell& spelllang&
call delete('XtestCIRCUMFIX.dic')
call delete('XtestCIRCUMFIX.aff')
call delete('XtestCIRCUMFIX-utf8.spl') call delete('XtestCIRCUMFIX-utf8.spl')
endfunc endfunc
@@ -1094,12 +1071,12 @@ func Test_spellfile_SFX_strip()
\ 'SFX A are hiamo [cg]are', \ 'SFX A are hiamo [cg]are',
\ 'SFX A re mo iare', \ 'SFX A re mo iare',
\ 'SFX A re vamo are'], \ 'SFX A re vamo are'],
\ 'XtestSFX.aff') \ 'XtestSFX.aff', 'D')
" Examples of Italian verbs: " Examples of Italian verbs:
" - cantare = to sing " - cantare = to sing
" - cercare = to search " - cercare = to search
" - odiare = to hate " - odiare = to hate
call writefile(['3', 'cantare/A', 'cercare/A', 'odiare/A'], 'XtestSFX.dic') call writefile(['3', 'cantare/A', 'cercare/A', 'odiare/A'], 'XtestSFX.dic', 'D')
mkspell! XtestSFX-utf8.spl XtestSFX mkspell! XtestSFX-utf8.spl XtestSFX
set spell spelllang=XtestSFX-utf8.spl set spell spelllang=XtestSFX-utf8.spl
@@ -1123,8 +1100,6 @@ func Test_spellfile_SFX_strip()
call assert_equal(['odiamo'], spellsuggest('odiiamo', 1)) call assert_equal(['odiamo'], spellsuggest('odiiamo', 1))
set spell& spelllang& set spell& spelllang&
call delete('XtestSFX.dic')
call delete('XtestSFX.aff')
call delete('XtestSFX-utf8.spl') call delete('XtestSFX-utf8.spl')
endfunc endfunc
@@ -1133,7 +1108,7 @@ endfunc
func Test_init_spellfile() func Test_init_spellfile()
let save_rtp = &rtp let save_rtp = &rtp
let save_encoding = &encoding let save_encoding = &encoding
call mkdir('Xrtp/spell', 'p') call mkdir('Xrtp/spell', 'pR')
call writefile(['vim'], 'Xrtp/spell/Xtest.dic') call writefile(['vim'], 'Xrtp/spell/Xtest.dic')
silent mkspell Xrtp/spell/Xtest.utf-8.spl Xrtp/spell/Xtest.dic silent mkspell Xrtp/spell/Xtest.utf-8.spl Xrtp/spell/Xtest.dic
set runtimepath=./Xrtp set runtimepath=./Xrtp
@@ -1143,8 +1118,8 @@ func Test_init_spellfile()
call assert_equal('./Xrtp/spell/Xtest.utf-8.add', &spellfile) call assert_equal('./Xrtp/spell/Xtest.utf-8.add', &spellfile)
call assert_equal(['abc'], readfile('Xrtp/spell/Xtest.utf-8.add')) call assert_equal(['abc'], readfile('Xrtp/spell/Xtest.utf-8.add'))
call assert_true(filereadable('Xrtp/spell/Xtest.utf-8.spl')) call assert_true(filereadable('Xrtp/spell/Xtest.utf-8.spl'))
set spell& spelllang& spellfile& set spell& spelllang& spellfile&
call delete('Xrtp', 'rf')
let &encoding = save_encoding let &encoding = save_encoding
let &rtp = save_rtp let &rtp = save_rtp
%bw! %bw!
@@ -1170,12 +1145,10 @@ enddef
" this was using a NULL pointer " this was using a NULL pointer
func Test_mkspell_empty_dic() func Test_mkspell_empty_dic()
call writefile(['1'], 'XtestEmpty.dic') call writefile(['1'], 'XtestEmpty.dic', 'D')
call writefile(['SOFOFROM abcd', 'SOFOTO ABCD', 'SAL CIA X'], 'XtestEmpty.aff') call writefile(['SOFOFROM abcd', 'SOFOTO ABCD', 'SAL CIA X'], 'XtestEmpty.aff', 'D')
mkspell! XtestEmpty.spl XtestEmpty mkspell! XtestEmpty.spl XtestEmpty
call delete('XtestEmpty.dic')
call delete('XtestEmpty.aff')
call delete('XtestEmpty.spl') call delete('XtestEmpty.spl')
endfunc endfunc

View File

@@ -43,14 +43,14 @@ func Test_after_comes_later()
quit quit
[CODE] [CODE]
call mkdir('Xhere/plugin', 'p') call mkdir('Xhere/plugin', 'pR')
call writefile(['let g:sequence .= "here "'], 'Xhere/plugin/here.vim') call writefile(['let g:sequence .= "here "'], 'Xhere/plugin/here.vim')
call mkdir('Xanother/plugin', 'p') call mkdir('Xanother/plugin', 'pR')
call writefile(['let g:sequence .= "another "'], 'Xanother/plugin/another.vim') call writefile(['let g:sequence .= "another "'], 'Xanother/plugin/another.vim')
call mkdir('Xhere/pack/foo/start/foobar/plugin', 'p') call mkdir('Xhere/pack/foo/start/foobar/plugin', 'p')
call writefile(['let g:sequence .= "pack "'], 'Xhere/pack/foo/start/foobar/plugin/foo.vim') call writefile(['let g:sequence .= "pack "'], 'Xhere/pack/foo/start/foobar/plugin/foo.vim')
call mkdir('Xafter/plugin', 'p') call mkdir('Xafter/plugin', 'pR')
call writefile(['let g:sequence .= "after "'], 'Xafter/plugin/later.vim') call writefile(['let g:sequence .= "after "'], 'Xafter/plugin/later.vim')
if RunVim(before, after, '') if RunVim(before, after, '')
@@ -72,9 +72,6 @@ func Test_after_comes_later()
call delete('Xtestout') call delete('Xtestout')
call delete('Xsequence') call delete('Xsequence')
call delete('Xhere', 'rf')
call delete('Xanother', 'rf')
call delete('Xafter', 'rf')
endfunc endfunc
func Test_pack_in_rtp_when_plugins_run() func Test_pack_in_rtp_when_plugins_run()
@@ -92,7 +89,7 @@ func Test_pack_in_rtp_when_plugins_run()
let after = [ let after = [
\ 'quit', \ 'quit',
\ ] \ ]
call mkdir('Xhere/plugin', 'p') call mkdir('Xhere/plugin', 'pR')
call writefile(['redir! > Xtestout', 'silent set runtimepath?', 'silent! call foo#Trigger()', 'redir END'], 'Xhere/plugin/here.vim') call writefile(['redir! > Xtestout', 'silent set runtimepath?', 'silent! call foo#Trigger()', 'redir END'], 'Xhere/plugin/here.vim')
call mkdir('Xhere/pack/foo/start/foobar/autoload', 'p') call mkdir('Xhere/pack/foo/start/foobar/autoload', 'p')
call writefile(['function! foo#Trigger()', 'echo "autoloaded foo"', 'endfunction'], 'Xhere/pack/foo/start/foobar/autoload/foo.vim') call writefile(['function! foo#Trigger()', 'echo "autoloaded foo"', 'endfunction'], 'Xhere/pack/foo/start/foobar/autoload/foo.vim')
@@ -105,7 +102,6 @@ func Test_pack_in_rtp_when_plugins_run()
endif endif
call delete('Xtestout') call delete('Xtestout')
call delete('Xhere', 'rf')
endfunc endfunc
func Test_help_arg() func Test_help_arg()
@@ -228,7 +224,6 @@ func Test_o_arg()
call assert_equal('foo', bn1) call assert_equal('foo', bn1)
call assert_equal('bar', bn2) call assert_equal('bar', bn2)
endif endif
call delete('Xtestout') call delete('Xtestout')
endfunc endfunc
@@ -303,7 +298,7 @@ func Test_q_arg()
return 666 return 666
} }
END END
call writefile(lines, 'Xbadfile.c') call writefile(lines, 'Xbadfile.c', 'D')
let after =<< trim [CODE] let after =<< trim [CODE]
call writefile([&errorfile, string(getpos("."))], "XtestoutQarg") call writefile([&errorfile, string(getpos("."))], "XtestoutQarg")
@@ -314,7 +309,7 @@ func Test_q_arg()
" Test with default argument '-q'. " Test with default argument '-q'.
call assert_equal('errors.err', &errorfile) call assert_equal('errors.err', &errorfile)
call writefile(["Xbadfile.c:4:12: error: expected ';' before '}' token"], 'errors.err') call writefile(["Xbadfile.c:4:12: error: expected ';' before '}' token"], 'errors.err', 'D')
if RunVim([], after, '-q') if RunVim([], after, '-q')
let lines = readfile('XtestoutQarg') let lines = readfile('XtestoutQarg')
call assert_equal(['errors.err', call assert_equal(['errors.err',
@@ -323,10 +318,9 @@ func Test_q_arg()
\ lines) \ lines)
endif endif
call delete('XtestoutQarg') call delete('XtestoutQarg')
call delete('errors.err')
" Test with explicit argument '-q XerrorsQarg' (with space). " Test with explicit argument '-q XerrorsQarg' (with space).
call writefile(["Xbadfile.c:4:12: error: expected ';' before '}' token"], 'XerrorsQarg') call writefile(["Xbadfile.c:4:12: error: expected ';' before '}' token"], 'XerrorsQarg', 'D')
if RunVim([], after, '-q XerrorsQarg') if RunVim([], after, '-q XerrorsQarg')
let lines = readfile('XtestoutQarg') let lines = readfile('XtestoutQarg')
call assert_equal(['XerrorsQarg', call assert_equal(['XerrorsQarg',
@@ -349,9 +343,7 @@ func Test_q_arg()
let out = system(GetVimCommand() .. ' -q xyz.err') let out = system(GetVimCommand() .. ' -q xyz.err')
call assert_equal(3, v:shell_error) call assert_equal(3, v:shell_error)
call delete('Xbadfile.c')
call delete('XtestoutQarg') call delete('XtestoutQarg')
call delete('XerrorsQarg')
endfunc endfunc
" Test the -V[N]{filename} argument to set the 'verbose' option to N " Test the -V[N]{filename} argument to set the 'verbose' option to N
@@ -400,7 +392,7 @@ endfunc
" Test the -A, -F and -H arguments (Arabic, Farsi and Hebrew modes). " Test the -A, -F and -H arguments (Arabic, Farsi and Hebrew modes).
func Test_A_F_H_arg() func Test_A_F_H_arg()
let after =<< trim [CODE] let after =<< trim [CODE]
call writefile([&rightleft, &arabic, &fkmap, &hkmap], "Xtestout") call writefile([&rightleft, &arabic, &fkmap, &hkmap], "Xtestout", 'D')
qall qall
[CODE] [CODE]
@@ -420,8 +412,6 @@ func Test_A_F_H_arg()
let lines = readfile('Xtestout') let lines = readfile('Xtestout')
call assert_equal(['1', '0', '0', '1'], lines) call assert_equal(['1', '0', '0', '1'], lines)
endif endif
call delete('Xtestout')
endfunc endfunc
" Test the --echo-wid argument (for GTK GUI only). " Test the --echo-wid argument (for GTK GUI only).
@@ -799,7 +789,7 @@ endfunc
func Test_zzz_startinsert() func Test_zzz_startinsert()
" Test :startinsert " Test :startinsert
call writefile(['123456'], 'Xtestout') call writefile(['123456'], 'Xtestout', 'D')
let after =<< trim [CODE] let after =<< trim [CODE]
:startinsert :startinsert
call feedkeys("foobar\<c-o>:wq\<cr>","t") call feedkeys("foobar\<c-o>:wq\<cr>","t")
@@ -820,7 +810,6 @@ func Test_zzz_startinsert()
let lines = readfile('Xtestout') let lines = readfile('Xtestout')
call assert_equal(['123456foobar'], lines) call assert_equal(['123456foobar'], lines)
endif endif
call delete('Xtestout')
endfunc endfunc
func Test_issue_3969() func Test_issue_3969()
@@ -898,8 +887,8 @@ func Test_t_arg()
\ "first\tXfile1\t/^ \\zsfirst$/", \ "first\tXfile1\t/^ \\zsfirst$/",
\ "second\tXfile1\t/^ \\zssecond$/", \ "second\tXfile1\t/^ \\zssecond$/",
\ "third\tXfile1\t/^ \\zsthird$/"], \ "third\tXfile1\t/^ \\zsthird$/"],
\ 'Xtags') \ 'Xtags', 'D')
call writefile([' first', ' second', ' third'], 'Xfile1') call writefile([' first', ' second', ' third'], 'Xfile1', 'D')
for t_arg in ['-t second', '-tsecond'] for t_arg in ['-t second', '-tsecond']
if RunVim(before, after, t_arg) if RunVim(before, after, t_arg)
@@ -907,9 +896,6 @@ func Test_t_arg()
call delete('Xtestout') call delete('Xtestout')
endif endif
endfor endfor
call delete('Xtags')
call delete('Xfile1')
endfunc endfunc
" Test the '-T' argument which sets the 'term' option. " Test the '-T' argument which sets the 'term' option.
@@ -1006,7 +992,7 @@ func Test_missing_vimrc()
call assert_match('^E282:', v:errmsg) call assert_match('^E282:', v:errmsg)
call writefile(v:errors, 'Xtestout') call writefile(v:errors, 'Xtestout')
[CODE] [CODE]
call writefile(after, 'Xafter') call writefile(after, 'Xafter', 'D')
let cmd = GetVimCommandCleanTerm() . ' -u Xvimrc_missing -S Xafter' let cmd = GetVimCommandCleanTerm() . ' -u Xvimrc_missing -S Xafter'
let buf = term_start(cmd, {'term_rows' : 10}) let buf = term_start(cmd, {'term_rows' : 10})
@@ -1017,7 +1003,7 @@ func Test_missing_vimrc()
call WaitForAssert({-> assert_match(':', term_getline(buf, 10))}) call WaitForAssert({-> assert_match(':', term_getline(buf, 10))})
call StopVimInTerminal(buf) call StopVimInTerminal(buf)
call assert_equal([], readfile('Xtestout')) call assert_equal([], readfile('Xtestout'))
call delete('Xafter')
call delete('Xtestout') call delete('Xtestout')
endfunc endfunc
@@ -1029,13 +1015,13 @@ func Test_VIMINIT()
call writefile(v:errors, 'Xtestout') call writefile(v:errors, 'Xtestout')
qall qall
[CODE] [CODE]
call writefile(after, 'Xafter') call writefile(after, 'Xafter', 'D')
let cmd = GetVimProg() . ' --not-a-term -S Xafter --cmd "set enc=utf8"' let cmd = GetVimProg() . ' --not-a-term -S Xafter --cmd "set enc=utf8"'
call setenv('VIMINIT', 'let viminit_found="yes"') call setenv('VIMINIT', 'let viminit_found="yes"')
exe "silent !" . cmd exe "silent !" . cmd
call assert_equal([], readfile('Xtestout')) call assert_equal([], readfile('Xtestout'))
call delete('Xtestout') call delete('Xtestout')
call delete('Xafter')
endfunc endfunc
" Test for using the $EXINIT environment variable " Test for using the $EXINIT environment variable
@@ -1046,13 +1032,13 @@ func Test_EXINIT()
call writefile(v:errors, 'Xtestout') call writefile(v:errors, 'Xtestout')
qall qall
[CODE] [CODE]
call writefile(after, 'Xafter') call writefile(after, 'Xafter', 'D')
let cmd = GetVimProg() . ' --not-a-term -S Xafter --cmd "set enc=utf8"' let cmd = GetVimProg() . ' --not-a-term -S Xafter --cmd "set enc=utf8"'
call setenv('EXINIT', 'let exinit_found="yes"') call setenv('EXINIT', 'let exinit_found="yes"')
exe "silent !" . cmd exe "silent !" . cmd
call assert_equal([], readfile('Xtestout')) call assert_equal([], readfile('Xtestout'))
call delete('Xtestout') call delete('Xtestout')
call delete('Xafter')
endfunc endfunc
" Test for using the 'exrc' option " Test for using the 'exrc' option
@@ -1064,13 +1050,12 @@ func Test_exrc()
call writefile(v:errors, 'Xtestout') call writefile(v:errors, 'Xtestout')
qall qall
[CODE] [CODE]
call mkdir('Xrcdir') call mkdir('Xrcdir', 'R')
call writefile(['let exrc_found=37'], 'Xrcdir/.exrc') call writefile(['let exrc_found=37'], 'Xrcdir/.exrc')
call writefile(after, 'Xrcdir/Xafter') call writefile(after, 'Xrcdir/Xafter')
let cmd = GetVimProg() . ' --not-a-term -S Xafter --cmd "cd Xrcdir" --cmd "set enc=utf8 exrc secure"' let cmd = GetVimProg() . ' --not-a-term -S Xafter --cmd "cd Xrcdir" --cmd "set enc=utf8 exrc secure"'
exe "silent !" . cmd exe "silent !" . cmd
call assert_equal([], readfile('Xrcdir/Xtestout')) call assert_equal([], readfile('Xrcdir/Xtestout'))
call delete('Xrcdir', 'rf')
endfunc endfunc
" Test for starting Vim with a non-terminal as input/output " Test for starting Vim with a non-terminal as input/output
@@ -1138,7 +1123,7 @@ func Test_w_arg()
" Can't catch the output of gvim. " Can't catch the output of gvim.
CheckNotGui CheckNotGui
call writefile(["iVim Editor\<Esc>:q!\<CR>"], 'Xscriptin', 'b') call writefile(["iVim Editor\<Esc>:q!\<CR>"], 'Xscriptin', 'bD')
if RunVim([], [], '-s Xscriptin -w Xscriptout') if RunVim([], [], '-s Xscriptin -w Xscriptout')
call assert_equal(["iVim Editor\e:q!\r"], readfile('Xscriptout')) call assert_equal(["iVim Editor\e:q!\r"], readfile('Xscriptout'))
call delete('Xscriptout') call delete('Xscriptout')
@@ -1162,7 +1147,6 @@ func Test_w_arg()
call delete('Xresult') call delete('Xresult')
endif endif
endfor endfor
call delete('Xscriptin')
endfunc endfunc
" Test for the "-s scriptin" argument " Test for the "-s scriptin" argument
@@ -1174,10 +1158,9 @@ func Test_s_arg()
let m = system(GetVimCommand() .. " -s abcxyz") let m = system(GetVimCommand() .. " -s abcxyz")
call assert_equal("Cannot open for reading: \"abcxyz\"\n", m) call assert_equal("Cannot open for reading: \"abcxyz\"\n", m)
call writefile([], 'Xinput') call writefile([], 'Xinput', 'D')
let m = system(GetVimCommand() .. " -s Xinput -s Xinput") let m = system(GetVimCommand() .. " -s Xinput -s Xinput")
call assert_equal("Attempt to open script file again: \"-s Xinput\"\n", m) call assert_equal("Attempt to open script file again: \"-s Xinput\"\n", m)
call delete('Xinput')
endfunc endfunc
" Test for the "-n" (no swap file) argument " Test for the "-n" (no swap file) argument
@@ -1252,7 +1235,7 @@ endfunc
func Test_progname() func Test_progname()
CheckUnix CheckUnix
call mkdir('Xprogname', 'p') call mkdir('Xprogname', 'pD')
call writefile(['silent !date', call writefile(['silent !date',
\ 'call writefile([mode(1), ' \ 'call writefile([mode(1), '
\ .. '&insertmode, &diff, &readonly, &updatecount, ' \ .. '&insertmode, &diff, &readonly, &updatecount, '
@@ -1324,12 +1307,11 @@ func Test_progname()
endfor endfor
call delete('Xprogname_after') call delete('Xprogname_after')
call delete('Xprogname', 'd')
endfunc endfunc
" Test for doing a write from .vimrc " Test for doing a write from .vimrc
func Test_write_in_vimrc() func Test_write_in_vimrc()
call writefile(['silent! write'], 'Xvimrc') call writefile(['silent! write'], 'Xvimrc', 'D')
let after =<< trim [CODE] let after =<< trim [CODE]
call assert_match('E32: ', v:errmsg) call assert_match('E32: ', v:errmsg)
call writefile(v:errors, 'Xtestout') call writefile(v:errors, 'Xtestout')
@@ -1339,7 +1321,6 @@ func Test_write_in_vimrc()
call assert_equal([], readfile('Xtestout')) call assert_equal([], readfile('Xtestout'))
call delete('Xtestout') call delete('Xtestout')
endif endif
call delete('Xvimrc')
endfunc endfunc
func Test_echo_true_in_cmd() func Test_echo_true_in_cmd()
@@ -1350,11 +1331,11 @@ func Test_echo_true_in_cmd()
call writefile(['done'], 'Xresult') call writefile(['done'], 'Xresult')
quit quit
END END
call writefile(lines, 'Xscript') call writefile(lines, 'Xscript', 'D')
if RunVim([], [], '--cmd "source Xscript"') if RunVim([], [], '--cmd "source Xscript"')
call assert_equal(['done'], readfile('Xresult')) call assert_equal(['done'], readfile('Xresult'))
endif endif
call delete('Xscript')
call delete('Xresult') call delete('Xresult')
endfunc endfunc
@@ -1365,11 +1346,11 @@ func Test_rename_buffer_on_startup()
call writefile(['done'], 'Xresult') call writefile(['done'], 'Xresult')
qa! qa!
END END
call writefile(lines, 'Xscript') call writefile(lines, 'Xscript', 'D')
if RunVim([], [], "--clean -e -s --cmd 'file x|new|file x' --cmd 'so Xscript'") if RunVim([], [], "--clean -e -s --cmd 'file x|new|file x' --cmd 'so Xscript'")
call assert_equal(['done'], readfile('Xresult')) call assert_equal(['done'], readfile('Xresult'))
endif endif
call delete('Xscript')
call delete('Xresult') call delete('Xresult')
endfunc endfunc

View File

@@ -6,7 +6,7 @@ source screendump.vim
func Test_read_stdin_utf8() func Test_read_stdin_utf8()
let linesin = ['テスト', '€ÀÈÌÒÙ'] let linesin = ['テスト', '€ÀÈÌÒÙ']
call writefile(linesin, 'Xtestin') call writefile(linesin, 'Xtestin', 'D')
let before = [ let before = [
\ 'set enc=utf-8', \ 'set enc=utf-8',
\ 'set fencs=cp932,utf-8', \ 'set fencs=cp932,utf-8',
@@ -26,8 +26,8 @@ func Test_read_stdin_utf8()
else else
call assert_equal('', 'RunVimPiped failed.') call assert_equal('', 'RunVimPiped failed.')
endif endif
call delete('Xtestout') call delete('Xtestout')
call delete('Xtestin')
endfunc endfunc
func Test_read_fifo_utf8() func Test_read_fifo_utf8()
@@ -41,7 +41,7 @@ func Test_read_fifo_utf8()
throw 'Skipped: bash or zsh is required' throw 'Skipped: bash or zsh is required'
endif endif
let linesin = ['テスト', '€ÀÈÌÒÙ'] let linesin = ['テスト', '€ÀÈÌÒÙ']
call writefile(linesin, 'Xtestin') call writefile(linesin, 'Xtestin', 'D')
let before = [ let before = [
\ 'set enc=utf-8', \ 'set enc=utf-8',
\ 'set fencs=cp932,utf-8', \ 'set fencs=cp932,utf-8',
@@ -56,8 +56,8 @@ func Test_read_fifo_utf8()
else else
call assert_equal('', 'RunVim failed.') call assert_equal('', 'RunVim failed.')
endif endif
call delete('Xtestout') call delete('Xtestout')
call delete('Xtestin')
endfunc endfunc
func Test_detect_ambiwidth() func Test_detect_ambiwidth()
@@ -69,14 +69,13 @@ func Test_detect_ambiwidth()
\ 'set ambiwidth=double', \ 'set ambiwidth=double',
\ 'call test_option_not_set("ambiwidth")', \ 'call test_option_not_set("ambiwidth")',
\ 'redraw', \ 'redraw',
\ ], 'Xscript') \ ], 'Xscript', 'D')
let buf = RunVimInTerminal('-S Xscript', #{keep_t_u7: 1}) let buf = RunVimInTerminal('-S Xscript', #{keep_t_u7: 1})
call TermWait(buf) call TermWait(buf)
call term_sendkeys(buf, "S\<C-R>=&ambiwidth\<CR>\<Esc>") call term_sendkeys(buf, "S\<C-R>=&ambiwidth\<CR>\<Esc>")
call WaitForAssert({-> assert_match('single', term_getline(buf, 1))}) call WaitForAssert({-> assert_match('single', term_getline(buf, 1))})
call StopVimInTerminal(buf) call StopVimInTerminal(buf)
call delete('Xscript')
endfunc endfunc
" vim: shiftwidth=2 sts=2 expandtab " vim: shiftwidth=2 sts=2 expandtab

View File

@@ -63,7 +63,7 @@ func Test_checktime()
let fname = 'Xtest.tmp' let fname = 'Xtest.tmp'
let fl = ['Hello World!'] let fl = ['Hello World!']
call writefile(fl, fname) call writefile(fl, fname, 'D')
set autoread set autoread
exec 'e' fname exec 'e' fname
call SleepForTimestamp() call SleepForTimestamp()
@@ -72,8 +72,6 @@ func Test_checktime()
call writefile(fl, fname) call writefile(fl, fname)
checktime checktime
call assert_equal(fl[0], getline(1)) call assert_equal(fl[0], getline(1))
call delete(fname)
endfunc endfunc
func Test_checktime_fast() func Test_checktime_fast()
@@ -82,7 +80,7 @@ func Test_checktime_fast()
let fname = 'Xtest.tmp' let fname = 'Xtest.tmp'
let fl = ['Hello World!'] let fl = ['Hello World!']
call writefile(fl, fname) call writefile(fl, fname, 'D')
set autoread set autoread
exec 'e' fname exec 'e' fname
let fl = readfile(fname) let fl = readfile(fname)
@@ -90,8 +88,6 @@ func Test_checktime_fast()
call writefile(fl, fname) call writefile(fl, fname)
checktime checktime
call assert_equal(fl[0], getline(1)) call assert_equal(fl[0], getline(1))
call delete(fname)
endfunc endfunc
func Test_autoread_fast() func Test_autoread_fast()
@@ -105,12 +101,10 @@ func Test_autoread_fast()
call setline(1, 'foo') call setline(1, 'foo')
w! w!
sleep 10m sleep 10m
call writefile(['bar'], 'Xautoread') call writefile(['bar'], 'Xautoread', 'D')
sleep 10m sleep 10m
checktime checktime
call assert_equal('bar', trim(getline(1))) call assert_equal('bar', trim(getline(1)))
call delete('Xautoread')
endfunc endfunc
func Test_autoread_file_deleted() func Test_autoread_file_deleted()

View File

@@ -470,14 +470,13 @@ func Test_statusline_removed_group()
set laststatus=2 set laststatus=2
let &statusline = '%#StatColorHi2#%(✓%#StatColorHi2#%) Q≡' let &statusline = '%#StatColorHi2#%(✓%#StatColorHi2#%) Q≡'
END END
call writefile(lines, 'XTest_statusline') call writefile(lines, 'XTest_statusline', 'D')
let buf = RunVimInTerminal('-S XTest_statusline', {'rows': 10, 'cols': 50}) let buf = RunVimInTerminal('-S XTest_statusline', {'rows': 10, 'cols': 50})
call VerifyScreenDump(buf, 'Test_statusline_1', {}) call VerifyScreenDump(buf, 'Test_statusline_1', {})
" clean up " clean up
call StopVimInTerminal(buf) call StopVimInTerminal(buf)
call delete('XTest_statusline')
endfunc endfunc
func Test_statusline_using_mode() func Test_statusline_using_mode()
@@ -488,7 +487,7 @@ func Test_statusline_using_mode()
split split
setlocal statusline=+%{mode()}+ setlocal statusline=+%{mode()}+
END END
call writefile(lines, 'XTest_statusline') call writefile(lines, 'XTest_statusline', 'D')
let buf = RunVimInTerminal('-S XTest_statusline', {'rows': 7, 'cols': 50}) let buf = RunVimInTerminal('-S XTest_statusline', {'rows': 7, 'cols': 50})
call VerifyScreenDump(buf, 'Test_statusline_mode_1', {}) call VerifyScreenDump(buf, 'Test_statusline_mode_1', {})
@@ -499,7 +498,6 @@ func Test_statusline_using_mode()
" clean up " clean up
call term_sendkeys(buf, "close\<CR>") call term_sendkeys(buf, "close\<CR>")
call StopVimInTerminal(buf) call StopVimInTerminal(buf)
call delete('XTest_statusline')
endfunc endfunc
func Test_statusline_after_split_vsplit() func Test_statusline_after_split_vsplit()
@@ -552,13 +550,12 @@ func Test_statusline_highlight_truncate()
hi! link User2 ErrorMsg hi! link User2 ErrorMsg
set statusline=%.5(%1*ABC%2*DEF%1*GHI%) set statusline=%.5(%1*ABC%2*DEF%1*GHI%)
END END
call writefile(lines, 'XTest_statusline') call writefile(lines, 'XTest_statusline', 'D')
let buf = RunVimInTerminal('-S XTest_statusline', {'rows': 6}) let buf = RunVimInTerminal('-S XTest_statusline', {'rows': 6})
call VerifyScreenDump(buf, 'Test_statusline_hl', {}) call VerifyScreenDump(buf, 'Test_statusline_hl', {})
call StopVimInTerminal(buf) call StopVimInTerminal(buf)
call delete('XTest_statusline')
endfunc endfunc
" vim: shiftwidth=2 sts=2 expandtab " vim: shiftwidth=2 sts=2 expandtab

View File

@@ -860,7 +860,7 @@ func Test_sub_with_no_last_pat()
call writefile(v:errors, 'Xresult') call writefile(v:errors, 'Xresult')
qall! qall!
[SCRIPT] [SCRIPT]
call writefile(lines, 'Xscript') call writefile(lines, 'Xscript', 'D')
if RunVim([], [], '--clean -S Xscript') if RunVim([], [], '--clean -S Xscript')
call assert_equal([], readfile('Xresult')) call assert_equal([], readfile('Xresult'))
endif endif
@@ -876,7 +876,6 @@ func Test_sub_with_no_last_pat()
call assert_equal([], readfile('Xresult')) call assert_equal([], readfile('Xresult'))
endif endif
call delete('Xscript')
call delete('Xresult') call delete('Xresult')
endfunc endfunc
@@ -1075,13 +1074,12 @@ func Test_sub_open_cmdline_win()
redir END redir END
qall! qall!
[SCRIPT] [SCRIPT]
call writefile(lines, 'Xscript') call writefile(lines, 'Xscript', 'D')
if RunVim([], [], '-u NONE -S Xscript') if RunVim([], [], '-u NONE -S Xscript')
call assert_match('E565: Not allowed to change text or change window', call assert_match('E565: Not allowed to change text or change window',
\ readfile('Xresult')->join('XX')) \ readfile('Xresult')->join('XX'))
endif endif
call delete('Xscript')
call delete('Xresult') call delete('Xresult')
endfunc endfunc

View File

@@ -16,7 +16,7 @@ func Test_swap_directory()
\ 'line 2 Abcdefghij', \ 'line 2 Abcdefghij',
\ 'line 3 Abcdefghij', \ 'line 3 Abcdefghij',
\ 'end of testfile'] \ 'end of testfile']
call writefile(content, 'Xtest1') call writefile(content, 'Xtest1', 'D')
" '.', swap file in the same directory as file " '.', swap file in the same directory as file
set dir=.,~ set dir=.,~
@@ -30,7 +30,7 @@ func Test_swap_directory()
" './dir', swap file in a directory relative to the file " './dir', swap file in a directory relative to the file
set dir=./Xtest2,.,~ set dir=./Xtest2,.,~
call mkdir("Xtest2") call mkdir("Xtest2", 'R')
edit Xtest1 edit Xtest1
call assert_equal([], glob(swfname, 1, 1, 1)) call assert_equal([], glob(swfname, 1, 1, 1))
let swfname = "Xtest2/Xtest1.swp" let swfname = "Xtest2/Xtest1.swp"
@@ -40,7 +40,7 @@ func Test_swap_directory()
" 'dir', swap file in directory relative to the current dir " 'dir', swap file in directory relative to the current dir
set dir=Xtest.je,~ set dir=Xtest.je,~
call mkdir("Xtest.je") call mkdir("Xtest.je", 'R')
call writefile(content, 'Xtest2/Xtest3') call writefile(content, 'Xtest2/Xtest3')
edit Xtest2/Xtest3 edit Xtest2/Xtest3
call assert_equal(["Xtest2/Xtest3"], glob("Xtest2/*", 1, 1, 1)) call assert_equal(["Xtest2/Xtest3"], glob("Xtest2/*", 1, 1, 1))
@@ -49,9 +49,6 @@ func Test_swap_directory()
call assert_equal([swfname], glob("Xtest.je/*", 1, 1, 1)) call assert_equal([swfname], glob("Xtest.je/*", 1, 1, 1))
set dir& set dir&
call delete("Xtest1")
call delete("Xtest2", "rf")
call delete("Xtest.je", "rf")
endfunc endfunc
func Test_swap_group() func Test_swap_group()
@@ -135,7 +132,7 @@ func Test_swapinfo()
let info = swapinfo('doesnotexist') let info = swapinfo('doesnotexist')
call assert_equal('Cannot open file', info.error) call assert_equal('Cannot open file', info.error)
call writefile(['burp'], 'Xnotaswapfile') call writefile(['burp'], 'Xnotaswapfile', 'D')
let info = swapinfo('Xnotaswapfile') let info = swapinfo('Xnotaswapfile')
call assert_equal('Cannot read file', info.error) call assert_equal('Cannot read file', info.error)
call delete('Xnotaswapfile') call delete('Xnotaswapfile')
@@ -143,7 +140,6 @@ func Test_swapinfo()
call writefile([repeat('x', 10000)], 'Xnotaswapfile') call writefile([repeat('x', 10000)], 'Xnotaswapfile')
let info = swapinfo('Xnotaswapfile') let info = swapinfo('Xnotaswapfile')
call assert_equal('Not a swap file', info.error) call assert_equal('Not a swap file', info.error)
call delete('Xnotaswapfile')
endfunc endfunc
func Test_swapname() func Test_swapname()
@@ -191,7 +187,7 @@ func Test_swapfile_delete()
" Close the file and recreate the swap file. " Close the file and recreate the swap file.
" Now editing the file will run into the process still existing " Now editing the file will run into the process still existing
quit quit
call writefile(swapfile_bytes, swapfile_name) call writefile(swapfile_bytes, swapfile_name, 'D')
let s:swap_choice = 'e' let s:swap_choice = 'e'
let s:swapname = '' let s:swapname = ''
split XswapfileText split XswapfileText
@@ -219,7 +215,6 @@ func Test_swapfile_delete()
call assert_equal(fnamemodify(swapfile_name, ':t'), fnamemodify(s:swapname, ':t')) call assert_equal(fnamemodify(swapfile_name, ':t'), fnamemodify(s:swapname, ':t'))
call delete('XswapfileText') call delete('XswapfileText')
call delete(swapfile_name)
augroup test_swapfile_delete augroup test_swapfile_delete
autocmd! autocmd!
augroup END augroup END
@@ -233,7 +228,7 @@ func Test_swap_recover()
autocmd SwapExists * let v:swapchoice = 'r' autocmd SwapExists * let v:swapchoice = 'r'
augroup END augroup END
call mkdir('Xswap') call mkdir('Xswap', 'R')
let $Xswap = 'foo' " Check for issue #4369. let $Xswap = 'foo' " Check for issue #4369.
set dir=Xswap// set dir=Xswap//
" Create a valid swapfile by editing a file. " Create a valid swapfile by editing a file.
@@ -246,7 +241,7 @@ func Test_swap_recover()
" Close the file and recreate the swap file. " Close the file and recreate the swap file.
quit quit
call writefile(swapfile_bytes, swapfile_name) call writefile(swapfile_bytes, swapfile_name, 'D')
" Edit the file again. This triggers recovery. " Edit the file again. This triggers recovery.
try try
split Xswap/text split Xswap/text
@@ -258,9 +253,6 @@ func Test_swap_recover()
call assert_equal(['one', 'two', 'three'], getline(1, 3)) call assert_equal(['one', 'two', 'three'], getline(1, 3))
quit! quit!
call delete('Xswap/text')
call delete(swapfile_name)
call delete('Xswap', 'd')
unlet $Xswap unlet $Xswap
set dir& set dir&
augroup test_swap_recover augroup test_swap_recover
@@ -288,7 +280,7 @@ func Test_swap_recover_ext()
" Close and delete the file and recreate the swap file. " Close and delete the file and recreate the swap file.
quit quit
call delete('Xtest.scr') call delete('Xtest.scr')
call writefile(swapfile_bytes, swapfile_name) call writefile(swapfile_bytes, swapfile_name, 'D')
" Edit the file again. This triggers recovery. " Edit the file again. This triggers recovery.
try try
split Xtest.scr split Xtest.scr
@@ -301,7 +293,6 @@ func Test_swap_recover_ext()
quit! quit!
call delete('Xtest.scr') call delete('Xtest.scr')
call delete(swapfile_name)
augroup test_swap_recover_ext augroup test_swap_recover_ext
autocmd! autocmd!
augroup END augroup END
@@ -329,7 +320,7 @@ func Test_swap_split_win()
" Close and delete the file and recreate the swap file. " Close and delete the file and recreate the swap file.
quit quit
call delete('Xtest.scr') call delete('Xtest.scr')
call writefile(swapfile_bytes, swapfile_name) call writefile(swapfile_bytes, swapfile_name, 'D')
" Split edit the file again. This should fail to open the window " Split edit the file again. This should fail to open the window
try try
split Xtest.scr split Xtest.scr
@@ -340,7 +331,6 @@ func Test_swap_split_win()
call assert_equal(1, winnr('$')) call assert_equal(1, winnr('$'))
call delete('Xtest.scr') call delete('Xtest.scr')
call delete(swapfile_name)
augroup test_swap_splitwin augroup test_swap_splitwin
autocmd! autocmd!
@@ -352,7 +342,7 @@ endfunc
func Test_swap_prompt_splitwin() func Test_swap_prompt_splitwin()
CheckRunVimInTerminal CheckRunVimInTerminal
call writefile(['foo bar'], 'Xfile1') call writefile(['foo bar'], 'Xfile1', 'D')
edit Xfile1 edit Xfile1
preserve " should help to make sure the swap file exists preserve " should help to make sure the swap file exists
@@ -387,13 +377,12 @@ func Test_swap_prompt_splitwin()
call StopVimInTerminal(buf) call StopVimInTerminal(buf)
%bwipe! %bwipe!
call delete('Xfile1')
endfunc endfunc
func Test_swap_symlink() func Test_swap_symlink()
CheckUnix CheckUnix
call writefile(['text'], 'Xtestfile') call writefile(['text'], 'Xtestfile', 'D')
silent !ln -s -f Xtestfile Xtestlink silent !ln -s -f Xtestfile Xtestlink
set dir=. set dir=.
@@ -404,7 +393,7 @@ func Test_swap_symlink()
call assert_match('Xtestfile\.swp$', s:swapname()) call assert_match('Xtestfile\.swp$', s:swapname())
bwipe! bwipe!
call mkdir('Xswapdir') call mkdir('Xswapdir', 'R')
exe 'set dir=' . getcwd() . '/Xswapdir//' exe 'set dir=' . getcwd() . '/Xswapdir//'
" Check that this also works when 'directory' ends with '//' " Check that this also works when 'directory' ends with '//'
@@ -413,9 +402,7 @@ func Test_swap_symlink()
bwipe! bwipe!
set dir& set dir&
call delete('Xtestfile')
call delete('Xtestlink') call delete('Xtestlink')
call delete('Xswapdir', 'rf')
endfunc endfunc
func s:get_unused_pid(base) func s:get_unused_pid(base)
@@ -467,7 +454,7 @@ func Test_swap_auto_delete()
" Change the process ID to avoid the "still running" warning. " Change the process ID to avoid the "still running" warning.
let swapfile_bytes[24:27] = s:pid_to_blob(s:get_unused_pid( let swapfile_bytes[24:27] = s:pid_to_blob(s:get_unused_pid(
\ s:blob_to_pid(swapfile_bytes[24:27]))) \ s:blob_to_pid(swapfile_bytes[24:27])))
call writefile(swapfile_bytes, swapfile_name) call writefile(swapfile_bytes, swapfile_name, 'D')
edit Xtest.scr edit Xtest.scr
" will end up using the same swap file after deleting the existing one " will end up using the same swap file after deleting the existing one
call assert_equal(swapfile_name, swapname('%')) call assert_equal(swapfile_name, swapname('%'))
@@ -491,7 +478,6 @@ func Test_swap_auto_delete()
bwipe! bwipe!
call delete('Xtest.scr') call delete('Xtest.scr')
call delete(swapfile_name)
augroup test_swap_recover_ext augroup test_swap_recover_ext
autocmd! autocmd!
augroup END augroup END
@@ -520,13 +506,13 @@ endfunc
" Test for the v:swapchoice variable " Test for the v:swapchoice variable
func Test_swapchoice() func Test_swapchoice()
call writefile(['aaa', 'bbb'], 'Xfile5') call writefile(['aaa', 'bbb'], 'Xfile5', 'D')
edit Xfile5 edit Xfile5
preserve preserve
let swapfname = swapname('') let swapfname = swapname('')
let b = readblob(swapfname) let b = readblob(swapfname)
bw! bw!
call writefile(b, swapfname) call writefile(b, swapfname, 'D')
autocmd! SwapExists autocmd! SwapExists
@@ -565,7 +551,6 @@ func Test_swapchoice()
%bw! %bw!
call assert_false(filereadable(swapfname)) call assert_false(filereadable(swapfname))
call delete('Xfile5')
call delete(swapfname) call delete(swapfname)
augroup test_swapchoice augroup test_swapchoice
autocmd! autocmd!

View File

@@ -652,7 +652,7 @@ func Test_syntax_c()
\ "\t}", \ "\t}",
\ "\tNote: asdf", \ "\tNote: asdf",
\ '}', \ '}',
\ ], 'Xtest.c') \ ], 'Xtest.c', 'D')
" This makes the default for 'background' use "dark", check that the " This makes the default for 'background' use "dark", check that the
" response to t_RB corrects it to "light". " response to t_RB corrects it to "light".
@@ -670,7 +670,6 @@ func Test_syntax_c()
call StopVimInTerminal(buf) call StopVimInTerminal(buf)
let $COLORFGBG = '' let $COLORFGBG = ''
call delete('Xtest.c')
endfun endfun
" Test \z(...) along with \z1 " Test \z(...) along with \z1
@@ -704,10 +703,10 @@ func Test_syn_wrong_z_one()
endfunc endfunc
func Test_syntax_after_bufdo() func Test_syntax_after_bufdo()
call writefile(['/* aaa comment */'], 'Xaaa.c') call writefile(['/* aaa comment */'], 'Xaaa.c', 'D')
call writefile(['/* bbb comment */'], 'Xbbb.c') call writefile(['/* bbb comment */'], 'Xbbb.c', 'D')
call writefile(['/* ccc comment */'], 'Xccc.c') call writefile(['/* ccc comment */'], 'Xccc.c', 'D')
call writefile(['/* ddd comment */'], 'Xddd.c') call writefile(['/* ddd comment */'], 'Xddd.c', 'D')
let bnr = bufnr('%') let bnr = bufnr('%')
new Xaaa.c new Xaaa.c
@@ -735,10 +734,6 @@ func Test_syntax_after_bufdo()
bwipe! Xccc.c bwipe! Xccc.c
bwipe! Xddd.c bwipe! Xddd.c
syntax off syntax off
call delete('Xaaa.c')
call delete('Xbbb.c')
call delete('Xccc.c')
call delete('Xddd.c')
endfunc endfunc
func Test_syntax_foldlevel() func Test_syntax_foldlevel()

View File

@@ -55,7 +55,7 @@ func Test_system_exmode()
let cmd = ' -es -c "source Xscript" +q; echo "result=$?"' let cmd = ' -es -c "source Xscript" +q; echo "result=$?"'
" Need to put this in a script, "catch" isn't found after an unknown " Need to put this in a script, "catch" isn't found after an unknown
" function. " function.
call writefile(['try', 'call doesnotexist()', 'catch', 'endtry'], 'Xscript') call writefile(['try', 'call doesnotexist()', 'catch', 'endtry'], 'Xscript', 'D')
let a = system(GetVimCommand() . cmd) let a = system(GetVimCommand() . cmd)
call assert_match('result=0', a) call assert_match('result=0', a)
call assert_equal(0, v:shell_error) call assert_equal(0, v:shell_error)
@@ -71,7 +71,6 @@ func Test_system_exmode()
let cmd = ' -es -c "source Xscript" +q' let cmd = ' -es -c "source Xscript" +q'
let a = system(GetVimCommand() . cmd) let a = system(GetVimCommand() . cmd)
call assert_notequal(0, v:shell_error) call assert_notequal(0, v:shell_error)
call delete('Xscript')
if has('unix') " echo $? only works on Unix if has('unix') " echo $? only works on Unix
let cmd = ' -es -c "call doesnotexist()" +q; echo $?' let cmd = ' -es -c "call doesnotexist()" +q; echo $?'

View File

@@ -699,6 +699,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
719,
/**/ /**/
718, 718,
/**/ /**/