0
0
mirror of https://github.com/vim/vim.git synced 2025-09-29 04:34:16 -04:00

patch 9.0.0323: using common name in tests leads to flaky tests

Problem:    Using common name in tests leads to flaky tests.
Solution:   Rename files and directories to be more specific.
This commit is contained in:
Bram Moolenaar
2022-08-29 22:31:20 +01:00
parent 4f1b083be4
commit 3b0d70f4ff
25 changed files with 531 additions and 530 deletions

View File

@@ -717,14 +717,14 @@ func Test_BufEnter()
call assert_equal('++', g:val) call assert_equal('++', g:val)
" Also get BufEnter when editing a directory " Also get BufEnter when editing a directory
call mkdir('Xdir') call mkdir('Xbufenterdir')
split Xdir split Xbufenterdir
call assert_equal('+++', g:val) call assert_equal('+++', g:val)
" On MS-Windows we can't edit the directory, make sure we wipe the right " On MS-Windows we can't edit the directory, make sure we wipe the right
" buffer. " buffer.
bwipe! Xdir bwipe! Xbufenterdir
call delete('Xdir', 'd') call delete('Xbufenterdir', 'd')
au! BufEnter au! BufEnter
" Editing a "nofile" buffer doesn't read the file but does trigger BufEnter " Editing a "nofile" buffer doesn't read the file but does trigger BufEnter
@@ -2723,16 +2723,16 @@ func Test_throw_in_BufWritePre()
endfunc endfunc
func Test_autocmd_in_try_block() func Test_autocmd_in_try_block()
call mkdir('Xdir') call mkdir('Xintrydir')
au BufEnter * let g:fname = expand('%') au BufEnter * let g:fname = expand('%')
try try
edit Xdir/ edit Xintrydir/
endtry endtry
call assert_match('Xdir', g:fname) call assert_match('Xintrydir', g:fname)
unlet g:fname unlet g:fname
au! BufEnter au! BufEnter
call delete('Xdir', 'rf') call delete('Xintrydir', 'rf')
endfunc endfunc
func Test_autocmd_SafeState() func Test_autocmd_SafeState()

View File

@@ -69,11 +69,11 @@ endfunc
" Test for chdir() " Test for chdir()
func Test_chdir_func() func Test_chdir_func()
let topdir = getcwd() let topdir = getcwd()
call mkdir('Xdir/y/z', 'p') call mkdir('Xchdir/y/z', 'p')
" Create a few tabpages and windows with different directories " Create a few tabpages and windows with different directories
new new
cd Xdir cd Xchdir
tabnew tabnew
tcd y tcd y
below new below new
@@ -81,22 +81,22 @@ func Test_chdir_func()
lcd z lcd z
tabfirst tabfirst
call assert_match('^\[global\] .*/Xdir$', trim(execute('verbose pwd'))) call assert_match('^\[global\] .*/Xchdir$', trim(execute('verbose pwd')))
call chdir('..') call chdir('..')
call assert_equal('y', fnamemodify(getcwd(1, 2), ':t')) call assert_equal('y', fnamemodify(getcwd(1, 2), ':t'))
call assert_equal('z', fnamemodify(3->getcwd(2), ':t')) call assert_equal('z', fnamemodify(3->getcwd(2), ':t'))
tabnext | wincmd t tabnext | wincmd t
call assert_match('^\[tabpage\] .*/y$', trim(execute('verbose pwd'))) call assert_match('^\[tabpage\] .*/y$', trim(execute('verbose pwd')))
eval '..'->chdir() eval '..'->chdir()
call assert_equal('Xdir', fnamemodify(getcwd(1, 2), ':t')) call assert_equal('Xchdir', fnamemodify(getcwd(1, 2), ':t'))
call assert_equal('Xdir', fnamemodify(getcwd(2, 2), ':t')) call assert_equal('Xchdir', fnamemodify(getcwd(2, 2), ':t'))
call assert_equal('z', fnamemodify(getcwd(3, 2), ':t')) call assert_equal('z', fnamemodify(getcwd(3, 2), ':t'))
call assert_equal('testdir', fnamemodify(getcwd(1, 1), ':t')) call assert_equal('testdir', fnamemodify(getcwd(1, 1), ':t'))
3wincmd w 3wincmd w
call assert_match('^\[window\] .*/z$', trim(execute('verbose pwd'))) call assert_match('^\[window\] .*/z$', trim(execute('verbose pwd')))
call chdir('..') call chdir('..')
call assert_equal('Xdir', fnamemodify(getcwd(1, 2), ':t')) call assert_equal('Xchdir', fnamemodify(getcwd(1, 2), ':t'))
call assert_equal('Xdir', fnamemodify(getcwd(2, 2), ':t')) call assert_equal('Xchdir', fnamemodify(getcwd(2, 2), ':t'))
call assert_equal('y', fnamemodify(getcwd(3, 2), ':t')) call assert_equal('y', fnamemodify(getcwd(3, 2), ':t'))
call assert_equal('testdir', fnamemodify(getcwd(1, 1), ':t')) call assert_equal('testdir', fnamemodify(getcwd(1, 1), ':t'))
@@ -110,20 +110,20 @@ func Test_chdir_func()
only | tabonly only | tabonly
call chdir(topdir) call chdir(topdir)
call delete('Xdir', 'rf') call delete('Xchdir', 'rf')
endfunc endfunc
" Test for changing to the previous directory '-' " Test for changing to the previous directory '-'
func Test_prev_dir() func Test_prev_dir()
let topdir = getcwd() let topdir = getcwd()
call mkdir('Xdir/a/b/c', 'p') call mkdir('Xprevdir/a/b/c', 'p')
" Create a few tabpages and windows with different directories " Create a few tabpages and windows with different directories
new | only new | only
tabnew | new tabnew | new
tabnew tabnew
tabfirst tabfirst
cd Xdir cd Xprevdir
tabnext | wincmd t tabnext | wincmd t
tcd a tcd a
wincmd w wincmd w
@@ -143,7 +143,7 @@ func Test_prev_dir()
" Check the directory of all the windows " Check the directory of all the windows
tabfirst tabfirst
call assert_equal('Xdir', fnamemodify(getcwd(), ':t')) call assert_equal('Xprevdir', fnamemodify(getcwd(), ':t'))
tabnext | wincmd t tabnext | wincmd t
call assert_equal('a', fnamemodify(getcwd(), ':t')) call assert_equal('a', fnamemodify(getcwd(), ':t'))
wincmd w wincmd w
@@ -163,7 +163,7 @@ func Test_prev_dir()
" Check the directory of all the windows " Check the directory of all the windows
tabfirst tabfirst
call assert_equal('Xdir', fnamemodify(getcwd(), ':t')) call assert_equal('Xprevdir', fnamemodify(getcwd(), ':t'))
tabnext | wincmd t tabnext | wincmd t
call assert_equal('a', fnamemodify(getcwd(), ':t')) call assert_equal('a', fnamemodify(getcwd(), ':t'))
wincmd w wincmd w
@@ -173,7 +173,7 @@ func Test_prev_dir()
only | tabonly only | tabonly
call chdir(topdir) call chdir(topdir)
call delete('Xdir', 'rf') call delete('Xprevdir', 'rf')
endfunc endfunc
func Test_lcd_split() func Test_lcd_split()

View File

@@ -2281,9 +2281,9 @@ func Test_zz_ch_log()
let text = readfile('Xlog') let text = readfile('Xlog')
call assert_match("hello there", text[1]) call assert_match("hello there", text[1])
call assert_match("%s%s", text[2]) call assert_match("%s%s", text[2])
call mkdir("Xdir1") call mkdir("Xchlogdir1")
call assert_fails("call ch_logfile('Xdir1')", 'E484:') call assert_fails("call ch_logfile('Xchlogdir1')", 'E484:')
cal delete("Xdir1", 'd') cal delete("Xchlogdir1", 'd')
call delete('Xlog') call delete('Xlog')
endfunc endfunc

View File

@@ -2,28 +2,28 @@
" Test for 'include' without \zs or \ze " Test for 'include' without \zs or \ze
func Test_checkpath1() func Test_checkpath1()
call mkdir("Xdir1/dir2", "p") call mkdir("Xcheckdir1/dir2", "p")
call writefile(['#include "bar.a"'], 'Xdir1/dir2/foo.a') call writefile(['#include "bar.a"'], 'Xcheckdir1/dir2/foo.a')
call writefile(['#include "baz.a"'], 'Xdir1/dir2/bar.a') call writefile(['#include "baz.a"'], 'Xcheckdir1/dir2/bar.a')
call writefile(['#include "foo.a"'], 'Xdir1/dir2/baz.a') call writefile(['#include "foo.a"'], 'Xcheckdir1/dir2/baz.a')
call writefile(['#include <foo.a>'], 'Xbase.a') call writefile(['#include <foo.a>'], 'Xbase.a')
edit Xbase.a edit Xbase.a
set path=Xdir1/dir2 set path=Xcheckdir1/dir2
let res = split(execute("checkpath!"), "\n") let res = split(execute("checkpath!"), "\n")
call assert_equal([ call assert_equal([
\ '--- Included files in path ---', \ '--- Included files in path ---',
\ 'Xdir1/dir2/foo.a', \ 'Xcheckdir1/dir2/foo.a',
\ 'Xdir1/dir2/foo.a -->', \ 'Xcheckdir1/dir2/foo.a -->',
\ ' Xdir1/dir2/bar.a', \ ' Xcheckdir1/dir2/bar.a',
\ ' Xdir1/dir2/bar.a -->', \ ' Xcheckdir1/dir2/bar.a -->',
\ ' Xdir1/dir2/baz.a', \ ' Xcheckdir1/dir2/baz.a',
\ ' Xdir1/dir2/baz.a -->', \ ' Xcheckdir1/dir2/baz.a -->',
\ ' "foo.a" (Already listed)'], res) \ ' "foo.a" (Already listed)'], res)
enew enew
call delete("./Xbase.a") call delete("./Xbase.a")
call delete("Xdir1", "rf") call delete("Xcheckdir1", "rf")
set path& set path&
endfunc endfunc
@@ -33,31 +33,31 @@ endfunc
" Test for 'include' with \zs and \ze " Test for 'include' with \zs and \ze
func Test_checkpath2() func Test_checkpath2()
call mkdir("Xdir1/dir2", "p") call mkdir("Xcheckdir2/dir2", "p")
call writefile(['%inc /bar/'], 'Xdir1/dir2/foo.b') call writefile(['%inc /bar/'], 'Xcheckdir2/dir2/foo.b')
call writefile(['%inc /baz/'], 'Xdir1/dir2/bar.b') call writefile(['%inc /baz/'], 'Xcheckdir2/dir2/bar.b')
call writefile(['%inc /foo/'], 'Xdir1/dir2/baz.b') call writefile(['%inc /foo/'], 'Xcheckdir2/dir2/baz.b')
call writefile(['%inc /foo/'], 'Xbase.b') call writefile(['%inc /foo/'], 'Xbase.b')
let &include='^\s*%inc\s*/\zs[^/]\+\ze' let &include='^\s*%inc\s*/\zs[^/]\+\ze'
let &includeexpr='DotsToSlashes()' let &includeexpr='DotsToSlashes()'
edit Xbase.b edit Xbase.b
set path=Xdir1/dir2 set path=Xcheckdir2/dir2
let res = split(execute("checkpath!"), "\n") let res = split(execute("checkpath!"), "\n")
call assert_equal([ call assert_equal([
\ '--- Included files in path ---', \ '--- Included files in path ---',
\ 'Xdir1/dir2/foo.b', \ 'Xcheckdir2/dir2/foo.b',
\ 'Xdir1/dir2/foo.b -->', \ 'Xcheckdir2/dir2/foo.b -->',
\ ' Xdir1/dir2/bar.b', \ ' Xcheckdir2/dir2/bar.b',
\ ' Xdir1/dir2/bar.b -->', \ ' Xcheckdir2/dir2/bar.b -->',
\ ' Xdir1/dir2/baz.b', \ ' Xcheckdir2/dir2/baz.b',
\ ' Xdir1/dir2/baz.b -->', \ ' Xcheckdir2/dir2/baz.b -->',
\ ' foo (Already listed)'], res) \ ' foo (Already listed)'], res)
enew enew
call delete("./Xbase.b") call delete("./Xbase.b")
call delete("Xdir1", "rf") call delete("Xcheckdir2", "rf")
set path& set path&
set include& set include&
set includeexpr& set includeexpr&
@@ -72,32 +72,32 @@ endfunc
" Test for 'include' with \zs and no \ze " Test for 'include' with \zs and no \ze
func Test_checkpath3() func Test_checkpath3()
call mkdir("Xdir1/dir2", "p") call mkdir("Xcheckdir3/dir2", "p")
call writefile(['%inc bar.c'], 'Xdir1/dir2/foo.c') call writefile(['%inc bar.c'], 'Xcheckdir3/dir2/foo.c')
call writefile(['%inc baz.c'], 'Xdir1/dir2/bar.c') call writefile(['%inc baz.c'], 'Xcheckdir3/dir2/bar.c')
call writefile(['%inc foo.c'], 'Xdir1/dir2/baz.c') call writefile(['%inc foo.c'], 'Xcheckdir3/dir2/baz.c')
call writefile(['%inc foo.c'], 'Xdir1/dir2/FALSE.c') call writefile(['%inc foo.c'], 'Xcheckdir3/dir2/FALSE.c')
call writefile(['%inc FALSE.c foo.c'], 'Xbase.c') call writefile(['%inc FALSE.c foo.c'], 'Xbase.c')
let &include='^\s*%inc\s*\%([[:upper:]][^[:space:]]*\s\+\)\?\zs\S\+\ze' let &include='^\s*%inc\s*\%([[:upper:]][^[:space:]]*\s\+\)\?\zs\S\+\ze'
let &includeexpr='StripNewlineChar()' let &includeexpr='StripNewlineChar()'
edit Xbase.c edit Xbase.c
set path=Xdir1/dir2 set path=Xcheckdir3/dir2
let res = split(execute("checkpath!"), "\n") let res = split(execute("checkpath!"), "\n")
call assert_equal([ call assert_equal([
\ '--- Included files in path ---', \ '--- Included files in path ---',
\ 'Xdir1/dir2/foo.c', \ 'Xcheckdir3/dir2/foo.c',
\ 'Xdir1/dir2/foo.c -->', \ 'Xcheckdir3/dir2/foo.c -->',
\ ' Xdir1/dir2/bar.c', \ ' Xcheckdir3/dir2/bar.c',
\ ' Xdir1/dir2/bar.c -->', \ ' Xcheckdir3/dir2/bar.c -->',
\ ' Xdir1/dir2/baz.c', \ ' Xcheckdir3/dir2/baz.c',
\ ' Xdir1/dir2/baz.c -->', \ ' Xcheckdir3/dir2/baz.c -->',
\ ' foo.c (Already listed)'], res) \ ' foo.c (Already listed)'], res)
enew enew
call delete("./Xbase.c") call delete("./Xbase.c")
call delete("Xdir1", "rf") call delete("Xcheckdir3", "rf")
set path& set path&
set include& set include&
set includeexpr& set includeexpr&

View File

@@ -83,38 +83,38 @@ func Test_complete_list()
endfunc endfunc
func Test_complete_wildmenu() func Test_complete_wildmenu()
call mkdir('Xdir1/Xdir2', 'p') call mkdir('Xwilddir1/Xdir2', 'p')
call writefile(['testfile1'], 'Xdir1/Xtestfile1') call writefile(['testfile1'], 'Xwilddir1/Xtestfile1')
call writefile(['testfile2'], 'Xdir1/Xtestfile2') call writefile(['testfile2'], 'Xwilddir1/Xtestfile2')
call writefile(['testfile3'], 'Xdir1/Xdir2/Xtestfile3') call writefile(['testfile3'], 'Xwilddir1/Xdir2/Xtestfile3')
call writefile(['testfile3'], 'Xdir1/Xdir2/Xtestfile4') call writefile(['testfile3'], 'Xwilddir1/Xdir2/Xtestfile4')
set wildmenu set wildmenu
" Pressing <Tab> completes, and moves to next files when pressing again. " Pressing <Tab> completes, and moves to next files when pressing again.
call feedkeys(":e Xdir1/\<Tab>\<Tab>\<CR>", 'tx') call feedkeys(":e Xwilddir1/\<Tab>\<Tab>\<CR>", 'tx')
call assert_equal('testfile1', getline(1)) call assert_equal('testfile1', getline(1))
call feedkeys(":e Xdir1/\<Tab>\<Tab>\<Tab>\<CR>", 'tx') call feedkeys(":e Xwilddir1/\<Tab>\<Tab>\<Tab>\<CR>", 'tx')
call assert_equal('testfile2', getline(1)) call assert_equal('testfile2', getline(1))
" <S-Tab> is like <Tab> but begin with the last match and then go to " <S-Tab> is like <Tab> but begin with the last match and then go to
" previous. " previous.
call feedkeys(":e Xdir1/Xtest\<S-Tab>\<CR>", 'tx') call feedkeys(":e Xwilddir1/Xtest\<S-Tab>\<CR>", 'tx')
call assert_equal('testfile2', getline(1)) call assert_equal('testfile2', getline(1))
call feedkeys(":e Xdir1/Xtest\<S-Tab>\<S-Tab>\<CR>", 'tx') call feedkeys(":e Xwilddir1/Xtest\<S-Tab>\<S-Tab>\<CR>", 'tx')
call assert_equal('testfile1', getline(1)) call assert_equal('testfile1', getline(1))
" <Left>/<Right> to move to previous/next file. " <Left>/<Right> to move to previous/next file.
call feedkeys(":e Xdir1/\<Tab>\<Right>\<CR>", 'tx') call feedkeys(":e Xwilddir1/\<Tab>\<Right>\<CR>", 'tx')
call assert_equal('testfile1', getline(1)) call assert_equal('testfile1', getline(1))
call feedkeys(":e Xdir1/\<Tab>\<Right>\<Right>\<CR>", 'tx') call feedkeys(":e Xwilddir1/\<Tab>\<Right>\<Right>\<CR>", 'tx')
call assert_equal('testfile2', getline(1)) call assert_equal('testfile2', getline(1))
call feedkeys(":e Xdir1/\<Tab>\<Right>\<Right>\<Left>\<CR>", 'tx') call feedkeys(":e Xwilddir1/\<Tab>\<Right>\<Right>\<Left>\<CR>", 'tx')
call assert_equal('testfile1', getline(1)) call assert_equal('testfile1', getline(1))
" <Up>/<Down> to go up/down directories. " <Up>/<Down> to go up/down directories.
call feedkeys(":e Xdir1/\<Tab>\<Down>\<CR>", 'tx') call feedkeys(":e Xwilddir1/\<Tab>\<Down>\<CR>", 'tx')
call assert_equal('testfile3', getline(1)) call assert_equal('testfile3', getline(1))
call feedkeys(":e Xdir1/\<Tab>\<Down>\<Up>\<Right>\<CR>", 'tx') call feedkeys(":e Xwilddir1/\<Tab>\<Down>\<Up>\<Right>\<CR>", 'tx')
call assert_equal('testfile1', getline(1)) call assert_equal('testfile1', getline(1))
" this fails in some Unix GUIs, not sure why " this fails in some Unix GUIs, not sure why
@@ -124,9 +124,9 @@ func Test_complete_wildmenu()
set wildcharm=<C-Z> set wildcharm=<C-Z>
cnoremap <C-J> <Down><C-Z> cnoremap <C-J> <Down><C-Z>
cnoremap <C-K> <Up><C-Z> cnoremap <C-K> <Up><C-Z>
call feedkeys(":e Xdir1/\<Tab>\<C-J>\<CR>", 'tx') call feedkeys(":e Xwilddir1/\<Tab>\<C-J>\<CR>", 'tx')
call assert_equal('testfile3', getline(1)) call assert_equal('testfile3', getline(1))
call feedkeys(":e Xdir1/\<Tab>\<C-J>\<C-K>\<CR>", 'tx') call feedkeys(":e Xwilddir1/\<Tab>\<C-J>\<C-K>\<CR>", 'tx')
call assert_equal('testfile1', getline(1)) call assert_equal('testfile1', getline(1))
set wildcharm=0 set wildcharm=0
cunmap <C-J> cunmap <C-J>
@@ -135,21 +135,21 @@ func Test_complete_wildmenu()
" Test for canceling the wild menu by adding a character " Test for canceling the wild menu by adding a character
redrawstatus redrawstatus
call feedkeys(":e Xdir1/\<Tab>x\<C-B>\"\<CR>", 'xt') call feedkeys(":e Xwilddir1/\<Tab>x\<C-B>\"\<CR>", 'xt')
call assert_equal('"e Xdir1/Xdir2/x', @:) call assert_equal('"e Xwilddir1/Xdir2/x', @:)
" Completion using a relative path " Completion using a relative path
cd Xdir1/Xdir2 cd Xwilddir1/Xdir2
call feedkeys(":e ../\<Tab>\<Right>\<Down>\<C-A>\<C-B>\"\<CR>", 'tx') call feedkeys(":e ../\<Tab>\<Right>\<Down>\<C-A>\<C-B>\"\<CR>", 'tx')
call assert_equal('"e Xtestfile3 Xtestfile4', @:) call assert_equal('"e Xtestfile3 Xtestfile4', @:)
cd - cd -
" test for wildmenumode() " test for wildmenumode()
cnoremap <expr> <F2> wildmenumode() cnoremap <expr> <F2> wildmenumode()
call feedkeys(":cd Xdir\<Tab>\<F2>\<C-B>\"\<CR>", 'tx') call feedkeys(":cd Xwilddir\<Tab>\<F2>\<C-B>\"\<CR>", 'tx')
call assert_equal('"cd Xdir1/0', @:) call assert_equal('"cd Xwilddir1/0', @:)
call feedkeys(":e Xdir1/\<Tab>\<F2>\<C-B>\"\<CR>", 'tx') call feedkeys(":e Xwilddir1/\<Tab>\<F2>\<C-B>\"\<CR>", 'tx')
call assert_equal('"e Xdir1/Xdir2/1', @:) call assert_equal('"e Xwilddir1/Xdir2/1', @:)
cunmap <F2> cunmap <F2>
" Test for canceling the wild menu by pressing <PageDown> or <PageUp>. " Test for canceling the wild menu by pressing <PageDown> or <PageUp>.
@@ -162,7 +162,7 @@ func Test_complete_wildmenu()
" cleanup " cleanup
%bwipe %bwipe
call delete('Xdir1', 'rf') call delete('Xwilddir1', 'rf')
set nowildmenu set nowildmenu
endfunc endfunc
@@ -1930,18 +1930,18 @@ endfunc
func Test_wildmenu_dirstack() func Test_wildmenu_dirstack()
CheckUnix CheckUnix
%bw! %bw!
call mkdir('Xdir1/dir2/dir3/dir4', 'p') call mkdir('Xwildmenu/dir2/dir3/dir4', 'p')
call writefile([], 'Xdir1/file1_1.txt') call writefile([], 'Xwildmenu/file1_1.txt')
call writefile([], 'Xdir1/file1_2.txt') call writefile([], 'Xwildmenu/file1_2.txt')
call writefile([], 'Xdir1/dir2/file2_1.txt') call writefile([], 'Xwildmenu/dir2/file2_1.txt')
call writefile([], 'Xdir1/dir2/file2_2.txt') call writefile([], 'Xwildmenu/dir2/file2_2.txt')
call writefile([], 'Xdir1/dir2/dir3/file3_1.txt') call writefile([], 'Xwildmenu/dir2/dir3/file3_1.txt')
call writefile([], 'Xdir1/dir2/dir3/file3_2.txt') call writefile([], 'Xwildmenu/dir2/dir3/file3_2.txt')
call writefile([], 'Xdir1/dir2/dir3/dir4/file4_1.txt') call writefile([], 'Xwildmenu/dir2/dir3/dir4/file4_1.txt')
call writefile([], 'Xdir1/dir2/dir3/dir4/file4_2.txt') call writefile([], 'Xwildmenu/dir2/dir3/dir4/file4_2.txt')
set wildmenu set wildmenu
cd Xdir1/dir2/dir3/dir4 cd Xwildmenu/dir2/dir3/dir4
call feedkeys(":e \<Tab>\<C-B>\"\<CR>", 'xt') call feedkeys(":e \<Tab>\<C-B>\"\<CR>", 'xt')
call assert_equal('"e file4_1.txt', @:) call assert_equal('"e file4_1.txt', @:)
call feedkeys(":e \<Tab>\<Up>\<C-B>\"\<CR>", 'xt') call feedkeys(":e \<Tab>\<Up>\<C-B>\"\<CR>", 'xt')
@@ -1955,10 +1955,10 @@ func Test_wildmenu_dirstack()
call feedkeys(":e \<Tab>\<Up>\<Up>\<Down>\<Down>\<C-B>\"\<CR>", 'xt') call feedkeys(":e \<Tab>\<Up>\<Up>\<Down>\<Down>\<C-B>\"\<CR>", 'xt')
call assert_equal('"e ../../dir3/dir4/file4_1.txt', @:) call assert_equal('"e ../../dir3/dir4/file4_1.txt', @:)
cd - cd -
call feedkeys(":e Xdir1/\<Tab>\<Down>\<Down>\<Down>\<C-B>\"\<CR>", 'xt') call feedkeys(":e Xwildmenu/\<Tab>\<Down>\<Down>\<Down>\<C-B>\"\<CR>", 'xt')
call assert_equal('"e Xdir1/dir2/dir3/dir4/file4_1.txt', @:) call assert_equal('"e Xwildmenu/dir2/dir3/dir4/file4_1.txt', @:)
call delete('Xdir1', 'rf') call delete('Xwildmenu', 'rf')
set wildmenu& set wildmenu&
endfunc endfunc

View File

@@ -14,32 +14,32 @@ func Test_file_delete()
endfunc endfunc
func Test_dir_delete() func Test_dir_delete()
call mkdir('Xdir1') call mkdir('Xdirdel')
call assert_true(isdirectory('Xdir1')) call assert_true(isdirectory('Xdirdel'))
call assert_equal(0, delete('Xdir1', 'd')) call assert_equal(0, delete('Xdirdel', 'd'))
call assert_false(isdirectory('Xdir1')) call assert_false(isdirectory('Xdirdel'))
call assert_equal(-1, delete('Xdir1', 'd')) call assert_equal(-1, delete('Xdirdel', 'd'))
endfunc endfunc
func Test_recursive_delete() func Test_recursive_delete()
call mkdir('Xdir1') call mkdir('Xrecdel')
call mkdir('Xdir1/subdir') call mkdir('Xrecdel/subdir')
call mkdir('Xdir1/empty') call mkdir('Xrecdel/empty')
split Xdir1/Xfile split Xrecdel/Xfile
call setline(1, ['a', 'b']) call setline(1, ['a', 'b'])
w w
w Xdir1/subdir/Xfile w Xrecdel/subdir/Xfile
close close
call assert_true(isdirectory('Xdir1')) call assert_true(isdirectory('Xrecdel'))
call assert_equal(['a', 'b'], readfile('Xdir1/Xfile')) call assert_equal(['a', 'b'], readfile('Xrecdel/Xfile'))
call assert_true(isdirectory('Xdir1/subdir')) call assert_true(isdirectory('Xrecdel/subdir'))
call assert_equal(['a', 'b'], readfile('Xdir1/subdir/Xfile')) call assert_equal(['a', 'b'], readfile('Xrecdel/subdir/Xfile'))
call assert_true('Xdir1/empty'->isdirectory()) call assert_true('Xrecdel/empty'->isdirectory())
call assert_equal(0, delete('Xdir1', 'rf')) call assert_equal(0, delete('Xrecdel', 'rf'))
call assert_false(isdirectory('Xdir1')) call assert_false(isdirectory('Xrecdel'))
call assert_equal(-1, delete('Xdir1', 'd')) call assert_equal(-1, delete('Xrecdel', 'd'))
bwipe Xdir1/Xfile bwipe Xrecdel/Xfile
bwipe Xdir1/subdir/Xfile bwipe Xrecdel/subdir/Xfile
endfunc endfunc
func Test_symlink_delete() func Test_symlink_delete()
@@ -47,59 +47,59 @@ func Test_symlink_delete()
split Xfile split Xfile
call setline(1, ['a', 'b']) call setline(1, ['a', 'b'])
wq wq
silent !ln -s Xfile Xlink silent !ln -s Xfile Xdellink
" Delete the link, not the file " Delete the link, not the file
call assert_equal(0, delete('Xlink')) call assert_equal(0, delete('Xdellink'))
call assert_equal(-1, delete('Xlink')) call assert_equal(-1, delete('Xdellink'))
call assert_equal(0, delete('Xfile')) call assert_equal(0, delete('Xfile'))
bwipe Xfile bwipe Xfile
endfunc endfunc
func Test_symlink_dir_delete() func Test_symlink_dir_delete()
CheckUnix CheckUnix
call mkdir('Xdir1') call mkdir('Xsymdir')
silent !ln -s Xdir1 Xlink silent !ln -s Xsymdir Xdirlink
call assert_true(isdirectory('Xdir1')) call assert_true(isdirectory('Xsymdir'))
call assert_true(isdirectory('Xlink')) call assert_true(isdirectory('Xdirlink'))
" Delete the link, not the directory " Delete the link, not the directory
call assert_equal(0, delete('Xlink')) call assert_equal(0, delete('Xdirlink'))
call assert_equal(-1, delete('Xlink')) call assert_equal(-1, delete('Xdirlink'))
call assert_equal(0, delete('Xdir1', 'd')) call assert_equal(0, delete('Xsymdir', 'd'))
endfunc endfunc
func Test_symlink_recursive_delete() func Test_symlink_recursive_delete()
CheckUnix CheckUnix
call mkdir('Xdir3') call mkdir('Xrecdir3')
call mkdir('Xdir3/subdir') call mkdir('Xrecdir3/subdir')
call mkdir('Xdir4') call mkdir('Xrecdir4')
split Xdir3/Xfile split Xrecdir3/Xfile
call setline(1, ['a', 'b']) call setline(1, ['a', 'b'])
w w
w Xdir3/subdir/Xfile w Xrecdir3/subdir/Xfile
w Xdir4/Xfile w Xrecdir4/Xfile
close close
silent !ln -s ../Xdir4 Xdir3/Xlink silent !ln -s ../Xrecdir4 Xrecdir3/Xreclink
call assert_true(isdirectory('Xdir3')) call assert_true(isdirectory('Xrecdir3'))
call assert_equal(['a', 'b'], readfile('Xdir3/Xfile')) call assert_equal(['a', 'b'], readfile('Xrecdir3/Xfile'))
call assert_true(isdirectory('Xdir3/subdir')) call assert_true(isdirectory('Xrecdir3/subdir'))
call assert_equal(['a', 'b'], readfile('Xdir3/subdir/Xfile')) call assert_equal(['a', 'b'], readfile('Xrecdir3/subdir/Xfile'))
call assert_true(isdirectory('Xdir4')) call assert_true(isdirectory('Xrecdir4'))
call assert_true(isdirectory('Xdir3/Xlink')) call assert_true(isdirectory('Xrecdir3/Xreclink'))
call assert_equal(['a', 'b'], readfile('Xdir4/Xfile')) call assert_equal(['a', 'b'], readfile('Xrecdir4/Xfile'))
call assert_equal(0, delete('Xdir3', 'rf')) call assert_equal(0, delete('Xrecdir3', 'rf'))
call assert_false(isdirectory('Xdir3')) call assert_false(isdirectory('Xrecdir3'))
call assert_equal(-1, delete('Xdir3', 'd')) call assert_equal(-1, delete('Xrecdir3', 'd'))
" symlink is deleted, not the directory it points to " symlink is deleted, not the directory it points to
call assert_true(isdirectory('Xdir4')) call assert_true(isdirectory('Xrecdir4'))
call assert_equal(['a', 'b'], readfile('Xdir4/Xfile')) call assert_equal(['a', 'b'], readfile('Xrecdir4/Xfile'))
call assert_equal(0, delete('Xdir4/Xfile')) call assert_equal(0, delete('Xrecdir4/Xfile'))
call assert_equal(0, delete('Xdir4', 'd')) call assert_equal(0, delete('Xrecdir4', 'd'))
bwipe Xdir3/Xfile bwipe Xrecdir3/Xfile
bwipe Xdir3/subdir/Xfile bwipe Xrecdir3/subdir/Xfile
bwipe Xdir4/Xfile bwipe Xrecdir4/Xfile
endfunc endfunc
func Test_delete_errors() func Test_delete_errors()

View File

@@ -1492,7 +1492,7 @@ func Test_edit_complete_very_long_name()
" Long directory names only work on Unix. " Long directory names only work on Unix.
CheckUnix CheckUnix
let dirname = getcwd() . "/Xdir" let dirname = getcwd() . "/Xlongdir"
let longdirname = dirname . repeat('/' . repeat('d', 255), 4) let longdirname = dirname . repeat('/' . repeat('d', 255), 4)
try try
call mkdir(longdirname, 'p') call mkdir(longdirname, 'p')
@@ -1729,7 +1729,7 @@ endfunc
" Test for editing a directory " Test for editing a directory
func Test_edit_is_a_directory() func Test_edit_is_a_directory()
CheckEnglish CheckEnglish
let dirname = getcwd() . "/Xdir" let dirname = getcwd() . "/Xeditdir"
call mkdir(dirname, 'p') call mkdir(dirname, 'p')
new new

View File

@@ -489,9 +489,9 @@ func Test_redir_cmd()
if has('unix') if has('unix')
" Redirecting to a directory name " Redirecting to a directory name
call mkdir('Xdir') call mkdir('Xredir')
call assert_fails('redir > Xdir', 'E17:') call assert_fails('redir > Xredir', 'E17:')
call delete('Xdir', 'd') call delete('Xredir', 'd')
endif endif
" Test for redirecting to a register " Test for redirecting to a register

View File

@@ -1,14 +1,14 @@
" Test findfile() and finddir() " Test findfile() and finddir()
let s:files = [ 'Xdir1/foo', let s:files = [ 'Xfinddir1/foo',
\ 'Xdir1/bar', \ 'Xfinddir1/bar',
\ 'Xdir1/Xdir2/foo', \ 'Xfinddir1/Xdir2/foo',
\ 'Xdir1/Xdir2/foobar', \ 'Xfinddir1/Xdir2/foobar',
\ 'Xdir1/Xdir2/Xdir3/bar', \ 'Xfinddir1/Xdir2/Xdir3/bar',
\ 'Xdir1/Xdir2/Xdir3/barfoo' ] \ 'Xfinddir1/Xdir2/Xdir3/barfoo' ]
func CreateFiles() func CreateFiles()
call mkdir('Xdir1/Xdir2/Xdir3/Xdir2', 'p') call mkdir('Xfinddir1/Xdir2/Xdir3/Xdir2', 'p')
for f in s:files for f in s:files
call writefile([], f) call writefile([], f)
endfor endfor
@@ -16,15 +16,15 @@ endfunc
func CleanFiles() func CleanFiles()
" Safer to delete each file even if it's more verbose " Safer to delete each file even if it's more verbose
" than doing a recursive delete('Xdir1', 'rf'). " than doing a recursive delete('Xfinddir1', 'rf').
for f in s:files for f in s:files
call delete(f) call delete(f)
endfor endfor
call delete('Xdir1/Xdir2/Xdir3/Xdir2', 'd') call delete('Xfinddir1/Xdir2/Xdir3/Xdir2', 'd')
call delete('Xdir1/Xdir2/Xdir3', 'd') call delete('Xfinddir1/Xdir2/Xdir3', 'd')
call delete('Xdir1/Xdir2', 'd') call delete('Xfinddir1/Xdir2', 'd')
call delete('Xdir1', 'd') call delete('Xfinddir1', 'd')
endfunc endfunc
" Test findfile({name} [, {path} [, {count}]]) " Test findfile({name} [, {path} [, {count}]])
@@ -34,7 +34,7 @@ func Test_findfile()
let save_dir = getcwd() let save_dir = getcwd()
set shellslash set shellslash
call CreateFiles() call CreateFiles()
cd Xdir1 cd Xfinddir1
e Xdir2/foo e Xdir2/foo
" With ,, in path, findfile() searches in current directory. " With ,, in path, findfile() searches in current directory.
@@ -83,34 +83,34 @@ func Test_findfile()
" Test upwards search. " Test upwards search.
cd Xdir2/Xdir3 cd Xdir2/Xdir3
call assert_equal('bar', findfile('bar', ';')) call assert_equal('bar', findfile('bar', ';'))
call assert_match('.*/Xdir1/Xdir2/foo', findfile('foo', ';')) call assert_match('.*/Xfinddir1/Xdir2/foo', findfile('foo', ';'))
call assert_match('.*/Xdir1/Xdir2/foo', findfile('foo', ';', 1)) call assert_match('.*/Xfinddir1/Xdir2/foo', findfile('foo', ';', 1))
call assert_match('.*/Xdir1/foo', findfile('foo', ';', 2)) call assert_match('.*/Xfinddir1/foo', findfile('foo', ';', 2))
call assert_match('.*/Xdir1/foo', findfile('foo', ';', 2)) call assert_match('.*/Xfinddir1/foo', findfile('foo', ';', 2))
call assert_match('.*/Xdir1/Xdir2/foo', findfile('foo', 'Xdir2;', 1)) call assert_match('.*/Xfinddir1/Xdir2/foo', findfile('foo', 'Xdir2;', 1))
call assert_equal('', findfile('foo', 'Xdir2;', 2)) call assert_equal('', findfile('foo', 'Xdir2;', 2))
" List l should have at least 2 values (possibly more if foo file " List l should have at least 2 values (possibly more if foo file
" happens to be found upwards above Xdir1). " happens to be found upwards above Xfinddir1).
let l = findfile('foo', ';', -1) let l = findfile('foo', ';', -1)
call assert_match('.*/Xdir1/Xdir2/foo', l[0]) call assert_match('.*/Xfinddir1/Xdir2/foo', l[0])
call assert_match('.*/Xdir1/foo', l[1]) call assert_match('.*/Xfinddir1/foo', l[1])
" Test upwards search with stop-directory. " Test upwards search with stop-directory.
cd Xdir2 cd Xdir2
let l = findfile('bar', ';' . save_dir . '/Xdir1/Xdir2/', -1) let l = findfile('bar', ';' . save_dir . '/Xfinddir1/Xdir2/', -1)
call assert_equal(1, len(l)) call assert_equal(1, len(l))
call assert_match('.*/Xdir1/Xdir2/Xdir3/bar', l[0]) call assert_match('.*/Xfinddir1/Xdir2/Xdir3/bar', l[0])
let l = findfile('bar', ';' . save_dir . '/Xdir1/', -1) let l = findfile('bar', ';' . save_dir . '/Xfinddir1/', -1)
call assert_equal(2, len(l)) call assert_equal(2, len(l))
call assert_match('.*/Xdir1/Xdir2/Xdir3/bar', l[0]) call assert_match('.*/Xfinddir1/Xdir2/Xdir3/bar', l[0])
call assert_match('.*/Xdir1/bar', l[1]) call assert_match('.*/Xfinddir1/bar', l[1])
" Test combined downwards and upwards search from Xdir2/. " Test combined downwards and upwards search from Xdir2/.
cd ../.. cd ../..
call assert_equal('Xdir3/bar', findfile('bar', '**;', 1)) call assert_equal('Xdir3/bar', findfile('bar', '**;', 1))
call assert_match('.*/Xdir1/bar', findfile('bar', '**;', 2)) call assert_match('.*/Xfinddir1/bar', findfile('bar', '**;', 2))
bwipe! bwipe!
call chdir(save_dir) call chdir(save_dir)
@@ -134,7 +134,7 @@ func Test_finddir()
let save_dir = getcwd() let save_dir = getcwd()
set path=,, set path=,,
call CreateFiles() call CreateFiles()
cd Xdir1 cd Xfinddir1
call assert_equal('Xdir2', finddir('Xdir2')) call assert_equal('Xdir2', finddir('Xdir2'))
call assert_equal('', 'Xdir3'->finddir()) call assert_equal('', 'Xdir3'->finddir())
@@ -157,17 +157,17 @@ func Test_finddir()
" Test upwards dir search. " Test upwards dir search.
cd Xdir2/Xdir3 cd Xdir2/Xdir3
call assert_match('.*/Xdir1', finddir('Xdir1', ';')) call assert_match('.*/Xfinddir1', finddir('Xfinddir1', ';'))
" Test upwards search with stop-directory. " Test upwards search with stop-directory.
call assert_match('.*/Xdir1', finddir('Xdir1', ';' . save_dir . '/')) call assert_match('.*/Xfinddir1', finddir('Xfinddir1', ';' . save_dir . '/'))
call assert_equal('', finddir('Xdir1', ';' . save_dir . '/Xdir1/')) call assert_equal('', finddir('Xfinddir1', ';' . save_dir . '/Xfinddir1/'))
" Test combined downwards and upwards dir search from Xdir2/. " Test combined downwards and upwards dir search from Xdir2/.
cd .. cd ..
call assert_match('.*/Xdir1', finddir('Xdir1', '**;', 1)) call assert_match('.*/Xfinddir1', finddir('Xfinddir1', '**;', 1))
call assert_equal('Xdir3/Xdir2', finddir('Xdir2', '**;', 1)) call assert_equal('Xdir3/Xdir2', finddir('Xdir2', '**;', 1))
call assert_match('.*/Xdir1/Xdir2', finddir('Xdir2', '**;', 2)) call assert_match('.*/Xfinddir1/Xdir2', finddir('Xdir2', '**;', 2))
call assert_equal('Xdir3', finddir('Xdir3', '**;', 1)) call assert_equal('Xdir3', finddir('Xdir3', '**;', 1))
call chdir(save_dir) call chdir(save_dir)
@@ -191,7 +191,7 @@ func Test_find_cmd()
let save_dir = getcwd() let save_dir = getcwd()
set path=.,./**/* set path=.,./**/*
call CreateFiles() call CreateFiles()
cd Xdir1 cd Xfinddir1
" Test for :find " Test for :find
find foo find foo

View File

@@ -347,9 +347,9 @@ func Test_resolve_unix()
call delete('Xlink2') call delete('Xlink2')
call delete('Xlink3') call delete('Xlink3')
silent !ln -s -f Xdir//Xfile Xlink silent !ln -s -f Xresolvedir//Xfile Xresolvelink
call assert_equal('Xdir/Xfile', resolve('Xlink')) call assert_equal('Xresolvedir/Xfile', resolve('Xresolvelink'))
call delete('Xlink') call delete('Xresolvelink')
silent !ln -s -f Xlink2/ Xlink1 silent !ln -s -f Xlink2/ Xlink1
call assert_equal('Xlink2', 'Xlink1'->resolve()) call assert_equal('Xlink2', 'Xlink1'->resolve())
@@ -375,22 +375,22 @@ func Test_resolve_win32()
" test for shortcut file " test for shortcut file
if executable('cscript') if executable('cscript')
new Xfile new Xresfile
wq wq
let lines =<< trim END let lines =<< trim END
Set fs = CreateObject("Scripting.FileSystemObject") Set fs = CreateObject("Scripting.FileSystemObject")
Set ws = WScript.CreateObject("WScript.Shell") Set ws = WScript.CreateObject("WScript.Shell")
Set shortcut = ws.CreateShortcut("Xlink.lnk") Set shortcut = ws.CreateShortcut("Xlink.lnk")
shortcut.TargetPath = fs.BuildPath(ws.CurrentDirectory, "Xfile") shortcut.TargetPath = fs.BuildPath(ws.CurrentDirectory, "Xresfile")
shortcut.Save shortcut.Save
END END
call writefile(lines, 'link.vbs') call writefile(lines, 'link.vbs')
silent !cscript link.vbs silent !cscript link.vbs
call delete('link.vbs') call delete('link.vbs')
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('Xfile') 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') call delete('Xlink.lnk')
else else
echomsg 'skipped test for shortcut file' echomsg 'skipped test for shortcut file'
@@ -398,52 +398,51 @@ func Test_resolve_win32()
" remove files " remove files
call delete('Xlink') call delete('Xlink')
call delete('Xdir', 'd') call delete('Xresfile')
call delete('Xfile')
" test for symbolic link to a file " test for symbolic link to a file
new Xfile new Xslinkfile
wq wq
call assert_equal('Xfile', resolve('Xfile')) call assert_equal('Xslinkfile', resolve('Xslinkfile'))
silent !mklink Xlink Xfile silent !mklink Xlink Xslinkfile
if !v:shell_error if !v:shell_error
call assert_equal(s:normalize_fname(getcwd() . '\Xfile'), s:normalize_fname(resolve('./Xlink'))) call assert_equal(s:normalize_fname(getcwd() . '\Xslinkfile'), s:normalize_fname(resolve('./Xlink')))
call delete('Xlink') call delete('Xlink')
else else
echomsg 'skipped test for symbolic link to a file' echomsg 'skipped test for symbolic link to a file'
endif endif
call delete('Xfile') call delete('Xslinkfile')
" test for junction to a directory " test for junction to a directory
call mkdir('Xdir') call mkdir('Xjuncdir')
silent !mklink /J Xlink Xdir silent !mklink /J Xlink Xjuncdir
if !v:shell_error if !v:shell_error
call assert_equal(s:normalize_fname(getcwd() . '\Xdir'), s:normalize_fname(resolve(getcwd() . '/Xlink'))) call assert_equal(s:normalize_fname(getcwd() . '\Xjuncdir'), s:normalize_fname(resolve(getcwd() . '/Xlink')))
call delete('Xdir', 'd') call delete('Xjuncdir', 'd')
" test for junction already removed " test for junction already removed
call assert_equal(s:normalize_fname(getcwd() . '\Xlink'), s:normalize_fname(resolve(getcwd() . '/Xlink'))) call assert_equal(s:normalize_fname(getcwd() . '\Xlink'), s:normalize_fname(resolve(getcwd() . '/Xlink')))
call delete('Xlink') call delete('Xlink')
else else
echomsg 'skipped test for junction to a directory' echomsg 'skipped test for junction to a directory'
call delete('Xdir', 'd') call delete('Xjuncdir', 'd')
endif endif
" test for symbolic link to a directory " test for symbolic link to a directory
call mkdir('Xdir') call mkdir('Xjuncdir')
silent !mklink /D Xlink Xdir silent !mklink /D Xlink Xjuncdir
if !v:shell_error if !v:shell_error
call assert_equal(s:normalize_fname(getcwd() . '\Xdir'), s:normalize_fname(resolve(getcwd() . '/Xlink'))) call assert_equal(s:normalize_fname(getcwd() . '\Xjuncdir'), s:normalize_fname(resolve(getcwd() . '/Xlink')))
call delete('Xdir', 'd') call delete('Xjuncdir', 'd')
" test for symbolic link already removed " test for symbolic link already removed
call assert_equal(s:normalize_fname(getcwd() . '\Xlink'), s:normalize_fname(resolve(getcwd() . '/Xlink'))) call assert_equal(s:normalize_fname(getcwd() . '\Xlink'), s:normalize_fname(resolve(getcwd() . '/Xlink')))
call delete('Xlink') call delete('Xlink')
else else
echomsg 'skipped test for symbolic link to a directory' echomsg 'skipped test for symbolic link to a directory'
call delete('Xdir', 'd') call delete('Xjuncdir', 'd')
endif endif
" test for buffer name " test for buffer name
@@ -461,20 +460,20 @@ func Test_resolve_win32()
call delete('Xfile') call delete('Xfile')
" test for reparse point " test for reparse point
call mkdir('Xdir') call mkdir('Xparsedir')
call assert_equal('Xdir', resolve('Xdir')) call assert_equal('Xdir', resolve('Xparsedir'))
silent !mklink /D Xdirlink Xdir silent !mklink /D Xdirlink Xparsedir
if !v:shell_error if !v:shell_error
w Xdir/text.txt w Xparsedir/text.txt
call assert_equal('Xdir/text.txt', resolve('Xdir/text.txt')) call assert_equal('Xparsedir/text.txt', resolve('Xparsedir/text.txt'))
call assert_equal(s:normalize_fname(getcwd() . '\Xdir\text.txt'), s:normalize_fname(resolve('Xdirlink\text.txt'))) call assert_equal(s:normalize_fname(getcwd() . '\Xparsedir\text.txt'), s:normalize_fname(resolve('Xdirlink\text.txt')))
call assert_equal(s:normalize_fname(getcwd() . '\Xdir'), s:normalize_fname(resolve('Xdirlink'))) call assert_equal(s:normalize_fname(getcwd() . '\Xparsedir'), s:normalize_fname(resolve('Xdirlink')))
call delete('Xdirlink') call delete('Xdirlink')
else else
echomsg 'skipped test for reparse point' echomsg 'skipped test for reparse point'
endif endif
call delete('Xdir', 'rf') call delete('Xparsedir', 'rf')
endfunc endfunc
func Test_simplify() func Test_simplify()
@@ -497,9 +496,9 @@ func Test_simplify()
call assert_equal('./file', simplify('dir/.././file')) call assert_equal('./file', simplify('dir/.././file'))
call assert_equal('../dir', simplify('./../dir')) call assert_equal('../dir', simplify('./../dir'))
call assert_equal('..', simplify('../testdir/..')) call assert_equal('..', simplify('../testdir/..'))
call mkdir('Xdir') call mkdir('Xsimpdir')
call assert_equal('.', simplify('Xdir/../.')) call assert_equal('.', simplify('Xsimpdir/../.'))
call delete('Xdir', 'd') call delete('Xsimpdir', 'd')
call assert_fails('call simplify({->0})', 'E729:') call assert_fails('call simplify({->0})', 'E729:')
call assert_fails('call simplify([])', 'E730:') call assert_fails('call simplify([])', 'E730:')
@@ -1336,9 +1335,9 @@ func Test_filewritable()
call assert_equal(0, filewritable('doesnotexist')) call assert_equal(0, filewritable('doesnotexist'))
call mkdir('Xdir') call mkdir('Xwritedir')
call assert_equal(2, filewritable('Xdir')) call assert_equal(2, filewritable('Xwritedir'))
call delete('Xdir', 'd') call delete('Xwritedir', 'd')
call delete('Xfilewritable') call delete('Xfilewritable')
bw! bw!
@@ -1364,17 +1363,17 @@ func Test_Executable()
bwipe bwipe
" create "notepad.bat" " create "notepad.bat"
call mkdir('Xdir') call mkdir('Xnotedir')
let notepadbat = fnamemodify('Xdir/notepad.bat', ':p') let notepadbat = fnamemodify('Xnotedir/notepad.bat', ':p')
call writefile([], notepadbat) call writefile([], notepadbat)
new new
" check that the path and the pathext order is valid " check that the path and the pathext order is valid
lcd Xdir lcd Xnotedir
let [pathext, $PATHEXT] = [$PATHEXT, '.com;.exe;.bat;.cmd'] let [pathext, $PATHEXT] = [$PATHEXT, '.com;.exe;.bat;.cmd']
call assert_equal(notepadbat, exepath('notepad')) call assert_equal(notepadbat, exepath('notepad'))
let $PATHEXT = pathext let $PATHEXT = pathext
bwipe bwipe
eval 'Xdir'->delete('rf') eval 'Xnotedir'->delete('rf')
elseif has('unix') elseif has('unix')
call assert_equal(1, 'cat'->executable()) call assert_equal(1, 'cat'->executable())
call assert_equal(0, executable('nodogshere')) call assert_equal(0, executable('nodogshere'))
@@ -2073,88 +2072,88 @@ func Test_platform_name()
endfunc endfunc
func Test_readdir() func Test_readdir()
call mkdir('Xdir') call mkdir('Xreaddir')
call writefile([], 'Xdir/foo.txt') call writefile([], 'Xreaddir/foo.txt')
call writefile([], 'Xdir/bar.txt') call writefile([], 'Xreaddir/bar.txt')
call mkdir('Xdir/dir') call mkdir('Xreaddir/dir')
" All results " All results
let files = readdir('Xdir') let files = readdir('Xreaddir')
call assert_equal(['bar.txt', 'dir', 'foo.txt'], sort(files)) call assert_equal(['bar.txt', 'dir', 'foo.txt'], sort(files))
" Only results containing "f" " Only results containing "f"
let files = 'Xdir'->readdir({ x -> stridx(x, 'f') != -1 }) let files = 'Xreaddir'->readdir({ x -> stridx(x, 'f') != -1 })
call assert_equal(['foo.txt'], sort(files)) call assert_equal(['foo.txt'], sort(files))
" Only .txt files " Only .txt files
let files = readdir('Xdir', { x -> x =~ '.txt$' }) let files = readdir('Xreaddir', { x -> x =~ '.txt$' })
call assert_equal(['bar.txt', 'foo.txt'], sort(files)) call assert_equal(['bar.txt', 'foo.txt'], sort(files))
" Only .txt files with string " Only .txt files with string
let files = readdir('Xdir', 'v:val =~ ".txt$"') let files = readdir('Xreaddir', 'v:val =~ ".txt$"')
call assert_equal(['bar.txt', 'foo.txt'], sort(files)) call assert_equal(['bar.txt', 'foo.txt'], sort(files))
" Limit to 1 result. " Limit to 1 result.
let l = [] let l = []
let files = readdir('Xdir', {x -> len(add(l, x)) == 2 ? -1 : 1}) let files = readdir('Xreaddir', {x -> len(add(l, x)) == 2 ? -1 : 1})
call assert_equal(1, len(files)) call assert_equal(1, len(files))
" Nested readdir() must not crash " Nested readdir() must not crash
let files = readdir('Xdir', 'readdir("Xdir", "1") != []') let files = readdir('Xreaddir', 'readdir("Xreaddir", "1") != []')
call sort(files)->assert_equal(['bar.txt', 'dir', 'foo.txt']) call sort(files)->assert_equal(['bar.txt', 'dir', 'foo.txt'])
eval 'Xdir'->delete('rf') eval 'Xreaddir'->delete('rf')
endfunc endfunc
func Test_readdirex() func Test_readdirex()
call mkdir('Xdir') call mkdir('Xexdir')
call writefile(['foo'], 'Xdir/foo.txt') call writefile(['foo'], 'Xexdir/foo.txt')
call writefile(['barbar'], 'Xdir/bar.txt') call writefile(['barbar'], 'Xexdir/bar.txt')
call mkdir('Xdir/dir') call mkdir('Xexdir/dir')
" All results " All results
let files = readdirex('Xdir')->map({-> v:val.name}) let files = readdirex('Xexdir')->map({-> v:val.name})
call assert_equal(['bar.txt', 'dir', 'foo.txt'], sort(files)) call assert_equal(['bar.txt', 'dir', 'foo.txt'], sort(files))
let sizes = readdirex('Xdir')->map({-> v:val.size}) let sizes = readdirex('Xexdir')->map({-> v:val.size})
call assert_equal([0, 4, 7], sort(sizes)) call assert_equal([0, 4, 7], sort(sizes))
" Only results containing "f" " Only results containing "f"
let files = 'Xdir'->readdirex({ e -> stridx(e.name, 'f') != -1 }) let files = 'Xexdir'->readdirex({ e -> stridx(e.name, 'f') != -1 })
\ ->map({-> v:val.name}) \ ->map({-> v:val.name})
call assert_equal(['foo.txt'], sort(files)) call assert_equal(['foo.txt'], sort(files))
" Only .txt files " Only .txt files
let files = readdirex('Xdir', { e -> e.name =~ '.txt$' }) let files = readdirex('Xexdir', { e -> e.name =~ '.txt$' })
\ ->map({-> v:val.name}) \ ->map({-> v:val.name})
call assert_equal(['bar.txt', 'foo.txt'], sort(files)) call assert_equal(['bar.txt', 'foo.txt'], sort(files))
" Only .txt files with string " Only .txt files with string
let files = readdirex('Xdir', 'v:val.name =~ ".txt$"') let files = readdirex('Xexdir', 'v:val.name =~ ".txt$"')
\ ->map({-> v:val.name}) \ ->map({-> v:val.name})
call assert_equal(['bar.txt', 'foo.txt'], sort(files)) call assert_equal(['bar.txt', 'foo.txt'], sort(files))
" Limit to 1 result. " Limit to 1 result.
let l = [] let l = []
let files = readdirex('Xdir', {e -> len(add(l, e.name)) == 2 ? -1 : 1}) let files = readdirex('Xexdir', {e -> len(add(l, e.name)) == 2 ? -1 : 1})
\ ->map({-> v:val.name}) \ ->map({-> v:val.name})
call assert_equal(1, len(files)) call assert_equal(1, len(files))
" Nested readdirex() must not crash " Nested readdirex() must not crash
let files = readdirex('Xdir', 'readdirex("Xdir", "1") != []') let files = readdirex('Xexdir', 'readdirex("Xexdir", "1") != []')
\ ->map({-> v:val.name}) \ ->map({-> v:val.name})
call sort(files)->assert_equal(['bar.txt', 'dir', 'foo.txt']) call sort(files)->assert_equal(['bar.txt', 'dir', 'foo.txt'])
" report broken link correctly " report broken link correctly
if has("unix") if has("unix")
call writefile([], 'Xdir/abc.txt') call writefile([], 'Xexdir/abc.txt')
call system("ln -s Xdir/abc.txt Xdir/link") call system("ln -s Xexdir/abc.txt Xexdir/link")
call delete('Xdir/abc.txt') call delete('Xexdir/abc.txt')
let files = readdirex('Xdir', 'readdirex("Xdir", "1") != []') let files = readdirex('Xexdir', 'readdirex("Xexdir", "1") != []')
\ ->map({-> v:val.name .. '_' .. v:val.type}) \ ->map({-> v:val.name .. '_' .. v:val.type})
call sort(files)->assert_equal( call sort(files)->assert_equal(
\ ['bar.txt_file', 'dir_dir', 'foo.txt_file', 'link_link']) \ ['bar.txt_file', 'dir_dir', 'foo.txt_file', 'link_link'])
endif endif
eval 'Xdir'->delete('rf') eval 'Xexdir'->delete('rf')
call assert_fails('call readdirex("doesnotexist")', 'E484:') call assert_fails('call readdirex("doesnotexist")', 'E484:')
endfunc endfunc
@@ -2166,34 +2165,34 @@ func Test_readdirex_sort()
throw 'Skipped: Test_readdirex_sort on systems that do not allow this using the default filesystem' throw 'Skipped: Test_readdirex_sort on systems that do not allow this using the default filesystem'
endif endif
let _collate = v:collate let _collate = v:collate
call mkdir('Xdir2') call mkdir('Xsortdir2')
call writefile(['1'], 'Xdir2/README.txt') call writefile(['1'], 'Xsortdir2/README.txt')
call writefile(['2'], 'Xdir2/Readme.txt') call writefile(['2'], 'Xsortdir2/Readme.txt')
call writefile(['3'], 'Xdir2/readme.txt') call writefile(['3'], 'Xsortdir2/readme.txt')
" 1) default " 1) default
let files = readdirex('Xdir2')->map({-> v:val.name}) let files = readdirex('Xsortdir2')->map({-> v:val.name})
let default = copy(files) let default = copy(files)
call assert_equal(['README.txt', 'Readme.txt', 'readme.txt'], files, 'sort using default') call assert_equal(['README.txt', 'Readme.txt', 'readme.txt'], files, 'sort using default')
" 2) no sorting " 2) no sorting
let files = readdirex('Xdir2', 1, #{sort: 'none'})->map({-> v:val.name}) let files = readdirex('Xsortdir2', 1, #{sort: 'none'})->map({-> v:val.name})
let unsorted = copy(files) let unsorted = copy(files)
call assert_equal(['README.txt', 'Readme.txt', 'readme.txt'], sort(files), 'unsorted') call assert_equal(['README.txt', 'Readme.txt', 'readme.txt'], sort(files), 'unsorted')
call assert_fails("call readdirex('Xdir2', 1, #{slort: 'none'})", 'E857: Dictionary key "sort" required') call assert_fails("call readdirex('Xsortdir2', 1, #{slort: 'none'})", 'E857: Dictionary key "sort" required')
" 3) sort by case (same as default) " 3) sort by case (same as default)
let files = readdirex('Xdir2', 1, #{sort: 'case'})->map({-> v:val.name}) let files = readdirex('Xsortdir2', 1, #{sort: 'case'})->map({-> v:val.name})
call assert_equal(default, files, 'sort by case') call assert_equal(default, files, 'sort by case')
" 4) sort by ignoring case " 4) sort by ignoring case
let files = readdirex('Xdir2', 1, #{sort: 'icase'})->map({-> v:val.name}) let files = readdirex('Xsortdir2', 1, #{sort: 'icase'})->map({-> v:val.name})
call assert_equal(unsorted->sort('i'), files, 'sort by icase') call assert_equal(unsorted->sort('i'), files, 'sort by icase')
" 5) Default Collation " 5) Default Collation
let collate = v:collate let collate = v:collate
lang collate C lang collate C
let files = readdirex('Xdir2', 1, #{sort: 'collate'})->map({-> v:val.name}) let files = readdirex('Xsortdir2', 1, #{sort: 'collate'})->map({-> v:val.name})
call assert_equal(['README.txt', 'Readme.txt', 'readme.txt'], files, 'sort by C collation') call assert_equal(['README.txt', 'Readme.txt', 'readme.txt'], files, 'sort by C collation')
" 6) Collation de_DE " 6) Collation de_DE
@@ -2201,20 +2200,20 @@ func Test_readdirex_sort()
" available " available
try try
lang collate de_DE lang collate de_DE
let files = readdirex('Xdir2', 1, #{sort: 'collate'})->map({-> v:val.name}) let files = readdirex('Xsortdir2', 1, #{sort: 'collate'})->map({-> v:val.name})
call assert_equal(['readme.txt', 'Readme.txt', 'README.txt'], files, 'sort by de_DE collation') call assert_equal(['readme.txt', 'Readme.txt', 'README.txt'], files, 'sort by de_DE collation')
catch catch
throw 'Skipped: de_DE collation is not available' throw 'Skipped: de_DE collation is not available'
finally finally
exe 'lang collate' collate exe 'lang collate' collate
eval 'Xdir2'->delete('rf') eval 'Xsortdir2'->delete('rf')
endtry endtry
endfunc endfunc
func Test_readdir_sort() func Test_readdir_sort()
" some more cases for testing sorting for readdirex " some more cases for testing sorting for readdirex
let dir = 'Xdir3' let dir = 'Xsortdir3'
call mkdir(dir) call mkdir(dir)
call writefile(['1'], dir .. '/README.txt') call writefile(['1'], dir .. '/README.txt')
call writefile(['2'], dir .. '/Readm.txt') call writefile(['2'], dir .. '/Readm.txt')
@@ -2259,26 +2258,26 @@ func Test_readdir_sort()
endfunc endfunc
func Test_delete_rf() func Test_delete_rf()
call mkdir('Xdir') call mkdir('Xrfdir')
call writefile([], 'Xdir/foo.txt') call writefile([], 'Xrfdir/foo.txt')
call writefile([], 'Xdir/bar.txt') call writefile([], 'Xrfdir/bar.txt')
call mkdir('Xdir/[a-1]') " issue #696 call mkdir('Xrfdir/[a-1]') " issue #696
call writefile([], 'Xdir/[a-1]/foo.txt') call writefile([], 'Xrfdir/[a-1]/foo.txt')
call writefile([], 'Xdir/[a-1]/bar.txt') call writefile([], 'Xrfdir/[a-1]/bar.txt')
call assert_true(filereadable('Xdir/foo.txt')) call assert_true(filereadable('Xrfdir/foo.txt'))
call assert_true('Xdir/[a-1]/foo.txt'->filereadable()) call assert_true('Xrfdir/[a-1]/foo.txt'->filereadable())
call assert_equal(0, delete('Xdir', 'rf')) call assert_equal(0, delete('Xrfdir', 'rf'))
call assert_false(filereadable('Xdir/foo.txt')) call assert_false(filereadable('Xrfdir/foo.txt'))
call assert_false(filereadable('Xdir/[a-1]/foo.txt')) call assert_false(filereadable('Xrfdir/[a-1]/foo.txt'))
if has('unix') if has('unix')
call mkdir('Xdir/Xdir2', 'p') call mkdir('Xrfdir/Xdir2', 'p')
silent !chmod 555 Xdir silent !chmod 555 Xrfdir
call assert_equal(-1, delete('Xdir/Xdir2', 'rf')) call assert_equal(-1, delete('Xrfdir/Xdir2', 'rf'))
call assert_equal(-1, delete('Xdir', 'rf')) call assert_equal(-1, delete('Xrfdir', 'rf'))
silent !chmod 755 Xdir silent !chmod 755 Xrfdir
call assert_equal(0, delete('Xdir', 'rf')) call assert_equal(0, delete('Xrfdir', 'rf'))
endif endif
endfunc endfunc

View File

@@ -40,9 +40,9 @@ func SetUp()
eval 'Xtopdir'->mkdir() eval 'Xtopdir'->mkdir()
cd Xtopdir cd Xtopdir
let g:topdir = getcwd() let g:topdir = getcwd()
call mkdir('Xdir1') call mkdir('Xcwdir1')
call mkdir('Xdir2') call mkdir('Xcwdir2')
call mkdir('Xdir3') call mkdir('Xcwdir3')
endfunction endfunction
let g:cwd=getcwd() let g:cwd=getcwd()
@@ -57,23 +57,23 @@ function Test_GetCwd()
new b new b
new c new c
3wincmd w 3wincmd w
lcd Xdir1 lcd Xcwdir1
call assert_equal("a Xdir1 1", GetCwdInfo(0, 0)) call assert_equal("a Xcwdir1 1", GetCwdInfo(0, 0))
call assert_equal(g:topdir, getcwd(-1)) call assert_equal(g:topdir, getcwd(-1))
wincmd W wincmd W
call assert_equal("b Xtopdir 0", GetCwdInfo(0, 0)) call assert_equal("b Xtopdir 0", GetCwdInfo(0, 0))
call assert_equal(g:topdir, getcwd(-1)) call assert_equal(g:topdir, getcwd(-1))
wincmd W wincmd W
lcd Xdir3 lcd Xcwdir3
call assert_equal("c Xdir3 1", GetCwdInfo(0, 0)) call assert_equal("c Xcwdir3 1", GetCwdInfo(0, 0))
call assert_equal("a Xdir1 1", GetCwdInfo(bufwinnr("a"), 0)) call assert_equal("a Xcwdir1 1", GetCwdInfo(bufwinnr("a"), 0))
call assert_equal("b Xtopdir 0", GetCwdInfo(bufwinnr("b"), 0)) call assert_equal("b Xtopdir 0", GetCwdInfo(bufwinnr("b"), 0))
call assert_equal("c Xdir3 1", GetCwdInfo(bufwinnr("c"), 0)) call assert_equal("c Xcwdir3 1", GetCwdInfo(bufwinnr("c"), 0))
call assert_equal(g:topdir, getcwd(-1)) call assert_equal(g:topdir, getcwd(-1))
wincmd W wincmd W
call assert_equal("a Xdir1 1", GetCwdInfo(bufwinnr("a"), tabpagenr())) call assert_equal("a Xcwdir1 1", GetCwdInfo(bufwinnr("a"), tabpagenr()))
call assert_equal("b Xtopdir 0", GetCwdInfo(bufwinnr("b"), tabpagenr())) call assert_equal("b Xtopdir 0", GetCwdInfo(bufwinnr("b"), tabpagenr()))
call assert_equal("c Xdir3 1", GetCwdInfo(bufwinnr("c"), tabpagenr())) call assert_equal("c Xcwdir3 1", GetCwdInfo(bufwinnr("c"), tabpagenr()))
call assert_equal(g:topdir, getcwd(-1)) call assert_equal(g:topdir, getcwd(-1))
tabnew x tabnew x
@@ -83,21 +83,21 @@ function Test_GetCwd()
call assert_equal("x Xtopdir 0", GetCwdInfo(0, 0)) call assert_equal("x Xtopdir 0", GetCwdInfo(0, 0))
call assert_equal(g:topdir, getcwd(-1)) call assert_equal(g:topdir, getcwd(-1))
wincmd W wincmd W
lcd Xdir2 lcd Xcwdir2
call assert_equal("y Xdir2 1", GetCwdInfo(0, 0)) call assert_equal("y Xcwdir2 1", GetCwdInfo(0, 0))
call assert_equal(g:topdir, getcwd(-1)) call assert_equal(g:topdir, getcwd(-1))
wincmd W wincmd W
lcd Xdir3 lcd Xcwdir3
call assert_equal("z Xdir3 1", GetCwdInfo(0, 0)) call assert_equal("z Xcwdir3 1", GetCwdInfo(0, 0))
call assert_equal("x Xtopdir 0", GetCwdInfo(bufwinnr("x"), 0)) call assert_equal("x Xtopdir 0", GetCwdInfo(bufwinnr("x"), 0))
call assert_equal("y Xdir2 1", GetCwdInfo(bufwinnr("y"), 0)) call assert_equal("y Xcwdir2 1", GetCwdInfo(bufwinnr("y"), 0))
call assert_equal("z Xdir3 1", GetCwdInfo(bufwinnr("z"), 0)) call assert_equal("z Xcwdir3 1", GetCwdInfo(bufwinnr("z"), 0))
call assert_equal(g:topdir, getcwd(-1)) call assert_equal(g:topdir, getcwd(-1))
let tp_nr = tabpagenr() let tp_nr = tabpagenr()
tabrewind tabrewind
call assert_equal("x Xtopdir 0", GetCwdInfo(3, tp_nr)) call assert_equal("x Xtopdir 0", GetCwdInfo(3, tp_nr))
call assert_equal("y Xdir2 1", GetCwdInfo(2, tp_nr)) call assert_equal("y Xcwdir2 1", GetCwdInfo(2, tp_nr))
call assert_equal("z Xdir3 1", GetCwdInfo(1, tp_nr)) call assert_equal("z Xcwdir3 1", GetCwdInfo(1, tp_nr))
call assert_equal(g:topdir, getcwd(-1)) call assert_equal(g:topdir, getcwd(-1))
" Non existing windows and tab pages " Non existing windows and tab pages
call assert_equal('', getcwd(100)) call assert_equal('', getcwd(100))
@@ -241,24 +241,24 @@ function Test_Tab_Local_Cwd()
" Change the global directory for the first tab page " Change the global directory for the first tab page
tabrewind | 1wincmd w tabrewind | 1wincmd w
cd ../Xdir1 cd ../Xcwdir1
call assert_equal("a Xdir1 0", GetCwdInfo(1, 1)) call assert_equal("a Xcwdir1 0", GetCwdInfo(1, 1))
call assert_equal("b Xdir1 0", GetCwdInfo(2, 1)) call assert_equal("b Xcwdir1 0", GetCwdInfo(2, 1))
call assert_equal("m Xtabdir1 2", GetCwdInfo(1, 2)) call assert_equal("m Xtabdir1 2", GetCwdInfo(1, 2))
call assert_equal("n Xwindir2 1", GetCwdInfo(2, 2)) call assert_equal("n Xwindir2 1", GetCwdInfo(2, 2))
" Change the global directory for the second tab page " Change the global directory for the second tab page
tabnext | 1wincmd w tabnext | 1wincmd w
cd ../Xdir3 cd ../Xcwdir3
call assert_equal("m Xdir3 0", GetCwdInfo(1, 2)) call assert_equal("m Xcwdir3 0", GetCwdInfo(1, 2))
call assert_equal("n Xwindir2 1", GetCwdInfo(2, 2)) call assert_equal("n Xwindir2 1", GetCwdInfo(2, 2))
call assert_equal("o Xdir3 0", GetCwdInfo(3, 2)) call assert_equal("o Xcwdir3 0", GetCwdInfo(3, 2))
" Change the tab-local directory for the third tab page " Change the tab-local directory for the third tab page
tabnext | 1wincmd w tabnext | 1wincmd w
cd ../Xdir1 cd ../Xcwdir1
call assert_equal("x Xdir1 0", GetCwdInfo(1, 3)) call assert_equal("x Xcwdir1 0", GetCwdInfo(1, 3))
call assert_equal("y Xdir1 0", GetCwdInfo(2, 3)) call assert_equal("y Xcwdir1 0", GetCwdInfo(2, 3))
call assert_equal("z Xwindir3 1", GetCwdInfo(3, 3)) call assert_equal("z Xwindir3 1", GetCwdInfo(3, 3))
enew | only | tabonly enew | only | tabonly

View File

@@ -1400,36 +1400,36 @@ func Test_gui_drop_files()
%argdelete %argdelete
" pressing shift when dropping files should change directory " pressing shift when dropping files should change directory
let save_cwd = getcwd() let save_cwd = getcwd()
call mkdir('Xdir1') call mkdir('Xdropdir1')
call writefile([], 'Xdir1/Xfile1') call writefile([], 'Xdropdir1/Xfile1')
call writefile([], 'Xdir1/Xfile2') call writefile([], 'Xdropdir1/Xfile2')
let d = #{files: ['Xdir1/Xfile1', 'Xdir1/Xfile2'], row: 1, col: 1, let d = #{files: ['Xdropdir1/Xfile1', 'Xdropdir1/Xfile2'], row: 1, col: 1,
\ modifiers: 0x4} \ modifiers: 0x4}
call test_gui_event('dropfiles', d) call test_gui_event('dropfiles', d)
call assert_equal('Xdir1', fnamemodify(getcwd(), ':t')) call assert_equal('Xdropdir1', fnamemodify(getcwd(), ':t'))
call assert_equal('Xfile1', @%) call assert_equal('Xfile1', @%)
call chdir(save_cwd) call chdir(save_cwd)
" pressing shift when dropping directory and files should change directory " pressing shift when dropping directory and files should change directory
let d = #{files: ['Xdir1', 'Xdir1/Xfile2'], row: 1, col: 1, modifiers: 0x4} let d = #{files: ['Xdropdir1', 'Xdropdir1/Xfile2'], row: 1, col: 1, modifiers: 0x4}
call test_gui_event('dropfiles', d) call test_gui_event('dropfiles', d)
call assert_equal('Xdir1', fnamemodify(getcwd(), ':t')) call assert_equal('Xdropdir1', fnamemodify(getcwd(), ':t'))
call assert_equal('Xdir1', fnamemodify(@%, ':t')) call assert_equal('Xdropdir1', fnamemodify(@%, ':t'))
call chdir(save_cwd) call chdir(save_cwd)
%bw! %bw!
%argdelete %argdelete
" dropping a directory should edit it " dropping a directory should edit it
let d = #{files: ['Xdir1'], row: 1, col: 1, modifiers: 0} let d = #{files: ['Xdropdir1'], row: 1, col: 1, modifiers: 0}
call test_gui_event('dropfiles', d) call test_gui_event('dropfiles', d)
call assert_equal('Xdir1', @%) call assert_equal('Xdropdir1', @%)
%bw! %bw!
%argdelete %argdelete
" dropping only a directory name with Shift should ignore it " dropping only a directory name with Shift should ignore it
let d = #{files: ['Xdir1'], row: 1, col: 1, modifiers: 0x4} let d = #{files: ['Xdropdir1'], row: 1, col: 1, modifiers: 0x4}
call test_gui_event('dropfiles', d) call test_gui_event('dropfiles', d)
call assert_equal('', @%) call assert_equal('', @%)
%bw! %bw!
%argdelete %argdelete
call delete('Xdir1', 'rf') call delete('Xdropdir1', 'rf')
" drop files in the command line. The GUI drop files adds the file names to " drop files in the command line. The GUI drop files adds the file names to
" the low level input buffer. So need to use a cmdline map and feedkeys() " the low level input buffer. So need to use a cmdline map and feedkeys()

View File

@@ -129,30 +129,30 @@ endfunc
" Test for the :helptags command " Test for the :helptags command
" NOTE: if you run tests as root this will fail. Don't run tests as root! " NOTE: if you run tests as root this will fail. Don't run tests as root!
func Test_helptag_cmd() func Test_helptag_cmd()
call mkdir('Xdir/a/doc', 'p') call mkdir('Xtagdir/a/doc', 'p')
" No help file to process in the directory " No help file to process in the directory
call assert_fails('helptags Xdir', 'E151:') call assert_fails('helptags Xtagdir', 'E151:')
call writefile([], 'Xdir/a/doc/sample.txt') call writefile([], 'Xtagdir/a/doc/sample.txt')
" Test for ++t argument " Test for ++t argument
helptags ++t Xdir helptags ++t Xtagdir
call assert_equal(["help-tags\ttags\t1"], readfile('Xdir/tags')) call assert_equal(["help-tags\ttags\t1"], readfile('Xtagdir/tags'))
call delete('Xdir/tags') call delete('Xtagdir/tags')
" Test parsing tags " Test parsing tags
call writefile(['*tag1*', 'Example: >', ' *notag*', 'Example end: *tag2*'], call writefile(['*tag1*', 'Example: >', ' *notag*', 'Example end: *tag2*'],
\ 'Xdir/a/doc/sample.txt') \ 'Xtagdir/a/doc/sample.txt')
helptags Xdir helptags Xtagdir
call assert_equal(["tag1\ta/doc/sample.txt\t/*tag1*", call assert_equal(["tag1\ta/doc/sample.txt\t/*tag1*",
\ "tag2\ta/doc/sample.txt\t/*tag2*"], readfile('Xdir/tags')) \ "tag2\ta/doc/sample.txt\t/*tag2*"], readfile('Xtagdir/tags'))
" Duplicate tags in the help file " Duplicate tags in the help file
call writefile(['*tag1*', '*tag1*', '*tag2*'], 'Xdir/a/doc/sample.txt') call writefile(['*tag1*', '*tag1*', '*tag2*'], 'Xtagdir/a/doc/sample.txt')
call assert_fails('helptags Xdir', 'E154:') call assert_fails('helptags Xtagdir', 'E154:')
call delete('Xdir', 'rf') call delete('Xtagdir', 'rf')
endfunc endfunc
func Test_helptag_cmd_readonly() func Test_helptag_cmd_readonly()
@@ -160,25 +160,25 @@ func Test_helptag_cmd_readonly()
CheckNotRoot CheckNotRoot
" Read-only tags file " Read-only tags file
call mkdir('Xdir/doc', 'p') call mkdir('Xrodir/doc', 'p')
call writefile([''], 'Xdir/doc/tags') call writefile([''], 'Xrodir/doc/tags')
call writefile([], 'Xdir/doc/sample.txt') call writefile([], 'Xrodir/doc/sample.txt')
call setfperm('Xdir/doc/tags', 'r-xr--r--') call setfperm('Xrodir/doc/tags', 'r-xr--r--')
call assert_fails('helptags Xdir/doc', 'E152:', getfperm('Xdir/doc/tags')) call assert_fails('helptags Xrodir/doc', 'E152:', getfperm('Xrodir/doc/tags'))
let rtp = &rtp let rtp = &rtp
let &rtp = 'Xdir' let &rtp = 'Xrodir'
helptags ALL helptags ALL
let &rtp = rtp let &rtp = rtp
call delete('Xdir/doc/tags') call delete('Xrodir/doc/tags')
" No permission to read the help file " No permission to read the help file
call mkdir('Xdir/b/doc', 'p') call mkdir('Xrodir/b/doc', 'p')
call writefile([], 'Xdir/b/doc/sample.txt') call writefile([], 'Xrodir/b/doc/sample.txt')
call setfperm('Xdir/b/doc/sample.txt', '-w-------') call setfperm('Xrodir/b/doc/sample.txt', '-w-------')
call assert_fails('helptags Xdir', 'E153:', getfperm('Xdir/b/doc/sample.txt')) call assert_fails('helptags Xrodir', 'E153:', getfperm('Xrodir/b/doc/sample.txt'))
call delete('Xdir', 'rf') call delete('Xrodir', 'rf')
endfunc endfunc
" Test for setting the 'helpheight' option in the help window " Test for setting the 'helpheight' option in the help window

View File

@@ -9,8 +9,8 @@ func Test_ins_complete()
edit test_ins_complete.vim edit test_ins_complete.vim
" The files in the current directory interferes with the files " The files in the current directory interferes with the files
" used by this test. So use a separate directory for the test. " used by this test. So use a separate directory for the test.
call mkdir('Xdir') call mkdir('Xcpldir')
cd Xdir cd Xcpldir
set ff=unix set ff=unix
call writefile(["test11\t36Gepeto\t/Tag/", call writefile(["test11\t36Gepeto\t/Tag/",
@@ -105,7 +105,7 @@ func Test_ins_complete()
call delete('Xtestdata') call delete('Xtestdata')
set cpt& cot& def& tags& tagbsearch& hidden& set cpt& cot& def& tags& tagbsearch& hidden&
cd .. cd ..
call delete('Xdir', 'rf') call delete('Xcpldir', 'rf')
endfunc endfunc
func Test_ins_complete_invalid_byte() func Test_ins_complete_invalid_byte()
@@ -433,7 +433,7 @@ endfunc
func Test_ins_completeslash() func Test_ins_completeslash()
CheckMSWindows CheckMSWindows
call mkdir('Xdir') call mkdir('Xcpldir')
let orig_shellslash = &shellslash let orig_shellslash = &shellslash
set cpt& set cpt&
new new
@@ -442,31 +442,31 @@ func Test_ins_completeslash()
set completeslash= set completeslash=
exe "normal oXd\<C-X>\<C-F>" exe "normal oXd\<C-X>\<C-F>"
call assert_equal('Xdir\', getline('.')) call assert_equal('Xcpldir\', getline('.'))
set completeslash=backslash set completeslash=backslash
exe "normal oXd\<C-X>\<C-F>" exe "normal oXd\<C-X>\<C-F>"
call assert_equal('Xdir\', getline('.')) call assert_equal('Xcpldir\', getline('.'))
set completeslash=slash set completeslash=slash
exe "normal oXd\<C-X>\<C-F>" exe "normal oXd\<C-X>\<C-F>"
call assert_equal('Xdir/', getline('.')) call assert_equal('Xcpldir/', getline('.'))
set shellslash set shellslash
set completeslash= set completeslash=
exe "normal oXd\<C-X>\<C-F>" exe "normal oXd\<C-X>\<C-F>"
call assert_equal('Xdir/', getline('.')) call assert_equal('Xcpldir/', getline('.'))
set completeslash=backslash set completeslash=backslash
exe "normal oXd\<C-X>\<C-F>" exe "normal oXd\<C-X>\<C-F>"
call assert_equal('Xdir\', getline('.')) call assert_equal('Xcpldir\', getline('.'))
set completeslash=slash set completeslash=slash
exe "normal oXd\<C-X>\<C-F>" exe "normal oXd\<C-X>\<C-F>"
call assert_equal('Xdir/', getline('.')) call assert_equal('Xcpldir/', getline('.'))
%bw! %bw!
call delete('Xdir', 'rf') call delete('Xcpldir', 'rf')
set noshellslash set noshellslash
set completeslash=slash set completeslash=slash

View File

@@ -3,7 +3,7 @@
source check.vim source check.vim
func SetUp() func SetUp()
let s:topdir = getcwd() . '/Xdir' let s:topdir = getcwd() . '/Xppdir'
exe 'set packpath=' . s:topdir exe 'set packpath=' . s:topdir
let s:plugdir = s:topdir . '/pack/mine/opt/mytest' let s:plugdir = s:topdir . '/pack/mine/opt/mytest'
endfunc endfunc
@@ -51,9 +51,9 @@ func Test_packadd()
call assert_equal(77, g:plugin_also_works) call assert_equal(77, g:plugin_also_works)
call assert_equal(17, g:ftdetect_works) call assert_equal(17, g:ftdetect_works)
call assert_true(len(&rtp) > len(rtp)) call assert_true(len(&rtp) > len(rtp))
call assert_match('/testdir/Xdir/pack/mine/opt/mytest\($\|,\)', &rtp) call assert_match('/testdir/Xppdir/pack/mine/opt/mytest\($\|,\)', &rtp)
let new_after = match(&rtp, '/testdir/Xdir/pack/mine/opt/mytest/after,') let new_after = match(&rtp, '/testdir/Xppdir/pack/mine/opt/mytest/after,')
let forwarded = substitute(first_after_entry, '\\', '[/\\\\]', 'g') let forwarded = substitute(first_after_entry, '\\', '[/\\\\]', 'g')
let old_after = match(&rtp, ',' . forwarded . '\>') let old_after = match(&rtp, ',' . forwarded . '\>')
call assert_true(new_after > 0, 'rtp is ' . &rtp) call assert_true(new_after > 0, 'rtp is ' . &rtp)
@@ -67,7 +67,7 @@ func Test_packadd()
" Check the path of 'myte' is added " Check the path of 'myte' is added
call assert_true(len(&rtp) > len(rtp)) call assert_true(len(&rtp) > len(rtp))
call assert_match('/testdir/Xdir/pack/mine/opt/myte\($\|,\)', &rtp) call assert_match('/testdir/Xppdir/pack/mine/opt/myte\($\|,\)', &rtp)
" Check exception " Check exception
call assert_fails("packadd directorynotfound", 'E919:') call assert_fails("packadd directorynotfound", 'E919:')
@@ -89,7 +89,7 @@ func Test_packadd_start()
call assert_equal(24, g:plugin_works) call assert_equal(24, g:plugin_works)
call assert_true(len(&rtp) > len(rtp)) call assert_true(len(&rtp) > len(rtp))
call assert_match('/testdir/Xdir/pack/mine/start/other\($\|,\)', &rtp) call assert_match('/testdir/Xppdir/pack/mine/start/other\($\|,\)', &rtp)
endfunc endfunc
func Test_packadd_noload() func Test_packadd_noload()
@@ -106,7 +106,7 @@ func Test_packadd_noload()
packadd! mytest packadd! mytest
call assert_true(len(&rtp) > len(rtp)) call assert_true(len(&rtp) > len(rtp))
call assert_match('testdir/Xdir/pack/mine/opt/mytest\($\|,\)', &rtp) call assert_match('testdir/Xppdir/pack/mine/opt/mytest\($\|,\)', &rtp)
call assert_equal(0, g:plugin_works) call assert_equal(0, g:plugin_works)
" check the path is not added twice " check the path is not added twice

View File

@@ -4390,7 +4390,7 @@ func Xvimgrep_autocmd_cd(cchar)
autocmd BufRead * silent cd %:p:h autocmd BufRead * silent cd %:p:h
augroup END augroup END
10Xvimgrep /vim/ Xdir/** 10Xvimgrep /vim/ Xgrepdir/**
let l = g:Xgetlist() let l = g:Xgetlist()
call assert_equal('f1.txt', bufname(l[0].bufnr)) call assert_equal('f1.txt', bufname(l[0].bufnr))
call assert_equal('f2.txt', fnamemodify(bufname(l[2].bufnr), ':t')) call assert_equal('f2.txt', fnamemodify(bufname(l[2].bufnr), ':t'))
@@ -4403,14 +4403,14 @@ func Xvimgrep_autocmd_cd(cchar)
endfunc endfunc
func Test_vimgrep_autocmd_cd() func Test_vimgrep_autocmd_cd()
call mkdir('Xdir/a', 'p') call mkdir('Xgrepdir/a', 'p')
call mkdir('Xdir/b', 'p') call mkdir('Xgrepdir/b', 'p')
call writefile(['a_L1_vim', 'a_L2_vim'], 'Xdir/a/f1.txt') call writefile(['a_L1_vim', 'a_L2_vim'], 'Xgrepdir/a/f1.txt')
call writefile(['b_L1_vim', 'b_L2_vim'], 'Xdir/b/f2.txt') call writefile(['b_L1_vim', 'b_L2_vim'], 'Xgrepdir/b/f2.txt')
call Xvimgrep_autocmd_cd('c') call Xvimgrep_autocmd_cd('c')
call Xvimgrep_autocmd_cd('l') call Xvimgrep_autocmd_cd('l')
%bwipe %bwipe
call delete('Xdir', 'rf') call delete('Xgrepdir', 'rf')
endfunc endfunc
" The following test used to crash Vim " The following test used to crash Vim

View File

@@ -1064,13 +1064,13 @@ func Test_exrc()
call writefile(v:errors, 'Xtestout') call writefile(v:errors, 'Xtestout')
qall qall
[CODE] [CODE]
call mkdir('Xdir') call mkdir('Xrcdir')
call writefile(['let exrc_found=37'], 'Xdir/.exrc') call writefile(['let exrc_found=37'], 'Xrcdir/.exrc')
call writefile(after, 'Xdir/Xafter') call writefile(after, 'Xrcdir/Xafter')
let cmd = GetVimProg() . ' --not-a-term -S Xafter --cmd "cd Xdir" --cmd "set enc=utf8 exrc secure"' let cmd = GetVimProg() . ' --not-a-term -S Xafter --cmd "cd Xrcdir" --cmd "set enc=utf8 exrc secure"'
exe "silent !" . cmd exe "silent !" . cmd
call assert_equal([], readfile('Xdir/Xtestout')) call assert_equal([], readfile('Xrcdir/Xtestout'))
call delete('Xdir', 'rf') call delete('Xrcdir', 'rf')
endfunc endfunc
" Test for starting Vim with a non-terminal as input/output " Test for starting Vim with a non-terminal as input/output
@@ -1125,10 +1125,10 @@ func Test_w_arg()
" Test for failing to open the script output file. This test works only when " Test for failing to open the script output file. This test works only when
" the language is English. " the language is English.
if v:lang == "C" || v:lang =~ '^[Ee]n' if v:lang == "C" || v:lang =~ '^[Ee]n'
call mkdir("Xdir") call mkdir("Xargdir")
let m = system(GetVimCommand() .. " -w Xdir") let m = system(GetVimCommand() .. " -w Xargdir")
call assert_equal("Cannot open for script output: \"Xdir\"\n", m) call assert_equal("Cannot open for script output: \"Xargdir\"\n", m)
call delete("Xdir", 'rf') call delete("Xargdir", 'rf')
endif endif
" A number argument sets the 'window' option " A number argument sets the 'window' option

View File

@@ -630,12 +630,12 @@ func Test_terminal_cwd()
CheckExecutable pwd CheckExecutable pwd
let cmd = 'pwd' let cmd = 'pwd'
endif endif
call mkdir('Xdir') call mkdir('Xtermdir')
let buf = term_start(cmd, {'cwd': 'Xdir'}) let buf = term_start(cmd, {'cwd': 'Xtermdir'})
call WaitForAssert({-> assert_equal('Xdir', fnamemodify(getline(1), ":t"))}) call WaitForAssert({-> assert_equal('Xtermdir', fnamemodify(getline(1), ":t"))})
exe buf . 'bwipe' exe buf . 'bwipe'
call delete('Xdir', 'rf') call delete('Xtermdir', 'rf')
endfunc endfunc
func Test_terminal_cwd_failure() func Test_terminal_cwd_failure()

View File

@@ -315,14 +315,14 @@ def s:ScriptFuncPush()
enddef enddef
def Test_disassemble_push() def Test_disassemble_push()
mkdir('Xdir/autoload', 'p') mkdir('Xdisdir/autoload', 'p')
var save_rtp = &rtp var save_rtp = &rtp
exe 'set rtp^=' .. getcwd() .. '/Xdir' exe 'set rtp^=' .. getcwd() .. '/Xdisdir'
var lines =<< trim END var lines =<< trim END
vim9script vim9script
END END
writefile(lines, 'Xdir/autoload/autoscript.vim') writefile(lines, 'Xdisdir/autoload/autoscript.vim')
lines =<< trim END lines =<< trim END
vim9script vim9script
@@ -342,7 +342,7 @@ def Test_disassemble_push()
END END
v9.CheckScriptSuccess(lines) v9.CheckScriptSuccess(lines)
delete('Xdir', 'rf') delete('Xdisdir', 'rf')
&rtp = save_rtp &rtp = save_rtp
enddef enddef

View File

@@ -41,7 +41,7 @@ def TestCompilingError()
enddef enddef
def TestCompilingErrorInTry() def TestCompilingErrorInTry()
var dir = 'Xdir/autoload' var dir = 'Xcompdir/autoload'
mkdir(dir, 'p') mkdir(dir, 'p')
var lines =<< trim END var lines =<< trim END
@@ -61,7 +61,7 @@ def TestCompilingErrorInTry()
catch /nothing/ catch /nothing/
endtry endtry
END END
lines[1] = 'set rtp=' .. getcwd() .. '/Xdir' lines[1] = 'set rtp=' .. getcwd() .. '/Xcompdir'
writefile(lines, 'XTest_compile_error') writefile(lines, 'XTest_compile_error')
var buf = g:RunVimInTerminal('-S XTest_compile_error', {rows: 10, wait_for_ruler: 0}) var buf = g:RunVimInTerminal('-S XTest_compile_error', {rows: 10, wait_for_ruler: 0})
@@ -71,7 +71,7 @@ def TestCompilingErrorInTry()
# clean up # clean up
g:StopVimInTerminal(buf) g:StopVimInTerminal(buf)
delete('XTest_compile_error') delete('XTest_compile_error')
delete('Xdir', 'rf') delete('Xcompdir', 'rf')
enddef enddef
def Test_comment_error() def Test_comment_error()
@@ -170,7 +170,7 @@ def Test_wrong_function_name()
enddef enddef
def Test_autoload_name_mismatch() def Test_autoload_name_mismatch()
var dir = 'Xdir/autoload' var dir = 'Xnamedir/autoload'
mkdir(dir, 'p') mkdir(dir, 'p')
var lines =<< trim END var lines =<< trim END
@@ -183,18 +183,18 @@ def Test_autoload_name_mismatch()
writefile(lines, dir .. '/script.vim') writefile(lines, dir .. '/script.vim')
var save_rtp = &rtp var save_rtp = &rtp
exe 'set rtp=' .. getcwd() .. '/Xdir' exe 'set rtp=' .. getcwd() .. '/Xnamedir'
lines =<< trim END lines =<< trim END
call script#Function() call script#Function()
END END
v9.CheckScriptFailure(lines, 'E117:', 1) v9.CheckScriptFailure(lines, 'E117:', 1)
&rtp = save_rtp &rtp = save_rtp
delete(dir, 'rf') delete('Xnamdir', 'rf')
enddef enddef
def Test_autoload_names() def Test_autoload_names()
var dir = 'Xdir/autoload' var dir = 'Xandir/autoload'
mkdir(dir, 'p') mkdir(dir, 'p')
var lines =<< trim END var lines =<< trim END
@@ -206,7 +206,7 @@ def Test_autoload_names()
writefile(lines, dir .. '/foobar.vim') writefile(lines, dir .. '/foobar.vim')
var save_rtp = &rtp var save_rtp = &rtp
exe 'set rtp=' .. getcwd() .. '/Xdir' exe 'set rtp=' .. getcwd() .. '/Xandir'
lines =<< trim END lines =<< trim END
assert_equal('yes', foobar#function()) assert_equal('yes', foobar#function())
@@ -218,11 +218,11 @@ def Test_autoload_names()
v9.CheckDefAndScriptSuccess(lines) v9.CheckDefAndScriptSuccess(lines)
&rtp = save_rtp &rtp = save_rtp
delete(dir, 'rf') delete('Xandir', 'rf')
enddef enddef
def Test_autoload_error_in_script() def Test_autoload_error_in_script()
var dir = 'Xdir/autoload' var dir = 'Xaedir/autoload'
mkdir(dir, 'p') mkdir(dir, 'p')
var lines =<< trim END var lines =<< trim END
@@ -234,7 +234,7 @@ def Test_autoload_error_in_script()
writefile(lines, dir .. '/scripterror.vim') writefile(lines, dir .. '/scripterror.vim')
var save_rtp = &rtp var save_rtp = &rtp
exe 'set rtp=' .. getcwd() .. '/Xdir' exe 'set rtp=' .. getcwd() .. '/Xaedir'
g:called_function = 'no' g:called_function = 'no'
# The error in the autoload script cannot be checked with assert_fails(), use # The error in the autoload script cannot be checked with assert_fails(), use
@@ -264,7 +264,7 @@ def Test_autoload_error_in_script()
assert_equal('yes', g:called_function) assert_equal('yes', g:called_function)
&rtp = save_rtp &rtp = save_rtp
delete(dir, 'rf') delete('Xaedir', 'rf')
enddef enddef
def s:CallRecursive(n: number): number def s:CallRecursive(n: number): number

View File

@@ -766,10 +766,10 @@ def Test_use_autoload_import_in_mapping()
g:result = 49 g:result = 49
enddef enddef
END END
mkdir('Xdir/autoload', 'p') mkdir('Ximpdir/autoload', 'p')
writefile(lines, 'Xdir/autoload/XautoloadExport.vim') writefile(lines, 'Ximpdir/autoload/XautoloadExport.vim')
var save_rtp = &rtp var save_rtp = &rtp
exe 'set rtp^=' .. getcwd() .. '/Xdir' exe 'set rtp^=' .. getcwd() .. '/Ximpdir'
lines =<< trim END lines =<< trim END
vim9script vim9script
@@ -786,7 +786,7 @@ def Test_use_autoload_import_in_mapping()
unlet g:result unlet g:result
delete('Xmapscript.vim') delete('Xmapscript.vim')
nunmap <F3> nunmap <F3>
delete('Xdir', 'rf') delete('Ximpdir', 'rf')
&rtp = save_rtp &rtp = save_rtp
enddef enddef
@@ -838,9 +838,9 @@ def Test_use_import_with_funcref_in_command_completion()
enddef enddef
def Test_use_autoload_import_in_insert_completion() def Test_use_autoload_import_in_insert_completion()
mkdir('Xdir/autoload', 'p') mkdir('Xinsdir/autoload', 'p')
var save_rtp = &rtp var save_rtp = &rtp
exe 'set rtp^=' .. getcwd() .. '/Xdir' exe 'set rtp^=' .. getcwd() .. '/Xinsdir'
var lines =<< trim END var lines =<< trim END
vim9script vim9script
@@ -857,7 +857,7 @@ def Test_use_autoload_import_in_insert_completion()
enddef enddef
g:completion_loaded = 'yes' g:completion_loaded = 'yes'
END END
writefile(lines, 'Xdir/autoload/completion.vim') writefile(lines, 'Xinsdir/autoload/completion.vim')
new new
lines =<< trim END lines =<< trim END
@@ -874,22 +874,22 @@ def Test_use_autoload_import_in_insert_completion()
set thesaurusfunc= set thesaurusfunc=
bwipe! bwipe!
delete('Xdir', 'rf') delete('Xinsdir', 'rf')
&rtp = save_rtp &rtp = save_rtp
enddef enddef
def Test_use_autoload_import_partial_in_opfunc() def Test_use_autoload_import_partial_in_opfunc()
mkdir('Xdir/autoload', 'p') mkdir('Xpartdir/autoload', 'p')
var save_rtp = &rtp var save_rtp = &rtp
exe 'set rtp^=' .. getcwd() .. '/Xdir' exe 'set rtp^=' .. getcwd() .. '/Xpartdir'
var lines =<< trim END var lines =<< trim END
vim9script vim9script
export def Opfunc(..._) export def Opfunc1(..._)
g:opfunc_called = 'yes' g:opfunc_called = 'yes'
enddef enddef
END END
writefile(lines, 'Xdir/autoload/opfunc.vim') writefile(lines, 'Xpartdir/autoload/opfunc.vim')
new new
lines =<< trim END lines =<< trim END
@@ -897,7 +897,7 @@ def Test_use_autoload_import_partial_in_opfunc()
import autoload 'opfunc.vim' import autoload 'opfunc.vim'
nnoremap <expr> <F3> TheFunc() nnoremap <expr> <F3> TheFunc()
def TheFunc(): string def TheFunc(): string
&operatorfunc = function('opfunc.Opfunc', [0]) &operatorfunc = function('opfunc.Opfunc1', [0])
return 'g@' return 'g@'
enddef enddef
feedkeys("\<F3>l", 'xt') feedkeys("\<F3>l", 'xt')
@@ -907,23 +907,23 @@ def Test_use_autoload_import_partial_in_opfunc()
set opfunc= set opfunc=
bwipe! bwipe!
delete('Xdir', 'rf') delete('Xpartdir', 'rf')
nunmap <F3> nunmap <F3>
&rtp = save_rtp &rtp = save_rtp
enddef enddef
def Test_set_opfunc_to_autoload_func_directly() def Test_set_opfunc_to_autoload_func_directly()
mkdir('Xdir/autoload', 'p') mkdir('Xdirdir/autoload', 'p')
var save_rtp = &rtp var save_rtp = &rtp
exe 'set rtp^=' .. getcwd() .. '/Xdir' exe 'set rtp^=' .. getcwd() .. '/Xdirdir'
var lines =<< trim END var lines =<< trim END
vim9script vim9script
export def Opfunc(..._) export def Opfunc2(..._)
g:opfunc_called = 'yes' g:opfunc_called = 'yes'
enddef enddef
END END
writefile(lines, 'Xdir/autoload/opfunc.vim') writefile(lines, 'Xdirdir/autoload/opfunc.vim')
new new
lines =<< trim END lines =<< trim END
@@ -931,7 +931,7 @@ def Test_set_opfunc_to_autoload_func_directly()
import autoload 'opfunc.vim' import autoload 'opfunc.vim'
nnoremap <expr> <F3> TheFunc() nnoremap <expr> <F3> TheFunc()
def TheFunc(): string def TheFunc(): string
&operatorfunc = opfunc.Opfunc &operatorfunc = opfunc.Opfunc2
return 'g@' return 'g@'
enddef enddef
feedkeys("\<F3>l", 'xt') feedkeys("\<F3>l", 'xt')
@@ -941,15 +941,15 @@ def Test_set_opfunc_to_autoload_func_directly()
set opfunc= set opfunc=
bwipe! bwipe!
delete('Xdir', 'rf') delete('Xdirdir', 'rf')
nunmap <F3> nunmap <F3>
&rtp = save_rtp &rtp = save_rtp
enddef enddef
def Test_use_autoload_import_in_fold_expression() def Test_use_autoload_import_in_fold_expression()
mkdir('Xdir/autoload', 'p') mkdir('Xfolddir/autoload', 'p')
var save_rtp = &rtp var save_rtp = &rtp
exe 'set rtp^=' .. getcwd() .. '/Xdir' exe 'set rtp^=' .. getcwd() .. '/Xfolddir'
var lines =<< trim END var lines =<< trim END
vim9script vim9script
@@ -961,7 +961,7 @@ def Test_use_autoload_import_in_fold_expression()
enddef enddef
g:fold_loaded = 'yes' g:fold_loaded = 'yes'
END END
writefile(lines, 'Xdir/autoload/fold.vim') writefile(lines, 'Xfolddir/autoload/fold.vim')
lines =<< trim END lines =<< trim END
vim9script vim9script
@@ -985,7 +985,7 @@ def Test_use_autoload_import_in_fold_expression()
set foldexpr= foldtext& foldmethod& debug= set foldexpr= foldtext& foldmethod& debug=
bwipe! bwipe!
delete('Xdir', 'rf') delete('Xfolddir', 'rf')
&rtp = save_rtp &rtp = save_rtp
enddef enddef
@@ -1200,7 +1200,7 @@ def Test_autoload_import_deleted()
END END
v9.CheckScriptFailure(lines, 'E484:') v9.CheckScriptFailure(lines, 'E484:')
delete('Xdir', 'rf') delete('Xa.vim')
enddef enddef
func Test_import_in_diffexpr() func Test_import_in_diffexpr()
@@ -1455,9 +1455,9 @@ def Run_Test_import_in_spellsuggest_expr()
enddef enddef
def Test_export_shadows_global_function() def Test_export_shadows_global_function()
mkdir('Xdir/autoload', 'p') mkdir('Xglobdir/autoload', 'p')
var save_rtp = &rtp var save_rtp = &rtp
exe 'set rtp^=' .. getcwd() .. '/Xdir' exe 'set rtp^=' .. getcwd() .. '/Xglobdir'
var lines =<< trim END var lines =<< trim END
vim9script vim9script
@@ -1465,7 +1465,7 @@ def Test_export_shadows_global_function()
return 'Shadow()' return 'Shadow()'
enddef enddef
END END
writefile(lines, 'Xdir/autoload/shadow.vim') writefile(lines, 'Xglobdir/autoload/shadow.vim')
lines =<< trim END lines =<< trim END
vim9script vim9script
@@ -1481,7 +1481,7 @@ def Test_export_shadows_global_function()
delfunc g:Shadow delfunc g:Shadow
bwipe! bwipe!
delete('Xdir', 'rf') delete('Xglobdir', 'rf')
&rtp = save_rtp &rtp = save_rtp
enddef enddef
@@ -2178,10 +2178,10 @@ def Test_vim9_autoload_full_name()
enddef enddef
END END
mkdir('Xdir/autoload', 'p') mkdir('Xfulldir/autoload', 'p')
writefile(lines, 'Xdir/autoload/some.vim') writefile(lines, 'Xfulldir/autoload/some.vim')
var save_rtp = &rtp var save_rtp = &rtp
exe 'set rtp^=' .. getcwd() .. '/Xdir' exe 'set rtp^=' .. getcwd() .. '/Xfulldir'
assert_equal('test', g:some#Gettest()) assert_equal('test', g:some#Gettest())
assert_equal('name', g:some#name) assert_equal('name', g:some#name)
@@ -2198,17 +2198,17 @@ def Test_vim9_autoload_full_name()
return 'other' return 'other'
enddef enddef
END END
writefile(lines, 'Xdir/autoload/Other.vim') writefile(lines, 'Xfulldir/autoload/Other.vim')
assert_equal('other', g:Other#GetOther()) assert_equal('other', g:Other#GetOther())
delete('Xdir', 'rf') delete('Xfulldir', 'rf')
&rtp = save_rtp &rtp = save_rtp
enddef enddef
def Test_vim9script_autoload() def Test_vim9script_autoload()
mkdir('Xdir/autoload', 'p') mkdir('Xaldir/autoload', 'p')
var save_rtp = &rtp var save_rtp = &rtp
exe 'set rtp^=' .. getcwd() .. '/Xdir' exe 'set rtp^=' .. getcwd() .. '/Xaldir'
# when the path has "/autoload/" prefix is not needed # when the path has "/autoload/" prefix is not needed
var lines =<< trim END var lines =<< trim END
@@ -2232,7 +2232,7 @@ def Test_vim9script_autoload()
export final fname = 'final' export final fname = 'final'
export const cname = 'const' export const cname = 'const'
END END
writefile(lines, 'Xdir/autoload/prefixed.vim') writefile(lines, 'Xaldir/autoload/prefixed.vim')
g:prefixed_loaded = 0 g:prefixed_loaded = 0
g:expected_loaded = 0 g:expected_loaded = 0
@@ -2266,14 +2266,14 @@ def Test_vim9script_autoload()
unlet g:prefixed_loaded unlet g:prefixed_loaded
unlet g:expected_loaded unlet g:expected_loaded
delete('Xdir', 'rf') delete('Xaldir', 'rf')
&rtp = save_rtp &rtp = save_rtp
enddef enddef
def Test_import_autoload_not_exported() def Test_import_autoload_not_exported()
mkdir('Xdir/autoload', 'p') mkdir('Xnimdir/autoload', 'p')
var save_rtp = &rtp var save_rtp = &rtp
exe 'set rtp^=' .. getcwd() .. '/Xdir' exe 'set rtp^=' .. getcwd() .. '/Xnimdir'
# error when using an item that is not exported from an autoload script # error when using an item that is not exported from an autoload script
var exportLines =<< trim END var exportLines =<< trim END
@@ -2283,7 +2283,7 @@ def Test_import_autoload_not_exported()
echo 'nop' echo 'nop'
enddef enddef
END END
writefile(exportLines, 'Xdir/autoload/notExport1.vim') writefile(exportLines, 'Xnimdir/autoload/notExport1.vim')
var lines =<< trim END var lines =<< trim END
vim9script vim9script
@@ -2329,7 +2329,7 @@ def Test_import_autoload_not_exported()
# using a :def function we use a different autoload script every time so that # using a :def function we use a different autoload script every time so that
# the function is compiled without the script loaded # the function is compiled without the script loaded
writefile(exportLines, 'Xdir/autoload/notExport2.vim') writefile(exportLines, 'Xnimdir/autoload/notExport2.vim')
lines =<< trim END lines =<< trim END
vim9script vim9script
import autoload 'notExport2.vim' import autoload 'notExport2.vim'
@@ -2340,7 +2340,7 @@ def Test_import_autoload_not_exported()
END END
v9.CheckScriptFailure(lines, 'E1048: Item not found in script: notExport2#notFound') v9.CheckScriptFailure(lines, 'E1048: Item not found in script: notExport2#notFound')
writefile(exportLines, 'Xdir/autoload/notExport3.vim') writefile(exportLines, 'Xnimdir/autoload/notExport3.vim')
lines =<< trim END lines =<< trim END
vim9script vim9script
import autoload 'notExport3.vim' import autoload 'notExport3.vim'
@@ -2352,7 +2352,7 @@ def Test_import_autoload_not_exported()
# don't get E1049 because it is too complicated to figure out # don't get E1049 because it is too complicated to figure out
v9.CheckScriptFailure(lines, 'E1048: Item not found in script: notExport3#notExported') v9.CheckScriptFailure(lines, 'E1048: Item not found in script: notExport3#notExported')
writefile(exportLines, 'Xdir/autoload/notExport4.vim') writefile(exportLines, 'Xnimdir/autoload/notExport4.vim')
lines =<< trim END lines =<< trim END
vim9script vim9script
import autoload 'notExport4.vim' import autoload 'notExport4.vim'
@@ -2363,7 +2363,7 @@ def Test_import_autoload_not_exported()
END END
v9.CheckScriptFailure(lines, 'E117: Unknown function: notExport4#NotFunc') v9.CheckScriptFailure(lines, 'E117: Unknown function: notExport4#NotFunc')
writefile(exportLines, 'Xdir/autoload/notExport5.vim') writefile(exportLines, 'Xnimdir/autoload/notExport5.vim')
lines =<< trim END lines =<< trim END
vim9script vim9script
import autoload 'notExport5.vim' import autoload 'notExport5.vim'
@@ -2374,7 +2374,7 @@ def Test_import_autoload_not_exported()
END END
v9.CheckScriptFailure(lines, 'E117: Unknown function: notExport5#NotExport') v9.CheckScriptFailure(lines, 'E117: Unknown function: notExport5#NotExport')
writefile(exportLines, 'Xdir/autoload/notExport6.vim') writefile(exportLines, 'Xnimdir/autoload/notExport6.vim')
lines =<< trim END lines =<< trim END
vim9script vim9script
import autoload 'notExport6.vim' import autoload 'notExport6.vim'
@@ -2385,7 +2385,7 @@ def Test_import_autoload_not_exported()
END END
v9.CheckScriptFailure(lines, 'E117: Unknown function: notExport6#NotFunc') v9.CheckScriptFailure(lines, 'E117: Unknown function: notExport6#NotFunc')
writefile(exportLines, 'Xdir/autoload/notExport7.vim') writefile(exportLines, 'Xnimdir/autoload/notExport7.vim')
lines =<< trim END lines =<< trim END
vim9script vim9script
import autoload 'notExport7.vim' import autoload 'notExport7.vim'
@@ -2396,14 +2396,14 @@ def Test_import_autoload_not_exported()
END END
v9.CheckScriptFailure(lines, 'E117: Unknown function: notExport7#NotExport') v9.CheckScriptFailure(lines, 'E117: Unknown function: notExport7#NotExport')
delete('Xdir', 'rf') delete('Xnimdir', 'rf')
&rtp = save_rtp &rtp = save_rtp
enddef enddef
def Test_vim9script_autoload_call() def Test_vim9script_autoload_call()
mkdir('Xdir/autoload', 'p') mkdir('Xcalldir/autoload', 'p')
var save_rtp = &rtp var save_rtp = &rtp
exe 'set rtp^=' .. getcwd() .. '/Xdir' exe 'set rtp^=' .. getcwd() .. '/Xcalldir'
var lines =<< trim END var lines =<< trim END
vim9script vim9script
@@ -2416,7 +2416,7 @@ def Test_vim9script_autoload_call()
g:result = 'other' g:result = 'other'
enddef enddef
END END
writefile(lines, 'Xdir/autoload/another.vim') writefile(lines, 'Xcalldir/autoload/another.vim')
lines =<< trim END lines =<< trim END
vim9script vim9script
@@ -2440,14 +2440,14 @@ def Test_vim9script_autoload_call()
v9.CheckScriptSuccess(lines) v9.CheckScriptSuccess(lines)
unlet g:result unlet g:result
delete('Xdir', 'rf') delete('Xcalldir', 'rf')
&rtp = save_rtp &rtp = save_rtp
enddef enddef
def Test_vim9script_noclear_autoload() def Test_vim9script_noclear_autoload()
mkdir('Xdir/autoload', 'p') mkdir('Xnocdir/autoload', 'p')
var save_rtp = &rtp var save_rtp = &rtp
exe 'set rtp^=' .. getcwd() .. '/Xdir' exe 'set rtp^=' .. getcwd() .. '/Xnocdir'
var lines =<< trim END var lines =<< trim END
vim9script vim9script
@@ -2456,7 +2456,7 @@ def Test_vim9script_noclear_autoload()
enddef enddef
g:double_loaded = 'yes' g:double_loaded = 'yes'
END END
writefile(lines, 'Xdir/autoload/double.vim') writefile(lines, 'Xnocdir/autoload/double.vim')
lines =<< trim END lines =<< trim END
vim9script noclear vim9script noclear
@@ -2482,12 +2482,12 @@ def Test_vim9script_noclear_autoload()
unlet g:double_loaded unlet g:double_loaded
unlet g:script_loaded unlet g:script_loaded
unlet g:result unlet g:result
delete('Xdir', 'rf') delete('Xnocdir', 'rf')
&rtp = save_rtp &rtp = save_rtp
enddef enddef
def Test_vim9script_autoload_duplicate() def Test_vim9script_autoload_duplicate()
mkdir('Xdir/autoload', 'p') mkdir('Xdupdir/autoload', 'p')
var lines =<< trim END var lines =<< trim END
vim9script vim9script
@@ -2498,8 +2498,8 @@ def Test_vim9script_autoload_duplicate()
def Func() def Func()
enddef enddef
END END
writefile(lines, 'Xdir/autoload/dupfunc.vim') writefile(lines, 'Xdupdir/autoload/dupfunc.vim')
assert_fails('source Xdir/autoload/dupfunc.vim', 'E1073:') assert_fails('source Xdupdir/autoload/dupfunc.vim', 'E1073:')
lines =<< trim END lines =<< trim END
vim9script vim9script
@@ -2510,8 +2510,8 @@ def Test_vim9script_autoload_duplicate()
export def Func() export def Func()
enddef enddef
END END
writefile(lines, 'Xdir/autoload/dup2func.vim') writefile(lines, 'Xdupdir/autoload/dup2func.vim')
assert_fails('source Xdir/autoload/dup2func.vim', 'E1073:') assert_fails('source Xdupdir/autoload/dup2func.vim', 'E1073:')
lines =<< trim END lines =<< trim END
vim9script vim9script
@@ -2521,8 +2521,8 @@ def Test_vim9script_autoload_duplicate()
export var Func = 'asdf' export var Func = 'asdf'
END END
writefile(lines, 'Xdir/autoload/dup3func.vim') writefile(lines, 'Xdupdir/autoload/dup3func.vim')
assert_fails('source Xdir/autoload/dup3func.vim', 'E1041: Redefining script item: "Func"') assert_fails('source Xdupdir/autoload/dup3func.vim', 'E1041: Redefining script item: "Func"')
lines =<< trim END lines =<< trim END
vim9script vim9script
@@ -2532,8 +2532,8 @@ def Test_vim9script_autoload_duplicate()
def Func() def Func()
enddef enddef
END END
writefile(lines, 'Xdir/autoload/dup4func.vim') writefile(lines, 'Xdupdir/autoload/dup4func.vim')
assert_fails('source Xdir/autoload/dup4func.vim', 'E707:') assert_fails('source Xdupdir/autoload/dup4func.vim', 'E707:')
lines =<< trim END lines =<< trim END
vim9script vim9script
@@ -2543,8 +2543,8 @@ def Test_vim9script_autoload_duplicate()
export def Func() export def Func()
enddef enddef
END END
writefile(lines, 'Xdir/autoload/dup5func.vim') writefile(lines, 'Xdupdir/autoload/dup5func.vim')
assert_fails('source Xdir/autoload/dup5func.vim', 'E707:') assert_fails('source Xdupdir/autoload/dup5func.vim', 'E707:')
lines =<< trim END lines =<< trim END
vim9script vim9script
@@ -2554,14 +2554,14 @@ def Test_vim9script_autoload_duplicate()
var Func = 'asdf' var Func = 'asdf'
END END
writefile(lines, 'Xdir/autoload/dup6func.vim') writefile(lines, 'Xdupdir/autoload/dup6func.vim')
assert_fails('source Xdir/autoload/dup6func.vim', 'E1041: Redefining script item: "Func"') assert_fails('source Xdupdir/autoload/dup6func.vim', 'E1041: Redefining script item: "Func"')
delete('Xdir', 'rf') delete('Xdupdir', 'rf')
enddef enddef
def Test_autoload_missing_function_name() def Test_autoload_missing_function_name()
mkdir('Xdir/autoload', 'p') mkdir('Xmisdir/autoload', 'p')
var lines =<< trim END var lines =<< trim END
vim9script vim9script
@@ -2569,10 +2569,10 @@ def Test_autoload_missing_function_name()
def loadme#() def loadme#()
enddef enddef
END END
writefile(lines, 'Xdir/autoload/loadme.vim') writefile(lines, 'Xmisdir/autoload/loadme.vim')
assert_fails('source Xdir/autoload/loadme.vim', 'E129:') assert_fails('source Xmisdir/autoload/loadme.vim', 'E129:')
delete('Xdir', 'rf') delete('Xmisdir', 'rf')
enddef enddef
def Test_autoload_name_wrong() def Test_autoload_name_wrong()
@@ -2584,22 +2584,22 @@ def Test_autoload_name_wrong()
v9.CheckScriptFailure(lines, 'E746:') v9.CheckScriptFailure(lines, 'E746:')
delete('Xscriptname.vim') delete('Xscriptname.vim')
mkdir('Xdir/autoload', 'p') mkdir('Xwrodir/autoload', 'p')
lines =<< trim END lines =<< trim END
vim9script vim9script
def somescript#Func() def somescript#Func()
enddef enddef
END END
writefile(lines, 'Xdir/autoload/somescript.vim') writefile(lines, 'Xwrodir/autoload/somescript.vim')
assert_fails('source Xdir/autoload/somescript.vim', 'E1263:') assert_fails('source Xwrodir/autoload/somescript.vim', 'E1263:')
delete('Xdir', 'rf') delete('Xwrodir', 'rf')
enddef enddef
def Test_import_autoload_postponed() def Test_import_autoload_postponed()
mkdir('Xdir/autoload', 'p') mkdir('Xpostdir/autoload', 'p')
var save_rtp = &rtp var save_rtp = &rtp
exe 'set rtp^=' .. getcwd() .. '/Xdir' exe 'set rtp^=' .. getcwd() .. '/Xpostdir'
var lines =<< trim END var lines =<< trim END
vim9script vim9script
@@ -2610,7 +2610,7 @@ def Test_import_autoload_postponed()
return 'bla' return 'bla'
enddef enddef
END END
writefile(lines, 'Xdir/autoload/postponed.vim') writefile(lines, 'Xpostdir/autoload/postponed.vim')
lines =<< trim END lines =<< trim END
vim9script vim9script
@@ -2628,14 +2628,14 @@ def Test_import_autoload_postponed()
assert_equal('true', g:loaded_postponed) assert_equal('true', g:loaded_postponed)
unlet g:loaded_postponed unlet g:loaded_postponed
delete('Xdir', 'rf') delete('Xpostdir', 'rf')
&rtp = save_rtp &rtp = save_rtp
enddef enddef
def Test_import_autoload_override() def Test_import_autoload_override()
mkdir('Xdir/autoload', 'p') mkdir('Xoverdir/autoload', 'p')
var save_rtp = &rtp var save_rtp = &rtp
exe 'set rtp^=' .. getcwd() .. '/Xdir' exe 'set rtp^=' .. getcwd() .. '/Xoverdir'
test_override('autoload', 1) test_override('autoload', 1)
var lines =<< trim END var lines =<< trim END
@@ -2647,7 +2647,7 @@ def Test_import_autoload_override()
return 'bla' return 'bla'
enddef enddef
END END
writefile(lines, 'Xdir/autoload/override.vim') writefile(lines, 'Xoverdir/autoload/override.vim')
lines =<< trim END lines =<< trim END
vim9script vim9script
@@ -2664,14 +2664,14 @@ def Test_import_autoload_override()
test_override('autoload', 0) test_override('autoload', 0)
unlet g:loaded_override unlet g:loaded_override
delete('Xdir', 'rf') delete('Xoverdir', 'rf')
&rtp = save_rtp &rtp = save_rtp
enddef enddef
def Test_autoload_mapping() def Test_autoload_mapping()
mkdir('Xdir/autoload', 'p') mkdir('Xmapdir/autoload', 'p')
var save_rtp = &rtp var save_rtp = &rtp
exe 'set rtp^=' .. getcwd() .. '/Xdir' exe 'set rtp^=' .. getcwd() .. '/Xmapdir'
var lines =<< trim END var lines =<< trim END
vim9script vim9script
@@ -2685,7 +2685,7 @@ def Test_autoload_mapping()
g:doit_called = 'yes' g:doit_called = 'yes'
enddef enddef
END END
writefile(lines, 'Xdir/autoload/toggle.vim') writefile(lines, 'Xmapdir/autoload/toggle.vim')
lines =<< trim END lines =<< trim END
vim9script vim9script
@@ -2716,7 +2716,7 @@ def Test_autoload_mapping()
nunmap yy nunmap yy
unlet g:toggle_loaded unlet g:toggle_loaded
unlet g:toggle_called unlet g:toggle_called
delete('Xdir', 'rf') delete('Xmapdir', 'rf')
&rtp = save_rtp &rtp = save_rtp
enddef enddef
@@ -2774,9 +2774,9 @@ enddef
" test disassembling an auto-loaded function starting with "debug" " test disassembling an auto-loaded function starting with "debug"
def Test_vim9_autoload_disass() def Test_vim9_autoload_disass()
mkdir('Xdir/autoload', 'p') mkdir('Xdasdir/autoload', 'p')
var save_rtp = &rtp var save_rtp = &rtp
exe 'set rtp^=' .. getcwd() .. '/Xdir' exe 'set rtp^=' .. getcwd() .. '/Xdasdir'
var lines =<< trim END var lines =<< trim END
vim9script vim9script
@@ -2784,7 +2784,7 @@ def Test_vim9_autoload_disass()
return 'debug' return 'debug'
enddef enddef
END END
writefile(lines, 'Xdir/autoload/debugit.vim') writefile(lines, 'Xdasdir/autoload/debugit.vim')
lines =<< trim END lines =<< trim END
vim9script vim9script
@@ -2792,7 +2792,7 @@ def Test_vim9_autoload_disass()
return 'profile' return 'profile'
enddef enddef
END END
writefile(lines, 'Xdir/autoload/profileit.vim') writefile(lines, 'Xdasdir/autoload/profileit.vim')
lines =<< trim END lines =<< trim END
vim9script vim9script
@@ -2803,7 +2803,7 @@ def Test_vim9_autoload_disass()
END END
v9.CheckScriptSuccess(lines) v9.CheckScriptSuccess(lines)
delete('Xdir', 'rf') delete('Xdasdir', 'rf')
&rtp = save_rtp &rtp = save_rtp
enddef enddef
@@ -2816,10 +2816,10 @@ def Test_vim9_aucmd_autoload()
enddef enddef
END END
mkdir('Xdir/autoload', 'p') mkdir('Xauldir/autoload', 'p')
writefile(lines, 'Xdir/autoload/foo.vim') writefile(lines, 'Xauldir/autoload/foo.vim')
var save_rtp = &rtp var save_rtp = &rtp
exe 'set rtp^=' .. getcwd() .. '/Xdir' exe 'set rtp^=' .. getcwd() .. '/Xauldir'
augroup test augroup test
autocmd TextYankPost * call foo#Test() autocmd TextYankPost * call foo#Test()
augroup END augroup END
@@ -2829,7 +2829,7 @@ def Test_vim9_aucmd_autoload()
augroup test augroup test
autocmd! autocmd!
augroup END augroup END
delete('Xdir', 'rf') delete('Xauldir', 'rf')
&rtp = save_rtp &rtp = save_rtp
enddef enddef
@@ -2842,10 +2842,10 @@ def Test_vim9_autoload_case_sensitive()
enddef enddef
END END
mkdir('Xdir/autoload', 'p') mkdir('Xcasedir/autoload', 'p')
writefile(lines, 'Xdir/autoload/CaseSensitive.vim') writefile(lines, 'Xcasedir/autoload/CaseSensitive.vim')
var save_rtp = &rtp var save_rtp = &rtp
exe 'set rtp^=' .. getcwd() .. '/Xdir' exe 'set rtp^=' .. getcwd() .. '/Xcasedir'
lines =<< trim END lines =<< trim END
vim9script vim9script
@@ -2863,7 +2863,7 @@ def Test_vim9_autoload_case_sensitive()
v9.CheckScriptFailure(lines, 'E1262:') v9.CheckScriptFailure(lines, 'E1262:')
endif endif
delete('Xdir', 'rf') delete('Xcasedir', 'rf')
&rtp = save_rtp &rtp = save_rtp
enddef enddef

View File

@@ -3586,13 +3586,13 @@ def Run_test_no_redraw_when_restoring_cpo()
export def Func() export def Func()
enddef enddef
END END
mkdir('Xdir/autoload', 'p') mkdir('Xnordir/autoload', 'p')
writefile(lines, 'Xdir/autoload/script.vim') writefile(lines, 'Xnordir/autoload/script.vim')
lines =<< trim END lines =<< trim END
vim9script vim9script
set cpo+=M set cpo+=M
exe 'set rtp^=' .. getcwd() .. '/Xdir' exe 'set rtp^=' .. getcwd() .. '/Xnordir'
au CmdlineEnter : ++once timer_start(0, (_) => script#Func()) au CmdlineEnter : ++once timer_start(0, (_) => script#Func())
setline(1, 'some text') setline(1, 'some text')
END END
@@ -3605,7 +3605,7 @@ def Run_test_no_redraw_when_restoring_cpo()
term_sendkeys(buf, "\<Esc>u") term_sendkeys(buf, "\<Esc>u")
g:StopVimInTerminal(buf) g:StopVimInTerminal(buf)
delete('XTest_redraw_cpo') delete('XTest_redraw_cpo')
delete('Xdir', 'rf') delete('Xnordir', 'rf')
enddef enddef
func Test_reject_declaration() func Test_reject_declaration()

View File

@@ -962,10 +962,10 @@ func Test_viminfo_perm()
call delete('Xviminfo') call delete('Xviminfo')
" Try to write the viminfo to a directory " Try to write the viminfo to a directory
call mkdir('Xdir') call mkdir('Xvifdir')
call assert_fails('wviminfo Xdir', 'E137:') call assert_fails('wviminfo Xvifdir', 'E137:')
call assert_fails('rviminfo Xdir', 'E195:') call assert_fails('rviminfo Xvifdir', 'E195:')
call delete('Xdir', 'rf') call delete('Xvifdir', 'rf')
endfunc endfunc
" Test for writing to an existing viminfo file merges the file marks " Test for writing to an existing viminfo file merges the file marks

View File

@@ -251,9 +251,9 @@ func Test_write_errors()
" Try to overwrite a directory " Try to overwrite a directory
if has('unix') if has('unix')
call mkdir('Xdir1') call mkdir('Xwerdir1')
call assert_fails('write Xdir1', 'E17:') call assert_fails('write Xwerdir1', 'E17:')
call delete('Xdir1', 'd') call delete('Xwerdir1', 'd')
endif endif
" Test for :wall for a buffer with no name " Test for :wall for a buffer with no name
@@ -479,20 +479,20 @@ func Test_write_readonly_dir()
" Root can do it too. " Root can do it too.
CheckNotRoot CheckNotRoot
call mkdir('Xdir/') call mkdir('Xrodir/')
call writefile(['one'], 'Xdir/Xfile1') call writefile(['one'], 'Xrodir/Xfile1')
call setfperm('Xdir', 'r-xr--r--') call setfperm('Xrodir', 'r-xr--r--')
" try to create a new file in the directory " try to create a new file in the directory
new Xdir/Xfile2 new Xrodir/Xfile2
call setline(1, 'two') call setline(1, 'two')
call assert_fails('write', 'E212:') call assert_fails('write', 'E212:')
" try to create a backup file in the directory " try to create a backup file in the directory
edit! Xdir/Xfile1 edit! Xrodir/Xfile1
set backupdir=./Xdir backupskip= set backupdir=./Xrodir backupskip=
set patchmode=.orig set patchmode=.orig
call assert_fails('write', 'E509:') call assert_fails('write', 'E509:')
call setfperm('Xdir', 'rwxr--r--') call setfperm('Xrodir', 'rwxr--r--')
call delete('Xdir', 'rf') call delete('Xrodir', 'rf')
set backupdir& backupskip& patchmode& set backupdir& backupskip& patchmode&
endfunc endfunc

View File

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