diff options
author | Björn Linse <bjorn.linse@gmail.com> | 2015-02-28 13:39:26 +0100 |
---|---|---|
committer | Björn Linse <bjorn.linse@gmail.com> | 2015-03-03 20:18:24 +0100 |
commit | 5be040ffe4499b6b924f810b5a30c54307a9cf38 (patch) | |
tree | 40761f1b54276aa522429bf80dc6d4e0c3c1b126 /test | |
parent | 6b7ece6cc89aa35f99d6bd3c078114a7a8a2daa1 (diff) | |
download | rneovim-5be040ffe4499b6b924f810b5a30c54307a9cf38.tar.gz rneovim-5be040ffe4499b6b924f810b5a30c54307a9cf38.tar.bz2 rneovim-5be040ffe4499b6b924f810b5a30c54307a9cf38.zip |
jobsend: Don't append extra newline after last item
This allows sending binary data that is not newline terminated
Diffstat (limited to 'test')
-rw-r--r-- | test/functional/job/job_spec.lua | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/test/functional/job/job_spec.lua b/test/functional/job/job_spec.lua index 9bdade7733..0d561ec4d7 100644 --- a/test/functional/job/job_spec.lua +++ b/test/functional/job/job_spec.lua @@ -45,7 +45,7 @@ describe('jobs', function() eq({'notification', 'stdout', {{'abc', ''}}}, next_message()) nvim('command', 'call jobsend(j, "123\\nxyz\\n")') eq({'notification', 'stdout', {{'123', 'xyz', ''}}}, next_message()) - nvim('command', 'call jobsend(j, [123, "xyz"])') + nvim('command', 'call jobsend(j, [123, "xyz", ""])') eq({'notification', 'stdout', {{'123', 'xyz', ''}}}, next_message()) nvim('command', "call jobstop(j)") eq({'notification', 'exit', {0}}, next_message()) @@ -67,7 +67,7 @@ describe('jobs', function() -- jobsend() preserves NULs. nvim('command', "let j = jobstart('xxx', 'cat', ['-'])") - nvim('command', [[call jobsend(j, ["123\n456"])]]) + nvim('command', [[call jobsend(j, ["123\n456",""])]]) eq({'notification', 'stdout', {{'123\n456', ''}}}, next_message()) nvim('command', "call jobstop(j)") end) @@ -92,13 +92,24 @@ describe('jobs', function() 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"])') + 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', 'exit', {0}}, next_message()) end) + it('can avoid sending final newline', 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, ["some data", "without\nfinal nl"])') + eq({'notification', 'stdout', {{'some data', 'without\nfinal nl'}}}, + next_message()) + nvim('command', "call jobstop(j)") + eq({'notification', 'exit', {0}}, next_message()) + end) + + it('will not allow jobsend/stop on a non-existent job', function() eq(false, pcall(eval, "jobsend(-1, 'lol')")) eq(false, pcall(eval, "jobstop(-1)")) |