diff options
Diffstat (limited to 'test/functional')
| -rw-r--r-- | test/functional/job/job_spec.lua | 17 | ||||
| -rw-r--r-- | test/functional/legacy/077_mf_hash_grow_spec.lua | 45 |
2 files changed, 59 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)")) diff --git a/test/functional/legacy/077_mf_hash_grow_spec.lua b/test/functional/legacy/077_mf_hash_grow_spec.lua new file mode 100644 index 0000000000..01d916ef04 --- /dev/null +++ b/test/functional/legacy/077_mf_hash_grow_spec.lua @@ -0,0 +1,45 @@ +-- Inserts 2 million lines with consecutive integers starting from 1 +-- (essentially, the output of GNU's seq 1 2000000), writes them to Xtest +-- and calculates its cksum. +-- We need 2 million lines to trigger a call to mf_hash_grow(). If it would mess +-- up the lines the checksum would differ. +-- cksum is part of POSIX and so should be available on most Unixes. +-- If it isn't available then the test will be skipped. + +local helpers = require('test.functional.helpers') +local feed, insert, source = helpers.feed, helpers.insert, helpers.source +local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect + +describe('mf_hash_grow()', function() + setup(clear) + + -- Check to see if cksum exists, otherwise skip the test + if os.execute('which cksum 2>&1 > /dev/null') ~= 0 then + pending("was not tested because cksum was not found") + else + it('is working', function() + execute('set fileformat=unix undolevels=-1') + + -- Fill the buffer with numbers 1 - 2000000 + execute('let i = 1') + execute('while i <= 2000000 | call append(i, range(i, i + 99)) | let i += 100 | endwhile') + + -- Delete empty first line, save to Xtest, and clear buffer + feed('ggdd<cr>') + execute('w! Xtest') + feed('ggdG<cr>') + + -- Calculate the cksum of Xtest and delete first line + execute('r !cksum Xtest') + feed('ggdd<cr>') + + -- Assert correct output of cksum. + expect([[ + 3678979763 14888896 Xtest]]) + end) + end + + teardown(function() + os.remove('Xtest') + end) +end) |