aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2023-04-29 07:51:58 +0800
committerzeertzjq <zeertzjq@outlook.com>2023-04-29 09:07:10 +0800
commit291fd767e3979b25146c32115eacc3c2f8e1e517 (patch)
tree516a0b4f5b703be4866bbd09306423ba30e9d343
parent129012172258a08efa87cbab927cdd3e4da7db90 (diff)
downloadrneovim-291fd767e3979b25146c32115eacc3c2f8e1e517.tar.gz
rneovim-291fd767e3979b25146c32115eacc3c2f8e1e517.tar.bz2
rneovim-291fd767e3979b25146c32115eacc3c2f8e1e517.zip
vim-patch:8.2.0551: not all code for options is tested
Problem: Not all code for options is tested. Solution: Add more tests. (Yegappan Lakshmanan, closes vim/vim#5913) https://github.com/vim/vim/commit/1363a30cef382b912bf092969e040333c5c293c6
-rw-r--r--test/old/testdir/test_options.vim56
-rw-r--r--test/old/testdir/test_python2.vim2
-rw-r--r--test/old/testdir/test_python3.vim78
-rw-r--r--test/old/testdir/test_undo.vim5
-rw-r--r--test/old/testdir/test_vimscript.vim5
5 files changed, 142 insertions, 4 deletions
diff --git a/test/old/testdir/test_options.vim b/test/old/testdir/test_options.vim
index be794cb845..f101f550d1 100644
--- a/test/old/testdir/test_options.vim
+++ b/test/old/testdir/test_options.vim
@@ -321,9 +321,54 @@ func Test_set_completion()
call feedkeys(":set tags=./\\\\ dif\<C-A>\<C-B>\"\<CR>", 'tx')
call assert_equal('"set tags=./\\ diff diffexpr diffopt', @:)
-
set tags&
+ " Expanding the option names
+ call feedkeys(":set \<Tab>\<C-B>\"\<CR>", 'xt')
+ call assert_equal('"set all', @:)
+
+ " Expanding a second set of option names
+ call feedkeys(":set wrapscan \<Tab>\<C-B>\"\<CR>", 'xt')
+ call assert_equal('"set wrapscan all', @:)
+
+ " Expanding a special keycode
+ " call feedkeys(":set <Home>\<Tab>\<C-B>\"\<CR>", 'xt')
+ " call assert_equal('"set <Home>', @:)
+
+ " Expanding an invalid special keycode
+ call feedkeys(":set <abcd>\<Tab>\<C-B>\"\<CR>", 'xt')
+ call assert_equal("\"set <abcd>\<Tab>", @:)
+
+ " Expanding a terminal keycode
+ " call feedkeys(":set t_AB\<Tab>\<C-B>\"\<CR>", 'xt')
+ " call assert_equal("\"set t_AB", @:)
+
+ " Expanding an invalid option name
+ call feedkeys(":set abcde=\<Tab>\<C-B>\"\<CR>", 'xt')
+ call assert_equal("\"set abcde=\<Tab>", @:)
+
+ " Expanding after a = for a boolean option
+ call feedkeys(":set wrapscan=\<Tab>\<C-B>\"\<CR>", 'xt')
+ call assert_equal("\"set wrapscan=\<Tab>", @:)
+
+ " Expanding a numeric option
+ call feedkeys(":set tabstop+=\<Tab>\<C-B>\"\<CR>", 'xt')
+ call assert_equal("\"set tabstop+=" .. &tabstop, @:)
+
+ " Expanding a non-boolean option
+ call feedkeys(":set invtabstop=\<Tab>\<C-B>\"\<CR>", 'xt')
+ call assert_equal("\"set invtabstop=", @:)
+
+ " Expand options for 'spellsuggest'
+ call feedkeys(":set spellsuggest=best,file:xyz\<Tab>\<C-B>\"\<CR>", 'xt')
+ call assert_equal("\"set spellsuggest=best,file:xyz", @:)
+
+ " Expand value for 'key'
+ " set key=abcd
+ " call feedkeys(":set key=\<Tab>\<C-B>\"\<CR>", 'xt')
+ " call assert_equal('"set key=*****', @:)
+ " set key=
+
" Expand values for 'filetype'
call feedkeys(":set filetype=sshdconfi\<Tab>\<C-B>\"\<CR>", 'xt')
call assert_equal('"set filetype=sshdconfig', @:)
@@ -411,7 +456,14 @@ func Test_set_errors()
set backupext& patchmode&
call assert_fails('set winminheight=10 winheight=9', 'E591:')
+ set winminheight& winheight&
+ set winheight=10 winminheight=10
+ call assert_fails('set winheight=9', 'E591:')
+ set winminheight& winheight&
call assert_fails('set winminwidth=10 winwidth=9', 'E592:')
+ set winminwidth& winwidth&
+ call assert_fails('set winwidth=9 winminwidth=10', 'E592:')
+ set winwidth& winminwidth&
call assert_fails("set showbreak=\x01", 'E595:')
call assert_fails('set t_foo=', 'E846:')
call assert_fails('set tabstop??', 'E488:')
@@ -944,7 +996,9 @@ endfunc
func Test_opt_sandbox()
for opt in ['backupdir', 'cdpath', 'exrc']
call assert_fails('sandbox set ' .. opt .. '?', 'E48:')
+ call assert_fails('sandbox let &' .. opt .. ' = 1', 'E48:')
endfor
+ call assert_fails('sandbox let &modelineexpr = 1', 'E48:')
endfunc
" Test for setting an option with local value to global value
diff --git a/test/old/testdir/test_python2.vim b/test/old/testdir/test_python2.vim
index 745b7da086..ab03408fc4 100644
--- a/test/old/testdir/test_python2.vim
+++ b/test/old/testdir/test_python2.vim
@@ -40,7 +40,7 @@ func Test_set_cursor()
endfunc
func Test_vim_function()
- throw 'skipped: Nvim does not support vim.bindeval()'
+ throw 'Skipped: Nvim does not support vim.bindeval()'
" Check creating vim.Function object
py import vim
diff --git a/test/old/testdir/test_python3.vim b/test/old/testdir/test_python3.vim
index 69f5f6dcc0..6c9676603f 100644
--- a/test/old/testdir/test_python3.vim
+++ b/test/old/testdir/test_python3.vim
@@ -40,7 +40,7 @@ func Test_set_cursor()
endfunc
func Test_vim_function()
- throw 'skipped: Nvim does not support vim.bindeval()'
+ throw 'Skipped: Nvim does not support vim.bindeval()'
" Check creating vim.Function object
py3 import vim
@@ -68,7 +68,7 @@ func Test_vim_function()
endfunc
func Test_skipped_python3_command_does_not_affect_pyxversion()
- throw 'skipped: Nvim hardcodes pyxversion=3'
+ throw 'Skipped: Nvim hardcodes pyxversion=3'
set pyxversion=0
if 0
python3 import vim
@@ -190,3 +190,77 @@ func Test_unicode()
set encoding=utf8
endfunc
+
+" Test for resetting options with local values to global values
+func Test_python3_opt_reset_local_to_global()
+ throw 'Skipped: Nvim does not support vim.bindeval()'
+ new
+
+ py3 curbuf = vim.current.buffer
+ py3 curwin = vim.current.window
+
+ " List of buffer-local options. Each list item has [option name, global
+ " value, buffer-local value, buffer-local value after reset] to use in the
+ " test.
+ let bopts = [
+ \ ['autoread', 1, 0, -1],
+ \ ['equalprg', 'geprg', 'leprg', ''],
+ \ ['keywordprg', 'gkprg', 'lkprg', ''],
+ \ ['path', 'gpath', 'lpath', ''],
+ \ ['backupcopy', 'yes', 'no', ''],
+ \ ['tags', 'gtags', 'ltags', ''],
+ \ ['tagcase', 'ignore', 'match', ''],
+ \ ['define', 'gdef', 'ldef', ''],
+ \ ['include', 'ginc', 'linc', ''],
+ \ ['dict', 'gdict', 'ldict', ''],
+ \ ['thesaurus', 'gtsr', 'ltsr', ''],
+ \ ['formatprg', 'gfprg', 'lfprg', ''],
+ \ ['errorformat', '%f:%l:%m', '%s-%l-%m', ''],
+ \ ['grepprg', 'ggprg', 'lgprg', ''],
+ \ ['makeprg', 'gmprg', 'lmprg', ''],
+ \ ['balloonexpr', 'gbexpr', 'lbexpr', ''],
+ \ ['cryptmethod', 'blowfish2', 'zip', ''],
+ \ ['lispwords', 'abc', 'xyz', ''],
+ \ ['makeencoding', 'utf-8', 'latin1', ''],
+ \ ['undolevels', 100, 200, -123456]]
+
+ " Set the global and buffer-local option values and then clear the
+ " buffer-local option value.
+ for opt in bopts
+ py3 pyopt = vim.bindeval("opt")
+ py3 vim.options[pyopt[0]] = pyopt[1]
+ py3 curbuf.options[pyopt[0]] = pyopt[2]
+ exe "call assert_equal(opt[2], &" .. opt[0] .. ")"
+ exe "call assert_equal(opt[1], &g:" .. opt[0] .. ")"
+ exe "call assert_equal(opt[2], &l:" .. opt[0] .. ")"
+ py3 del curbuf.options[pyopt[0]]
+ exe "call assert_equal(opt[1], &" .. opt[0] .. ")"
+ exe "call assert_equal(opt[1], &g:" .. opt[0] .. ")"
+ exe "call assert_equal(opt[3], &l:" .. opt[0] .. ")"
+ exe "set " .. opt[0] .. "&"
+ endfor
+
+ " Set the global and window-local option values and then clear the
+ " window-local option value.
+ let wopts = [
+ \ ['scrolloff', 5, 10, -1],
+ \ ['sidescrolloff', 6, 12, -1],
+ \ ['statusline', '%<%f', '%<%F', '']]
+ for opt in wopts
+ py3 pyopt = vim.bindeval("opt")
+ py3 vim.options[pyopt[0]] = pyopt[1]
+ py3 curwin.options[pyopt[0]] = pyopt[2]
+ exe "call assert_equal(opt[2], &" .. opt[0] .. ")"
+ exe "call assert_equal(opt[1], &g:" .. opt[0] .. ")"
+ exe "call assert_equal(opt[2], &l:" .. opt[0] .. ")"
+ py3 del curwin.options[pyopt[0]]
+ exe "call assert_equal(opt[1], &" .. opt[0] .. ")"
+ exe "call assert_equal(opt[1], &g:" .. opt[0] .. ")"
+ exe "call assert_equal(opt[3], &l:" .. opt[0] .. ")"
+ exe "set " .. opt[0] .. "&"
+ endfor
+
+ close!
+endfunc
+
+" vim: shiftwidth=2 sts=2 expandtab
diff --git a/test/old/testdir/test_undo.vim b/test/old/testdir/test_undo.vim
index ee8b52caaf..4678a51d60 100644
--- a/test/old/testdir/test_undo.vim
+++ b/test/old/testdir/test_undo.vim
@@ -126,6 +126,11 @@ func Test_global_local_undolevels()
call assert_equal(50, &g:undolevels)
call assert_equal(-123456, &l:undolevels)
+ " Resetting the local 'undolevels' value to use the global value
+ setlocal undolevels=5
+ setlocal undolevels<
+ call assert_equal(-123456, &l:undolevels)
+
" Drop created windows
set ul&
new
diff --git a/test/old/testdir/test_vimscript.vim b/test/old/testdir/test_vimscript.vim
index 055a2bd2f2..68ce493927 100644
--- a/test/old/testdir/test_vimscript.vim
+++ b/test/old/testdir/test_vimscript.vim
@@ -6705,6 +6705,11 @@ func Test_echo_and_string()
let l = split(result, "\n")
call assert_equal(["{'a': [], 'b': []}",
\ "{'a': [], 'b': []}"], l)
+
+ call assert_fails('echo &:', 'E112:')
+ call assert_fails('echo &g:', 'E112:')
+ call assert_fails('echo &l:', 'E112:')
+
endfunc
"-------------------------------------------------------------------------------