aboutsummaryrefslogtreecommitdiff
path: root/test/functional/eval/msgpack_functions_spec.lua
diff options
context:
space:
mode:
authorZyX <kp-pav@yandex.ru>2015-09-19 01:52:19 +0300
committerZyX <kp-pav@yandex.ru>2015-09-19 01:54:43 +0300
commitc6102f9a9f6f765f759d2501a618fbfbfdaa0f2a (patch)
treea75daf17aba4644f72736f1856cb819b0e6027a4 /test/functional/eval/msgpack_functions_spec.lua
parente881a20dfb3bde40e004df64d447cdc16dc3eaa1 (diff)
downloadrneovim-c6102f9a9f6f765f759d2501a618fbfbfdaa0f2a.tar.gz
rneovim-c6102f9a9f6f765f759d2501a618fbfbfdaa0f2a.tar.bz2
rneovim-c6102f9a9f6f765f759d2501a618fbfbfdaa0f2a.zip
functests: Test how msgpack\* functions behave with invalid input
Diffstat (limited to 'test/functional/eval/msgpack_functions_spec.lua')
-rw-r--r--test/functional/eval/msgpack_functions_spec.lua70
1 files changed, 70 insertions, 0 deletions
diff --git a/test/functional/eval/msgpack_functions_spec.lua b/test/functional/eval/msgpack_functions_spec.lua
index 66cfb57b88..927d17fca9 100644
--- a/test/functional/eval/msgpack_functions_spec.lua
+++ b/test/functional/eval/msgpack_functions_spec.lua
@@ -459,6 +459,41 @@ describe('msgpackparse() function', function()
api_info = eval(cmd) -- do it again
eq('functions', api_info)
end)
+
+ it('fails when called with no arguments', function()
+ eq('Vim(call):E119: Not enough arguments for function: msgpackparse',
+ exc_exec('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)'))
+ end)
+
+ it('fails to parse a string', function()
+ eq('Vim(call):E686: Argument of msgpackparse() must be a List',
+ exc_exec('call msgpackparse("abcdefghijklmnopqrstuvwxyz")'))
+ end)
+
+ it('fails to parse a number', function()
+ eq('Vim(call):E686: Argument of msgpackparse() must be a List',
+ exc_exec('call msgpackparse(127)'))
+ end)
+
+ it('fails to parse a dictionary', function()
+ eq('Vim(call):E686: Argument of msgpackparse() must be a List',
+ exc_exec('call msgpackparse({})'))
+ end)
+
+ it('fails to parse a funcref', function()
+ eq('Vim(call):E686: Argument of msgpackparse() must be a List',
+ exc_exec('call msgpackparse(function("tr"))'))
+ end)
+
+ it('fails to parse a float', function()
+ eq('Vim(call):E686: Argument of msgpackparse() must be a List',
+ exc_exec('call msgpackparse(0.0)'))
+ end)
end)
describe('msgpackdump() function', function()
@@ -558,4 +593,39 @@ describe('msgpackdump() function', function()
eq('Vim(call):E475: Invalid argument: container references itself',
exc_exec('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()'))
+ end)
+
+ it('fails when called with two arguments', function()
+ eq('Vim(call):E118: Too many arguments for function: msgpackdump',
+ exc_exec('call msgpackdump(["", ""], 1)'))
+ end)
+
+ it('fails to dump a string', function()
+ eq('Vim(call):E686: Argument of msgpackdump() must be a List',
+ exc_exec('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)'))
+ end)
+
+ it('fails to dump a dictionary', function()
+ eq('Vim(call):E686: Argument of msgpackdump() must be a List',
+ exc_exec('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"))'))
+ 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)'))
+ end)
end)