mirror of
https://github.com/neovim/neovim.git
synced 2025-10-02 07:58:35 +00:00
vim-patch:8.0.1253: still too many old style tests
Problem: Still too many old style tests.
Solution: Convert a few more tests to new style. (Yegappan Lakshmanan,
closes vim/vim#2272)
430dc5d360
Skip Test_tag_file_encoding.
083_tag_search_with_file_encoding_spec.lua handles the same test case.
This commit is contained in:
@@ -17,7 +17,6 @@ SCRIPTS_DEFAULT = \
|
||||
test14.out \
|
||||
test24.out \
|
||||
test37.out \
|
||||
test40.out \
|
||||
test42.out \
|
||||
test48.out \
|
||||
test52.out \
|
||||
@@ -102,6 +101,7 @@ NEW_TESTS ?= \
|
||||
test_stat.res \
|
||||
test_startup.res \
|
||||
test_substitute.res \
|
||||
test_swap.res \
|
||||
test_syntax.res \
|
||||
test_system.res \
|
||||
test_tab.res \
|
||||
|
@@ -1,63 +0,0 @@
|
||||
Test for "*Cmd" autocommands
|
||||
|
||||
STARTTEST
|
||||
:set wildchar=^E
|
||||
:/^start/,$w! Xxx " write lines below to Xxx
|
||||
:au BufReadCmd XtestA 0r Xxx|$del
|
||||
:e XtestA " will read text of Xxd instead
|
||||
:au BufWriteCmd XtestA call append(line("$"), "write")
|
||||
:w " will append a line to the file
|
||||
:r XtestA " should not read anything
|
||||
: " now we have:
|
||||
: " 1 start of Xxx
|
||||
: " 2 test40
|
||||
: " 3 end of Xxx
|
||||
: " 4 write
|
||||
:au FileReadCmd XtestB '[r Xxx
|
||||
:2r XtestB " will read Xxx below line 2 instead
|
||||
: " 1 start of Xxx
|
||||
: " 2 test40
|
||||
: " 3 start of Xxx
|
||||
: " 4 test40
|
||||
: " 5 end of Xxx
|
||||
: " 6 end of Xxx
|
||||
: " 7 write
|
||||
:au FileWriteCmd XtestC '[,']copy $
|
||||
4GA1
|
||||
:4,5w XtestC " will copy lines 4 and 5 to the end
|
||||
:r XtestC " should not read anything
|
||||
: " 1 start of Xxx
|
||||
: " 2 test40
|
||||
: " 3 start of Xxx
|
||||
: " 4 test401
|
||||
: " 5 end of Xxx
|
||||
: " 6 end of Xxx
|
||||
: " 7 write
|
||||
: " 8 test401
|
||||
: " 9 end of Xxx
|
||||
:au FILEAppendCmd XtestD '[,']w! test.out
|
||||
:w >>XtestD " will write all lines to test.out
|
||||
:$r XtestD " should not read anything
|
||||
:$w >>test.out " append "end of Xxx" to test.out
|
||||
:au BufReadCmd XtestE 0r test.out|$del
|
||||
:sp XtestE " split window with test.out
|
||||
5Goasdf:"
|
||||
:au BufWriteCmd XtestE w! test.out
|
||||
:wall " will write other window to test.out
|
||||
: " 1 start of Xxx
|
||||
: " 2 test40
|
||||
: " 3 start of Xxx
|
||||
: " 4 test401
|
||||
: " 5 end of Xxx
|
||||
: " 6 asdf
|
||||
: " 7 end of Xxx
|
||||
: " 8 write
|
||||
: " 9 test401
|
||||
: " 10 end of Xxx
|
||||
: " 11 end of Xxx
|
||||
:qa!
|
||||
ENDTEST
|
||||
|
||||
start of Xxx
|
||||
test40
|
||||
end of Xxx
|
@@ -1,11 +0,0 @@
|
||||
start of Xxx
|
||||
test40
|
||||
start of Xxx
|
||||
test401
|
||||
end of Xxx
|
||||
asdf
|
||||
end of Xxx
|
||||
write
|
||||
test401
|
||||
end of Xxx
|
||||
end of Xxx
|
@@ -1,6 +1,5 @@
|
||||
" Tests for autocommands
|
||||
|
||||
|
||||
func! s:cleanup_buffers() abort
|
||||
for bnr in range(1, bufnr('$'))
|
||||
if bufloaded(bnr) && bufnr('%') != bnr
|
||||
|
@@ -467,3 +467,170 @@ func Test_fold_error()
|
||||
set foldmethod&
|
||||
bw!
|
||||
endfunc
|
||||
|
||||
" Various fold related tests
|
||||
|
||||
" Basic test if a fold can be created, opened, moving to the end and closed
|
||||
func Test_fold_manual()
|
||||
enew!
|
||||
set fdm=manual
|
||||
|
||||
let content = ['1 aa', '2 bb', '3 cc']
|
||||
call append(0, content)
|
||||
call cursor(1, 1)
|
||||
normal zf2j
|
||||
call assert_equal('1 aa', getline(foldclosed('.')))
|
||||
normal zo
|
||||
call assert_equal(-1, foldclosed('.'))
|
||||
normal ]z
|
||||
call assert_equal('3 cc', getline('.'))
|
||||
normal zc
|
||||
call assert_equal('1 aa', getline(foldclosed('.')))
|
||||
|
||||
set fdm&
|
||||
enew!
|
||||
endfunc
|
||||
|
||||
" test folding with markers.
|
||||
func Test_fold_marker()
|
||||
enew!
|
||||
set fdm=marker fdl=1 fdc=3
|
||||
|
||||
let content = ['4 dd {{{', '5 ee {{{ }}}', '6 ff }}}']
|
||||
call append(0, content)
|
||||
call cursor(2, 1)
|
||||
call assert_equal(2, foldlevel('.'))
|
||||
normal [z
|
||||
call assert_equal(1, foldlevel('.'))
|
||||
exe "normal jo{{ \<Esc>r{jj"
|
||||
call assert_equal(1, foldlevel('.'))
|
||||
normal kYpj
|
||||
call assert_equal(0, foldlevel('.'))
|
||||
|
||||
set fdm& fdl& fdc&
|
||||
enew!
|
||||
endfunc
|
||||
|
||||
" test folding with indent
|
||||
func Test_fold_indent()
|
||||
enew!
|
||||
set fdm=indent sw=2
|
||||
|
||||
let content = ['1 aa', '2 bb', '3 cc']
|
||||
call append(0, content)
|
||||
call cursor(2, 1)
|
||||
exe "normal i \<Esc>jI "
|
||||
call assert_equal(2, foldlevel('.'))
|
||||
normal k
|
||||
call assert_equal(1, foldlevel('.'))
|
||||
|
||||
set fdm& sw&
|
||||
enew!
|
||||
endfunc
|
||||
|
||||
" test syntax folding
|
||||
func Test_fold_syntax()
|
||||
if !has('syntax')
|
||||
return
|
||||
endif
|
||||
|
||||
enew!
|
||||
set fdm=syntax fdl=0
|
||||
|
||||
syn region Hup start="dd" end="ii" fold contains=Fd1,Fd2,Fd3
|
||||
syn region Fd1 start="ee" end="ff" fold contained
|
||||
syn region Fd2 start="gg" end="hh" fold contained
|
||||
syn region Fd3 start="commentstart" end="commentend" fold contained
|
||||
let content = ['3 cc', '4 dd {{{', '5 ee {{{ }}}', '{{{{', '6 ff }}}',
|
||||
\ '6 ff }}}', '7 gg', '8 hh', '9 ii']
|
||||
call append(0, content)
|
||||
normal Gzk
|
||||
call assert_equal('9 ii', getline('.'))
|
||||
normal k
|
||||
call assert_equal('3 cc', getline('.'))
|
||||
exe "normal jAcommentstart \<Esc>Acommentend"
|
||||
set fdl=1
|
||||
normal 3j
|
||||
call assert_equal('7 gg', getline('.'))
|
||||
set fdl=0
|
||||
exe "normal zO\<C-L>j"
|
||||
call assert_equal('8 hh', getline('.'))
|
||||
syn clear Fd1 Fd2 Fd3 Hup
|
||||
|
||||
set fdm& fdl&
|
||||
enew!
|
||||
endfunc
|
||||
|
||||
func Flvl()
|
||||
let l = getline(v:lnum)
|
||||
if l =~ "bb$"
|
||||
return 2
|
||||
elseif l =~ "gg$"
|
||||
return "s1"
|
||||
elseif l =~ "ii$"
|
||||
return ">2"
|
||||
elseif l =~ "kk$"
|
||||
return "0"
|
||||
endif
|
||||
return "="
|
||||
endfun
|
||||
|
||||
" test expression folding
|
||||
func Test_fold_expr()
|
||||
enew!
|
||||
set fdm=expr fde=Flvl()
|
||||
|
||||
let content = ['1 aa',
|
||||
\ '2 bb',
|
||||
\ '3 cc',
|
||||
\ '4 dd {{{commentstart commentend',
|
||||
\ '5 ee {{{ }}}',
|
||||
\ '{{{',
|
||||
\ '6 ff }}}',
|
||||
\ '6 ff }}}',
|
||||
\ ' 7 gg',
|
||||
\ ' 8 hh',
|
||||
\ '9 ii',
|
||||
\ 'a jj',
|
||||
\ 'b kk']
|
||||
call append(0, content)
|
||||
call cursor(1, 1)
|
||||
exe "normal /bb$\<CR>"
|
||||
call assert_equal(2, foldlevel('.'))
|
||||
exe "normal /hh$\<CR>"
|
||||
call assert_equal(1, foldlevel('.'))
|
||||
exe "normal /ii$\<CR>"
|
||||
call assert_equal(2, foldlevel('.'))
|
||||
exe "normal /kk$\<CR>"
|
||||
call assert_equal(0, foldlevel('.'))
|
||||
|
||||
set fdm& fde&
|
||||
enew!
|
||||
endfunc
|
||||
|
||||
" Bug with fdm=indent and moving folds
|
||||
" Moving a fold a few times, messes up the folds below the moved fold.
|
||||
" Fixed by 7.4.700
|
||||
func Test_fold_move()
|
||||
enew!
|
||||
set fdm=indent sw=2 fdl=0
|
||||
|
||||
let content = ['', '', 'Line1', ' Line2', ' Line3',
|
||||
\ 'Line4', ' Line5', ' Line6',
|
||||
\ 'Line7', ' Line8', ' Line9']
|
||||
call append(0, content)
|
||||
normal zM
|
||||
call cursor(4, 1)
|
||||
move 2
|
||||
move 1
|
||||
call assert_equal(7, foldclosed(7))
|
||||
call assert_equal(8, foldclosedend(7))
|
||||
call assert_equal(0, foldlevel(9))
|
||||
call assert_equal(10, foldclosed(10))
|
||||
call assert_equal(11, foldclosedend(10))
|
||||
call assert_equal('+-- 2 lines: Line2', foldtextresult(2))
|
||||
call assert_equal('+-- 2 lines: Line8', foldtextresult(10))
|
||||
|
||||
set fdm& sw& fdl&
|
||||
enew!
|
||||
endfunc
|
||||
|
48
src/nvim/testdir/test_swap.vim
Normal file
48
src/nvim/testdir/test_swap.vim
Normal file
@@ -0,0 +1,48 @@
|
||||
" Tests for the swap feature
|
||||
|
||||
" Tests for 'directory' option.
|
||||
func Test_swap_directory()
|
||||
if !has("unix")
|
||||
return
|
||||
endif
|
||||
let content = ['start of testfile',
|
||||
\ 'line 2 Abcdefghij',
|
||||
\ 'line 3 Abcdefghij',
|
||||
\ 'end of testfile']
|
||||
call writefile(content, 'Xtest1')
|
||||
|
||||
" '.', swap file in the same directory as file
|
||||
set dir=.,~
|
||||
|
||||
" Verify that the swap file doesn't exist in the current directory
|
||||
call assert_equal([], glob(".Xtest1*.swp", 1, 1, 1))
|
||||
edit Xtest1
|
||||
let swfname = split(execute("swapname"))[0]
|
||||
call assert_equal([swfname], glob(swfname, 1, 1, 1))
|
||||
|
||||
" './dir', swap file in a directory relative to the file
|
||||
set dir=./Xtest2,.,~
|
||||
|
||||
call mkdir("Xtest2")
|
||||
edit Xtest1
|
||||
call assert_equal([], glob(swfname, 1, 1, 1))
|
||||
let swfname = "Xtest2/Xtest1.swp"
|
||||
call assert_equal(swfname, split(execute("swapname"))[0])
|
||||
call assert_equal([swfname], glob("Xtest2/*", 1, 1, 1))
|
||||
|
||||
" 'dir', swap file in directory relative to the current dir
|
||||
set dir=Xtest.je,~
|
||||
|
||||
call mkdir("Xtest.je")
|
||||
call writefile(content, 'Xtest2/Xtest3')
|
||||
edit Xtest2/Xtest3
|
||||
call assert_equal(["Xtest2/Xtest3"], glob("Xtest2/*", 1, 1, 1))
|
||||
let swfname = "Xtest.je/Xtest3.swp"
|
||||
call assert_equal(swfname, split(execute("swapname"))[0])
|
||||
call assert_equal([swfname], glob("Xtest.je/*", 1, 1, 1))
|
||||
|
||||
set dir&
|
||||
call delete("Xtest1")
|
||||
call delete("Xtest2", "rf")
|
||||
call delete("Xtest.je", "rf")
|
||||
endfunc
|
@@ -174,4 +174,60 @@ func Test_tag_symbolic()
|
||||
%bwipe!
|
||||
endfunc
|
||||
|
||||
" Tests for tag search with !_TAG_FILE_ENCODING.
|
||||
" Depends on the test83-tags2 and test83-tags3 files.
|
||||
func Test_tag_file_encoding()
|
||||
throw 'skipped: Nvim removed test83-tags2, test83-tags3'
|
||||
if has('vms')
|
||||
return
|
||||
endif
|
||||
|
||||
if !has('iconv') || iconv("\x82\x60", "cp932", "utf-8") != "\uff21"
|
||||
return
|
||||
endif
|
||||
|
||||
let save_enc = &encoding
|
||||
set encoding=utf8
|
||||
|
||||
let content = ['text for tags1', 'abcdefghijklmnopqrs']
|
||||
call writefile(content, 'Xtags1.txt')
|
||||
let content = ['text for tags2', 'ABC']
|
||||
call writefile(content, 'Xtags2.txt')
|
||||
let content = ['text for tags3', 'ABC']
|
||||
call writefile(content, 'Xtags3.txt')
|
||||
let content = ['!_TAG_FILE_ENCODING utf-8 //', 'abcdefghijklmnopqrs Xtags1.txt /abcdefghijklmnopqrs']
|
||||
call writefile(content, 'Xtags1')
|
||||
|
||||
" case1:
|
||||
new
|
||||
set tags=Xtags1
|
||||
tag abcdefghijklmnopqrs
|
||||
call assert_equal('Xtags1.txt', expand('%:t'))
|
||||
call assert_equal('abcdefghijklmnopqrs', getline('.'))
|
||||
close
|
||||
|
||||
" case2:
|
||||
new
|
||||
set tags=test83-tags2
|
||||
tag /.BC
|
||||
call assert_equal('Xtags2.txt', expand('%:t'))
|
||||
call assert_equal('ABC', getline('.'))
|
||||
close
|
||||
|
||||
" case3:
|
||||
new
|
||||
set tags=test83-tags3
|
||||
tag abc50
|
||||
call assert_equal('Xtags3.txt', expand('%:t'))
|
||||
call assert_equal('ABC', getline('.'))
|
||||
close
|
||||
|
||||
set tags&
|
||||
let &encoding = save_enc
|
||||
call delete('Xtags1.txt')
|
||||
call delete('Xtags2.txt')
|
||||
call delete('Xtags3.txt')
|
||||
call delete('Xtags1')
|
||||
endfunc
|
||||
|
||||
" vim: shiftwidth=2 sts=2 expandtab
|
||||
|
Reference in New Issue
Block a user