mirror of
https://github.com/vim/vim.git
synced 2025-09-24 03:44:06 -04:00
patch 9.0.0363: common names in test files causes tests to be flaky
Problem: Common names in test files causes tests to be flaky. Solution: Use more specific names.
This commit is contained in:
@@ -3062,7 +3062,7 @@ func Test_BufDelete_changebuf()
|
||||
augroup END
|
||||
let save_cpo = &cpo
|
||||
set cpo+=f
|
||||
call assert_fails('r Xfile', ['E812:', 'E484:'])
|
||||
call assert_fails('r Xchangebuf', ['E812:', 'E484:'])
|
||||
call assert_equal('somefile', @%)
|
||||
let &cpo = save_cpo
|
||||
augroup TestAuCmd
|
||||
|
@@ -35,9 +35,9 @@ func Test_mkdir_p()
|
||||
call assert_report('mkdir(..., "p") failed for an existing directory')
|
||||
endtry
|
||||
" 'p' doesn't suppress real errors
|
||||
call writefile([], 'Xfile')
|
||||
call assert_fails('call mkdir("Xfile", "p")', 'E739:')
|
||||
call delete('Xfile')
|
||||
call writefile([], 'Xmkdirfile')
|
||||
call assert_fails('call mkdir("Xmkdirfile", "p")', 'E739:')
|
||||
call delete('Xmkdirfile')
|
||||
call delete('Xmkdir', 'rf')
|
||||
call assert_equal(0, mkdir(test_null_string()))
|
||||
call assert_fails('call mkdir([])', 'E730:')
|
||||
|
@@ -83,23 +83,23 @@ endfunc
|
||||
|
||||
" Test for the :drop command
|
||||
func Test_drop_cmd()
|
||||
call writefile(['L1', 'L2'], 'Xfile')
|
||||
call writefile(['L1', 'L2'], 'Xdropfile')
|
||||
enew | only
|
||||
drop Xfile
|
||||
drop Xdropfile
|
||||
call assert_equal('L2', getline(2))
|
||||
" Test for switching to an existing window
|
||||
below new
|
||||
drop Xfile
|
||||
drop Xdropfile
|
||||
call assert_equal(1, winnr())
|
||||
" Test for splitting the current window
|
||||
enew | only
|
||||
set modified
|
||||
drop Xfile
|
||||
drop Xdropfile
|
||||
call assert_equal(2, winnr('$'))
|
||||
" Check for setting the argument list
|
||||
call assert_equal(['Xfile'], argv())
|
||||
call assert_equal(['Xdropfile'], argv())
|
||||
enew | only!
|
||||
call delete('Xfile')
|
||||
call delete('Xdropfile')
|
||||
endfunc
|
||||
|
||||
" Test for the :append command
|
||||
@@ -509,10 +509,10 @@ func Test_redir_cmd_readonly()
|
||||
CheckNotRoot
|
||||
|
||||
" Redirecting to a read-only file
|
||||
call writefile([], 'Xfile')
|
||||
call setfperm('Xfile', 'r--r--r--')
|
||||
call assert_fails('redir! > Xfile', 'E190:')
|
||||
call delete('Xfile')
|
||||
call writefile([], 'Xredirfile')
|
||||
call setfperm('Xredirfile', 'r--r--r--')
|
||||
call assert_fails('redir! > Xredirfile', 'E190:')
|
||||
call delete('Xredirfile')
|
||||
endfunc
|
||||
|
||||
" Test for the :filetype command
|
||||
@@ -532,21 +532,21 @@ endfunc
|
||||
|
||||
" Test for the :read command
|
||||
func Test_read_cmd()
|
||||
call writefile(['one'], 'Xfile')
|
||||
call writefile(['one'], 'Xcmdfile')
|
||||
new
|
||||
call assert_fails('read', 'E32:')
|
||||
edit Xfile
|
||||
edit Xcmdfile
|
||||
read
|
||||
call assert_equal(['one', 'one'], getline(1, '$'))
|
||||
close!
|
||||
new
|
||||
read Xfile
|
||||
read Xcmdfile
|
||||
call assert_equal(['', 'one'], getline(1, '$'))
|
||||
call deletebufline('', 1, '$')
|
||||
call feedkeys("Qr Xfile\<CR>visual\<CR>", 'xt')
|
||||
call feedkeys("Qr Xcmdfile\<CR>visual\<CR>", 'xt')
|
||||
call assert_equal(['one'], getline(1, '$'))
|
||||
close!
|
||||
call delete('Xfile')
|
||||
call delete('Xcmdfile')
|
||||
endfunc
|
||||
|
||||
" Test for running Ex commands when text is locked.
|
||||
@@ -633,9 +633,9 @@ func Sandbox_tests()
|
||||
endif
|
||||
call assert_fails("let $TESTVAR=1", 'E48:')
|
||||
call assert_fails("call feedkeys('ivim')", 'E48:')
|
||||
call assert_fails("source! Xfile", 'E48:')
|
||||
call assert_fails("call delete('Xfile')", 'E48:')
|
||||
call assert_fails("call writefile([], 'Xfile')", 'E48:')
|
||||
call assert_fails("source! Xsomefile", 'E48:')
|
||||
call assert_fails("call delete('Xthatfile')", 'E48:')
|
||||
call assert_fails("call writefile([], 'Xanotherfile')", 'E48:')
|
||||
call assert_fails('!ls', 'E48:')
|
||||
call assert_fails('shell', 'E48:')
|
||||
call assert_fails('stop', 'E48:')
|
||||
@@ -660,7 +660,7 @@ func Sandbox_tests()
|
||||
if has('terminal')
|
||||
call assert_fails('terminal', 'E48:')
|
||||
call assert_fails('call term_start("vim")', 'E48:')
|
||||
call assert_fails('call term_dumpwrite(1, "Xfile")', 'E48:')
|
||||
call assert_fails('call term_dumpwrite(1, "Xdumpfile")', 'E48:')
|
||||
endif
|
||||
if has('channel')
|
||||
call assert_fails("call ch_logfile('chlog')", 'E48:')
|
||||
@@ -727,17 +727,17 @@ endfunc
|
||||
|
||||
" Test :write after changing name with :file and loading it with :edit
|
||||
func Test_write_after_rename()
|
||||
call writefile(['text'], 'Xfile')
|
||||
call writefile(['text'], 'Xafterfile')
|
||||
|
||||
enew
|
||||
file Xfile
|
||||
file Xafterfile
|
||||
call assert_fails('write', 'E13: File exists (add ! to override)')
|
||||
|
||||
" works OK after ":edit"
|
||||
edit
|
||||
write
|
||||
|
||||
call delete('Xfile')
|
||||
call delete('Xafterfile')
|
||||
bwipe!
|
||||
endfunc
|
||||
|
||||
|
@@ -57,26 +57,26 @@ func Test_expandcmd()
|
||||
unlet $FOO
|
||||
|
||||
new
|
||||
edit Xfile1
|
||||
call assert_equal('e Xfile1', expandcmd('e %'))
|
||||
edit Xfile2
|
||||
edit Xfile1
|
||||
call assert_equal('e Xfile2', 'e #'->expandcmd())
|
||||
edit Xfile2
|
||||
edit Xfile3
|
||||
edit Xfile4
|
||||
let bnum = bufnr('Xfile2')
|
||||
call assert_equal('e Xfile2', expandcmd('e #' . bnum))
|
||||
edit Xpandfile1
|
||||
call assert_equal('e Xpandfile1', expandcmd('e %'))
|
||||
edit Xpandfile2
|
||||
edit Xpandfile1
|
||||
call assert_equal('e Xpandfile2', 'e #'->expandcmd())
|
||||
edit Xpandfile2
|
||||
edit Xpandfile3
|
||||
edit Xpandfile4
|
||||
let bnum = bufnr('Xpandfile2')
|
||||
call assert_equal('e Xpandfile2', expandcmd('e #' . bnum))
|
||||
call setline('.', 'Vim!@#')
|
||||
call assert_equal('e Vim', expandcmd('e <cword>'))
|
||||
call assert_equal('e Vim!@#', expandcmd('e <cWORD>'))
|
||||
enew!
|
||||
edit Xfile.java
|
||||
call assert_equal('e Xfile.py', expandcmd('e %:r.py'))
|
||||
edit Xpandfile.java
|
||||
call assert_equal('e Xpandfile.py', expandcmd('e %:r.py'))
|
||||
call assert_equal('make abc.java', expandcmd('make abc.%:e'))
|
||||
call assert_equal('make Xabc.java', expandcmd('make %:s?file?abc?'))
|
||||
call assert_equal('make Xabc.java', expandcmd('make %:s?pandfile?abc?'))
|
||||
edit a1a2a3.rb
|
||||
call assert_equal('make b1b2b3.rb a1a2a3 Xfile.o', expandcmd('make %:gs?a?b? %< #<.o'))
|
||||
call assert_equal('make b1b2b3.rb a1a2a3 Xpandfile.o', expandcmd('make %:gs?a?b? %< #<.o'))
|
||||
|
||||
call assert_equal('make <afile>', expandcmd("make <afile>"))
|
||||
call assert_equal('make <amatch>', expandcmd("make <amatch>"))
|
||||
|
@@ -22,9 +22,9 @@ func Test_file_perm()
|
||||
call assert_equal(1, setfperm('Xtest', 'rwx------'))
|
||||
call delete('Xtest')
|
||||
|
||||
call assert_fails("call setfperm(['Xfile'], 'rw-rw-rw-')", 'E730:')
|
||||
call assert_fails("call setfperm('Xfile', [])", 'E730:')
|
||||
call assert_fails("call setfperm('Xfile', 'rwxrwxrwxrw')", 'E475:')
|
||||
call assert_fails("call setfperm(['Xpermfile'], 'rw-rw-rw-')", 'E730:')
|
||||
call assert_fails("call setfperm('Xpermfile', [])", 'E730:')
|
||||
call assert_fails("call setfperm('Xpermfile', 'rwxrwxrwxrw')", 'E475:')
|
||||
endfunc
|
||||
|
||||
" vim: shiftwidth=2 sts=2 expandtab
|
||||
|
@@ -253,15 +253,15 @@ endfunc
|
||||
|
||||
" Test for editing a new buffer from a FileChangedShell autocmd
|
||||
func Test_FileChangedShell_newbuf()
|
||||
call writefile(['one', 'two'], 'Xfile')
|
||||
new Xfile
|
||||
call writefile(['one', 'two'], 'Xchfile')
|
||||
new Xchfile
|
||||
augroup testnewbuf
|
||||
autocmd FileChangedShell * enew
|
||||
augroup END
|
||||
call writefile(['red'], 'Xfile')
|
||||
call writefile(['red'], 'Xchfile')
|
||||
call assert_fails('checktime', 'E811:')
|
||||
au! testnewbuf
|
||||
call delete('Xfile')
|
||||
call delete('Xchfile')
|
||||
endfunc
|
||||
|
||||
" vim: shiftwidth=2 sts=2 expandtab
|
||||
|
@@ -22,16 +22,16 @@ endfunc
|
||||
func Test_fileformat_autocommand()
|
||||
let filecnt = ["", "foobar\<CR>", "eins\<CR>", "\<CR>", "zwei\<CR>", "drei", "vier", "fünf", ""]
|
||||
let ffs = &ffs
|
||||
call writefile(filecnt, 'Xfile', 'b')
|
||||
au BufReadPre Xfile set ffs=dos ff=dos
|
||||
new Xfile
|
||||
call writefile(filecnt, 'Xffafile', 'b')
|
||||
au BufReadPre Xffafile set ffs=dos ff=dos
|
||||
new Xffafile
|
||||
call assert_equal('dos', &l:ff)
|
||||
call assert_equal('dos', &ffs)
|
||||
|
||||
" cleanup
|
||||
call delete('Xfile')
|
||||
call delete('Xffafile')
|
||||
let &ffs = ffs
|
||||
au! BufReadPre Xfile
|
||||
au! BufReadPre Xffafile
|
||||
bw!
|
||||
endfunc
|
||||
|
||||
@@ -314,14 +314,14 @@ endfunc
|
||||
" used as the 'fileformat'.
|
||||
func Test_fileformat_on_startup()
|
||||
let after =<< trim END
|
||||
call writefile([&fileformat], 'Xfile', 'a')
|
||||
call writefile([&fileformat], 'Xonsfile', 'a')
|
||||
quit
|
||||
END
|
||||
call RunVim(["set ffs=dos,unix,mac"], after, '')
|
||||
call RunVim(["set ffs=mac,dos,unix"], after, '')
|
||||
call RunVim(["set ffs=unix,mac,dos"], after, '')
|
||||
call assert_equal(['dos', 'mac', 'unix'], readfile('Xfile'))
|
||||
call delete('Xfile')
|
||||
call assert_equal(['dos', 'mac', 'unix'], readfile('Xonsfile'))
|
||||
call delete('Xonsfile')
|
||||
endfunc
|
||||
|
||||
" vim: shiftwidth=2 sts=2 expandtab
|
||||
|
@@ -14,15 +14,15 @@ endfunc
|
||||
|
||||
func Test_conf_type()
|
||||
filetype on
|
||||
call writefile(['# some comment', 'must be conf'], 'Xfile')
|
||||
call writefile(['# some comment', 'must be conf'], 'Xconffile')
|
||||
augroup filetypedetect
|
||||
au BufNewFile,BufRead * call assert_equal(0, did_filetype())
|
||||
augroup END
|
||||
split Xfile
|
||||
split Xconffile
|
||||
call assert_equal('conf', &filetype)
|
||||
|
||||
bwipe!
|
||||
call delete('Xfile')
|
||||
call delete('Xconffile')
|
||||
filetype off
|
||||
endfunc
|
||||
|
||||
@@ -30,15 +30,15 @@ func Test_other_type()
|
||||
filetype on
|
||||
augroup filetypedetect
|
||||
au BufNewFile,BufRead * call assert_equal(0, did_filetype())
|
||||
au BufNewFile,BufRead Xfile setf testfile
|
||||
au BufNewFile,BufRead Xotherfile setf testfile
|
||||
au BufNewFile,BufRead * call assert_equal(1, did_filetype())
|
||||
augroup END
|
||||
call writefile(['# some comment', 'must be conf'], 'Xfile')
|
||||
split Xfile
|
||||
call writefile(['# some comment', 'must be conf'], 'Xotherfile')
|
||||
split Xotherfile
|
||||
call assert_equal('testfile', &filetype)
|
||||
|
||||
bwipe!
|
||||
call delete('Xfile')
|
||||
call delete('Xotherfile')
|
||||
filetype off
|
||||
endfunc
|
||||
|
||||
|
@@ -137,9 +137,9 @@ func Test_indent_fold_with_read()
|
||||
call assert_equal(1, foldlevel(n))
|
||||
endfor
|
||||
|
||||
call writefile(["a", "", "\<Tab>a"], 'Xfile')
|
||||
call writefile(["a", "", "\<Tab>a"], 'Xinfofile')
|
||||
foldopen
|
||||
2read Xfile
|
||||
2read Xinfofile
|
||||
%foldclose
|
||||
call assert_equal(1, foldlevel(1))
|
||||
call assert_equal(2, foldclosedend(1))
|
||||
@@ -150,7 +150,7 @@ func Test_indent_fold_with_read()
|
||||
|
||||
bwipe!
|
||||
set foldmethod&
|
||||
call delete('Xfile')
|
||||
call delete('Xinfofile')
|
||||
endfunc
|
||||
|
||||
func Test_combining_folds_indent()
|
||||
@@ -216,8 +216,8 @@ func Test_update_folds_expr_read()
|
||||
set foldexpr=s:TestFoldExpr(v:lnum)
|
||||
2
|
||||
foldopen
|
||||
call writefile(['b', 'b', 'a', 'a', 'd', 'a', 'a', 'c'], 'Xfile')
|
||||
read Xfile
|
||||
call writefile(['b', 'b', 'a', 'a', 'd', 'a', 'a', 'c'], 'Xupfofile')
|
||||
read Xupfofile
|
||||
%foldclose
|
||||
call assert_equal(2, foldclosedend(1))
|
||||
call assert_equal(0, foldlevel(3))
|
||||
@@ -226,7 +226,7 @@ func Test_update_folds_expr_read()
|
||||
call assert_equal(10, foldclosedend(7))
|
||||
call assert_equal(14, foldclosedend(11))
|
||||
|
||||
call delete('Xfile')
|
||||
call delete('Xupfofile')
|
||||
bwipe!
|
||||
set foldmethod& foldexpr&
|
||||
endfunc
|
||||
|
@@ -375,22 +375,22 @@ func Test_resolve_win32()
|
||||
|
||||
" test for shortcut file
|
||||
if executable('cscript')
|
||||
new Xfile
|
||||
new Xresfile
|
||||
wq
|
||||
let lines =<< trim END
|
||||
Set fs = CreateObject("Scripting.FileSystemObject")
|
||||
Set ws = WScript.CreateObject("WScript.Shell")
|
||||
Set shortcut = ws.CreateShortcut("Xlink.lnk")
|
||||
shortcut.TargetPath = fs.BuildPath(ws.CurrentDirectory, "Xfile")
|
||||
shortcut.TargetPath = fs.BuildPath(ws.CurrentDirectory, "Xresfile")
|
||||
shortcut.Save
|
||||
END
|
||||
call writefile(lines, 'link.vbs')
|
||||
silent !cscript link.vbs
|
||||
call delete('link.vbs')
|
||||
call assert_equal(s:normalize_fname(getcwd() . '\Xfile'), s:normalize_fname(resolve('./Xlink.lnk')))
|
||||
call delete('Xfile')
|
||||
call assert_equal(s:normalize_fname(getcwd() . '\Xresfile'), s:normalize_fname(resolve('./Xlink.lnk')))
|
||||
call delete('Xresfile')
|
||||
|
||||
call assert_equal(s:normalize_fname(getcwd() . '\Xfile'), s:normalize_fname(resolve('./Xlink.lnk')))
|
||||
call assert_equal(s:normalize_fname(getcwd() . '\Xresfile'), s:normalize_fname(resolve('./Xlink.lnk')))
|
||||
call delete('Xlink.lnk')
|
||||
else
|
||||
echomsg 'skipped test for shortcut file'
|
||||
@@ -399,20 +399,20 @@ func Test_resolve_win32()
|
||||
" remove files
|
||||
call delete('Xlink')
|
||||
call delete('Xdir', 'd')
|
||||
call delete('Xfile')
|
||||
call delete('Xresfile')
|
||||
|
||||
" test for symbolic link to a file
|
||||
new Xfile
|
||||
new Xresfile
|
||||
wq
|
||||
call assert_equal('Xfile', resolve('Xfile'))
|
||||
silent !mklink Xlink Xfile
|
||||
call assert_equal('Xresfile', resolve('Xresfile'))
|
||||
silent !mklink Xlink Xresfile
|
||||
if !v:shell_error
|
||||
call assert_equal(s:normalize_fname(getcwd() . '\Xfile'), s:normalize_fname(resolve('./Xlink')))
|
||||
call assert_equal(s:normalize_fname(getcwd() . '\Xresfile'), s:normalize_fname(resolve('./Xlink')))
|
||||
call delete('Xlink')
|
||||
else
|
||||
echomsg 'skipped test for symbolic link to a file'
|
||||
endif
|
||||
call delete('Xfile')
|
||||
call delete('Xresfile')
|
||||
|
||||
" test for junction to a directory
|
||||
call mkdir('Xdir')
|
||||
@@ -447,9 +447,9 @@ func Test_resolve_win32()
|
||||
endif
|
||||
|
||||
" test for buffer name
|
||||
new Xfile
|
||||
new Xbuffile
|
||||
wq
|
||||
silent !mklink Xlink Xfile
|
||||
silent !mklink Xlink Xbuffile
|
||||
if !v:shell_error
|
||||
edit Xlink
|
||||
call assert_equal('Xlink', bufname('%'))
|
||||
@@ -458,7 +458,7 @@ func Test_resolve_win32()
|
||||
else
|
||||
echomsg 'skipped test for buffer name'
|
||||
endif
|
||||
call delete('Xfile')
|
||||
call delete('Xbuffile')
|
||||
|
||||
" test for reparse point
|
||||
call mkdir('Xdir')
|
||||
|
@@ -49,38 +49,38 @@ endfunc
|
||||
func Test_gF()
|
||||
new
|
||||
call setline(1, ['111', '222', '333', '444'])
|
||||
w! Xfile
|
||||
w! Xgffile
|
||||
close
|
||||
new
|
||||
set isfname-=:
|
||||
call setline(1, ['one', 'Xfile:3', 'three'])
|
||||
call setline(1, ['one', 'Xgffile:3', 'three'])
|
||||
2
|
||||
call assert_fails('normal gF', 'E37:')
|
||||
call assert_equal(2, getcurpos()[1])
|
||||
w! Xfile2
|
||||
w! Xgffile2
|
||||
normal gF
|
||||
call assert_equal('Xfile', bufname('%'))
|
||||
call assert_equal('Xgffile', bufname('%'))
|
||||
call assert_equal(3, getcurpos()[1])
|
||||
|
||||
enew!
|
||||
call setline(1, ['one', 'the Xfile line 2, and more', 'three'])
|
||||
w! Xfile2
|
||||
call setline(1, ['one', 'the Xgffile line 2, and more', 'three'])
|
||||
w! Xgffile2
|
||||
normal 2GfX
|
||||
normal gF
|
||||
call assert_equal('Xfile', bufname('%'))
|
||||
call assert_equal('Xgffile', bufname('%'))
|
||||
call assert_equal(2, getcurpos()[1])
|
||||
|
||||
" jumping to the file/line with CTRL-W_F
|
||||
%bw!
|
||||
edit Xfile1
|
||||
call setline(1, ['one', 'Xfile:4', 'three'])
|
||||
call setline(1, ['one', 'Xgffile:4', 'three'])
|
||||
exe "normal 2G\<C-W>F"
|
||||
call assert_equal('Xfile', bufname('%'))
|
||||
call assert_equal('Xgffile', bufname('%'))
|
||||
call assert_equal(4, getcurpos()[1])
|
||||
|
||||
set isfname&
|
||||
call delete('Xfile')
|
||||
call delete('Xfile2')
|
||||
call delete('Xgffile')
|
||||
call delete('Xgffile2')
|
||||
%bw!
|
||||
endfunc
|
||||
|
||||
|
@@ -1602,7 +1602,7 @@ endfunc
|
||||
|
||||
func Test_gui_dialog_file()
|
||||
let lines =<< trim END
|
||||
file Xfile
|
||||
file Xdialfile
|
||||
normal axxx
|
||||
confirm qa
|
||||
END
|
||||
@@ -1614,10 +1614,10 @@ func Test_gui_dialog_file()
|
||||
execute prefix .. GetVimCommand() .. ' -g -f --clean --gui-dialog-file Xdialog -S Xlines'
|
||||
|
||||
call WaitForAssert({-> assert_true(filereadable('Xdialog'))})
|
||||
call assert_match('Question: Save changes to "Xfile"?', readfile('Xdialog')->join('<NL>'))
|
||||
call assert_match('Question: Save changes to "Xdialfile"?', readfile('Xdialog')->join('<NL>'))
|
||||
|
||||
call delete('Xdialog')
|
||||
call delete('Xfile')
|
||||
call delete('Xdialfile')
|
||||
call delete('Xlines')
|
||||
endfunc
|
||||
|
||||
|
@@ -161,9 +161,9 @@ func Test_modeline_indent_expr()
|
||||
func GetIndent()
|
||||
return line('.') * 2
|
||||
endfunc
|
||||
call writefile(['# vim: indentexpr=GetIndent()'], 'Xfile.txt')
|
||||
call writefile(['# vim: indentexpr=GetIndent()'], 'Xmlfile.txt')
|
||||
set modelineexpr
|
||||
new Xfile.txt
|
||||
new Xmlfile.txt
|
||||
call assert_equal('GetIndent()', &indentexpr)
|
||||
exe "normal Oa\nb\n"
|
||||
call assert_equal([' a', ' b'], getline(1, 2))
|
||||
@@ -172,7 +172,7 @@ func Test_modeline_indent_expr()
|
||||
delfunc GetIndent
|
||||
let &modeline = modeline
|
||||
close!
|
||||
call delete('Xfile.txt')
|
||||
call delete('Xmlfile.txt')
|
||||
endfunc
|
||||
|
||||
func Test_indent_func_with_gq()
|
||||
|
@@ -1226,14 +1226,14 @@ func Test_complete_unreadable_thesaurus_file()
|
||||
CheckUnix
|
||||
CheckNotRoot
|
||||
|
||||
call writefile(['about', 'above'], 'Xfile')
|
||||
call setfperm('Xfile', '---r--r--')
|
||||
call writefile(['about', 'above'], 'Xunrfile')
|
||||
call setfperm('Xunrfile', '---r--r--')
|
||||
new
|
||||
set complete=sXfile
|
||||
exe "normal! ia\<C-P>"
|
||||
call assert_equal('a', getline(1))
|
||||
bw!
|
||||
call delete('Xfile')
|
||||
call delete('Xunrfile')
|
||||
set complete&
|
||||
endfunc
|
||||
|
||||
|
@@ -1235,8 +1235,8 @@ endfunc
|
||||
|
||||
" Test for creating views with manual folds
|
||||
func Test_mkview_manual_fold()
|
||||
call writefile(range(1,10), 'Xfile')
|
||||
new Xfile
|
||||
call writefile(range(1,10), 'Xmkvfile')
|
||||
new Xmkvfile
|
||||
" create recursive folds
|
||||
5,6fold
|
||||
4,7fold
|
||||
@@ -1259,7 +1259,7 @@ func Test_mkview_manual_fold()
|
||||
source Xview
|
||||
call assert_equal([-1, -1, -1, -1, -1, -1], [foldclosed(3), foldclosed(4),
|
||||
\ foldclosed(5), foldclosed(6), foldclosed(7), foldclosed(8)])
|
||||
call delete('Xfile')
|
||||
call delete('Xmkvfile')
|
||||
call delete('Xview')
|
||||
bw!
|
||||
endfunc
|
||||
|
@@ -350,13 +350,13 @@ endfunc
|
||||
|
||||
" Some options cannot be set from the modeline when 'diff' option is set
|
||||
func Test_modeline_diff_buffer()
|
||||
call writefile(['vim: diff foldmethod=marker wrap'], 'Xfile')
|
||||
call writefile(['vim: diff foldmethod=marker wrap'], 'Xmdifile')
|
||||
set foldmethod& nowrap
|
||||
new Xfile
|
||||
new Xmdifile
|
||||
call assert_equal('manual', &foldmethod)
|
||||
call assert_false(&wrap)
|
||||
set wrap&
|
||||
call delete('Xfile')
|
||||
call delete('Xmdifile')
|
||||
bw
|
||||
endfunc
|
||||
|
||||
|
@@ -1709,14 +1709,14 @@ endfunc
|
||||
func Test_normal20_exmode()
|
||||
" Reading from redirected file doesn't work on MS-Windows
|
||||
CheckNotMSWindows
|
||||
call writefile(['1a', 'foo', 'bar', '.', 'w! Xfile2', 'q!'], 'Xscript')
|
||||
call writefile(['1', '2'], 'Xfile')
|
||||
call system(GetVimCommand() .. ' -e -s < Xscript Xfile')
|
||||
let a=readfile('Xfile2')
|
||||
call writefile(['1a', 'foo', 'bar', '.', 'w! Xn20file2', 'q!'], 'Xn20script')
|
||||
call writefile(['1', '2'], 'Xn20file')
|
||||
call system(GetVimCommand() .. ' -e -s < Xn20script Xn20file')
|
||||
let a=readfile('Xn20file2')
|
||||
call assert_equal(['1', 'foo', 'bar', '2'], a)
|
||||
|
||||
" clean up
|
||||
for file in ['Xfile', 'Xfile2', 'Xscript']
|
||||
for file in ['Xn20file', 'Xn20file2', 'Xn20script']
|
||||
call delete(file)
|
||||
endfor
|
||||
bw!
|
||||
@@ -1758,22 +1758,22 @@ func Test_normal22_zet()
|
||||
" Test for ZZ
|
||||
" let shell = &shell
|
||||
" let &shell = 'sh'
|
||||
call writefile(['1', '2'], 'Xfile')
|
||||
call writefile(['1', '2'], 'Xn22file')
|
||||
let args = ' -N -i NONE --noplugins -X --not-a-term'
|
||||
call system(GetVimCommand() .. args .. ' -c "%d" -c ":norm! ZZ" Xfile')
|
||||
let a = readfile('Xfile')
|
||||
call system(GetVimCommand() .. args .. ' -c "%d" -c ":norm! ZZ" Xn22file')
|
||||
let a = readfile('Xn22file')
|
||||
call assert_equal([], a)
|
||||
" Test for ZQ
|
||||
call writefile(['1', '2'], 'Xfile')
|
||||
call system(GetVimCommand() . args . ' -c "%d" -c ":norm! ZQ" Xfile')
|
||||
let a = readfile('Xfile')
|
||||
call writefile(['1', '2'], 'Xn22file')
|
||||
call system(GetVimCommand() . args . ' -c "%d" -c ":norm! ZQ" Xn22file')
|
||||
let a = readfile('Xn22file')
|
||||
call assert_equal(['1', '2'], a)
|
||||
|
||||
" Unsupported Z command
|
||||
call assert_beeps('normal! ZW')
|
||||
|
||||
" clean up
|
||||
for file in ['Xfile']
|
||||
for file in ['Xn22file']
|
||||
call delete(file)
|
||||
endfor
|
||||
" let &shell = shell
|
||||
|
@@ -883,7 +883,7 @@ func Test_write()
|
||||
new
|
||||
call setline(1, ['L1'])
|
||||
set nowrite
|
||||
call assert_fails('write Xfile', 'E142:')
|
||||
call assert_fails('write Xwrfile', 'E142:')
|
||||
set write
|
||||
close!
|
||||
endfunc
|
||||
|
@@ -12,26 +12,26 @@ endfunction
|
||||
|
||||
func Test_edit_bad()
|
||||
" Test loading a utf8 file with bad utf8 sequences.
|
||||
call writefile(["[\xff][\xc0][\xe2\x89\xf0][\xc2\xc2]"], "Xfile")
|
||||
call writefile(["[\xff][\xc0][\xe2\x89\xf0][\xc2\xc2]"], "Xbadfile")
|
||||
new
|
||||
|
||||
" Without ++bad=..., the default behavior is like ++bad=?
|
||||
e! ++enc=utf8 Xfile
|
||||
e! ++enc=utf8 Xbadfile
|
||||
call assert_equal('[?][?][???][??]', getline(1))
|
||||
|
||||
e! ++encoding=utf8 ++bad=_ Xfile
|
||||
e! ++encoding=utf8 ++bad=_ Xbadfile
|
||||
call assert_equal('[_][_][___][__]', getline(1))
|
||||
|
||||
e! ++enc=utf8 ++bad=drop Xfile
|
||||
e! ++enc=utf8 ++bad=drop Xbadfile
|
||||
call assert_equal('[][][][]', getline(1))
|
||||
|
||||
e! ++enc=utf8 ++bad=keep Xfile
|
||||
e! ++enc=utf8 ++bad=keep Xbadfile
|
||||
call assert_equal("[\xff][\xc0][\xe2\x89\xf0][\xc2\xc2]", getline(1))
|
||||
|
||||
call assert_fails('e! ++enc=utf8 ++bad=foo Xfile', 'E474:')
|
||||
call assert_fails('e! ++enc=utf8 ++bad=foo Xbadfile', 'E474:')
|
||||
|
||||
bw!
|
||||
call delete('Xfile')
|
||||
call delete('Xbadfile')
|
||||
endfunc
|
||||
|
||||
" Test for ++bin and ++nobin arguments
|
||||
|
@@ -4104,7 +4104,7 @@ endfunc
|
||||
|
||||
|
||||
func Test_popup_setoptions_other_tab()
|
||||
new Xfile
|
||||
new Xpotfile
|
||||
let winid = win_getid()
|
||||
call setline(1, 'some text')
|
||||
call prop_type_add('textprop', {})
|
||||
@@ -4116,7 +4116,7 @@ func Test_popup_setoptions_other_tab()
|
||||
|
||||
tabclose
|
||||
call popup_close(id)
|
||||
bwipe! Xfile
|
||||
bwipe! Xpotfile
|
||||
call prop_type_delete('textprop')
|
||||
endfunc
|
||||
|
||||
|
@@ -1565,11 +1565,11 @@ func Test_python_buffer()
|
||||
%bw!
|
||||
|
||||
" Range object for a deleted buffer
|
||||
new Xfile
|
||||
new Xpbuffile
|
||||
call setline(1, ['one', 'two', 'three'])
|
||||
py b = vim.current.buffer
|
||||
py r = vim.current.buffer.range(0, 2)
|
||||
call assert_equal('<range Xfile (0:2)>', pyeval('repr(r)'))
|
||||
call assert_equal('<range Xpbuffile (0:2)>', pyeval('repr(r)'))
|
||||
%bw!
|
||||
call AssertException(['py r[:] = []'],
|
||||
\ 'Vim(python):vim.error: attempt to refer to deleted buffer')
|
||||
@@ -1598,7 +1598,7 @@ endfunc
|
||||
" Test vim.buffers object
|
||||
func Test_python_buffers()
|
||||
%bw!
|
||||
edit Xfile
|
||||
edit Xpbuffile
|
||||
py cb = vim.current.buffer
|
||||
set hidden
|
||||
edit a
|
||||
@@ -1626,8 +1626,8 @@ func Test_python_buffers()
|
||||
cb.append('i3:' + str(next(i3)))
|
||||
del i3
|
||||
EOF
|
||||
call assert_equal(['i:<buffer Xfile>',
|
||||
\ 'i2:<buffer Xfile>', 'i:<buffer a>', 'i3:<buffer Xfile>'],
|
||||
call assert_equal(['i:<buffer Xpbuffile>',
|
||||
\ 'i2:<buffer Xpbuffile>', 'i:<buffer a>', 'i3:<buffer Xpbuffile>'],
|
||||
\ getline(2, '$'))
|
||||
%d
|
||||
|
||||
@@ -1645,7 +1645,7 @@ func Test_python_buffers()
|
||||
|
||||
cb.append(str(len(vim.buffers)))
|
||||
EOF
|
||||
call assert_equal([bufnr('Xfile') .. ':<buffer Xfile>=<buffer Xfile>',
|
||||
call assert_equal([bufnr('Xpbuffile') .. ':<buffer Xpbuffile>=<buffer Xpbuffile>',
|
||||
\ bufnr('a') .. ':<buffer a>=<buffer a>',
|
||||
\ bufnr('b') .. ':<buffer b>=<buffer b>',
|
||||
\ bufnr('c') .. ':<buffer c>=<buffer c>', '4'], getline(2, '$'))
|
||||
@@ -1675,15 +1675,15 @@ func Test_python_buffers()
|
||||
del i4
|
||||
del bnums
|
||||
EOF
|
||||
call assert_equal(['i4:<buffer Xfile>',
|
||||
\ 'i4:<buffer Xfile>', 'StopIteration'], getline(2, '$'))
|
||||
call assert_equal(['i4:<buffer Xpbuffile>',
|
||||
\ 'i4:<buffer Xpbuffile>', 'StopIteration'], getline(2, '$'))
|
||||
%bw!
|
||||
endfunc
|
||||
|
||||
" Test vim.{tabpage,window}list and vim.{tabpage,window} objects
|
||||
func Test_python_tabpage_window()
|
||||
%bw
|
||||
edit Xfile
|
||||
edit Xpbuffile
|
||||
py cb = vim.current.buffer
|
||||
tabnew 0
|
||||
tabnew 1
|
||||
@@ -1748,7 +1748,7 @@ func Test_python_tabpage_window()
|
||||
Current tab pages:
|
||||
<tabpage 0>(1): 1 windows, current is <window object (unknown)>
|
||||
Windows:
|
||||
<window object (unknown)>(1): displays buffer <buffer Xfile>; cursor is at (2, 0)
|
||||
<window object (unknown)>(1): displays buffer <buffer Xpbuffile>; cursor is at (2, 0)
|
||||
<tabpage 1>(2): 1 windows, current is <window object (unknown)>
|
||||
Windows:
|
||||
<window object (unknown)>(1): displays buffer <buffer 0>; cursor is at (1, 0)
|
||||
@@ -1764,14 +1764,14 @@ func Test_python_tabpage_window()
|
||||
<window 3>(4): displays buffer <buffer 2>; cursor is at (1, 0)
|
||||
Number of windows in current tab page: 4
|
||||
END
|
||||
call assert_equal(expected, getbufline(bufnr('Xfile'), 2, '$'))
|
||||
call assert_equal(expected, getbufline(bufnr('Xpbuffile'), 2, '$'))
|
||||
%bw!
|
||||
endfunc
|
||||
|
||||
" Test vim.current
|
||||
func Test_python_vim_current()
|
||||
%bw
|
||||
edit Xfile
|
||||
edit Xpbuffile
|
||||
py cb = vim.current.buffer
|
||||
tabnew 0
|
||||
tabnew 1
|
||||
@@ -1797,8 +1797,8 @@ func Test_python_vim_current()
|
||||
Current window: <window 0>: <window 0> is <window 0>
|
||||
Current buffer: <buffer c.2>: <buffer c.2> is <buffer c.2> is <buffer c.2>
|
||||
END
|
||||
call assert_equal(expected, getbufline(bufnr('Xfile'), 2, '$'))
|
||||
call deletebufline(bufnr('Xfile'), 1, '$')
|
||||
call assert_equal(expected, getbufline(bufnr('Xpbuffile'), 2, '$'))
|
||||
call deletebufline(bufnr('Xpbuffile'), 1, '$')
|
||||
|
||||
" Assigning: fails
|
||||
py << trim EOF
|
||||
@@ -1821,10 +1821,10 @@ func Test_python_vim_current()
|
||||
Type error at assigning None to vim.current.tabpage
|
||||
Type error at assigning None to vim.current.buffer
|
||||
END
|
||||
call assert_equal(expected, getbufline(bufnr('Xfile'), 2, '$'))
|
||||
call deletebufline(bufnr('Xfile'), 1, '$')
|
||||
call assert_equal(expected, getbufline(bufnr('Xpbuffile'), 2, '$'))
|
||||
call deletebufline(bufnr('Xpbuffile'), 1, '$')
|
||||
|
||||
call setbufline(bufnr('Xfile'), 1, 'python interface')
|
||||
call setbufline(bufnr('Xpbuffile'), 1, 'python interface')
|
||||
py << trim EOF
|
||||
# Assigning: success
|
||||
vim.current.tabpage = vim.tabpages[-2]
|
||||
@@ -1840,13 +1840,13 @@ func Test_python_vim_current()
|
||||
let expected =<< trim END
|
||||
Current tab page: <tabpage 2>
|
||||
Current window: <window 0>
|
||||
Current buffer: <buffer Xfile>
|
||||
Current buffer: <buffer Xpbuffile>
|
||||
Current line: 'python interface'
|
||||
END
|
||||
call assert_equal(expected, getbufline(bufnr('Xfile'), 2, '$'))
|
||||
call assert_equal(expected, getbufline(bufnr('Xpbuffile'), 2, '$'))
|
||||
py vim.current.line = 'one line'
|
||||
call assert_equal('one line', getline('.'))
|
||||
call deletebufline(bufnr('Xfile'), 1, '$')
|
||||
call deletebufline(bufnr('Xpbuffile'), 1, '$')
|
||||
|
||||
py << trim EOF
|
||||
ws = list(vim.windows)
|
||||
@@ -1866,7 +1866,7 @@ func Test_python_vim_current()
|
||||
w.valid: [True, False]
|
||||
t.valid: [True, False, True, False]
|
||||
END
|
||||
call assert_equal(expected, getbufline(bufnr('Xfile'), 2, '$'))
|
||||
call assert_equal(expected, getbufline(bufnr('Xpbuffile'), 2, '$'))
|
||||
%bw!
|
||||
endfunc
|
||||
|
||||
@@ -2409,7 +2409,7 @@ endfunc
|
||||
|
||||
" Test chdir
|
||||
func Test_python_chdir()
|
||||
new Xfile
|
||||
new Xpycfile
|
||||
py cb = vim.current.buffer
|
||||
py << trim EOF
|
||||
import os
|
||||
@@ -2420,7 +2420,7 @@ func Test_python_chdir()
|
||||
path = fnamemodify('.', ':p:h:t')
|
||||
if path != 'src' and path != 'src2':
|
||||
# Running tests from a shadow directory, so move up another level
|
||||
# This will result in @% looking like shadow/testdir/Xfile, hence the
|
||||
# This will result in @% looking like shadow/testdir/Xpycfile, hence the
|
||||
# extra fnamemodify
|
||||
os.chdir('..')
|
||||
cb.append(fnamemodify('.', ':p:h:t'))
|
||||
@@ -2436,8 +2436,8 @@ func Test_python_chdir()
|
||||
cb.append(vim.eval('@%'))
|
||||
del fnamemodify
|
||||
EOF
|
||||
call assert_equal(['testdir', 'Xfile', 'src', 'testdir/Xfile', 'testdir',
|
||||
\ 'Xfile'], getline(2, '$'))
|
||||
call assert_equal(['testdir', 'Xpycfile', 'src', 'testdir/Xpycfile', 'testdir',
|
||||
\ 'Xpycfile'], getline(2, '$'))
|
||||
close!
|
||||
call AssertException(["py vim.chdir(None)"], "Vim(python):TypeError:")
|
||||
endfunc
|
||||
|
@@ -1762,11 +1762,11 @@ func Test_python3_buffer()
|
||||
%bw!
|
||||
|
||||
" Range object for a deleted buffer
|
||||
new Xfile
|
||||
new Xp3buffile
|
||||
call setline(1, ['one', 'two', 'three'])
|
||||
py3 b = vim.current.buffer
|
||||
py3 r = vim.current.buffer.range(0, 2)
|
||||
call assert_equal('<range Xfile (0:2)>', py3eval('repr(r)'))
|
||||
call assert_equal('<range Xp3buffile (0:2)>', py3eval('repr(r)'))
|
||||
%bw!
|
||||
call AssertException(['py3 r[:] = []'],
|
||||
\ 'Vim(py3):vim.error: attempt to refer to deleted buffer')
|
||||
@@ -1795,7 +1795,7 @@ endfunc
|
||||
" Test vim.buffers object
|
||||
func Test_python3_buffers()
|
||||
%bw!
|
||||
edit Xfile
|
||||
edit Xp3buffile
|
||||
py3 cb = vim.current.buffer
|
||||
set hidden
|
||||
edit a
|
||||
@@ -1819,8 +1819,8 @@ func Test_python3_buffers()
|
||||
cb.append('i3:' + str(next(i3)))
|
||||
del i3
|
||||
EOF
|
||||
call assert_equal(['i:<buffer Xfile>',
|
||||
\ 'i2:<buffer Xfile>', 'i:<buffer a>', 'i3:<buffer Xfile>'],
|
||||
call assert_equal(['i:<buffer Xp3buffile>',
|
||||
\ 'i2:<buffer Xp3buffile>', 'i:<buffer a>', 'i3:<buffer Xp3buffile>'],
|
||||
\ getline(2, '$'))
|
||||
%d
|
||||
|
||||
@@ -1838,7 +1838,7 @@ func Test_python3_buffers()
|
||||
|
||||
cb.append(str(len(vim.buffers)))
|
||||
EOF
|
||||
call assert_equal([bufnr('Xfile') .. ':<buffer Xfile>=<buffer Xfile>',
|
||||
call assert_equal([bufnr('Xp3buffile') .. ':<buffer Xp3buffile>=<buffer Xp3buffile>',
|
||||
\ bufnr('a') .. ':<buffer a>=<buffer a>',
|
||||
\ bufnr('b') .. ':<buffer b>=<buffer b>',
|
||||
\ bufnr('c') .. ':<buffer c>=<buffer c>', '4'], getline(2, '$'))
|
||||
@@ -1868,15 +1868,15 @@ func Test_python3_buffers()
|
||||
del i4
|
||||
del bnums
|
||||
EOF
|
||||
call assert_equal(['i4:<buffer Xfile>',
|
||||
\ 'i4:<buffer Xfile>', 'StopIteration'], getline(2, '$'))
|
||||
call assert_equal(['i4:<buffer Xp3buffile>',
|
||||
\ 'i4:<buffer Xp3buffile>', 'StopIteration'], getline(2, '$'))
|
||||
%bw!
|
||||
endfunc
|
||||
|
||||
" Test vim.{tabpage,window}list and vim.{tabpage,window} objects
|
||||
func Test_python3_tabpage_window()
|
||||
%bw
|
||||
edit Xfile
|
||||
edit Xp3buffile
|
||||
py3 cb = vim.current.buffer
|
||||
tabnew 0
|
||||
tabnew 1
|
||||
@@ -1937,7 +1937,7 @@ func Test_python3_tabpage_window()
|
||||
Current tab pages:
|
||||
<tabpage 0>(1): 1 windows, current is <window object (unknown)>
|
||||
Windows:
|
||||
<window object (unknown)>(1): displays buffer <buffer Xfile>; cursor is at (2, 0)
|
||||
<window object (unknown)>(1): displays buffer <buffer Xp3buffile>; cursor is at (2, 0)
|
||||
<tabpage 1>(2): 1 windows, current is <window object (unknown)>
|
||||
Windows:
|
||||
<window object (unknown)>(1): displays buffer <buffer 0>; cursor is at (1, 0)
|
||||
@@ -1953,14 +1953,14 @@ func Test_python3_tabpage_window()
|
||||
<window 3>(4): displays buffer <buffer 2>; cursor is at (1, 0)
|
||||
Number of windows in current tab page: 4
|
||||
END
|
||||
call assert_equal(expected, getbufline(bufnr('Xfile'), 2, '$'))
|
||||
call assert_equal(expected, getbufline(bufnr('Xp3buffile'), 2, '$'))
|
||||
%bw!
|
||||
endfunc
|
||||
|
||||
" Test vim.current
|
||||
func Test_python3_vim_current()
|
||||
%bw
|
||||
edit Xfile
|
||||
edit Xpy3cfile
|
||||
py3 cb = vim.current.buffer
|
||||
tabnew 0
|
||||
tabnew 1
|
||||
@@ -1986,8 +1986,8 @@ func Test_python3_vim_current()
|
||||
Current window: <window 0>: <window 0> is <window 0>
|
||||
Current buffer: <buffer c.2>: <buffer c.2> is <buffer c.2> is <buffer c.2>
|
||||
END
|
||||
call assert_equal(expected, getbufline(bufnr('Xfile'), 2, '$'))
|
||||
call deletebufline(bufnr('Xfile'), 1, '$')
|
||||
call assert_equal(expected, getbufline(bufnr('Xpy3cfile'), 2, '$'))
|
||||
call deletebufline(bufnr('Xpy3cfile'), 1, '$')
|
||||
|
||||
" Assigning: fails
|
||||
py3 << trim EOF
|
||||
@@ -2010,10 +2010,10 @@ func Test_python3_vim_current()
|
||||
Type error at assigning None to vim.current.tabpage
|
||||
Type error at assigning None to vim.current.buffer
|
||||
END
|
||||
call assert_equal(expected, getbufline(bufnr('Xfile'), 2, '$'))
|
||||
call deletebufline(bufnr('Xfile'), 1, '$')
|
||||
call assert_equal(expected, getbufline(bufnr('Xpy3cfile'), 2, '$'))
|
||||
call deletebufline(bufnr('Xpy3cfile'), 1, '$')
|
||||
|
||||
call setbufline(bufnr('Xfile'), 1, 'python interface')
|
||||
call setbufline(bufnr('Xpy3cfile'), 1, 'python interface')
|
||||
py3 << trim EOF
|
||||
# Assigning: success
|
||||
vim.current.tabpage = vim.tabpages[-2]
|
||||
@@ -2029,13 +2029,13 @@ func Test_python3_vim_current()
|
||||
let expected =<< trim END
|
||||
Current tab page: <tabpage 2>
|
||||
Current window: <window 0>
|
||||
Current buffer: <buffer Xfile>
|
||||
Current buffer: <buffer Xpy3cfile>
|
||||
Current line: 'python interface'
|
||||
END
|
||||
call assert_equal(expected, getbufline(bufnr('Xfile'), 2, '$'))
|
||||
call assert_equal(expected, getbufline(bufnr('Xpy3cfile'), 2, '$'))
|
||||
py3 vim.current.line = 'one line'
|
||||
call assert_equal('one line', getline('.'))
|
||||
call deletebufline(bufnr('Xfile'), 1, '$')
|
||||
call deletebufline(bufnr('Xpy3cfile'), 1, '$')
|
||||
|
||||
py3 << trim EOF
|
||||
ws = list(vim.windows)
|
||||
@@ -2055,7 +2055,7 @@ func Test_python3_vim_current()
|
||||
w.valid: [True, False]
|
||||
t.valid: [True, False, True, False]
|
||||
END
|
||||
call assert_equal(expected, getbufline(bufnr('Xfile'), 2, '$'))
|
||||
call assert_equal(expected, getbufline(bufnr('Xpy3cfile'), 2, '$'))
|
||||
%bw!
|
||||
endfunc
|
||||
|
||||
@@ -2598,7 +2598,7 @@ endfunc
|
||||
|
||||
" Test chdir
|
||||
func Test_python3_chdir()
|
||||
new Xfile
|
||||
new Xp3cdfile
|
||||
py3 cb = vim.current.buffer
|
||||
py3 << trim EOF
|
||||
import os
|
||||
@@ -2609,7 +2609,7 @@ func Test_python3_chdir()
|
||||
path = fnamemodify('.', ':p:h:t')
|
||||
if path != b'src' and path != b'src2':
|
||||
# Running tests from a shadow directory, so move up another level
|
||||
# This will result in @% looking like shadow/testdir/Xfile, hence the
|
||||
# This will result in @% looking like shadow/testdir/Xp3cdfile, hence the
|
||||
# slicing to remove the leading path and path separator
|
||||
os.chdir('..')
|
||||
cb.append(str(fnamemodify('.', ':p:h:t')))
|
||||
@@ -2625,8 +2625,8 @@ func Test_python3_chdir()
|
||||
cb.append(vim.eval('@%'))
|
||||
del fnamemodify
|
||||
EOF
|
||||
call assert_equal(["b'testdir'", 'Xfile', "b'src'", 'testdir/Xfile',
|
||||
\"b'testdir'", 'Xfile'], getline(2, '$'))
|
||||
call assert_equal(["b'testdir'", 'Xp3cdfile', "b'src'", 'testdir/Xp3cdfile',
|
||||
\"b'testdir'", 'Xp3cdfile'], getline(2, '$'))
|
||||
close!
|
||||
call AssertException(["py3 vim.chdir(None)"], "Vim(py3):TypeError:")
|
||||
endfunc
|
||||
|
@@ -63,10 +63,10 @@ endfunc
|
||||
|
||||
" When sourcing a vim script, shebang should be ignored.
|
||||
func Test_source_ignore_shebang()
|
||||
call writefile(['#!./xyzabc', 'let g:val=369'], 'Xfile.vim')
|
||||
source Xfile.vim
|
||||
call writefile(['#!./xyzabc', 'let g:val=369'], 'Xsisfile.vim')
|
||||
source Xsisfile.vim
|
||||
call assert_equal(g:val, 369)
|
||||
call delete('Xfile.vim')
|
||||
call delete('Xsisfile.vim')
|
||||
endfunc
|
||||
|
||||
" Test for expanding <sfile> in an autocmd and for <slnum> and <sflnum>
|
||||
@@ -480,12 +480,12 @@ func Test_source_buffer_vim9()
|
||||
|
||||
augroup Test
|
||||
au!
|
||||
au BufNewFile Xfile g:readFile = 1
|
||||
au BufNewFile Xsubfile g:readFile = 1
|
||||
| g:readExtra = 2
|
||||
augroup END
|
||||
g:readFile = 0
|
||||
g:readExtra = 0
|
||||
new Xfile
|
||||
new Xsubfile
|
||||
bwipe!
|
||||
augroup Test
|
||||
au!
|
||||
|
@@ -171,7 +171,7 @@ func Test_getftype()
|
||||
return
|
||||
endif
|
||||
|
||||
silent !ln -s Xfile Xlink
|
||||
silent !ln -s Xlinkfile Xlink
|
||||
call assert_equal('link', getftype('Xlink'))
|
||||
call delete('Xlink')
|
||||
|
||||
|
@@ -141,7 +141,7 @@ endfunc
|
||||
|
||||
func Test_substitute_repeat()
|
||||
" This caused an invalid memory access.
|
||||
split Xfile
|
||||
split Xsubfile
|
||||
s/^/x
|
||||
call feedkeys("Qsc\<CR>y", 'tx')
|
||||
bwipe!
|
||||
@@ -1068,7 +1068,7 @@ func Test_sub_edit_scriptfile()
|
||||
new
|
||||
norm o0000000000000000000000000000000000000000000000000000
|
||||
func EditScript()
|
||||
silent! scr! Xfile
|
||||
silent! scr! Xsedfile
|
||||
endfunc
|
||||
s/\%')/\=EditScript()
|
||||
|
||||
|
@@ -768,14 +768,14 @@ endfunc
|
||||
func Test_tabpage_close_on_switch()
|
||||
tabnew
|
||||
tabnew
|
||||
edit Xfile
|
||||
edit Xtabfile
|
||||
augroup T2
|
||||
au!
|
||||
au BufLeave Xfile 1tabclose
|
||||
au BufLeave Xtabfile 1tabclose
|
||||
augroup END
|
||||
tabfirst
|
||||
call assert_equal(2, tabpagenr())
|
||||
call assert_equal('Xfile', @%)
|
||||
call assert_equal('Xtabfile', @%)
|
||||
augroup T2
|
||||
au!
|
||||
augroup END
|
||||
|
@@ -15,20 +15,20 @@ endfunc
|
||||
func Test_ptjump()
|
||||
CheckFeature quickfix
|
||||
|
||||
set tags=Xtags
|
||||
set tags=Xpttags
|
||||
call writefile(["!_TAG_FILE_ENCODING\tutf-8\t//",
|
||||
\ "one\tXfile\t1",
|
||||
\ "three\tXfile\t3",
|
||||
\ "two\tXfile\t2"],
|
||||
\ 'Xtags')
|
||||
call writefile(['one', 'two', 'three'], 'Xfile')
|
||||
\ "one\tXptfile\t1",
|
||||
\ "three\tXptfile\t3",
|
||||
\ "two\tXptfile\t2"],
|
||||
\ 'Xpttags')
|
||||
call writefile(['one', 'two', 'three'], 'Xptfile')
|
||||
|
||||
%bw!
|
||||
ptjump two
|
||||
call assert_equal(2, winnr())
|
||||
wincmd p
|
||||
call assert_equal(1, &previewwindow)
|
||||
call assert_equal('Xfile', expand("%:p:t"))
|
||||
call assert_equal('Xptfile', expand("%:p:t"))
|
||||
call assert_equal(2, line('.'))
|
||||
call assert_equal(2, winnr('$'))
|
||||
call assert_equal(1, winnr())
|
||||
@@ -38,7 +38,7 @@ func Test_ptjump()
|
||||
call assert_equal(2, winnr())
|
||||
wincmd p
|
||||
call assert_equal(1, &previewwindow)
|
||||
call assert_equal('Xfile', expand("%:p:t"))
|
||||
call assert_equal('Xptfile', expand("%:p:t"))
|
||||
call assert_equal(3, line('.'))
|
||||
call assert_equal(2, winnr('$'))
|
||||
call assert_equal(1, winnr())
|
||||
@@ -48,8 +48,8 @@ func Test_ptjump()
|
||||
call assert_equal(5, winheight(0))
|
||||
close
|
||||
|
||||
call delete('Xtags')
|
||||
call delete('Xfile')
|
||||
call delete('Xpttags')
|
||||
call delete('Xptfile')
|
||||
set tags&
|
||||
endfunc
|
||||
|
||||
@@ -73,12 +73,12 @@ func Test_cancel_ptjump()
|
||||
endfunc
|
||||
|
||||
func Test_static_tagjump()
|
||||
set tags=Xtags
|
||||
set tags=Xtjtags
|
||||
call writefile(["!_TAG_FILE_ENCODING\tutf-8\t//",
|
||||
\ "one\tXfile1\t/^one/;\"\tf\tfile:\tsignature:(void)",
|
||||
\ "word\tXfile2\tcmd2"],
|
||||
\ 'Xtags')
|
||||
new Xfile1
|
||||
\ "one\tXtjfile1\t/^one/;\"\tf\tfile:\tsignature:(void)",
|
||||
\ "word\tXtjfile2\tcmd2"],
|
||||
\ 'Xtjtags')
|
||||
new Xtjfile1
|
||||
call setline(1, ['empty', 'one()', 'empty'])
|
||||
write
|
||||
tag one
|
||||
@@ -86,19 +86,19 @@ func Test_static_tagjump()
|
||||
|
||||
bwipe!
|
||||
set tags&
|
||||
call delete('Xtags')
|
||||
call delete('Xfile1')
|
||||
call delete('Xtjtags')
|
||||
call delete('Xtjfile1')
|
||||
endfunc
|
||||
|
||||
func Test_duplicate_tagjump()
|
||||
set tags=Xtags
|
||||
set tags=Xdttags
|
||||
call writefile(["!_TAG_FILE_ENCODING\tutf-8\t//",
|
||||
\ "thesame\tXfile1\t1;\"\td\tfile:",
|
||||
\ "thesame\tXfile1\t2;\"\td\tfile:",
|
||||
\ "thesame\tXfile1\t3;\"\td\tfile:",
|
||||
\ "thesame\tXdtfile1\t1;\"\td\tfile:",
|
||||
\ "thesame\tXdtfile1\t2;\"\td\tfile:",
|
||||
\ "thesame\tXdtfile1\t3;\"\td\tfile:",
|
||||
\ ],
|
||||
\ 'Xtags')
|
||||
new Xfile1
|
||||
\ 'Xdttags')
|
||||
new Xdtfile1
|
||||
call setline(1, ['thesame one', 'thesame two', 'thesame three'])
|
||||
write
|
||||
tag thesame
|
||||
@@ -110,19 +110,19 @@ func Test_duplicate_tagjump()
|
||||
|
||||
bwipe!
|
||||
set tags&
|
||||
call delete('Xtags')
|
||||
call delete('Xfile1')
|
||||
call delete('Xdttags')
|
||||
call delete('Xdtfile1')
|
||||
endfunc
|
||||
|
||||
func Test_tagjump_switchbuf()
|
||||
CheckFeature quickfix
|
||||
|
||||
set tags=Xtags
|
||||
set tags=Xswtags
|
||||
call writefile(["!_TAG_FILE_ENCODING\tutf-8\t//",
|
||||
\ "second\tXfile1\t2",
|
||||
\ "third\tXfile1\t3",],
|
||||
\ 'Xtags')
|
||||
call writefile(['first', 'second', 'third'], 'Xfile1')
|
||||
\ "second\tXsbfile1\t2",
|
||||
\ "third\tXsbfile1\t3",],
|
||||
\ 'Xswtags')
|
||||
call writefile(['first', 'second', 'third'], 'Xsbfile1')
|
||||
|
||||
enew | only
|
||||
set switchbuf=
|
||||
@@ -153,8 +153,8 @@ func Test_tagjump_switchbuf()
|
||||
|
||||
tabclose!
|
||||
enew | only
|
||||
call delete('Xfile1')
|
||||
call delete('Xtags')
|
||||
call delete('Xsbfile1')
|
||||
call delete('Xswtags')
|
||||
set tags&
|
||||
set switchbuf&vim
|
||||
endfunc
|
||||
@@ -205,14 +205,14 @@ func Test_tag_symbolic()
|
||||
call writefile([
|
||||
\ "SECTION_OFF " . getcwd() . "/Xtest.dir/Xtest.c /^#define SECTION_OFF 3$/",
|
||||
\ '',
|
||||
\ ], 'Xtags')
|
||||
\ ], 'Xsymtags')
|
||||
call writefile(['#define SECTION_OFF 3',
|
||||
\ '#define NUM_SECTIONS 3'], 'Xtest.c')
|
||||
|
||||
" Try jumping to a tag, but with a path that contains a symbolic link. When
|
||||
" wrong, this will give the ATTENTION message. The next space will then be
|
||||
" eaten by hit-return, instead of moving the cursor to 'd'.
|
||||
set tags=Xtags
|
||||
set tags=Xsymtags
|
||||
enew!
|
||||
call append(0, 'SECTION_OFF')
|
||||
call cursor(1,1)
|
||||
@@ -223,7 +223,7 @@ func Test_tag_symbolic()
|
||||
set hidden&
|
||||
set tags&
|
||||
enew!
|
||||
call delete('Xtags')
|
||||
call delete('Xsymtags')
|
||||
call delete('Xtest.c')
|
||||
call delete("Xtest.dir", "rf")
|
||||
%bwipe!
|
||||
@@ -263,12 +263,12 @@ func Test_tag_file_encoding()
|
||||
new
|
||||
let content = ['!_TAG_FILE_ENCODING cp932 //',
|
||||
\ "\x82`\x82a\x82b Xtags2.txt /\x82`\x82a\x82b"]
|
||||
call writefile(content, 'Xtags')
|
||||
set tags=Xtags
|
||||
call writefile(content, 'Xenctags')
|
||||
set tags=Xenctags
|
||||
tag /.BC
|
||||
call assert_equal('Xtags2.txt', expand('%:t'))
|
||||
call assert_equal('ABC', getline('.'))
|
||||
call delete('Xtags')
|
||||
call delete('Xenctags')
|
||||
close
|
||||
|
||||
" case3:
|
||||
@@ -280,12 +280,12 @@ func Test_tag_file_encoding()
|
||||
call add(contents, 'abc' .. i
|
||||
\ .. " Xtags3.txt /\x82`\x82a\x82b")
|
||||
endfor
|
||||
call writefile(contents, 'Xtags')
|
||||
set tags=Xtags
|
||||
call writefile(contents, 'Xenctags')
|
||||
set tags=Xenctags
|
||||
tag abc50
|
||||
call assert_equal('Xtags3.txt', expand('%:t'))
|
||||
call assert_equal('ABC', getline('.'))
|
||||
call delete('Xtags')
|
||||
call delete('Xenctags')
|
||||
close
|
||||
|
||||
set tags&
|
||||
@@ -314,8 +314,8 @@ func Test_tagjump_etags()
|
||||
\ "Xmain.c,64",
|
||||
\ "void foo() {}\x7ffoo\x011,0",
|
||||
\ "int main(int argc, char **argv)\x7fmain\x012,14",
|
||||
\ ], 'Xtags')
|
||||
set tags=Xtags
|
||||
\ ], 'Xtetags')
|
||||
set tags=Xtetags
|
||||
ta foo
|
||||
call assert_equal('void foo() {}', getline('.'))
|
||||
|
||||
@@ -328,7 +328,7 @@ func Test_tagjump_etags()
|
||||
\ "Xnonexisting,include",
|
||||
\ "\x0c",
|
||||
\ "Xtags2,include"
|
||||
\ ], 'Xtags')
|
||||
\ ], 'Xtetags')
|
||||
call writefile([
|
||||
\ "\x0c",
|
||||
\ "Xmain.c,64",
|
||||
@@ -343,7 +343,7 @@ func Test_tagjump_etags()
|
||||
\ "\x0c",
|
||||
\ "Xmain.c,8",
|
||||
\ "int main"
|
||||
\ ], 'Xtags', 'b')
|
||||
\ ], 'Xtetags', 'b')
|
||||
call assert_fails('tag foo', 'E426:')
|
||||
|
||||
" invalid line number
|
||||
@@ -351,7 +351,7 @@ func Test_tagjump_etags()
|
||||
\ "\x0c",
|
||||
\ "Xmain.c,64",
|
||||
\ "void foo() {}\x7ffoo\x0abc,0",
|
||||
\ ], 'Xtags')
|
||||
\ ], 'Xtetags')
|
||||
call assert_fails('tag foo', 'E426:')
|
||||
|
||||
" invalid tag name
|
||||
@@ -359,7 +359,7 @@ func Test_tagjump_etags()
|
||||
\ "\x0c",
|
||||
\ "Xmain.c,64",
|
||||
\ ";;;;\x7f1,0",
|
||||
\ ], 'Xtags')
|
||||
\ ], 'Xtetags')
|
||||
call assert_fails('tag foo', 'E431:')
|
||||
|
||||
" end of file after a CTRL-L line
|
||||
@@ -368,14 +368,14 @@ func Test_tagjump_etags()
|
||||
\ "Xmain.c,64",
|
||||
\ "void foo() {}\x7ffoo\x011,0",
|
||||
\ "\x0c",
|
||||
\ ], 'Xtags')
|
||||
\ ], 'Xtetags')
|
||||
call assert_fails('tag main', 'E426:')
|
||||
|
||||
" error in an included tags file
|
||||
call writefile([
|
||||
\ "\x0c",
|
||||
\ "Xtags2,include"
|
||||
\ ], 'Xtags')
|
||||
\ ], 'Xtetags')
|
||||
call writefile([
|
||||
\ "\x0c",
|
||||
\ "Xmain.c,64",
|
||||
@@ -383,7 +383,7 @@ func Test_tagjump_etags()
|
||||
\ ], 'Xtags2')
|
||||
call assert_fails('tag foo', 'E431:')
|
||||
|
||||
call delete('Xtags')
|
||||
call delete('Xtetags')
|
||||
call delete('Xtags2')
|
||||
call delete('Xmain.c')
|
||||
set tags&
|
||||
@@ -392,9 +392,9 @@ endfunc
|
||||
|
||||
" Test for getting and modifying the tag stack
|
||||
func Test_getsettagstack()
|
||||
call writefile(['line1', 'line2', 'line3'], 'Xfile1')
|
||||
call writefile(['line1', 'line2', 'line3'], 'Xfile2')
|
||||
call writefile(['line1', 'line2', 'line3'], 'Xfile3')
|
||||
call writefile(['line1', 'line2', 'line3'], 'Xstsfile1')
|
||||
call writefile(['line1', 'line2', 'line3'], 'Xstsfile2')
|
||||
call writefile(['line1', 'line2', 'line3'], 'Xstsfile3')
|
||||
|
||||
enew | only
|
||||
call settagstack(1, {'items' : []})
|
||||
@@ -409,12 +409,12 @@ func Test_getsettagstack()
|
||||
call assert_fails("call settagstack(1, {'items' : []}, 'b')", 'E962:')
|
||||
call assert_equal(-1, settagstack(0, test_null_dict()))
|
||||
|
||||
set tags=Xtags
|
||||
set tags=Xtsttags
|
||||
call writefile(["!_TAG_FILE_ENCODING\tutf-8\t//",
|
||||
\ "one\tXfile1\t1",
|
||||
\ "three\tXfile3\t3",
|
||||
\ "two\tXfile2\t2"],
|
||||
\ 'Xtags')
|
||||
\ "one\tXstsfile1\t1",
|
||||
\ "three\tXstsfile3\t3",
|
||||
\ "two\tXstsfile2\t2"],
|
||||
\ 'Xtsttags')
|
||||
|
||||
let stk = []
|
||||
call add(stk, {'bufnr' : bufnr('%'), 'tagname' : 'one',
|
||||
@@ -495,10 +495,10 @@ func Test_getsettagstack()
|
||||
|
||||
" Tag with multiple matches
|
||||
call writefile(["!_TAG_FILE_ENCODING\tutf-8\t//",
|
||||
\ "two\tXfile1\t1",
|
||||
\ "two\tXfile2\t3",
|
||||
\ "two\tXfile3\t2"],
|
||||
\ 'Xtags')
|
||||
\ "two\tXstsfile1\t1",
|
||||
\ "two\tXstsfile2\t3",
|
||||
\ "two\tXstsfile3\t2"],
|
||||
\ 'Xtsttags')
|
||||
call settagstack(1, {'items' : []})
|
||||
tag two
|
||||
tnext
|
||||
@@ -515,10 +515,10 @@ func Test_getsettagstack()
|
||||
call assert_fails('call gettagstack()', 'E342:')
|
||||
|
||||
call settagstack(1, {'items' : []})
|
||||
call delete('Xfile1')
|
||||
call delete('Xfile2')
|
||||
call delete('Xfile3')
|
||||
call delete('Xtags')
|
||||
call delete('Xstsfile1')
|
||||
call delete('Xstsfile2')
|
||||
call delete('Xstsfile3')
|
||||
call delete('Xtsttags')
|
||||
set tags&
|
||||
endfunc
|
||||
|
||||
@@ -735,11 +735,11 @@ endfunc
|
||||
" Test for :ptag
|
||||
func Test_tag_preview()
|
||||
call writefile(["!_TAG_FILE_ENCODING\tutf-8\t//",
|
||||
\ "second\tXfile1\t2",
|
||||
\ "third\tXfile1\t3",],
|
||||
\ "second\tXtpfile1\t2",
|
||||
\ "third\tXtpfile1\t3",],
|
||||
\ 'Xtags')
|
||||
set tags=Xtags
|
||||
call writefile(['first', 'second', 'third'], 'Xfile1')
|
||||
call writefile(['first', 'second', 'third'], 'Xtpfile1')
|
||||
|
||||
enew | only
|
||||
ptag third
|
||||
@@ -766,7 +766,7 @@ func Test_tag_preview()
|
||||
pclose
|
||||
call assert_equal(1, winnr('$'))
|
||||
|
||||
call delete('Xfile1')
|
||||
call delete('Xtpfile1')
|
||||
call delete('Xtags')
|
||||
set tags&
|
||||
endfunc
|
||||
@@ -1453,24 +1453,24 @@ endfunc
|
||||
func Test_tag_length()
|
||||
set tags=Xtags
|
||||
call writefile(["!_TAG_FILE_ENCODING\tutf-8\t//",
|
||||
\ "tame\tXfile1\t1;",
|
||||
\ "tape\tXfile2\t1;"], 'Xtags')
|
||||
call writefile(['tame'], 'Xfile1')
|
||||
call writefile(['tape'], 'Xfile2')
|
||||
\ "tame\tXtlfile1\t1;",
|
||||
\ "tape\tXtlfile2\t1;"], 'Xtags')
|
||||
call writefile(['tame'], 'Xtlfile1')
|
||||
call writefile(['tape'], 'Xtlfile2')
|
||||
|
||||
" Jumping to the tag 'tape', should instead jump to 'tame'
|
||||
new
|
||||
set taglength=2
|
||||
tag tape
|
||||
call assert_equal('Xfile1', @%)
|
||||
call assert_equal('Xtlfile1', @%)
|
||||
" Tag search should jump to the right tag
|
||||
enew
|
||||
tag /^tape$
|
||||
call assert_equal('Xfile2', @%)
|
||||
call assert_equal('Xtlfile2', @%)
|
||||
|
||||
call delete('Xtags')
|
||||
call delete('Xfile1')
|
||||
call delete('Xfile2')
|
||||
call delete('Xtlfile1')
|
||||
call delete('Xtlfile2')
|
||||
set tags& taglength&
|
||||
endfunc
|
||||
|
||||
|
@@ -641,10 +641,10 @@ endfunc
|
||||
func Test_terminal_cwd_failure()
|
||||
" Case 1: Provided directory is not actually a directory. Attempt to make
|
||||
" the file executable as well.
|
||||
call writefile([], 'Xfile')
|
||||
call setfperm('Xfile', 'rwx------')
|
||||
call assert_fails("call term_start(&shell, {'cwd': 'Xfile'})", 'E475:')
|
||||
call delete('Xfile')
|
||||
call writefile([], 'Xtcfile')
|
||||
call setfperm('Xftcile', 'rwx------')
|
||||
call assert_fails("call term_start(&shell, {'cwd': 'Xftcile'})", 'E475:')
|
||||
call delete('Xftcile')
|
||||
|
||||
" Case 2: Directory does not exist.
|
||||
call assert_fails("call term_start(&shell, {'cwd': 'Xdir'})", 'E475:')
|
||||
@@ -878,12 +878,12 @@ endfunc
|
||||
func Test_terminal_redir_file()
|
||||
let g:test_is_flaky = 1
|
||||
let cmd = Get_cat_123_cmd()
|
||||
let buf = term_start(cmd, {'out_io': 'file', 'out_name': 'Xfile'})
|
||||
let buf = term_start(cmd, {'out_io': 'file', 'out_name': 'Xtrfile'})
|
||||
call TermWait(buf)
|
||||
" ConPTY may precede escape sequence. There are things that are not so.
|
||||
if !has('conpty')
|
||||
call WaitForAssert({-> assert_notequal(0, len(readfile("Xfile")))})
|
||||
call assert_match('123', readfile('Xfile')[0])
|
||||
call WaitForAssert({-> assert_notequal(0, len(readfile("Xtrfile")))})
|
||||
call assert_match('123', readfile('Xtrfile')[0])
|
||||
endif
|
||||
let g:job = term_getjob(buf)
|
||||
call WaitForAssert({-> assert_equal("dead", job_status(g:job))})
|
||||
@@ -894,18 +894,18 @@ func Test_terminal_redir_file()
|
||||
" Just wait for a moment.
|
||||
sleep 50m
|
||||
endif
|
||||
call delete('Xfile')
|
||||
call delete('Xtrfile')
|
||||
bwipe
|
||||
|
||||
if has('unix')
|
||||
call writefile(['one line'], 'Xfile')
|
||||
let buf = term_start('cat', {'in_io': 'file', 'in_name': 'Xfile'})
|
||||
call writefile(['one line'], 'Xtrfile')
|
||||
let buf = term_start('cat', {'in_io': 'file', 'in_name': 'Xtrfile'})
|
||||
call TermWait(buf)
|
||||
call WaitForAssert({-> assert_equal('one line', term_getline(buf, 1))})
|
||||
let g:job = term_getjob(buf)
|
||||
call WaitForAssert({-> assert_equal('dead', job_status(g:job))})
|
||||
bwipe
|
||||
call delete('Xfile')
|
||||
call delete('Xtrfile')
|
||||
endif
|
||||
endfunc
|
||||
|
||||
|
@@ -415,11 +415,11 @@ func Test_terminal_does_not_truncate_last_newlines()
|
||||
\ ]
|
||||
|
||||
for c in contents
|
||||
call writefile(c, 'Xfile')
|
||||
call writefile(c, 'Xdntfile')
|
||||
if has('win32')
|
||||
term cmd /c type Xfile
|
||||
term cmd /c type Xdntfile
|
||||
else
|
||||
term cat Xfile
|
||||
term cat Xdntfile
|
||||
endif
|
||||
let bnr = bufnr('$')
|
||||
call assert_equal('terminal', getbufvar(bnr, '&buftype'))
|
||||
@@ -429,7 +429,7 @@ func Test_terminal_does_not_truncate_last_newlines()
|
||||
quit
|
||||
endfor
|
||||
|
||||
call delete('Xfile')
|
||||
call delete('Xdntfile')
|
||||
endfunc
|
||||
|
||||
func GetDummyCmd()
|
||||
|
@@ -2211,7 +2211,7 @@ def Test_script_local_in_legacy()
|
||||
END
|
||||
v9.CheckScriptFailure(lines, 'E476:', 1)
|
||||
|
||||
edit! Xfile
|
||||
edit! Xslfile
|
||||
lines =<< trim END
|
||||
var edit: bool
|
||||
legacy edit
|
||||
|
@@ -931,11 +931,11 @@ func Test_command_modifier_confirm()
|
||||
let lines =<< trim END
|
||||
call setline(1, 'changed')
|
||||
def Getout()
|
||||
confirm write Xfile
|
||||
confirm write Xcmodfile
|
||||
enddef
|
||||
END
|
||||
call writefile(lines, 'Xconfirmscript')
|
||||
call writefile(['empty'], 'Xfile')
|
||||
call writefile(['empty'], 'Xcmodfile')
|
||||
let buf = RunVimInTerminal('-S Xconfirmscript', {'rows': 8})
|
||||
call term_sendkeys(buf, ":call Getout()\n")
|
||||
call WaitForAssert({-> assert_match('(Y)es, \[N\]o: ', term_getline(buf, 8))}, 1000)
|
||||
@@ -945,9 +945,9 @@ func Test_command_modifier_confirm()
|
||||
call TermWait(buf)
|
||||
call StopVimInTerminal(buf)
|
||||
|
||||
call assert_equal(['changed'], readfile('Xfile'))
|
||||
call delete('Xfile')
|
||||
call delete('.Xfile.swp') " in case Vim was killed
|
||||
call assert_equal(['changed'], readfile('Xcmodfile'))
|
||||
call delete('Xcmodfile')
|
||||
call delete('.Xcmodfile.swp') " in case Vim was killed
|
||||
call delete('Xconfirmscript')
|
||||
endfunc
|
||||
|
||||
@@ -1065,13 +1065,13 @@ def Test_command_modifier_other()
|
||||
edit Xsomefile
|
||||
bwipe!
|
||||
|
||||
au BufNewFile Xfile g:readFile = 1
|
||||
au BufNewFile Xcmofile g:readFile = 1
|
||||
g:readFile = 0
|
||||
edit Xfile
|
||||
edit Xcmofile
|
||||
assert_equal(1, g:readFile)
|
||||
bwipe!
|
||||
g:readFile = 0
|
||||
noautocmd edit Xfile
|
||||
noautocmd edit Xcmofile
|
||||
assert_equal(0, g:readFile)
|
||||
au! BufNewFile
|
||||
unlet g:readFile
|
||||
@@ -1407,7 +1407,7 @@ def Test_star_command()
|
||||
enddef
|
||||
|
||||
def Test_cmd_argument_without_colon()
|
||||
new Xfile
|
||||
new Xawcfile
|
||||
setline(1, ['a', 'b', 'c', 'd'])
|
||||
write
|
||||
edit +3 %
|
||||
@@ -1415,7 +1415,7 @@ def Test_cmd_argument_without_colon()
|
||||
edit +/a %
|
||||
assert_equal(1, getcurpos()[1])
|
||||
bwipe
|
||||
delete('Xfile')
|
||||
delete('Xawcfile')
|
||||
enddef
|
||||
|
||||
def Test_ambiguous_user_cmd()
|
||||
@@ -1882,7 +1882,7 @@ def Test_redir_to_var()
|
||||
var text: string
|
||||
redir => text
|
||||
echo 'hello'
|
||||
redir > Xfile
|
||||
redir > Xnopfile
|
||||
redir END
|
||||
END
|
||||
v9.CheckDefFailure(lines, 'E1092:')
|
||||
@@ -2025,10 +2025,10 @@ enddef
|
||||
" Test for the 'previewpopup' option
|
||||
def Test_previewpopup()
|
||||
set previewpopup=height:10,width:60
|
||||
pedit Xfile
|
||||
pedit Xppfile
|
||||
var id = popup_findpreview()
|
||||
assert_notequal(id, 0)
|
||||
assert_match('Xfile', popup_getoptions(id).title)
|
||||
assert_match('Xppfile', popup_getoptions(id).title)
|
||||
popup_clear()
|
||||
set previewpopup&
|
||||
enddef
|
||||
|
@@ -1414,13 +1414,13 @@ def Test_import_in_charconvert()
|
||||
END
|
||||
v9.CheckScriptSuccess(lines)
|
||||
|
||||
writefile(['one', 'two'], 'Xfile')
|
||||
new Xfile
|
||||
write ++enc=ucase Xfile1
|
||||
assert_equal(['ONE', 'TWO'], readfile('Xfile1'))
|
||||
writefile(['one', 'two'], 'Xiicfile')
|
||||
new Xiicfile
|
||||
write ++enc=ucase Xiicfile1
|
||||
assert_equal(['ONE', 'TWO'], readfile('Xiicfile1'))
|
||||
|
||||
delete('Xfile')
|
||||
delete('Xfile1')
|
||||
delete('Xiicfile')
|
||||
delete('Xiicfile1')
|
||||
delete('Xconvert.vim')
|
||||
bwipe!
|
||||
set charconvert&
|
||||
|
@@ -968,11 +968,11 @@ def Test_cnext_works_in_catch()
|
||||
var lines =<< trim END
|
||||
vim9script
|
||||
au BufEnter * eval 1 + 2
|
||||
writefile(['text'], 'Xfile1')
|
||||
writefile(['text'], 'Xfile2')
|
||||
writefile(['text'], 'Xcncfile1')
|
||||
writefile(['text'], 'Xcncfile2')
|
||||
var items = [
|
||||
{lnum: 1, filename: 'Xfile1', valid: true},
|
||||
{lnum: 1, filename: 'Xfile2', valid: true}
|
||||
{lnum: 1, filename: 'Xcncfile1', valid: true},
|
||||
{lnum: 1, filename: 'Xcncfile2', valid: true}
|
||||
]
|
||||
setqflist([], ' ', {items: items})
|
||||
cwindow
|
||||
@@ -988,17 +988,17 @@ def Test_cnext_works_in_catch()
|
||||
|
||||
CnextOrCfirst()
|
||||
CnextOrCfirst()
|
||||
writefile([getqflist({idx: 0}).idx], 'Xresult')
|
||||
writefile([getqflist({idx: 0}).idx], 'Xcncresult')
|
||||
qall
|
||||
END
|
||||
writefile(lines, 'XCatchCnext')
|
||||
g:RunVim([], [], '--clean -S XCatchCnext')
|
||||
assert_equal(['1'], readfile('Xresult'))
|
||||
assert_equal(['1'], readfile('Xcncresult'))
|
||||
|
||||
delete('Xfile1')
|
||||
delete('Xfile2')
|
||||
delete('Xcncfile1')
|
||||
delete('Xcncfile2')
|
||||
delete('XCatchCnext')
|
||||
delete('Xresult')
|
||||
delete('Xcncresult')
|
||||
enddef
|
||||
|
||||
def Test_throw_skipped()
|
||||
@@ -2708,7 +2708,7 @@ def Test_vim9_comment()
|
||||
'#{something',
|
||||
], 'E1170:')
|
||||
|
||||
split Xfile
|
||||
split Xv9cfile
|
||||
v9.CheckScriptSuccess([
|
||||
'vim9script',
|
||||
'edit #something',
|
||||
@@ -3544,20 +3544,20 @@ def Test_restoring_cpo()
|
||||
mkdir('Xhome')
|
||||
var lines =<< trim END
|
||||
vim9script
|
||||
writefile(['before: ' .. &cpo], 'Xresult')
|
||||
writefile(['before: ' .. &cpo], 'Xrporesult')
|
||||
set cpo+=M
|
||||
writefile(['after: ' .. &cpo], 'Xresult', 'a')
|
||||
writefile(['after: ' .. &cpo], 'Xrporesult', 'a')
|
||||
END
|
||||
writefile(lines, 'Xhome/.vimrc')
|
||||
|
||||
lines =<< trim END
|
||||
call writefile(['later: ' .. &cpo], 'Xresult', 'a')
|
||||
call writefile(['later: ' .. &cpo], 'Xrporesult', 'a')
|
||||
END
|
||||
writefile(lines, 'Xlegacy')
|
||||
|
||||
lines =<< trim END
|
||||
vim9script
|
||||
call writefile(['vim9: ' .. &cpo], 'Xresult', 'a')
|
||||
call writefile(['vim9: ' .. &cpo], 'Xrporesult', 'a')
|
||||
qa
|
||||
END
|
||||
writefile(lines, 'Xvim9')
|
||||
@@ -3570,13 +3570,13 @@ def Test_restoring_cpo()
|
||||
'before: aABceFs',
|
||||
'after: aABceFsM',
|
||||
'later: aABceFsM',
|
||||
'vim9: aABceFs'], readfile('Xresult'))
|
||||
'vim9: aABceFs'], readfile('Xrporesult'))
|
||||
|
||||
$HOME = save_HOME
|
||||
delete('Xhome', 'rf')
|
||||
delete('Xlegacy')
|
||||
delete('Xvim9')
|
||||
delete('Xresult')
|
||||
delete('Xrporesult')
|
||||
endif
|
||||
enddef
|
||||
|
||||
|
@@ -1472,7 +1472,7 @@ endfunc
|
||||
func Test_visual_area_adjusted_when_hiding()
|
||||
" The Visual area ended after the end of the line after :hide
|
||||
call setline(1, 'xxx')
|
||||
vsplit Xfile
|
||||
vsplit Xvaafile
|
||||
call setline(1, 'xxxxxxxx')
|
||||
norm! $o
|
||||
hid
|
||||
|
@@ -1083,12 +1083,12 @@ func Run_noroom_for_newwindow_test(dir_arg)
|
||||
endtry
|
||||
endwhile
|
||||
|
||||
call writefile(['first', 'second', 'third'], 'Xfile1')
|
||||
call writefile([], 'Xfile2')
|
||||
call writefile([], 'Xfile3')
|
||||
call writefile(['first', 'second', 'third'], 'Xnorfile1')
|
||||
call writefile([], 'Xnorfile2')
|
||||
call writefile([], 'Xnorfile3')
|
||||
|
||||
" Argument list related commands
|
||||
args Xfile1 Xfile2 Xfile3
|
||||
args Xnorfile1 Xnorfile2 Xnorfile3
|
||||
next
|
||||
for cmd in ['sargument 2', 'snext', 'sprevious', 'sNext', 'srewind',
|
||||
\ 'sfirst', 'slast']
|
||||
@@ -1099,13 +1099,13 @@ func Run_noroom_for_newwindow_test(dir_arg)
|
||||
" Buffer related commands
|
||||
set modified
|
||||
hide enew
|
||||
for cmd in ['sbuffer Xfile1', 'sbnext', 'sbprevious', 'sbNext', 'sbrewind',
|
||||
for cmd in ['sbuffer Xnorfile1', 'sbnext', 'sbprevious', 'sbNext', 'sbrewind',
|
||||
\ 'sbfirst', 'sblast', 'sball', 'sbmodified', 'sunhide']
|
||||
call assert_fails(dir .. cmd, 'E36:')
|
||||
endfor
|
||||
|
||||
" Window related commands
|
||||
for cmd in ['split', 'split Xfile2', 'new', 'new Xfile3', 'sview Xfile1',
|
||||
for cmd in ['split', 'split Xnorfile2', 'new', 'new Xnorfile3', 'sview Xnorfile1',
|
||||
\ 'sfind runtest.vim']
|
||||
call assert_fails(dir .. cmd, 'E36:')
|
||||
endfor
|
||||
@@ -1128,7 +1128,7 @@ func Run_noroom_for_newwindow_test(dir_arg)
|
||||
call assert_fails(dir .. 'lopen', 'E36:')
|
||||
|
||||
" Preview window
|
||||
call assert_fails(dir .. 'pedit Xfile2', 'E36:')
|
||||
call assert_fails(dir .. 'pedit Xnorfile2', 'E36:')
|
||||
call setline(1, 'abc')
|
||||
call assert_fails(dir .. 'psearch abc', 'E36:')
|
||||
endif
|
||||
@@ -1136,15 +1136,15 @@ func Run_noroom_for_newwindow_test(dir_arg)
|
||||
" Window commands (CTRL-W ^ and CTRL-W f)
|
||||
if a:dir_arg == 'h'
|
||||
call assert_fails('call feedkeys("\<C-W>^", "xt")', 'E36:')
|
||||
call setline(1, 'Xfile1')
|
||||
call setline(1, 'Xnorfile1')
|
||||
call assert_fails('call feedkeys("gg\<C-W>f", "xt")', 'E36:')
|
||||
endif
|
||||
enew!
|
||||
|
||||
" Tag commands (:stag, :stselect and :stjump)
|
||||
call writefile(["!_TAG_FILE_ENCODING\tutf-8\t//",
|
||||
\ "second\tXfile1\t2",
|
||||
\ "third\tXfile1\t3",],
|
||||
\ "second\tXnorfile1\t2",
|
||||
\ "third\tXnorfile1\t3",],
|
||||
\ 'Xtags')
|
||||
set tags=Xtags
|
||||
call assert_fails(dir .. 'stag second', 'E36:')
|
||||
@@ -1166,9 +1166,9 @@ func Run_noroom_for_newwindow_test(dir_arg)
|
||||
endif
|
||||
|
||||
%bwipe!
|
||||
call delete('Xfile1')
|
||||
call delete('Xfile2')
|
||||
call delete('Xfile3')
|
||||
call delete('Xnorfile1')
|
||||
call delete('Xnorfile2')
|
||||
call delete('Xnorfile3')
|
||||
only
|
||||
endfunc
|
||||
|
||||
@@ -1387,16 +1387,16 @@ endfunc
|
||||
" window to another.
|
||||
func Test_close_dest_window()
|
||||
split
|
||||
edit Xfile
|
||||
edit Xdstfile
|
||||
|
||||
" Test for BufLeave
|
||||
augroup T1
|
||||
au!
|
||||
au BufLeave Xfile $wincmd c
|
||||
au BufLeave Xdstfile $wincmd c
|
||||
augroup END
|
||||
wincmd b
|
||||
call assert_equal(1, winnr('$'))
|
||||
call assert_equal('Xfile', @%)
|
||||
call assert_equal('Xdstfile', @%)
|
||||
augroup T1
|
||||
au!
|
||||
augroup END
|
||||
@@ -1410,7 +1410,7 @@ func Test_close_dest_window()
|
||||
augroup END
|
||||
wincmd t
|
||||
call assert_equal(1, winnr('$'))
|
||||
call assert_equal('Xfile', @%)
|
||||
call assert_equal('Xdstfile', @%)
|
||||
augroup T1
|
||||
au!
|
||||
augroup END
|
||||
@@ -1595,12 +1595,12 @@ func Test_window_alloc_failure()
|
||||
call assert_fails('split', 'E342:')
|
||||
call assert_equal(1, winnr('$'))
|
||||
|
||||
edit Xfile1
|
||||
edit Xfile2
|
||||
edit Xwaffile1
|
||||
edit Xwaffile2
|
||||
call test_alloc_fail(GetAllocId('newwin_wvars'), 0, 0)
|
||||
call assert_fails('sb Xfile1', 'E342:')
|
||||
call assert_fails('sb Xwaffile1', 'E342:')
|
||||
call assert_equal(1, winnr('$'))
|
||||
call assert_equal('Xfile2', @%)
|
||||
call assert_equal('Xwaffile2', @%)
|
||||
%bw!
|
||||
|
||||
" FIXME: The following test crashes Vim
|
||||
|
@@ -18,7 +18,7 @@ func Test_writefile()
|
||||
call assert_equal("vimmers", l[4])
|
||||
call delete(f)
|
||||
|
||||
call assert_fails('call writefile("text", "Xfile")', 'E475: Invalid argument: writefile() first argument must be a List or a Blob')
|
||||
call assert_fails('call writefile("text", "Xwffile")', 'E475: Invalid argument: writefile() first argument must be a List or a Blob')
|
||||
endfunc
|
||||
|
||||
func Test_writefile_ignore_regexp_error()
|
||||
@@ -27,17 +27,17 @@ func Test_writefile_ignore_regexp_error()
|
||||
endfunc
|
||||
|
||||
func Test_writefile_fails_gently()
|
||||
call assert_fails('call writefile(["test"], "Xfile", [])', 'E730:')
|
||||
call assert_false(filereadable("Xfile"))
|
||||
call delete("Xfile")
|
||||
call assert_fails('call writefile(["test"], "Xwffile", [])', 'E730:')
|
||||
call assert_false(filereadable("Xwffile"))
|
||||
call delete("Xwffile")
|
||||
|
||||
call assert_fails('call writefile(["test", [], [], [], "tset"], "Xfile")', 'E730:')
|
||||
call assert_false(filereadable("Xfile"))
|
||||
call delete("Xfile")
|
||||
call assert_fails('call writefile(["test", [], [], [], "tset"], "Xwffile")', 'E730:')
|
||||
call assert_false(filereadable("Xwffile"))
|
||||
call delete("Xwffile")
|
||||
|
||||
call assert_fails('call writefile([], "Xfile", [])', 'E730:')
|
||||
call assert_false(filereadable("Xfile"))
|
||||
call delete("Xfile")
|
||||
call assert_fails('call writefile([], "Xwffile", [])', 'E730:')
|
||||
call assert_false(filereadable("Xwffile"))
|
||||
call delete("Xwffile")
|
||||
|
||||
call assert_fails('call writefile([], [])', 'E730:')
|
||||
endfunc
|
||||
@@ -52,35 +52,35 @@ func Test_writefile_fails_conversion()
|
||||
set nobackup nowritebackup backupdir=. backupskip=
|
||||
new
|
||||
let contents = ["line one", "line two"]
|
||||
call writefile(contents, 'Xfile')
|
||||
edit Xfile
|
||||
call writefile(contents, 'Xwfcfile')
|
||||
edit Xwfcfile
|
||||
call setline(1, ["first line", "cannot convert \u010b", "third line"])
|
||||
call assert_fails('write ++enc=cp932', 'E513:')
|
||||
call assert_equal(contents, readfile('Xfile'))
|
||||
call assert_equal(contents, readfile('Xwfcfile'))
|
||||
|
||||
" With 'backupcopy' set, if there is a conversion error, the backup file is
|
||||
" still created.
|
||||
set backupcopy=yes writebackup& backup&
|
||||
call delete('Xfile' .. &backupext)
|
||||
call delete('Xwfcfile' .. &backupext)
|
||||
call assert_fails('write ++enc=cp932', 'E513:')
|
||||
call assert_equal(contents, readfile('Xfile'))
|
||||
call assert_equal(contents, readfile('Xfile' .. &backupext))
|
||||
call assert_equal(contents, readfile('Xwfcfile'))
|
||||
call assert_equal(contents, readfile('Xwfcfile' .. &backupext))
|
||||
set backupcopy&
|
||||
%bw!
|
||||
|
||||
" Conversion error during write
|
||||
new
|
||||
call setline(1, ["\U10000000"])
|
||||
let output = execute('write! ++enc=utf-16 Xfile')
|
||||
let output = execute('write! ++enc=utf-16 Xwfcfile')
|
||||
call assert_match('CONVERSION ERROR', output)
|
||||
let output = execute('write! ++enc=ucs-2 Xfile')
|
||||
let output = execute('write! ++enc=ucs-2 Xwfcfile')
|
||||
call assert_match('CONVERSION ERROR', output)
|
||||
call delete('Xfilz~')
|
||||
call delete('Xfily~')
|
||||
%bw!
|
||||
|
||||
call delete('Xfile')
|
||||
call delete('Xfile' .. &backupext)
|
||||
call delete('Xwfcfile')
|
||||
call delete('Xwfcfile' .. &backupext)
|
||||
bwipe!
|
||||
set backup& writebackup& backupdir&vim backupskip&vim
|
||||
endfunc
|
||||
@@ -94,16 +94,16 @@ func Test_writefile_fails_conversion2()
|
||||
" but then the backup file must remain
|
||||
set nobackup writebackup backupdir=. backupskip=
|
||||
let contents = ["line one", "line two"]
|
||||
call writefile(contents, 'Xfile_conversion_err')
|
||||
edit Xfile_conversion_err
|
||||
call writefile(contents, 'Xwf2file_conversion_err')
|
||||
edit Xwf2file_conversion_err
|
||||
call setline(1, ["first line", "cannot convert \u010b", "third line"])
|
||||
set fileencoding=latin1
|
||||
let output = execute('write')
|
||||
call assert_match('CONVERSION ERROR', output)
|
||||
call assert_equal(contents, readfile('Xfile_conversion_err~'))
|
||||
call assert_equal(contents, readfile('Xwf2file_conversion_err~'))
|
||||
|
||||
call delete('Xfile_conversion_err')
|
||||
call delete('Xfile_conversion_err~')
|
||||
call delete('Xwf2file_conversion_err')
|
||||
call delete('Xwf2file_conversion_err~')
|
||||
bwipe!
|
||||
set backup& writebackup& backupdir&vim backupskip&vim
|
||||
endfunc
|
||||
@@ -117,7 +117,7 @@ func Test_write_quit_split()
|
||||
augroup testgroup
|
||||
autocmd BufWritePre * split
|
||||
augroup END
|
||||
e! Xfile
|
||||
e! Xwqsfile
|
||||
call setline(1, 'nothing')
|
||||
wq
|
||||
|
||||
@@ -130,13 +130,13 @@ func Test_write_quit_split()
|
||||
unlet g:flag
|
||||
endif
|
||||
au! testgroup
|
||||
bwipe Xfile
|
||||
call delete('Xfile')
|
||||
bwipe Xwqsfile
|
||||
call delete('Xwqsfile')
|
||||
endfunc
|
||||
|
||||
func Test_nowrite_quit_split()
|
||||
" Prevent exiting by opening a help window.
|
||||
e! Xfile
|
||||
e! Xnqsfile
|
||||
help
|
||||
wincmd w
|
||||
exe winnr() . 'q'
|
||||
@@ -149,7 +149,7 @@ func Test_nowrite_quit_split()
|
||||
call assert_equal(1, g:flag)
|
||||
unlet g:flag
|
||||
endif
|
||||
bwipe Xfile
|
||||
bwipe Xnqsfile
|
||||
endfunc
|
||||
|
||||
func Test_writefile_sync_arg()
|
||||
@@ -213,23 +213,23 @@ func Test_write_pipe_to_cmd()
|
||||
CheckUnix
|
||||
new
|
||||
call setline(1, ['L1', 'L2', 'L3', 'L4'])
|
||||
2,3w !cat > Xfile
|
||||
call assert_equal(['L2', 'L3'], readfile('Xfile'))
|
||||
2,3w !cat > Xptfile
|
||||
call assert_equal(['L2', 'L3'], readfile('Xptfile'))
|
||||
close!
|
||||
call delete('Xfile')
|
||||
call delete('Xptfile')
|
||||
endfunc
|
||||
|
||||
" Test for :saveas
|
||||
func Test_saveas()
|
||||
call assert_fails('saveas', 'E471:')
|
||||
call writefile(['L1'], 'Xfile')
|
||||
new Xfile
|
||||
call writefile(['L1'], 'Xsafile')
|
||||
new Xsafile
|
||||
new
|
||||
call setline(1, ['L1'])
|
||||
call assert_fails('saveas Xfile', 'E139:')
|
||||
call assert_fails('saveas Xsafile', 'E139:')
|
||||
close!
|
||||
enew | only
|
||||
call delete('Xfile')
|
||||
call delete('Xsafile')
|
||||
|
||||
" :saveas should detect and set the file type.
|
||||
syntax on
|
||||
@@ -242,8 +242,8 @@ endfunc
|
||||
|
||||
func Test_write_errors()
|
||||
" Test for writing partial buffer
|
||||
call writefile(['L1', 'L2', 'L3'], 'Xfile')
|
||||
new Xfile
|
||||
call writefile(['L1', 'L2', 'L3'], 'Xwefile')
|
||||
new Xwefile
|
||||
call assert_fails('1,2write', 'E140:')
|
||||
close!
|
||||
|
||||
@@ -263,24 +263,24 @@ func Test_write_errors()
|
||||
enew!
|
||||
|
||||
" Test for writing a 'readonly' file
|
||||
new Xfile
|
||||
new Xwefile
|
||||
set readonly
|
||||
call assert_fails('write', 'E45:')
|
||||
close
|
||||
|
||||
" Test for writing to a read-only file
|
||||
new Xfile
|
||||
call setfperm('Xfile', 'r--r--r--')
|
||||
new Xwefile
|
||||
call setfperm('Xwefile', 'r--r--r--')
|
||||
call assert_fails('write', 'E505:')
|
||||
call setfperm('Xfile', 'rw-rw-rw-')
|
||||
call setfperm('Xwefile', 'rw-rw-rw-')
|
||||
close
|
||||
|
||||
call delete('Xfile')
|
||||
call delete('Xwefile')
|
||||
|
||||
call writefile(test_null_list(), 'Xfile')
|
||||
call assert_false(filereadable('Xfile'))
|
||||
call writefile(test_null_blob(), 'Xfile')
|
||||
call assert_false(filereadable('Xfile'))
|
||||
call writefile(test_null_list(), 'Xwefile')
|
||||
call assert_false(filereadable('Xwefile'))
|
||||
call writefile(test_null_blob(), 'Xwefile')
|
||||
call assert_false(filereadable('Xwefile'))
|
||||
call assert_fails('call writefile([], "")', 'E482:')
|
||||
|
||||
" very long file name
|
||||
@@ -305,9 +305,9 @@ func Test_write_file_mtime()
|
||||
CheckRunVimInTerminal
|
||||
|
||||
" First read the file into a buffer
|
||||
call writefile(["Line1", "Line2"], 'Xfile')
|
||||
let old_ftime = getftime('Xfile')
|
||||
let buf = RunVimInTerminal('Xfile', #{rows : 10})
|
||||
call writefile(["Line1", "Line2"], 'Xwfmfile')
|
||||
let old_ftime = getftime('Xwfmfile')
|
||||
let buf = RunVimInTerminal('Xwfmfile', #{rows : 10})
|
||||
call TermWait(buf)
|
||||
call term_sendkeys(buf, ":set noswapfile\<CR>")
|
||||
call TermWait(buf)
|
||||
@@ -316,12 +316,12 @@ func Test_write_file_mtime()
|
||||
" different. Note that on Linux/Unix, the file is considered modified
|
||||
" outside, only if the difference is 2 seconds or more
|
||||
sleep 1
|
||||
call writefile(["Line3", "Line4"], 'Xfile')
|
||||
let new_ftime = getftime('Xfile')
|
||||
call writefile(["Line3", "Line4"], 'Xwfmfile')
|
||||
let new_ftime = getftime('Xwfmfile')
|
||||
while new_ftime - old_ftime < 2
|
||||
sleep 100m
|
||||
call writefile(["Line3", "Line4"], 'Xfile')
|
||||
let new_ftime = getftime('Xfile')
|
||||
call writefile(["Line3", "Line4"], 'Xwfmfile')
|
||||
let new_ftime = getftime('Xwfmfile')
|
||||
endwhile
|
||||
|
||||
" Try to overwrite the file and check for the prompt
|
||||
@@ -332,24 +332,24 @@ func Test_write_file_mtime()
|
||||
\ term_getline(buf, 10))
|
||||
call term_sendkeys(buf, "n\<CR>")
|
||||
call TermWait(buf)
|
||||
call assert_equal(new_ftime, getftime('Xfile'))
|
||||
call assert_equal(new_ftime, getftime('Xwfmfile'))
|
||||
call term_sendkeys(buf, ":w\<CR>")
|
||||
call TermWait(buf)
|
||||
call term_sendkeys(buf, "y\<CR>")
|
||||
call TermWait(buf)
|
||||
call WaitForAssert({-> assert_equal('Line2', readfile('Xfile')[1])})
|
||||
call WaitForAssert({-> assert_equal('Line2', readfile('Xwfmfile')[1])})
|
||||
|
||||
" clean up
|
||||
call StopVimInTerminal(buf)
|
||||
call delete('Xfile')
|
||||
call delete('Xwfmfile')
|
||||
endfunc
|
||||
|
||||
" Test for an autocmd unloading a buffer during a write command
|
||||
func Test_write_autocmd_unloadbuf_lockmark()
|
||||
augroup WriteTest
|
||||
autocmd BufWritePre Xfile enew | write
|
||||
autocmd BufWritePre Xwaufile enew | write
|
||||
augroup END
|
||||
e Xfile
|
||||
e Xwaufile
|
||||
call assert_fails('lockmarks write', ['E32:', 'E203:'])
|
||||
augroup WriteTest
|
||||
au!
|
||||
@@ -359,7 +359,7 @@ endfunc
|
||||
|
||||
" Test for writing a buffer with 'acwrite' but without autocmds
|
||||
func Test_write_acwrite_error()
|
||||
new Xfile
|
||||
new Xwaefile
|
||||
call setline(1, ['line1', 'line2', 'line3'])
|
||||
set buftype=acwrite
|
||||
call assert_fails('write', 'E676:')
|
||||
@@ -370,35 +370,35 @@ endfunc
|
||||
|
||||
" Test for adding and removing lines from an autocmd when writing a buffer
|
||||
func Test_write_autocmd_add_remove_lines()
|
||||
new Xfile
|
||||
new Xwaafile
|
||||
call setline(1, ['aaa', 'bbb', 'ccc', 'ddd'])
|
||||
|
||||
" Autocmd deleting lines from the file when writing a partial file
|
||||
augroup WriteTest2
|
||||
au!
|
||||
autocmd FileWritePre Xfile 1,2d
|
||||
autocmd FileWritePre Xwaafile 1,2d
|
||||
augroup END
|
||||
call assert_fails('2,3w!', 'E204:')
|
||||
|
||||
" Autocmd adding lines to a file when writing a partial file
|
||||
augroup WriteTest2
|
||||
au!
|
||||
autocmd FileWritePre Xfile call append(0, ['xxx', 'yyy'])
|
||||
autocmd FileWritePre Xwaafile call append(0, ['xxx', 'yyy'])
|
||||
augroup END
|
||||
%d
|
||||
call setline(1, ['aaa', 'bbb', 'ccc', 'ddd'])
|
||||
1,2w!
|
||||
call assert_equal(['xxx', 'yyy', 'aaa', 'bbb'], readfile('Xfile'))
|
||||
call assert_equal(['xxx', 'yyy', 'aaa', 'bbb'], readfile('Xwaafile'))
|
||||
|
||||
" Autocmd deleting lines from the file when writing the whole file
|
||||
augroup WriteTest2
|
||||
au!
|
||||
autocmd BufWritePre Xfile 1,2d
|
||||
autocmd BufWritePre Xwaafile 1,2d
|
||||
augroup END
|
||||
%d
|
||||
call setline(1, ['aaa', 'bbb', 'ccc', 'ddd'])
|
||||
w
|
||||
call assert_equal(['ccc', 'ddd'], readfile('Xfile'))
|
||||
call assert_equal(['ccc', 'ddd'], readfile('Xwaafile'))
|
||||
|
||||
augroup WriteTest2
|
||||
au!
|
||||
@@ -406,14 +406,14 @@ func Test_write_autocmd_add_remove_lines()
|
||||
augroup! WriteTest2
|
||||
|
||||
close!
|
||||
call delete('Xfile')
|
||||
call delete('Xwaafile')
|
||||
endfunc
|
||||
|
||||
" Test for writing to a readonly file
|
||||
func Test_write_readonly()
|
||||
call writefile([], 'Xfile')
|
||||
call setfperm('Xfile', "r--------")
|
||||
edit Xfile
|
||||
call writefile([], 'Xwrofile')
|
||||
call setfperm('Xwrofile', "r--------")
|
||||
edit Xwrofile
|
||||
set noreadonly backupskip=
|
||||
call assert_fails('write', 'E505:')
|
||||
let save_cpo = &cpo
|
||||
@@ -422,11 +422,11 @@ func Test_write_readonly()
|
||||
let &cpo = save_cpo
|
||||
call setline(1, ['line1'])
|
||||
write!
|
||||
call assert_equal(['line1'], readfile('Xfile'))
|
||||
call assert_equal(['line1'], readfile('Xwrofile'))
|
||||
|
||||
" Auto-saving a readonly file should fail with 'autowriteall'
|
||||
%bw!
|
||||
e Xfile
|
||||
e Xwrofile
|
||||
set noreadonly autowriteall
|
||||
call setline(1, ['aaaa'])
|
||||
call assert_fails('n', 'E505:')
|
||||
@@ -436,39 +436,39 @@ func Test_write_readonly()
|
||||
set autowriteall&
|
||||
|
||||
set backupskip&
|
||||
call delete('Xfile')
|
||||
call delete('Xwrofile')
|
||||
%bw!
|
||||
endfunc
|
||||
|
||||
" Test for 'patchmode'
|
||||
func Test_patchmode()
|
||||
call writefile(['one'], 'Xfile')
|
||||
call writefile(['one'], 'Xpafile')
|
||||
set patchmode=.orig nobackup backupskip= writebackup
|
||||
new Xfile
|
||||
new Xpafile
|
||||
call setline(1, 'two')
|
||||
" first write should create the .orig file
|
||||
write
|
||||
call assert_equal(['one'], readfile('Xfile.orig'))
|
||||
call assert_equal(['one'], readfile('Xpafile.orig'))
|
||||
call setline(1, 'three')
|
||||
" subsequent writes should not create/modify the .orig file
|
||||
write
|
||||
call assert_equal(['one'], readfile('Xfile.orig'))
|
||||
call assert_equal(['one'], readfile('Xpafile.orig'))
|
||||
|
||||
" use 'patchmode' with 'nobackup' and 'nowritebackup' to create an empty
|
||||
" original file
|
||||
call delete('Xfile')
|
||||
call delete('Xfile.orig')
|
||||
call delete('Xpafile')
|
||||
call delete('Xpafile.orig')
|
||||
%bw!
|
||||
set patchmode=.orig nobackup nowritebackup
|
||||
edit Xfile
|
||||
edit Xpafile
|
||||
call setline(1, ['xxx'])
|
||||
write
|
||||
call assert_equal(['xxx'], readfile('Xfile'))
|
||||
call assert_equal([], readfile('Xfile.orig'))
|
||||
call assert_equal(['xxx'], readfile('Xpafile'))
|
||||
call assert_equal([], readfile('Xpafile.orig'))
|
||||
|
||||
set patchmode& backup& backupskip& writebackup&
|
||||
call delete('Xfile')
|
||||
call delete('Xfile.orig')
|
||||
call delete('Xpafile')
|
||||
call delete('Xpafile.orig')
|
||||
endfunc
|
||||
|
||||
" Test for writing to a file in a readonly directory
|
||||
@@ -500,7 +500,7 @@ endfunc
|
||||
func Test_write_invalid_encoding()
|
||||
new
|
||||
call setline(1, 'abc')
|
||||
call assert_fails('write ++enc=axbyc Xfile', 'E213:')
|
||||
call assert_fails('write ++enc=axbyc Xiefile', 'E213:')
|
||||
close!
|
||||
endfunc
|
||||
|
||||
@@ -515,101 +515,101 @@ func Test_write_file_encoding()
|
||||
2 cp1251 text: <20><><EFBFBD> Vim version 6.2. <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: 1970 Jan 01
|
||||
3 cp866 text: <20><><EFBFBD> Vim version 6.2. <20><><EFBFBD><E1ABA5><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: 1970 Jan 01
|
||||
END
|
||||
call writefile(text, 'Xfile')
|
||||
edit Xfile
|
||||
call writefile(text, 'Xwfefile')
|
||||
edit Xwfefile
|
||||
|
||||
" write tests:
|
||||
" combine three values for 'encoding' with three values for 'fileencoding'
|
||||
" also write files for read tests
|
||||
call cursor(1, 1)
|
||||
set encoding=utf-8
|
||||
.w! ++enc=utf-8 Xtest
|
||||
.w ++enc=cp1251 >> Xtest
|
||||
.w ++enc=cp866 >> Xtest
|
||||
.w! ++enc=utf-8 Xwfetest
|
||||
.w ++enc=cp1251 >> Xwfetest
|
||||
.w ++enc=cp866 >> Xwfetest
|
||||
.w! ++enc=utf-8 Xutf8
|
||||
let expected =<< trim END
|
||||
1 utf-8 text: Для Vim version 6.2. Последнее изменение: 1970 Jan 01
|
||||
1 utf-8 text: <20><><EFBFBD> Vim version 6.2. <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: 1970 Jan 01
|
||||
1 utf-8 text: <20><><EFBFBD> Vim version 6.2. <20><><EFBFBD><E1ABA5><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: 1970 Jan 01
|
||||
END
|
||||
call assert_equal(expected, readfile('Xtest'))
|
||||
call assert_equal(expected, readfile('Xwfetest'))
|
||||
|
||||
call cursor(2, 1)
|
||||
set encoding=cp1251
|
||||
.w! ++enc=utf-8 Xtest
|
||||
.w ++enc=cp1251 >> Xtest
|
||||
.w ++enc=cp866 >> Xtest
|
||||
.w! ++enc=utf-8 Xwfetest
|
||||
.w ++enc=cp1251 >> Xwfetest
|
||||
.w ++enc=cp866 >> Xwfetest
|
||||
.w! ++enc=cp1251 Xcp1251
|
||||
let expected =<< trim END
|
||||
2 cp1251 text: Для Vim version 6.2. Последнее изменение: 1970 Jan 01
|
||||
2 cp1251 text: <20><><EFBFBD> Vim version 6.2. <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: 1970 Jan 01
|
||||
2 cp1251 text: <20><><EFBFBD> Vim version 6.2. <20><><EFBFBD><E1ABA5><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: 1970 Jan 01
|
||||
END
|
||||
call assert_equal(expected, readfile('Xtest'))
|
||||
call assert_equal(expected, readfile('Xwfetest'))
|
||||
|
||||
call cursor(3, 1)
|
||||
set encoding=cp866
|
||||
.w! ++enc=utf-8 Xtest
|
||||
.w ++enc=cp1251 >> Xtest
|
||||
.w ++enc=cp866 >> Xtest
|
||||
.w! ++enc=utf-8 Xwfetest
|
||||
.w ++enc=cp1251 >> Xwfetest
|
||||
.w ++enc=cp866 >> Xwfetest
|
||||
.w! ++enc=cp866 Xcp866
|
||||
let expected =<< trim END
|
||||
3 cp866 text: Для Vim version 6.2. Последнее изменение: 1970 Jan 01
|
||||
3 cp866 text: <20><><EFBFBD> Vim version 6.2. <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: 1970 Jan 01
|
||||
3 cp866 text: <20><><EFBFBD> Vim version 6.2. <20><><EFBFBD><E1ABA5><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: 1970 Jan 01
|
||||
END
|
||||
call assert_equal(expected, readfile('Xtest'))
|
||||
call assert_equal(expected, readfile('Xwfetest'))
|
||||
|
||||
" read three 'fileencoding's with utf-8 'encoding'
|
||||
set encoding=utf-8 fencs=utf-8,cp1251
|
||||
e Xutf8
|
||||
.w! ++enc=utf-8 Xtest
|
||||
.w! ++enc=utf-8 Xwfetest
|
||||
e Xcp1251
|
||||
.w ++enc=utf-8 >> Xtest
|
||||
.w ++enc=utf-8 >> Xwfetest
|
||||
set fencs=utf-8,cp866
|
||||
e Xcp866
|
||||
.w ++enc=utf-8 >> Xtest
|
||||
.w ++enc=utf-8 >> Xwfetest
|
||||
let expected =<< trim END
|
||||
1 utf-8 text: Для Vim version 6.2. Последнее изменение: 1970 Jan 01
|
||||
2 cp1251 text: Для Vim version 6.2. Последнее изменение: 1970 Jan 01
|
||||
3 cp866 text: Для Vim version 6.2. Последнее изменение: 1970 Jan 01
|
||||
END
|
||||
call assert_equal(expected, readfile('Xtest'))
|
||||
call assert_equal(expected, readfile('Xwfetest'))
|
||||
|
||||
" read three 'fileencoding's with cp1251 'encoding'
|
||||
set encoding=utf-8 fencs=utf-8,cp1251
|
||||
e Xutf8
|
||||
.w! ++enc=cp1251 Xtest
|
||||
.w! ++enc=cp1251 Xwfetest
|
||||
e Xcp1251
|
||||
.w ++enc=cp1251 >> Xtest
|
||||
.w ++enc=cp1251 >> Xwfetest
|
||||
set fencs=utf-8,cp866
|
||||
e Xcp866
|
||||
.w ++enc=cp1251 >> Xtest
|
||||
.w ++enc=cp1251 >> Xwfetest
|
||||
let expected =<< trim END
|
||||
1 utf-8 text: <20><><EFBFBD> Vim version 6.2. <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: 1970 Jan 01
|
||||
2 cp1251 text: <20><><EFBFBD> Vim version 6.2. <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: 1970 Jan 01
|
||||
3 cp866 text: <20><><EFBFBD> Vim version 6.2. <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: 1970 Jan 01
|
||||
END
|
||||
call assert_equal(expected, readfile('Xtest'))
|
||||
call assert_equal(expected, readfile('Xwfetest'))
|
||||
|
||||
" read three 'fileencoding's with cp866 'encoding'
|
||||
set encoding=cp866 fencs=utf-8,cp1251
|
||||
e Xutf8
|
||||
.w! ++enc=cp866 Xtest
|
||||
.w! ++enc=cp866 Xwfetest
|
||||
e Xcp1251
|
||||
.w ++enc=cp866 >> Xtest
|
||||
.w ++enc=cp866 >> Xwfetest
|
||||
set fencs=utf-8,cp866
|
||||
e Xcp866
|
||||
.w ++enc=cp866 >> Xtest
|
||||
.w ++enc=cp866 >> Xwfetest
|
||||
let expected =<< trim END
|
||||
1 utf-8 text: <20><><EFBFBD> Vim version 6.2. <20><><EFBFBD><E1ABA5><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: 1970 Jan 01
|
||||
2 cp1251 text: <20><><EFBFBD> Vim version 6.2. <20><><EFBFBD><E1ABA5><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: 1970 Jan 01
|
||||
3 cp866 text: <20><><EFBFBD> Vim version 6.2. <20><><EFBFBD><E1ABA5><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: 1970 Jan 01
|
||||
END
|
||||
call assert_equal(expected, readfile('Xtest'))
|
||||
call assert_equal(expected, readfile('Xwfetest'))
|
||||
|
||||
call delete('Xfile')
|
||||
call delete('Xtest')
|
||||
call delete('Xwfefile')
|
||||
call delete('Xwfetest')
|
||||
call delete('Xutf8')
|
||||
call delete('Xcp1251')
|
||||
call delete('Xcp866')
|
||||
@@ -635,114 +635,114 @@ func Test_readwrite_file_with_bom()
|
||||
set cpoptions+=S
|
||||
|
||||
" Check that editing a latin1 file doesn't see a BOM
|
||||
call writefile(["\xFE\xFElatin-1"], 'Xtest1')
|
||||
edit Xtest1
|
||||
call writefile(["\xFE\xFElatin-1"], 'Xrwtest1')
|
||||
edit Xrwtest1
|
||||
call assert_equal('latin1', &fileencoding)
|
||||
call assert_equal(0, &bomb)
|
||||
set fenc=latin1
|
||||
write Xfile2
|
||||
call assert_equal(["\xFE\xFElatin-1", ''], readfile('Xfile2', 'b'))
|
||||
write Xrwfile2
|
||||
call assert_equal(["\xFE\xFElatin-1", ''], readfile('Xrwfile2', 'b'))
|
||||
set bomb fenc=latin1
|
||||
write Xtest3
|
||||
call assert_equal(["\xFE\xFElatin-1", ''], readfile('Xtest3', 'b'))
|
||||
write Xrwtest3
|
||||
call assert_equal(["\xFE\xFElatin-1", ''], readfile('Xrwtest3', 'b'))
|
||||
set bomb&
|
||||
|
||||
" Check utf-8 BOM
|
||||
%bw!
|
||||
call writefile([utf8_bom .. "utf-8"], 'Xtest1')
|
||||
edit! Xtest1
|
||||
call writefile([utf8_bom .. "utf-8"], 'Xrwtest1')
|
||||
edit! Xrwtest1
|
||||
call assert_equal('utf-8', &fileencoding)
|
||||
call assert_equal(1, &bomb)
|
||||
call assert_equal('utf-8', getline(1))
|
||||
set fenc=latin1
|
||||
write! Xfile2
|
||||
call assert_equal(['utf-8', ''], readfile('Xfile2', 'b'))
|
||||
write! Xrwfile2
|
||||
call assert_equal(['utf-8', ''], readfile('Xrwfile2', 'b'))
|
||||
set fenc=utf-8
|
||||
w! Xtest3
|
||||
call assert_equal([utf8_bom .. "utf-8", ''], readfile('Xtest3', 'b'))
|
||||
w! Xrwtest3
|
||||
call assert_equal([utf8_bom .. "utf-8", ''], readfile('Xrwtest3', 'b'))
|
||||
|
||||
" Check utf-8 with an error (will fall back to latin-1)
|
||||
%bw!
|
||||
call writefile([utf8_bom .. "utf-8\x80err"], 'Xtest1')
|
||||
edit! Xtest1
|
||||
call writefile([utf8_bom .. "utf-8\x80err"], 'Xrwtest1')
|
||||
edit! Xrwtest1
|
||||
call assert_equal('latin1', &fileencoding)
|
||||
call assert_equal(0, &bomb)
|
||||
call assert_equal("\xC3\xAF\xC2\xBB\xC2\xBFutf-8\xC2\x80err", getline(1))
|
||||
set fenc=latin1
|
||||
write! Xfile2
|
||||
call assert_equal([utf8_bom .. "utf-8\x80err", ''], readfile('Xfile2', 'b'))
|
||||
write! Xrwfile2
|
||||
call assert_equal([utf8_bom .. "utf-8\x80err", ''], readfile('Xrwfile2', 'b'))
|
||||
set fenc=utf-8
|
||||
w! Xtest3
|
||||
w! Xrwtest3
|
||||
call assert_equal(["\xC3\xAF\xC2\xBB\xC2\xBFutf-8\xC2\x80err", ''],
|
||||
\ readfile('Xtest3', 'b'))
|
||||
\ readfile('Xrwtest3', 'b'))
|
||||
|
||||
" Check ucs-2 BOM
|
||||
%bw!
|
||||
call writefile([utf16be_bom .. "\nu\nc\ns\n-\n2\n"], 'Xtest1')
|
||||
edit! Xtest1
|
||||
call writefile([utf16be_bom .. "\nu\nc\ns\n-\n2\n"], 'Xrwtest1')
|
||||
edit! Xrwtest1
|
||||
call assert_equal('utf-16', &fileencoding)
|
||||
call assert_equal(1, &bomb)
|
||||
call assert_equal('ucs-2', getline(1))
|
||||
set fenc=latin1
|
||||
write! Xfile2
|
||||
call assert_equal(["ucs-2", ''], readfile('Xfile2', 'b'))
|
||||
write! Xrwfile2
|
||||
call assert_equal(["ucs-2", ''], readfile('Xrwfile2', 'b'))
|
||||
set fenc=ucs-2
|
||||
w! Xtest3
|
||||
w! Xrwtest3
|
||||
call assert_equal([utf16be_bom .. "\nu\nc\ns\n-\n2\n", ''],
|
||||
\ readfile('Xtest3', 'b'))
|
||||
\ readfile('Xrwtest3', 'b'))
|
||||
|
||||
" Check ucs-2le BOM
|
||||
%bw!
|
||||
call writefile([utf16le_bom .. "u\nc\ns\n-\n2\nl\ne\n"], 'Xtest1')
|
||||
call writefile([utf16le_bom .. "u\nc\ns\n-\n2\nl\ne\n"], 'Xrwtest1')
|
||||
" Need to add a NUL byte after the NL byte
|
||||
call writefile(0z00, 'Xtest1', 'a')
|
||||
edit! Xtest1
|
||||
call writefile(0z00, 'Xrwtest1', 'a')
|
||||
edit! Xrwtest1
|
||||
call assert_equal('utf-16le', &fileencoding)
|
||||
call assert_equal(1, &bomb)
|
||||
call assert_equal('ucs-2le', getline(1))
|
||||
set fenc=latin1
|
||||
write! Xfile2
|
||||
call assert_equal(["ucs-2le", ''], readfile('Xfile2', 'b'))
|
||||
write! Xrwfile2
|
||||
call assert_equal(["ucs-2le", ''], readfile('Xrwfile2', 'b'))
|
||||
set fenc=ucs-2le
|
||||
w! Xtest3
|
||||
w! Xrwtest3
|
||||
call assert_equal([utf16le_bom .. "u\nc\ns\n-\n2\nl\ne\n", "\n"],
|
||||
\ readfile('Xtest3', 'b'))
|
||||
\ readfile('Xrwtest3', 'b'))
|
||||
|
||||
" Check ucs-4 BOM
|
||||
%bw!
|
||||
call writefile([utf32be_bom .. "\n\n\nu\n\n\nc\n\n\ns\n\n\n-\n\n\n4\n\n\n"], 'Xtest1')
|
||||
edit! Xtest1
|
||||
call writefile([utf32be_bom .. "\n\n\nu\n\n\nc\n\n\ns\n\n\n-\n\n\n4\n\n\n"], 'Xrwtest1')
|
||||
edit! Xrwtest1
|
||||
call assert_equal('ucs-4', &fileencoding)
|
||||
call assert_equal(1, &bomb)
|
||||
call assert_equal('ucs-4', getline(1))
|
||||
set fenc=latin1
|
||||
write! Xfile2
|
||||
call assert_equal(["ucs-4", ''], readfile('Xfile2', 'b'))
|
||||
write! Xrwfile2
|
||||
call assert_equal(["ucs-4", ''], readfile('Xrwfile2', 'b'))
|
||||
set fenc=ucs-4
|
||||
w! Xtest3
|
||||
call assert_equal([utf32be_bom .. "\n\n\nu\n\n\nc\n\n\ns\n\n\n-\n\n\n4\n\n\n", ''], readfile('Xtest3', 'b'))
|
||||
w! Xrwtest3
|
||||
call assert_equal([utf32be_bom .. "\n\n\nu\n\n\nc\n\n\ns\n\n\n-\n\n\n4\n\n\n", ''], readfile('Xrwtest3', 'b'))
|
||||
|
||||
" Check ucs-4le BOM
|
||||
%bw!
|
||||
call writefile([utf32le_bom .. "u\n\n\nc\n\n\ns\n\n\n-\n\n\n4\n\n\nl\n\n\ne\n\n\n"], 'Xtest1')
|
||||
call writefile([utf32le_bom .. "u\n\n\nc\n\n\ns\n\n\n-\n\n\n4\n\n\nl\n\n\ne\n\n\n"], 'Xrwtest1')
|
||||
" Need to add three NUL bytes after the NL byte
|
||||
call writefile(0z000000, 'Xtest1', 'a')
|
||||
edit! Xtest1
|
||||
call writefile(0z000000, 'Xrwtest1', 'a')
|
||||
edit! Xrwtest1
|
||||
call assert_equal('ucs-4le', &fileencoding)
|
||||
call assert_equal(1, &bomb)
|
||||
call assert_equal('ucs-4le', getline(1))
|
||||
set fenc=latin1
|
||||
write! Xfile2
|
||||
call assert_equal(["ucs-4le", ''], readfile('Xfile2', 'b'))
|
||||
write! Xrwfile2
|
||||
call assert_equal(["ucs-4le", ''], readfile('Xrwfile2', 'b'))
|
||||
set fenc=ucs-4le
|
||||
w! Xtest3
|
||||
call assert_equal([utf32le_bom .. "u\n\n\nc\n\n\ns\n\n\n-\n\n\n4\n\n\nl\n\n\ne\n\n\n", "\n\n\n"], readfile('Xtest3', 'b'))
|
||||
w! Xrwtest3
|
||||
call assert_equal([utf32le_bom .. "u\n\n\nc\n\n\ns\n\n\n-\n\n\n4\n\n\nl\n\n\ne\n\n\n", "\n\n\n"], readfile('Xrwtest3', 'b'))
|
||||
|
||||
set cpoptions-=S
|
||||
let &fileencoding = save_fileencoding
|
||||
call delete('Xtest1')
|
||||
call delete('Xfile2')
|
||||
call delete('Xtest3')
|
||||
call delete('Xrwtest1')
|
||||
call delete('Xrwfile2')
|
||||
call delete('Xrwtest3')
|
||||
%bw!
|
||||
endfunc
|
||||
|
||||
@@ -773,83 +773,83 @@ func Test_backupcopy()
|
||||
" With the default 'backupcopy' setting, saving a symbolic link file
|
||||
" should not break the link.
|
||||
set backupcopy&
|
||||
call writefile(['1111'], 'Xfile1')
|
||||
silent !ln -s Xfile1 Xfile2
|
||||
new Xfile2
|
||||
call writefile(['1111'], 'Xbcfile1')
|
||||
silent !ln -s Xbcfile1 Xbcfile2
|
||||
new Xbcfile2
|
||||
call setline(1, ['2222'])
|
||||
write
|
||||
close
|
||||
call assert_equal(['2222'], readfile('Xfile1'))
|
||||
call assert_equal('Xfile1', resolve('Xfile2'))
|
||||
call assert_equal('link', getftype('Xfile2'))
|
||||
call delete('Xfile1')
|
||||
call delete('Xfile2')
|
||||
call assert_equal(['2222'], readfile('Xbcfile1'))
|
||||
call assert_equal('Xbcfile1', resolve('Xbcfile2'))
|
||||
call assert_equal('link', getftype('Xbcfile2'))
|
||||
call delete('Xbcfile1')
|
||||
call delete('Xbcfile2')
|
||||
|
||||
" With the 'backupcopy' set to 'breaksymlink', saving a symbolic link file
|
||||
" should break the link.
|
||||
set backupcopy=yes,breaksymlink
|
||||
call writefile(['1111'], 'Xfile1')
|
||||
silent !ln -s Xfile1 Xfile2
|
||||
new Xfile2
|
||||
call writefile(['1111'], 'Xbcfile1')
|
||||
silent !ln -s Xbcfile1 Xbcfile2
|
||||
new Xbcfile2
|
||||
call setline(1, ['2222'])
|
||||
write
|
||||
close
|
||||
call assert_equal(['1111'], readfile('Xfile1'))
|
||||
call assert_equal(['2222'], readfile('Xfile2'))
|
||||
call assert_equal('Xfile2', resolve('Xfile2'))
|
||||
call assert_equal('file', getftype('Xfile2'))
|
||||
call delete('Xfile1')
|
||||
call delete('Xfile2')
|
||||
call assert_equal(['1111'], readfile('Xbcfile1'))
|
||||
call assert_equal(['2222'], readfile('Xbcfile2'))
|
||||
call assert_equal('Xbcfile2', resolve('Xbcfile2'))
|
||||
call assert_equal('file', getftype('Xbcfile2'))
|
||||
call delete('Xbcfile1')
|
||||
call delete('Xbcfile2')
|
||||
set backupcopy&
|
||||
|
||||
" With the default 'backupcopy' setting, saving a hard link file
|
||||
" should not break the link.
|
||||
set backupcopy&
|
||||
call writefile(['1111'], 'Xfile1')
|
||||
silent !ln Xfile1 Xfile2
|
||||
new Xfile2
|
||||
call writefile(['1111'], 'Xbcfile1')
|
||||
silent !ln Xbcfile1 Xbcfile2
|
||||
new Xbcfile2
|
||||
call setline(1, ['2222'])
|
||||
write
|
||||
close
|
||||
call assert_equal(['2222'], readfile('Xfile1'))
|
||||
call delete('Xfile1')
|
||||
call delete('Xfile2')
|
||||
call assert_equal(['2222'], readfile('Xbcfile1'))
|
||||
call delete('Xbcfile1')
|
||||
call delete('Xbcfile2')
|
||||
|
||||
" With the 'backupcopy' set to 'breaksymlink', saving a hard link file
|
||||
" should break the link.
|
||||
set backupcopy=yes,breakhardlink
|
||||
call writefile(['1111'], 'Xfile1')
|
||||
silent !ln Xfile1 Xfile2
|
||||
new Xfile2
|
||||
call writefile(['1111'], 'Xbcfile1')
|
||||
silent !ln Xbcfile1 Xbcfile2
|
||||
new Xbcfile2
|
||||
call setline(1, ['2222'])
|
||||
write
|
||||
call assert_equal(['1111'], readfile('Xfile1'))
|
||||
call assert_equal(['2222'], readfile('Xfile2'))
|
||||
call delete('Xfile1')
|
||||
call delete('Xfile2')
|
||||
call assert_equal(['1111'], readfile('Xbcfile1'))
|
||||
call assert_equal(['2222'], readfile('Xbcfile2'))
|
||||
call delete('Xbcfile1')
|
||||
call delete('Xbcfile2')
|
||||
|
||||
" If a backup file is already present, then a slightly modified filename
|
||||
" should be used as the backup file. Try with 'backupcopy' set to 'yes' and
|
||||
" 'no'.
|
||||
%bw
|
||||
call writefile(['aaaa'], 'Xfile')
|
||||
call writefile(['bbbb'], 'Xfile.bak')
|
||||
call writefile(['aaaa'], 'Xbcfile')
|
||||
call writefile(['bbbb'], 'Xbcfile.bak')
|
||||
set backupcopy=yes backupext=.bak
|
||||
new Xfile
|
||||
new Xbcfile
|
||||
call setline(1, ['cccc'])
|
||||
write
|
||||
close
|
||||
call assert_equal(['cccc'], readfile('Xfile'))
|
||||
call assert_equal(['bbbb'], readfile('Xfile.bak'))
|
||||
call assert_equal(['cccc'], readfile('Xbcfile'))
|
||||
call assert_equal(['bbbb'], readfile('Xbcfile.bak'))
|
||||
set backupcopy=no backupext=.bak
|
||||
new Xfile
|
||||
new Xbcfile
|
||||
call setline(1, ['dddd'])
|
||||
write
|
||||
close
|
||||
call assert_equal(['dddd'], readfile('Xfile'))
|
||||
call assert_equal(['bbbb'], readfile('Xfile.bak'))
|
||||
call delete('Xfile')
|
||||
call delete('Xfile.bak')
|
||||
call assert_equal(['dddd'], readfile('Xbcfile'))
|
||||
call assert_equal(['bbbb'], readfile('Xbcfile.bak'))
|
||||
call delete('Xbcfile')
|
||||
call delete('Xbcfile.bak')
|
||||
|
||||
" Write to a device file (in Unix-like systems) which cannot be backed up.
|
||||
if has('unix')
|
||||
@@ -880,10 +880,10 @@ endfunc
|
||||
func Test_write_utf16()
|
||||
new
|
||||
call setline(1, ["\U00010001"])
|
||||
write ++enc=utf-16 Xfile
|
||||
write ++enc=utf-16 Xw16file
|
||||
bw!
|
||||
call assert_equal(0zD800DC01, readfile('Xfile', 'B')[0:3])
|
||||
call delete('Xfile')
|
||||
call assert_equal(0zD800DC01, readfile('Xw16file', 'B')[0:3])
|
||||
call delete('Xw16file')
|
||||
endfunc
|
||||
|
||||
" Test for trying to save a backup file when the backup file is a symbolic
|
||||
@@ -893,24 +893,24 @@ func Test_write_backup_symlink()
|
||||
call mkdir('Xbackup')
|
||||
let save_backupdir = &backupdir
|
||||
set backupdir=.,./Xbackup
|
||||
call writefile(['1111'], 'Xfile')
|
||||
silent !ln -s Xfile Xfile.bak
|
||||
call writefile(['1111'], 'Xwbsfile')
|
||||
silent !ln -s Xwbsfile Xwbsfile.bak
|
||||
|
||||
new Xfile
|
||||
new Xwbsfile
|
||||
set backup backupcopy=yes backupext=.bak
|
||||
write
|
||||
call assert_equal('link', getftype('Xfile.bak'))
|
||||
call assert_equal('Xfile', resolve('Xfile.bak'))
|
||||
call assert_equal('link', getftype('Xwbsfile.bak'))
|
||||
call assert_equal('Xwbsfile', resolve('Xwbsfile.bak'))
|
||||
" backup file should be created in the 'backup' directory
|
||||
if !has('bsd')
|
||||
" This check fails on FreeBSD
|
||||
call assert_true(filereadable('./Xbackup/Xfile.bak'))
|
||||
call assert_true(filereadable('./Xbackup/Xwbsfile.bak'))
|
||||
endif
|
||||
set backup& backupcopy& backupext&
|
||||
%bw
|
||||
|
||||
call delete('Xfile')
|
||||
call delete('Xfile.bak')
|
||||
call delete('Xwbsfile')
|
||||
call delete('Xwbsfile.bak')
|
||||
call delete('Xbackup', 'rf')
|
||||
let &backupdir = save_backupdir
|
||||
endfunc
|
||||
@@ -918,19 +918,19 @@ endfunc
|
||||
" Test for ':write ++bin' and ':write ++nobin'
|
||||
func Test_write_binary_file()
|
||||
" create a file without an eol/eof character
|
||||
call writefile(0z616161, 'Xfile1', 'b')
|
||||
new Xfile1
|
||||
write ++bin Xfile2
|
||||
write ++nobin Xfile3
|
||||
call assert_equal(0z616161, readblob('Xfile2'))
|
||||
call writefile(0z616161, 'Xwbfile1', 'b')
|
||||
new Xwbfile1
|
||||
write ++bin Xwbfile2
|
||||
write ++nobin Xwbfile3
|
||||
call assert_equal(0z616161, readblob('Xwbfile2'))
|
||||
if has('win32')
|
||||
call assert_equal(0z6161610D.0A, readblob('Xfile3'))
|
||||
call assert_equal(0z6161610D.0A, readblob('Xwbfile3'))
|
||||
else
|
||||
call assert_equal(0z6161610A, readblob('Xfile3'))
|
||||
call assert_equal(0z6161610A, readblob('Xwbfile3'))
|
||||
endif
|
||||
call delete('Xfile1')
|
||||
call delete('Xfile2')
|
||||
call delete('Xfile3')
|
||||
call delete('Xwbfile1')
|
||||
call delete('Xwbfile2')
|
||||
call delete('Xwbfile3')
|
||||
endfunc
|
||||
|
||||
" Check that buffer is written before triggering QuitPre
|
||||
|
@@ -707,6 +707,8 @@ static char *(features[]) =
|
||||
|
||||
static int included_patches[] =
|
||||
{ /* Add new patch number below this line */
|
||||
/**/
|
||||
363,
|
||||
/**/
|
||||
362,
|
||||
/**/
|
||||
|
Reference in New Issue
Block a user