]>
Commit | Line | Data |
---|---|---|
0a7814d6 AG |
1 | To: vim-dev@vim.org |
2 | Subject: patch 7.1.071 | |
3 | Fcc: outbox | |
4 | From: Bram Moolenaar <Bram@moolenaar.net> | |
5 | Mime-Version: 1.0 | |
6 | Content-Type: text/plain; charset=ISO-8859-1 | |
7 | Content-Transfer-Encoding: 8bit | |
8 | ------------ | |
9 | ||
10 | Patch 7.1.071 (after 7.1.040) | |
11 | Problem: Regexp patterns are not tested. | |
12 | Solution: Add a basic test, to be expanded later. | |
13 | Also add (commented-out) support for valgrind. | |
14 | Files: src/testdir/Makefile, src/testdir/test64.in, src/testdir/test64.ok | |
15 | ||
16 | ||
17 | *** ../vim-7.1.070/src/testdir/Makefile Thu Jul 26 22:55:11 2007 | |
18 | --- src/testdir/Makefile Tue Aug 14 15:16:08 2007 | |
19 | *************** | |
20 | *** 4,9 **** | |
21 | --- 4,13 ---- | |
22 | ||
23 | VIMPROG = ../vim | |
24 | ||
25 | + # Uncomment this line for using valgrind. | |
26 | + # The output goes into a file "valgrind.$PID" (sorry, no test number). | |
27 | + # VALGRIND = valgrind --tool=memcheck --num-callers=15 --logfile=valgrind | |
28 | + | |
29 | SCRIPTS = test1.out test2.out test3.out test4.out test5.out test6.out \ | |
30 | test7.out test8.out test9.out test10.out test11.out \ | |
31 | test12.out test13.out test14.out test15.out test17.out \ | |
32 | *************** | |
33 | *** 15,21 **** | |
34 | test43.out test44.out test45.out test46.out test47.out \ | |
35 | test48.out test49.out test51.out test52.out test53.out \ | |
36 | test54.out test55.out test56.out test57.out test58.out \ | |
37 | ! test59.out test60.out test61.out test62.out test63.out | |
38 | ||
39 | SCRIPTS_GUI = test16.out | |
40 | ||
41 | --- 19,26 ---- | |
42 | test43.out test44.out test45.out test46.out test47.out \ | |
43 | test48.out test49.out test51.out test52.out test53.out \ | |
44 | test54.out test55.out test56.out test57.out test58.out \ | |
45 | ! test59.out test60.out test61.out test62.out test63.out \ | |
46 | ! test64.out | |
47 | ||
48 | SCRIPTS_GUI = test16.out | |
49 | ||
50 | *************** | |
51 | *** 38,44 **** | |
52 | ||
53 | test1.out: test1.in | |
54 | -rm -f $*.failed tiny.vim small.vim mbyte.vim test.ok X* viminfo | |
55 | ! $(VIMPROG) -u unix.vim -U NONE --noplugin -s dotest.in $*.in | |
56 | @/bin/sh -c "if diff test.out $*.ok; \ | |
57 | then mv -f test.out $*.out; \ | |
58 | else echo; \ | |
59 | --- 43,49 ---- | |
60 | ||
61 | test1.out: test1.in | |
62 | -rm -f $*.failed tiny.vim small.vim mbyte.vim test.ok X* viminfo | |
63 | ! $(VALGRIND) $(VIMPROG) -u unix.vim -U NONE --noplugin -s dotest.in $*.in | |
64 | @/bin/sh -c "if diff test.out $*.ok; \ | |
65 | then mv -f test.out $*.out; \ | |
66 | else echo; \ | |
67 | *************** | |
68 | *** 51,57 **** | |
69 | cp $*.ok test.ok | |
70 | # Sleep a moment to avoid that the xterm title is messed up | |
71 | @-sleep .2 | |
72 | ! -$(VIMPROG) -u unix.vim -U NONE --noplugin -s dotest.in $*.in | |
73 | @/bin/sh -c "if test -f test.out; then\ | |
74 | if diff test.out $*.ok; \ | |
75 | then mv -f test.out $*.out; \ | |
76 | --- 56,62 ---- | |
77 | cp $*.ok test.ok | |
78 | # Sleep a moment to avoid that the xterm title is messed up | |
79 | @-sleep .2 | |
80 | ! -$(VALGRIND) $(VIMPROG) -u unix.vim -U NONE --noplugin -s dotest.in $*.in | |
81 | @/bin/sh -c "if test -f test.out; then\ | |
82 | if diff test.out $*.ok; \ | |
83 | then mv -f test.out $*.out; \ | |
84 | *** ../vim-7.1.070/src/testdir/test64.in Tue Aug 14 17:26:28 2007 | |
85 | --- src/testdir/test64.in Tue Aug 14 16:03:44 2007 | |
86 | *************** | |
87 | *** 0 **** | |
88 | --- 1,52 ---- | |
89 | + Test for regexp patterns. | |
90 | + | |
91 | + A pattern that gives the expected result produces OK, so that we know it was | |
92 | + actually tried. | |
93 | + | |
94 | + STARTTEST | |
95 | + :so small.vim | |
96 | + :" tl is a List of Lists with: | |
97 | + :" regexp pattern | |
98 | + :" text to test the pattern on | |
99 | + :" expected match (optional) | |
100 | + :" expected submatch 1 (optional) | |
101 | + :" expected submatch 2 (optional) | |
102 | + :" etc. | |
103 | + :" When there is no match use only the first two items. | |
104 | + :let tl = [] | |
105 | + :call add(tl, ['b', 'abcdef', 'b']) | |
106 | + :call add(tl, ['bc*', 'abccccdef', 'bcccc']) | |
107 | + :call add(tl, ['bc\{-}', 'abccccdef', 'b']) | |
108 | + :call add(tl, ['bc\{-}\(d\)', 'abccccdef', 'bccccd', 'd']) | |
109 | + :call add(tl, ['x', 'abcdef']) | |
110 | + :" | |
111 | + :for t in tl | |
112 | + : let l = matchlist(t[1], t[0]) | |
113 | + :" check the match itself | |
114 | + : if len(l) == 0 && len(t) > 2 | |
115 | + : $put ='ERROR: pat: \"' . t[0] . '\", text: \"' . t[1] . '\", did not match, expected: \"' . t[2] . '\"' | |
116 | + : elseif len(l) > 0 && len(t) == 2 | |
117 | + : $put ='ERROR: pat: \"' . t[0] . '\", text: \"' . t[1] . '\", match: \"' . l[0] . '\", expected no match' | |
118 | + : elseif len(t) > 2 && l[0] != t[2] | |
119 | + : $put ='ERROR: pat: \"' . t[0] . '\", text: \"' . t[1] . '\", match: \"' . l[0] . '\", expected: \"' . t[2] . '\"' | |
120 | + : else | |
121 | + : $put ='OK' | |
122 | + : endif | |
123 | + : if len(l) > 0 | |
124 | + :" check all the nine submatches | |
125 | + : for i in range(1, 9) | |
126 | + : if len(t) <= i + 2 | |
127 | + : let e = '' | |
128 | + : else | |
129 | + : let e = t[i + 2] | |
130 | + : endif | |
131 | + : if l[i] != e | |
132 | + : $put ='ERROR: pat: \"' . t[0] . '\", text: \"' . t[1] . '\", submatch ' . i . ': \"' . l[i] . '\", expected: \"' . e . '\"' | |
133 | + : endif | |
134 | + : endfor | |
135 | + : endif | |
136 | + :endfor | |
137 | + :/^Results/,$wq! test.out | |
138 | + ENDTEST | |
139 | + | |
140 | + Results of test64: | |
141 | *** ../vim-7.1.070/src/testdir/test64.ok Tue Aug 14 17:26:28 2007 | |
142 | --- src/testdir/test64.ok Tue Aug 14 16:01:47 2007 | |
143 | *************** | |
144 | *** 0 **** | |
145 | --- 1,6 ---- | |
146 | + Results of test64: | |
147 | + OK | |
148 | + OK | |
149 | + OK | |
150 | + OK | |
151 | + OK | |
152 | *** ../vim-7.1.070/src/version.c Tue Aug 14 16:57:04 2007 | |
153 | --- src/version.c Tue Aug 14 17:25:20 2007 | |
154 | *************** | |
155 | *** 668,669 **** | |
156 | --- 668,671 ---- | |
157 | { /* Add new patch number below this line */ | |
158 | + /**/ | |
159 | + 71, | |
160 | /**/ | |
161 | ||
162 | -- | |
163 | hundred-and-one symptoms of being an internet addict: | |
164 | 150. You find yourself counting emoticons to get to sleep. | |
165 | ||
166 | /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ | |
167 | /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ | |
168 | \\\ download, build and distribute -- http://www.A-A-P.org /// | |
169 | \\\ help me help AIDS victims -- http://ICCF-Holland.org /// |