Mercurial > vim
comparison src/testdir/test_regexp_utf8.vim @ 18906:bb87c5c1e29b v8.2.0014
patch 8.2.0014: test69 and test95 are old style
Commit: https://github.com/vim/vim/commit/afc13bd8271819c7871ff2ae2cfebb22190a0d39
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Dec 16 22:43:31 2019 +0100
patch 8.2.0014: test69 and test95 are old style
Problem: Test69 and test95 are old style.
Solution: Convert to new style tests. (Yegappan Lakshmanan, closes https://github.com/vim/vim/issues/5365)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 16 Dec 2019 22:45:04 +0100 |
parents | f4ce361bb1e5 |
children | 097f5b5c907b |
comparison
equal
deleted
inserted
replaced
18905:c1b0da0ac838 | 18906:bb87c5c1e29b |
---|---|
213 let pat = '\\%[' .. repeat('x', 9000) .. ']' | 213 let pat = '\\%[' .. repeat('x', 9000) .. ']' |
214 call assert_fails('call match("abc def", "' .. pat .. '")', 'E339:') | 214 call assert_fails('call match("abc def", "' .. pat .. '")', 'E339:') |
215 set re=0 | 215 set re=0 |
216 endfunc | 216 endfunc |
217 | 217 |
218 " Test for regexp patterns with multi-byte support, using utf-8. | |
219 func Test_multibyte_chars() | |
220 " tl is a List of Lists with: | |
221 " 2: test auto/old/new 0: test auto/old 1: test auto/new | |
222 " regexp pattern | |
223 " text to test the pattern on | |
224 " expected match (optional) | |
225 " expected submatch 1 (optional) | |
226 " expected submatch 2 (optional) | |
227 " etc. | |
228 " When there is no match use only the first two items. | |
229 let tl = [] | |
230 | |
231 " Multi-byte character tests. These will fail unless vim is compiled | |
232 " with Multibyte (FEAT_MBYTE) or BIG/HUGE features. | |
233 call add(tl, [2, '[[:alpha:][=a=]]\+', '879 aiaãâaiuvna ', 'aiaãâaiuvna']) | |
234 call add(tl, [2, '[[=a=]]\+', 'ddaãâbcd', 'aãâ']) " equivalence classes | |
235 call add(tl, [2, '[^ม ]\+', 'มม oijasoifjos ifjoisj f osij j มมมมม abcd', 'oijasoifjos']) | |
236 call add(tl, [2, ' [^ ]\+', 'start มabcdม ', ' มabcdม']) | |
237 call add(tl, [2, '[ม[:alpha:][=a=]]\+', '879 aiaãมâมaiuvna ', 'aiaãมâมaiuvna']) | |
238 | |
239 " this is not a normal "i" but 0xec | |
240 call add(tl, [2, '\p\+', 'ìa', 'ìa']) | |
241 call add(tl, [2, '\p*', 'aあ', 'aあ']) | |
242 | |
243 " Test recognition of some character classes | |
244 call add(tl, [2, '\i\+', '&*¨xx ', 'xx']) | |
245 call add(tl, [2, '\f\+', '&*fname ', 'fname']) | |
246 | |
247 " Test composing character matching | |
248 call add(tl, [2, '.ม', 'xม่x yมy', 'yม']) | |
249 call add(tl, [2, '.ม่', 'xม่x yมy', 'xม่']) | |
250 call add(tl, [2, "\u05b9", " x\u05b9 ", "x\u05b9"]) | |
251 call add(tl, [2, ".\u05b9", " x\u05b9 ", "x\u05b9"]) | |
252 call add(tl, [2, "\u05b9\u05bb", " x\u05b9\u05bb ", "x\u05b9\u05bb"]) | |
253 call add(tl, [2, ".\u05b9\u05bb", " x\u05b9\u05bb ", "x\u05b9\u05bb"]) | |
254 call add(tl, [2, "\u05bb\u05b9", " x\u05b9\u05bb ", "x\u05b9\u05bb"]) | |
255 call add(tl, [2, ".\u05bb\u05b9", " x\u05b9\u05bb ", "x\u05b9\u05bb"]) | |
256 call add(tl, [2, "\u05b9", " y\u05bb x\u05b9 ", "x\u05b9"]) | |
257 call add(tl, [2, ".\u05b9", " y\u05bb x\u05b9 ", "x\u05b9"]) | |
258 call add(tl, [2, "\u05b9", " y\u05bb\u05b9 x\u05b9 ", "y\u05bb\u05b9"]) | |
259 call add(tl, [2, ".\u05b9", " y\u05bb\u05b9 x\u05b9 ", "y\u05bb\u05b9"]) | |
260 call add(tl, [1, "\u05b9\u05bb", " y\u05b9 x\u05b9\u05bb ", "x\u05b9\u05bb"]) | |
261 call add(tl, [2, ".\u05b9\u05bb", " y\u05bb x\u05b9\u05bb ", "x\u05b9\u05bb"]) | |
262 call add(tl, [2, "a", "ca\u0300t"]) | |
263 call add(tl, [2, "ca", "ca\u0300t"]) | |
264 call add(tl, [2, "a\u0300", "ca\u0300t", "a\u0300"]) | |
265 call add(tl, [2, 'a\%C', "ca\u0300t", "a\u0300"]) | |
266 call add(tl, [2, 'ca\%C', "ca\u0300t", "ca\u0300"]) | |
267 call add(tl, [2, 'ca\%Ct', "ca\u0300t", "ca\u0300t"]) | |
268 | |
269 " Test \Z | |
270 call add(tl, [2, 'ú\Z', 'x']) | |
271 call add(tl, [2, 'יהוה\Z', 'יהוה', 'יהוה']) | |
272 call add(tl, [2, 'יְהוָה\Z', 'יהוה', 'יהוה']) | |
273 call add(tl, [2, 'יהוה\Z', 'יְהוָה', 'יְהוָה']) | |
274 call add(tl, [2, 'יְהוָה\Z', 'יְהוָה', 'יְהוָה']) | |
275 call add(tl, [2, 'יְ\Z', 'וְיַ', 'יַ']) | |
276 call add(tl, [2, "ק\u200d\u05b9x\\Z", "xק\u200d\u05b9xy", "ק\u200d\u05b9x"]) | |
277 call add(tl, [2, "ק\u200d\u05b9x\\Z", "xק\u200dxy", "ק\u200dx"]) | |
278 call add(tl, [2, "ק\u200dx\\Z", "xק\u200d\u05b9xy", "ק\u200d\u05b9x"]) | |
279 call add(tl, [2, "ק\u200dx\\Z", "xק\u200dxy", "ק\u200dx"]) | |
280 call add(tl, [2, "\u05b9\\Z", "xyz"]) | |
281 call add(tl, [2, "\\Z\u05b9", "xyz"]) | |
282 call add(tl, [2, "\u05b9\\Z", "xy\u05b9z", "y\u05b9"]) | |
283 call add(tl, [2, "\\Z\u05b9", "xy\u05b9z", "y\u05b9"]) | |
284 call add(tl, [1, "\u05b9\\+\\Z", "xy\u05b9z\u05b9 ", "y\u05b9z\u05b9"]) | |
285 call add(tl, [1, "\\Z\u05b9\\+", "xy\u05b9z\u05b9 ", "y\u05b9z\u05b9"]) | |
286 | |
287 " Combining different tests and features | |
288 call add(tl, [2, '[^[=a=]]\+', 'ddaãâbcd', 'dd']) | |
289 | |
290 " Run the tests | |
291 for t in tl | |
292 let re = t[0] | |
293 let pat = t[1] | |
294 let text = t[2] | |
295 let matchidx = 3 | |
296 for engine in [0, 1, 2] | |
297 if engine == 2 && re == 0 || engine == 1 && re == 1 | |
298 continue | |
299 endif | |
300 let ®expengine = engine | |
301 try | |
302 let l = matchlist(text, pat) | |
303 catch | |
304 call assert_report('Error ' . engine . ': pat: \"' . pat . | |
305 \ '\", text: \"' . text . | |
306 \ '\", caused an exception: \"' . v:exception . '\"') | |
307 endtry | |
308 " check the match itself | |
309 if len(l) == 0 && len(t) > matchidx | |
310 call assert_report('Error ' . engine . ': pat: \"' . pat . | |
311 \ '\", text: \"' . text . | |
312 \ '\", did not match, expected: \"' . t[matchidx] . '\"') | |
313 elseif len(l) > 0 && len(t) == matchidx | |
314 call assert_report('Error ' . engine . ': pat: \"' . pat . | |
315 \ '\", text: \"' . text . '\", match: \"' . l[0] . | |
316 \ '\", expected no match') | |
317 elseif len(t) > matchidx && l[0] != t[matchidx] | |
318 call assert_report('Error ' . engine . ': pat: \"' . pat . | |
319 \ '\", text: \"' . text . '\", match: \"' . l[0] . | |
320 \ '\", expected: \"' . t[matchidx] . '\"') | |
321 else | |
322 " Test passed | |
323 endif | |
324 if len(l) > 0 | |
325 " check all the nine submatches | |
326 for i in range(1, 9) | |
327 if len(t) <= matchidx + i | |
328 let e = '' | |
329 else | |
330 let e = t[matchidx + i] | |
331 endif | |
332 if l[i] != e | |
333 call assert_report('Error ' . engine . ': pat: \"' . pat . | |
334 \ '\", text: \"' . text . '\", submatch ' . i . | |
335 \ ': \"' . l[i] . '\", expected: \"' . e . '\"') | |
336 endif | |
337 endfor | |
338 unlet i | |
339 endif | |
340 endfor | |
341 endfor | |
342 set regexpengine& | |
343 endfunc | |
344 | |
345 " check that 'ambiwidth' does not change the meaning of \p | |
346 func Test_ambiwidth() | |
347 set regexpengine=1 ambiwidth=single | |
348 call assert_equal(0, match("\u00EC", '\p')) | |
349 set regexpengine=1 ambiwidth=double | |
350 call assert_equal(0, match("\u00EC", '\p')) | |
351 set regexpengine=2 ambiwidth=single | |
352 call assert_equal(0, match("\u00EC", '\p')) | |
353 set regexpengine=2 ambiwidth=double | |
354 call assert_equal(0, match("\u00EC", '\p')) | |
355 set regexpengine& ambiwidth& | |
356 endfunc | |
357 | |
358 " vim: shiftwidth=2 sts=2 expandtab |