shada: Make sure that NIL and EXT values can also be parsed back

Note: currently they are both *dumped*, but parsing them produces an error. This
is inappropriate: variables should either be skipped with error message when
dumping or should be read back properly.

It also appears that I did not have test for “has wrong variable value type”
error, so nothing got removed from errors_spec.
This commit is contained in:
ZyX
2016-02-06 21:03:33 +03:00
parent 0aa3e7b7ce
commit d4106f6df3
2 changed files with 11 additions and 8 deletions

View File

@@ -3883,12 +3883,6 @@ shada_read_next_item_hist_no_conv:
initial_fpos);
goto shada_read_next_item_error;
}
if (unpacked.data.via.array.ptr[1].type == MSGPACK_OBJECT_NIL
|| unpacked.data.via.array.ptr[1].type == MSGPACK_OBJECT_EXT) {
emsgu(_(READERR("variable", "has wrong variable value type")),
initial_fpos);
goto shada_read_next_item_error;
}
entry->data.global_var.name =
xmemdupz(unpacked.data.via.array.ptr[0].via.bin.ptr,
unpacked.data.via.array.ptr[0].via.bin.size);

View File

@@ -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()
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')