aboutsummaryrefslogtreecommitdiff
path: root/test/functional/job/job_spec.lua
diff options
context:
space:
mode:
Diffstat (limited to 'test/functional/job/job_spec.lua')
-rw-r--r--test/functional/job/job_spec.lua33
1 files changed, 25 insertions, 8 deletions
diff --git a/test/functional/job/job_spec.lua b/test/functional/job/job_spec.lua
index 5304c9e9d3..b87c3a827b 100644
--- a/test/functional/job/job_spec.lua
+++ b/test/functional/job/job_spec.lua
@@ -41,11 +41,11 @@ describe('jobs', function()
nvim('command', "let j = jobstart('xxx', 'cat', ['-'])")
neq(0, eval('j'))
nvim('command', 'call jobsend(j, "abc\\n")')
- eq({'notification', 'stdout', {{'abc'}}}, next_message())
+ eq({'notification', 'stdout', {{'abc', ''}}}, next_message())
nvim('command', 'call jobsend(j, "123\\nxyz\\n")')
- eq({'notification', 'stdout', {{'123', 'xyz'}}}, next_message())
+ eq({'notification', 'stdout', {{'123', 'xyz', ''}}}, next_message())
nvim('command', 'call jobsend(j, [123, "xyz"])')
- eq({'notification', 'stdout', {{'123', 'xyz'}}}, next_message())
+ eq({'notification', 'stdout', {{'123', 'xyz', ''}}}, next_message())
nvim('command', "call jobstop(j)")
eq({'notification', 'exit', {0}}, next_message())
end)
@@ -60,24 +60,41 @@ describe('jobs', function()
-- v:job_data preserves NULs.
nvim('command', notify_str('v:job_data[1]', 'get(v:job_data, 2)'))
nvim('command', "let j = jobstart('xxx', 'cat', ['"..filename.."'])")
- eq({'notification', 'stdout', {{'abc\ndef'}}}, next_message())
+ eq({'notification', 'stdout', {{'abc\ndef', ''}}}, next_message())
eq({'notification', 'exit', {0}}, next_message())
os.remove(filename)
-- jobsend() preserves NULs.
nvim('command', "let j = jobstart('xxx', 'cat', ['-'])")
nvim('command', [[call jobsend(j, ["123\n456"])]])
- eq({'notification', 'stdout', {{'123\n456'}}}, next_message())
+ eq({'notification', 'stdout', {{'123\n456', ''}}}, next_message())
nvim('command', "call jobstop(j)")
end)
- it('will hold data if it does not end in a newline', function()
+ it('will not buffer data if it doesnt end in newlines', function()
nvim('command', notify_str('v:job_data[1]', 'get(v:job_data, 2)'))
nvim('command', "let j = jobstart('xxx', 'cat', ['-'])")
nvim('command', 'call jobsend(j, "abc\\nxyz")')
- eq({'notification', 'stdout', {{'abc'}}}, next_message())
+ eq({'notification', 'stdout', {{'abc', 'xyz'}}}, next_message())
+ nvim('command', "call jobstop(j)")
+ eq({'notification', 'exit', {0}}, next_message())
+ end)
+
+ it('can preserve newlines', function()
+ nvim('command', notify_str('v:job_data[1]', 'get(v:job_data, 2)'))
+ nvim('command', "let j = jobstart('xxx', 'cat', ['-'])")
+ nvim('command', 'call jobsend(j, "a\\n\\nc\\n\\n\\n\\nb\\n\\n")')
+ eq({'notification', 'stdout', {{'a', '', 'c', '', '', '', 'b', '', ''}}},
+ next_message())
+ end)
+
+ it('can preserve nuls', function()
+ nvim('command', notify_str('v:job_data[1]', 'get(v:job_data, 2)'))
+ nvim('command', "let j = jobstart('xxx', 'cat', ['-'])")
+ nvim('command', 'call jobsend(j, ["\n123\n", "abc\\nxyz\n"])')
+ eq({'notification', 'stdout', {{'\n123\n', 'abc\nxyz\n', ''}}},
+ next_message())
nvim('command', "call jobstop(j)")
- eq({'notification', 'stdout', {{'xyz'}}}, next_message())
eq({'notification', 'exit', {0}}, next_message())
end)