aboutsummaryrefslogtreecommitdiff
path: root/test/functional/legacy/command_count_spec.lua
diff options
context:
space:
mode:
authorLucas Hoffmann <l-m-h@web.de>2016-02-04 19:06:53 +0100
committerLucas Hoffmann <l-m-h@web.de>2016-02-04 19:25:07 +0100
commitad83cd82e1b94e4ca994509914945ea837d0198a (patch)
treebd249ccdc899d584c942d79922a21b8d60927229 /test/functional/legacy/command_count_spec.lua
parentc1b0c45bee5faaf966d36c9ceab119709a47834a (diff)
downloadrneovim-ad83cd82e1b94e4ca994509914945ea837d0198a.tar.gz
rneovim-ad83cd82e1b94e4ca994509914945ea837d0198a.tar.bz2
rneovim-ad83cd82e1b94e4ca994509914945ea837d0198a.zip
tests: Simplify migrated legacy test.
Diffstat (limited to 'test/functional/legacy/command_count_spec.lua')
-rw-r--r--test/functional/legacy/command_count_spec.lua236
1 files changed, 130 insertions, 106 deletions
diff --git a/test/functional/legacy/command_count_spec.lua b/test/functional/legacy/command_count_spec.lua
index de7bb7d2a7..d9b4f09263 100644
--- a/test/functional/legacy/command_count_spec.lua
+++ b/test/functional/legacy/command_count_spec.lua
@@ -15,9 +15,8 @@ describe('command_count', function()
-- 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'})
+ local nvim2 = spawn({nvim_prog, '-u', 'NONE', '-i', 'NONE', '--embed',
+ 'test_command_count.in'})
helpers.set_session(nvim2)
source([[
@@ -45,45 +44,54 @@ describe('command_count', function()
\ :call add(g:lines, 'RangeTabs '.<line1>.' '.<line2>)
com -range=% -addr=tabs RangeTabsAll
\ :call add(g:lines, 'RangeTabsAll '.<line1>.' '.<line2>)
+ set hidden
+ arga a b c d
+ argdo echo "loading buffers"
+ argu 3
+ .-,$-RangeArguments
+ %RangeArguments
+ RangeArgumentsAll
+ N
+ .RangeArguments
+ split
+ split
+ split
+ split
+ 3wincmd w
+ .,$RangeWindows
+ %RangeWindows
+ RangeWindowsAll
+ only
+ blast
+ bd
+ .,$RangeLoadedBuffers
+ %RangeLoadedBuffers
+ RangeLoadedBuffersAll
+ .,$RangeBuffers
+ %RangeBuffers
+ RangeBuffersAll
+ tabe
+ tabe
+ tabe
+ tabe
+ normal 2gt
+ .,$RangeTabs
+ %RangeTabs
+ RangeTabsAll
+ 1tabonly
+ s/\n/\r\r\r\r\r/
+ 2ma<
+ $-ma>
+ '<,'>RangeLines
+ com -range=% -buffer LocalRangeLines
+ \ :call add(g:lines, 'LocalRangeLines '.<line1>.' '.<line2>)
+ '<,'>LocalRangeLines
+ b1
+ call add(g:lines, '')
+ %argd
+ arga a b c d
]])
- execute('set hidden')
- execute('arga a b c d')
- execute('argdo echo "loading buffers"')
- execute('argu 3')
- execute('.-,$-RangeArguments')
- execute('%RangeArguments')
- execute('RangeArgumentsAll')
- execute('N')
- execute('.RangeArguments')
- execute('split|split|split|split')
- execute('3wincmd w')
- execute('.,$RangeWindows')
- execute('%RangeWindows')
- execute('RangeWindowsAll')
- execute('only')
- execute('blast|bd')
- execute('.,$RangeLoadedBuffers')
- execute('%RangeLoadedBuffers')
- execute('RangeLoadedBuffersAll')
- execute('.,$RangeBuffers')
- execute('%RangeBuffers')
- execute('RangeBuffersAll')
- execute('tabe|tabe|tabe|tabe')
- execute('normal 2gt')
- execute('.,$RangeTabs')
- execute('%RangeTabs')
- execute('RangeTabsAll')
- execute('1tabonly')
- execute([[s/\n/\r\r\r\r\r/]])
- execute('2ma<')
- execute('$-ma>')
- execute([['<,'>RangeLines]])
- execute([[com -range=% -buffer LocalRangeLines :call add(g:lines, 'LocalRangeLines '.<line1>.' '.<line2>)]])
- execute([['<,'>LocalRangeLines]])
- execute('b1')
- execute([[call add(g:lines, '')]])
- execute('%argd')
- execute('arga a b c d')
+ -- This can not be in the source() call as it will produce errors.
execute([[let v:errmsg = '']])
execute('5argu')
execute([[call add(g:lines, '5argu ' . v:errmsg)]])
@@ -95,7 +103,10 @@ describe('command_count', function()
execute([[let v:errmsg = '']])
execute('100b')
execute([[call add(g:lines, '100b ' . v:errmsg)]])
- execute('split|split|split|split')
+ execute('split')
+ execute('split')
+ execute('split')
+ execute('split')
execute([[let v:errmsg = '']])
execute('0close')
execute([[call add(g:lines, '0close ' . v:errmsg)]])
@@ -110,70 +121,83 @@ describe('command_count', function()
execute([[let v:errmsg = '']])
execute('$+tabe')
execute([[call add(g:lines, '$+tabe ' . v:errmsg)]])
- execute('only!')
- execute('e x')
- execute('0tabm')
- execute('normal 1gt')
- execute([[call add(g:lines, '0tabm ' . expand('%:t'))]])
- execute('tabonly!')
- execute('only!')
- execute('e! test.out')
- execute('call append(0, g:lines)')
- execute('unlet g:lines')
- execute('w|bd')
- execute('b1')
- execute('let g:lines = []')
- execute('func BufStatus()')
- execute([[ call add(g:lines, 'aaa: ' . buflisted(g:buf_aaa) . ' bbb: ' . buflisted(g:buf_bbb) . ' ccc: ' . buflisted(g:buf_ccc))]])
- execute('endfunc')
- execute('se nohidden')
- execute('e aaa')
- execute([[let buf_aaa = bufnr('%')]])
- execute('e bbb')
- execute([[let buf_bbb = bufnr('%')]])
- execute('e ccc')
- execute([[let buf_ccc = bufnr('%')]])
- execute('b1')
- execute('call BufStatus()')
- execute('exe buf_bbb . "," . buf_ccc . "bdelete"')
- execute('call BufStatus()')
- execute('exe buf_aaa . "bdelete"')
- execute('call BufStatus()')
- execute('e! test.out')
- execute([[call append('$', g:lines)]])
- execute('unlet g:lines')
- execute('delfunc BufStatus')
- execute('w|bd')
- execute('b1')
- execute('se hidden')
- execute('only!')
- execute('let g:lines = []')
- execute('%argd')
- execute('arga a b c d e f')
- execute('3argu')
- execute([[let args = '']])
- execute([[.,$-argdo let args .= ' '.expand('%')]])
- execute([[call add(g:lines, 'argdo:' . args)]])
- execute('split|split|split|split')
- execute('2wincmd w')
- execute([[let windows = '']])
- execute([[.,$-windo let windows .= ' '.winnr()]])
- execute([[call add(g:lines, 'windo:'. windows)]])
- execute('b2')
- 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)]])
- execute('tabe|tabe|tabe|tabe')
- execute('normal! 2gt')
- execute([[let tabpages = '']])
- execute([[.,$-tabdo let tabpages .= ' '.tabpagenr()]])
- execute([[call add(g:lines, 'tabdo:' . tabpages)]])
- execute('e! test.out')
- execute([[call append('$', g:lines)]])
+ source([[
+ only!
+ e x
+ 0tabm
+ normal 1gt
+ call add(g:lines, '0tabm ' . expand('%:t'))
+ tabonly!
+ only!
+ e! test.out
+ call append(0, g:lines)
+ unlet g:lines
+ w
+ bd
+ b1
+ let g:lines = []
+ func BufStatus()
+ call add(g:lines,
+ \ 'aaa: ' . buflisted(g:buf_aaa) .
+ \ ' bbb: ' . buflisted(g:buf_bbb) .
+ \ ' ccc: ' . buflisted(g:buf_ccc))
+ endfunc
+ se nohidden
+ e aaa
+ let buf_aaa = bufnr('%')
+ e bbb
+ let buf_bbb = bufnr('%')
+ e ccc
+ let buf_ccc = bufnr('%')
+ b1
+ call BufStatus()
+ exe buf_bbb . "," . buf_ccc . "bdelete"
+ call BufStatus()
+ exe buf_aaa . "bdelete"
+ call BufStatus()
+ e! test.out
+ call append('$', g:lines)
+ unlet g:lines
+ delfunc BufStatus
+ w
+ bd
+ b1
+ se hidden
+ only!
+ let g:lines = []
+ %argd
+ arga a b c d e f
+ 3argu
+ let args = ''
+ .,$-argdo let args .= ' '.expand('%')
+ call add(g:lines, 'argdo:' . args)
+ split
+ split
+ split
+ split
+ 2wincmd w
+ let windows = ''
+ .,$-windo let windows .= ' '.winnr()
+ call add(g:lines, 'windo:'. windows)
+ b2
+ let buffers = ''
+ .,$-bufdo let buffers .= ' '.bufnr('%')
+ call add(g:lines, 'bufdo:' . buffers)
+ 3bd
+ let buffers = ''
+ 3,7bufdo let buffers .= ' '.bufnr('%')
+ call add(g:lines, 'bufdo:' . buffers)
+ tabe
+ tabe
+ tabe
+ tabe
+ normal! 2gt
+ let tabpages = ''
+ .,$-tabdo let tabpages .= ' '.tabpagenr()
+ call add(g:lines, 'tabdo:' . tabpages)
+ e! test.out
+ call append('$', g:lines)
+ ]])
-- Assert buffer contents.
expect([[