diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/functional/autocmd/autocmd_spec.lua | 2 | ||||
-rw-r--r-- | test/functional/core/job_spec.lua | 18 | ||||
-rw-r--r-- | test/functional/eval/setpos_spec.lua | 64 |
3 files changed, 83 insertions, 1 deletions
diff --git a/test/functional/autocmd/autocmd_spec.lua b/test/functional/autocmd/autocmd_spec.lua index 162e112047..c38bd75c69 100644 --- a/test/functional/autocmd/autocmd_spec.lua +++ b/test/functional/autocmd/autocmd_spec.lua @@ -12,8 +12,8 @@ describe('autocmds:', function() local expected = { 'WinLeave', 'TabLeave', - 'TabNew', 'WinEnter', + 'TabNew', 'TabEnter', 'BufLeave', 'BufEnter' diff --git a/test/functional/core/job_spec.lua b/test/functional/core/job_spec.lua index 75b50aad0a..48a4689545 100644 --- a/test/functional/core/job_spec.lua +++ b/test/functional/core/job_spec.lua @@ -312,6 +312,24 @@ describe('jobs', function() end) end) + it('does not repeat output with slow output handlers', function() + source([[ + let d = {'data': []} + function! d.on_stdout(job, data, event) dict + call add(self.data, a:data) + sleep 200m + endfunction + if has('win32') + let cmd = '1,2,3,4,5 | foreach-object -process {echo $_; sleep 0.1}' + else + let cmd = ['sh', '-c', 'for i in $(seq 1 5); do echo $i; sleep 0.1; done'] + endif + call jobwait([jobstart(cmd, d)]) + call rpcnotify(g:channel, 'data', d.data) + ]]) + eq({'notification', 'data', {{{'1', ''}, {'2', ''}, {'3', ''}, {'4', ''}, {'5', ''}}}}, next_msg()) + end) + describe('jobwait', function() it('returns a list of status codes', function() source([[ diff --git a/test/functional/eval/setpos_spec.lua b/test/functional/eval/setpos_spec.lua new file mode 100644 index 0000000000..2e27cd8ac0 --- /dev/null +++ b/test/functional/eval/setpos_spec.lua @@ -0,0 +1,64 @@ +local helpers = require('test.functional.helpers')(after_each) +local setpos = helpers.funcs.setpos +local getpos = helpers.funcs.getpos +local insert = helpers.insert +local clear = helpers.clear +local execute = helpers.execute +local eval = helpers.eval +local eq = helpers.eq +local exc_exec = helpers.exc_exec + + +describe('setpos() function', function() + before_each(function() + clear() + insert([[ + First line of text + Second line of text + Third line of text]]) + execute('new') + insert([[ + Line of text 1 + Line of text 2 + Line of text 3]]) + end) + it('can set the current cursor position', function() + setpos(".", {0, 2, 1, 0}) + eq(getpos("."), {0, 2, 1, 0}) + setpos(".", {2, 1, 1, 0}) + eq(getpos("."), {0, 1, 1, 0}) + -- Ensure get an error attempting to set position to another buffer + local ret = exc_exec('call setpos(".", [1, 1, 1, 0])') + eq('Vim(call):E474: Invalid argument', ret) + end) + it('can set lowercase marks in the current buffer', function() + setpos("'d", {0, 2, 1, 0}) + eq(getpos("'d"), {0, 2, 1, 0}) + execute('undo', 'call setpos("\'d", [2, 3, 1, 0])') + eq(getpos("'d"), {0, 3, 1, 0}) + end) + it('can set lowercase marks in other buffers', function() + local retval = setpos("'d", {1, 2, 1, 0}) + eq(0, retval) + setpos("'d", {1, 2, 1, 0}) + eq(getpos("'d"), {0, 0, 0, 0}) + execute('wincmd w') + eq(eval('bufnr("%")'), 1) + eq(getpos("'d"), {0, 2, 1, 0}) + end) + it("fails when setting a mark in a buffer that doesn't exist", function() + local retval = setpos("'d", {3, 2, 1, 0}) + eq(-1, retval) + eq(getpos("'d"), {0, 0, 0, 0}) + retval = setpos("'D", {3, 2, 1, 0}) + eq(-1, retval) + eq(getpos("'D"), {0, 0, 0, 0}) + end) + it('can set uppercase marks', function() + setpos("'D", {2, 2, 3, 0}) + eq(getpos("'D"), {2, 2, 3, 0}) + -- Can set a mark in another buffer + setpos("'D", {1, 2, 2, 0}) + eq(getpos("'D"), {1, 2, 2, 0}) + end) +end) |