Patch 8.0.0019
Problem: Test_command_count is old style.
Solution: Turn it into a new style test. (Naruhiko Nishino)
Use more assert functions.
Files: src/Makefile, src/testdir/Make_all.mak, src/testdir/test_alot.vim,
src/testdir/test_autocmd.vim, src/testdir/test_command_count.in,
src/testdir/test_command_count.ok,
src/testdir/test_command_count.vim
*** ../vim-8.0.0018/src/Makefile 2016-09-26 20:14:49.921906772 +0200
--- src/Makefile 2016-09-29 19:23:13.153274891 +0200
***************
*** 2028,2034 ****
test_breakindent \
test_changelist \
test_close_count \
- test_command_count \
test_comparators \
test_erasebackword \
test_eval \
--- 2028,2033 ----
***************
*** 2066,2071 ****
--- 2065,2071 ----
test_channel \
test_charsearch \
test_cmdline \
+ test_command_count \
test_crypt \
test_cscope \
test_cursor_func \
*** ../vim-8.0.0018/src/testdir/Make_all.mak 2016-09-26 20:14:49.921906772
+0200
--- src/testdir/Make_all.mak 2016-09-29 19:11:33.650159645 +0200
***************
*** 79,85 ****
test_breakindent.out \
test_changelist.out \
test_close_count.out \
- test_command_count.out \
test_comparators.out \
test_erasebackword.out \
test_eval.out \
--- 79,84 ----
*** ../vim-8.0.0018/src/testdir/test_alot.vim 2016-09-11 14:34:48.000000000
+0200
--- src/testdir/test_alot.vim 2016-09-29 19:11:33.650159645 +0200
***************
*** 3,8 ****
--- 3,9 ----
source test_assign.vim
source test_autocmd.vim
+ source test_command_count.vim
source test_cursor_func.vim
source test_delete.vim
source test_execute_func.vim
*** ../vim-8.0.0018/src/testdir/test_autocmd.vim 2016-09-08
22:06:01.000000000 +0200
--- src/testdir/test_autocmd.vim 2016-09-29 19:11:33.650159645 +0200
***************
*** 1,5 ****
--- 1,13 ----
" Tests for autocommands
+ function! s:cleanup_buffers() abort
+ for bnr in range(1, bufnr('$'))
+ if bufloaded(bnr) && bufnr('%') != bnr
+ execute 'bd! ' . bnr
+ endif
+ endfor
+ endfunction
+
func Test_vim_did_enter()
call assert_false(v:vim_did_enter)
***************
*** 254,259 ****
--- 262,270 ----
" Tests for autocommands on :close command.
" This used to be in test13.
func Test_three_windows()
+ " Clean up buffers, because in some cases this function fails.
+ call s:cleanup_buffers()
+
" Write three files and open them, each in a window.
" Then go to next window, with autocommand that deletes the previous one.
" Do this twice, writing the file.
*** ../vim-8.0.0018/src/testdir/test_command_count.in 2015-02-27
20:03:15.000000000 +0100
--- src/testdir/test_command_count.in 1970-01-01 01:00:00.000000000 +0100
***************
*** 1,158 ****
- Test for user command counts vim: set ft=vim :
-
- STARTTEST
- :so small.vim
- :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>)
- :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
- ENDTEST
-
- STARTTEST
- :call add(g:lines, '')
- :%argd
- :arga a b c d
- :let v:errmsg = ''
- :5argu
- :call add(g:lines, '5argu ' . v:errmsg)
- :$argu
- :call add(g:lines, '4argu ' . expand('%:t'))
- :let v:errmsg = ''
- :1argu
- :call add(g:lines, '1argu ' . expand('%:t'))
- :let v:errmsg = ''
- :100b
- :call add(g:lines, '100b ' . v:errmsg)
- :split|split|split|split
- :let v:errmsg = ''
- :0close
- :call add(g:lines, '0close ' . v:errmsg)
- :$wincmd w
- :$close
- :call add(g:lines, '$close ' . winnr())
- :let v:errmsg = ''
- :$+close
- :call add(g:lines, '$+close ' . v:errmsg)
- :$tabe
- :call add(g:lines, '$tabe ' . tabpagenr())
- :let v:errmsg = ''
- :$+tabe
- :call add(g:lines, '$+tabe ' . v:errmsg)
- :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
- ENDTEST
-
- STARTTEST
- :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
- ENDTEST
-
- STARTTEST
- :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)
- :w|qa!
- ENDTEST
-
-
--- 0 ----
*** ../vim-8.0.0018/src/testdir/test_command_count.ok 2015-02-27
20:03:15.000000000 +0100
--- src/testdir/test_command_count.ok 1970-01-01 01:00:00.000000000 +0100
***************
*** 1,38 ****
- RangeArguments 2 4
- RangeArguments 1 5
- RangeArgumentsAll 1 5
- RangeArguments 2 2
- RangeWindows 3 5
- RangeWindows 1 5
- RangeWindowsAll 1 5
- RangeLoadedBuffers 2 4
- RangeLoadedBuffers 1 4
- RangeLoadedBuffersAll 1 4
- RangeBuffers 2 5
- RangeBuffers 1 5
- RangeBuffersAll 1 5
- RangeTabs 2 5
- RangeTabs 1 5
- RangeTabsAll 1 5
- RangeLines 2 5
- LocalRangeLines 2 5
-
- 5argu E16: Invalid range
- 4argu d
- 1argu a
- 100b E16: Invalid range
- 0close
- $close 3
- $+close E16: Invalid range
- $tabe 2
- $+tabe E16: Invalid range
- 0tabm x
-
- aaa: 1 bbb: 1 ccc: 1
- aaa: 1 bbb: 0 ccc: 0
- aaa: 0 bbb: 0 ccc: 0
- argdo: c d e
- windo: 2 3 4
- bufdo: 2 3 4 5 6 7 8 9 10 15
- bufdo: 4 5 6 7
- tabdo: 2 3 4
--- 0 ----
*** ../vim-8.0.0018/src/testdir/test_command_count.vim 2016-09-29
20:53:54.971440078 +0200
--- src/testdir/test_command_count.vim 2016-09-29 20:49:32.317263612 +0200
***************
*** 0 ****
--- 1,191 ----
+ " Test for user command counts.
+
+ func Test_command_count_0()
+ set hidden
+ set noswapfile
+
+ split DoesNotExistEver
+ let lastbuf = bufnr('$')
+ call setline(1, 'asdf')
+ quit!
+
+ command! -range -addr=loaded_buffers RangeLoadedBuffers :let lines =
[<line1>, <line2>]
+ command! -range=% -addr=loaded_buffers RangeLoadedBuffersAll :let lines =
[<line1>, <line2>]
+ command! -range -addr=buffers RangeBuffers :let lines = [<line1>, <line2>]
+ command! -range=% -addr=buffers RangeBuffersAll :let lines = [<line1>,
<line2>]
+
+ .,$RangeLoadedBuffers
+ call assert_equal([1, 1], lines)
+ %RangeLoadedBuffers
+ call assert_equal([1, 1], lines)
+ RangeLoadedBuffersAll
+ call assert_equal([1, 1], lines)
+ .,$RangeBuffers
+ call assert_equal([1, lastbuf], lines)
+ %RangeBuffers
+ call assert_equal([1, lastbuf], lines)
+ RangeBuffersAll
+ call assert_equal([1, lastbuf], lines)
+
+ delcommand RangeLoadedBuffers
+ delcommand RangeLoadedBuffersAll
+ delcommand RangeBuffers
+ delcommand RangeBuffersAll
+
+ set hidden&
+ set swapfile&
+ endfunc
+
+ func Test_command_count_1()
+ silent! %argd
+ arga a b c d e
+ argdo echo "loading buffers"
+ argu 3
+ command! -range -addr=arguments RangeArguments :let lines = [<line1>,
<line2>]
+ command! -range=% -addr=arguments RangeArgumentsAll :let lines = [<line1>,
<line2>]
+ .-,$-RangeArguments
+ call assert_equal([2, 4], lines)
+ %RangeArguments
+ call assert_equal([1, 5], lines)
+ RangeArgumentsAll
+ call assert_equal([1, 5], lines)
+ N
+ .RangeArguments
+ call assert_equal([2, 2], lines)
+ delcommand RangeArguments
+ delcommand RangeArgumentsAll
+
+ split|split|split|split
+ 3wincmd w
+ command! -range -addr=windows RangeWindows :let lines = [<line1>, <line2>]
+ .,$RangeWindows
+ call assert_equal([3, 5], lines)
+ %RangeWindows
+ call assert_equal([1, 5], lines)
+ delcommand RangeWindows
+
+ command! -range=% -addr=windows RangeWindowsAll :let lines = [<line1>,
<line2>]
+ RangeWindowsAll
+ call assert_equal([1, 5], lines)
+ delcommand RangeWindowsAll
+ only
+ blast|bd
+
+ tabe|tabe|tabe|tabe
+ normal 2gt
+ command! -range -addr=tabs RangeTabs :let lines = [<line1>, <line2>]
+ .,$RangeTabs
+ call assert_equal([2, 5], lines)
+ %RangeTabs
+ call assert_equal([1, 5], lines)
+ delcommand RangeTabs
+
+ command! -range=% -addr=tabs RangeTabsAll :let lines = [<line1>, <line2>]
+ RangeTabsAll
+ call assert_equal([1, 5], lines)
+ delcommand RangeTabsAll
+ 1tabonly
+
+ s/\n/\r\r\r\r\r/
+ 2ma<
+ $-ma>
+ command! -range=% RangeLines :let lines = [<line1>, <line2>]
+ '<,'>RangeLines
+ call assert_equal([2, 5], lines)
+ delcommand RangeLines
+
+ command! -range=% -buffer LocalRangeLines :let lines = [<line1>, <line2>]
+ '<,'>LocalRangeLines
+ call assert_equal([2, 5], lines)
+ delcommand LocalRangeLines
+ endfunc
+
+ func Test_command_count_2()
+ silent! %argd
+ arga a b c d
+ call assert_fails('5argu', 'E16:')
+
+ $argu
+ call assert_equal('d', expand('%:t'))
+
+ 1argu
+ call assert_equal('a', expand('%:t'))
+
+ call assert_fails('300b', 'E16:')
+
+ split|split|split|split
+ 0close
+
+ $wincmd w
+ $close
+ call assert_equal(3, winnr())
+
+ call assert_fails('$+close', 'E16:')
+
+ $tabe
+ call assert_equal(2, tabpagenr())
+
+ call assert_fails('$+tabe', 'E16:')
+
+ only!
+ e x
+ 0tabm
+ normal 1gt
+ call assert_equal('x', expand('%:t'))
+
+ tabonly!
+ only!
+ endfunc
+
+ func Test_command_count_3()
+ se nohidden
+ e aaa
+ let buf_aaa = bufnr('%')
+ e bbb
+ let buf_bbb = bufnr('%')
+ e ccc
+ let buf_ccc = bufnr('%')
+ buf 1
+ call assert_equal([1, 1, 1], [buflisted(buf_aaa), buflisted(buf_bbb),
buflisted(buf_ccc)])
+ exe buf_bbb . "," . buf_ccc . "bdelete"
+ call assert_equal([1, 0, 0], [buflisted(buf_aaa), buflisted(buf_bbb),
buflisted(buf_ccc)])
+ exe buf_aaa . "bdelete"
+ call assert_equal([0, 0, 0], [buflisted(buf_aaa), buflisted(buf_bbb),
buflisted(buf_ccc)])
+ endfunc
+
+ func Test_command_count_4()
+ %argd
+ let bufnr = bufnr('$') + 1
+ arga aa bb cc dd ee ff
+ 3argu
+ let args = []
+ .,$-argdo call add(args, expand('%'))
+ call assert_equal(['cc', 'dd', 'ee'], args)
+
+ " create windows to get 5
+ split|split|split|split
+ 2wincmd w
+ let windows = []
+ .,$-windo call add(windows, winnr())
+ call assert_equal([2, 3, 4], windows)
+ only!
+
+ exe bufnr . 'buf'
+ let buffers = []
+ .,$-bufdo call add(buffers, bufnr('%'))
+ call assert_equal([bufnr, bufnr + 1, bufnr + 2, bufnr + 3, bufnr + 4],
buffers)
+
+ exe (bufnr + 3) . 'bdel'
+ let buffers = []
+ exe (bufnr + 2) . ',' . (bufnr + 5) . "bufdo call add(buffers, bufnr('%'))"
+ call assert_equal([bufnr + 2, bufnr + 4, bufnr + 5], buffers)
+
+ " create tabpages to get 5
+ tabe|tabe|tabe|tabe
+ normal! 2gt
+ let tabpages = []
+ .,$-tabdo call add(tabpages, tabpagenr())
+ call assert_equal([2, 3, 4], tabpages)
+ tabonly!
+ bwipe!
+ endfunc
*** ../vim-8.0.0018/src/version.c 2016-09-29 15:18:51.359768012 +0200
--- src/version.c 2016-09-29 20:50:17.684948652 +0200
***************
*** 766,767 ****
--- 766,769 ----
{ /* Add new patch number below this line */
+ /**/
+ 19,
/**/
--
A computer programmer is a device for turning requirements into
undocumented features. It runs on cola, pizza and Dilbert cartoons.
Bram Moolenaar
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.