Fix f_jobstop() failed loudly

The return value of jobstop()
@return 1 for valid job id
        0 for invalid id, including jobs have exited or stopped
This commit is contained in:
Billy Su
2020-01-20 20:06:38 +08:00
parent 270cd623ef
commit 041ec8997a
3 changed files with 16 additions and 6 deletions

View File

@@ -306,16 +306,16 @@ describe('jobs', function()
end))
end)
it('disallows jobsend/stop on a non-existent job', function()
it('disallows jobsend on a non-existent job', function()
eq(false, pcall(eval, "jobsend(-1, 'lol')"))
eq(false, pcall(eval, "jobstop(-1)"))
eq(0, eval('jobstop(-1)'))
end)
it('disallows jobstop twice on the same job', function()
it('jobstop twice on the stopped or exited job return 0', function()
nvim('command', "let j = jobstart(['cat', '-'], g:job_opts)")
neq(0, eval('j'))
eq(true, pcall(eval, "jobstop(j)"))
eq(false, pcall(eval, "jobstop(j)"))
eq(1, eval("jobstop(j)"))
eq(0, eval("jobstop(j)"))
end)
it('will not leak memory if we leave a job running', function()
@@ -919,6 +919,13 @@ describe('jobs', function()
end)
end)
it('jobstop on same id before stopped', function()
nvim('command', 'let j = jobstart(["cat", "-"], g:job_opts)')
neq(0, eval('j'))
eq({1, 0}, eval('[jobstop(j), jobstop(j)]'))
end)
describe('running tty-test program', function()
if helpers.pending_win32(pending) then return end
local function next_chunk()