diff options
author | Scott Prager <splinterofchaos@gmail.com> | 2014-10-28 13:27:47 -0400 |
---|---|---|
committer | Thiago de Arruda <tpadilha84@gmail.com> | 2014-11-07 13:34:56 -0300 |
commit | fd36dc208e2ded0173209163424cbadc15329558 (patch) | |
tree | 5b75c3c30fd0064b430810e0b701e7855887e8fa /test | |
parent | e90973e0359b782a6e3ad4997258d9ca42495c2f (diff) | |
download | rneovim-fd36dc208e2ded0173209163424cbadc15329558.tar.gz rneovim-fd36dc208e2ded0173209163424cbadc15329558.tar.bz2 rneovim-fd36dc208e2ded0173209163424cbadc15329558.zip |
job: Let vimL jobsend() accept a list.
Use save_tv_as_string(), same as vimL system(). This also makes
jobsend() more liberal in what it can accept. For example,
`jobsend(j, 123)` is now valid.
Closes #1176
Diffstat (limited to 'test')
-rw-r--r-- | test/functional/job/job_spec.lua | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/test/functional/job/job_spec.lua b/test/functional/job/job_spec.lua index 51218288a5..744e165b61 100644 --- a/test/functional/job/job_spec.lua +++ b/test/functional/job/job_spec.lua @@ -44,11 +44,33 @@ 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"])') + eq({'notification', 'stdout', {{'123', 'xyz'}}}, next_message()) nvim('command', notify_str('v:job_data[1])')) nvim('command', "call jobstop(j)") eq({'notification', 'exit', {}}, next_message()) end) + it('preserves NULs', function() + -- Make a file with NULs in it. + local filename = os.tmpname() + local file = io.open(filename, "w") + file:write("abc\0def\n") + file:close() + + -- v:job_data preserves NULs. + nvim('command', notify_str('v:job_data[1]', 'v:job_data[2]')) + nvim('command', "let j = jobstart('xxx', 'cat', ['"..filename.."'])") + eq({'notification', 'stdout', {{'abc\ndef'}}}, 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()) + nvim('command', "call jobstop(j)") + end) + it('will hold data if it does not end in a newline', function() nvim('command', notify_str('v:job_data[1]', 'v:job_data[2]')) nvim('command', "let j = jobstart('xxx', 'cat', ['-'])") @@ -58,7 +80,6 @@ describe('jobs', function() eq({'notification', 'stdout', {{'xyz'}}}, 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, 'lol')")) |