4444
|
1 Test for regexp patterns with multi-byte support.
|
|
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
|
|
10 :" tl is a List of Lists with:
|
|
11 :" regexp pattern
|
|
12 :" text to test the pattern on
|
|
13 :" expected match (optional)
|
|
14 :" expected submatch 1 (optional)
|
|
15 :" expected submatch 2 (optional)
|
|
16 :" etc.
|
|
17 :" When there is no match use only the first two items.
|
|
18 :let tl = []
|
|
19
|
|
20 :"""" Multi-byte character tests. These will fail unless vim is compiled
|
|
21 :"""" with Multibyte (FEAT_MBYTE) or BIG/HUGE features.
|
|
22 :call add(tl, ['[[:alpha:][=a=]]\+', '879 aiaãâaiuvna ', 'aiaãâaiuvna'])
|
|
23 :call add(tl, ['[[=a=]]\+', 'ddaãâbcd', 'aãâ']) " equivalence classes
|
|
24 :call add(tl, ['[^ม ]\+', 'มม oijasoifjos ifjoisj f osij j มมมมม abcd', 'oijasoifjos'])
|
|
25 :call add(tl, [' [^ ]\+', 'start มabcdม ', ' มabcdม'])
|
|
26 :call add(tl, ['[ม[:alpha:][=a=]]\+', '879 aiaãมâมaiuvna ', 'aiaãมâมaiuvna'])
|
|
27
|
|
28 :"""" Run the tests
|
|
29
|
|
30 :"
|
|
31 :for t in tl
|
|
32 : let l = matchlist(t[1], t[0])
|
|
33 :" check the match itself
|
|
34 : if len(l) == 0 && len(t) > 2
|
|
35 : $put ='ERROR: pat: \"' . t[0] . '\", text: \"' . t[1] . '\", did not match, expected: \"' . t[2] . '\"'
|
|
36 : elseif len(l) > 0 && len(t) == 2
|
|
37 : $put ='ERROR: pat: \"' . t[0] . '\", text: \"' . t[1] . '\", match: \"' . l[0] . '\", expected no match'
|
|
38 : elseif len(t) > 2 && l[0] != t[2]
|
|
39 : $put ='ERROR: pat: \"' . t[0] . '\", text: \"' . t[1] . '\", match: \"' . l[0] . '\", expected: \"' . t[2] . '\"'
|
|
40 : else
|
|
41 : $put ='OK - ' . t[0]
|
|
42 : endif
|
|
43 : if len(l) > 0
|
|
44 :" check all the nine submatches
|
|
45 : for i in range(1, 9)
|
|
46 : if len(t) <= i + 2
|
|
47 : let e = ''
|
|
48 : else
|
|
49 : let e = t[i + 2]
|
|
50 : endif
|
|
51 : if l[i] != e
|
|
52 : $put ='ERROR: pat: \"' . t[0] . '\", text: \"' . t[1] . '\", submatch ' . i . ': \"' . l[i] . '\", expected: \"' . e . '\"'
|
|
53 : endif
|
|
54 : endfor
|
|
55 : unlet i
|
|
56 : endif
|
|
57 :endfor
|
|
58 :unlet t tl e l
|
|
59
|
|
60 :/\%#=1^Results/,$wq! test.out
|
|
61 ENDTEST
|
|
62
|
|
63 Results of test95:
|