diff options
Diffstat (limited to 'test/functional/shada/marks_spec.lua')
-rw-r--r-- | test/functional/shada/marks_spec.lua | 72 |
1 files changed, 32 insertions, 40 deletions
diff --git a/test/functional/shada/marks_spec.lua b/test/functional/shada/marks_spec.lua index 18ce470cb7..b03af39662 100644 --- a/test/functional/shada/marks_spec.lua +++ b/test/functional/shada/marks_spec.lua @@ -1,9 +1,9 @@ -- ShaDa marks saving/reading support local helpers = require('test.functional.helpers') -local nvim, nvim_window, nvim_curwin, nvim_command, nvim_feed, nvim_eval, eq = - helpers.nvim, helpers.window, helpers.curwin, helpers.command, helpers.feed, - helpers.eval, helpers.eq -local exc_exec = helpers.exc_exec +local meths, curwinmeths, curbufmeths, nvim_command, funcs, eq = + helpers.meths, helpers.curwinmeths, helpers.curbufmeths, helpers.command, + helpers.funcs, helpers.eq +local exc_exec, redir_exec = helpers.exc_exec, helpers.redir_exec local shada_helpers = require('test.functional.shada.helpers') local reset, set_additional_cmd, clear = @@ -11,7 +11,7 @@ local reset, set_additional_cmd, clear = shada_helpers.clear local nvim_current_line = function() - return nvim_window('get_cursor', nvim_curwin())[1] + return curwinmeths.get_cursor()[1] end describe('ShaDa support code', function() @@ -43,7 +43,7 @@ describe('ShaDa support code', function() reset() nvim_command('rshada') nvim_command('normal! `A') - eq(testfilename, nvim_eval('fnamemodify(@%, ":t")')) + eq(testfilename, funcs.fnamemodify(curbufmeths.get_name(), ':t')) eq(1, nvim_current_line()) nvim_command('normal! `B') eq(2, nvim_current_line()) @@ -71,7 +71,7 @@ describe('ShaDa support code', function() reset() nvim_command('language C') nvim_command('normal! `A') - eq(testfilename, nvim_eval('fnamemodify(@%, ":t")')) + eq(testfilename, funcs.fnamemodify(curbufmeths.get_name(), ':t')) eq(1, nvim_current_line()) end) @@ -84,7 +84,7 @@ describe('ShaDa support code', function() reset() nvim_command('edit ' .. testfilename) nvim_command('normal! `a') - eq(testfilename, nvim_eval('fnamemodify(@%, ":t")')) + eq(testfilename, funcs.fnamemodify(curbufmeths.get_name(), ':t')) eq(1, nvim_current_line()) nvim_command('normal! `b') eq(2, nvim_current_line()) @@ -92,19 +92,19 @@ describe('ShaDa support code', function() it('is able to populate v:oldfiles', function() nvim_command('edit ' .. testfilename) - local tf_full = nvim_eval('fnamemodify(bufname("%"), ":p")') + local tf_full = curbufmeths.get_name() nvim_command('edit ' .. testfilename_2) - local tf_full_2 = nvim_eval('fnamemodify(bufname("%"), ":p")') + local tf_full_2 = curbufmeths.get_name() nvim_command('qall') reset() - local oldfiles = nvim('get_vvar', 'oldfiles') + local oldfiles = meths.get_vvar('oldfiles') eq(2, #oldfiles) eq(testfilename, oldfiles[1]:sub(-#testfilename)) eq(testfilename_2, oldfiles[2]:sub(-#testfilename_2)) eq(tf_full, oldfiles[1]) eq(tf_full_2, oldfiles[2]) nvim_command('rshada!') - local oldfiles = nvim('get_vvar', 'oldfiles') + local oldfiles = meths.get_vvar('oldfiles') eq(2, #oldfiles) eq(testfilename, oldfiles[1]:sub(-#testfilename)) eq(testfilename_2, oldfiles[2]:sub(-#testfilename_2)) @@ -114,74 +114,66 @@ describe('ShaDa support code', function() it('is able to dump and restore jump list', function() nvim_command('edit ' .. testfilename_2) - nvim_feed('G') - nvim_feed('gg') + nvim_command('normal! G') + nvim_command('normal! gg') nvim_command('edit ' .. testfilename) - nvim_feed('G') - nvim_feed('gg') + nvim_command('normal! G') + nvim_command('normal! gg') nvim_command('enew') - nvim_feed('gg') - nvim_command('redir => g:jumps | jumps | redir END') - local saved = nvim_eval('g:jumps') + nvim_command('normal! gg') + local saved = redir_exec('jumps') nvim_command('qall') reset() - nvim_command('redir => g:jumps | jumps | redir END') - eq(saved, nvim_eval('g:jumps')) + eq(saved, redir_exec('jumps')) end) it('is able to dump and restore jump list with different times (slow!)', function() nvim_command('edit ' .. testfilename_2) nvim_command('sleep 2') - nvim_feed('G') + nvim_command('normal! G') nvim_command('sleep 2') - nvim_feed('gg') + nvim_command('normal! gg') nvim_command('sleep 2') nvim_command('edit ' .. testfilename) nvim_command('sleep 2') - nvim_feed('G') + nvim_command('normal! G') nvim_command('sleep 2') - nvim_feed('gg') - -- nvim_command('redir! >/tmp/jumps.last | jumps | redir END') - -- nvim_command('wshada /tmp/foo') + nvim_command('normal! gg') nvim_command('qall') reset() nvim_command('redraw') - -- nvim_command('redir! >/tmp/jumps.init | jumps | redir END') nvim_command('edit ' .. testfilename) - -- nvim_command('redir! >/tmp/jumps | jumps | redir END') - eq(testfilename, nvim_eval('bufname("%")')) + eq(testfilename, funcs.bufname('%')) eq(1, nvim_current_line()) nvim_command('execute "normal! \\<C-o>"') - eq(testfilename, nvim_eval('bufname("%")')) + eq(testfilename, funcs.bufname('%')) eq(1, nvim_current_line()) nvim_command('execute "normal! \\<C-o>"') - eq(testfilename, nvim_eval('bufname("%")')) + eq(testfilename, funcs.bufname('%')) eq(2, nvim_current_line()) nvim_command('execute "normal! \\<C-o>"') - eq(testfilename_2, nvim_eval('bufname("%")')) + eq(testfilename_2, funcs.bufname('%')) eq(1, nvim_current_line()) nvim_command('execute "normal! \\<C-o>"') - eq(testfilename_2, nvim_eval('bufname("%")')) + eq(testfilename_2, funcs.bufname('%')) eq(2, nvim_current_line()) end) it('is able to dump and restore change list', function() nvim_command('edit ' .. testfilename) - nvim_feed('Gra') - nvim_feed('ggrb') + nvim_command('normal! Gra') + nvim_command('normal! ggrb') nvim_command('qall!') reset() nvim_command('edit ' .. testfilename) - -- nvim_command('rshada') - -- nvim_command('redir! >/tmp/changes | changes | redir END') - nvim_feed('Gg;') + nvim_command('normal! Gg;') -- Note: without “sync” “commands” test has good changes to fail for unknown -- reason (in first eq expected 1 is compared with 2). Any command inserted -- causes this to work properly. nvim_command('" sync') eq(1, nvim_current_line()) - nvim_feed('g;') + nvim_command('normal! g;') nvim_command('" sync 2') eq(2, nvim_current_line()) end) |