4444
|
1 Test for regexp patterns without multi-byte support.
|
|
2 See test95 for multi-byte tests.
|
1357
|
3
|
|
4 A pattern that gives the expected result produces OK, so that we know it was
|
|
5 actually tried.
|
|
6
|
|
7 STARTTEST
|
|
8 :so small.vim
|
|
9 :" tl is a List of Lists with:
|
|
10 :" regexp pattern
|
|
11 :" text to test the pattern on
|
|
12 :" expected match (optional)
|
|
13 :" expected submatch 1 (optional)
|
|
14 :" expected submatch 2 (optional)
|
|
15 :" etc.
|
|
16 :" When there is no match use only the first two items.
|
|
17 :let tl = []
|
4444
|
18
|
|
19 :""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
20 :"""" Previously written tests """"""""""""""""""""""""""""""""
|
|
21 :""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
22
|
1465
|
23 :call add(tl, ['ab', 'aab', 'ab'])
|
1357
|
24 :call add(tl, ['b', 'abcdef', 'b'])
|
|
25 :call add(tl, ['bc*', 'abccccdef', 'bcccc'])
|
|
26 :call add(tl, ['bc\{-}', 'abccccdef', 'b'])
|
|
27 :call add(tl, ['bc\{-}\(d\)', 'abccccdef', 'bccccd', 'd'])
|
1465
|
28 :call add(tl, ['bc*', 'abbdef', 'b'])
|
|
29 :call add(tl, ['c*', 'ccc', 'ccc'])
|
|
30 :call add(tl, ['bc*', 'abdef', 'b'])
|
|
31 :call add(tl, ['c*', 'abdef', ''])
|
|
32 :call add(tl, ['bc\+', 'abccccdef', 'bcccc'])
|
|
33 :call add(tl, ['bc\+', 'abdef']) "no match
|
|
34 :"
|
|
35 :"operator \|
|
|
36 :call add(tl, ['a\|ab', 'cabd', 'a']) "alternation is ordered
|
|
37 :"
|
|
38 :call add(tl, ['c\?', 'ccb', 'c'])
|
|
39 :call add(tl, ['bc\?', 'abd', 'b'])
|
|
40 :call add(tl, ['bc\?', 'abccd', 'bc'])
|
|
41 :"
|
|
42 :call add(tl, ['\va{1}', 'ab', 'a'])
|
|
43 :"
|
|
44 :call add(tl, ['\va{2}', 'aa', 'aa'])
|
|
45 :call add(tl, ['\va{2}', 'caad', 'aa'])
|
|
46 :call add(tl, ['\va{2}', 'aba'])
|
|
47 :call add(tl, ['\va{2}', 'ab'])
|
|
48 :call add(tl, ['\va{2}', 'abaa', 'aa'])
|
|
49 :call add(tl, ['\va{2}', 'aaa', 'aa'])
|
|
50 :"
|
|
51 :call add(tl, ['\vb{1}', 'abca', 'b'])
|
|
52 :call add(tl, ['\vba{2}', 'abaa', 'baa'])
|
|
53 :call add(tl, ['\vba{3}', 'aabaac'])
|
|
54 :"
|
|
55 :call add(tl, ['\v(ab){1}', 'ab', 'ab', 'ab'])
|
|
56 :call add(tl, ['\v(ab){1}', 'dabc', 'ab', 'ab'])
|
|
57 :call add(tl, ['\v(ab){1}', 'acb'])
|
|
58 :"
|
|
59 :call add(tl, ['\v(ab){0,2}', 'acb', "", ""])
|
|
60 :call add(tl, ['\v(ab){0,2}', 'ab', 'ab', 'ab'])
|
|
61 :call add(tl, ['\v(ab){1,2}', 'ab', 'ab', 'ab'])
|
|
62 :call add(tl, ['\v(ab){1,2}', 'ababc', 'abab', 'ab'])
|
|
63 :call add(tl, ['\v(ab){2,4}', 'ababcab', 'abab', 'ab'])
|
|
64 :call add(tl, ['\v(ab){2,4}', 'abcababa', 'abab', 'ab'])
|
|
65 :"
|
|
66 :call add(tl, ['\v(ab){2}', 'abab', 'abab', 'ab'])
|
|
67 :call add(tl, ['\v(ab){2}', 'cdababe', 'abab', 'ab'])
|
|
68 :call add(tl, ['\v(ab){2}', 'abac'])
|
|
69 :call add(tl, ['\v(ab){2}', 'abacabab', 'abab', 'ab'])
|
|
70 :call add(tl, ['\v((ab){2}){2}', 'abababab', 'abababab', 'abab', 'ab'])
|
|
71 :call add(tl, ['\v((ab){2}){2}', 'abacabababab', 'abababab', 'abab', 'ab'])
|
|
72 :"
|
|
73 :call add(tl, ['\v(a{1}){1}', 'a', 'a', 'a'])
|
|
74 :call add(tl, ['\v(a{2}){1}', 'aa', 'aa', 'aa'])
|
|
75 :call add(tl, ['\v(a{2}){1}', 'aaac', 'aa', 'aa'])
|
|
76 :call add(tl, ['\v(a{2}){1}', 'daaac', 'aa', 'aa'])
|
|
77 :call add(tl, ['\v(a{1}){2}', 'daaac', 'aa', 'a'])
|
|
78 :call add(tl, ['\v(a{1}){2}', 'aaa', 'aa', 'a'])
|
|
79 :call add(tl, ['\v(a{2})+', 'adaac', 'aa', 'aa'])
|
|
80 :call add(tl, ['\v(a{2})+', 'aa', 'aa', 'aa'])
|
|
81 :call add(tl, ['\v(a{2}){1}', 'aa', 'aa', 'aa'])
|
|
82 :call add(tl, ['\v(a{1}){2}', 'aa', 'aa', 'a'])
|
|
83 :call add(tl, ['\v(a{1}){1}', 'a', 'a', 'a'])
|
|
84 :call add(tl, ['\v(a{2}){2}', 'aaaa', 'aaaa', 'aa'])
|
|
85 :call add(tl, ['\v(a{2}){2}', 'aaabaaaa', 'aaaa', 'aa'])
|
|
86 :"
|
|
87 :call add(tl, ['\v(a+){2}', 'dadaac', 'aa', 'a'])
|
|
88 :call add(tl, ['\v(a{3}){2}', 'aaaaaaa', 'aaaaaa', 'aaa'])
|
|
89 :"
|
|
90 :call add(tl, ['\v(a{1,2}){2}', 'daaac', 'aaa', 'a'])
|
|
91 :call add(tl, ['\v(a{1,3}){2}', 'daaaac', 'aaaa', 'a'])
|
|
92 :call add(tl, ['\v(a{1,3}){2}', 'daaaaac', 'aaaaa', 'aa'])
|
|
93 :call add(tl, ['\v(a{1,3}){3}', 'daac'])
|
|
94 :call add(tl, ['\v(a{1,2}){2}', 'dac'])
|
|
95 :call add(tl, ['\v(a+)+', 'daac', 'aa', 'aa'])
|
|
96 :call add(tl, ['\v(a+)+', 'aaa', 'aaa', 'aaa'])
|
|
97 :call add(tl, ['\v(a+){1,2}', 'aaa', 'aaa', 'aaa'])
|
|
98 :call add(tl, ['\v(a+)(a+)', 'aaa', 'aaa', 'aa', 'a'])
|
|
99 :call add(tl, ['\v(a{3})+', 'daaaac', 'aaa', 'aaa'])
|
|
100 :call add(tl, ['\v(a|b|c)+', 'aacb', 'aacb', 'b'])
|
|
101 :call add(tl, ['\v(a|b|c){2}', 'abcb', 'ab', 'b'])
|
|
102 :call add(tl, ['\v(abc){2}', 'abcabd', ])
|
|
103 :call add(tl, ['\v(abc){2}', 'abdabcabc','abcabc', 'abc'])
|
|
104 :"
|
|
105 :call add(tl, ['a*', 'cc', ''])
|
|
106 :call add(tl, ['\v(a*)+', 'cc', ''])
|
|
107 :call add(tl, ['\v((ab)+)+', 'ab', 'ab', 'ab', 'ab'])
|
|
108 :call add(tl, ['\v(((ab)+)+)+', 'ab', 'ab', 'ab', 'ab', 'ab'])
|
|
109 :call add(tl, ['\v(((ab)+)+)+', 'dababc', 'abab', 'abab', 'abab', 'ab'])
|
|
110 :call add(tl, ['\v(a{0,2})+', 'cc', ''])
|
|
111 :call add(tl, ['\v(a*)+', '', ''])
|
|
112 :call add(tl, ['\v((a*)+)+', '', ''])
|
|
113 :call add(tl, ['\v((ab)*)+', '', ''])
|
|
114 :call add(tl, ['\va{1,3}', 'aab', 'aa'])
|
|
115 :call add(tl, ['\va{2,3}', 'abaa', 'aa'])
|
|
116 :"
|
|
117 :call add(tl, ['\v((ab)+|c*)+', 'abcccaba', 'abcccab', '', 'ab'])
|
|
118 :call add(tl, ['\v(a{2})|(b{3})', 'bbabbbb', 'bbb', '', 'bbb'])
|
|
119 :call add(tl, ['\va{2}|b{2}', 'abab'])
|
|
120 :call add(tl, ['\v(a)+|(c)+', 'bbacbaacbbb', 'a', 'a'])
|
|
121 :call add(tl, ['\vab{2,3}c', 'aabbccccccccccccc', 'abbc'])
|
|
122 :call add(tl, ['\vab{2,3}c', 'aabbbccccccccccccc', 'abbbc'])
|
|
123 :call add(tl, ['\vab{2,3}cd{2,3}e', 'aabbbcddee', 'abbbcdde'])
|
|
124 :call add(tl, ['\va(bc){2}d', 'aabcbfbc' ])
|
|
125 :call add(tl, ['\va*a{2}', 'a', ])
|
|
126 :call add(tl, ['\va*a{2}', 'aa', 'aa' ])
|
|
127 :call add(tl, ['\va*a{2}', 'aaa', 'aaa' ])
|
|
128 :call add(tl, ['\va*a{2}', 'bbbabcc', ])
|
|
129 :call add(tl, ['\va*b*|a*c*', 'a', 'a'])
|
|
130 :call add(tl, ['\va{1}b{1}|a{1}b{1}', ''])
|
|
131 :"
|
|
132 :"submatches
|
|
133 :call add(tl, ['\v(a)', 'ab', 'a', 'a'])
|
|
134 :call add(tl, ['\v(a)(b)', 'ab', 'ab', 'a', 'b'])
|
|
135 :call add(tl, ['\v(ab)(b)(c)', 'abbc', 'abbc', 'ab', 'b', 'c'])
|
|
136 :call add(tl, ['\v((a)(b))', 'ab', 'ab', 'ab', 'a', 'b'])
|
|
137 :call add(tl, ['\v(a)|(b)', 'ab', 'a', 'a'])
|
|
138 :"
|
|
139 :call add(tl, ['\v(a*)+', 'aaaa', 'aaaa', ''])
|
1357
|
140 :call add(tl, ['x', 'abcdef'])
|
4444
|
141
|
|
142 :""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
143 :""""" Simple tests """""""""""""""""""""""""""""""""""""""""""
|
|
144 :""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
145
|
|
146 :" Search single groups
|
|
147 :call add(tl, ['ab', 'aab', 'ab'])
|
|
148 :call add(tl, ['ab', 'baced'])
|
|
149 :call add(tl, ['ab', ' ab ', 'ab'])
|
|
150
|
|
151 :" Search multi-modifiers
|
|
152 :call add(tl, ['x*', 'xcd', 'x'])
|
|
153 :call add(tl, ['x*', 'xxxxxxxxxxxxxxxxsofijiojgf', 'xxxxxxxxxxxxxxxx'])
|
|
154 :call add(tl, ['x*', 'abcdoij', '']) " empty match is good
|
|
155 :call add(tl, ['x\+', 'abcdoin']) " no match here
|
|
156 :call add(tl, ['x\+', 'abcdeoijdfxxiuhfij', 'xx'])
|
|
157 :call add(tl, ['x\+', 'xxxxx', 'xxxxx'])
|
|
158 :call add(tl, ['x\+', 'abc x siufhiush xxxxxxxxx', 'x'])
|
|
159 :call add(tl, ['x\=', 'x sdfoij', 'x'])
|
|
160 :call add(tl, ['x\=', 'abc sfoij', '']) " empty match is good
|
|
161 :call add(tl, ['x\=', 'xxxxxxxxx c', 'x'])
|
|
162 :call add(tl, ['x\?', 'x sdfoij', 'x'])
|
|
163 :call add(tl, ['x\?', 'abc sfoij', '']) " empty match is good
|
|
164 :call add(tl, ['x\?', 'xxxxxxxxxx c', 'x'])
|
|
165
|
|
166 :call add(tl, ['a\{0,0}', 'abcdfdoij', ''])
|
|
167 :call add(tl, ['a\{0,1}', 'asiubid axxxaaa', 'a']) " same thing as 'a?'
|
|
168 :call add(tl, ['a\{1,0}', 'asiubid axxxaaa', 'a']) " same thing as 'a\{0,1}'
|
|
169 :call add(tl, ['a\{3,6}', 'aa siofuh'])
|
|
170 :call add(tl, ['a\{3,6}', 'aaaaa asfoij afaa', 'aaaaa'])
|
|
171 :call add(tl, ['a\{3,6}', 'aaaaaaaa', 'aaaaaa'])
|
|
172 :call add(tl, ['a\{0}', 'asoiuj', ''])
|
|
173 :call add(tl, ['a\{2}', 'aaaa', 'aa'])
|
|
174 :call add(tl, ['a\{2}', 'iuash fiusahfliusah fiushfilushfi uhsaifuh askfj nasfvius afg aaaa sfiuhuhiushf', 'aa'])
|
|
175 :call add(tl, ['a\{2}', 'abcdefghijklmnopqrestuvwxyz1234567890'])
|
|
176 :call add(tl, ['a\{0,}', 'oij sdigfusnf', '']) " same thing as 'a*'
|
|
177 :call add(tl, ['a\{0,}', 'aaaaa aa', 'aaaaa'])
|
|
178 :call add(tl, ['a\{2,}', 'sdfiougjdsafg'])
|
|
179 :call add(tl, ['a\{2,}', 'aaaaasfoij ', 'aaaaa'])
|
|
180 :call add(tl, ['a\{,0}', 'oidfguih iuhi hiu aaaa', ''])
|
|
181 :call add(tl, ['a\{,5}', 'abcd', 'a'])
|
|
182 :call add(tl, ['a\{,5}', 'aaaaaaaaaa', 'aaaaa'])
|
|
183 :call add(tl, ['a\{}', 'bbbcddiuhfcd', '']) " same thing as 'a*'
|
|
184 :call add(tl, ['a\{}', 'aaaaioudfh coisf jda', 'aaaa'])
|
|
185
|
|
186 :call add(tl, ['a\{-0,0}', 'abcdfdoij', ''])
|
|
187 :call add(tl, ['a\{-0,1}', 'asiubid axxxaaa', '']) " anti-greedy version of 'a?'
|
|
188 :call add(tl, ['a\{-3,6}', 'aa siofuh'])
|
|
189 :call add(tl, ['a\{-3,6}', 'aaaaa asfoij afaa', 'aaa'])
|
|
190 :call add(tl, ['a\{-3,6}', 'aaaaaaaa', 'aaa'])
|
|
191 :call add(tl, ['a\{-0}', 'asoiuj', ''])
|
|
192 :call add(tl, ['a\{-2}', 'aaaa', 'aa'])
|
|
193 :call add(tl, ['a\{-2}', 'abcdefghijklmnopqrestuvwxyz1234567890'])
|
|
194 :call add(tl, ['a\{-0,}', 'oij sdigfusnf', ''])
|
|
195 :call add(tl, ['a\{-0,}', 'aaaaa aa', ''])
|
|
196 :call add(tl, ['a\{-2,}', 'sdfiougjdsafg'])
|
|
197 :call add(tl, ['a\{-2,}', 'aaaaasfoij ', 'aa'])
|
|
198 :call add(tl, ['a\{-,0}', 'oidfguih iuhi hiu aaaa', ''])
|
|
199 :call add(tl, ['a\{-,5}', 'abcd', ''])
|
|
200 :call add(tl, ['a\{-,5}', 'aaaaaaaaaa', ''])
|
|
201 :call add(tl, ['a\{-}', 'bbbcddiuhfcd', '']) " anti-greedy version of 'a*'
|
|
202 :call add(tl, ['a\{-}', 'aaaaioudfh coisf jda', ''])
|
|
203
|
|
204 :" Test groups of characters and submatches
|
|
205 :call add(tl, ['\(abc\)*', 'abcabcabc', 'abcabcabc', 'abc'])
|
|
206 :call add(tl, ['\(ab\)\+', 'abababaaaaa', 'ababab', 'ab'])
|
|
207 :call add(tl, ['\(abaaaaa\)*cd', 'cd', 'cd', ''])
|
|
208 :call add(tl, ['\(test1\)\? \(test2\)\?', 'test1 test3', 'test1 ', 'test1', ''])
|
|
209 :call add(tl, ['\(test1\)\= \(test2\) \(test4443\)\=', ' test2 test4443 yupiiiiiiiiiii', ' test2 test4443', '', 'test2', 'test4443'])
|
|
210 :call add(tl, ['\(\(sub1\) hello \(sub 2\)\)', 'asterix sub1 hello sub 2 obelix', 'sub1 hello sub 2', 'sub1 hello sub 2', 'sub1', 'sub 2'])
|
|
211 :call add(tl, ['\(\(\(yyxxzz\)\)\)', 'abcdddsfiusfyyzzxxyyxxzz', 'yyxxzz', 'yyxxzz', 'yyxxzz', 'yyxxzz'])
|
|
212 :call add(tl, ['\v((ab)+|c+)+', 'abcccaba', 'abcccab', 'ab', 'ab'])
|
|
213 :call add(tl, ['\v((ab)|c*)+', 'abcccaba', 'abcccab', '', 'ab'])
|
|
214 :call add(tl, ['\v(a(c*)+b)+', 'acbababaaa', 'acbabab', 'ab', ''])
|
|
215 :call add(tl, ['\v(a|b*)+', 'aaaa', 'aaaa', ''])
|
|
216
|
|
217 :" Test greedy-ness and lazy-ness
|
|
218 :call add(tl, ['a\{-2,7}','aaaaaaaaaaaaa', 'aa'])
|
|
219 :call add(tl, ['a\{2,7}','aaaaaaaaaaaaaaaaaaaa', 'aaaaaaa'])
|
|
220 :call add(tl, ['\vx(.{-,8})yz(.*)','xayxayzxayzxayz','xayxayzxayzxayz','ayxa','xayzxayz'])
|
|
221 :call add(tl, ['\vx(.*)yz(.*)','xayxayzxayzxayz','xayxayzxayzxayz', 'ayxayzxayzxa',''])
|
|
222 :call add(tl, ['\v(a{1,2}){-2,3}','aaaaaaa','aaaa','aa'])
|
|
223 :call add(tl, ['\v(a{-1,3})+','aa','aa','a'])
|
|
224
|
|
225 :" Test Character classes
|
|
226 :call add(tl, ['\d\+e\d\d','test 10e23 fd','10e23'])
|
|
227
|
|
228 :" Test collections and character range []
|
|
229 :call add(tl, ['\v[a]', 'abcd', 'a'])
|
|
230 :call add(tl, ['a[bcd]', 'abcd', 'ab'])
|
|
231 :call add(tl, ['a[b-d]', 'acbd', 'ac'])
|
|
232 :call add(tl, ['[a-d][e-f][x-x]d', 'cexdxx', 'cexd'])
|
|
233 :call add(tl, ['\v[[:alpha:]]+', 'abcdefghijklmnopqrstuvwxyz6','abcdefghijklmnopqrstuvwxyz'])
|
|
234 :call add(tl, ['[[:alpha:]\+]', '6x8','x'])
|
|
235 :call add(tl, ['[^abc]\+','abcabcabc'])
|
|
236 :call add(tl, ['[^abc]','defghiasijvoinasoiunbvb','d'])
|
|
237 :call add(tl, ['[^abc]\+','ddddddda','ddddddd'])
|
|
238 :call add(tl, ['[^a-d]\+','aaaAAAZIHFNCddd','AAAZIHFNC'])
|
|
239 :call add(tl, ['[a-f]*','iiiiiiii',''])
|
|
240 :call add(tl, ['[a-f]*','abcdefgh','abcdef'])
|
|
241 :call add(tl, ['[^a-f]\+','abcdefgh','gh'])
|
|
242 :call add(tl, ['[a-c]\{-3,6}','abcabc','abc'])
|
|
243 :call add(tl, ['[^[:alpha:]]\+','abcccadfoij7787ysf287yrnccdu','7787'])
|
|
244 :call add(tl, ['[-a]', '-', '-'])
|
|
245 :call add(tl, ['[a-]', '-', '-'])
|
|
246 :call add(tl, ['[-./[:alnum:]_~]\+', 'log13.file', 'log13.file']) " filename regexp
|
|
247 :call add(tl, ['[\]\^\-\\]\+', '\^\\\-\---^', '\^\\\-\---^']) " special chars
|
|
248 :call add(tl, ['[[.a.]]\+', 'aa', 'aa']) " collation elem
|
|
249 :call add(tl, ['abc[0-9]*ddd', 'siuhabc ii']) " middle of regexp
|
|
250 :call add(tl, ['abc[0-9]*ddd', 'adf abc44482ddd oijs', 'abc44482ddd'])
|
|
251 :call add(tl, ['\_[0-9]\+', 'asfi9888u', '9888'])
|
|
252 :call add(tl, ['[0-9\n]\+', 'asfi9888u', '9888'])
|
|
253
|
|
254
|
|
255 :"""" Test recognition of some character classes
|
|
256 :call add(tl, ['[0-9]', '8', '8'])
|
|
257 :call add(tl, ['[^0-9]', '8'])
|
|
258 :call add(tl, ['[0-9a-fA-F]*', '0a7', '0a7'])
|
|
259 :call add(tl, ['[^0-9A-Fa-f]\+', '0a7'])
|
|
260 :call add(tl, ['[a-z_A-Z0-9]\+', 'aso_sfoij', 'aso_sfoij'])
|
|
261 :call add(tl, ['[a-z]', 'a', 'a'])
|
|
262 :call add(tl, ['[a-zA-Z]', 'a', 'a'])
|
|
263 :call add(tl, ['[A-Z]', 'a'])
|
|
264 :call add(tl, ['\C[^A-Z]\+', 'ABCOIJDEOIFNSD jsfoij sa', ' jsfoij sa'])
|
4466
|
265 :call add(tl, ['\i\+', '&*§xx ', 'xx'])
|
|
266 :call add(tl, ['\%#=1\i\+', '&*§xx ', 'xx'])
|
|
267 :call add(tl, ['\f\+', '&*fname ', 'fname'])
|
|
268 :call add(tl, ['\%#=1\i\+', '&*fname ', 'fname'])
|
4444
|
269
|
|
270 :"""" Tests for \z features
|
|
271 :call add(tl, ['xx \ze test', 'xx ']) " must match after \ze
|
|
272 :call add(tl, ['abc\zeend', 'oij abcend', 'abc'])
|
|
273 :call add(tl, ['abc\zsdd', 'ddabcddxyzt', 'dd'])
|
|
274 :call add(tl, ['aa \zsax', ' ax']) " must match before \zs
|
|
275 :call add(tl, ['abc \zsmatch\ze abc', 'abc abc abc match abc abc', 'match'])
|
|
276 :call add(tl, ['\v(a \zsif .*){2}', 'a if then a if last', 'if last', 'a if last'])
|
|
277
|
|
278 :"""" Tests for \@ features
|
|
279 :call add(tl, ['abc\@=', 'abc', 'ab'])
|
|
280 :call add(tl, ['abc\@=cd', 'abcd', 'abcd'])
|
|
281 :call add(tl, ['abc\@=', 'ababc', 'ab'])
|
|
282 :call add(tl, ['abcd\@=e', 'abcd']) " will never match, no matter the input text
|
|
283 :call add(tl, ['abcd\@=e', 'any text in here ... ']) " will never match
|
|
284 :call add(tl, ['\v(abc)@=..', 'xabcd', 'ab', 'abc'])
|
|
285 :call add(tl, ['\(.*John\)\@=.*Bob', 'here is John, and here is B']) " no match
|
|
286 :call add(tl, ['\(John.*\)\@=.*Bob', 'John is Bobs friend', 'John is Bob', 'John is Bobs friend'])
|
|
287 :call add(tl, ['.*John\&.*Bob', 'here is John, and here is B']) " no match
|
|
288 :call add(tl, ['.*John\&.*Bob', 'John is Bobs friend', 'John is Bob'])
|
|
289 :call add(tl, ['\v(test1)@=.*yep', 'this is a test1, yep it is', 'test1, yep', 'test1'])
|
|
290
|
|
291 :"""" Combining different tests and features
|
|
292 :call add(tl, ['[[:alpha:]]\{-2,6}', '787abcdiuhsasiuhb4', 'ab'])
|
|
293 :call add(tl, ['[^[=a=]]\+', 'ddaãâbcd', 'dd'])
|
|
294 :call add(tl, ['', 'abcd', ''])
|
|
295 :call add(tl, ['\v(())', 'any possible text', ''])
|
|
296 :call add(tl, ['\v%(ab(xyz)c)', ' abxyzc ', 'abxyzc', 'xyz'])
|
|
297 :call add(tl, ['\v(test|)empty', 'tesempty', 'empty', ''])
|
|
298 :call add(tl, ['\v(a|aa)(a|aa)', 'aaa', 'aa', 'a', 'a'])
|
|
299
|
|
300
|
|
301 :"""" Run the tests
|
|
302
|
1357
|
303 :"
|
|
304 :for t in tl
|
|
305 : let l = matchlist(t[1], t[0])
|
|
306 :" check the match itself
|
|
307 : if len(l) == 0 && len(t) > 2
|
|
308 : $put ='ERROR: pat: \"' . t[0] . '\", text: \"' . t[1] . '\", did not match, expected: \"' . t[2] . '\"'
|
|
309 : elseif len(l) > 0 && len(t) == 2
|
|
310 : $put ='ERROR: pat: \"' . t[0] . '\", text: \"' . t[1] . '\", match: \"' . l[0] . '\", expected no match'
|
|
311 : elseif len(t) > 2 && l[0] != t[2]
|
|
312 : $put ='ERROR: pat: \"' . t[0] . '\", text: \"' . t[1] . '\", match: \"' . l[0] . '\", expected: \"' . t[2] . '\"'
|
|
313 : else
|
4444
|
314 : $put ='OK - ' . t[0]
|
1357
|
315 : endif
|
|
316 : if len(l) > 0
|
|
317 :" check all the nine submatches
|
|
318 : for i in range(1, 9)
|
|
319 : if len(t) <= i + 2
|
|
320 : let e = ''
|
|
321 : else
|
|
322 : let e = t[i + 2]
|
|
323 : endif
|
|
324 : if l[i] != e
|
|
325 : $put ='ERROR: pat: \"' . t[0] . '\", text: \"' . t[1] . '\", submatch ' . i . ': \"' . l[i] . '\", expected: \"' . e . '\"'
|
|
326 : endif
|
|
327 : endfor
|
1405
|
328 : unlet i
|
1357
|
329 : endif
|
|
330 :endfor
|
1405
|
331 :unlet t tl e l
|
4444
|
332
|
|
333 :" Check that \_[0-9] matching EOL does not break a following \>
|
|
334 :" This only works on a buffer line, not with expression evaluation
|
|
335 /^Find this
|
|
336 /\<\(\(25\_[0-5]\|2\_[0-4]\_[0-9]\|\_[01]\?\_[0-9]\_[0-9]\?\)\.\)\{3\}\(25\_[0-5]\|2\_[0-4]\_[0-9]\|\_[01]\?\_[0-9]\_[0-9]\?\)\>
|
|
337 y$Gop:"
|
|
338
|
|
339 :/\%#=1^Results/,$wq! test.out
|
1357
|
340 ENDTEST
|
|
341
|
4444
|
342 Find this:
|
|
343 localnet/192.168.0.1
|
|
344
|
1357
|
345 Results of test64:
|