aboutsummaryrefslogtreecommitdiff
path: root/test/functional/shada
diff options
context:
space:
mode:
Diffstat (limited to 'test/functional/shada')
-rw-r--r--test/functional/shada/compatibility_spec.lua4
-rw-r--r--test/functional/shada/helpers.lua20
-rw-r--r--test/functional/shada/registers_spec.lua18
-rw-r--r--test/functional/shada/shada_spec.lua16
-rw-r--r--test/functional/shada/variables_spec.lua13
5 files changed, 36 insertions, 35 deletions
diff --git a/test/functional/shada/compatibility_spec.lua b/test/functional/shada/compatibility_spec.lua
index 2ca0b16e75..1fa88c58e5 100644
--- a/test/functional/shada/compatibility_spec.lua
+++ b/test/functional/shada/compatibility_spec.lua
@@ -270,9 +270,7 @@ describe('ShaDa forward compatibility support code', function()
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)))
- -- 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.getreg('a', 1, 1))
eq('', funcs.getregtype('a'))
nvim_command('wshada ' .. shada_fname)
local found = 0
diff --git a/test/functional/shada/helpers.lua b/test/functional/shada/helpers.lua
index 146ae8d51e..d4eb7f57bd 100644
--- a/test/functional/shada/helpers.lua
+++ b/test/functional/shada/helpers.lua
@@ -3,7 +3,7 @@ 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')
+local mpack = require('mpack')
local tmpname = os.tmpname()
local additional_cmd = ''
@@ -20,14 +20,8 @@ local function nvim_argv()
end
end
-local session = nil
-
local reset = function()
- if session then
- session:exit(0)
- end
- session = spawn(nvim_argv())
- set_session(session)
+ set_session(spawn(nvim_argv()))
meths.set_var('tmpname', tmpname)
end
@@ -66,13 +60,13 @@ local read_shada_file = function(fname)
local fd = io.open(fname, 'r')
local mstring = fd:read('*a')
fd:close()
- local unpacker = msgpack.unpacker(mstring)
+ local unpack = mpack.Unpacker()
local ret = {}
- local cur
+ local cur, val
local i = 0
- while true do
- local off, val = unpacker()
- if not off then break end
+ local off = 1
+ while off <= #mstring do
+ val, off = unpack(mstring, off)
if i % 4 == 0 then
cur = {}
ret[#ret + 1] = cur
diff --git a/test/functional/shada/registers_spec.lua b/test/functional/shada/registers_spec.lua
index f0133b1086..4043d94a69 100644
--- a/test/functional/shada/registers_spec.lua
+++ b/test/functional/shada/registers_spec.lua
@@ -43,9 +43,9 @@ describe('ShaDa support code', function()
setreg('b', {'bca', 'abc', 'cba'}, 'b3')
nvim_command('qall')
reset()
- eq({nil, ''}, getreg('c'))
- eq({nil, ''}, getreg('l'))
- eq({nil, ''}, getreg('b'))
+ eq({{}, ''}, getreg('c'))
+ eq({{}, ''}, getreg('l'))
+ eq({{}, ''}, getreg('b'))
end)
it('does restore registers with zero <', function()
@@ -67,9 +67,9 @@ describe('ShaDa support code', function()
setreg('b', {'bca', 'abc', 'cba'}, 'b3')
nvim_command('qall')
reset()
- eq({nil, ''}, getreg('c'))
- eq({nil, ''}, getreg('l'))
- eq({nil, ''}, getreg('b'))
+ eq({{}, ''}, getreg('c'))
+ eq({{}, ''}, getreg('l'))
+ eq({{}, ''}, getreg('b'))
end)
it('does restore registers with zero "', function()
@@ -103,7 +103,7 @@ describe('ShaDa support code', function()
nvim_command('qall')
reset()
eq({{'d'}, 'v'}, getreg('o'))
- eq({nil, ''}, getreg('t'))
+ eq({{}, ''}, getreg('t'))
end)
it('does limit number of lines according to "', function()
@@ -113,7 +113,7 @@ describe('ShaDa support code', function()
nvim_command('qall')
reset()
eq({{'d'}, 'v'}, getreg('o'))
- eq({nil, ''}, getreg('t'))
+ eq({{}, ''}, getreg('t'))
end)
it('does limit number of lines according to < rather then "', function()
@@ -125,7 +125,7 @@ describe('ShaDa support code', function()
reset()
eq({{'d'}, 'v'}, getreg('o'))
eq({{'a', 'b', 'cde'}, 'V'}, getreg('t'))
- eq({nil, ''}, getreg('h'))
+ eq({{}, ''}, getreg('h'))
end)
it('dumps and loads register correctly when &encoding is not UTF-8',
diff --git a/test/functional/shada/shada_spec.lua b/test/functional/shada/shada_spec.lua
index 822ab3913c..683d520627 100644
--- a/test/functional/shada/shada_spec.lua
+++ b/test/functional/shada/shada_spec.lua
@@ -8,7 +8,7 @@ local write_file, spawn, set_session, nvim_prog, exc_exec =
local lfs = require('lfs')
local paths = require('test.config.paths')
-local msgpack = require('MessagePack')
+local mpack = require('mpack')
local shada_helpers = require('test.functional.shada.helpers')
local reset, clear, get_shada_rw =
@@ -107,7 +107,7 @@ describe('ShaDa support code', function()
end)
it('reads correctly various timestamps', function()
- local mpack = {
+ local msgpack = {
'\100', -- Positive fixnum 100
'\204\255', -- uint 8 255
'\205\010\003', -- uint 16 2563
@@ -116,23 +116,23 @@ describe('ShaDa support code', function()
}
local s = '\100'
local e = '\001\192'
- wshada(s .. table.concat(mpack, e .. s) .. e)
+ wshada(s .. table.concat(msgpack, e .. s) .. e)
eq(0, exc_exec('wshada ' .. shada_fname))
local found = 0
- local typ = select(2, msgpack.unpacker(s)())
+ local typ = mpack.unpack(s)
for _, v in ipairs(read_shada_file(shada_fname)) do
if v.type == typ then
found = found + 1
- eq(select(2, msgpack.unpacker(mpack[found])()), v.timestamp)
+ eq(mpack.unpack(msgpack[found]), v.timestamp)
end
end
- eq(#mpack, found)
+ eq(#msgpack, found)
end)
it('does not write NONE file', function()
local session = spawn({nvim_prog, '-u', 'NONE', '-i', 'NONE', '--embed',
'--cmd', 'qall'}, true)
- session:exit(0)
+ session:close()
eq(nil, lfs.attributes('NONE'))
eq(nil, lfs.attributes('NONE.tmp.a'))
end)
@@ -143,7 +143,7 @@ describe('ShaDa support code', function()
true)
set_session(session)
eq('', funcs.getreg('a'))
- session:exit(0)
+ session:close()
os.remove('NONE')
end)
diff --git a/test/functional/shada/variables_spec.lua b/test/functional/shada/variables_spec.lua
index 3becf1bc32..7ceeafdc71 100644
--- a/test/functional/shada/variables_spec.lua
+++ b/test/functional/shada/variables_spec.lua
@@ -22,12 +22,17 @@ describe('ShaDa support code', function()
eq('foo', meths.get_var('STRVAR'))
end)
- local autotest = function(tname, varname, varval)
+ local autotest = function(tname, varname, varval, val_is_expr)
it('is able to dump and read back ' .. tname .. ' variable automatically',
function()
set_additional_cmd('set shada+=!')
reset()
- meths.set_var(varname, varval)
+ if val_is_expr then
+ nvim_command('let g:' .. varname .. ' = ' .. varval)
+ varval = meths.get_var(varname)
+ else
+ meths.set_var(varname, varval)
+ end
-- Exit during `reset` is not a regular exit: it does not write shada
-- automatically
nvim_command('qall')
@@ -41,6 +46,10 @@ describe('ShaDa support code', function()
autotest('float', 'FLTVAR', 42.5)
autotest('dictionary', 'DCTVAR', {a=10})
autotest('list', 'LSTVAR', {{a=10}, {b=10.5}, {c='str'}})
+ autotest('true', 'TRUEVAR', true)
+ autotest('false', 'FALSEVAR', false)
+ autotest('null', 'NULLVAR', 'v:null', true)
+ autotest('ext', 'EXTVAR', '{"_TYPE": v:msgpack_types.ext, "_VAL": [2, ["", ""]]}', true)
it('does not read back variables without `!` in &shada', function()
meths.set_var('STRVAR', 'foo')