mirror of
https://github.com/vim/vim.git
synced 2025-10-02 05:04:20 -04:00
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 #5913)
This commit is contained in:
@@ -259,3 +259,76 @@ func Test_python3_range()
|
||||
|
||||
bwipe!
|
||||
endfunc
|
||||
|
||||
" Test for resetting options with local values to global values
|
||||
func Test_python3_opt_reset_local_to_global()
|
||||
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
|
||||
|
Reference in New Issue
Block a user