mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
test: Minimize shada/helpers.lua #10728
This commit is contained in:
parent
25fff17d19
commit
4bb728dfa0
@ -419,6 +419,14 @@ end
|
|||||||
-- clear('-e')
|
-- clear('-e')
|
||||||
-- clear{args={'-e'}, args_rm={'-i'}, env={TERM=term}}
|
-- clear{args={'-e'}, args_rm={'-i'}, env={TERM=term}}
|
||||||
function module.clear(...)
|
function module.clear(...)
|
||||||
|
local argv, env = module.new_argv(...)
|
||||||
|
module.set_session(module.spawn(argv, nil, env))
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Builds an argument list for use in clear().
|
||||||
|
--
|
||||||
|
--@see clear() for parameters.
|
||||||
|
function module.new_argv(...)
|
||||||
local args = {unpack(module.nvim_argv)}
|
local args = {unpack(module.nvim_argv)}
|
||||||
table.insert(args, '--headless')
|
table.insert(args, '--headless')
|
||||||
local new_args
|
local new_args
|
||||||
@ -458,7 +466,7 @@ function module.clear(...)
|
|||||||
for _, arg in ipairs(new_args) do
|
for _, arg in ipairs(new_args) do
|
||||||
table.insert(args, arg)
|
table.insert(args, arg)
|
||||||
end
|
end
|
||||||
module.set_session(module.spawn(args, nil, env))
|
return args, env
|
||||||
end
|
end
|
||||||
|
|
||||||
function module.insert(...)
|
function module.insert(...)
|
||||||
|
@ -1,26 +1,22 @@
|
|||||||
-- ShaDa buffer list saving/reading support
|
-- shada buffer list saving/reading support
|
||||||
local helpers = require('test.functional.helpers')(after_each)
|
local helpers = require('test.functional.helpers')(after_each)
|
||||||
local nvim_command, funcs, eq, curbufmeths =
|
local nvim_command, funcs, eq, curbufmeths =
|
||||||
helpers.command, helpers.funcs, helpers.eq, helpers.curbufmeths
|
helpers.command, helpers.funcs, helpers.eq, helpers.curbufmeths
|
||||||
|
|
||||||
local shada_helpers = require('test.functional.shada.helpers')
|
local shada_helpers = require('test.functional.shada.helpers')
|
||||||
local reset, set_additional_cmd, clear =
|
local reset, clear = shada_helpers.reset, shada_helpers.clear
|
||||||
shada_helpers.reset, shada_helpers.set_additional_cmd,
|
|
||||||
shada_helpers.clear
|
|
||||||
|
|
||||||
describe('ShaDa support code', function()
|
describe('shada support code', function()
|
||||||
local testfilename = 'Xtestfile-functional-shada-buffers'
|
local testfilename = 'Xtestfile-functional-shada-buffers'
|
||||||
local testfilename_2 = 'Xtestfile-functional-shada-buffers-2'
|
local testfilename_2 = 'Xtestfile-functional-shada-buffers-2'
|
||||||
before_each(reset)
|
|
||||||
after_each(clear)
|
after_each(clear)
|
||||||
|
|
||||||
it('is able to dump and restore buffer list', function()
|
it('is able to dump and restore buffer list', function()
|
||||||
set_additional_cmd('set shada+=%')
|
reset('set shada+=%')
|
||||||
reset()
|
|
||||||
nvim_command('edit ' .. testfilename)
|
nvim_command('edit ' .. testfilename)
|
||||||
nvim_command('edit ' .. testfilename_2)
|
nvim_command('edit ' .. testfilename_2)
|
||||||
nvim_command('qall')
|
nvim_command('qall')
|
||||||
reset()
|
reset('set shada+=%')
|
||||||
eq(3, funcs.bufnr('$'))
|
eq(3, funcs.bufnr('$'))
|
||||||
eq('', funcs.bufname(1))
|
eq('', funcs.bufname(1))
|
||||||
eq(testfilename, funcs.bufname(2))
|
eq(testfilename, funcs.bufname(2))
|
||||||
@ -28,11 +24,9 @@ describe('ShaDa support code', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it('does not restore buffer list without % in &shada', function()
|
it('does not restore buffer list without % in &shada', function()
|
||||||
set_additional_cmd('set shada+=%')
|
reset('set shada+=%')
|
||||||
reset()
|
|
||||||
nvim_command('edit ' .. testfilename)
|
nvim_command('edit ' .. testfilename)
|
||||||
nvim_command('edit ' .. testfilename_2)
|
nvim_command('edit ' .. testfilename_2)
|
||||||
set_additional_cmd('')
|
|
||||||
nvim_command('qall')
|
nvim_command('qall')
|
||||||
reset()
|
reset()
|
||||||
eq(1, funcs.bufnr('$'))
|
eq(1, funcs.bufnr('$'))
|
||||||
@ -40,61 +34,57 @@ describe('ShaDa support code', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it('does not dump buffer list without % in &shada', function()
|
it('does not dump buffer list without % in &shada', function()
|
||||||
|
reset()
|
||||||
nvim_command('edit ' .. testfilename)
|
nvim_command('edit ' .. testfilename)
|
||||||
nvim_command('edit ' .. testfilename_2)
|
nvim_command('edit ' .. testfilename_2)
|
||||||
set_additional_cmd('set shada+=%')
|
|
||||||
nvim_command('qall')
|
nvim_command('qall')
|
||||||
reset()
|
reset('set shada+=%')
|
||||||
eq(1, funcs.bufnr('$'))
|
eq(1, funcs.bufnr('$'))
|
||||||
eq('', funcs.bufname(1))
|
eq('', funcs.bufname(1))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('does not dump unlisted buffer', function()
|
it('does not dump unlisted buffer', function()
|
||||||
set_additional_cmd('set shada+=%')
|
reset('set shada+=%')
|
||||||
reset()
|
|
||||||
nvim_command('edit ' .. testfilename)
|
nvim_command('edit ' .. testfilename)
|
||||||
nvim_command('edit ' .. testfilename_2)
|
nvim_command('edit ' .. testfilename_2)
|
||||||
curbufmeths.set_option('buflisted', false)
|
curbufmeths.set_option('buflisted', false)
|
||||||
nvim_command('qall')
|
nvim_command('qall')
|
||||||
reset()
|
reset('set shada+=%')
|
||||||
eq(2, funcs.bufnr('$'))
|
eq(2, funcs.bufnr('$'))
|
||||||
eq('', funcs.bufname(1))
|
eq('', funcs.bufname(1))
|
||||||
eq(testfilename, funcs.bufname(2))
|
eq(testfilename, funcs.bufname(2))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('does not dump quickfix buffer', function()
|
it('does not dump quickfix buffer', function()
|
||||||
set_additional_cmd('set shada+=%')
|
reset('set shada+=%')
|
||||||
reset()
|
|
||||||
nvim_command('edit ' .. testfilename)
|
nvim_command('edit ' .. testfilename)
|
||||||
nvim_command('edit ' .. testfilename_2)
|
nvim_command('edit ' .. testfilename_2)
|
||||||
curbufmeths.set_option('buftype', 'quickfix')
|
curbufmeths.set_option('buftype', 'quickfix')
|
||||||
nvim_command('qall')
|
nvim_command('qall')
|
||||||
reset()
|
reset('set shada+=%')
|
||||||
eq(2, funcs.bufnr('$'))
|
eq(2, funcs.bufnr('$'))
|
||||||
eq('', funcs.bufname(1))
|
eq('', funcs.bufname(1))
|
||||||
eq(testfilename, funcs.bufname(2))
|
eq(testfilename, funcs.bufname(2))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('does not dump unnamed buffers', function()
|
it('does not dump unnamed buffers', function()
|
||||||
set_additional_cmd('set shada+=% hidden')
|
reset('set shada+=% hidden')
|
||||||
reset()
|
|
||||||
curbufmeths.set_lines(0, 1, true, {'foo'})
|
curbufmeths.set_lines(0, 1, true, {'foo'})
|
||||||
nvim_command('enew')
|
nvim_command('enew')
|
||||||
curbufmeths.set_lines(0, 1, true, {'bar'})
|
curbufmeths.set_lines(0, 1, true, {'bar'})
|
||||||
eq(2, funcs.bufnr('$'))
|
eq(2, funcs.bufnr('$'))
|
||||||
nvim_command('qall!')
|
nvim_command('qall!')
|
||||||
reset()
|
reset('set shada+=% hidden')
|
||||||
eq(1, funcs.bufnr('$'))
|
eq(1, funcs.bufnr('$'))
|
||||||
eq('', funcs.bufname(1))
|
eq('', funcs.bufname(1))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('restores 1 buffer with %1 in &shada, #5759', function()
|
it('restores 1 buffer with %1 in &shada, #5759', function()
|
||||||
set_additional_cmd('set shada+=%1')
|
reset('set shada+=%1')
|
||||||
reset()
|
|
||||||
nvim_command('edit ' .. testfilename)
|
nvim_command('edit ' .. testfilename)
|
||||||
nvim_command('edit ' .. testfilename_2)
|
nvim_command('edit ' .. testfilename_2)
|
||||||
nvim_command('qall')
|
nvim_command('qall')
|
||||||
reset()
|
reset('set shada+=%1')
|
||||||
eq(2, funcs.bufnr('$'))
|
eq(2, funcs.bufnr('$'))
|
||||||
eq('', funcs.bufname(1))
|
eq('', funcs.bufname(1))
|
||||||
eq(testfilename, funcs.bufname(2))
|
eq(testfilename, funcs.bufname(2))
|
||||||
|
@ -1,47 +1,39 @@
|
|||||||
local helpers = require('test.functional.helpers')(nil)
|
local helpers = require('test.functional.helpers')(nil)
|
||||||
local spawn, set_session, meths, nvim_prog =
|
local meths = helpers.meths
|
||||||
helpers.spawn, helpers.set_session, helpers.meths, helpers.nvim_prog
|
local write_file = helpers.write_file
|
||||||
local write_file, merge_args = helpers.write_file, helpers.merge_args
|
local concat_tables = helpers.concat_tables
|
||||||
|
|
||||||
local mpack = require('mpack')
|
local mpack = require('mpack')
|
||||||
|
|
||||||
local tmpname = helpers.tmpname()
|
local tmpname = helpers.tmpname()
|
||||||
local append_argv = nil
|
|
||||||
|
|
||||||
local function nvim_argv(shada_file, embed)
|
-- o={
|
||||||
if embed == nil then
|
-- args=…,
|
||||||
embed = true
|
-- args_rm=…,
|
||||||
|
-- shadafile=…,
|
||||||
|
-- }
|
||||||
|
local function reset(o)
|
||||||
|
assert(o == nil or type(o) == 'table' or type(o) == 'string')
|
||||||
|
o = o and o or {}
|
||||||
|
local args_rm = o.args_rm or {}
|
||||||
|
table.insert(args_rm, '-i')
|
||||||
|
local args={
|
||||||
|
'-i', o.shadafile or tmpname,
|
||||||
|
}
|
||||||
|
if type(o) == 'string' then
|
||||||
|
args = concat_tables(args, {'--cmd', o})
|
||||||
|
elseif o.args then
|
||||||
|
args = concat_tables(args, o.args)
|
||||||
end
|
end
|
||||||
local argv = {nvim_prog, '-u', 'NONE', '-i', shada_file or tmpname, '-N',
|
helpers.clear{
|
||||||
'--cmd', 'set shortmess+=I background=light noswapfile',
|
args_rm=args_rm,
|
||||||
'--headless', embed and '--embed' or nil}
|
args=args,
|
||||||
if helpers.prepend_argv or append_argv then
|
}
|
||||||
return merge_args(helpers.prepend_argv, argv, append_argv)
|
|
||||||
else
|
|
||||||
return argv
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local reset = function(shada_file)
|
|
||||||
set_session(spawn(nvim_argv(shada_file)))
|
|
||||||
meths.set_var('tmpname', tmpname)
|
meths.set_var('tmpname', tmpname)
|
||||||
end
|
end
|
||||||
|
|
||||||
local set_additional_cmd = function(s)
|
|
||||||
append_argv = {'--cmd', s}
|
|
||||||
end
|
|
||||||
|
|
||||||
local function add_argv(...)
|
|
||||||
if select('#', ...) == 0 then
|
|
||||||
append_argv = nil
|
|
||||||
else
|
|
||||||
append_argv = {...}
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local clear = function()
|
local clear = function()
|
||||||
os.remove(tmpname)
|
os.remove(tmpname)
|
||||||
append_argv = nil
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local get_shada_rw = function(fname)
|
local get_shada_rw = function(fname)
|
||||||
@ -89,10 +81,7 @@ end
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
reset=reset,
|
reset=reset,
|
||||||
set_additional_cmd=set_additional_cmd,
|
|
||||||
add_argv=add_argv,
|
|
||||||
clear=clear,
|
clear=clear,
|
||||||
get_shada_rw=get_shada_rw,
|
get_shada_rw=get_shada_rw,
|
||||||
read_shada_file=read_shada_file,
|
read_shada_file=read_shada_file,
|
||||||
nvim_argv=nvim_argv,
|
|
||||||
}
|
}
|
||||||
|
@ -6,11 +6,7 @@ local meths, curwinmeths, curbufmeths, nvim_command, funcs, eq =
|
|||||||
local exc_exec, redir_exec = helpers.exc_exec, helpers.redir_exec
|
local exc_exec, redir_exec = helpers.exc_exec, helpers.redir_exec
|
||||||
|
|
||||||
local shada_helpers = require('test.functional.shada.helpers')
|
local shada_helpers = require('test.functional.shada.helpers')
|
||||||
local reset, set_additional_cmd, clear =
|
local reset, clear = shada_helpers.reset, shada_helpers.clear
|
||||||
shada_helpers.reset, shada_helpers.set_additional_cmd,
|
|
||||||
shada_helpers.clear
|
|
||||||
local add_argv = shada_helpers.add_argv
|
|
||||||
local nvim_argv = shada_helpers.nvim_argv
|
|
||||||
|
|
||||||
local nvim_current_line = function()
|
local nvim_current_line = function()
|
||||||
return curwinmeths.get_cursor()[1]
|
return curwinmeths.get_cursor()[1]
|
||||||
@ -71,8 +67,7 @@ describe('ShaDa support code', function()
|
|||||||
nvim_command('2')
|
nvim_command('2')
|
||||||
nvim_command('kB')
|
nvim_command('kB')
|
||||||
nvim_command('wshada')
|
nvim_command('wshada')
|
||||||
set_additional_cmd('set shada=\'0,f0')
|
reset('set shada=\'0,f0')
|
||||||
reset()
|
|
||||||
nvim_command('language C')
|
nvim_command('language C')
|
||||||
nvim_command('normal! `A')
|
nvim_command('normal! `A')
|
||||||
eq(testfilename, funcs.fnamemodify(curbufmeths.get_name(), ':t'))
|
eq(testfilename, funcs.fnamemodify(curbufmeths.get_name(), ':t'))
|
||||||
@ -223,17 +218,32 @@ describe('ShaDa support code', function()
|
|||||||
-- during -c used to add item with zero lnum to jump list.
|
-- during -c used to add item with zero lnum to jump list.
|
||||||
it('does not create incorrect file for non-existent buffers when writing from -c',
|
it('does not create incorrect file for non-existent buffers when writing from -c',
|
||||||
function()
|
function()
|
||||||
add_argv('--cmd', 'silent edit ' .. non_existent_testfilename, '-c', 'qall')
|
local argv = helpers.new_argv{
|
||||||
local argv = nvim_argv(nil, false) -- no --embed
|
args_rm={
|
||||||
|
'-i',
|
||||||
|
'--embed', -- no --embed
|
||||||
|
},
|
||||||
|
args={
|
||||||
|
'-i', meths.get_var('tmpname'), -- Use same shada file as parent.
|
||||||
|
'--cmd', 'silent edit '..non_existent_testfilename,
|
||||||
|
'-c', 'qall'},
|
||||||
|
}
|
||||||
eq('', funcs.system(argv))
|
eq('', funcs.system(argv))
|
||||||
eq(0, exc_exec('rshada'))
|
eq(0, exc_exec('rshada'))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('does not create incorrect file for non-existent buffers opened from -c',
|
it('does not create incorrect file for non-existent buffers opened from -c',
|
||||||
function()
|
function()
|
||||||
add_argv('-c', 'silent edit ' .. non_existent_testfilename,
|
local argv = helpers.new_argv{
|
||||||
'-c', 'autocmd VimEnter * qall')
|
args_rm={
|
||||||
local argv = nvim_argv(nil, false) -- no --embed
|
'-i',
|
||||||
|
'--embed', -- no --embed
|
||||||
|
},
|
||||||
|
args={
|
||||||
|
'-i', meths.get_var('tmpname'), -- Use same shada file as parent.
|
||||||
|
'-c', 'silent edit '..non_existent_testfilename,
|
||||||
|
'-c', 'autocmd VimEnter * qall'},
|
||||||
|
}
|
||||||
eq('', funcs.system(argv))
|
eq('', funcs.system(argv))
|
||||||
eq(0, exc_exec('rshada'))
|
eq(0, exc_exec('rshada'))
|
||||||
end)
|
end)
|
||||||
|
@ -3,9 +3,7 @@ local helpers = require('test.functional.helpers')(after_each)
|
|||||||
local nvim_command, funcs, eq = helpers.command, helpers.funcs, helpers.eq
|
local nvim_command, funcs, eq = helpers.command, helpers.funcs, helpers.eq
|
||||||
|
|
||||||
local shada_helpers = require('test.functional.shada.helpers')
|
local shada_helpers = require('test.functional.shada.helpers')
|
||||||
local reset, set_additional_cmd, clear =
|
local reset, clear = shada_helpers.reset, shada_helpers.clear
|
||||||
shada_helpers.reset, shada_helpers.set_additional_cmd,
|
|
||||||
shada_helpers.clear
|
|
||||||
|
|
||||||
local setreg = function(name, contents, typ)
|
local setreg = function(name, contents, typ)
|
||||||
if type(contents) == 'string' then
|
if type(contents) == 'string' then
|
||||||
@ -52,9 +50,8 @@ describe('ShaDa support code', function()
|
|||||||
setreg('c', {'d', 'e', ''}, 'c')
|
setreg('c', {'d', 'e', ''}, 'c')
|
||||||
setreg('l', {'a', 'b', 'cde'}, 'l')
|
setreg('l', {'a', 'b', 'cde'}, 'l')
|
||||||
setreg('b', {'bca', 'abc', 'cba'}, 'b3')
|
setreg('b', {'bca', 'abc', 'cba'}, 'b3')
|
||||||
set_additional_cmd('set shada=\'0,<0')
|
|
||||||
nvim_command('qall')
|
nvim_command('qall')
|
||||||
reset()
|
reset('set shada=\'0,<0')
|
||||||
eq({{'d', 'e', ''}, 'v'}, getreg('c'))
|
eq({{'d', 'e', ''}, 'v'}, getreg('c'))
|
||||||
eq({{'a', 'b', 'cde'}, 'V'}, getreg('l'))
|
eq({{'a', 'b', 'cde'}, 'V'}, getreg('l'))
|
||||||
eq({{'bca', 'abc', 'cba'}, '\0223'}, getreg('b'))
|
eq({{'bca', 'abc', 'cba'}, '\0223'}, getreg('b'))
|
||||||
@ -76,9 +73,8 @@ describe('ShaDa support code', function()
|
|||||||
setreg('c', {'d', 'e', ''}, 'c')
|
setreg('c', {'d', 'e', ''}, 'c')
|
||||||
setreg('l', {'a', 'b', 'cde'}, 'l')
|
setreg('l', {'a', 'b', 'cde'}, 'l')
|
||||||
setreg('b', {'bca', 'abc', 'cba'}, 'b3')
|
setreg('b', {'bca', 'abc', 'cba'}, 'b3')
|
||||||
set_additional_cmd('set shada=\'0,\\"0')
|
|
||||||
nvim_command('qall')
|
nvim_command('qall')
|
||||||
reset()
|
reset('set shada=\'0,\\"0')
|
||||||
eq({{'d', 'e', ''}, 'v'}, getreg('c'))
|
eq({{'d', 'e', ''}, 'v'}, getreg('c'))
|
||||||
eq({{'a', 'b', 'cde'}, 'V'}, getreg('l'))
|
eq({{'a', 'b', 'cde'}, 'V'}, getreg('l'))
|
||||||
eq({{'bca', 'abc', 'cba'}, '\0223'}, getreg('b'))
|
eq({{'bca', 'abc', 'cba'}, '\0223'}, getreg('b'))
|
||||||
@ -142,7 +138,6 @@ describe('ShaDa support code', function()
|
|||||||
reset()
|
reset()
|
||||||
-- \171 is U+00AB LEFT-POINTING DOUBLE ANGLE QUOTATION MARK in latin1
|
-- \171 is U+00AB LEFT-POINTING DOUBLE ANGLE QUOTATION MARK in latin1
|
||||||
setreg('e', {'\171«'}, 'c')
|
setreg('e', {'\171«'}, 'c')
|
||||||
set_additional_cmd('')
|
|
||||||
nvim_command('qall')
|
nvim_command('qall')
|
||||||
reset()
|
reset()
|
||||||
eq({{'\171«'}, 'v'}, getreg('e'))
|
eq({{'\171«'}, 'v'}, getreg('e'))
|
||||||
|
@ -15,7 +15,6 @@ local shada_helpers = require('test.functional.shada.helpers')
|
|||||||
local reset, clear, get_shada_rw =
|
local reset, clear, get_shada_rw =
|
||||||
shada_helpers.reset, shada_helpers.clear, shada_helpers.get_shada_rw
|
shada_helpers.reset, shada_helpers.clear, shada_helpers.get_shada_rw
|
||||||
local read_shada_file = shada_helpers.read_shada_file
|
local read_shada_file = shada_helpers.read_shada_file
|
||||||
local set_additional_cmd = shada_helpers.set_additional_cmd
|
|
||||||
|
|
||||||
local wshada, _, shada_fname, clean =
|
local wshada, _, shada_fname, clean =
|
||||||
get_shada_rw('Xtest-functional-shada-shada.shada')
|
get_shada_rw('Xtest-functional-shada-shada.shada')
|
||||||
@ -244,8 +243,7 @@ describe('ShaDa support code', function()
|
|||||||
|
|
||||||
funcs.mkdir(dirname, '', 0)
|
funcs.mkdir(dirname, '', 0)
|
||||||
eq(0, funcs.filewritable(dirname))
|
eq(0, funcs.filewritable(dirname))
|
||||||
set_additional_cmd('set shada=')
|
reset{shadafile=dirshada, args={'--cmd', 'set shada='}}
|
||||||
reset(dirshada)
|
|
||||||
meths.set_option('shada', '\'10')
|
meths.set_option('shada', '\'10')
|
||||||
eq('Vim(wshada):E886: System error while opening ShaDa file '
|
eq('Vim(wshada):E886: System error while opening ShaDa file '
|
||||||
.. 'Xtest-functional-shada-shada.d/main.shada for reading to merge '
|
.. 'Xtest-functional-shada-shada.d/main.shada for reading to merge '
|
||||||
|
@ -4,9 +4,7 @@ local meths, funcs, nvim_command, eq, exc_exec =
|
|||||||
helpers.meths, helpers.funcs, helpers.command, helpers.eq, helpers.exc_exec
|
helpers.meths, helpers.funcs, helpers.command, helpers.eq, helpers.exc_exec
|
||||||
|
|
||||||
local shada_helpers = require('test.functional.shada.helpers')
|
local shada_helpers = require('test.functional.shada.helpers')
|
||||||
local reset, set_additional_cmd, clear =
|
local reset, clear = shada_helpers.reset, shada_helpers.clear
|
||||||
shada_helpers.reset, shada_helpers.set_additional_cmd,
|
|
||||||
shada_helpers.clear
|
|
||||||
|
|
||||||
describe('ShaDa support code', function()
|
describe('ShaDa support code', function()
|
||||||
before_each(reset)
|
before_each(reset)
|
||||||
@ -25,8 +23,7 @@ describe('ShaDa support code', function()
|
|||||||
local autotest = function(tname, varname, varval, val_is_expr)
|
local autotest = function(tname, varname, varval, val_is_expr)
|
||||||
it('is able to dump and read back ' .. tname .. ' variable automatically',
|
it('is able to dump and read back ' .. tname .. ' variable automatically',
|
||||||
function()
|
function()
|
||||||
set_additional_cmd('set shada+=!')
|
reset('set shada+=!')
|
||||||
reset()
|
|
||||||
if val_is_expr then
|
if val_is_expr then
|
||||||
nvim_command('let g:' .. varname .. ' = ' .. varval)
|
nvim_command('let g:' .. varname .. ' = ' .. varval)
|
||||||
varval = meths.get_var(varname)
|
varval = meths.get_var(varname)
|
||||||
@ -36,7 +33,7 @@ describe('ShaDa support code', function()
|
|||||||
-- Exit during `reset` is not a regular exit: it does not write shada
|
-- Exit during `reset` is not a regular exit: it does not write shada
|
||||||
-- automatically
|
-- automatically
|
||||||
nvim_command('qall')
|
nvim_command('qall')
|
||||||
reset()
|
reset('set shada+=!')
|
||||||
eq(varval, meths.get_var(varname))
|
eq(varval, meths.get_var(varname))
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
@ -55,8 +52,7 @@ describe('ShaDa support code', function()
|
|||||||
meths.set_var('STRVAR', 'foo')
|
meths.set_var('STRVAR', 'foo')
|
||||||
nvim_command('set shada+=!')
|
nvim_command('set shada+=!')
|
||||||
nvim_command('wshada')
|
nvim_command('wshada')
|
||||||
set_additional_cmd('set shada-=!')
|
reset('set shada-=!')
|
||||||
reset()
|
|
||||||
nvim_command('rshada')
|
nvim_command('rshada')
|
||||||
eq(0, funcs.exists('g:STRVAR'))
|
eq(0, funcs.exists('g:STRVAR'))
|
||||||
end)
|
end)
|
||||||
@ -98,7 +94,6 @@ describe('ShaDa support code', function()
|
|||||||
meths.set_var('LSTVAR', {'«'})
|
meths.set_var('LSTVAR', {'«'})
|
||||||
meths.set_var('DCTVAR', {['«']='«'})
|
meths.set_var('DCTVAR', {['«']='«'})
|
||||||
meths.set_var('NESTEDVAR', {['«']={{'«'}, {['«']='«'}, {a='Test'}}})
|
meths.set_var('NESTEDVAR', {['«']={{'«'}, {['«']='«'}, {a='Test'}}})
|
||||||
set_additional_cmd('')
|
|
||||||
nvim_command('qall')
|
nvim_command('qall')
|
||||||
reset()
|
reset()
|
||||||
eq('«', meths.get_var('STRVAR'))
|
eq('«', meths.get_var('STRVAR'))
|
||||||
@ -131,11 +126,10 @@ describe('ShaDa support code', function()
|
|||||||
nvim_command('let F = function("tr")')
|
nvim_command('let F = function("tr")')
|
||||||
meths.set_var('U', '10')
|
meths.set_var('U', '10')
|
||||||
nvim_command('set shada+=!')
|
nvim_command('set shada+=!')
|
||||||
set_additional_cmd('set shada+=!')
|
|
||||||
eq('Vim(wshada):E5004: Error while dumping variable g:F, itself: attempt to dump function reference',
|
eq('Vim(wshada):E5004: Error while dumping variable g:F, itself: attempt to dump function reference',
|
||||||
exc_exec('wshada'))
|
exc_exec('wshada'))
|
||||||
meths.set_option('shada', '')
|
meths.set_option('shada', '')
|
||||||
reset()
|
reset('set shada+=!')
|
||||||
eq('10', meths.get_var('U'))
|
eq('10', meths.get_var('U'))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@ -148,8 +142,7 @@ describe('ShaDa support code', function()
|
|||||||
eq('Vim(wshada):E5005: Unable to dump variable g:L: container references itself in index 0',
|
eq('Vim(wshada):E5005: Unable to dump variable g:L: container references itself in index 0',
|
||||||
exc_exec('wshada'))
|
exc_exec('wshada'))
|
||||||
meths.set_option('shada', '')
|
meths.set_option('shada', '')
|
||||||
set_additional_cmd('set shada+=!')
|
reset('set shada+=!')
|
||||||
reset()
|
|
||||||
eq('10', meths.get_var('U'))
|
eq('10', meths.get_var('U'))
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
Loading…
Reference in New Issue
Block a user