From 1beee0685d33adf15457927b2487e8f89da178a0 Mon Sep 17 00:00:00 2001 From: Thiago de Arruda Date: Fri, 21 Aug 2015 09:07:06 -0300 Subject: eval: Protect job callbacks from being redefined ref: #3188 --- test/functional/job/job_spec.lua | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'test') diff --git a/test/functional/job/job_spec.lua b/test/functional/job/job_spec.lua index 7085d61cc7..bdaf2a7ec6 100644 --- a/test/functional/job/job_spec.lua +++ b/test/functional/job/job_spec.lua @@ -6,6 +6,7 @@ local clear, eq, eval, execute, expect, feed, insert, neq, next_msg, nvim, helpers.insert, helpers.neq, helpers.next_message, helpers.nvim, helpers.nvim_dir, helpers.ok, helpers.run, helpers.session, helpers.source, helpers.stop, helpers.wait, helpers.write_file +local Screen = require('test.functional.ui.screen') describe('jobs', function() @@ -188,6 +189,41 @@ describe('jobs', function() eq({'notification', 'exit', {45, 10}}, next_msg()) end) + it('cant redefine callbacks being used by a job', function() + local screen = Screen.new() + screen:attach() + local script = [[ + function! g:JobHandler(job_id, data, event) + endfunction + + let g:callbacks = { + \ 'on_stdout': function('g:JobHandler'), + \ 'on_stderr': function('g:JobHandler'), + \ 'on_exit': function('g:JobHandler') + \ } + let job = jobstart('cat -', g:callbacks) + ]] + source(script) + feed(':function! g:JobHandler(job_id, data, event)') + feed(':endfunction') + 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^ | + ]]) + end) + describe('jobwait', function() it('returns a list of status codes', function() source([[ -- cgit