comparison src/testdir/test_python3.vim @ 19991:f27473034f26 v8.2.0551

patch 8.2.0551: not all code for options is tested Commit: https://github.com/vim/vim/commit/1363a30cef382b912bf092969e040333c5c293c6 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Apr 12 13:50:26 2020 +0200 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 https://github.com/vim/vim/issues/5913)
author Bram Moolenaar <Bram@vim.org>
date Sun, 12 Apr 2020 14:00:04 +0200
parents f22626353eb3
children 04ef2ccf2519
comparison
equal deleted inserted replaced
19990:696d046d651b 19991:f27473034f26
257 py3 r.append('b', 1) 257 py3 r.append('b', 1)
258 call assert_equal(['1', '2', 'b', '3', '4', 'a', '5'], getline(1, '$')) 258 call assert_equal(['1', '2', 'b', '3', '4', 'a', '5'], getline(1, '$'))
259 259
260 bwipe! 260 bwipe!
261 endfunc 261 endfunc
262
263 " Test for resetting options with local values to global values
264 func Test_python3_opt_reset_local_to_global()
265 new
266
267 py3 curbuf = vim.current.buffer
268 py3 curwin = vim.current.window
269
270 " List of buffer-local options. Each list item has [option name, global
271 " value, buffer-local value, buffer-local value after reset] to use in the
272 " test.
273 let bopts = [
274 \ ['autoread', 1, 0, -1],
275 \ ['equalprg', 'geprg', 'leprg', ''],
276 \ ['keywordprg', 'gkprg', 'lkprg', ''],
277 \ ['path', 'gpath', 'lpath', ''],
278 \ ['backupcopy', 'yes', 'no', ''],
279 \ ['tags', 'gtags', 'ltags', ''],
280 \ ['tagcase', 'ignore', 'match', ''],
281 \ ['define', 'gdef', 'ldef', ''],
282 \ ['include', 'ginc', 'linc', ''],
283 \ ['dict', 'gdict', 'ldict', ''],
284 \ ['thesaurus', 'gtsr', 'ltsr', ''],
285 \ ['formatprg', 'gfprg', 'lfprg', ''],
286 \ ['errorformat', '%f:%l:%m', '%s-%l-%m', ''],
287 \ ['grepprg', 'ggprg', 'lgprg', ''],
288 \ ['makeprg', 'gmprg', 'lmprg', ''],
289 \ ['balloonexpr', 'gbexpr', 'lbexpr', ''],
290 \ ['cryptmethod', 'blowfish2', 'zip', ''],
291 \ ['lispwords', 'abc', 'xyz', ''],
292 \ ['makeencoding', 'utf-8', 'latin1', ''],
293 \ ['undolevels', 100, 200, -123456]]
294
295 " Set the global and buffer-local option values and then clear the
296 " buffer-local option value.
297 for opt in bopts
298 py3 pyopt = vim.bindeval("opt")
299 py3 vim.options[pyopt[0]] = pyopt[1]
300 py3 curbuf.options[pyopt[0]] = pyopt[2]
301 exe "call assert_equal(opt[2], &" .. opt[0] .. ")"
302 exe "call assert_equal(opt[1], &g:" .. opt[0] .. ")"
303 exe "call assert_equal(opt[2], &l:" .. opt[0] .. ")"
304 py3 del curbuf.options[pyopt[0]]
305 exe "call assert_equal(opt[1], &" .. opt[0] .. ")"
306 exe "call assert_equal(opt[1], &g:" .. opt[0] .. ")"
307 exe "call assert_equal(opt[3], &l:" .. opt[0] .. ")"
308 exe "set " .. opt[0] .. "&"
309 endfor
310
311 " Set the global and window-local option values and then clear the
312 " window-local option value.
313 let wopts = [
314 \ ['scrolloff', 5, 10, -1],
315 \ ['sidescrolloff', 6, 12, -1],
316 \ ['statusline', '%<%f', '%<%F', '']]
317 for opt in wopts
318 py3 pyopt = vim.bindeval("opt")
319 py3 vim.options[pyopt[0]] = pyopt[1]
320 py3 curwin.options[pyopt[0]] = pyopt[2]
321 exe "call assert_equal(opt[2], &" .. opt[0] .. ")"
322 exe "call assert_equal(opt[1], &g:" .. opt[0] .. ")"
323 exe "call assert_equal(opt[2], &l:" .. opt[0] .. ")"
324 py3 del curwin.options[pyopt[0]]
325 exe "call assert_equal(opt[1], &" .. opt[0] .. ")"
326 exe "call assert_equal(opt[1], &g:" .. opt[0] .. ")"
327 exe "call assert_equal(opt[3], &l:" .. opt[0] .. ")"
328 exe "set " .. opt[0] .. "&"
329 endfor
330
331 close!
332 endfunc
333
334 " vim: shiftwidth=2 sts=2 expandtab