aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/functional/shada/errors_spec.lua95
-rw-r--r--test/unit/eval/encode_spec.lua36
2 files changed, 38 insertions, 93 deletions
diff --git a/test/functional/shada/errors_spec.lua b/test/functional/shada/errors_spec.lua
index e000d0988b..321744f7dd 100644
--- a/test/functional/shada/errors_spec.lua
+++ b/test/functional/shada/errors_spec.lua
@@ -58,7 +58,7 @@ describe('ShaDa error handling', function()
it('fails on search pattern item with zero length', function()
wshada('\002\000\000')
eq(
- 'Vim(rshada):E576: Failed to parse ShaDa file: incomplete msgpack string at position 3',
+ 'Vim(rshada):E575: Error while reading ShaDa file: search pattern entry at position 0 is not a dictionary',
exc_exec(sdrcmd())
)
end)
@@ -89,18 +89,10 @@ describe('ShaDa error handling', function()
it('fails on search pattern item with invalid byte', function()
-- 195 (== 0xC1) cannot start any valid messagepack entry (the only byte
- -- that cannot do this). Specifically unpack_template.h contains
- --
- -- //case 0xc1: // string
- -- // again_terminal_trail(NEXT_CS(p), p+1);
- --
- -- (literally: commented out code) which means that in place of this code
- -- `goto _failed` is used from default: case. I do not know any other way to
- -- get MSGPACK_UNPACK_PARSE_ERROR and not MSGPACK_UNPACK_CONTINUE or
- -- MSGPACK_UNPACK_EXTRA_BYTES.
+ -- that cannot do this)
wshada('\002\000\001\193')
eq(
- 'Vim(rshada):E576: Failed to parse ShaDa file due to a msgpack parser error at position 3',
+ 'Vim(rshada):E575: Error while reading ShaDa file: search pattern entry at position 0 is not a dictionary',
exc_exec(sdrcmd())
)
end)
@@ -108,7 +100,7 @@ describe('ShaDa error handling', function()
it('fails on search pattern item with incomplete map', function()
wshada('\002\000\001\129')
eq(
- 'Vim(rshada):E576: Failed to parse ShaDa file: incomplete msgpack string at position 3',
+ 'Vim(rshada):E575: Error while reading ShaDa file: search pattern entry at position 0 has key value which is not a string',
exc_exec(sdrcmd())
)
end)
@@ -124,7 +116,7 @@ describe('ShaDa error handling', function()
it('fails on search pattern with extra bytes', function()
wshada('\002\000\002\128\000')
eq(
- 'Vim(rshada):E576: Failed to parse ShaDa file: extra bytes in msgpack string at position 3',
+ 'Vim(rshada):E575: Error while reading ShaDa file: search pattern entry at position 0 has no pattern',
exc_exec(sdrcmd())
)
end)
@@ -138,15 +130,6 @@ describe('ShaDa error handling', function()
end)
-- sp entry is here because it causes an allocation.
- it('fails on search pattern item with BIN key', function()
- wshada('\002\000\014\131\162sp\196\001a\162sX\192\196\000\000')
- eq(
- 'Vim(rshada):E575: Error while reading ShaDa file: search pattern entry at position 0 has key which is not a string',
- exc_exec(sdrcmd())
- )
- end)
-
- -- sp entry is here because it causes an allocation.
it('fails on search pattern item with empty key', function()
wshada('\002\000\013\131\162sp\196\001a\162sX\192\160\000')
eq(
@@ -235,22 +218,12 @@ describe('ShaDa error handling', function()
)
end)
- it('fails on search pattern item with STR pat key value', function()
- wshada('\002\000\011\130\162sX\192\162sp\162sp')
- eq(
- 'Vim(rshada):E575: Error while reading ShaDa file: search pattern entry at position 0 has sp key value which is not a binary',
- exc_exec(sdrcmd())
- )
- end)
-
for _, v in ipairs({
{ name = 'global mark', mpack = '\007' },
{ name = 'jump', mpack = '\008' },
{ name = 'local mark', mpack = '\010' },
{ name = 'change', mpack = '\011' },
}) do
- local is_mark_test = ({ ['global mark'] = true, ['local mark'] = true })[v.name]
-
it('fails on ' .. v.name .. ' item with NIL value', function()
wshada(v.mpack .. '\000\001\192')
eq(
@@ -260,15 +233,6 @@ describe('ShaDa error handling', function()
end)
-- f entry is here because it causes an allocation.
- it('fails on ' .. v.name .. ' item with BIN key', function()
- wshada(v.mpack .. '\000\013\131\161f\196\001/\162mX\192\196\000\000')
- eq(
- 'Vim(rshada):E575: Error while reading ShaDa file: mark entry at position 0 has key which is not a string',
- exc_exec(sdrcmd())
- )
- end)
-
- -- f entry is here because it causes an allocation.
it('fails on ' .. v.name .. ' item with empty key', function()
wshada(v.mpack .. '\000\012\131\161f\196\001/\162mX\192\160\000')
eq(
@@ -312,9 +276,7 @@ describe('ShaDa error handling', function()
it('fails on ' .. v.name .. ' item with STR n key value', function()
wshada(v.mpack .. '\000\011\130\162mX\192\161n\163spa')
eq(
- is_mark_test
- and 'Vim(rshada):E575: Error while reading ShaDa file: mark entry at position 0 has n key value which is not an unsigned integer'
- or 'Vim(rshada):E575: Error while reading ShaDa file: mark entry at position 0 has n key which is only valid for local and global mark entries',
+ 'Vim(rshada):E575: Error while reading ShaDa file: mark entry at position 0 has n key value which is not an integer',
exc_exec(sdrcmd())
)
end)
@@ -334,14 +296,6 @@ describe('ShaDa error handling', function()
exc_exec(sdrcmd())
)
end)
-
- it('fails on ' .. v.name .. ' item with STR f key value', function()
- wshada(v.mpack .. '\000\010\130\162mX\192\161f\162sp')
- eq(
- 'Vim(rshada):E575: Error while reading ShaDa file: mark entry at position 0 has f key value which is not a binary',
- exc_exec(sdrcmd())
- )
- end)
end
it('fails on register item with NIL value', function()
@@ -354,15 +308,6 @@ describe('ShaDa error handling', function()
-- rc entry is here because it causes an allocation
it('fails on register item with BIN key', function()
- wshada('\005\000\015\131\162rc\145\196\001a\162rX\192\196\000\000')
- eq(
- 'Vim(rshada):E575: Error while reading ShaDa file: register entry at position 0 has key which is not a string',
- exc_exec(sdrcmd())
- )
- end)
-
- -- rc entry is here because it causes an allocation
- it('fails on register item with BIN key', function()
wshada('\005\000\014\131\162rc\145\196\001a\162rX\192\160\000')
eq(
'Vim(rshada):E575: Error while reading ShaDa file: register entry at position 0 has empty key',
@@ -373,7 +318,7 @@ describe('ShaDa error handling', function()
it('fails on register item with NIL rt key value', function()
wshada('\005\000\009\130\162rX\192\162rt\192')
eq(
- 'Vim(rshada):E575: Error while reading ShaDa file: register entry at position 0 has rt key value which is not an unsigned integer',
+ 'Vim(rshada):E575: Error while reading ShaDa file: register entry at position 0 has rt key value which is not an integer',
exc_exec(sdrcmd())
)
end)
@@ -381,7 +326,7 @@ describe('ShaDa error handling', function()
it('fails on register item with NIL rw key value', function()
wshada('\005\000\009\130\162rX\192\162rw\192')
eq(
- 'Vim(rshada):E575: Error while reading ShaDa file: register entry at position 0 has rw key value which is not an unsigned integer',
+ 'Vim(rshada):E575: Error while reading ShaDa file: register entry at position 0 has rw key value which is not an integer',
exc_exec(sdrcmd())
)
end)
@@ -397,7 +342,7 @@ describe('ShaDa error handling', function()
it('fails on register item with empty rc key value', function()
wshada('\005\000\009\130\162rX\192\162rc\144')
eq(
- 'Vim(rshada):E575: Error while reading ShaDa file: register entry at position 0 has rc key with empty array',
+ 'Vim(rshada):E575: Error while reading ShaDa file: register entry at position 0 has rc key with missing or empty array',
exc_exec(sdrcmd())
)
end)
@@ -413,7 +358,7 @@ describe('ShaDa error handling', function()
it('fails on register item without rc array', function()
wshada('\005\000\009\129\162rX\146\196\001a\192')
eq(
- 'Vim(rshada):E575: Error while reading ShaDa file: register entry at position 0 has missing rc array',
+ 'Vim(rshada):E575: Error while reading ShaDa file: register entry at position 0 has rc key with missing or empty array',
exc_exec(sdrcmd())
)
end)
@@ -421,7 +366,7 @@ describe('ShaDa error handling', function()
it('fails on history item with NIL value', function()
wshada('\004\000\001\192')
eq(
- 'Vim(rshada):E575: Error while reading ShaDa file: history entry at position 0 is not an array',
+ 'Vim(rshada):E575: Error while reading ShaDa file: history entry at position 0 is not an array with enough elements',
exc_exec(sdrcmd())
)
end)
@@ -429,7 +374,7 @@ describe('ShaDa error handling', function()
it('fails on history item with empty value', function()
wshada('\004\000\001\144')
eq(
- 'Vim(rshada):E575: Error while reading ShaDa file: history entry at position 0 does not have enough elements',
+ 'Vim(rshada):E575: Error while reading ShaDa file: history entry at position 0 is not an array with enough elements',
exc_exec(sdrcmd())
)
end)
@@ -437,7 +382,7 @@ describe('ShaDa error handling', function()
it('fails on history item with single element value', function()
wshada('\004\000\002\145\000')
eq(
- 'Vim(rshada):E575: Error while reading ShaDa file: history entry at position 0 does not have enough elements',
+ 'Vim(rshada):E575: Error while reading ShaDa file: history entry at position 0 is not an array with enough elements',
exc_exec(sdrcmd())
)
end)
@@ -485,7 +430,7 @@ describe('ShaDa error handling', function()
it('fails on variable item with NIL value', function()
wshada('\006\000\001\192')
eq(
- 'Vim(rshada):E575: Error while reading ShaDa file: variable entry at position 0 is not an array',
+ 'Vim(rshada):E575: Error while reading ShaDa file: variable entry at position 0 is not an array with enough elements',
exc_exec(sdrcmd())
)
end)
@@ -493,7 +438,7 @@ describe('ShaDa error handling', function()
it('fails on variable item with empty value', function()
wshada('\006\000\001\144')
eq(
- 'Vim(rshada):E575: Error while reading ShaDa file: variable entry at position 0 does not have enough elements',
+ 'Vim(rshada):E575: Error while reading ShaDa file: variable entry at position 0 is not an array with enough elements',
exc_exec(sdrcmd())
)
end)
@@ -501,7 +446,7 @@ describe('ShaDa error handling', function()
it('fails on variable item with single element value', function()
wshada('\006\000\002\145\000')
eq(
- 'Vim(rshada):E575: Error while reading ShaDa file: variable entry at position 0 does not have enough elements',
+ 'Vim(rshada):E575: Error while reading ShaDa file: variable entry at position 0 is not an array with enough elements',
exc_exec(sdrcmd())
)
end)
@@ -525,7 +470,7 @@ describe('ShaDa error handling', function()
it('fails on replacement item with NIL value', function()
wshada('\003\000\001\192')
eq(
- 'Vim(rshada):E575: Error while reading ShaDa file: sub string entry at position 0 is not an array',
+ 'Vim(rshada):E575: Error while reading ShaDa file: sub string entry at position 0 is not an array with enough elements',
exc_exec(sdrcmd())
)
end)
@@ -533,7 +478,7 @@ describe('ShaDa error handling', function()
it('fails on replacement item with empty value', function()
wshada('\003\000\001\144')
eq(
- 'Vim(rshada):E575: Error while reading ShaDa file: sub string entry at position 0 does not have enough elements',
+ 'Vim(rshada):E575: Error while reading ShaDa file: sub string entry at position 0 is not an array with enough elements',
exc_exec(sdrcmd())
)
end)
@@ -577,7 +522,7 @@ describe('ShaDa error handling', function()
nvim_command('set shada+=%')
wshada('\009\000\017\146\129\161f\196\001/\130\161f\196\002/a\161l\192')
eq(
- 'Vim(rshada):E575: Error while reading ShaDa file: buffer list entry entry at position 0 has l key value which is not an integer',
+ 'Vim(rshada):E575: Error while reading ShaDa file: buffer list at position 0 contains entry that has l key value which is not an integer',
exc_exec(sdrcmd())
)
end)
@@ -613,7 +558,7 @@ describe('ShaDa error handling', function()
nvim_command('set shada+=%')
wshada('\009\000\017\146\129\161f\196\001/\130\161f\196\002/a\161c\192')
eq(
- 'Vim(rshada):E575: Error while reading ShaDa file: buffer list entry entry at position 0 has c key value which is not an integer',
+ 'Vim(rshada):E575: Error while reading ShaDa file: buffer list at position 0 contains entry that has c key value which is not an integer',
exc_exec(sdrcmd())
)
end)
diff --git a/test/unit/eval/encode_spec.lua b/test/unit/eval/encode_spec.lua
index 5b9188163e..9f193bc2f9 100644
--- a/test/unit/eval/encode_spec.lua
+++ b/test/unit/eval/encode_spec.lua
@@ -21,81 +21,81 @@ describe('encode_list_write()', function()
itp('writes empty string', function()
local l = list()
- eq(0, encode_list_write(l, ''))
+ encode_list_write(l, '')
eq({ [type_key] = list_type }, lst2tbl(l))
end)
itp('writes ASCII string literal with printable characters', function()
local l = list()
- eq(0, encode_list_write(l, 'abc'))
+ encode_list_write(l, 'abc')
eq({ 'abc' }, lst2tbl(l))
end)
itp('writes string starting with NL', function()
local l = list()
- eq(0, encode_list_write(l, '\nabc'))
+ encode_list_write(l, '\nabc')
eq({ null_string, 'abc' }, lst2tbl(l))
end)
itp('writes string starting with NL twice', function()
local l = list()
- eq(0, encode_list_write(l, '\nabc'))
+ encode_list_write(l, '\nabc')
eq({ null_string, 'abc' }, lst2tbl(l))
- eq(0, encode_list_write(l, '\nabc'))
+ encode_list_write(l, '\nabc')
eq({ null_string, 'abc', 'abc' }, lst2tbl(l))
end)
itp('writes string ending with NL', function()
local l = list()
- eq(0, encode_list_write(l, 'abc\n'))
+ encode_list_write(l, 'abc\n')
eq({ 'abc', null_string }, lst2tbl(l))
end)
itp('writes string ending with NL twice', function()
local l = list()
- eq(0, encode_list_write(l, 'abc\n'))
+ encode_list_write(l, 'abc\n')
eq({ 'abc', null_string }, lst2tbl(l))
- eq(0, encode_list_write(l, 'abc\n'))
+ encode_list_write(l, 'abc\n')
eq({ 'abc', 'abc', null_string }, lst2tbl(l))
end)
itp('writes string starting, ending and containing NL twice', function()
local l = list()
- eq(0, encode_list_write(l, '\na\nb\n'))
+ encode_list_write(l, '\na\nb\n')
eq({ null_string, 'a', 'b', null_string }, lst2tbl(l))
- eq(0, encode_list_write(l, '\na\nb\n'))
+ encode_list_write(l, '\na\nb\n')
eq({ null_string, 'a', 'b', null_string, 'a', 'b', null_string }, lst2tbl(l))
end)
itp('writes string starting, ending and containing NUL with NL between twice', function()
local l = list()
- eq(0, encode_list_write(l, '\0\n\0\n\0'))
+ encode_list_write(l, '\0\n\0\n\0')
eq({ '\n', '\n', '\n' }, lst2tbl(l))
- eq(0, encode_list_write(l, '\0\n\0\n\0'))
+ encode_list_write(l, '\0\n\0\n\0')
eq({ '\n', '\n', '\n\n', '\n', '\n' }, lst2tbl(l))
end)
itp('writes string starting, ending and containing NL with NUL between twice', function()
local l = list()
- eq(0, encode_list_write(l, '\n\0\n\0\n'))
+ encode_list_write(l, '\n\0\n\0\n')
eq({ null_string, '\n', '\n', null_string }, lst2tbl(l))
- eq(0, encode_list_write(l, '\n\0\n\0\n'))
+ encode_list_write(l, '\n\0\n\0\n')
eq({ null_string, '\n', '\n', null_string, '\n', '\n', null_string }, lst2tbl(l))
end)
itp('writes string containing a single NL twice', function()
local l = list()
- eq(0, encode_list_write(l, '\n'))
+ encode_list_write(l, '\n')
eq({ null_string, null_string }, lst2tbl(l))
- eq(0, encode_list_write(l, '\n'))
+ encode_list_write(l, '\n')
eq({ null_string, null_string, null_string }, lst2tbl(l))
end)
itp('writes string containing a few NLs twice', function()
local l = list()
- eq(0, encode_list_write(l, '\n\n\n'))
+ encode_list_write(l, '\n\n\n')
eq({ null_string, null_string, null_string, null_string }, lst2tbl(l))
- eq(0, encode_list_write(l, '\n\n\n'))
+ encode_list_write(l, '\n\n\n')
eq(
{ null_string, null_string, null_string, null_string, null_string, null_string, null_string },
lst2tbl(l)