diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/functional/core/job_partial_spec.lua | 27 | ||||
-rw-r--r-- | test/functional/core/job_spec.lua | 39 | ||||
-rw-r--r-- | test/functional/ex_cmds/dict_notifications_spec.lua | 20 | ||||
-rw-r--r-- | test/functional/legacy/055_list_and_dict_types_spec.lua | 10 | ||||
-rw-r--r-- | test/functional/terminal/buffer_spec.lua | 2 |
5 files changed, 63 insertions, 35 deletions
diff --git a/test/functional/core/job_partial_spec.lua b/test/functional/core/job_partial_spec.lua new file mode 100644 index 0000000000..b60f239db9 --- /dev/null +++ b/test/functional/core/job_partial_spec.lua @@ -0,0 +1,27 @@ +local helpers = require('test.functional.helpers')(after_each) +local clear, eq, next_msg, nvim, source = helpers.clear, helpers.eq, + helpers.next_message, helpers.nvim, helpers.source + +if helpers.pending_win32(pending) then return end + +describe('jobs with partials', function() + local channel + + before_each(function() + clear() + channel = nvim('get_api_info')[1] + nvim('set_var', 'channel', channel) + end) + + it('works correctly', function() + source([[ + function PrintArgs(a1, a2, id, data, event) + call rpcnotify(g:channel, '1', a:a1, a:a2, a:data, a:event) + endfunction + let Callback = function('PrintArgs', ["foo", "bar"]) + let g:job_opts = {'on_stdout': Callback} + call jobstart(['echo'], g:job_opts) + ]]) + eq({'notification', '1', {'foo', 'bar', {'', ''}, 'stdout'}}, next_msg()) + end) +end) diff --git a/test/functional/core/job_spec.lua b/test/functional/core/job_spec.lua index 79cc877cac..34085fa522 100644 --- a/test/functional/core/job_spec.lua +++ b/test/functional/core/job_spec.lua @@ -18,7 +18,7 @@ describe('jobs', function() channel = nvim('get_api_info')[1] nvim('set_var', 'channel', channel) source([[ - function! s:OnEvent(id, data, event) + function! s:OnEvent(id, data, event) dict let userdata = get(self, 'user') call rpcnotify(g:channel, a:event, userdata, a:data) endfunction @@ -265,9 +265,12 @@ describe('jobs', function() eq({'notification', 'exit', {45, 10}}, next_msg()) end) - it('cannot redefine callbacks being used by a job', function() + it('can redefine callbacks being used by a job', function() local screen = Screen.new() screen:attach() + screen:set_default_attr_ids({ + [1] = {bold=true, foreground=Screen.colors.Blue}, + }) local script = [[ function! g:JobHandler(job_id, data, event) endfunction @@ -283,20 +286,20 @@ describe('jobs', function() feed(':function! g:JobHandler(job_id, data, event)<cr>') feed(':endfunction<cr>') screen:expect([[ - ~ | - ~ | - ~ | - ~ | - ~ | - ~ | - ~ | - ~ | - ~ | - :function! g:JobHandler(job_id, data, event) | - : :endfunction | - E127: Cannot redefine function JobHandler: It is in u| - se | - Press ENTER or type command to continue^ | + ^ | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | ]]) end) @@ -317,7 +320,7 @@ describe('jobs', function() source([[ let g:dict = {'id': 10} let g:exits = 0 - function g:dict.on_exit(id, code) + function g:dict.on_exit(id, code, event) if a:code != 5 throw 'Error!' endif @@ -365,7 +368,7 @@ describe('jobs', function() eq({'notification', 'wait', {{-2}}}, next_msg()) end) - it('can be called recursively', function() + pending('can be called recursively', function() source([[ let g:opts = {} let g:counter = 0 diff --git a/test/functional/ex_cmds/dict_notifications_spec.lua b/test/functional/ex_cmds/dict_notifications_spec.lua index dc87312911..e6f7609016 100644 --- a/test/functional/ex_cmds/dict_notifications_spec.lua +++ b/test/functional/ex_cmds/dict_notifications_spec.lua @@ -2,6 +2,7 @@ local helpers = require('test.functional.helpers')(after_each) local clear, nvim, source = helpers.clear, helpers.nvim, helpers.source local eq, next_msg = helpers.eq, helpers.next_message local exc_exec = helpers.exc_exec +local command = helpers.command describe('dictionary change notifications', function() @@ -229,11 +230,9 @@ describe('dictionary change notifications', function() exc_exec('call dictwatcherdel(g:, "invalid_key", "g:Watcher2")')) end) - it("fails to add/remove if the callback doesn't exist", function() - eq("Vim(call):Function g:InvalidCb doesn't exist", - exc_exec('call dictwatcheradd(g:, "key", "g:InvalidCb")')) - eq("Vim(call):Function g:InvalidCb doesn't exist", - exc_exec('call dictwatcherdel(g:, "key", "g:InvalidCb")')) + it("does not fail to add/remove if the callback doesn't exist", function() + command('call dictwatcheradd(g:, "key", "g:InvalidCb")') + command('call dictwatcherdel(g:, "key", "g:InvalidCb")') end) it('fails with empty keys', function() @@ -243,15 +242,18 @@ describe('dictionary change notifications', function() exc_exec('call dictwatcherdel(g:, "", "g:Watcher1")')) end) - it('fails to replace a watcher function', function() + it('does not fail to replace a watcher function', function() source([[ function! g:ReplaceWatcher2() - function! g:Watcher2() + function! g:Watcher2(dict, key, value) + call rpcnotify(g:channel, '2b', a:key, a:value) endfunction endfunction ]]) - eq("Vim(function):E127: Cannot redefine function Watcher2: It is in use", - exc_exec('call g:ReplaceWatcher2()')) + command('call g:ReplaceWatcher2()') + command('let g:key = "value"') + eq({'notification', '2b', {'key', {old = 'v2', new = 'value'}}}, next_msg()) + end) end) end) diff --git a/test/functional/legacy/055_list_and_dict_types_spec.lua b/test/functional/legacy/055_list_and_dict_types_spec.lua index b9e5a8bc03..dbe9e1bc7f 100644 --- a/test/functional/legacy/055_list_and_dict_types_spec.lua +++ b/test/functional/legacy/055_list_and_dict_types_spec.lua @@ -274,17 +274,13 @@ describe('list and dictionary types', function() let dict.data = [1,2,3] call dict.func("len: ") let x = dict.func("again: ") - try - let Fn = dict.func - call Fn('xxx') - catch - $put =v:exception[:15] - endtry]]) + let Fn = dict.func + call Fn('xxx')]]) expect([[ len: 3 again: 3 - Vim(call):E725: ]]) + xxx3]]) end) it('Function in script-local List or Dict', function() diff --git a/test/functional/terminal/buffer_spec.lua b/test/functional/terminal/buffer_spec.lua index 427aa011e9..cecd67d7fa 100644 --- a/test/functional/terminal/buffer_spec.lua +++ b/test/functional/terminal/buffer_spec.lua @@ -167,7 +167,7 @@ describe('terminal buffer', function() local tbuf = eval('bufnr("%")') source([[ - function! SplitWindow() + function! SplitWindow(id, data, event) new call feedkeys("iabc\<Esc>") endfunction |