diff options
author | Marco Hinz <mh.codebro@gmail.com> | 2016-03-01 18:06:35 +0100 |
---|---|---|
committer | Marco Hinz <mh.codebro@gmail.com> | 2016-03-01 18:06:35 +0100 |
commit | c00da817c49bec5cdc5a24d859bfa59802565edc (patch) | |
tree | b47bda2b63fa6cf7663fd2b4a1170fcaa3749bc1 | |
parent | 2ee37cc2858aa68f5ca0440ed017bde112ffdec7 (diff) | |
parent | 6bfd88dec143c0cd47291bcb23069808228ce102 (diff) | |
download | rneovim-c00da817c49bec5cdc5a24d859bfa59802565edc.tar.gz rneovim-c00da817c49bec5cdc5a24d859bfa59802565edc.tar.bz2 rneovim-c00da817c49bec5cdc5a24d859bfa59802565edc.zip |
Merge PR #3657 'Correct max numbers of args for some functions'
-rw-r--r-- | src/nvim/eval.c | 6 | ||||
-rw-r--r-- | test/functional/viml/function_spec.lua | 29 |
2 files changed, 32 insertions, 3 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 33b8415336..0e5da13242 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -7360,7 +7360,7 @@ static struct fst { { "pathshorten", 1, 1, f_pathshorten }, { "pow", 2, 2, f_pow }, { "prevnonblank", 1, 1, f_prevnonblank }, - { "printf", 2, 19, f_printf }, + { "printf", 2, MAX_FUNC_ARGS, f_printf }, { "pumvisible", 0, 0, f_pumvisible }, { "py3eval", 1, 1, f_py3eval }, { "pyeval", 1, 1, f_pyeval }, @@ -7374,8 +7374,8 @@ static struct fst { { "resolve", 1, 1, f_resolve }, { "reverse", 1, 1, f_reverse }, { "round", 1, 1, f_round }, - { "rpcnotify", 2, 64, f_rpcnotify }, - { "rpcrequest", 2, 64, f_rpcrequest }, + { "rpcnotify", 2, MAX_FUNC_ARGS, f_rpcnotify }, + { "rpcrequest", 2, MAX_FUNC_ARGS, f_rpcrequest }, { "rpcstart", 1, 2, f_rpcstart }, { "rpcstop", 1, 1, f_rpcstop }, { "screenattr", 2, 2, f_screenattr }, diff --git a/test/functional/viml/function_spec.lua b/test/functional/viml/function_spec.lua new file mode 100644 index 0000000000..665f5d4467 --- /dev/null +++ b/test/functional/viml/function_spec.lua @@ -0,0 +1,29 @@ +local helpers = require('test.functional.helpers') + +local clear = helpers.clear +local eq = helpers.eq +local exc_exec = helpers.exc_exec + +describe('Up to MAX_FUNC_ARGS arguments are handled by', function() + local max_func_args = 20 -- from eval.h + local range = helpers.funcs.range + + before_each(clear) + + it('printf()', function() + local printf = helpers.funcs.printf + local rep = helpers.funcs['repeat'] + local expected = '2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,' + eq(expected, printf(rep('%d,', max_func_args-1), unpack(range(2, max_func_args)))) + local ret = exc_exec('call printf("", 2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21)') + eq('Vim(call):E740: Too many arguments for function printf', ret) + end) + + it('rpcnotify()', function() + local rpcnotify = helpers.funcs.rpcnotify + local ret = rpcnotify(0, 'foo', unpack(range(3, max_func_args))) + eq(1, ret) + ret = exc_exec('call rpcnotify(0, "foo", 3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21)') + eq('Vim(call):E740: Too many arguments for function rpcnotify', ret) + end) +end) |