functests: Refactor tests:

- Remove unused variables.
- Do not use helpers.nvim_feed in most cases.
- Do not use helpers.nvim and helpers.nvim_eval at all.
- Add helpers.funcs and helpers.\*meths special tables. Indexing such table 
  creates functions which call helpers.call or helpers.nvim (and similar) with 
  first argument equal to table index.
This commit is contained in:
ZyX
2015-09-27 02:49:48 +03:00
parent 9d72f8ebaa
commit 1162962d8b
12 changed files with 345 additions and 349 deletions

View File

@@ -1,40 +1,36 @@
local helpers = require('test.functional.helpers')
local clear, nvim, call, eq =
helpers.clear, helpers.nvim, helpers.call, helpers.eq
local clear, meths, funcs, eq =
helpers.clear, helpers.meths, helpers.funcs, helpers.eq
describe('history support code', function()
before_each(clear)
local histadd = function(...) return call('histadd', ...) end
local histget = function(...) return call('histget', ...) end
local histdel = function(...) return call('histdel', ...) end
it('correctly clears start of the history', function()
-- Regression test: check absense of the memory leak when clearing start of
-- the history using ex_getln.c/clr_history().
eq(1, histadd(':', 'foo'))
eq(1, histdel(':'))
eq('', histget(':', -1))
eq(1, funcs.histadd(':', 'foo'))
eq(1, funcs.histdel(':'))
eq('', funcs.histget(':', -1))
end)
it('correctly clears end of the history', function()
-- Regression test: check absense of the memory leak when clearing end of
-- the history using ex_getln.c/clr_history().
nvim('set_option', 'history', 1)
eq(1, histadd(':', 'foo'))
eq(1, histdel(':'))
eq('', histget(':', -1))
meths.set_option('history', 1)
eq(1, funcs.histadd(':', 'foo'))
eq(1, funcs.histdel(':'))
eq('', funcs.histget(':', -1))
end)
it('correctly removes item from history', function()
-- Regression test: check that ex_getln.c/del_history_idx() correctly clears
-- history index after removing history entry. If it does not then deleting
-- history will result in a double free.
eq(1, histadd(':', 'foo'))
eq(1, histadd(':', 'bar'))
eq(1, histadd(':', 'baz'))
eq(1, histdel(':', -2))
eq(1, histdel(':'))
eq('', histget(':', -1))
eq(1, funcs.histadd(':', 'foo'))
eq(1, funcs.histadd(':', 'bar'))
eq(1, funcs.histadd(':', 'baz'))
eq(1, funcs.histdel(':', -2))
eq(1, funcs.histdel(':'))
eq('', funcs.histget(':', -1))
end)
end)

View File

@@ -359,6 +359,38 @@ local exc_exec = function(cmd)
return ret
end
local function redir_exec(cmd)
nvim_command(([[
redir => g:__output
silent! execute "%s"
redir END
]]):format(cmd:gsub('\n', '\\n'):gsub('[\\"]', '\\%0')))
local ret = nvim_eval('get(g:, "__output", 0)')
nvim_command('unlet! g:__output')
return ret
end
local function create_callindex(func)
local tbl = {}
setmetatable(tbl, {
__index = function(tbl, arg1)
ret = function(...) return func(arg1, ...) end
tbl[arg1] = ret
return ret
end,
})
return tbl
end
local funcs = create_callindex(nvim_call)
local meths = create_callindex(nvim)
local bufmeths = create_callindex(buffer)
local winmeths = create_callindex(window)
local tabmeths = create_callindex(tabpage)
local curbufmeths = create_callindex(curbuf)
local curwinmeths = create_callindex(curwin)
local curtabmeths = create_callindex(curtab)
return {
prepend_argv = prepend_argv,
clear = clear,
@@ -397,5 +429,14 @@ return {
rmdir = rmdir,
mkdir = lfs.mkdir,
exc_exec = exc_exec,
redir_exec = redir_exec,
merge_args = merge_args,
funcs = funcs,
meths = meths,
bufmeths = bufmeths,
winmeths = winmeths,
tabmeths = tabmeths,
curbufmeths = curbufmeths,
curwinmeths = curwinmeths,
curtabmeths = curtabmeths,
}

View File

@@ -1,18 +1,13 @@
-- ShaDa buffer list saving/reading support
local helpers = require('test.functional.helpers')
local nvim, nvim_window, nvim_curwin, nvim_command, nvim_feed, nvim_eval, eq =
helpers.nvim, helpers.window, helpers.curwin, helpers.command, helpers.feed,
helpers.eval, helpers.eq
local nvim_command, funcs, eq =
helpers.command, helpers.funcs, helpers.eq
local shada_helpers = require('test.functional.shada.helpers')
local reset, set_additional_cmd, clear =
shada_helpers.reset, shada_helpers.set_additional_cmd,
shada_helpers.clear
local nvim_current_line = function()
return nvim_window('get_cursor', nvim_curwin())[1]
end
describe('ShaDa support code', function()
testfilename = 'Xtestfile-functional-shada-buffers'
testfilename_2 = 'Xtestfile-functional-shada-buffers-2'
@@ -24,15 +19,12 @@ describe('ShaDa support code', function()
reset()
nvim_command('edit ' .. testfilename)
nvim_command('edit ' .. testfilename_2)
-- nvim_command('redir! > /tmp/vistr | verbose set shada? | redir END')
-- nvim_command('wshada /tmp/foo')
nvim_command('qall')
reset()
-- nvim_command('call writefile([&shada], "/tmp/vistr")')
eq(3, nvim_eval('bufnr("$")'))
eq('', nvim_eval('bufname(1)'))
eq(testfilename, nvim_eval('bufname(2)'))
eq(testfilename_2, nvim_eval('bufname(3)'))
eq(3, funcs.bufnr('$'))
eq('', funcs.bufname(1))
eq(testfilename, funcs.bufname(2))
eq(testfilename_2, funcs.bufname(3))
end)
it('does not restore buffer list without % in &shada', function()
@@ -40,26 +32,20 @@ describe('ShaDa support code', function()
reset()
nvim_command('edit ' .. testfilename)
nvim_command('edit ' .. testfilename_2)
-- nvim_command('redir! > /tmp/vistr | verbose set shada? | redir END')
-- nvim_command('wshada /tmp/foo')
set_additional_cmd('')
nvim_command('qall')
reset()
-- nvim_command('call writefile([&shada], "/tmp/vistr")')
eq(1, nvim_eval('bufnr("$")'))
eq('', nvim_eval('bufname(1)'))
eq(1, funcs.bufnr('$'))
eq('', funcs.bufname(1))
end)
it('does not dump buffer list without % in &shada', function()
nvim_command('edit ' .. testfilename)
nvim_command('edit ' .. testfilename_2)
-- nvim_command('redir! > /tmp/vistr | verbose set shada? | redir END')
-- nvim_command('wshada /tmp/foo')
set_additional_cmd('set shada+=%')
nvim_command('qall')
reset()
-- nvim_command('call writefile([&shada], "/tmp/vistr")')
eq(1, nvim_eval('bufnr("$")'))
eq('', nvim_eval('bufname(1)'))
eq(1, funcs.bufnr('$'))
eq('', funcs.bufname(1))
end)
end)

View File

@@ -1,8 +1,6 @@
-- ShaDa compatibility support
local helpers = require('test.functional.helpers')
local nvim, nvim_window, nvim_curwin, nvim_command, nvim_feed, nvim_eval, eq =
helpers.nvim, helpers.window, helpers.curwin, helpers.command, helpers.feed,
helpers.eval, helpers.eq
local nvim_command, funcs, eq = helpers.command, helpers.funcs, helpers.eq
local exc_exec = helpers.exc_exec
local shada_helpers = require('test.functional.shada.helpers')
@@ -45,11 +43,11 @@ describe('ShaDa forward compatibility support code', function()
end
end
eq(true, found)
nvim_eval('garbagecollect(1)')
nvim_eval('garbagecollect(1)')
funcs.garbagecollect(1)
funcs.garbagecollect(1)
nvim_command('rshada! ' .. shada_fname)
nvim_eval('garbagecollect(1)')
nvim_eval('garbagecollect(1)')
funcs.garbagecollect(1)
funcs.garbagecollect(1)
end)
it('works with s/search pattern item with BOOL unknown (sX) key value', function()
@@ -77,11 +75,11 @@ describe('ShaDa forward compatibility support code', function()
end
end
eq(true, found)
nvim_eval('garbagecollect(1)')
nvim_eval('garbagecollect(1)')
funcs.garbagecollect(1)
funcs.garbagecollect(1)
nvim_command('rshada!' .. shada_fname)
nvim_eval('garbagecollect(1)')
nvim_eval('garbagecollect(1)')
funcs.garbagecollect(1)
funcs.garbagecollect(1)
end)
it('works with replacement item with BOOL additional value in list', function()
@@ -110,11 +108,11 @@ describe('ShaDa forward compatibility support code', function()
end
end
eq(true, found)
nvim_eval('garbagecollect(1)')
nvim_eval('garbagecollect(1)')
funcs.garbagecollect(1)
funcs.garbagecollect(1)
nvim_command('rshada!' .. shada_fname)
nvim_eval('garbagecollect(1)')
nvim_eval('garbagecollect(1)')
funcs.garbagecollect(1)
funcs.garbagecollect(1)
end)
for _, v in ipairs({{name='global mark', mpack='\007\001\018\131\162mX\195\161f\196\006/a/b/c\161nA'},
@@ -124,8 +122,8 @@ describe('ShaDa forward compatibility support code', function()
}) do
it('works with ' .. v.name .. ' item with BOOL unknown (mX) key value', function()
nvim_command('silent noautocmd edit /a/b/c')
eq('/a/b/c', nvim_eval('bufname("%")'))
nvim_command('call setline(".", ["1", "2", "3"])')
eq('/a/b/c', funcs.bufname('%'))
funcs.setline('.', {'1', '2', '3'})
wshada(v.mpack)
eq(0, exc_exec(sdrcmd(true)))
os.remove(shada_fname)
@@ -141,7 +139,7 @@ describe('ShaDa forward compatibility support code', function()
eq(true, found)
eq(0, exc_exec(sdrcmd()))
nvim_command('bwipeout!')
nvim_eval('setpos("\'A", [0, 1, 1, 0])')
funcs.setpos('\'A', {0, 1, 1, 0})
os.remove(shada_fname)
nvim_command('wshada ' .. shada_fname)
found = false
@@ -153,18 +151,18 @@ describe('ShaDa forward compatibility support code', function()
end
end
eq(false, found)
nvim_eval('garbagecollect(1)')
nvim_eval('garbagecollect(1)')
funcs.garbagecollect(1)
funcs.garbagecollect(1)
nvim_command('rshada!' .. shada_fname)
nvim_eval('garbagecollect(1)')
nvim_eval('garbagecollect(1)')
funcs.garbagecollect(1)
funcs.garbagecollect(1)
end)
if v.name == 'global mark' or v.name == 'local mark' then
it('works with ' .. v.name .. ' item with <C-a> name', function()
nvim_command('silent noautocmd edit /a/b/c')
eq('/a/b/c', nvim_eval('bufname("%")'))
nvim_command('call setline(".", ["1", "2", "3"])')
eq('/a/b/c', funcs.bufname('%'))
funcs.setline('.', {'1', '2', '3'})
wshada(v.mpack:gsub('n.$', 'n\001')
.. v.mpack:gsub('n.$', 'n\002')
.. v.mpack:gsub('n.$', 'n\003'):gsub('/a/b/c', '/d/e/f'))
@@ -195,11 +193,11 @@ describe('ShaDa forward compatibility support code', function()
end
end
eq(0, found)
nvim_eval('garbagecollect(1)')
nvim_eval('garbagecollect(1)')
funcs.garbagecollect(1)
funcs.garbagecollect(1)
nvim_command('rshada!' .. shada_fname)
nvim_eval('garbagecollect(1)')
nvim_eval('garbagecollect(1)')
funcs.garbagecollect(1)
funcs.garbagecollect(1)
end)
end
end
@@ -227,11 +225,11 @@ describe('ShaDa forward compatibility support code', function()
end
end
eq(false, found)
nvim_eval('garbagecollect(1)')
nvim_eval('garbagecollect(1)')
funcs.garbagecollect(1)
funcs.garbagecollect(1)
nvim_command('rshada!' .. shada_fname)
nvim_eval('garbagecollect(1)')
nvim_eval('garbagecollect(1)')
funcs.garbagecollect(1)
funcs.garbagecollect(1)
end)
it('works with register item with <C-a> name', function()
@@ -263,17 +261,20 @@ describe('ShaDa forward compatibility support code', function()
end
end
eq(0, found)
nvim_eval('garbagecollect(1)')
nvim_eval('garbagecollect(1)')
funcs.garbagecollect(1)
funcs.garbagecollect(1)
nvim_command('rshada!' .. shada_fname)
nvim_eval('garbagecollect(1)')
nvim_eval('garbagecollect(1)')
funcs.garbagecollect(1)
funcs.garbagecollect(1)
end)
it('works with register item with type 10', function()
wshada('\005\001\019\132\161na\162rX\194\162rc\145\196\001-\162rt\010')
eq(0, exc_exec(sdrcmd(true)))
eq({{}, ''}, nvim_eval('[getreg("a", 1, 1)[:], getregtype("a")]'))
-- getreg may return empty list as list with NULL pointer which API
-- translates into nil for some reason.
eq({}, funcs.getreg('a', 1, 1) or {})
eq('', funcs.getregtype('a'))
nvim_command('wshada ' .. shada_fname)
local found = 0
for i, v in ipairs(read_shada_file(shada_fname)) do
@@ -300,19 +301,19 @@ describe('ShaDa forward compatibility support code', function()
end
end
eq(0, found)
nvim_eval('garbagecollect(1)')
nvim_eval('garbagecollect(1)')
funcs.garbagecollect(1)
funcs.garbagecollect(1)
nvim_command('rshada!' .. shada_fname)
nvim_eval('garbagecollect(1)')
nvim_eval('garbagecollect(1)')
funcs.garbagecollect(1)
funcs.garbagecollect(1)
end)
it('works with buffer list item with BOOL unknown (bX) key', function()
nvim_command('set shada+=%')
wshada('\009\000\016\145\130\161f\196\006/a/b/c\162bX\195')
eq(0, exc_exec(sdrcmd()))
eq(2, nvim_eval('bufnr("$")'))
eq('/a/b/c', nvim_eval('bufname(2)'))
eq(2, funcs.bufnr('$'))
eq('/a/b/c', funcs.bufname(2))
os.remove(shada_fname)
nvim_command('wshada ' .. shada_fname)
local found = false
@@ -335,11 +336,11 @@ describe('ShaDa forward compatibility support code', function()
end
eq(false, found)
nvim_command('bwipeout!')
nvim_eval('garbagecollect(1)')
nvim_eval('garbagecollect(1)')
funcs.garbagecollect(1)
funcs.garbagecollect(1)
nvim_command('rshada!' .. shada_fname)
nvim_eval('garbagecollect(1)')
nvim_eval('garbagecollect(1)')
funcs.garbagecollect(1)
funcs.garbagecollect(1)
end)
it('works with history item with BOOL additional value in list', function()
@@ -358,8 +359,8 @@ describe('ShaDa forward compatibility support code', function()
eq(true, found)
eq(0, exc_exec(sdrcmd()))
os.remove(shada_fname)
nvim_eval('histadd(":", "--")')
nvim_eval('histadd(":", "-")')
funcs.histadd(':', '--')
funcs.histadd(':', '-')
nvim_command('wshada ' .. shada_fname)
found = false
for _, v in ipairs(read_shada_file(shada_fname)) do
@@ -369,11 +370,11 @@ describe('ShaDa forward compatibility support code', function()
end
end
eq(true, found)
nvim_eval('garbagecollect(1)')
nvim_eval('garbagecollect(1)')
funcs.garbagecollect(1)
funcs.garbagecollect(1)
nvim_command('rshada!' .. shada_fname)
nvim_eval('garbagecollect(1)')
nvim_eval('garbagecollect(1)')
funcs.garbagecollect(1)
funcs.garbagecollect(1)
end)
it('works with history item with type 10', function()
@@ -406,11 +407,11 @@ describe('ShaDa forward compatibility support code', function()
end
end
eq(0, found)
nvim_eval('garbagecollect(1)')
nvim_eval('garbagecollect(1)')
funcs.garbagecollect(1)
funcs.garbagecollect(1)
nvim_command('rshada!' .. shada_fname)
nvim_eval('garbagecollect(1)')
nvim_eval('garbagecollect(1)')
funcs.garbagecollect(1)
funcs.garbagecollect(1)
end)
it('works with item with 100 type', function()
@@ -443,10 +444,10 @@ describe('ShaDa forward compatibility support code', function()
end
end
eq(0, found)
nvim_eval('garbagecollect(1)')
nvim_eval('garbagecollect(1)')
funcs.garbagecollect(1)
funcs.garbagecollect(1)
nvim_command('rshada!' .. shada_fname)
nvim_eval('garbagecollect(1)')
nvim_eval('garbagecollect(1)')
funcs.garbagecollect(1)
funcs.garbagecollect(1)
end)
end)

View File

@@ -1,14 +1,10 @@
-- ShaDa errors handling support
local helpers = require('test.functional.helpers')
local nvim, nvim_window, nvim_curwin, nvim_command, nvim_feed, nvim_eval, eq =
helpers.nvim, helpers.window, helpers.curwin, helpers.command, helpers.feed,
helpers.eval, helpers.eq
local exc_exec = helpers.exc_exec
local nvim_command, eq, exc_exec = helpers.command, helpers.eq, helpers.exc_exec
local shada_helpers = require('test.functional.shada.helpers')
local reset, set_additional_cmd, clear, get_shada_rw =
shada_helpers.reset, shada_helpers.set_additional_cmd,
shada_helpers.clear, shada_helpers.get_shada_rw
local reset, clear, get_shada_rw =
shada_helpers.reset, shada_helpers.clear, shada_helpers.get_shada_rw
local wshada, sdrcmd, shada_fname, clean =
get_shada_rw('Xtest-functional-shada-errors.shada')

View File

@@ -1,7 +1,6 @@
local helpers = require('test.functional.helpers')
local spawn, set_session, nvim, nvim_prog, nvim_command, nvim_eval =
helpers.spawn, helpers.set_session, helpers.nvim, helpers.nvim_prog,
helpers.command, helpers.eval
local spawn, set_session, meths, nvim_prog =
helpers.spawn, helpers.set_session, helpers.meths, helpers.nvim_prog
local write_file, merge_args = helpers.write_file, helpers.merge_args
local msgpack = require('MessagePack')
@@ -30,7 +29,7 @@ local reset = function()
end
session = spawn(nvim_argv())
set_session(session)
nvim('set_var', 'tmpname', tmpname)
meths.set_var('tmpname', tmpname)
end
local set_additional_cmd = function(s)

View File

@@ -1,7 +1,7 @@
-- ShaDa history saving/reading support
local helpers = require('test.functional.helpers')
local nvim, nvim_command, nvim_eval, nvim_feed, eq =
helpers.nvim, helpers.command, helpers.eval, helpers.feed, helpers.eq
local nvim_command, funcs, meths, nvim_feed, eq =
helpers.command, helpers.funcs, helpers.meths, helpers.feed, helpers.eq
local shada_helpers = require('test.functional.shada.helpers')
local reset, set_additional_cmd, clear =
@@ -19,7 +19,7 @@ describe('ShaDa support code', function()
reset()
nvim_command('set shada=\'0')
nvim_command('rshada')
eq('" Test', nvim_eval('histget(":", -1)'))
eq('" Test', funcs.histget(':', -1))
end)
it('is able to dump and read back 2 items in command-line history', function()
@@ -30,8 +30,8 @@ describe('ShaDa support code', function()
reset()
nvim_command('set shada=\'0 history=2')
nvim_command('rshada')
eq('" Test 2', nvim_eval('histget(":", -1)'))
eq('" Test', nvim_eval('histget(":", -2)'))
eq('" Test 2', funcs.histget(':', -1))
eq('" Test', funcs.histget(':', -2))
nvim_command('qall')
end)
@@ -44,8 +44,8 @@ describe('ShaDa support code', function()
reset()
nvim_command('set shada=\'0 history=2')
nvim_command('rshada')
eq('" Test 2', nvim_eval('histget(":", -1)'))
eq('', nvim_eval('histget(":", -2)'))
eq('" Test 2', funcs.histget(':', -1))
eq('', funcs.histget(':', -2))
end)
it('respects &history when loading',
@@ -57,8 +57,8 @@ describe('ShaDa support code', function()
reset()
nvim_command('set shada=\'0 history=1')
nvim_command('rshada')
eq('" Test 2', nvim_eval('histget(":", -1)'))
eq('', nvim_eval('histget(":", -2)'))
eq('" Test 2', funcs.histget(':', -1))
eq('', funcs.histget(':', -2))
end)
it('dumps only requested amount of command-line history items', function()
@@ -67,13 +67,13 @@ describe('ShaDa support code', function()
nvim_feed(':" Test 2\n')
nvim_command('wshada')
-- Regression test: :wshada should not alter or free history.
eq('" Test 2', nvim_eval('histget(":", -1)'))
eq('" Test', nvim_eval('histget(":", -2)'))
eq('" Test 2', funcs.histget(':', -1))
eq('" Test', funcs.histget(':', -2))
reset()
nvim_command('set shada=\'0')
nvim_command('rshada')
eq('" Test 2', nvim_eval('histget(":", -1)'))
eq('', nvim_eval('histget(":", -2)'))
eq('" Test 2', funcs.histget(':', -1))
eq('', funcs.histget(':', -2))
end)
it('does not respect number in &shada when loading history', function()
@@ -84,8 +84,8 @@ describe('ShaDa support code', function()
reset()
nvim_command('set shada=\'0,:1')
nvim_command('rshada')
eq('" Test 2', nvim_eval('histget(":", -1)'))
eq('" Test', nvim_eval('histget(":", -2)'))
eq('" Test 2', funcs.histget(':', -1))
eq('" Test', funcs.histget(':', -2))
end)
it('dumps and loads all kinds of histories', function()
@@ -99,31 +99,31 @@ describe('ShaDa support code', function()
nvim_command('wshada')
reset()
nvim_command('rshada')
eq('" Test', nvim_eval('histget(":", -1)'))
eq('Test', nvim_eval('histget("/", -1)'))
eq('"Test"', nvim_eval('histget("=", -1)'))
eq('Test 2', nvim_eval('histget("@", -1)'))
eq('c', nvim_eval('histget(">", -1)'))
eq('" Test', funcs.histget(':', -1))
eq('Test', funcs.histget('/', -1))
eq('"Test"', funcs.histget('=', -1))
eq('Test 2', funcs.histget('@', -1))
eq('c', funcs.histget('>', -1))
end)
it('dumps and loads last search pattern with offset', function()
nvim_eval('setline(".", ["foo", "bar"])')
funcs.setline('.', {'foo', 'bar'})
nvim_feed('gg0/a/e+1\n')
eq({0, 2, 3, 0}, nvim_eval('getpos(".")'))
eq({0, 2, 3, 0}, funcs.getpos('.'))
nvim_command('wshada')
reset()
nvim_eval('setline(".", ["foo", "bar"])')
funcs.setline('.', {'foo', 'bar'})
nvim_feed('gg0n')
eq({0, 2, 3, 0}, nvim_eval('getpos(".")'))
eq({0, 2, 3, 0}, funcs.getpos('.'))
end)
it('saves v:hlsearch=1', function()
nvim_command('set hlsearch shada-=h')
nvim_feed('/test\n')
eq(1, nvim_eval('v:hlsearch'))
eq(1, meths.get_vvar('hlsearch'))
nvim_command('qall')
reset()
eq(1, nvim_eval('v:hlsearch'))
eq(1, meths.get_vvar('hlsearch'))
end)
it('saves v:hlsearch=0 with :nohl', function()
@@ -132,27 +132,27 @@ describe('ShaDa support code', function()
nvim_command('nohlsearch')
nvim_command('qall')
reset()
eq(0, nvim_eval('v:hlsearch'))
eq(0, meths.get_vvar('hlsearch'))
end)
it('saves v:hlsearch=0 with default &shada', function()
nvim_command('set hlsearch')
nvim_feed('/test\n')
eq(1, nvim_eval('v:hlsearch'))
eq(1, meths.get_vvar('hlsearch'))
nvim_command('qall')
reset()
eq(0, nvim_eval('v:hlsearch'))
eq(0, meths.get_vvar('hlsearch'))
end)
it('dumps and loads last substitute pattern and replacement string', function()
nvim_eval('setline(".", ["foo", "bar"])')
funcs.setline('.', {'foo', 'bar'})
nvim_command('%s/f/g/g')
eq('goo', nvim_eval('getline(1)'))
eq('goo', funcs.getline(1))
nvim_command('wshada')
reset()
nvim_eval('setline(".", ["foo", "bar"])')
funcs.setline('.', {'foo', 'bar'})
nvim_command('&')
eq('goo', nvim_eval('getline(1)'))
eq('goo', funcs.getline(1))
end)
it('dumps and loads history correctly when &encoding is not UTF-8', function()
@@ -162,7 +162,7 @@ describe('ShaDa support code', function()
nvim_feed(':echo "\171"\n')
nvim_command('qall')
reset()
eq('echo "\171"', nvim_eval('histget(":", -1)'))
eq('echo "\171"', funcs.histget(':', -1))
end)
it('dumps and loads history correctly when &encoding /= UTF-8 when dumping',
@@ -174,7 +174,7 @@ describe('ShaDa support code', function()
set_additional_cmd('')
nvim_command('qall')
reset()
eq('echo "«"', nvim_eval('histget(":", -1)'))
eq('echo "«"', funcs.histget(':', -1))
end)
it('dumps and loads history correctly when &encoding /= UTF-8 when loading',
@@ -184,7 +184,7 @@ describe('ShaDa support code', function()
set_additional_cmd('set encoding=latin1')
nvim_command('qall')
reset()
eq('echo "\171"', nvim_eval('histget(":", -1)'))
eq('echo "\171"', funcs.histget(':', -1))
end)
it('dumps and loads replacement correctly when &encoding is not UTF-8',
@@ -195,9 +195,9 @@ describe('ShaDa support code', function()
nvim_command('substitute/./\171/ge')
nvim_command('qall!')
reset()
nvim_eval('setline(".", ["."])')
funcs.setline('.', {'.'})
nvim_command('&')
eq('\171', nvim_eval('getline(".")'))
eq('\171', funcs.getline('.'))
end)
it('dumps&loads replacement correctly when &encoding /= UTF-8 when dumping',
@@ -209,9 +209,9 @@ describe('ShaDa support code', function()
set_additional_cmd('')
nvim_command('qall')
reset()
nvim_eval('setline(".", ["."])')
funcs.setline('.', {'.'})
nvim_command('&')
eq('«', nvim_eval('getline(".")'))
eq('«', funcs.getline('.'))
end)
it('dumps&loads replacement correctly when &encoding /= UTF-8 when loading',
@@ -221,9 +221,9 @@ describe('ShaDa support code', function()
set_additional_cmd('set encoding=latin1')
nvim_command('qall')
reset()
nvim_eval('setline(".", ["."])')
funcs.setline('.', {'.'})
nvim_command('&')
eq('\171', nvim_eval('getline(".")'))
eq('\171', funcs.getline('.'))
end)
it('dumps and loads substitute pattern correctly when &encoding is not UTF-8',
@@ -234,9 +234,9 @@ describe('ShaDa support code', function()
nvim_command('substitute/\171/./ge')
nvim_command('qall!')
reset()
nvim_eval('setline(".", ["\171«"])')
funcs.setline('.', {'\171«'})
nvim_command('&')
eq('', nvim_eval('getline(".")'))
eq('', funcs.getline('.'))
end)
it('dumps&loads s/pattern correctly when &encoding /= UTF-8 when dumping',
@@ -248,9 +248,9 @@ describe('ShaDa support code', function()
set_additional_cmd('')
nvim_command('qall')
reset()
nvim_eval('setline(".", ["«\171"])')
funcs.setline('.', {'«\171'})
nvim_command('&')
eq('.\171', nvim_eval('getline(".")'))
eq('.\171', funcs.getline('.'))
end)
it('dumps&loads s/pattern correctly when &encoding /= UTF-8 when loading',
@@ -260,9 +260,9 @@ describe('ShaDa support code', function()
set_additional_cmd('set encoding=latin1')
nvim_command('qall')
reset()
nvim_eval('setline(".", ["\171«"])')
funcs.setline('.', {'\171«'})
nvim_command('&')
eq('', nvim_eval('getline(".")'))
eq('', funcs.getline('.'))
end)
it('dumps and loads search pattern correctly when &encoding is not UTF-8',
@@ -274,10 +274,10 @@ describe('ShaDa support code', function()
nvim_command('set shada+=/0')
nvim_command('qall!')
reset()
nvim_eval('setline(".", ["\171«"])')
funcs.setline('.', {'\171«'})
nvim_command('~&')
eq('«', nvim_eval('getline(".")'))
eq('', nvim_eval('histget("/", -1)'))
eq('«', funcs.getline('.'))
eq('', funcs.histget('/', -1))
end)
it('dumps&loads /pattern correctly when &encoding /= UTF-8 when dumping',
@@ -290,10 +290,10 @@ describe('ShaDa support code', function()
set_additional_cmd('')
nvim_command('qall')
reset()
nvim_eval('setline(".", ["«\171"])')
funcs.setline('.', {'«\171'})
nvim_command('~&')
eq('\171', nvim_eval('getline(".")'))
eq('', nvim_eval('histget("/", -1)'))
eq('\171', funcs.getline('.'))
eq('', funcs.histget('/', -1))
end)
it('dumps&loads /pattern correctly when &encoding /= UTF-8 when loading',
@@ -304,9 +304,9 @@ describe('ShaDa support code', function()
set_additional_cmd('set encoding=latin1')
nvim_command('qall')
reset()
nvim_eval('setline(".", ["\171«"])')
funcs.setline('.', {'\171«'})
nvim_command('~&')
eq('«', nvim_eval('getline(".")'))
eq('', nvim_eval('histget("/", -1)'))
eq('«', funcs.getline('.'))
eq('', funcs.histget('/', -1))
end)
end)

View File

@@ -1,9 +1,9 @@
-- ShaDa marks saving/reading support
local helpers = require('test.functional.helpers')
local nvim, nvim_window, nvim_curwin, nvim_command, nvim_feed, nvim_eval, eq =
helpers.nvim, helpers.window, helpers.curwin, helpers.command, helpers.feed,
helpers.eval, helpers.eq
local exc_exec = helpers.exc_exec
local meths, curwinmeths, curbufmeths, nvim_command, funcs, eq =
helpers.meths, helpers.curwinmeths, helpers.curbufmeths, helpers.command,
helpers.funcs, helpers.eq
local exc_exec, redir_exec = helpers.exc_exec, helpers.redir_exec
local shada_helpers = require('test.functional.shada.helpers')
local reset, set_additional_cmd, clear =
@@ -11,7 +11,7 @@ local reset, set_additional_cmd, clear =
shada_helpers.clear
local nvim_current_line = function()
return nvim_window('get_cursor', nvim_curwin())[1]
return curwinmeths.get_cursor()[1]
end
describe('ShaDa support code', function()
@@ -43,7 +43,7 @@ describe('ShaDa support code', function()
reset()
nvim_command('rshada')
nvim_command('normal! `A')
eq(testfilename, nvim_eval('fnamemodify(@%, ":t")'))
eq(testfilename, funcs.fnamemodify(curbufmeths.get_name(), ':t'))
eq(1, nvim_current_line())
nvim_command('normal! `B')
eq(2, nvim_current_line())
@@ -71,7 +71,7 @@ describe('ShaDa support code', function()
reset()
nvim_command('language C')
nvim_command('normal! `A')
eq(testfilename, nvim_eval('fnamemodify(@%, ":t")'))
eq(testfilename, funcs.fnamemodify(curbufmeths.get_name(), ':t'))
eq(1, nvim_current_line())
end)
@@ -84,7 +84,7 @@ describe('ShaDa support code', function()
reset()
nvim_command('edit ' .. testfilename)
nvim_command('normal! `a')
eq(testfilename, nvim_eval('fnamemodify(@%, ":t")'))
eq(testfilename, funcs.fnamemodify(curbufmeths.get_name(), ':t'))
eq(1, nvim_current_line())
nvim_command('normal! `b')
eq(2, nvim_current_line())
@@ -92,19 +92,19 @@ describe('ShaDa support code', function()
it('is able to populate v:oldfiles', function()
nvim_command('edit ' .. testfilename)
local tf_full = nvim_eval('fnamemodify(bufname("%"), ":p")')
local tf_full = curbufmeths.get_name()
nvim_command('edit ' .. testfilename_2)
local tf_full_2 = nvim_eval('fnamemodify(bufname("%"), ":p")')
local tf_full_2 = curbufmeths.get_name()
nvim_command('qall')
reset()
local oldfiles = nvim('get_vvar', 'oldfiles')
local oldfiles = meths.get_vvar('oldfiles')
eq(2, #oldfiles)
eq(testfilename, oldfiles[1]:sub(-#testfilename))
eq(testfilename_2, oldfiles[2]:sub(-#testfilename_2))
eq(tf_full, oldfiles[1])
eq(tf_full_2, oldfiles[2])
nvim_command('rshada!')
local oldfiles = nvim('get_vvar', 'oldfiles')
local oldfiles = meths.get_vvar('oldfiles')
eq(2, #oldfiles)
eq(testfilename, oldfiles[1]:sub(-#testfilename))
eq(testfilename_2, oldfiles[2]:sub(-#testfilename_2))
@@ -114,74 +114,66 @@ describe('ShaDa support code', function()
it('is able to dump and restore jump list', function()
nvim_command('edit ' .. testfilename_2)
nvim_feed('G')
nvim_feed('gg')
nvim_command('normal! G')
nvim_command('normal! gg')
nvim_command('edit ' .. testfilename)
nvim_feed('G')
nvim_feed('gg')
nvim_command('normal! G')
nvim_command('normal! gg')
nvim_command('enew')
nvim_feed('gg')
nvim_command('redir => g:jumps | jumps | redir END')
local saved = nvim_eval('g:jumps')
nvim_command('normal! gg')
local saved = redir_exec('jumps')
nvim_command('qall')
reset()
nvim_command('redir => g:jumps | jumps | redir END')
eq(saved, nvim_eval('g:jumps'))
eq(saved, redir_exec('jumps'))
end)
it('is able to dump and restore jump list with different times (slow!)',
function()
nvim_command('edit ' .. testfilename_2)
nvim_command('sleep 2')
nvim_feed('G')
nvim_command('normal! G')
nvim_command('sleep 2')
nvim_feed('gg')
nvim_command('normal! gg')
nvim_command('sleep 2')
nvim_command('edit ' .. testfilename)
nvim_command('sleep 2')
nvim_feed('G')
nvim_command('normal! G')
nvim_command('sleep 2')
nvim_feed('gg')
-- nvim_command('redir! >/tmp/jumps.last | jumps | redir END')
-- nvim_command('wshada /tmp/foo')
nvim_command('normal! gg')
nvim_command('qall')
reset()
nvim_command('redraw')
-- nvim_command('redir! >/tmp/jumps.init | jumps | redir END')
nvim_command('edit ' .. testfilename)
-- nvim_command('redir! >/tmp/jumps | jumps | redir END')
eq(testfilename, nvim_eval('bufname("%")'))
eq(testfilename, funcs.bufname('%'))
eq(1, nvim_current_line())
nvim_command('execute "normal! \\<C-o>"')
eq(testfilename, nvim_eval('bufname("%")'))
eq(testfilename, funcs.bufname('%'))
eq(1, nvim_current_line())
nvim_command('execute "normal! \\<C-o>"')
eq(testfilename, nvim_eval('bufname("%")'))
eq(testfilename, funcs.bufname('%'))
eq(2, nvim_current_line())
nvim_command('execute "normal! \\<C-o>"')
eq(testfilename_2, nvim_eval('bufname("%")'))
eq(testfilename_2, funcs.bufname('%'))
eq(1, nvim_current_line())
nvim_command('execute "normal! \\<C-o>"')
eq(testfilename_2, nvim_eval('bufname("%")'))
eq(testfilename_2, funcs.bufname('%'))
eq(2, nvim_current_line())
end)
it('is able to dump and restore change list', function()
nvim_command('edit ' .. testfilename)
nvim_feed('Gra')
nvim_feed('ggrb')
nvim_command('normal! Gra')
nvim_command('normal! ggrb')
nvim_command('qall!')
reset()
nvim_command('edit ' .. testfilename)
-- nvim_command('rshada')
-- nvim_command('redir! >/tmp/changes | changes | redir END')
nvim_feed('Gg;')
nvim_command('normal! Gg;')
-- Note: without “sync” “commands” test has good changes to fail for unknown
-- reason (in first eq expected 1 is compared with 2). Any command inserted
-- causes this to work properly.
nvim_command('" sync')
eq(1, nvim_current_line())
nvim_feed('g;')
nvim_command('normal! g;')
nvim_command('" sync 2')
eq(2, nvim_current_line())
end)

View File

@@ -1,14 +1,13 @@
-- ShaDa merging data support
local helpers = require('test.functional.helpers')
local nvim, nvim_window, nvim_curwin, nvim_command, nvim_feed, nvim_eval, eq =
helpers.nvim, helpers.window, helpers.curwin, helpers.command, helpers.feed,
helpers.eval, helpers.eq
local exc_exec = helpers.exc_exec
local nvim_command, meths, funcs, curbufmeths, eq =
helpers.command, helpers.meths, helpers.funcs,
helpers.curbufmeths, helpers.eq
local exc_exec, redir_exec = helpers.exc_exec, helpers.redir_exec
local shada_helpers = require('test.functional.shada.helpers')
local reset, set_additional_cmd, clear, get_shada_rw =
shada_helpers.reset, shada_helpers.set_additional_cmd,
shada_helpers.clear, shada_helpers.get_shada_rw
local reset, clear, get_shada_rw =
shada_helpers.reset, shada_helpers.clear, shada_helpers.get_shada_rw
local read_shada_file = shada_helpers.read_shada_file
local wshada, sdrcmd, shada_fname =
@@ -142,7 +141,7 @@ describe('ShaDa history merging code', function()
eq(0, exc_exec('wshada! ' .. shada_fname))
local items = {'ad', 'ab', 'ac', 'af', 'ae'}
for i, v in ipairs(items) do
eq(v, nvim_eval(('histget(":", %i)'):format(i)))
eq(v, funcs.histget(':', i))
end
local found = 0
for _, v in ipairs(read_shada_file(shada_fname)) do
@@ -244,7 +243,7 @@ describe('ShaDa search pattern support code', function()
eq(0, exc_exec(sdrcmd()))
wshada('\002\000\011\130\162sX\194\162sp\196\001?')
eq(0, exc_exec(sdrcmd()))
eq('-', nvim_eval('@/'))
eq('-', funcs.getreg('/'))
end)
it('uses last search pattern with gt tstamp from file when reading with bang',
@@ -253,7 +252,7 @@ describe('ShaDa search pattern support code', function()
eq(0, exc_exec(sdrcmd()))
wshada('\002\000\011\130\162sX\194\162sp\196\001?')
eq(0, exc_exec(sdrcmd(true)))
eq('?', nvim_eval('@/'))
eq('?', funcs.getreg('/'))
end)
it('uses last search pattern with eq timestamp from instance when reading',
@@ -262,7 +261,7 @@ describe('ShaDa search pattern support code', function()
eq(0, exc_exec(sdrcmd()))
wshada('\002\001\011\130\162sX\194\162sp\196\001?')
eq(0, exc_exec(sdrcmd()))
eq('-', nvim_eval('@/'))
eq('-', funcs.getreg('/'))
end)
it('uses last search pattern with gt timestamp from file when reading',
@@ -271,7 +270,7 @@ describe('ShaDa search pattern support code', function()
eq(0, exc_exec(sdrcmd()))
wshada('\002\002\011\130\162sX\194\162sp\196\001?')
eq(0, exc_exec(sdrcmd()))
eq('?', nvim_eval('@/'))
eq('?', funcs.getreg('/'))
end)
it('uses last search pattern with gt timestamp from instance when writing',
@@ -279,7 +278,7 @@ describe('ShaDa search pattern support code', function()
wshada('\002\001\011\130\162sX\194\162sp\196\001-')
eq(0, exc_exec(sdrcmd()))
wshada('\002\000\011\130\162sX\194\162sp\196\001?')
eq('-', nvim_eval('@/'))
eq('-', funcs.getreg('/'))
eq(0, exc_exec('wshada ' .. shada_fname))
local found = 0
for _, v in ipairs(read_shada_file(shada_fname)) do
@@ -295,7 +294,7 @@ describe('ShaDa search pattern support code', function()
wshada('\002\001\011\130\162sX\194\162sp\196\001-')
eq(0, exc_exec(sdrcmd()))
wshada('\002\001\011\130\162sX\194\162sp\196\001?')
eq('-', nvim_eval('@/'))
eq('-', funcs.getreg('/'))
eq(0, exc_exec('wshada ' .. shada_fname))
local found = 0
for _, v in ipairs(read_shada_file(shada_fname)) do
@@ -311,7 +310,7 @@ describe('ShaDa search pattern support code', function()
wshada('\002\001\011\130\162sX\194\162sp\196\001-')
eq(0, exc_exec(sdrcmd()))
wshada('\002\002\011\130\162sX\194\162sp\196\001?')
eq('-', nvim_eval('@/'))
eq('-', funcs.getreg('/'))
eq(0, exc_exec('wshada ' .. shada_fname))
local found = 0
for _, v in ipairs(read_shada_file(shada_fname)) do
@@ -328,7 +327,7 @@ describe('ShaDa search pattern support code', function()
eq(0, exc_exec(sdrcmd()))
wshada('\002\000\011\130\162ss\195\162sp\196\001?')
eq(0, exc_exec(sdrcmd()))
eq('-', nvim_eval('@/'))
eq('-', funcs.getreg('/'))
end)
it('uses last s/ pattern with gt timestamp from file when reading with !',
@@ -337,7 +336,7 @@ describe('ShaDa search pattern support code', function()
eq(0, exc_exec(sdrcmd()))
wshada('\002\000\011\130\162ss\195\162sp\196\001?')
eq(0, exc_exec(sdrcmd(true)))
eq('?', nvim_eval('@/'))
eq('?', funcs.getreg('/'))
end)
it('uses last s/ pattern with eq timestamp from instance when reading',
@@ -346,7 +345,7 @@ describe('ShaDa search pattern support code', function()
eq(0, exc_exec(sdrcmd()))
wshada('\002\001\011\130\162ss\195\162sp\196\001?')
eq(0, exc_exec(sdrcmd()))
eq('-', nvim_eval('@/'))
eq('-', funcs.getreg('/'))
end)
it('uses last s/ pattern with gt timestamp from file when reading',
@@ -355,7 +354,7 @@ describe('ShaDa search pattern support code', function()
eq(0, exc_exec(sdrcmd()))
wshada('\002\002\011\130\162ss\195\162sp\196\001?')
eq(0, exc_exec(sdrcmd()))
eq('?', nvim_eval('@/'))
eq('?', funcs.getreg('/'))
end)
it('uses last s/ pattern with gt timestamp from instance when writing',
@@ -363,7 +362,7 @@ describe('ShaDa search pattern support code', function()
wshada('\002\001\011\130\162ss\195\162sp\196\001-')
eq(0, exc_exec(sdrcmd()))
wshada('\002\000\011\130\162ss\195\162sp\196\001?')
eq('-', nvim_eval('@/'))
eq('-', funcs.getreg('/'))
eq(0, exc_exec('wshada ' .. shada_fname))
local found = 0
for _, v in ipairs(read_shada_file(shada_fname)) do
@@ -379,7 +378,7 @@ describe('ShaDa search pattern support code', function()
wshada('\002\001\011\130\162ss\195\162sp\196\001-')
eq(0, exc_exec(sdrcmd()))
wshada('\002\001\011\130\162ss\195\162sp\196\001?')
eq('-', nvim_eval('@/'))
eq('-', funcs.getreg('/'))
eq(0, exc_exec('wshada ' .. shada_fname))
local found = 0
for _, v in ipairs(read_shada_file(shada_fname)) do
@@ -395,7 +394,7 @@ describe('ShaDa search pattern support code', function()
wshada('\002\001\011\130\162ss\195\162sp\196\001-')
eq(0, exc_exec(sdrcmd()))
wshada('\002\002\011\130\162ss\195\162sp\196\001?')
eq('-', nvim_eval('@/'))
eq('-', funcs.getreg('/'))
eq(0, exc_exec('wshada ' .. shada_fname))
local found = 0
for _, v in ipairs(read_shada_file(shada_fname)) do
@@ -421,7 +420,7 @@ describe('ShaDa replacement string support code', function()
wshada('\003\000\004\145\196\001?')
eq(0, exc_exec(sdrcmd()))
nvim_command('s/.*/~')
eq('-', nvim_eval('getline(".")'))
eq('-', funcs.getline('.'))
nvim_command('bwipeout!')
end)
@@ -432,7 +431,7 @@ describe('ShaDa replacement string support code', function()
wshada('\003\000\004\145\196\001?')
eq(0, exc_exec(sdrcmd(true)))
nvim_command('s/.*/~')
eq('?', nvim_eval('getline(".")'))
eq('?', funcs.getline('.'))
nvim_command('bwipeout!')
end)
@@ -443,7 +442,7 @@ describe('ShaDa replacement string support code', function()
wshada('\003\001\004\145\196\001?')
eq(0, exc_exec(sdrcmd()))
nvim_command('s/.*/~')
eq('-', nvim_eval('getline(".")'))
eq('-', funcs.getline('.'))
nvim_command('bwipeout!')
end)
@@ -454,7 +453,7 @@ describe('ShaDa replacement string support code', function()
wshada('\003\002\004\145\196\001?')
eq(0, exc_exec(sdrcmd()))
nvim_command('s/.*/~')
eq('?', nvim_eval('getline(".")'))
eq('?', funcs.getline('.'))
nvim_command('bwipeout!')
end)
@@ -518,7 +517,7 @@ describe('ShaDa marks support code', function()
wshada('\007\000\018\131\162mX\195\161f\196\006/a/b/?\161nA')
eq(0, exc_exec(sdrcmd()))
nvim_command('normal! `A')
eq('-', nvim_eval('fnamemodify(bufname("%"), ":t")'))
eq('-', funcs.fnamemodify(curbufmeths.get_name(), ':t'))
end)
it('uses last A mark with gt timestamp from file when reading with !',
@@ -528,7 +527,7 @@ describe('ShaDa marks support code', function()
wshada('\007\000\018\131\162mX\195\161f\196\006/a/b/?\161nA')
eq(0, exc_exec(sdrcmd(true)))
nvim_command('normal! `A')
eq('?', nvim_eval('fnamemodify(bufname("%"), ":t")'))
eq('?', funcs.fnamemodify(curbufmeths.get_name(), ':t'))
end)
it('uses last A mark with eq timestamp from instance when reading',
@@ -538,7 +537,7 @@ describe('ShaDa marks support code', function()
wshada('\007\001\018\131\162mX\195\161f\196\006/a/b/?\161nA')
eq(0, exc_exec(sdrcmd()))
nvim_command('normal! `A')
eq('-', nvim_eval('fnamemodify(bufname("%"), ":t")'))
eq('-', funcs.fnamemodify(curbufmeths.get_name(), ':t'))
end)
it('uses last A mark with gt timestamp from file when reading',
@@ -548,7 +547,7 @@ describe('ShaDa marks support code', function()
wshada('\007\002\018\131\162mX\195\161f\196\006/a/b/?\161nA')
eq(0, exc_exec(sdrcmd()))
nvim_command('normal! `A')
eq('?', nvim_eval('fnamemodify(bufname("%"), ":t")'))
eq('?', funcs.fnamemodify(curbufmeths.get_name(), ':t'))
end)
it('uses last A mark with gt timestamp from instance when writing',
@@ -557,7 +556,7 @@ describe('ShaDa marks support code', function()
eq(0, exc_exec(sdrcmd()))
wshada('\007\000\018\131\162mX\195\161f\196\006/a/b/?\161nA')
nvim_command('normal! `A')
eq('-', nvim_eval('fnamemodify(bufname("%"), ":t")'))
eq('-', funcs.fnamemodify(curbufmeths.get_name(), ':t'))
eq(0, exc_exec('wshada ' .. shada_fname))
local found = 0
for _, v in ipairs(read_shada_file(shada_fname)) do
@@ -574,7 +573,7 @@ describe('ShaDa marks support code', function()
eq(0, exc_exec(sdrcmd()))
wshada('\007\001\018\131\162mX\195\161f\196\006/a/b/?\161nA')
nvim_command('normal! `A')
eq('-', nvim_eval('fnamemodify(bufname("%"), ":t")'))
eq('-', funcs.fnamemodify(curbufmeths.get_name(), ':t'))
eq(0, exc_exec('wshada ' .. shada_fname))
local found = 0
for _, v in ipairs(read_shada_file(shada_fname)) do
@@ -591,7 +590,7 @@ describe('ShaDa marks support code', function()
eq(0, exc_exec(sdrcmd()))
wshada('\007\002\018\131\162mX\195\161f\196\006/a/b/?\161nA')
nvim_command('normal! `A')
eq('-', nvim_eval('fnamemodify(bufname("%"), ":t")'))
eq('-', funcs.fnamemodify(curbufmeths.get_name(), ':t'))
eq(0, exc_exec('wshada ' .. shada_fname))
local found = 0
for _, v in ipairs(read_shada_file(shada_fname)) do
@@ -605,60 +604,60 @@ describe('ShaDa marks support code', function()
it('uses last a mark with gt timestamp from instance when reading',
function()
nvim_command('edit /a/b/-')
nvim_eval('setline(1, ["-", "?"])')
funcs.setline(1, {'-', '?'})
wshada('\010\001\017\131\161l\001\161f\196\006/a/b/-\161na')
eq(0, exc_exec(sdrcmd()))
wshada('\010\000\017\131\161l\002\161f\196\006/a/b/-\161na')
eq(0, exc_exec(sdrcmd()))
nvim_command('normal! `a')
eq('-', nvim_eval('getline(".")'))
eq('-', funcs.getline('.'))
end)
it('uses last a mark with gt timestamp from file when reading with !',
function()
nvim_command('edit /a/b/-')
nvim_eval('setline(1, ["-", "?"])')
funcs.setline(1, {'-', '?'})
wshada('\010\001\017\131\161l\001\161f\196\006/a/b/-\161na')
eq(0, exc_exec(sdrcmd()))
wshada('\010\000\017\131\161l\002\161f\196\006/a/b/-\161na')
eq(0, exc_exec(sdrcmd(true)))
nvim_command('normal! `a')
eq('?', nvim_eval('getline(".")'))
eq('?', funcs.getline('.'))
end)
it('uses last a mark with eq timestamp from instance when reading',
function()
nvim_command('edit /a/b/-')
nvim_eval('setline(1, ["-", "?"])')
funcs.setline(1, {'-', '?'})
wshada('\010\001\017\131\161l\001\161f\196\006/a/b/-\161na')
eq(0, exc_exec(sdrcmd()))
wshada('\010\001\017\131\161l\002\161f\196\006/a/b/-\161na')
eq(0, exc_exec(sdrcmd()))
nvim_command('normal! `a')
eq('-', nvim_eval('getline(".")'))
eq('-', funcs.getline('.'))
end)
it('uses last a mark with gt timestamp from file when reading',
function()
nvim_command('edit /a/b/-')
nvim_eval('setline(1, ["-", "?"])')
funcs.setline(1, {'-', '?'})
wshada('\010\001\017\131\161l\001\161f\196\006/a/b/-\161na')
eq(0, exc_exec(sdrcmd()))
wshada('\010\002\017\131\161l\002\161f\196\006/a/b/-\161na')
eq(0, exc_exec(sdrcmd()))
nvim_command('normal! `a')
eq('?', nvim_eval('getline(".")'))
eq('?', funcs.getline('.'))
end)
it('uses last a mark with gt timestamp from instance when writing',
function()
nvim_command('edit /a/b/-')
nvim_eval('setline(1, ["-", "?"])')
funcs.setline(1, {'-', '?'})
wshada('\010\001\017\131\161l\001\161f\196\006/a/b/-\161na')
eq(0, exc_exec(sdrcmd()))
wshada('\010\000\017\131\161l\002\161f\196\006/a/b/-\161na')
nvim_command('normal! `a')
eq('-', nvim_eval('getline(".")'))
eq('-', funcs.getline('.'))
eq(0, exc_exec('wshada ' .. shada_fname))
local found = 0
for _, v in ipairs(read_shada_file(shada_fname)) do
@@ -673,12 +672,12 @@ describe('ShaDa marks support code', function()
it('uses last a mark with eq timestamp from instance when writing',
function()
nvim_command('edit /a/b/-')
nvim_eval('setline(1, ["-", "?"])')
funcs.setline(1, {'-', '?'})
wshada('\010\001\017\131\161l\001\161f\196\006/a/b/-\161na')
eq(0, exc_exec(sdrcmd()))
wshada('\010\001\017\131\161l\002\161f\196\006/a/b/-\161na')
nvim_command('normal! `a')
eq('-', nvim_eval('getline(".")'))
eq('-', funcs.getline('.'))
eq(0, exc_exec('wshada ' .. shada_fname))
local found = 0
for _, v in ipairs(read_shada_file(shada_fname)) do
@@ -693,12 +692,12 @@ describe('ShaDa marks support code', function()
it('uses last a mark with gt timestamp from file when writing',
function()
nvim_command('edit /a/b/-')
nvim_eval('setline(1, ["-", "?"])')
funcs.setline(1, {'-', '?'})
wshada('\010\001\017\131\161l\001\161f\196\006/a/b/-\161na')
eq(0, exc_exec(sdrcmd()))
wshada('\010\002\017\131\161l\002\161f\196\006/a/b/-\161na')
nvim_command('normal! `a')
eq('-', nvim_eval('fnamemodify(bufname("%"), ":t")'))
eq('-', funcs.fnamemodify(curbufmeths.get_name(), ':t'))
eq(0, exc_exec('wshada ' .. shada_fname))
local found = 0
for _, v in ipairs(read_shada_file(shada_fname)) do
@@ -724,7 +723,7 @@ describe('ShaDa registers support code', function()
eq(0, exc_exec(sdrcmd()))
wshada('\005\000\015\131\161na\162rX\194\162rc\145\196\001?')
eq(0, exc_exec(sdrcmd()))
eq('-', nvim_eval('@a'))
eq('-', funcs.getreg('a'))
end)
it('uses last a register with gt timestamp from file when reading with !',
@@ -733,7 +732,7 @@ describe('ShaDa registers support code', function()
eq(0, exc_exec(sdrcmd()))
wshada('\005\000\015\131\161na\162rX\194\162rc\145\196\001?')
eq(0, exc_exec(sdrcmd(true)))
eq('?', nvim_eval('@a'))
eq('?', funcs.getreg('a'))
end)
it('uses last a register with eq timestamp from instance when reading',
@@ -742,7 +741,7 @@ describe('ShaDa registers support code', function()
eq(0, exc_exec(sdrcmd()))
wshada('\005\001\015\131\161na\162rX\194\162rc\145\196\001?')
eq(0, exc_exec(sdrcmd()))
eq('-', nvim_eval('@a'))
eq('-', funcs.getreg('a'))
end)
it('uses last a register with gt timestamp from file when reading',
@@ -751,7 +750,7 @@ describe('ShaDa registers support code', function()
eq(0, exc_exec(sdrcmd()))
wshada('\005\002\015\131\161na\162rX\194\162rc\145\196\001?')
eq(0, exc_exec(sdrcmd()))
eq('?', nvim_eval('@a'))
eq('?', funcs.getreg('a'))
end)
it('uses last a register with gt timestamp from instance when writing',
@@ -759,7 +758,7 @@ describe('ShaDa registers support code', function()
wshada('\005\001\015\131\161na\162rX\194\162rc\145\196\001-')
eq(0, exc_exec(sdrcmd()))
wshada('\005\000\015\131\161na\162rX\194\162rc\145\196\001?')
eq('-', nvim_eval('@a'))
eq('-', funcs.getreg('a'))
eq(0, exc_exec('wshada ' .. shada_fname))
local found = 0
for _, v in ipairs(read_shada_file(shada_fname)) do
@@ -776,7 +775,7 @@ describe('ShaDa registers support code', function()
wshada('\005\001\015\131\161na\162rX\194\162rc\145\196\001-')
eq(0, exc_exec(sdrcmd()))
wshada('\005\001\015\131\161na\162rX\194\162rc\145\196\001?')
eq('-', nvim_eval('@a'))
eq('-', funcs.getreg('a'))
eq(0, exc_exec('wshada ' .. shada_fname))
local found = 0
for _, v in ipairs(read_shada_file(shada_fname)) do
@@ -793,7 +792,7 @@ describe('ShaDa registers support code', function()
wshada('\005\001\015\131\161na\162rX\194\162rc\145\196\001-')
eq(0, exc_exec(sdrcmd()))
wshada('\005\002\015\131\161na\162rX\194\162rc\145\196\001?')
eq('-', nvim_eval('@a'))
eq('-', funcs.getreg('a'))
eq(0, exc_exec('wshada ' .. shada_fname))
local found = 0
for _, v in ipairs(read_shada_file(shada_fname)) do
@@ -822,8 +821,7 @@ describe('ShaDa jumps support code', function()
.. '\008\004\018\131\162mX\195\161f\196\006/a/b/d\161l\003'
.. '\008\007\018\131\162mX\195\161f\196\006/a/b/f\161l\002')
eq(0, exc_exec(sdrcmd()))
nvim_command('redir => g:jumps | jumps | redir END')
eq('', nvim_eval('bufname("%")'))
eq('', curbufmeths.get_name())
eq('\n'
.. ' jump line col file/text\n'
.. ' 6 2 0 /a/b/c\n'
@@ -832,7 +830,7 @@ describe('ShaDa jumps support code', function()
.. ' 3 2 0 /a/b/e\n'
.. ' 2 2 0 /a/b/f\n'
.. ' 1 1 0 \n'
.. '>', nvim_eval('g:jumps'))
.. '>', redir_exec('jumps'))
end)
it('merges jumps when writing', function()
@@ -916,7 +914,6 @@ describe('ShaDa changes support code', function()
.. '\011\004\018\131\162mX\195\161f\196\006/a/b/c\161l\005'
.. '\011\008\018\131\162mX\195\161f\196\006/a/b/c\161l\004')
eq(0, exc_exec(sdrcmd()))
nvim_command('redir => g:changes | changes | redir END')
eq('\n'
.. 'change line col text\n'
.. ' 5 1 0 0\n'
@@ -924,7 +921,7 @@ describe('ShaDa changes support code', function()
.. ' 3 5 0 4\n'
.. ' 2 3 0 2\n'
.. ' 1 4 0 3\n'
.. '>', nvim_eval('g:changes'))
.. '>', redir_exec('changes'))
end)
it('merges changes when writing', function()

View File

@@ -1,34 +1,23 @@
-- ShaDa registers saving/reading support
local helpers = require('test.functional.helpers')
local nvim, nvim_window, nvim_curwin, nvim_command, nvim_feed, nvim_eval, eq =
helpers.nvim, helpers.window, helpers.curwin, helpers.command, helpers.feed,
helpers.eval, helpers.eq
local nvim_command, funcs, eq = helpers.command, helpers.funcs, helpers.eq
local shada_helpers = require('test.functional.shada.helpers')
local reset, set_additional_cmd, clear =
shada_helpers.reset, shada_helpers.set_additional_cmd,
shada_helpers.clear
local nvim_current_line = function()
return nvim_window('get_cursor', nvim_curwin())[1]
end
local setreg = function(name, contents, typ)
local expr = 'setreg("' .. name .. '", ['
if type(contents) == 'string' then
contents = {contents}
end
for _, line in ipairs(contents) do
expr = expr .. '"' .. line:gsub('[\\"]', '\\\\\\0') .. '", '
end
expr = expr .. '], "' .. typ .. '")'
nvim_eval(expr)
funcs.setreg(name, contents, typ)
end
local getreg = function(name)
return {
nvim_eval(('getreg("%s", 1, 1)'):format(name)),
nvim_eval(('getregtype("%s")'):format(name)),
funcs.getreg(name, 1, 1),
funcs.getregtype(name),
}
end
@@ -40,7 +29,7 @@ describe('ShaDa support code', function()
setreg('c', {'d', 'e', ''}, 'c')
setreg('l', {'a', 'b', 'cde'}, 'l')
setreg('b', {'bca', 'abc', 'cba'}, 'b3')
nvim_command('qa')
nvim_command('qall')
reset()
eq({{'d', 'e', ''}, 'v'}, getreg('c'))
eq({{'a', 'b', 'cde'}, 'V'}, getreg('l'))
@@ -52,7 +41,7 @@ describe('ShaDa support code', function()
setreg('c', {'d', 'e', ''}, 'c')
setreg('l', {'a', 'b', 'cde'}, 'l')
setreg('b', {'bca', 'abc', 'cba'}, 'b3')
nvim_command('qa')
nvim_command('qall')
reset()
eq({nil, ''}, getreg('c'))
eq({nil, ''}, getreg('l'))
@@ -64,7 +53,7 @@ describe('ShaDa support code', function()
setreg('l', {'a', 'b', 'cde'}, 'l')
setreg('b', {'bca', 'abc', 'cba'}, 'b3')
set_additional_cmd('set shada=\'0,<0')
nvim_command('qa')
nvim_command('qall')
reset()
eq({{'d', 'e', ''}, 'v'}, getreg('c'))
eq({{'a', 'b', 'cde'}, 'V'}, getreg('l'))
@@ -76,7 +65,7 @@ describe('ShaDa support code', function()
setreg('c', {'d', 'e', ''}, 'c')
setreg('l', {'a', 'b', 'cde'}, 'l')
setreg('b', {'bca', 'abc', 'cba'}, 'b3')
nvim_command('qa')
nvim_command('qall')
reset()
eq({nil, ''}, getreg('c'))
eq({nil, ''}, getreg('l'))
@@ -88,7 +77,7 @@ describe('ShaDa support code', function()
setreg('l', {'a', 'b', 'cde'}, 'l')
setreg('b', {'bca', 'abc', 'cba'}, 'b3')
set_additional_cmd('set shada=\'0,\\"0')
nvim_command('qa')
nvim_command('qall')
reset()
eq({{'d', 'e', ''}, 'v'}, getreg('c'))
eq({{'a', 'b', 'cde'}, 'V'}, getreg('l'))
@@ -100,7 +89,7 @@ describe('ShaDa support code', function()
setreg('c', {'d', 'e', ''}, 'c')
setreg('l', {'a', 'b', 'cde'}, 'l')
setreg('b', {'bca', 'abc', 'cba'}, 'b3')
nvim_command('qa')
nvim_command('qall')
reset()
eq({{'d', 'e', ''}, 'v'}, getreg('c'))
eq({{'a', 'b', 'cde'}, 'V'}, getreg('l'))
@@ -111,7 +100,7 @@ describe('ShaDa support code', function()
nvim_command('set shada=\'0,<2')
setreg('o', {'d'}, 'c')
setreg('t', {'a', 'b', 'cde'}, 'l')
nvim_command('qa')
nvim_command('qall')
reset()
eq({{'d'}, 'v'}, getreg('o'))
eq({nil, ''}, getreg('t'))
@@ -121,7 +110,7 @@ describe('ShaDa support code', function()
nvim_command('set shada=\'0,\\"2')
setreg('o', {'d'}, 'c')
setreg('t', {'a', 'b', 'cde'}, 'l')
nvim_command('qa')
nvim_command('qall')
reset()
eq({{'d'}, 'v'}, getreg('o'))
eq({nil, ''}, getreg('t'))
@@ -132,7 +121,7 @@ describe('ShaDa support code', function()
setreg('o', {'d'}, 'c')
setreg('t', {'a', 'b', 'cde'}, 'l')
setreg('h', {'abc', 'acb', 'bac', 'bca', 'cab', 'cba'}, 'b3')
nvim_command('qa')
nvim_command('qall')
reset()
eq({{'d'}, 'v'}, getreg('o'))
eq({{'a', 'b', 'cde'}, 'V'}, getreg('t'))

View File

@@ -1,8 +1,7 @@
-- Other ShaDa tests
local helpers = require('test.functional.helpers')
local nvim, nvim_window, nvim_curwin, nvim_command, nvim_feed, nvim_eval, eq =
helpers.nvim, helpers.window, helpers.curwin, helpers.command, helpers.feed,
helpers.eval, helpers.eq
local meths, nvim_command, funcs, eq =
helpers.meths, helpers.command, helpers.funcs, helpers.eq
local write_file, spawn, set_session, nvim_prog, exc_exec =
helpers.write_file, helpers.spawn, helpers.set_session, helpers.nvim_prog,
helpers.exc_exec
@@ -12,12 +11,12 @@ local paths = require('test.config.paths')
local msgpack = require('MessagePack')
local shada_helpers = require('test.functional.shada.helpers')
local reset, set_additional_cmd, clear, get_shada_rw =
shada_helpers.reset, shada_helpers.set_additional_cmd,
shada_helpers.clear, shada_helpers.get_shada_rw
local reset, clear, get_shada_rw =
shada_helpers.reset, shada_helpers.clear, shada_helpers.get_shada_rw
local read_shada_file = shada_helpers.read_shada_file
local wshada, sdrcmd, shada_fname, clean = get_shada_rw('Xtest-functional-shada-shada.shada')
local wshada, _, shada_fname, clean =
get_shada_rw('Xtest-functional-shada-shada.shada')
describe('ShaDa support code', function()
before_each(reset)
@@ -52,8 +51,8 @@ describe('ShaDa support code', function()
local hist1 = ('-'):rep(1024 - 5)
local hist2 = ('-'):rep(1025 - 5)
nvim_command('set shada-=s10 shada+=s1')
nvim_eval(('histadd(":", "%s")'):format(hist1))
nvim_eval(('histadd(":", "%s")'):format(hist2))
funcs.histadd(':', hist1)
funcs.histadd(':', hist2)
eq(0, exc_exec('wshada ' .. shada_fname))
local found = 0
for _, v in ipairs(read_shada_file(shada_fname)) do
@@ -143,7 +142,7 @@ describe('ShaDa support code', function()
local session = spawn({nvim_prog, '-u', 'NONE', '-i', 'NONE', '--embed'},
true)
set_session(session)
eq('', nvim_eval('@a'))
eq('', funcs.getreg('a'))
session:exit(0)
os.remove('NONE')
end)
@@ -166,7 +165,7 @@ describe('ShaDa support code', function()
end
it('correctly uses shada-r option', function()
nvim('set_var', '__home', paths.test_source_path)
meths.set_var('__home', paths.test_source_path)
nvim_command('let $HOME = __home')
nvim_command('unlet __home')
nvim_command('edit ~/README.md')
@@ -188,12 +187,12 @@ describe('ShaDa support code', function()
end)
it('correctly ignores case with shada-r option', function()
local pwd = nvim('call_function', 'getcwd', {})
local pwd = funcs.getcwd()
local relfname = 'абв/test'
local fname = pwd .. '/' .. relfname
nvim('set_var', '__fname', fname)
meths.set_var('__fname', fname)
nvim_command('silent! edit `=__fname`')
nvim('call_function', 'setline', {1, {'a', 'b', 'c', 'd'}})
funcs.setline(1, {'a', 'b', 'c', 'd'})
nvim_command('normal! GmAggmaAabc')
nvim_command('undo')
nvim_command('set shada+=%')

View File

@@ -1,7 +1,7 @@
-- ShaDa variables saving/reading support
local helpers = require('test.functional.helpers')
local nvim, nvim_command, nvim_eval, eq =
helpers.nvim, helpers.command, helpers.eval, helpers.eq
local meths, funcs, nvim_command, eq =
helpers.meths, helpers.funcs, helpers.command, helpers.eq
local shada_helpers = require('test.functional.shada.helpers')
local reset, set_additional_cmd, clear =
@@ -13,13 +13,13 @@ describe('ShaDa support code', function()
after_each(clear)
it('is able to dump and read back string variable', function()
nvim('set_var', 'STRVAR', 'foo')
meths.set_var('STRVAR', 'foo')
nvim_command('set shada+=!')
nvim_command('wshada')
reset()
nvim_command('set shada+=!')
nvim_command('rshada')
eq('foo', nvim('get_var', 'STRVAR'))
eq('foo', meths.get_var('STRVAR'))
end)
local autotest = function(tname, varname, varval)
@@ -27,12 +27,12 @@ describe('ShaDa support code', function()
function()
set_additional_cmd('set shada+=!')
reset()
nvim('set_var', varname, varval)
meths.set_var(varname, varval)
-- Exit during `reset` is not a regular exit: it does not write shada
-- automatically
nvim_command('qall')
reset()
eq(varval, nvim('get_var', varname))
eq(varval, meths.get_var(varname))
end)
end
@@ -43,43 +43,43 @@ describe('ShaDa support code', function()
autotest('list', 'LSTVAR', {{a=10}, {b=10.5}, {c='str'}})
it('does not read back variables without `!` in &shada', function()
nvim('set_var', 'STRVAR', 'foo')
meths.set_var('STRVAR', 'foo')
nvim_command('set shada+=!')
nvim_command('wshada')
set_additional_cmd('set shada-=!')
reset()
nvim_command('rshada')
eq(0, nvim_eval('exists("g:STRVAR")'))
eq(0, funcs.exists('g:STRVAR'))
end)
it('does not dump variables without `!` in &shada', function()
nvim_command('set shada-=!')
nvim('set_var', 'STRVAR', 'foo')
meths.set_var('STRVAR', 'foo')
nvim_command('wshada')
reset()
nvim_command('set shada+=!')
nvim_command('rshada')
eq(0, nvim_eval('exists("g:STRVAR")'))
eq(0, funcs.exists('g:STRVAR'))
end)
it('does not dump session variables', function()
nvim_command('set shada+=!')
nvim('set_var', 'StrVar', 'foo')
meths.set_var('StrVar', 'foo')
nvim_command('wshada')
reset()
nvim_command('set shada+=!')
nvim_command('rshada')
eq(0, nvim_eval('exists("g:StrVar")'))
eq(0, funcs.exists('g:StrVar'))
end)
it('does not dump regular variables', function()
nvim_command('set shada+=!')
nvim('set_var', 'str_var', 'foo')
meths.set_var('str_var', 'foo')
nvim_command('wshada')
reset()
nvim_command('set shada+=!')
nvim_command('rshada')
eq(0, nvim_eval('exists("g:str_var")'))
eq(0, funcs.exists('g:str_var'))
end)
it('dumps and loads variables correctly when &encoding is not UTF-8',
@@ -87,18 +87,18 @@ describe('ShaDa support code', function()
set_additional_cmd('set encoding=latin1')
reset()
-- \171 is U+00AB LEFT-POINTING DOUBLE ANGLE QUOTATION MARK in latin1
nvim('set_var', 'STRVAR', '\171')
nvim('set_var', 'LSTVAR', {'\171'})
nvim('set_var', 'DCTVAR', {['\171']='\171'})
nvim('set_var', 'NESTEDVAR', {['\171']={{'\171'}, {['\171']='\171'},
{a='Test'}}})
meths.set_var('STRVAR', '\171')
meths.set_var('LSTVAR', {'\171'})
meths.set_var('DCTVAR', {['\171']='\171'})
meths.set_var('NESTEDVAR', {['\171']={{'\171'}, {['\171']='\171'},
{a='Test'}}})
nvim_command('qall')
reset()
eq('\171', nvim('get_var', 'STRVAR'))
eq({'\171'}, nvim('get_var', 'LSTVAR'))
eq({['\171']='\171'}, nvim('get_var', 'DCTVAR'))
eq('\171', meths.get_var('STRVAR'))
eq({'\171'}, meths.get_var('LSTVAR'))
eq({['\171']='\171'}, meths.get_var('DCTVAR'))
eq({['\171']={{'\171'}, {['\171']='\171'}, {a='Test'}}},
nvim('get_var', 'NESTEDVAR'))
meths.get_var('NESTEDVAR'))
end)
it('dumps and loads variables correctly when &encoding /= UTF-8 when dumping',
@@ -106,34 +106,34 @@ describe('ShaDa support code', function()
set_additional_cmd('set encoding=latin1')
reset()
-- \171 is U+00AB LEFT-POINTING DOUBLE ANGLE QUOTATION MARK in latin1
nvim('set_var', 'STRVAR', '\171')
nvim('set_var', 'LSTVAR', {'\171'})
nvim('set_var', 'DCTVAR', {['\171']='\171'})
nvim('set_var', 'NESTEDVAR', {['\171']={{'\171'}, {['\171']='\171'},
{a='Test'}}})
meths.set_var('STRVAR', '\171')
meths.set_var('LSTVAR', {'\171'})
meths.set_var('DCTVAR', {['\171']='\171'})
meths.set_var('NESTEDVAR', {['\171']={{'\171'}, {['\171']='\171'},
{a='Test'}}})
set_additional_cmd('')
nvim_command('qall')
reset()
eq('«', nvim('get_var', 'STRVAR'))
eq({'«'}, nvim('get_var', 'LSTVAR'))
eq({['«']='«'}, nvim('get_var', 'DCTVAR'))
eq({['«']={{'«'}, {['«']='«'}, {a='Test'}}}, nvim('get_var', 'NESTEDVAR'))
eq('«', meths.get_var('STRVAR'))
eq({'«'}, meths.get_var('LSTVAR'))
eq({['«']='«'}, meths.get_var('DCTVAR'))
eq({['«']={{'«'}, {['«']='«'}, {a='Test'}}}, meths.get_var('NESTEDVAR'))
end)
it('dumps and loads variables correctly when &encoding /= UTF-8 when loading',
function()
-- \171 is U+00AB LEFT-POINTING DOUBLE ANGLE QUOTATION MARK in latin1
nvim('set_var', 'STRVAR', '«')
nvim('set_var', 'LSTVAR', {'«'})
nvim('set_var', 'DCTVAR', {['«']='«'})
nvim('set_var', 'NESTEDVAR', {['«']={{'«'}, {['«']='«'}, {a='Test'}}})
meths.set_var('STRVAR', '«')
meths.set_var('LSTVAR', {'«'})
meths.set_var('DCTVAR', {['«']='«'})
meths.set_var('NESTEDVAR', {['«']={{'«'}, {['«']='«'}, {a='Test'}}})
set_additional_cmd('set encoding=latin1')
nvim_command('qall')
reset()
eq('\171', nvim('get_var', 'STRVAR'))
eq({'\171'}, nvim('get_var', 'LSTVAR'))
eq({['\171']='\171'}, nvim('get_var', 'DCTVAR'))
eq('\171', meths.get_var('STRVAR'))
eq({'\171'}, meths.get_var('LSTVAR'))
eq({['\171']='\171'}, meths.get_var('DCTVAR'))
eq({['\171']={{'\171'}, {['\171']='\171'}, {a='Test'}}},
nvim('get_var', 'NESTEDVAR'))
meths.get_var('NESTEDVAR'))
end)
end)