diff options
author | zeertzjq <zeertzjq@outlook.com> | 2022-12-03 21:44:13 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-03 21:44:13 +0800 |
commit | e642825e281b7a9f259b8bc0b83b94a78b18a2c4 (patch) | |
tree | 846f82101d13a45c8c5faf26971472ea880af4ea /src/nvim/testdir | |
parent | c768b578faba671beab435954dc4e5a321c94728 (diff) | |
parent | 0cb90114d4c4801457e286c9b72ad0f394877d05 (diff) | |
download | rneovim-e642825e281b7a9f259b8bc0b83b94a78b18a2c4.tar.gz rneovim-e642825e281b7a9f259b8bc0b83b94a78b18a2c4.tar.bz2 rneovim-e642825e281b7a9f259b8bc0b83b94a78b18a2c4.zip |
Merge pull request #21274 from zeertzjq/vim-8.2.3992
vim-patch:8.2.{3992,4261,4262},9.0.{0110,0577}
Diffstat (limited to 'src/nvim/testdir')
-rw-r--r-- | src/nvim/testdir/runtest.vim | 2 | ||||
-rw-r--r-- | src/nvim/testdir/test_functions.vim | 5 | ||||
-rw-r--r-- | src/nvim/testdir/test_help.vim | 73 | ||||
-rw-r--r-- | src/nvim/testdir/test_help_tagjump.vim | 12 | ||||
-rw-r--r-- | src/nvim/testdir/test_ins_complete.vim | 6 | ||||
-rw-r--r-- | src/nvim/testdir/test_normal.vim | 2 | ||||
-rw-r--r-- | src/nvim/testdir/test_tagfunc.vim | 2 | ||||
-rw-r--r-- | src/nvim/testdir/test_trycatch.vim | 22 | ||||
-rw-r--r-- | src/nvim/testdir/vim9.vim | 32 |
9 files changed, 130 insertions, 26 deletions
diff --git a/src/nvim/testdir/runtest.vim b/src/nvim/testdir/runtest.vim index 15f66fc1ad..3c5699af73 100644 --- a/src/nvim/testdir/runtest.vim +++ b/src/nvim/testdir/runtest.vim @@ -105,7 +105,7 @@ set nomore lang mess C " Nvim: append runtime from build dir, which contains the generated doc/tags. -let &runtimepath .= ','.expand($BUILD_DIR).'/runtime/' +let &runtimepath ..= ',' .. expand($BUILD_DIR) .. '/runtime/' let s:t_bold = &t_md let s:t_normal = &t_me diff --git a/src/nvim/testdir/test_functions.vim b/src/nvim/testdir/test_functions.vim index 1308beeae5..f3594d3cdc 100644 --- a/src/nvim/testdir/test_functions.vim +++ b/src/nvim/testdir/test_functions.vim @@ -2,6 +2,9 @@ source shared.vim source check.vim +source term_util.vim +source screendump.vim +source vim9.vim " Must be done first, since the alternate buffer must be unset. func Test_00_bufexists() @@ -2518,7 +2521,7 @@ func Test_builtin_check() vim9script var s:trim = (x) => " " .. x END - " call CheckScriptFailure(lines, 'E704:') + call CheckScriptFailure(lines, 'E704:') call assert_fails('call extend(g:, #{foo: { -> "foo" }})', 'E704:') let g:bar = 123 diff --git a/src/nvim/testdir/test_help.vim b/src/nvim/testdir/test_help.vim index e30d305703..08dd3dcb9a 100644 --- a/src/nvim/testdir/test_help.vim +++ b/src/nvim/testdir/test_help.vim @@ -1,6 +1,22 @@ " Tests for :help source check.vim +source vim9.vim + +func SetUp() + let s:vimruntime = $VIMRUNTIME + let s:runtimepath = &runtimepath + " Set $VIMRUNTIME to $BUILD_DIR/runtime and remove the original $VIMRUNTIME + " path from &runtimepath so that ":h local-additions" won't pick up builtin + " help files. + let $VIMRUNTIME = expand($BUILD_DIR) .. '/runtime' + set runtimepath-=../../../runtime +endfunc + +func TearDown() + let $VIMRUNTIME = s:vimruntime + let &runtimepath = s:runtimepath +endfunc func Test_help_restore_snapshot() help @@ -81,16 +97,42 @@ func Test_help_local_additions() call writefile(['*mydoc-ext.txt* my extended awesome doc'], 'Xruntime/doc/mydoc-ext.txt') let rtp_save = &rtp set rtp+=./Xruntime - help - 1 - call search('mydoc.txt') - call assert_equal('|mydoc.txt| my awesome doc', getline('.')) - 1 - call search('mydoc-ext.txt') - call assert_equal('|mydoc-ext.txt| my extended awesome doc', getline('.')) + help local-additions + let lines = getline(line(".") + 1, search("^$") - 1) + call assert_equal([ + \ '|mydoc-ext.txt| my extended awesome doc', + \ '|mydoc.txt| my awesome doc' + \ ], lines) + call delete('Xruntime/doc/mydoc-ext.txt') + close + + call mkdir('Xruntime-ja/doc', 'p') + call writefile(["local-additions\thelp.jax\t/*local-additions*"], 'Xruntime-ja/doc/tags-ja') + call writefile(['*help.txt* This is jax file', '', + \ 'LOCAL ADDITIONS: *local-additions*', ''], 'Xruntime-ja/doc/help.jax') + call writefile(['*work.txt* This is jax file'], 'Xruntime-ja/doc/work.jax') + call writefile(['*work2.txt* This is jax file'], 'Xruntime-ja/doc/work2.jax') + set rtp+=./Xruntime-ja + + help local-additions@en + let lines = getline(line(".") + 1, search("^$") - 1) + call assert_equal([ + \ '|mydoc.txt| my awesome doc' + \ ], lines) + close + + help local-additions@ja + let lines = getline(line(".") + 1, search("^$") - 1) + call assert_equal([ + \ '|mydoc.txt| my awesome doc', + \ '|help.txt| This is jax file', + \ '|work.txt| This is jax file', + \ '|work2.txt| This is jax file', + \ ], lines) close call delete('Xruntime', 'rf') + call delete('Xruntime-ja', 'rf') let &rtp = rtp_save endfunc @@ -114,6 +156,13 @@ func Test_helptag_cmd() call assert_equal(["help-tags\ttags\t1"], readfile('Xdir/tags')) call delete('Xdir/tags') + " Test parsing tags + call writefile(['*tag1*', 'Example: >', ' *notag*', 'Example end: *tag2*'], + \ 'Xdir/a/doc/sample.txt') + helptags Xdir + call assert_equal(["tag1\ta/doc/sample.txt\t/*tag1*", + \ "tag2\ta/doc/sample.txt\t/*tag2*"], readfile('Xdir/tags')) + " Duplicate tags in the help file call writefile(['*tag1*', '*tag1*', '*tag2*'], 'Xdir/a/doc/sample.txt') call assert_fails('helptags Xdir', 'E154:') @@ -166,5 +215,15 @@ func Test_help_long_argument() endtry endfunc +func Test_help_using_visual_match() + let lines =<< trim END + call setline(1, ' ') + /^ + exe "normal \<C-V>\<C-V>" + h5\%V] + END + call CheckScriptFailure(lines, 'E149:') +endfunc + " vim: shiftwidth=2 sts=2 expandtab diff --git a/src/nvim/testdir/test_help_tagjump.vim b/src/nvim/testdir/test_help_tagjump.vim index f81e4fb1ef..eae1a241e3 100644 --- a/src/nvim/testdir/test_help_tagjump.vim +++ b/src/nvim/testdir/test_help_tagjump.vim @@ -1,17 +1,5 @@ " Tests for :help! {subject} -func SetUp() - " v:progpath is …/build/bin/nvim and we need …/build/runtime - " to be added to &rtp - let builddir = fnamemodify(exepath(v:progpath), ':h:h') - let s:rtp = &rtp - let &rtp .= printf(',%s/runtime', builddir) -endfunc - -func TearDown() - let &rtp = s:rtp -endfunc - func Test_help_tagjump() help call assert_equal("help", &filetype) diff --git a/src/nvim/testdir/test_ins_complete.vim b/src/nvim/testdir/test_ins_complete.vim index 1811c82767..c1c78e9a8f 100644 --- a/src/nvim/testdir/test_ins_complete.vim +++ b/src/nvim/testdir/test_ins_complete.vim @@ -1535,7 +1535,7 @@ func Test_completefunc_callback() assert_equal([[1, ''], [0, 'three']], g:LocalCompleteFuncArgs) bw! END - " call CheckScriptSuccess(lines) + call CheckScriptSuccess(lines) " cleanup set completefunc& @@ -1792,7 +1792,7 @@ func Test_omnifunc_callback() assert_equal([[1, ''], [0, 'three']], g:LocalOmniFuncArgs) bw! END - " call CheckScriptSuccess(lines) + call CheckScriptSuccess(lines) " cleanup set omnifunc& @@ -2085,7 +2085,7 @@ func Test_thesaurusfunc_callback() assert_equal([[1, ''], [0, 'three']], g:LocalTsrFuncArgs) bw! END - " call CheckScriptSuccess(lines) + call CheckScriptSuccess(lines) " cleanup set thesaurusfunc& diff --git a/src/nvim/testdir/test_normal.vim b/src/nvim/testdir/test_normal.vim index 7e8b8c5eef..c2ad49f0c9 100644 --- a/src/nvim/testdir/test_normal.vim +++ b/src/nvim/testdir/test_normal.vim @@ -695,7 +695,7 @@ func Test_opfunc_callback() assert_equal(['char'], g:LocalOpFuncArgs) bw! END - " call CheckScriptSuccess(lines) + call CheckScriptSuccess(lines) " setting 'opfunc' to a script local function outside of a script context " should fail diff --git a/src/nvim/testdir/test_tagfunc.vim b/src/nvim/testdir/test_tagfunc.vim index 93b9c67b25..cba96d3504 100644 --- a/src/nvim/testdir/test_tagfunc.vim +++ b/src/nvim/testdir/test_tagfunc.vim @@ -380,7 +380,7 @@ func Test_tagfunc_callback() assert_equal(['a12', '', {}], g:LocalTagFuncArgs) bw! END - " call CheckScriptSuccess(lines) + call CheckScriptSuccess(lines) " cleanup delfunc TagFunc1 diff --git a/src/nvim/testdir/test_trycatch.vim b/src/nvim/testdir/test_trycatch.vim index 8a1d2d3fa7..ef20e03126 100644 --- a/src/nvim/testdir/test_trycatch.vim +++ b/src/nvim/testdir/test_trycatch.vim @@ -3,6 +3,7 @@ source check.vim source shared.vim +source vim9.vim "------------------------------------------------------------------------------- " Test environment {{{1 @@ -2007,6 +2008,27 @@ func Test_try_catch_errors() call assert_fails('try | for i in range(5) | endif | endtry', 'E580:') call assert_fails('try | while v:true | endtry', 'E170:') call assert_fails('try | if v:true | endtry', 'E171:') + + " this was using a negative index in cstack[] + let lines =<< trim END + try + for + if + endwhile + if + finally + END + call CheckScriptFailure(lines, 'E690:') + + let lines =<< trim END + try + for + if + endwhile + if + endtry + END + call CheckScriptFailure(lines, 'E690:') endfunc " Test for verbose messages with :try :catch, and :finally {{{1 diff --git a/src/nvim/testdir/vim9.vim b/src/nvim/testdir/vim9.vim index db74ce3b11..3c0ff2b2dd 100644 --- a/src/nvim/testdir/vim9.vim +++ b/src/nvim/testdir/vim9.vim @@ -2,6 +2,38 @@ " Use a different file name for each run. let s:sequence = 1 +func CheckScriptFailure(lines, error, lnum = -3) + if get(a:lines, 0, '') ==# 'vim9script' + return + endif + let cwd = getcwd() + let fname = 'XScriptFailure' .. s:sequence + let s:sequence += 1 + call writefile(a:lines, fname) + try + call assert_fails('so ' .. fname, a:error, a:lines, a:lnum) + finally + call chdir(cwd) + call delete(fname) + endtry +endfunc + +func CheckScriptSuccess(lines) + if get(a:lines, 0, '') ==# 'vim9script' + return + endif + let cwd = getcwd() + let fname = 'XScriptSuccess' .. s:sequence + let s:sequence += 1 + call writefile(a:lines, fname) + try + exe 'so ' .. fname + finally + call chdir(cwd) + call delete(fname) + endtry +endfunc + " Check that "lines" inside a legacy function has no error. func CheckLegacySuccess(lines) let cwd = getcwd() |