aboutsummaryrefslogtreecommitdiff
path: root/test/functional/api/vim_spec.lua
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2018-05-04 08:20:37 +0200
committerJustin M. Keyes <justinkz@gmail.com>2018-05-06 14:38:26 +0200
commitfe7ab60af7c8fbc2b1830dcfbcff75e39f5c4bbe (patch)
treed0725a1a5cc37e5ec0df7de5625ed7579a832838 /test/functional/api/vim_spec.lua
parent19c2ce1901b08aa493ad3b12514d681cb22160f6 (diff)
downloadrneovim-fe7ab60af7c8fbc2b1830dcfbcff75e39f5c4bbe.tar.gz
rneovim-fe7ab60af7c8fbc2b1830dcfbcff75e39f5c4bbe.tar.bz2
rneovim-fe7ab60af7c8fbc2b1830dcfbcff75e39f5c4bbe.zip
API: nvim_call_dict_function: eliminate `internal` param
The `internal` param is difficult to explain, and will rarely be anything but `true`. To avoid it, use a hack: check if the resolved dict value starts with "function(".
Diffstat (limited to 'test/functional/api/vim_spec.lua')
-rw-r--r--test/functional/api/vim_spec.lua40
1 files changed, 24 insertions, 16 deletions
diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua
index f49469d201..250c2e58ac 100644
--- a/test/functional/api/vim_spec.lua
+++ b/test/functional/api/vim_spec.lua
@@ -180,37 +180,45 @@ describe('api', function()
end)
describe('nvim_call_dict_function', function()
- it('invokes VimL dict', function()
- source('function! F(name) dict\n return self.greeting . ", " . a:name . "!"\nendfunction')
+ it('invokes VimL dict function', function()
+ source([[
+ function! F(name) dict
+ return self.greeting . ", " . a:name . "!"
+ endfunction
+ ]])
+
+ -- function() ("non-internal") function
nvim('set_var', 'dict_function_dict', { greeting = 'Hello', F = 'function("F")' })
- eq('Hello, World!', nvim('call_dict_function', 'g:dict_function_dict', 'F', false, {'World'}))
+ eq('Hello, World!', nvim('call_dict_function', 'g:dict_function_dict', 'F', {'World'}))
eq({ greeting = 'Hello', F = 'function("F")' }, nvim('get_var', 'dict_function_dict'))
+
+ -- "internal" function
nvim('set_var', 'dict_function_dict_i', { greeting = 'Hi', F = "F" })
- eq('Hi, Moon!', nvim('call_dict_function', 'g:dict_function_dict_i', 'F', true, {'Moon'}))
+ eq('Hi, Moon!', nvim('call_dict_function', 'g:dict_function_dict_i', 'F', {'Moon'}))
eq({ greeting = 'Hi', F = "F" }, nvim('get_var', 'dict_function_dict_i'))
end)
it('invokes RPC dict', function()
source('function! G() dict\n return self.result\nendfunction')
- eq('self', nvim('call_dict_function', { result = 'self', G = 'G'}, 'G', false, {}))
+ eq('it works', nvim('call_dict_function', { result = 'it works', G = 'G'}, 'G', {}))
end)
it('validates args', function()
command('let g:d={"baz":"zub","meep":[]}')
- expect_err('Function not found in dict', request,
- 'nvim_call_dict_function', 'g:d', 'bogus', true, {1,2})
- expect_err('Error calling function.', request,
- 'nvim_call_dict_function', 'g:d', 'baz', true, {1,2})
+ expect_err('Error calling function', request,
+ 'nvim_call_dict_function', 'g:d', 'bogus', {1,2})
+ expect_err('Error calling function', request,
+ 'nvim_call_dict_function', 'g:d', 'baz', {1,2})
expect_err('Value found in dict is not a valid function', request,
- 'nvim_call_dict_function', 'g:d', 'meep', true, {1,2})
- expect_err('Cannot invoke RPC dict as a VimL reference', request,
- 'nvim_call_dict_function', { f = '' }, 'f', true, {1,2})
+ 'nvim_call_dict_function', 'g:d', 'meep', {1,2})
+ expect_err('Error calling function', request,
+ 'nvim_call_dict_function', { f = '' }, 'f', {1,2})
expect_err('Invalid %(empty%) function name', request,
- 'nvim_call_dict_function', "{ 'f': '' }", 'f', true, {1,2})
+ 'nvim_call_dict_function', "{ 'f': '' }", 'f', {1,2})
expect_err('dict argument type must be String or Dictionary', request,
- 'nvim_call_dict_function', 42, 'f', true, {1,2})
+ 'nvim_call_dict_function', 42, 'f', {1,2})
expect_err('Failed to evaluate dict expression', request,
- 'nvim_call_dict_function', 'foo', 'f', true, {1,2})
+ 'nvim_call_dict_function', 'foo', 'f', {1,2})
expect_err('Referenced dict does not exist', request,
- 'nvim_call_dict_function', '42', 'f', true, {1,2})
+ 'nvim_call_dict_function', '42', 'f', {1,2})
end)
end)