test(old): add more missing test files and run more tests alone

Copy four files from Vim v8.2.1432.
Try to match Vim's test_alot.vim.
This marks Vim patch 8.2.0164 as ported:

vim-patch:8.2.0164: test_alot takes too long

Problem:    Test_alot takes too long.
Solution:   Run several tests individually.
842931cd7a
This commit is contained in:
zeertzjq
2022-03-03 11:57:25 +08:00
parent 5d6006f9bf
commit 78bb8c4ee7
10 changed files with 212 additions and 182 deletions

View File

@@ -3,56 +3,33 @@
source test_backup.vim
source test_behave.vim
source test_cd.vim
source test_changedtick.vim
source test_compiler.vim
source test_cursor_func.vim
source test_cursorline.vim
source test_ex_equal.vim
source test_ex_undo.vim
source test_ex_z.vim
source test_ex_mode.vim
source test_execute_func.vim
source test_expand.vim
source test_expand_func.vim
source test_feedkeys.vim
source test_filter_cmd.vim
source test_filter_map.vim
source test_findfile.vim
source test_float_func.vim
source test_functions.vim
source test_file_perm.vim
source test_fnamemodify.vim
source test_ga.vim
source test_glob2regpat.vim
source test_global.vim
source test_goto.vim
source test_join.vim
source test_jumps.vim
source test_fileformat.vim
source test_filetype.vim
source test_filetype_lua.vim
source test_lambda.vim
source test_lispwords.vim
source test_menu.vim
source test_messages.vim
source test_modeline.vim
source test_move.vim
source test_partial.vim
source test_popup.vim
source test_put.vim
source test_rename.vim
source test_reltime.vim
source test_scroll_opt.vim
source test_searchpos.vim
source test_set.vim
source test_shift.vim
" Test fails on windows CI when using the MSVC compiler.
" source test_sort.vim
source test_sha256.vim
source test_suspend.vim
source test_syn_attr.vim
source test_tabline.vim
source test_tabpage.vim
source test_tagcase.vim
source test_tagfunc.vim
source test_tagjump.vim
source test_taglist.vim
source test_true_false.vim
source test_unlet.vim
source test_version.vim
source test_virtualedit.vim
source test_window_cmd.vim
source test_wnext.vim

View File

@@ -0,0 +1,114 @@
" Test for delete().
func Test_file_delete()
split Xfile
call setline(1, ['a', 'b'])
wq
call assert_equal(['a', 'b'], readfile('Xfile'))
call assert_equal(0, delete('Xfile'))
call assert_fails('call readfile("Xfile")', 'E484:')
call assert_equal(-1, delete('Xfile'))
bwipe Xfile
endfunc
func Test_dir_delete()
call mkdir('Xdir1')
call assert_true(isdirectory('Xdir1'))
call assert_equal(0, delete('Xdir1', 'd'))
call assert_false(isdirectory('Xdir1'))
call assert_equal(-1, delete('Xdir1', 'd'))
endfunc
func Test_recursive_delete()
call mkdir('Xdir1')
call mkdir('Xdir1/subdir')
call mkdir('Xdir1/empty')
split Xdir1/Xfile
call setline(1, ['a', 'b'])
w
w Xdir1/subdir/Xfile
close
call assert_true(isdirectory('Xdir1'))
call assert_equal(['a', 'b'], readfile('Xdir1/Xfile'))
call assert_true(isdirectory('Xdir1/subdir'))
call assert_equal(['a', 'b'], readfile('Xdir1/subdir/Xfile'))
call assert_true('Xdir1/empty'->isdirectory())
call assert_equal(0, delete('Xdir1', 'rf'))
call assert_false(isdirectory('Xdir1'))
call assert_equal(-1, delete('Xdir1', 'd'))
bwipe Xdir1/Xfile
bwipe Xdir1/subdir/Xfile
endfunc
func Test_symlink_delete()
if !has('unix')
return
endif
split Xfile
call setline(1, ['a', 'b'])
wq
silent !ln -s Xfile Xlink
" Delete the link, not the file
call assert_equal(0, delete('Xlink'))
call assert_equal(-1, delete('Xlink'))
call assert_equal(0, delete('Xfile'))
bwipe Xfile
endfunc
func Test_symlink_dir_delete()
if !has('unix')
return
endif
call mkdir('Xdir1')
silent !ln -s Xdir1 Xlink
call assert_true(isdirectory('Xdir1'))
call assert_true(isdirectory('Xlink'))
" Delete the link, not the directory
call assert_equal(0, delete('Xlink'))
call assert_equal(-1, delete('Xlink'))
call assert_equal(0, delete('Xdir1', 'd'))
endfunc
func Test_symlink_recursive_delete()
if !has('unix')
return
endif
call mkdir('Xdir3')
call mkdir('Xdir3/subdir')
call mkdir('Xdir4')
split Xdir3/Xfile
call setline(1, ['a', 'b'])
w
w Xdir3/subdir/Xfile
w Xdir4/Xfile
close
silent !ln -s ../Xdir4 Xdir3/Xlink
call assert_true(isdirectory('Xdir3'))
call assert_equal(['a', 'b'], readfile('Xdir3/Xfile'))
call assert_true(isdirectory('Xdir3/subdir'))
call assert_equal(['a', 'b'], readfile('Xdir3/subdir/Xfile'))
call assert_true(isdirectory('Xdir4'))
call assert_true(isdirectory('Xdir3/Xlink'))
call assert_equal(['a', 'b'], readfile('Xdir4/Xfile'))
call assert_equal(0, delete('Xdir3', 'rf'))
call assert_false(isdirectory('Xdir3'))
call assert_equal(-1, delete('Xdir3', 'd'))
" symlink is deleted, not the directory it points to
call assert_true(isdirectory('Xdir4'))
call assert_equal(['a', 'b'], readfile('Xdir4/Xfile'))
call assert_equal(0, delete('Xdir4/Xfile'))
call assert_equal(0, delete('Xdir4', 'd'))
bwipe Xdir3/Xfile
bwipe Xdir3/subdir/Xfile
bwipe Xdir4/Xfile
endfunc
func Test_delete_errors()
call assert_fails('call delete('''')', 'E474:')
call assert_fails('call delete(''foo'', 0)', 'E15:')
endfunc
" vim: shiftwidth=2 sts=2 expandtab

View File

@@ -0,0 +1,30 @@
" Test getting and setting file permissions.
func Test_file_perm()
call assert_equal('', getfperm('Xtest'))
call assert_equal(0, 'Xtest'->setfperm('r--------'))
call writefile(['one'], 'Xtest')
call assert_true(len('Xtest'->getfperm()) == 9)
call assert_equal(1, setfperm('Xtest', 'rwx------'))
if has('win32')
call assert_equal('rw-rw-rw-', getfperm('Xtest'))
else
call assert_equal('rwx------', getfperm('Xtest'))
endif
call assert_equal(1, setfperm('Xtest', 'r--r--r--'))
call assert_equal('r--r--r--', getfperm('Xtest'))
call assert_fails("setfperm('Xtest', '---')")
call assert_equal(1, setfperm('Xtest', 'rwx------'))
call delete('Xtest')
call assert_fails("call setfperm(['Xfile'], 'rw-rw-rw-')", 'E730:')
call assert_fails("call setfperm('Xfile', [])", 'E730:')
call assert_fails("call setfperm('Xfile', 'rwxrwxrwxrw')", 'E475:')
endfunc
" vim: shiftwidth=2 sts=2 expandtab

View File

@@ -0,0 +1,30 @@
" Tests for searchpos()
func Test_searchpos()
new one
0put ='1a3'
1put ='123xyz'
call cursor(1, 1)
call assert_equal([1, 1, 2], searchpos('\%(\([a-z]\)\|\_.\)\{-}xyz', 'pcW'))
call cursor(1, 2)
call assert_equal([2, 1, 1], '\%(\([a-z]\)\|\_.\)\{-}xyz'->searchpos('pcW'))
set cpo-=c
call cursor(1, 2)
call assert_equal([1, 2, 2], searchpos('\%(\([a-z]\)\|\_.\)\{-}xyz', 'pcW'))
call cursor(1, 3)
call assert_equal([1, 3, 1], searchpos('\%(\([a-z]\)\|\_.\)\{-}xyz', 'pcW'))
" Now with \zs, first match is in column 0, "a" is matched.
call cursor(1, 3)
call assert_equal([2, 4, 2], searchpos('\%(\([a-z]\)\|\_.\)\{-}\zsxyz', 'pcW'))
" With z flag start at cursor column, don't see the "a".
call cursor(1, 3)
call assert_equal([2, 4, 1], searchpos('\%(\([a-z]\)\|\_.\)\{-}\zsxyz', 'pcWz'))
set cpo+=c
" close the window
q!
endfunc
" vim: shiftwidth=2 sts=2 expandtab

View File

@@ -0,0 +1,29 @@
" Tests for the :set command
function Test_set_backslash()
let isk_save = &isk
set isk=a,b,c
set isk+=d
call assert_equal('a,b,c,d', &isk)
set isk+=\\,e
call assert_equal('a,b,c,d,\,e', &isk)
set isk-=e
call assert_equal('a,b,c,d,\', &isk)
set isk-=\\
call assert_equal('a,b,c,d', &isk)
let &isk = isk_save
endfunction
function Test_set_add()
let wig_save = &wig
set wildignore=*.png,
set wildignore+=*.jpg
call assert_equal('*.png,*.jpg', &wig)
let &wig = wig_save
endfunction
" vim: shiftwidth=2 sts=2 expandtab

View File

@@ -12,6 +12,7 @@ func Compare2(a, b) abort
endfunc
func Test_sort_strings()
CheckNotMSWindows " FIXME: Why does this fail with MSVC?
" numbers compared as strings
call assert_equal([1, 2, 3], sort([3, 2, 1]))
call assert_equal([13, 28, 3], sort([3, 28, 13]))