diff options
author | Lucas Hoffmann <l-m-h@web.de> | 2015-06-16 14:33:41 +0200 |
---|---|---|
committer | Lucas Hoffmann <l-m-h@web.de> | 2016-02-04 19:23:47 +0100 |
commit | c1b0c45bee5faaf966d36c9ceab119709a47834a (patch) | |
tree | 1ba60432b37ea052c54d37812929636b4c75b39d /test/functional/legacy/command_count_spec.lua | |
parent | 153fe65c01a572fdc29937fc8d5d15addeb45ed3 (diff) | |
download | rneovim-c1b0c45bee5faaf966d36c9ceab119709a47834a.tar.gz rneovim-c1b0c45bee5faaf966d36c9ceab119709a47834a.tar.bz2 rneovim-c1b0c45bee5faaf966d36c9ceab119709a47834a.zip |
tests: Fix migrated legacy test.
The test involves argument and buffer numbers. Therefore it was necessary to
use a custom testing session to ensure that the initial buffer corresponds to
an argument.
Diffstat (limited to 'test/functional/legacy/command_count_spec.lua')
-rw-r--r-- | test/functional/legacy/command_count_spec.lua | 59 |
1 files changed, 41 insertions, 18 deletions
diff --git a/test/functional/legacy/command_count_spec.lua b/test/functional/legacy/command_count_spec.lua index 49bb3acb61..de7bb7d2a7 100644 --- a/test/functional/legacy/command_count_spec.lua +++ b/test/functional/legacy/command_count_spec.lua @@ -1,8 +1,9 @@ -- Test for user command counts local helpers = require('test.functional.helpers') -local source = helpers.source -local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect +local clear, source, expect = helpers.clear, helpers.source, helpers.expect +local execute, spawn = helpers.execute, helpers.spawn +local nvim_prog = helpers.nvim_prog describe('command_count', function() setup(clear) @@ -11,19 +12,40 @@ describe('command_count', function() end) it('is working', function() - execute('lang C') - execute('let g:lines = []') - execute([[com -range=% RangeLines :call add(g:lines, 'RangeLines '.<line1>.' '.<line2>)]]) - execute([[com -range -addr=arguments RangeArguments :call add(g:lines, 'RangeArguments '.<line1>.' '.<line2>)]]) - execute([[com -range=% -addr=arguments RangeArgumentsAll :call add(g:lines, 'RangeArgumentsAll '.<line1>.' '.<line2>)]]) - execute([[com -range -addr=loaded_buffers RangeLoadedBuffers :call add(g:lines, 'RangeLoadedBuffers '.<line1>.' '.<line2>)]]) - execute([[com -range=% -addr=loaded_buffers RangeLoadedBuffersAll :call add(g:lines, 'RangeLoadedBuffersAll '.<line1>.' '.<line2>)]]) - execute([[com -range -addr=buffers RangeBuffers :call add(g:lines, 'RangeBuffers '.<line1>.' '.<line2>)]]) - execute([[com -range=% -addr=buffers RangeBuffersAll :call add(g:lines, 'RangeBuffersAll '.<line1>.' '.<line2>)]]) - execute([[com -range -addr=windows RangeWindows :call add(g:lines, 'RangeWindows '.<line1>.' '.<line2>)]]) - execute([[com -range=% -addr=windows RangeWindowsAll :call add(g:lines, 'RangeWindowsAll '.<line1>.' '.<line2>)]]) - execute([[com -range -addr=tabs RangeTabs :call add(g:lines, 'RangeTabs '.<line1>.' '.<line2>)]]) - execute([[com -range=% -addr=tabs RangeTabsAll :call add(g:lines, 'RangeTabsAll '.<line1>.' '.<line2>)]]) + -- It is relevant for the test to load a file initially. If this is + -- emulated with :arg the buffer count is wrong as nvim creates an empty + -- buffer if it was started without a filename. + local nvim2 = spawn({helpers.nvim_prog, '-u', 'NONE', '-i', 'NONE', + '--embed', + 'test_command_count.in'}) + helpers.set_session(nvim2) + + source([[ + lang C + let g:lines = [] + com -range=% RangeLines + \ :call add(g:lines, 'RangeLines '.<line1>.' '.<line2>) + com -range -addr=arguments RangeArguments + \ :call add(g:lines, 'RangeArguments '.<line1>.' '.<line2>) + com -range=% -addr=arguments RangeArgumentsAll + \ :call add(g:lines, 'RangeArgumentsAll '.<line1>.' '.<line2>) + com -range -addr=loaded_buffers RangeLoadedBuffers + \ :call add(g:lines, 'RangeLoadedBuffers '.<line1>.' '.<line2>) + com -range=% -addr=loaded_buffers RangeLoadedBuffersAll + \ :call add(g:lines, 'RangeLoadedBuffersAll '.<line1>.' '.<line2>) + com -range -addr=buffers RangeBuffers + \ :call add(g:lines, 'RangeBuffers '.<line1>.' '.<line2>) + com -range=% -addr=buffers RangeBuffersAll + \ :call add(g:lines, 'RangeBuffersAll '.<line1>.' '.<line2>) + com -range -addr=windows RangeWindows + \ :call add(g:lines, 'RangeWindows '.<line1>.' '.<line2>) + com -range=% -addr=windows RangeWindowsAll + \ :call add(g:lines, 'RangeWindowsAll '.<line1>.' '.<line2>) + com -range -addr=tabs RangeTabs + \ :call add(g:lines, 'RangeTabs '.<line1>.' '.<line2>) + com -range=% -addr=tabs RangeTabsAll + \ :call add(g:lines, 'RangeTabsAll '.<line1>.' '.<line2>) + ]]) execute('set hidden') execute('arga a b c d') execute('argdo echo "loading buffers"') @@ -141,6 +163,7 @@ describe('command_count', function() execute([[let buffers = '']]) execute([[.,$-bufdo let buffers .= ' '.bufnr('%')]]) execute([[call add(g:lines, 'bufdo:' . buffers)]]) + execute('3bd') -- Added after e949c2bd62f399a04ae23570203d61344bdd69e9 execute([[let buffers = '']]) execute([[3,7bufdo let buffers .= ' '.bufnr('%')]]) execute([[call add(g:lines, 'bufdo:' . buffers)]]) @@ -153,7 +176,7 @@ describe('command_count', function() execute([[call append('$', g:lines)]]) -- Assert buffer contents. - expect([=[ + expect([[ RangeArguments 2 4 RangeArguments 1 5 RangeArgumentsAll 1 5 @@ -190,7 +213,7 @@ describe('command_count', function() argdo: c d e windo: 2 3 4 bufdo: 2 3 4 5 6 7 8 9 10 15 - bufdo: 3 4 5 6 7 - tabdo: 2 3 4]=]) + bufdo: 4 5 6 7 + tabdo: 2 3 4]]) end) end) |