b8c892f
To: vim-dev@vim.org
b8c892f
Subject: patch 7.1.071
b8c892f
Fcc: outbox
b8c892f
From: Bram Moolenaar <Bram@moolenaar.net>
b8c892f
Mime-Version: 1.0
b8c892f
Content-Type: text/plain; charset=ISO-8859-1
b8c892f
Content-Transfer-Encoding: 8bit
b8c892f
------------
b8c892f
b8c892f
Patch 7.1.071 (after 7.1.040)
b8c892f
Problem:    Regexp patterns are not tested.
b8c892f
Solution:   Add a basic test, to be expanded later.
b8c892f
	    Also add (commented-out) support for valgrind.
b8c892f
Files:	    src/testdir/Makefile, src/testdir/test64.in, src/testdir/test64.ok
b8c892f
b8c892f
b8c892f
*** ../vim-7.1.070/src/testdir/Makefile	Thu Jul 26 22:55:11 2007
b8c892f
--- src/testdir/Makefile	Tue Aug 14 15:16:08 2007
b8c892f
***************
b8c892f
*** 4,9 ****
b8c892f
--- 4,13 ----
b8c892f
  
b8c892f
  VIMPROG = ../vim
b8c892f
  
b8c892f
+ # Uncomment this line for using valgrind.
b8c892f
+ # The output goes into a file "valgrind.$PID" (sorry, no test number).
b8c892f
+ # VALGRIND = valgrind --tool=memcheck --num-callers=15 --logfile=valgrind
b8c892f
+ 
b8c892f
  SCRIPTS = test1.out test2.out test3.out test4.out test5.out test6.out \
b8c892f
  		test7.out test8.out test9.out test10.out test11.out \
b8c892f
  		test12.out  test13.out test14.out test15.out test17.out \
b8c892f
***************
b8c892f
*** 15,21 ****
b8c892f
  		test43.out test44.out test45.out test46.out test47.out \
b8c892f
  		test48.out test49.out test51.out test52.out test53.out \
b8c892f
  		test54.out test55.out test56.out test57.out test58.out \
b8c892f
! 		test59.out test60.out test61.out test62.out test63.out
b8c892f
  
b8c892f
  SCRIPTS_GUI = test16.out
b8c892f
  
b8c892f
--- 19,26 ----
b8c892f
  		test43.out test44.out test45.out test46.out test47.out \
b8c892f
  		test48.out test49.out test51.out test52.out test53.out \
b8c892f
  		test54.out test55.out test56.out test57.out test58.out \
b8c892f
! 		test59.out test60.out test61.out test62.out test63.out \
b8c892f
! 		test64.out
b8c892f
  
b8c892f
  SCRIPTS_GUI = test16.out
b8c892f
  
b8c892f
***************
b8c892f
*** 38,44 ****
b8c892f
  
b8c892f
  test1.out: test1.in
b8c892f
  	-rm -f $*.failed tiny.vim small.vim mbyte.vim test.ok X* viminfo
b8c892f
! 	$(VIMPROG) -u unix.vim -U NONE --noplugin -s dotest.in $*.in
b8c892f
  	@/bin/sh -c "if diff test.out $*.ok; \
b8c892f
  		then mv -f test.out $*.out; \
b8c892f
  		else echo; \
b8c892f
--- 43,49 ----
b8c892f
  
b8c892f
  test1.out: test1.in
b8c892f
  	-rm -f $*.failed tiny.vim small.vim mbyte.vim test.ok X* viminfo
b8c892f
! 	$(VALGRIND) $(VIMPROG) -u unix.vim -U NONE --noplugin -s dotest.in $*.in
b8c892f
  	@/bin/sh -c "if diff test.out $*.ok; \
b8c892f
  		then mv -f test.out $*.out; \
b8c892f
  		else echo; \
b8c892f
***************
b8c892f
*** 51,57 ****
b8c892f
  	cp $*.ok test.ok
b8c892f
  	# Sleep a moment to avoid that the xterm title is messed up
b8c892f
  	@-sleep .2
b8c892f
! 	-$(VIMPROG) -u unix.vim -U NONE --noplugin -s dotest.in $*.in
b8c892f
  	@/bin/sh -c "if test -f test.out; then\
b8c892f
  		  if diff test.out $*.ok; \
b8c892f
  		  then mv -f test.out $*.out; \
b8c892f
--- 56,62 ----
b8c892f
  	cp $*.ok test.ok
b8c892f
  	# Sleep a moment to avoid that the xterm title is messed up
b8c892f
  	@-sleep .2
b8c892f
! 	-$(VALGRIND) $(VIMPROG) -u unix.vim -U NONE --noplugin -s dotest.in $*.in
b8c892f
  	@/bin/sh -c "if test -f test.out; then\
b8c892f
  		  if diff test.out $*.ok; \
b8c892f
  		  then mv -f test.out $*.out; \
b8c892f
*** ../vim-7.1.070/src/testdir/test64.in	Tue Aug 14 17:26:28 2007
b8c892f
--- src/testdir/test64.in	Tue Aug 14 16:03:44 2007
b8c892f
***************
b8c892f
*** 0 ****
b8c892f
--- 1,52 ----
b8c892f
+ Test for regexp patterns.
b8c892f
+ 
b8c892f
+ A pattern that gives the expected result produces OK, so that we know it was
b8c892f
+ actually tried.
b8c892f
+ 
b8c892f
+ STARTTEST
b8c892f
+ :so small.vim
b8c892f
+ :" tl is a List of Lists with:
b8c892f
+ :"    regexp pattern
b8c892f
+ :"    text to test the pattern on
b8c892f
+ :"    expected match (optional)
b8c892f
+ :"    expected submatch 1 (optional)
b8c892f
+ :"    expected submatch 2 (optional)
b8c892f
+ :"    etc.
b8c892f
+ :"  When there is no match use only the first two items.
b8c892f
+ :let tl = []
b8c892f
+ :call add(tl, ['b', 'abcdef', 'b'])
b8c892f
+ :call add(tl, ['bc*', 'abccccdef', 'bcccc'])
b8c892f
+ :call add(tl, ['bc\{-}', 'abccccdef', 'b'])
b8c892f
+ :call add(tl, ['bc\{-}\(d\)', 'abccccdef', 'bccccd', 'd'])
b8c892f
+ :call add(tl, ['x', 'abcdef'])
b8c892f
+ :"
b8c892f
+ :for t in tl
b8c892f
+ :  let l = matchlist(t[1], t[0])
b8c892f
+ :" check the match itself
b8c892f
+ :  if len(l) == 0 && len(t) > 2
b8c892f
+ :    $put ='ERROR: pat: \"' . t[0] . '\", text: \"' . t[1] . '\", did not match, expected: \"' . t[2] . '\"'
b8c892f
+ :  elseif len(l) > 0 && len(t) == 2
b8c892f
+ :    $put ='ERROR: pat: \"' . t[0] . '\", text: \"' . t[1] . '\", match: \"' . l[0] . '\", expected no match'
b8c892f
+ :  elseif len(t) > 2 && l[0] != t[2]
b8c892f
+ :    $put ='ERROR: pat: \"' . t[0] . '\", text: \"' . t[1] . '\", match: \"' . l[0] . '\", expected: \"' . t[2] . '\"'
b8c892f
+ :  else
b8c892f
+ :    $put ='OK'
b8c892f
+ :  endif
b8c892f
+ :  if len(l) > 0
b8c892f
+ :"   check all the nine submatches
b8c892f
+ :    for i in range(1, 9)
b8c892f
+ :      if len(t) <= i + 2
b8c892f
+ :        let e = ''
b8c892f
+ :      else
b8c892f
+ :        let e = t[i + 2]
b8c892f
+ :      endif
b8c892f
+ :      if l[i] != e
b8c892f
+ :        $put ='ERROR: pat: \"' . t[0] . '\", text: \"' . t[1] . '\", submatch ' . i . ': \"' . l[i] . '\", expected: \"' . e . '\"'
b8c892f
+ :      endif
b8c892f
+ :    endfor
b8c892f
+ :  endif
b8c892f
+ :endfor
b8c892f
+ :/^Results/,$wq! test.out
b8c892f
+ ENDTEST
b8c892f
+ 
b8c892f
+ Results of test64:
b8c892f
*** ../vim-7.1.070/src/testdir/test64.ok	Tue Aug 14 17:26:28 2007
b8c892f
--- src/testdir/test64.ok	Tue Aug 14 16:01:47 2007
b8c892f
***************
b8c892f
*** 0 ****
b8c892f
--- 1,6 ----
b8c892f
+ Results of test64:
b8c892f
+ OK
b8c892f
+ OK
b8c892f
+ OK
b8c892f
+ OK
b8c892f
+ OK
b8c892f
*** ../vim-7.1.070/src/version.c	Tue Aug 14 16:57:04 2007
b8c892f
--- src/version.c	Tue Aug 14 17:25:20 2007
b8c892f
***************
b8c892f
*** 668,669 ****
b8c892f
--- 668,671 ----
b8c892f
  {   /* Add new patch number below this line */
b8c892f
+ /**/
b8c892f
+     71,
b8c892f
  /**/
b8c892f
b8c892f
-- 
b8c892f
hundred-and-one symptoms of being an internet addict:
b8c892f
150. You find yourself counting emoticons to get to sleep.
b8c892f
b8c892f
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
b8c892f
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
b8c892f
\\\        download, build and distribute -- http://www.A-A-P.org        ///
b8c892f
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///