refactor(test): drop deprecated exc_exec #39242

This commit is contained in:
Justin M. Keyes
2026-04-20 14:16:41 -04:00
committed by GitHub
parent faa7c15b5a
commit 4ceca862fc
77 changed files with 1009 additions and 799 deletions

View File

@@ -1,4 +1,5 @@
local t = require('test.testutil')
local pcall_err = t.pcall_err
local n = require('test.functional.testnvim')()
local clear = n.clear
@@ -6,7 +7,6 @@ local fn = n.fn
local eval, eq = n.eval, t.eq
local command = n.command
local api = n.api
local exc_exec = n.exc_exec
describe('msgpack*() functions', function()
setup(clear)
@@ -480,42 +480,42 @@ describe('msgpackparse() function', function()
it('fails when called with no arguments', function()
eq(
'Vim(call):E119: Not enough arguments for function: msgpackparse',
exc_exec('call msgpackparse()')
pcall_err(command, 'call msgpackparse()')
)
end)
it('fails when called with two arguments', function()
eq(
'Vim(call):E118: Too many arguments for function: msgpackparse',
exc_exec('call msgpackparse(["", ""], 1)')
pcall_err(command, 'call msgpackparse(["", ""], 1)')
)
end)
it('fails to parse a string', function()
eq(
'Vim(call):E899: Argument of msgpackparse() must be a List or Blob',
exc_exec('call msgpackparse("abcdefghijklmnopqrstuvwxyz")')
pcall_err(command, 'call msgpackparse("abcdefghijklmnopqrstuvwxyz")')
)
end)
it('fails to parse a number', function()
eq(
'Vim(call):E899: Argument of msgpackparse() must be a List or Blob',
exc_exec('call msgpackparse(127)')
pcall_err(command, 'call msgpackparse(127)')
)
end)
it('fails to parse a dict', function()
eq(
'Vim(call):E899: Argument of msgpackparse() must be a List or Blob',
exc_exec('call msgpackparse({})')
pcall_err(command, 'call msgpackparse({})')
)
end)
it('fails to parse a funcref', function()
eq(
'Vim(call):E899: Argument of msgpackparse() must be a List or Blob',
exc_exec('call msgpackparse(function("tr"))')
pcall_err(command, 'call msgpackparse(function("tr"))')
)
end)
@@ -523,29 +523,29 @@ describe('msgpackparse() function', function()
command('function! T() dict\nendfunction')
eq(
'Vim(call):E899: Argument of msgpackparse() must be a List or Blob',
exc_exec('call msgpackparse(function("T", [1, 2], {}))')
pcall_err(command, 'call msgpackparse(function("T", [1, 2], {}))')
)
end)
it('fails to parse a float', function()
eq(
'Vim(call):E899: Argument of msgpackparse() must be a List or Blob',
exc_exec('call msgpackparse(0.0)')
pcall_err(command, 'call msgpackparse(0.0)')
)
end)
it('fails on incomplete msgpack string', function()
local expected = 'Vim(call):E475: Invalid argument: Incomplete msgpack string'
eq(expected, exc_exec([[call msgpackparse(["\xc4"])]]))
eq(expected, exc_exec([[call msgpackparse(["\xca", "\x02\x03"])]]))
eq(expected, exc_exec('call msgpackparse(0zc4)'))
eq(expected, exc_exec('call msgpackparse(0zca0a0203)'))
eq(expected, pcall_err(command, [[call msgpackparse(["\xc4"])]]))
eq(expected, pcall_err(command, [[call msgpackparse(["\xca", "\x02\x03"])]]))
eq(expected, pcall_err(command, 'call msgpackparse(0zc4)'))
eq(expected, pcall_err(command, 'call msgpackparse(0zca0a0203)'))
end)
it('fails when unable to parse msgpack string', function()
local expected = 'Vim(call):E475: Invalid argument: Failed to parse msgpack string'
eq(expected, exc_exec([[call msgpackparse(["\xc1"])]]))
eq(expected, exc_exec('call msgpackparse(0zc1)'))
eq(expected, pcall_err(command, [[call msgpackparse(["\xc1"])]]))
eq(expected, pcall_err(command, 'call msgpackparse(0zc1)'))
end)
end)
@@ -626,7 +626,7 @@ describe('msgpackdump() function', function()
command('let Todump = function("tr")')
eq(
'Vim(call):E5004: Error while dumping msgpackdump() argument, index 0, itself: attempt to dump function reference',
exc_exec('call msgpackdump([Todump])')
pcall_err(command, 'call msgpackdump([Todump])')
)
end)
@@ -635,7 +635,7 @@ describe('msgpackdump() function', function()
command('let Todump = function("T", [1, 2], {})')
eq(
'Vim(call):E5004: Error while dumping msgpackdump() argument, index 0, itself: attempt to dump function reference',
exc_exec('call msgpackdump([Todump])')
pcall_err(command, 'call msgpackdump([Todump])')
)
end)
@@ -643,7 +643,7 @@ describe('msgpackdump() function', function()
command('let todump = [function("tr")]')
eq(
'Vim(call):E5004: Error while dumping msgpackdump() argument, index 0, index 0: attempt to dump function reference',
exc_exec('call msgpackdump([todump])')
pcall_err(command, 'call msgpackdump([todump])')
)
end)
@@ -652,7 +652,7 @@ describe('msgpackdump() function', function()
command('call add(todump[0][0], todump)')
eq(
'Vim(call):E5005: Unable to dump msgpackdump() argument, index 0: container references itself in index 0, index 0, index 0',
exc_exec('call msgpackdump([todump])')
pcall_err(command, 'call msgpackdump([todump])')
)
end)
@@ -661,7 +661,7 @@ describe('msgpackdump() function', function()
command('call extend(todump.d.d, {"d": todump})')
eq(
"Vim(call):E5005: Unable to dump msgpackdump() argument, index 0: container references itself in key 'd', key 'd', key 'd'",
exc_exec('call msgpackdump([todump])')
pcall_err(command, 'call msgpackdump([todump])')
)
end)
@@ -682,7 +682,7 @@ describe('msgpackdump() function', function()
command('call add(todump._VAL, todump)')
eq(
'Vim(call):E5005: Unable to dump msgpackdump() argument, index 0: container references itself in index 0',
exc_exec('call msgpackdump([todump])')
pcall_err(command, 'call msgpackdump([todump])')
)
end)
@@ -691,7 +691,7 @@ describe('msgpackdump() function', function()
command('call add(todump._VAL, [todump, 0])')
eq(
'Vim(call):E5005: Unable to dump msgpackdump() argument, index 0: container references itself in index 0',
exc_exec('call msgpackdump([todump])')
pcall_err(command, 'call msgpackdump([todump])')
)
end)
@@ -700,7 +700,7 @@ describe('msgpackdump() function', function()
command('call add(todump._VAL, [0, todump])')
eq(
'Vim(call):E5005: Unable to dump msgpackdump() argument, index 0: container references itself in key 0 at index 0 from special map',
exc_exec('call msgpackdump([todump])')
pcall_err(command, 'call msgpackdump([todump])')
)
end)
@@ -709,7 +709,7 @@ describe('msgpackdump() function', function()
command('call add(todump._VAL[0][0], todump._VAL)')
eq(
'Vim(call):E5005: Unable to dump msgpackdump() argument, index 0: container references itself in key [[[[...@0], []]]] at index 0 from special map, index 0',
exc_exec('call msgpackdump([todump])')
pcall_err(command, 'call msgpackdump([todump])')
)
end)
@@ -718,7 +718,7 @@ describe('msgpackdump() function', function()
command('call add(todump._VAL[0][1], todump._VAL)')
eq(
'Vim(call):E5005: Unable to dump msgpackdump() argument, index 0: container references itself in key [] at index 0 from special map, index 0',
exc_exec('call msgpackdump([todump])')
pcall_err(command, 'call msgpackdump([todump])')
)
end)
@@ -727,46 +727,49 @@ describe('msgpackdump() function', function()
command('call add(todump._VAL, [0, todump._VAL])')
eq(
'Vim(call):E5005: Unable to dump msgpackdump() argument, index 0: container references itself in index 0, index 1',
exc_exec('call msgpackdump([todump])')
pcall_err(command, 'call msgpackdump([todump])')
)
end)
it('fails when called with no arguments', function()
eq(
'Vim(call):E119: Not enough arguments for function: msgpackdump',
exc_exec('call msgpackdump()')
pcall_err(command, 'call msgpackdump()')
)
end)
it('fails when called with three arguments', function()
eq(
'Vim(call):E118: Too many arguments for function: msgpackdump',
exc_exec('call msgpackdump(["", ""], 1, 2)')
pcall_err(command, 'call msgpackdump(["", ""], 1, 2)')
)
end)
it('fails to dump a string', function()
eq(
'Vim(call):E686: Argument of msgpackdump() must be a List',
exc_exec('call msgpackdump("abcdefghijklmnopqrstuvwxyz")')
pcall_err(command, 'call msgpackdump("abcdefghijklmnopqrstuvwxyz")')
)
end)
it('fails to dump a number', function()
eq(
'Vim(call):E686: Argument of msgpackdump() must be a List',
exc_exec('call msgpackdump(127)')
pcall_err(command, 'call msgpackdump(127)')
)
end)
it('fails to dump a dict', function()
eq('Vim(call):E686: Argument of msgpackdump() must be a List', exc_exec('call msgpackdump({})'))
eq(
'Vim(call):E686: Argument of msgpackdump() must be a List',
pcall_err(command, 'call msgpackdump({})')
)
end)
it('fails to dump a funcref', function()
eq(
'Vim(call):E686: Argument of msgpackdump() must be a List',
exc_exec('call msgpackdump(function("tr"))')
pcall_err(command, 'call msgpackdump(function("tr"))')
)
end)
@@ -774,14 +777,14 @@ describe('msgpackdump() function', function()
command('function! T() dict\nendfunction')
eq(
'Vim(call):E686: Argument of msgpackdump() must be a List',
exc_exec('call msgpackdump(function("T", [1, 2], {}))')
pcall_err(command, 'call msgpackdump(function("T", [1, 2], {}))')
)
end)
it('fails to dump a float', function()
eq(
'Vim(call):E686: Argument of msgpackdump() must be a List',
exc_exec('call msgpackdump(0.0)')
pcall_err(command, 'call msgpackdump(0.0)')
)
end)
@@ -789,7 +792,7 @@ describe('msgpackdump() function', function()
for _, val in ipairs({ 'v:true', 'v:false', 'v:null' }) do
eq(
'Vim(call):E686: Argument of msgpackdump() must be a List',
exc_exec('call msgpackdump(' .. val .. ')')
pcall_err(command, 'call msgpackdump(' .. val .. ')')
)
end
end)