Patch 7.4.980
Problem:    Tests for :cdo, :ldo, etc. are outdated.
Solution:   Add new style tests for these commands. (Yegappan Lakshmanan)
Files:      src/testdir/Make_amiga.mak, src/testdir/Make_dos.mak,
            src/testdir/Make_ming.mak, src/testdir/Make_os2.mak,
            src/testdir/Make_vms.mms, src/testdir/Makefile,
            src/testdir/test_cdo.in, src/testdir/test_cdo.ok,
            src/testdir/test_cdo.vim


*** ../vim-7.4.979/src/testdir/Make_amiga.mak   2015-12-03 16:54:21.970106719 
+0100
--- src/testdir/Make_amiga.mak  2015-12-28 13:53:35.147680085 +0100
***************
*** 41,47 ****
                test_autocmd_option.out \
                test_autoformat_join.out \
                test_breakindent.out \
-               test_cdo.out \
                test_changelist.out \
                test_charsearch.out \
                test_close_count.out \
--- 41,46 ----
***************
*** 197,203 ****
  test_autocmd_option.out: test_autocmd_option.in
  test_autoformat_join.out: test_autoformat_join.in
  test_breakindent.out: test_breakindent.in
- test_cdo.out: test_cdo.in
  test_changelist.out: test_changelist.in
  test_charsearch.out: test_charsearch.in
  test_close_count.out: test_close_count.in
--- 196,201 ----
*** ../vim-7.4.979/src/testdir/Make_dos.mak     2015-12-03 16:54:21.970106719 
+0100
--- src/testdir/Make_dos.mak    2015-12-28 13:53:35.147680085 +0100
***************
*** 40,46 ****
                test_autocmd_option.out \
                test_autoformat_join.out \
                test_breakindent.out \
-               test_cdo.out \
                test_changelist.out \
                test_charsearch.out \
                test_close_count.out \
--- 40,45 ----
*** ../vim-7.4.979/src/testdir/Make_ming.mak    2015-12-03 16:54:21.970106719 
+0100
--- src/testdir/Make_ming.mak   2015-12-28 13:53:35.147680085 +0100
***************
*** 62,68 ****
                test_autocmd_option.out \
                test_autoformat_join.out \
                test_breakindent.out \
-               test_cdo.out \
                test_changelist.out \
                test_charsearch.out \
                test_close_count.out \
--- 62,67 ----
*** ../vim-7.4.979/src/testdir/Make_os2.mak     2015-12-03 16:54:21.970106719 
+0100
--- src/testdir/Make_os2.mak    2015-12-28 13:53:35.147680085 +0100
***************
*** 42,48 ****
                test_autocmd_option.out \
                test_autoformat_join.out \
                test_breakindent.out \
-               test_cdo.out \
                test_changelist.out \
                test_charsearch.out \
                test_close_count.out \
--- 42,47 ----
*** ../vim-7.4.979/src/testdir/Make_vms.mms     2015-12-03 16:54:21.970106719 
+0100
--- src/testdir/Make_vms.mms    2015-12-28 13:53:35.151680041 +0100
***************
*** 101,107 ****
         test_autocmd_option.out \
         test_autoformat_join.out \
         test_breakindent.out \
-        test_cdo.out \
         test_changelist.out \
         test_charsearch.out \
         test_close_count.out \
--- 101,106 ----
*** ../vim-7.4.979/src/testdir/Makefile 2015-12-05 20:56:52.805365468 +0100
--- src/testdir/Makefile        2015-12-28 14:03:09.501457529 +0100
***************
*** 41,47 ****
                test_autocmd_option.out \
                test_autoformat_join.out \
                test_breakindent.out \
-               test_cdo.out \
                test_changelist.out \
                test_charsearch.out \
                test_close_count.out \
--- 41,46 ----
***************
*** 72,77 ****
--- 71,77 ----
                test_writefile.out
  
  NEW_TESTS = test_assert.res \
+           test_cdo.res \
            test_alot.res
  
  SCRIPTS_GUI = test16.out
***************
*** 173,176 ****
  newtests: $(NEW_TESTS)
  
  .vim.res:
!       $(RUN_VIMTEST) -u runtest.vim $*.vim
--- 173,176 ----
  newtests: $(NEW_TESTS)
  
  .vim.res:
!       $(RUN_VIMTEST) -S runtest.vim $*.vim
*** ../vim-7.4.979/src/testdir/test_cdo.in      2015-12-19 15:15:49.888288506 
+0100
--- src/testdir/test_cdo.in     1970-01-01 01:00:00.000000000 +0100
***************
*** 1,108 ****
- Tests for the :cdo, :cfdo, :ldo and :lfdo commands
- 
- STARTTEST
- :so small.vim
- :lang mess C
- :if !has('quickfix') | e! test.ok | wq! test.out | endif
- 
- :call writefile(["Line1", "Line2", "Line3"], 'Xtestfile1')
- :call writefile(["Line1", "Line2", "Line3"], 'Xtestfile2')
- :call writefile(["Line1", "Line2", "Line3"], 'Xtestfile3')
- 
- :function RunTests(cchar)
- :  let nl="\n"
- 
- :  enew
- :  " Try with an empty list
- :  exe a:cchar . "do let g:result .= expand('%') . ' ' . line('.') . 'L' . ' 
' . col('.') . 'C' . nl"
- 
- :  " Populate the list and then try
- :  exe a:cchar . "getexpr ['non-error 1', 'Xtestfile1:1:3:Line1', 'non-error 
2', 'Xtestfile2:2:2:Line2', 'non-error 3', 'Xtestfile3:3:1:Line3']"
- :  exe a:cchar . "do let g:result .= expand('%') . ' ' . line('.') . 'L' . ' 
' . col('.') . 'C' . nl"
- 
- :  " Run command only on selected error lines
- :  enew
- :  exe "2,3" . a:cchar . "do let g:result .= expand('%') . ' ' . line('.') . 
'L' . ' ' . col('.') . 'C' . nl"
- :  " Boundary condition tests
- :  enew
- :  exe "1,1" . a:cchar . "do let g:result .= expand('%') . ' ' . line('.') . 
'L' . ' ' . col('.') . 'C' . nl"
- :  enew
- :  exe "3" . a:cchar . "do let g:result .= expand('%') . ' ' . line('.') . 
'L' . ' ' . col('.') . 'C' . nl"
- :  " Range test commands
- :  enew
- :  exe "%" . a:cchar . "do let g:result .= expand('%') . ' ' . line('.') . 
'L' . ' ' . col('.') . 'C' . nl"
- :  enew
- :  exe "1,$" . a:cchar . "do let g:result .= expand('%') . ' ' . line('.') . 
'L' . ' ' . col('.') . 'C' . nl"
- :  enew
- :  exe a:cchar . 'prev'
- :  exe "." . a:cchar . "do let g:result .= expand('%') . ' ' . line('.') . 
'L' . ' ' . col('.') . 'C' . nl"
- :  " Invalid error lines test
- :  enew
- :  exe "27" . a:cchar . "do let g:result .= expand('%') . ' ' . line('.') . 
'L' . ' ' . col('.') . 'C' . nl"
- :  exe "4,5" . a:cchar . "do let g:result .= expand('%') . ' ' . line('.') . 
'L' . ' ' . col('.') . 'C' . nl"
- 
- :  " Run commands from an unsaved buffer
- :  let v:errmsg=''
- :  enew
- :  setlocal modified
- :  exe "2,2" . a:cchar . "do let g:result .= expand('%') . ' ' . line('.') . 
'L' . ' ' . col('.') . 'C' . nl"
- :  if v:errmsg =~# 'No write since last change'
- :     let g:result .= 'Unsaved file change test passed' . nl
- :  else
- :     let g:result .= 'Unsaved file change test failed' . nl
- :  endif
- 
- :  " If the executed command fails, then the operation should be aborted
- :  enew!
- :  let subst_count = 0
- :  exe a:cchar . "do s/Line/xLine/ | let subst_count += 1"
- :  if subst_count == 1 && getline('.') == 'xLine1'
- :     let g:result .= 'Abort command on error test passed' . nl
- :  else
- :     let g:result .= 'Abort command on error test failed' . nl
- :  endif
- 
- :  exe "2,2" . a:cchar . "do! let g:result .= expand('%') . ' ' . line('.') . 
'L' . ' ' . col('.') . 'C' . nl"
- 
- :  " List with no valid error entries
- :  edit! +2 Xtestfile1
- :  exe a:cchar . "getexpr ['non-error 1', 'non-error 2', 'non-error 3']"
- :  exe a:cchar . "do let g:result .= expand('%') . ' ' . line('.') . 'L' . ' 
' . col('.') . 'C' . nl"
- :  exe "2" . a:cchar . "do let g:result .= expand('%') . ' ' . line('.') . 
'L' . ' ' . col('.') . 'C' . nl"
- :  let v:errmsg=''
- :  exe "%" . a:cchar . "do let g:result .= expand('%') . ' ' . line('.') . 
'L' . ' ' . col('.') . 'C' . nl"
- :  exe "1,$" . a:cchar . "do let g:result .= expand('%') . ' ' . line('.') . 
'L' . ' ' . col('.') . 'C' . nl"
- :  exe "." . a:cchar . "do let g:result .= expand('%') . ' ' . line('.') . 
'L' . ' ' . col('.') . 'C' . nl"
- :  let g:result .= v:errmsg
- 
- :  " List with only one valid entry
- :  exe a:cchar . "getexpr ['Xtestfile3:3:1:Line3']"
- :  exe a:cchar . "do let g:result .= expand('%') . ' ' . line('.') . 'L' . ' 
' . col('.') . 'C' . nl"
- 
- :  " Tests for :cfdo and :lfdo commands
- :  exe a:cchar . "getexpr ['non-error 1', 'Xtestfile1:1:3:Line1', 
'Xtestfile1:2:1:Line2', 'non-error 2', 'Xtestfile2:2:2:Line2', 'non-error 3', 
'Xtestfile3:2:3:Line2', 'Xtestfile3:3:1:Line3']"
- :  exe a:cchar . "fdo let g:result .= expand('%') . ' ' . line('.') . 'L' . ' 
' . col('.') . 'C' . nl"
- :  exe "3" . a:cchar . "fdo let g:result .= expand('%') . ' ' . line('.') . 
'L' . ' ' . col('.') . 'C' . nl"
- :  exe "2,3" . a:cchar . "fdo let g:result .= expand('%') . ' ' . line('.') . 
'L' . ' ' . col('.') . 'C' . nl"
- :  exe "%" . a:cchar . "fdo let g:result .= expand('%') . ' ' . line('.') . 
'L' . ' ' . col('.') . 'C' . nl"
- :  exe "1,$" . a:cchar . "fdo let g:result .= expand('%') . ' ' . line('.') . 
'L' . ' ' . col('.') . 'C' . nl"
- :  exe a:cchar . 'pfile'
- :  exe "." . a:cchar . "fdo let g:result .= expand('%') . ' ' . line('.') . 
'L' . ' ' . col('.') . 'C' . nl"
- 
- :  " List with only one valid entry
- :  exe a:cchar . "getexpr ['Xtestfile2:2:5:Line2']"
- :  exe a:cchar . "fdo let g:result .= expand('%') . ' ' . line('.') . 'L' . ' 
' . col('.') . 'C' . nl"
- :endfunction
- 
- :let result=''
- :" Tests for the :cdo quickfix list command
- :call RunTests('c')
- :let result .= "\n"
- :" Tests for the :ldo location list command
- :call RunTests('l')
- 
- :edit! test.out
- :0put =result
- :wq!
- ENDTEST
- 
--- 0 ----
*** ../vim-7.4.979/src/testdir/test_cdo.ok      2015-09-08 18:46:04.349233550 
+0200
--- src/testdir/test_cdo.ok     1970-01-01 01:00:00.000000000 +0100
***************
*** 1,66 ****
- Xtestfile1 1L 3C
- Xtestfile2 2L 2C
- Xtestfile3 3L 1C
- Xtestfile2 2L 2C
- Xtestfile3 3L 1C
- Xtestfile1 1L 3C
- Xtestfile3 3L 1C
- Xtestfile1 1L 3C
- Xtestfile2 2L 2C
- Xtestfile3 3L 1C
- Xtestfile1 1L 3C
- Xtestfile2 2L 2C
- Xtestfile3 3L 1C
- Xtestfile2 2L 2C
- Unsaved file change test passed
- Abort command on error test passed
- Xtestfile2 2L 2C
- Xtestfile3 3L 1C
- Xtestfile1 1L 3C
- Xtestfile2 2L 2C
- Xtestfile3 2L 3C
- Xtestfile3 2L 3C
- Xtestfile2 2L 2C
- Xtestfile3 2L 3C
- Xtestfile1 1L 3C
- Xtestfile2 2L 2C
- Xtestfile3 2L 3C
- Xtestfile1 1L 3C
- Xtestfile2 2L 2C
- Xtestfile3 2L 3C
- Xtestfile2 2L 2C
- Xtestfile2 2L 5C
- 
- Xtestfile1 1L 3C
- Xtestfile2 2L 2C
- Xtestfile3 3L 1C
- Xtestfile2 2L 2C
- Xtestfile3 3L 1C
- Xtestfile1 1L 3C
- Xtestfile3 3L 1C
- Xtestfile1 1L 3C
- Xtestfile2 2L 2C
- Xtestfile3 3L 1C
- Xtestfile1 1L 3C
- Xtestfile2 2L 2C
- Xtestfile3 3L 1C
- Xtestfile2 2L 2C
- Unsaved file change test passed
- Abort command on error test passed
- Xtestfile2 2L 2C
- Xtestfile3 3L 1C
- Xtestfile1 1L 3C
- Xtestfile2 2L 2C
- Xtestfile3 2L 3C
- Xtestfile3 2L 3C
- Xtestfile2 2L 2C
- Xtestfile3 2L 3C
- Xtestfile1 1L 3C
- Xtestfile2 2L 2C
- Xtestfile3 2L 3C
- Xtestfile1 1L 3C
- Xtestfile2 2L 2C
- Xtestfile3 2L 3C
- Xtestfile2 2L 2C
- Xtestfile2 2L 5C
- 
--- 0 ----
*** ../vim-7.4.979/src/testdir/test_cdo.vim     2015-12-28 14:01:47.630345168 
+0100
--- src/testdir/test_cdo.vim    2015-12-28 13:53:35.151680041 +0100
***************
*** 0 ****
--- 1,206 ----
+ " Tests for the :cdo, :cfdo, :ldo and :lfdo commands
+ 
+ lang mess C
+ if !has('quickfix')
+   finish
+ endif
+ 
+ " Create the files used by the tests
+ function SetUp()
+   call writefile(["Line1", "Line2", "Line3"], 'Xtestfile1')
+   call writefile(["Line1", "Line2", "Line3"], 'Xtestfile2')
+   call writefile(["Line1", "Line2", "Line3"], 'Xtestfile3')
+ endfunction
+ 
+ " Remove the files used by the tests
+ function TearDown()
+   call delete('Xtestfile1')
+   call delete('Xtestfile2')
+   call delete('Xtestfile3')
+ endfunction
+ 
+ " Returns the current line in '<filename> <linenum>L <column>C' format
+ function GetRuler()
+   return expand('%') . ' ' . line('.') . 'L' . ' ' . col('.') . 'C'
+ endfunction
+ 
+ " Tests for the :cdo and :ldo commands
+ function XdoTests(cchar)
+   enew
+ 
+   " Shortcuts for calling the cdo and ldo commands
+   let Xdo = a:cchar . 'do'
+   let Xgetexpr = a:cchar . 'getexpr'
+   let Xprev = a:cchar. 'prev'
+   let XdoCmd = Xdo . ' call add(l, GetRuler())'
+ 
+   " Try with an empty list
+   let l = []
+   exe XdoCmd
+   call assert_equal([], l)
+ 
+   " Populate the list and then try
+   exe Xgetexpr . " ['non-error 1', 'Xtestfile1:1:3:Line1', 'non-error 2', 
'Xtestfile2:2:2:Line2', 'non-error 3', 'Xtestfile3:3:1:Line3']"
+ 
+   let l = []
+   exe XdoCmd
+   call assert_equal(['Xtestfile1 1L 3C', 'Xtestfile2 2L 2C', 'Xtestfile3 3L 
1C'], l)
+ 
+   " Run command only on selected error lines
+   let l = []
+   enew
+   exe "2,3" . XdoCmd
+   call assert_equal(['Xtestfile2 2L 2C', 'Xtestfile3 3L 1C'], l)
+ 
+   " Boundary condition tests
+   let l = []
+   enew
+   exe "1,1" . XdoCmd
+   call assert_equal(['Xtestfile1 1L 3C'], l)
+ 
+   let l = []
+   enew
+   exe "3" . XdoCmd
+   call assert_equal(['Xtestfile3 3L 1C'], l)
+ 
+   " Range test commands
+   let l = []
+   enew
+   exe "%" . XdoCmd
+   call assert_equal(['Xtestfile1 1L 3C', 'Xtestfile2 2L 2C', 'Xtestfile3 3L 
1C'], l)
+ 
+   let l = []
+   enew
+   exe "1,$" . XdoCmd
+   call assert_equal(['Xtestfile1 1L 3C', 'Xtestfile2 2L 2C', 'Xtestfile3 3L 
1C'], l)
+ 
+   let l = []
+   enew
+   exe Xprev
+   exe "." . XdoCmd
+   call assert_equal(['Xtestfile2 2L 2C'], l)
+ 
+   let l = []
+   enew
+   exe "+" . XdoCmd
+   call assert_equal(['Xtestfile3 3L 1C'], l)
+ 
+   " Invalid error lines test
+   let l = []
+   enew
+   exe "silent! 27" . XdoCmd
+   exe "silent! 4,5" . XdoCmd
+   call assert_equal([], l)
+ 
+   " Run commands from an unsaved buffer
+   let v:errmsg=''
+   let l = []
+   enew
+   setlocal modified
+   exe "silent! 2,2" . XdoCmd
+   if v:errmsg !~# 'No write since last change'
+     call add(v:errors, 'Unsaved file change test failed')
+   endif
+ 
+   " If the executed command fails, then the operation should be aborted
+   enew!
+   let subst_count = 0
+   exe "silent!" . Xdo . " s/Line/xLine/ | let subst_count += 1"
+   if subst_count != 1 || getline('.') != 'xLine1'
+     call add(v:errors, 'Abort command on error test failed')
+   endif
+ 
+   let l = []
+   exe "2,2" . Xdo . "! call add(l, GetRuler())"
+   call assert_equal(['Xtestfile2 2L 2C'], l)
+ 
+   " List with no valid error entries
+   let l = []
+   edit! +2 Xtestfile1
+   exe Xgetexpr . " ['non-error 1', 'non-error 2', 'non-error 3']"
+   exe XdoCmd
+   call assert_equal([], l)
+   exe "silent! 2" . XdoCmd
+   call assert_equal([], l)
+   let v:errmsg=''
+   exe "%" . XdoCmd
+   exe "1,$" . XdoCmd
+   exe "." . XdoCmd
+   call assert_equal('', v:errmsg)
+ 
+   " List with only one valid entry
+   let l = []
+   exe Xgetexpr . " ['Xtestfile3:3:1:Line3']"
+   exe XdoCmd
+   call assert_equal(['Xtestfile3 3L 1C'], l)
+ 
+ endfunction
+ 
+ " Tests for the :cfdo and :lfdo commands
+ function XfdoTests(cchar)
+   enew
+ 
+   " Shortcuts for calling the cfdo and lfdo commands
+   let Xfdo = a:cchar . 'fdo'
+   let Xgetexpr = a:cchar . 'getexpr'
+   let XfdoCmd = Xfdo . ' call add(l, GetRuler())'
+   let Xpfile = a:cchar. 'pfile'
+ 
+   " Clear the quickfix/location list
+   exe Xgetexpr . " []"
+ 
+   " Try with an empty list
+   let l = []
+   exe XfdoCmd
+   call assert_equal([], l)
+ 
+   " Populate the list and then try
+   exe Xgetexpr . " ['non-error 1', 'Xtestfile1:1:3:Line1', 
'Xtestfile1:2:1:Line2', 'non-error 2', 'Xtestfile2:2:2:Line2', 'non-error 3', 
'Xtestfile3:2:3:Line2', 'Xtestfile3:3:1:Line3']"
+ 
+   let l = []
+   exe XfdoCmd
+   call assert_equal(['Xtestfile1 1L 3C', 'Xtestfile2 2L 2C', 'Xtestfile3 2L 
3C'], l)
+ 
+   " Run command only on selected error lines
+   let l = []
+   exe "2,3" . XfdoCmd
+   call assert_equal(['Xtestfile2 2L 2C', 'Xtestfile3 2L 3C'], l)
+ 
+   " Boundary condition tests
+   let l = []
+   exe "3" . XfdoCmd
+   call assert_equal(['Xtestfile3 2L 3C'], l)
+ 
+   " Range test commands
+   let l = []
+   exe "%" . XfdoCmd
+   call assert_equal(['Xtestfile1 1L 3C', 'Xtestfile2 2L 2C', 'Xtestfile3 2L 
3C'], l)
+ 
+   let l = []
+   exe "1,$" . XfdoCmd
+   call assert_equal(['Xtestfile1 1L 3C', 'Xtestfile2 2L 2C', 'Xtestfile3 2L 
3C'], l)
+ 
+   let l = []
+   exe Xpfile
+   exe "." . XfdoCmd
+   call assert_equal(['Xtestfile2 2L 2C'], l)
+ 
+   " List with only one valid entry
+   let l = []
+   exe Xgetexpr . " ['Xtestfile2:2:5:Line2']"
+   exe XfdoCmd
+   call assert_equal(['Xtestfile2 2L 5C'], l)
+ 
+ endfunction
+ 
+ " Tests for cdo and cfdo
+ function Test_cdo()
+   call XdoTests('c')
+   call XfdoTests('c')
+ endfunction
+ 
+ " Tests for ldo and lfdo
+ function Test_ldo()
+   call XdoTests('l')
+   call XfdoTests('l')
+ endfunction
*** ../vim-7.4.979/src/version.c        2015-12-19 15:28:14.112228963 +0100
--- src/version.c       2015-12-28 13:56:48.765585829 +0100
***************
*** 743,744 ****
--- 743,746 ----
  {   /* Add new patch number below this line */
+ /**/
+     980,
  /**/

-- 
GUARD #1:  Where'd you get the coconut?
ARTHUR:    We found them.
GUARD #1:  Found them?  In Mercea?  The coconut's tropical!
ARTHUR:    What do you mean?
GUARD #1:  Well, this is a temperate zone.
                                  The Quest for the Holy Grail (Monty Python)

 /// 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.

Raspunde prin e-mail lui