Mercurial > vim
annotate src/testdir/test95.in @ 4527:55bcaa1d2749 v7.3.1011
updated for version 7.3.1011
Problem: New regexp engine is inefficient with multi-byte characters.
Solution: Handle a character at a time instead of a byte at a time. Also
make \Z partly work.
author | Bram Moolenaar <bram@vim.org> |
---|---|
date | Fri, 24 May 2013 21:59:54 +0200 |
parents | 36ddcf4cecbc |
children | 432a6b8c7d93 |
rev | line source |
---|---|
4476 | 1 Test for regexp patterns with multi-byte support, using utf-8. |
4444 | 2 See test64 for the non-multi-byte tests. |
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 :so mbyte.vim | |
4525
36ddcf4cecbc
updated for version 7.3.1010
Bram Moolenaar <bram@vim.org>
parents:
4521
diff
changeset
|
10 :set nocp encoding=utf-8 viminfo+=nviminfo nomore |
4444 | 11 :" tl is a List of Lists with: |
12 :" regexp pattern | |
13 :" text to test the pattern on | |
14 :" expected match (optional) | |
15 :" expected submatch 1 (optional) | |
16 :" expected submatch 2 (optional) | |
17 :" etc. | |
18 :" When there is no match use only the first two items. | |
19 :let tl = [] | |
20 | |
21 :"""" Multi-byte character tests. These will fail unless vim is compiled | |
22 :"""" with Multibyte (FEAT_MBYTE) or BIG/HUGE features. | |
23 :call add(tl, ['[[:alpha:][=a=]]\+', '879 aiaãâaiuvna ', 'aiaãâaiuvna']) | |
24 :call add(tl, ['[[=a=]]\+', 'ddaãâbcd', 'aãâ']) " equivalence classes | |
25 :call add(tl, ['[^ม ]\+', 'มม oijasoifjos ifjoisj f osij j มมมมม abcd', 'oijasoifjos']) | |
26 :call add(tl, [' [^ ]\+', 'start มabcdม ', ' มabcdม']) | |
27 :call add(tl, ['[ม[:alpha:][=a=]]\+', '879 aiaãมâมaiuvna ', 'aiaãมâมaiuvna']) | |
28 | |
4468 | 29 :" this is not a normal "i" but 0xec |
30 :call add(tl, ['\p\+', 'ìa', 'ìa']) | |
31 | |
4478 | 32 :"""" Test recognition of some character classes |
4521
8cb14f59a327
updated for version 7.3.1008
Bram Moolenaar <bram@vim.org>
parents:
4478
diff
changeset
|
33 :call add(tl, ['\i\+', '&*¨xx ', 'xx']) |
8cb14f59a327
updated for version 7.3.1008
Bram Moolenaar <bram@vim.org>
parents:
4478
diff
changeset
|
34 :call add(tl, ['\%#=1\i\+', '&*¨xx ', 'xx']) |
4478 | 35 :call add(tl, ['\f\+', '&*fname ', 'fname']) |
4521
8cb14f59a327
updated for version 7.3.1008
Bram Moolenaar <bram@vim.org>
parents:
4478
diff
changeset
|
36 :call add(tl, ['\%#=1\f\+', '&*fname ', 'fname']) |
4478 | 37 |
4527
55bcaa1d2749
updated for version 7.3.1011
Bram Moolenaar <bram@vim.org>
parents:
4525
diff
changeset
|
38 :"""" Test composing character matching |
55bcaa1d2749
updated for version 7.3.1011
Bram Moolenaar <bram@vim.org>
parents:
4525
diff
changeset
|
39 :call add(tl, ['.ม', 'xม่x yมy', 'yม']) |
55bcaa1d2749
updated for version 7.3.1011
Bram Moolenaar <bram@vim.org>
parents:
4525
diff
changeset
|
40 :call add(tl, ['.ม่', 'xม่x yมy', 'xม่']) |
55bcaa1d2749
updated for version 7.3.1011
Bram Moolenaar <bram@vim.org>
parents:
4525
diff
changeset
|
41 |
4525
36ddcf4cecbc
updated for version 7.3.1010
Bram Moolenaar <bram@vim.org>
parents:
4521
diff
changeset
|
42 :"""" Test \Z |
36ddcf4cecbc
updated for version 7.3.1010
Bram Moolenaar <bram@vim.org>
parents:
4521
diff
changeset
|
43 :call add(tl, ['ú\Z', 'x']) |
36ddcf4cecbc
updated for version 7.3.1010
Bram Moolenaar <bram@vim.org>
parents:
4521
diff
changeset
|
44 |
4478 | 45 :"""" Combining different tests and features |
46 :call add(tl, ['[^[=a=]]\+', 'ddaãâbcd', 'dd']) | |
47 | |
4444 | 48 :"""" Run the tests |
49 :" | |
50 :for t in tl | |
51 : let l = matchlist(t[1], t[0]) | |
52 :" check the match itself | |
53 : if len(l) == 0 && len(t) > 2 | |
54 : $put ='ERROR: pat: \"' . t[0] . '\", text: \"' . t[1] . '\", did not match, expected: \"' . t[2] . '\"' | |
55 : elseif len(l) > 0 && len(t) == 2 | |
56 : $put ='ERROR: pat: \"' . t[0] . '\", text: \"' . t[1] . '\", match: \"' . l[0] . '\", expected no match' | |
57 : elseif len(t) > 2 && l[0] != t[2] | |
58 : $put ='ERROR: pat: \"' . t[0] . '\", text: \"' . t[1] . '\", match: \"' . l[0] . '\", expected: \"' . t[2] . '\"' | |
59 : else | |
60 : $put ='OK - ' . t[0] | |
61 : endif | |
62 : if len(l) > 0 | |
63 :" check all the nine submatches | |
64 : for i in range(1, 9) | |
65 : if len(t) <= i + 2 | |
66 : let e = '' | |
67 : else | |
68 : let e = t[i + 2] | |
69 : endif | |
70 : if l[i] != e | |
71 : $put ='ERROR: pat: \"' . t[0] . '\", text: \"' . t[1] . '\", submatch ' . i . ': \"' . l[i] . '\", expected: \"' . e . '\"' | |
72 : endif | |
73 : endfor | |
74 : unlet i | |
75 : endif | |
76 :endfor | |
77 :unlet t tl e l | |
78 | |
79 :/\%#=1^Results/,$wq! test.out | |
80 ENDTEST | |
81 | |
82 Results of test95: |