diff --git a/src/nvim/testdir/Makefile b/src/nvim/testdir/Makefile index 31082f3a37ed26..d1511bbd1f4a6c 100644 --- a/src/nvim/testdir/Makefile +++ b/src/nvim/testdir/Makefile @@ -15,7 +15,6 @@ export TMPDIR := $(abspath ../../../Xtest-tmpdir) SCRIPTS_DEFAULT = \ test14.out \ - test24.out \ test37.out \ test42.out \ test48.out \ @@ -45,12 +44,16 @@ NEW_TESTS ?= \ test_close_count.res \ test_cmdline.res \ test_command_count.res \ + test_comparators.res \ test_cscope.res \ test_curswant.res \ test_digraph.res \ test_edit.res \ test_erasebackword.res \ + test_escaped_glob.res \ + test_exec_while_if.res \ test_exists.res \ + test_exists_autocmd.res \ test_diffmode.res \ test_farsi.res \ test_file_size.res \ @@ -61,6 +64,7 @@ NEW_TESTS ?= \ test_fnameescape.res \ test_fold.res \ test_ga.res \ + test_getcwd.res \ test_getvar.res \ test_glob2regpat.res \ test_gf.res \ @@ -81,6 +85,7 @@ NEW_TESTS ?= \ test_listdict.res \ test_listchars.res \ test_makeencoding.res \ + test_maparg.res \ test_marks.res \ test_match.res \ test_matchadd_conceal.res \ @@ -89,6 +94,7 @@ NEW_TESTS ?= \ test_normal.res \ test_number.res \ test_options.res \ + test_plus_arg_edit.res \ test_preview.res \ test_profile.res \ test_put.res \ @@ -97,6 +103,7 @@ NEW_TESTS ?= \ test_quickfix.res \ test_quotestar.res \ test_recover.res \ + test_regex_char_classes.res \ test_registers.res \ test_retab.res \ test_scrollbind.res \ diff --git a/src/nvim/testdir/test24.in b/src/nvim/testdir/test24.in deleted file mode 100644 index 292f4030483199..00000000000000 Binary files a/src/nvim/testdir/test24.in and /dev/null differ diff --git a/src/nvim/testdir/test24.ok b/src/nvim/testdir/test24.ok deleted file mode 100644 index cd61210968658b..00000000000000 --- a/src/nvim/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/nvim/testdir/test_comparators.vim b/src/nvim/testdir/test_comparators.vim new file mode 100644 index 00000000000000..87be006cf2ff0e --- /dev/null +++ b/src/nvim/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/nvim/testdir/test_escaped_glob.vim b/src/nvim/testdir/test_escaped_glob.vim new file mode 100644 index 00000000000000..9b34e775637969 --- /dev/null +++ b/src/nvim/testdir/test_escaped_glob.vim @@ -0,0 +1,26 @@ +" 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() + let slash = (!exists('+shellslash') || &shellslash) ? '/' : '\' + call assert_equal('sautest'.slash.'autoload'.slash.'footest.vim', + \ globpath('sautest/autoload', '*.vim')) + call assert_equal(['sautest'.slash.'autoload'.slash.'footest.vim'], + \ globpath('sautest/autoload', '*.vim', 0, 1)) +endfunction diff --git a/src/nvim/testdir/test_exec_while_if.vim b/src/nvim/testdir/test_exec_while_if.vim new file mode 100644 index 00000000000000..d6afabff451fe4 --- /dev/null +++ b/src/nvim/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/nvim/testdir/test_exists_autocmd.vim b/src/nvim/testdir/test_exists_autocmd.vim new file mode 100644 index 00000000000000..7e44a726534c16 --- /dev/null +++ b/src/nvim/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#")) + au BufEnter let g:entered=1 + call assert_true(exists("#BufEnter#")) + edit testfile2.test + call assert_false(exists("#BufEnter#")) +endfunction diff --git a/src/nvim/testdir/test_getcwd.vim b/src/nvim/testdir/test_getcwd.vim new file mode 100644 index 00000000000000..15eab2abbb487b --- /dev/null +++ b/src/nvim/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/nvim/testdir/test_maparg.vim b/src/nvim/testdir/test_maparg.vim new file mode 100644 index 00000000000000..9ad83836c656f6 --- /dev/null +++ b/src/nvim/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(''), '\zs\d\+\ze_SID$')) +endfun + +function Test_maparg() + new + set cpo-=< + set encoding=utf8 + " Test maparg() with a string result + map foo isfoo + vnoremap