aboutsummaryrefslogtreecommitdiff
path: root/test/old/testdir/test_python3.vim
diff options
context:
space:
mode:
Diffstat (limited to 'test/old/testdir/test_python3.vim')
-rw-r--r--test/old/testdir/test_python3.vim102
1 files changed, 100 insertions, 2 deletions
diff --git a/test/old/testdir/test_python3.vim b/test/old/testdir/test_python3.vim
index 69f5f6dcc0..23c63f22d8 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,101 @@ 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 << trim END
+ pyopt = vim.bindeval("opt")
+ vim.options[pyopt[0]] = pyopt[1]
+ curbuf.options[pyopt[0]] = pyopt[2]
+ END
+ 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 << trim
+ pyopt = vim.bindeval("opt")
+ vim.options[pyopt[0]] = pyopt[1]
+ 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
+
+" Test for various heredoc syntax
+func Test_python3_heredoc()
+ python3 << END
+s='A'
+END
+ python3 <<
+s+='B'
+.
+ python3 << trim END
+ s+='C'
+ END
+ python3 << trim
+ s+='D'
+ .
+ python3 << trim eof
+ s+='E'
+ eof
+ call assert_equal('ABCDE', pyxeval('s'))
+endfunc
+
+" vim: shiftwidth=2 sts=2 expandtab