diff options
Diffstat (limited to 'src/testdir')
28 files changed, 329 insertions, 379 deletions
diff --git a/src/testdir/Make_all.mak b/src/testdir/Make_all.mak index 9a3cafd372..217a295472 100644 --- a/src/testdir/Make_all.mak +++ b/src/testdir/Make_all.mak @@ -24,9 +24,6 @@ SCRIPTS_ALL = \ test19.out \ test20.out \ test22.out \ - test23.out \ - test24.out \ - test26.out \ test28.out \ test29.out \ test31.out \ @@ -51,12 +48,10 @@ SCRIPTS_ALL = \ test60.out \ test64.out \ test66.out \ - test67.out \ test68.out \ test69.out \ test70.out \ test73.out \ - test75.out \ test77.out \ test79.out \ test80.out \ @@ -75,11 +70,9 @@ SCRIPTS_ALL = \ test_autoformat_join.out \ test_changelist.out \ test_close_count.out \ - test_comparators.out \ test_erasebackword.out \ test_eval.out \ test_fixeol.out \ - test_getcwd.out \ test_insertcount.out \ test_listchars.out \ test_search_mbyte.out \ @@ -99,8 +92,7 @@ SCRIPTS_MORE1 = \ SCRIPTS_MORE2 = \ test12.out \ test25.out \ - test49.out \ - test97.out + test49.out # Tests that run on most systems, but not MingW and Cygwin. diff --git a/src/testdir/Make_ming.mak b/src/testdir/Make_ming.mak index dbf94f0559..31dfe702b7 100644 --- a/src/testdir/Make_ming.mak +++ b/src/testdir/Make_ming.mak @@ -69,7 +69,7 @@ fixff: -$(VIMPROG) -u dos.vim $(NO_INITS) "+argdo set ff=dos|upd" +q *.in *.ok -$(VIMPROG) -u dos.vim $(NO_INITS) "+argdo set ff=unix|upd" +q \ dotest.in test60.ok test_listchars.ok \ - test_getcwd.ok test_wordcount.ok + test_wordcount.ok clean: -@if exist *.out $(DEL) *.out diff --git a/src/testdir/Make_vms.mms b/src/testdir/Make_vms.mms index 5f124afc27..a85e98df9b 100644 --- a/src/testdir/Make_vms.mms +++ b/src/testdir/Make_vms.mms @@ -80,7 +80,6 @@ SCRIPT = test1.out test3.out test4.out test5.out \ test7.out test8.out test9.out \ test14.out test15.out \ test19.out test20.out test22.out \ - test23.out test24.out test26.out \ test28.out test29.out test30.out test31.out test32.out \ test33.out test34.out test36.out test37.out \ test38.out test39.out test40.out test41.out test42.out \ @@ -88,8 +87,8 @@ SCRIPT = test1.out test3.out test4.out test5.out \ test48.out test49.out test51.out test53.out test54.out \ test55.out test56.out test57.out test60.out \ test64.out \ - test66.out test67.out test68.out test69.out \ - test72.out test75.out \ + test66.out test68.out test69.out \ + test72.out \ test77a.out test78.out test79.out test80.out \ test84.out test88.out \ test91.out test94.out \ @@ -101,11 +100,9 @@ SCRIPT = test1.out test3.out test4.out test5.out \ test_breakindent.out \ test_changelist.out \ test_close_count.out \ - test_comparators.out \ test_erasebackword.out \ test_eval.out \ test_fixeol.out \ - test_getcwd.out \ test_insertcount.out \ test_listchars.out \ test_listlbr.out \ @@ -131,7 +128,7 @@ SCRIPT = test1.out test3.out test4.out test5.out \ # test83: ? # test85: no Lua interface # test89: bug - findfile() does not work on VMS (just in the current directory) -# test97, test102: Just ODS-5 supports space and special chars in the filename. +# test102: Just ODS-5 supports space and special chars in the filename. # On ODS-2 tests fail. .IFDEF WANT_GUI @@ -156,7 +153,7 @@ SCRIPT_MZSCH = test70.out .ENDIF .IFDEF HAVE_ODS5 -SCRIPT_ODS5 = test97.out test102.out +SCRIPT_ODS5 = test102.out .ENDIF .IFDEF HAVE_GZIP diff --git a/src/testdir/main.aap b/src/testdir/main.aap index 821aa2d94a..93159ba20d 100644 --- a/src/testdir/main.aap +++ b/src/testdir/main.aap @@ -8,7 +8,7 @@ Scripts = test1.out test2.out test3.out test4.out test5.out test6.out test7.out test8.out test9.out test11.out test12.out test13.out test14.out test15.out test17.out test18.out test19.out test20.out test21.out test22.out - test23.out test24.out test25.out test26.out test27.out + test25.out test27.out test28.out test29.out test30.out test31.out test32.out test33.out test34.out test36.out test37.out test38.out test39.out test40.out test41.out test42.out diff --git a/src/testdir/test23.in b/src/testdir/test23.in deleted file mode 100644 index 0e0e605531..0000000000 --- a/src/testdir/test23.in +++ /dev/null @@ -1,15 +0,0 @@ -Tests for complicated + argument to :edit command - -STARTTEST -:$-1w! Xfile1 -:$w! Xfile2 -:edit +1|s/|/PIPE/|w Xfile1| e Xfile2|1 | s/\//SLASH/|w -:w! test.out -:e Xfile1 -:w >> test.out -:qa! -ENDTEST - -The result should be in Xfile1: "fooPIPEbar", in Xfile2: "fooSLASHbar" -foo|bar -foo/bar diff --git a/src/testdir/test23.ok b/src/testdir/test23.ok deleted file mode 100644 index f1930abad6..0000000000 --- a/src/testdir/test23.ok +++ /dev/null @@ -1,2 +0,0 @@ -fooSLASHbar -fooPIPEbar diff --git a/src/testdir/test24.in b/src/testdir/test24.in Binary files differdeleted file mode 100644 index 7dfc1afdc6..0000000000 --- a/src/testdir/test24.in +++ /dev/null diff --git a/src/testdir/test24.ok b/src/testdir/test24.ok deleted file mode 100644 index cd61210968..0000000000 --- a/src/testdir/test24.ok +++ /dev/null @@ -1,32 +0,0 @@ -start -test text test text -test text test text -test text test text -test text test text -test text test text -test text test text -test text test text x61 -test text test text x60-x64 -test text test text x78 5 -test text test text o143 -test text test text o140-o144 -test text test text o41 7 -test text test text \%x42 -test text test text \%o103 -test text test text [\x00] -test text test text [\x00-\x10] -test text test text [\x-z] -test text test text [\u-z] -xx xx a -xx aaaaa xx a -xx aaaaa xx a -xx Aaa xx -xx Aaaa xx -xx Aaa xx -xx foobar xA xx -xx an A xx -XX 9; -YY 77; - xyz - bcd - BB diff --git a/src/testdir/test26.in b/src/testdir/test26.in deleted file mode 100644 index e7cd757661..0000000000 --- a/src/testdir/test26.in +++ /dev/null @@ -1,44 +0,0 @@ -Test for :execute, :while and :if - -STARTTEST -:so small.vim -mt:let i = 0 -:while i < 12 -: let i = i + 1 -: if has("ebcdic") -: execute "normal o" . i . "\047" -: else -: execute "normal o" . i . "\033" -: endif -: if i % 2 -: normal Ax -: if i == 9 -: break -: endif -: if i == 5 -: continue -: else -: let j = 9 -: while j > 0 -: if has("ebcdic") -: execute "normal" j . "a" . j . "\x27" -: else -: execute "normal" j . "a" . j . "\x1b" -: endif -: let j = j - 1 -: endwhile -: endif -: endif -: if i == 9 -: if has("ebcdic") -: execute "normal Az\047" -: else -: execute "normal Az\033" -: endif -: endif -:endwhile -:unlet i j -:'t,$w! test.out -:qa! -ENDTEST - diff --git a/src/testdir/test26.ok b/src/testdir/test26.ok deleted file mode 100644 index bc44761187..0000000000 --- a/src/testdir/test26.ok +++ /dev/null @@ -1,10 +0,0 @@ - -1x999999999888888887777777666666555554444333221 -2 -3x999999999888888887777777666666555554444333221 -4 -5x -6 -7x999999999888888887777777666666555554444333221 -8 -9x diff --git a/src/testdir/test67.in b/src/testdir/test67.in deleted file mode 100644 index e40cbabd6f..0000000000 --- a/src/testdir/test67.in +++ /dev/null @@ -1,33 +0,0 @@ -Test that groups and patterns are tested correctly when calling exists() for -autocommands. - -STARTTEST -:so small.vim -:let results=[] -:augroup auexists -:augroup END -:call add(results, "##BufEnter: " . exists("##BufEnter")) -:call add(results, "#BufEnter: " . exists("#BufEnter")) -:au BufEnter * let g:entered=1 -:call add(results, "#BufEnter: " . exists("#BufEnter")) -:call add(results, "#auexists#BufEnter: " . exists("#auexists#BufEnter")) -:augroup auexists -:au BufEnter * let g:entered=1 -:augroup END -:call add(results, "#auexists#BufEnter: " . exists("#auexists#BufEnter")) -:call add(results, "#BufEnter#*.test: " . exists("#BufEnter#*.test")) -:au BufEnter *.test let g:entered=1 -:call add(results, "#BufEnter#*.test: " . exists("#BufEnter#*.test")) -:edit testfile.test -:call add(results, "#BufEnter#<buffer>: " . exists("#BufEnter#<buffer>")) -:au BufEnter <buffer> let g:entered=1 -:call add(results, "#BufEnter#<buffer>: " . exists("#BufEnter#<buffer>")) -:edit testfile2.test -:call add(results, "#BufEnter#<buffer>: " . exists("#BufEnter#<buffer>")) -:e! test.out -:call append(0, results) -:$d -:w -:qa! -ENDTEST - diff --git a/src/testdir/test67.ok b/src/testdir/test67.ok deleted file mode 100644 index 51188e5afd..0000000000 --- a/src/testdir/test67.ok +++ /dev/null @@ -1,10 +0,0 @@ -##BufEnter: 1 -#BufEnter: 0 -#BufEnter: 1 -#auexists#BufEnter: 0 -#auexists#BufEnter: 1 -#BufEnter#*.test: 0 -#BufEnter#*.test: 1 -#BufEnter#<buffer>: 0 -#BufEnter#<buffer>: 1 -#BufEnter#<buffer>: 0 diff --git a/src/testdir/test75.in b/src/testdir/test75.in deleted file mode 100644 index 8fabccdf52..0000000000 --- a/src/testdir/test75.in +++ /dev/null @@ -1,41 +0,0 @@ -Tests for maparg(). -Also test utf8 map with a 0x80 byte. - -STARTTEST -:so small.vim -:so mbyte.vim -:set cpo-=< -:set encoding=utf8 -:" Test maparg() with a string result -:map foo<C-V> is<F4>foo -:vnoremap <script> <buffer> <expr> <silent> bar isbar -:call append('$', maparg('foo<C-V>')) -:call append('$', string(maparg('foo<C-V>', '', 0, 1))) -:call append('$', string(maparg('bar', '', 0, 1))) -:map <buffer> <nowait> foo bar -:call append('$', string(maparg('foo', '', 0, 1))) -:" -:map abc x<char-114>x -:call append('$', maparg('abc')) -:map abc y<S-char-114>y -:call append('$', maparg('abc')) -:" -Go:" -:" Outside of the range, minimum -:inoremap <Char-0x1040> a -:execute "normal a\u1040\<Esc>" -:" Inside of the range, minimum -:inoremap <Char-0x103f> b -:execute "normal a\u103f\<Esc>" -:" Inside of the range, maximum -:inoremap <Char-0xf03f> c -:execute "normal a\uf03f\<Esc>" -:" Outside of the range, maximum -:inoremap <Char-0xf040> d -:execute "normal a\uf040\<Esc>" -:" -:/^eof/+1,$w! test.out -:qa! -ENDTEST - -eof diff --git a/src/testdir/test75.ok b/src/testdir/test75.ok deleted file mode 100644 index a2c5c5ac3d..0000000000 --- a/src/testdir/test75.ok +++ /dev/null @@ -1,7 +0,0 @@ -is<F4>foo -{'silent': 0, 'noremap': 0, 'lhs': 'foo<C-V>', 'mode': ' ', 'nowait': 0, 'expr': 0, 'sid': 0, 'rhs': 'is<F4>foo', 'buffer': 0} -{'silent': 1, 'noremap': 1, 'lhs': 'bar', 'mode': 'v', 'nowait': 0, 'expr': 1, 'sid': 0, 'rhs': 'isbar', 'buffer': 1} -{'silent': 0, 'noremap': 0, 'lhs': 'foo', 'mode': ' ', 'nowait': 1, 'expr': 0, 'sid': 0, 'rhs': 'bar', 'buffer': 1} -xrx -yRy -abcd diff --git a/src/testdir/test97.in b/src/testdir/test97.in deleted file mode 100644 index 5a4cb1e17c..0000000000 --- a/src/testdir/test97.in +++ /dev/null @@ -1,23 +0,0 @@ -Test whether glob()/globpath() return correct results with certain escaped -characters. - -STARTTEST -:so small.vim -:" make sure glob() doesn't use the shell -:set shell=doesnotexist -:" consistent sorting of file names -:set nofileignorecase -:e! test.out -:$put =glob('Xxx\{') -:$put =glob('Xxx\$') -:w! Xxx{ -:w! Xxx\$ -:$put =glob('Xxx\{') -:$put =glob('Xxx\$') -:" -:$put =string(globpath('sautest/autoload', '*.vim')) -:$put =string(globpath('sautest/autoload', '*.vim', 0, 1)) -:w -:qa! -ENDTEST - diff --git a/src/testdir/test97.ok b/src/testdir/test97.ok deleted file mode 100644 index 32cdcbf1be..0000000000 --- a/src/testdir/test97.ok +++ /dev/null @@ -1,8 +0,0 @@ - - - -Xxx{ -Xxx$ -'sautest/autoload/Test104.vim -sautest/autoload/footest.vim' -['sautest/autoload/Test104.vim', 'sautest/autoload/footest.vim'] diff --git a/src/testdir/test_comparators.in b/src/testdir/test_comparators.in deleted file mode 100644 index 53a12a32e4..0000000000 --- a/src/testdir/test_comparators.in +++ /dev/null @@ -1,21 +0,0 @@ -" Test for expression comparators. vim: set ft=vim : - - -STARTTEST -:so small.vim -:try -: let oldisident=&isident -: set isident+=# -: if 1 is#1 -: $put ='ok' -: else -: $put ='ng' -: endif -:finally -: let &isident=oldisident -:endtry -:" -:/^marker/+1,$wq! test.out -ENDTEST - -marker diff --git a/src/testdir/test_comparators.ok b/src/testdir/test_comparators.ok deleted file mode 100644 index 9766475a41..0000000000 --- a/src/testdir/test_comparators.ok +++ /dev/null @@ -1 +0,0 @@ -ok diff --git a/src/testdir/test_comparators.vim b/src/testdir/test_comparators.vim new file mode 100644 index 0000000000..87be006cf2 --- /dev/null +++ b/src/testdir/test_comparators.vim @@ -0,0 +1,9 @@ +function Test_Comparators() + try + let oldisident=&isident + set isident+=# + call assert_equal(1, 1 is#1) + finally + let &isident=oldisident + endtry +endfunction diff --git a/src/testdir/test_escaped_glob.vim b/src/testdir/test_escaped_glob.vim new file mode 100644 index 0000000000..6eca8bc713 --- /dev/null +++ b/src/testdir/test_escaped_glob.vim @@ -0,0 +1,25 @@ +" Test whether glob()/globpath() return correct results with certain escaped +" characters. + +function SetUp() + " make sure glob() doesn't use the shell + set shell=doesnotexist + " consistent sorting of file names + set nofileignorecase +endfunction + +function Test_glob() + call assert_equal("", glob('Xxx\{')) + call assert_equal("", glob('Xxx\$')) + w! Xxx{ + w! Xxx\$ + call assert_equal("Xxx{", glob('Xxx\{')) + call assert_equal("Xxx$", glob('Xxx\$')) +endfunction + +function Test_globpath() + call assert_equal("sautest/autoload/Test104.vim\nsautest/autoload/footest.vim", + \ globpath('sautest/autoload', '*.vim')) + call assert_equal(['sautest/autoload/Test104.vim', 'sautest/autoload/footest.vim'], + \ globpath('sautest/autoload', '*.vim', 0, 1)) +endfunction diff --git a/src/testdir/test_exec_while_if.vim b/src/testdir/test_exec_while_if.vim new file mode 100644 index 0000000000..d6afabff45 --- /dev/null +++ b/src/testdir/test_exec_while_if.vim @@ -0,0 +1,53 @@ +" Test for :execute, :while and :if + +function Test_exec_while_if() + new + + let i = 0 + while i < 12 + let i = i + 1 + if has("ebcdic") + execute "normal o" . i . "\047" + else + execute "normal o" . i . "\033" + endif + if i % 2 + normal Ax + if i == 9 + break + endif + if i == 5 + continue + else + let j = 9 + while j > 0 + if has("ebcdic") + execute "normal" j . "a" . j . "\x27" + else + execute "normal" j . "a" . j . "\x1b" + endif + let j = j - 1 + endwhile + endif + endif + if i == 9 + if has("ebcdic") + execute "normal Az\047" + else + execute "normal Az\033" + endif + endif + endwhile + unlet i j + + call assert_equal(["", + \ "1x999999999888888887777777666666555554444333221", + \ "2", + \ "3x999999999888888887777777666666555554444333221", + \ "4", + \ "5x", + \ "6", + \ "7x999999999888888887777777666666555554444333221", + \ "8", + \ "9x"], getline(1, 10)) +endfunction diff --git a/src/testdir/test_exists_autocmd.vim b/src/testdir/test_exists_autocmd.vim new file mode 100644 index 0000000000..7e44a72653 --- /dev/null +++ b/src/testdir/test_exists_autocmd.vim @@ -0,0 +1,26 @@ +" Test that groups and patterns are tested correctly when calling exists() for +" autocommands. + +function Test_AutoCommands() + let results=[] + augroup auexists + augroup END + call assert_true(exists("##BufEnter")) + call assert_false(exists("#BufEnter")) + au BufEnter * let g:entered=1 + call assert_true(exists("#BufEnter")) + call assert_false(exists("#auexists#BufEnter")) + augroup auexists + au BufEnter * let g:entered=1 + augroup END + call assert_true(exists("#auexists#BufEnter")) + call assert_false(exists("#BufEnter#*.test")) + au BufEnter *.test let g:entered=1 + call assert_true(exists("#BufEnter#*.test")) + edit testfile.test + call assert_false(exists("#BufEnter#<buffer>")) + au BufEnter <buffer> let g:entered=1 + call assert_true(exists("#BufEnter#<buffer>")) + edit testfile2.test + call assert_false(exists("#BufEnter#<buffer>")) +endfunction diff --git a/src/testdir/test_getcwd.in b/src/testdir/test_getcwd.in deleted file mode 100644 index f62d21afa1..0000000000 --- a/src/testdir/test_getcwd.in +++ /dev/null @@ -1,96 +0,0 @@ -Tests for getcwd(), haslocaldir(), and :lcd vim: set ft=vim : - -STARTTEST -:so small.vim -:" Do all test in a separate window to avoid E211 when we recursively -:" delete the Xtopdir directory during cleanup -:" -:" This will cause a few errors, do it silently. -:set visualbell -:set nocp viminfo+=nviminfo -:" -:" On windows a swapfile in Xtopdir prevents it from being cleaned up. -:set noswapfile -:" -:function! GetCwdInfo(win, tab) -: let tab_changed = 0 -: let mod = ":t" -: if a:tab > 0 && a:tab != tabpagenr() -: let tab_changed = 1 -: exec "tabnext " . a:tab -: endif -: let bufname = fnamemodify(bufname(winbufnr(a:win)), mod) -: if tab_changed -: tabprevious -: endif -: if a:win == 0 && a:tab == 0 -: let dirname = fnamemodify(getcwd(), mod) -: let lflag = haslocaldir() -: elseif a:tab == 0 -: let dirname = fnamemodify(getcwd(a:win), mod) -: let lflag = haslocaldir(a:win) -: else -: let dirname = fnamemodify(getcwd(a:win, a:tab), mod) -: let lflag = haslocaldir(a:win, a:tab) -: endif -: return bufname . ' ' . dirname . ' ' . lflag -:endfunction -:" On windows a stale "Xtopdir" directory may exist, remove it so that -:" we start from a clean state. -:call delete("Xtopdir", "rf") -:let r=[] -:new -:let cwd=getcwd() -:let test_out = cwd . '/test.out' -:call mkdir('Xtopdir') -:cd Xtopdir -:call mkdir('Xdir1') -:call mkdir('Xdir2') -:call mkdir('Xdir3') -:new a -:new b -:new c -:3wincmd w -:lcd Xdir1 -:call add(r, GetCwdInfo(0, 0)) -:wincmd W -:call add(r, GetCwdInfo(0, 0)) -:wincmd W -:lcd Xdir3 -:call add(r, GetCwdInfo(0, 0)) -:call add(r, GetCwdInfo(bufwinnr("a"), 0)) -:call add(r, GetCwdInfo(bufwinnr("b"), 0)) -:call add(r, GetCwdInfo(bufwinnr("c"), 0)) -:wincmd W -:call add(r, GetCwdInfo(bufwinnr("a"), tabpagenr())) -:call add(r, GetCwdInfo(bufwinnr("b"), tabpagenr())) -:call add(r, GetCwdInfo(bufwinnr("c"), tabpagenr())) -:" -:tabnew x -:new y -:new z -:3wincmd w -:call add(r, GetCwdInfo(0, 0)) -:wincmd W -:lcd Xdir2 -:call add(r, GetCwdInfo(0, 0)) -:wincmd W -:lcd Xdir3 -:call add(r, GetCwdInfo(0, 0)) -:call add(r, GetCwdInfo(bufwinnr("x"), 0)) -:call add(r, GetCwdInfo(bufwinnr("y"), 0)) -:call add(r, GetCwdInfo(bufwinnr("z"), 0)) -:let tp_nr = tabpagenr() -:tabrewind -:call add(r, GetCwdInfo(3, tp_nr)) -:call add(r, GetCwdInfo(2, tp_nr)) -:call add(r, GetCwdInfo(1, tp_nr)) -:" -:call writefile(r, test_out, "a") -:q -:exec "cd " . cwd -:call delete("Xtopdir", "rf") -:qa! -ENDTEST - - diff --git a/src/testdir/test_getcwd.ok b/src/testdir/test_getcwd.ok deleted file mode 100644 index 23699891f3..0000000000 --- a/src/testdir/test_getcwd.ok +++ /dev/null @@ -1,18 +0,0 @@ -a Xdir1 1 -b Xtopdir 0 -c Xdir3 1 -a Xdir1 1 -b Xtopdir 0 -c Xdir3 1 -a Xdir1 1 -b Xtopdir 0 -c Xdir3 1 -x Xtopdir 0 -y Xdir2 1 -z Xdir3 1 -x Xtopdir 0 -y Xdir2 1 -z Xdir3 1 -x Xtopdir 0 -y Xdir2 1 -z Xdir3 1 diff --git a/src/testdir/test_getcwd.vim b/src/testdir/test_getcwd.vim new file mode 100644 index 0000000000..15eab2abbb --- /dev/null +++ b/src/testdir/test_getcwd.vim @@ -0,0 +1,91 @@ +function! GetCwdInfo(win, tab) + let tab_changed = 0 + let mod = ":t" + if a:tab > 0 && a:tab != tabpagenr() + let tab_changed = 1 + exec "tabnext " . a:tab + endif + let bufname = fnamemodify(bufname(winbufnr(a:win)), mod) + if tab_changed + tabprevious + endif + if a:win == 0 && a:tab == 0 + let dirname = fnamemodify(getcwd(), mod) + let lflag = haslocaldir() + elseif a:tab == 0 + let dirname = fnamemodify(getcwd(a:win), mod) + let lflag = haslocaldir(a:win) + else + let dirname = fnamemodify(getcwd(a:win, a:tab), mod) + let lflag = haslocaldir(a:win, a:tab) + endif + return bufname . ' ' . dirname . ' ' . lflag +endfunction + +" Do all test in a separate window to avoid E211 when we recursively +" delete the Xtopdir directory during cleanup +function SetUp() + set visualbell + set nocp viminfo+=nviminfo + + " On windows a swapfile in Xtopdir prevents it from being cleaned up. + set noswapfile + + " On windows a stale "Xtopdir" directory may exist, remove it so that + " we start from a clean state. + call delete("Xtopdir", "rf") + new + call mkdir('Xtopdir') + cd Xtopdir + call mkdir('Xdir1') + call mkdir('Xdir2') + call mkdir('Xdir3') +endfunction + +let g:cwd=getcwd() +function TearDown() + q + exec "cd " . g:cwd + call delete("Xtopdir", "rf") +endfunction + +function Test_GetCwd() + new a + new b + new c + 3wincmd w + lcd Xdir1 + call assert_equal("a Xdir1 1", GetCwdInfo(0, 0)) + wincmd W + call assert_equal("b Xtopdir 0", GetCwdInfo(0, 0)) + wincmd W + lcd Xdir3 + call assert_equal("c Xdir3 1", GetCwdInfo(0, 0)) + call assert_equal("a Xdir1 1", GetCwdInfo(bufwinnr("a"), 0)) + call assert_equal("b Xtopdir 0", GetCwdInfo(bufwinnr("b"), 0)) + call assert_equal("c Xdir3 1", GetCwdInfo(bufwinnr("c"), 0)) + wincmd W + call assert_equal("a Xdir1 1", GetCwdInfo(bufwinnr("a"), tabpagenr())) + call assert_equal("b Xtopdir 0", GetCwdInfo(bufwinnr("b"), tabpagenr())) + call assert_equal("c Xdir3 1", GetCwdInfo(bufwinnr("c"), tabpagenr())) + + tabnew x + new y + new z + 3wincmd w + call assert_equal("x Xtopdir 0", GetCwdInfo(0, 0)) + wincmd W + lcd Xdir2 + call assert_equal("y Xdir2 1", GetCwdInfo(0, 0)) + wincmd W + lcd Xdir3 + call assert_equal("z Xdir3 1", GetCwdInfo(0, 0)) + call assert_equal("x Xtopdir 0", GetCwdInfo(bufwinnr("x"), 0)) + call assert_equal("y Xdir2 1", GetCwdInfo(bufwinnr("y"), 0)) + call assert_equal("z Xdir3 1", GetCwdInfo(bufwinnr("z"), 0)) + let tp_nr = tabpagenr() + tabrewind + call assert_equal("x Xtopdir 0", GetCwdInfo(3, tp_nr)) + call assert_equal("y Xdir2 1", GetCwdInfo(2, tp_nr)) + call assert_equal("z Xdir3 1", GetCwdInfo(1, tp_nr)) +endfunc diff --git a/src/testdir/test_maparg.vim b/src/testdir/test_maparg.vim new file mode 100644 index 0000000000..9ad83836c6 --- /dev/null +++ b/src/testdir/test_maparg.vim @@ -0,0 +1,52 @@ +" Tests for maparg(). +" Also test utf8 map with a 0x80 byte. +if !has("multi_byte") + finish +endif + +function s:SID() + return str2nr(matchstr(expand('<sfile>'), '<SNR>\zs\d\+\ze_SID$')) +endfun + +function Test_maparg() + new + set cpo-=< + set encoding=utf8 + " Test maparg() with a string result + map foo<C-V> is<F4>foo + vnoremap <script> <buffer> <expr> <silent> bar isbar + let sid = s:SID() + call assert_equal("is<F4>foo", maparg('foo<C-V>')) + call assert_equal({'silent': 0, 'noremap': 0, 'lhs': 'foo<C-V>', + \ 'mode': ' ', 'nowait': 0, 'expr': 0, 'sid': sid, 'rhs': 'is<F4>foo', + \ 'buffer': 0}, maparg('foo<C-V>', '', 0, 1)) + call assert_equal({'silent': 1, 'noremap': 1, 'lhs': 'bar', 'mode': 'v', + \ 'nowait': 0, 'expr': 1, 'sid': sid, 'rhs': 'isbar', 'buffer': 1}, + \ maparg('bar', '', 0, 1)) + map <buffer> <nowait> foo bar + call assert_equal({'silent': 0, 'noremap': 0, 'lhs': 'foo', 'mode': ' ', + \ 'nowait': 1, 'expr': 0, 'sid': sid, 'rhs': 'bar', 'buffer': 1}, + \ maparg('foo', '', 0, 1)) + + map abc x<char-114>x + call assert_equal(maparg('abc'), "xrx") + map abc y<S-char-114>y + call assert_equal(maparg('abc'), "yRy") +endfunction + +function Test_range_map() + new + " Outside of the range, minimum + inoremap <Char-0x1040> a + execute "normal a\u1040\<Esc>" + " Inside of the range, minimum + inoremap <Char-0x103f> b + execute "normal a\u103f\<Esc>" + " Inside of the range, maximum + inoremap <Char-0xf03f> c + execute "normal a\uf03f\<Esc>" + " Outside of the range, maximum + inoremap <Char-0xf040> d + execute "normal a\uf040\<Esc>" + call assert_equal("abcd", getline(1)) +endfunction diff --git a/src/testdir/test_plus_arg_edit.vim b/src/testdir/test_plus_arg_edit.vim new file mode 100644 index 0000000000..0907550bfa --- /dev/null +++ b/src/testdir/test_plus_arg_edit.vim @@ -0,0 +1,8 @@ +" Tests for complicated + argument to :edit command +function Test_edit() + call writefile(["foo|bar"], "Xfile1") + call writefile(["foo/bar"], "Xfile2") + edit +1|s/|/PIPE/|w Xfile1| e Xfile2|1 | s/\//SLASH/|w + call assert_equal(["fooPIPEbar"], readfile("Xfile1")) + call assert_equal(["fooSLASHbar"], readfile("Xfile2")) +endfunction diff --git a/src/testdir/test_regex_char_classes.vim b/src/testdir/test_regex_char_classes.vim new file mode 100644 index 0000000000..2192b5e8fc --- /dev/null +++ b/src/testdir/test_regex_char_classes.vim @@ -0,0 +1,58 @@ +" Tests for regexp with backslash and other special characters inside [] +" Also test backslash for hex/octal numbered character. + +function RunSTest(value, calls, expected) + new + call feedkeys("i" . a:value, "mx") + exec a:calls + call assert_equal(a:expected, getline(1), printf("wrong result for %s", a:calls)) + quit! +endfunction + +function RunXTest(value, search_exp, expected) + new + call feedkeys("i" . a:value, "mx") + call feedkeys("gg" . a:search_exp . "\nx", "mx") + call assert_equal(a:expected, getline(1), printf("wrong result for %s", a:search_exp)) + quit! +endfunction + + +function Test_x_search() + let res = "test text test text" + call RunXTest("test \\text test text", "/[\\x]", res) + call RunXTest("test \ttext test text", "/[\\t\\]]", res) + call RunXTest("test text ]test text", "/[]y]", res) + call RunXTest("test ]text test text", "/[\\]]", res) + call RunXTest("test text te^st text", "/[y^]", res) + call RunXTest("test te$xt test text", "/[$y]", res) + call RunXTest("test taext test text", "/[\\x61]", res) + call RunXTest("test tbext test text","/[\\x60-\\x64]", res) + call RunXTest("test 5text test text","/[\\x785]", res) + call RunXTest("testc text test text","/[\\o143]", res) + call RunXTest("tesdt text test text","/[\\o140-\\o144]", res) + call RunXTest("test7 text test text", "/[\\o417]", res) + call RunXTest("test text tBest text", "/\\%x42", res) + call RunXTest("test text teCst text" |