annotate src/testdir/test_regexp_utf8.vim @ 8995:3cf6704d6efc v7.4.1783

commit https://github.com/vim/vim/commit/af98a49dd0ef1661b4998f118151fddbf6e4df75 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Apr 24 14:40:12 2016 +0200 patch 7.4.1783 Problem: The old regexp engine doesn't handle character classes correctly. (Manuel Ortega) Solution: Use regmbc() instead of regc(). Add a test.
author Christian Brabandt <cb@256bit.org>
date Sun, 24 Apr 2016 14:45:04 +0200
parents 318eaa6fa973
children f414db42d167
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
8825
318eaa6fa973 commit https://github.com/vim/vim/commit/22e421549d54147d003f6444de007cb1d73f1d27
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1 " Tests for regexp in utf8 encoding
318eaa6fa973 commit https://github.com/vim/vim/commit/22e421549d54147d003f6444de007cb1d73f1d27
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2 if !has('multi_byte')
318eaa6fa973 commit https://github.com/vim/vim/commit/22e421549d54147d003f6444de007cb1d73f1d27
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3 finish
318eaa6fa973 commit https://github.com/vim/vim/commit/22e421549d54147d003f6444de007cb1d73f1d27
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4 endif
318eaa6fa973 commit https://github.com/vim/vim/commit/22e421549d54147d003f6444de007cb1d73f1d27
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5 set encoding=utf-8
318eaa6fa973 commit https://github.com/vim/vim/commit/22e421549d54147d003f6444de007cb1d73f1d27
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6 scriptencoding utf-8
318eaa6fa973 commit https://github.com/vim/vim/commit/22e421549d54147d003f6444de007cb1d73f1d27
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7
318eaa6fa973 commit https://github.com/vim/vim/commit/22e421549d54147d003f6444de007cb1d73f1d27
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8 func s:equivalence_test()
318eaa6fa973 commit https://github.com/vim/vim/commit/22e421549d54147d003f6444de007cb1d73f1d27
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9 let str = "AÀÁÂÃÄÅĀĂĄǍǞǠẢ BḂḆ CÇĆĈĊČ DĎĐḊḎḐ EÈÉÊËĒĔĖĘĚẺẼ FḞ GĜĞĠĢǤǦǴḠ HĤĦḢḦḨ IÌÍÎÏĨĪĬĮİǏỈ JĴ KĶǨḰḴ LĹĻĽĿŁḺ MḾṀ NÑŃŅŇṄṈ OÒÓÔÕÖØŌŎŐƠǑǪǬỎ PṔṖ Q RŔŖŘṘṞ SŚŜŞŠṠ TŢŤŦṪṮ UÙÚÛÜŨŪŬŮŰŲƯǓỦ VṼ WŴẀẂẄẆ XẊẌ YÝŶŸẎỲỶỸ ZŹŻŽƵẐẔ aàáâãäåāăąǎǟǡả bḃḇ cçćĉċč dďđḋḏḑ eèéêëēĕėęěẻẽ fḟ gĝğġģǥǧǵḡ hĥħḣḧḩẖ iìíîïĩīĭįǐỉ jĵǰ kķǩḱḵ lĺļľŀłḻ mḿṁ nñńņňʼnṅṉ oòóôõöøōŏőơǒǫǭỏ pṕṗ q rŕŗřṙṟ sśŝşšṡ tţťŧṫṯẗ uùúûüũūŭůűųưǔủ vṽ wŵẁẃẅẇẘ xẋẍ yýÿŷẏẙỳỷỹ zźżžƶẑẕ"
318eaa6fa973 commit https://github.com/vim/vim/commit/22e421549d54147d003f6444de007cb1d73f1d27
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10 let groups = split(str)
318eaa6fa973 commit https://github.com/vim/vim/commit/22e421549d54147d003f6444de007cb1d73f1d27
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
11 for group1 in groups
318eaa6fa973 commit https://github.com/vim/vim/commit/22e421549d54147d003f6444de007cb1d73f1d27
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
12 for c in split(group1, '\zs')
318eaa6fa973 commit https://github.com/vim/vim/commit/22e421549d54147d003f6444de007cb1d73f1d27
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
13 " next statement confirms that equivalence class matches every
318eaa6fa973 commit https://github.com/vim/vim/commit/22e421549d54147d003f6444de007cb1d73f1d27
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
14 " character in group
318eaa6fa973 commit https://github.com/vim/vim/commit/22e421549d54147d003f6444de007cb1d73f1d27
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
15 call assert_match('^[[=' . c . '=]]*$', group1)
318eaa6fa973 commit https://github.com/vim/vim/commit/22e421549d54147d003f6444de007cb1d73f1d27
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
16 for group2 in groups
318eaa6fa973 commit https://github.com/vim/vim/commit/22e421549d54147d003f6444de007cb1d73f1d27
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
17 if group2 != group1
318eaa6fa973 commit https://github.com/vim/vim/commit/22e421549d54147d003f6444de007cb1d73f1d27
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
18 " next statement converts that equivalence class doesn't match
318eaa6fa973 commit https://github.com/vim/vim/commit/22e421549d54147d003f6444de007cb1d73f1d27
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
19 " character in any other group
318eaa6fa973 commit https://github.com/vim/vim/commit/22e421549d54147d003f6444de007cb1d73f1d27
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
20 call assert_equal(-1, match(group2, '[[=' . c . '=]]'))
318eaa6fa973 commit https://github.com/vim/vim/commit/22e421549d54147d003f6444de007cb1d73f1d27
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
21 endif
318eaa6fa973 commit https://github.com/vim/vim/commit/22e421549d54147d003f6444de007cb1d73f1d27
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
22 endfor
318eaa6fa973 commit https://github.com/vim/vim/commit/22e421549d54147d003f6444de007cb1d73f1d27
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
23 endfor
318eaa6fa973 commit https://github.com/vim/vim/commit/22e421549d54147d003f6444de007cb1d73f1d27
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
24 endfor
318eaa6fa973 commit https://github.com/vim/vim/commit/22e421549d54147d003f6444de007cb1d73f1d27
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
25 endfunc
318eaa6fa973 commit https://github.com/vim/vim/commit/22e421549d54147d003f6444de007cb1d73f1d27
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
26
318eaa6fa973 commit https://github.com/vim/vim/commit/22e421549d54147d003f6444de007cb1d73f1d27
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
27 func Test_equivalence_re1()
318eaa6fa973 commit https://github.com/vim/vim/commit/22e421549d54147d003f6444de007cb1d73f1d27
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
28 set re=1
318eaa6fa973 commit https://github.com/vim/vim/commit/22e421549d54147d003f6444de007cb1d73f1d27
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
29 call s:equivalence_test()
318eaa6fa973 commit https://github.com/vim/vim/commit/22e421549d54147d003f6444de007cb1d73f1d27
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
30 endfunc
318eaa6fa973 commit https://github.com/vim/vim/commit/22e421549d54147d003f6444de007cb1d73f1d27
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
31
318eaa6fa973 commit https://github.com/vim/vim/commit/22e421549d54147d003f6444de007cb1d73f1d27
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
32 func Test_equivalence_re2()
318eaa6fa973 commit https://github.com/vim/vim/commit/22e421549d54147d003f6444de007cb1d73f1d27
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
33 set re=2
318eaa6fa973 commit https://github.com/vim/vim/commit/22e421549d54147d003f6444de007cb1d73f1d27
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
34 call s:equivalence_test()
318eaa6fa973 commit https://github.com/vim/vim/commit/22e421549d54147d003f6444de007cb1d73f1d27
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
35 endfunc
8995
3cf6704d6efc commit https://github.com/vim/vim/commit/af98a49dd0ef1661b4998f118151fddbf6e4df75
Christian Brabandt <cb@256bit.org>
parents: 8825
diff changeset
36
3cf6704d6efc commit https://github.com/vim/vim/commit/af98a49dd0ef1661b4998f118151fddbf6e4df75
Christian Brabandt <cb@256bit.org>
parents: 8825
diff changeset
37 func s:classes_test()
3cf6704d6efc commit https://github.com/vim/vim/commit/af98a49dd0ef1661b4998f118151fddbf6e4df75
Christian Brabandt <cb@256bit.org>
parents: 8825
diff changeset
38 call assert_equal('Motörhead', matchstr('Motörhead', '[[:print:]]\+'))
3cf6704d6efc commit https://github.com/vim/vim/commit/af98a49dd0ef1661b4998f118151fddbf6e4df75
Christian Brabandt <cb@256bit.org>
parents: 8825
diff changeset
39
3cf6704d6efc commit https://github.com/vim/vim/commit/af98a49dd0ef1661b4998f118151fddbf6e4df75
Christian Brabandt <cb@256bit.org>
parents: 8825
diff changeset
40 let alphachars = ''
3cf6704d6efc commit https://github.com/vim/vim/commit/af98a49dd0ef1661b4998f118151fddbf6e4df75
Christian Brabandt <cb@256bit.org>
parents: 8825
diff changeset
41 let lowerchars = ''
3cf6704d6efc commit https://github.com/vim/vim/commit/af98a49dd0ef1661b4998f118151fddbf6e4df75
Christian Brabandt <cb@256bit.org>
parents: 8825
diff changeset
42 let upperchars = ''
3cf6704d6efc commit https://github.com/vim/vim/commit/af98a49dd0ef1661b4998f118151fddbf6e4df75
Christian Brabandt <cb@256bit.org>
parents: 8825
diff changeset
43 let alnumchars = ''
3cf6704d6efc commit https://github.com/vim/vim/commit/af98a49dd0ef1661b4998f118151fddbf6e4df75
Christian Brabandt <cb@256bit.org>
parents: 8825
diff changeset
44 let printchars = ''
3cf6704d6efc commit https://github.com/vim/vim/commit/af98a49dd0ef1661b4998f118151fddbf6e4df75
Christian Brabandt <cb@256bit.org>
parents: 8825
diff changeset
45 let punctchars = ''
3cf6704d6efc commit https://github.com/vim/vim/commit/af98a49dd0ef1661b4998f118151fddbf6e4df75
Christian Brabandt <cb@256bit.org>
parents: 8825
diff changeset
46 let xdigitchars = ''
3cf6704d6efc commit https://github.com/vim/vim/commit/af98a49dd0ef1661b4998f118151fddbf6e4df75
Christian Brabandt <cb@256bit.org>
parents: 8825
diff changeset
47 let i = 1
3cf6704d6efc commit https://github.com/vim/vim/commit/af98a49dd0ef1661b4998f118151fddbf6e4df75
Christian Brabandt <cb@256bit.org>
parents: 8825
diff changeset
48 while i <= 255
3cf6704d6efc commit https://github.com/vim/vim/commit/af98a49dd0ef1661b4998f118151fddbf6e4df75
Christian Brabandt <cb@256bit.org>
parents: 8825
diff changeset
49 let c = nr2char(i)
3cf6704d6efc commit https://github.com/vim/vim/commit/af98a49dd0ef1661b4998f118151fddbf6e4df75
Christian Brabandt <cb@256bit.org>
parents: 8825
diff changeset
50 if c =~ '[[:alpha:]]'
3cf6704d6efc commit https://github.com/vim/vim/commit/af98a49dd0ef1661b4998f118151fddbf6e4df75
Christian Brabandt <cb@256bit.org>
parents: 8825
diff changeset
51 let alphachars .= c
3cf6704d6efc commit https://github.com/vim/vim/commit/af98a49dd0ef1661b4998f118151fddbf6e4df75
Christian Brabandt <cb@256bit.org>
parents: 8825
diff changeset
52 endif
3cf6704d6efc commit https://github.com/vim/vim/commit/af98a49dd0ef1661b4998f118151fddbf6e4df75
Christian Brabandt <cb@256bit.org>
parents: 8825
diff changeset
53 if c =~ '[[:lower:]]'
3cf6704d6efc commit https://github.com/vim/vim/commit/af98a49dd0ef1661b4998f118151fddbf6e4df75
Christian Brabandt <cb@256bit.org>
parents: 8825
diff changeset
54 let lowerchars .= c
3cf6704d6efc commit https://github.com/vim/vim/commit/af98a49dd0ef1661b4998f118151fddbf6e4df75
Christian Brabandt <cb@256bit.org>
parents: 8825
diff changeset
55 endif
3cf6704d6efc commit https://github.com/vim/vim/commit/af98a49dd0ef1661b4998f118151fddbf6e4df75
Christian Brabandt <cb@256bit.org>
parents: 8825
diff changeset
56 if c =~ '[[:upper:]]'
3cf6704d6efc commit https://github.com/vim/vim/commit/af98a49dd0ef1661b4998f118151fddbf6e4df75
Christian Brabandt <cb@256bit.org>
parents: 8825
diff changeset
57 let upperchars .= c
3cf6704d6efc commit https://github.com/vim/vim/commit/af98a49dd0ef1661b4998f118151fddbf6e4df75
Christian Brabandt <cb@256bit.org>
parents: 8825
diff changeset
58 endif
3cf6704d6efc commit https://github.com/vim/vim/commit/af98a49dd0ef1661b4998f118151fddbf6e4df75
Christian Brabandt <cb@256bit.org>
parents: 8825
diff changeset
59 if c =~ '[[:alnum:]]'
3cf6704d6efc commit https://github.com/vim/vim/commit/af98a49dd0ef1661b4998f118151fddbf6e4df75
Christian Brabandt <cb@256bit.org>
parents: 8825
diff changeset
60 let alnumchars .= c
3cf6704d6efc commit https://github.com/vim/vim/commit/af98a49dd0ef1661b4998f118151fddbf6e4df75
Christian Brabandt <cb@256bit.org>
parents: 8825
diff changeset
61 endif
3cf6704d6efc commit https://github.com/vim/vim/commit/af98a49dd0ef1661b4998f118151fddbf6e4df75
Christian Brabandt <cb@256bit.org>
parents: 8825
diff changeset
62 if c =~ '[[:print:]]'
3cf6704d6efc commit https://github.com/vim/vim/commit/af98a49dd0ef1661b4998f118151fddbf6e4df75
Christian Brabandt <cb@256bit.org>
parents: 8825
diff changeset
63 let printchars .= c
3cf6704d6efc commit https://github.com/vim/vim/commit/af98a49dd0ef1661b4998f118151fddbf6e4df75
Christian Brabandt <cb@256bit.org>
parents: 8825
diff changeset
64 endif
3cf6704d6efc commit https://github.com/vim/vim/commit/af98a49dd0ef1661b4998f118151fddbf6e4df75
Christian Brabandt <cb@256bit.org>
parents: 8825
diff changeset
65 if c =~ '[[:punct:]]'
3cf6704d6efc commit https://github.com/vim/vim/commit/af98a49dd0ef1661b4998f118151fddbf6e4df75
Christian Brabandt <cb@256bit.org>
parents: 8825
diff changeset
66 let punctchars .= c
3cf6704d6efc commit https://github.com/vim/vim/commit/af98a49dd0ef1661b4998f118151fddbf6e4df75
Christian Brabandt <cb@256bit.org>
parents: 8825
diff changeset
67 endif
3cf6704d6efc commit https://github.com/vim/vim/commit/af98a49dd0ef1661b4998f118151fddbf6e4df75
Christian Brabandt <cb@256bit.org>
parents: 8825
diff changeset
68 if c =~ '[[:xdigit:]]'
3cf6704d6efc commit https://github.com/vim/vim/commit/af98a49dd0ef1661b4998f118151fddbf6e4df75
Christian Brabandt <cb@256bit.org>
parents: 8825
diff changeset
69 let xdigitchars .= c
3cf6704d6efc commit https://github.com/vim/vim/commit/af98a49dd0ef1661b4998f118151fddbf6e4df75
Christian Brabandt <cb@256bit.org>
parents: 8825
diff changeset
70 endif
3cf6704d6efc commit https://github.com/vim/vim/commit/af98a49dd0ef1661b4998f118151fddbf6e4df75
Christian Brabandt <cb@256bit.org>
parents: 8825
diff changeset
71 let i += 1
3cf6704d6efc commit https://github.com/vim/vim/commit/af98a49dd0ef1661b4998f118151fddbf6e4df75
Christian Brabandt <cb@256bit.org>
parents: 8825
diff changeset
72 endwhile
3cf6704d6efc commit https://github.com/vim/vim/commit/af98a49dd0ef1661b4998f118151fddbf6e4df75
Christian Brabandt <cb@256bit.org>
parents: 8825
diff changeset
73
3cf6704d6efc commit https://github.com/vim/vim/commit/af98a49dd0ef1661b4998f118151fddbf6e4df75
Christian Brabandt <cb@256bit.org>
parents: 8825
diff changeset
74 call assert_equal('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz', alphachars)
3cf6704d6efc commit https://github.com/vim/vim/commit/af98a49dd0ef1661b4998f118151fddbf6e4df75
Christian Brabandt <cb@256bit.org>
parents: 8825
diff changeset
75 call assert_equal('abcdefghijklmnopqrstuvwxyzµßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ', lowerchars)
3cf6704d6efc commit https://github.com/vim/vim/commit/af98a49dd0ef1661b4998f118151fddbf6e4df75
Christian Brabandt <cb@256bit.org>
parents: 8825
diff changeset
76 call assert_equal('ABCDEFGHIJKLMNOPQRSTUVWXYZÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞ', upperchars)
3cf6704d6efc commit https://github.com/vim/vim/commit/af98a49dd0ef1661b4998f118151fddbf6e4df75
Christian Brabandt <cb@256bit.org>
parents: 8825
diff changeset
77 call assert_equal('0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz', alnumchars)
3cf6704d6efc commit https://github.com/vim/vim/commit/af98a49dd0ef1661b4998f118151fddbf6e4df75
Christian Brabandt <cb@256bit.org>
parents: 8825
diff changeset
78 call assert_equal(' !"#$%&''()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ', printchars)
3cf6704d6efc commit https://github.com/vim/vim/commit/af98a49dd0ef1661b4998f118151fddbf6e4df75
Christian Brabandt <cb@256bit.org>
parents: 8825
diff changeset
79 call assert_equal('!"#$%&''()*+,-./:;<=>?@[\]^_`{|}~', punctchars)
3cf6704d6efc commit https://github.com/vim/vim/commit/af98a49dd0ef1661b4998f118151fddbf6e4df75
Christian Brabandt <cb@256bit.org>
parents: 8825
diff changeset
80 call assert_equal('0123456789ABCDEFabcdef', xdigitchars)
3cf6704d6efc commit https://github.com/vim/vim/commit/af98a49dd0ef1661b4998f118151fddbf6e4df75
Christian Brabandt <cb@256bit.org>
parents: 8825
diff changeset
81 endfunc
3cf6704d6efc commit https://github.com/vim/vim/commit/af98a49dd0ef1661b4998f118151fddbf6e4df75
Christian Brabandt <cb@256bit.org>
parents: 8825
diff changeset
82
3cf6704d6efc commit https://github.com/vim/vim/commit/af98a49dd0ef1661b4998f118151fddbf6e4df75
Christian Brabandt <cb@256bit.org>
parents: 8825
diff changeset
83 func Test_classes_re1()
3cf6704d6efc commit https://github.com/vim/vim/commit/af98a49dd0ef1661b4998f118151fddbf6e4df75
Christian Brabandt <cb@256bit.org>
parents: 8825
diff changeset
84 set re=1
3cf6704d6efc commit https://github.com/vim/vim/commit/af98a49dd0ef1661b4998f118151fddbf6e4df75
Christian Brabandt <cb@256bit.org>
parents: 8825
diff changeset
85 call s:classes_test()
3cf6704d6efc commit https://github.com/vim/vim/commit/af98a49dd0ef1661b4998f118151fddbf6e4df75
Christian Brabandt <cb@256bit.org>
parents: 8825
diff changeset
86 endfunc
3cf6704d6efc commit https://github.com/vim/vim/commit/af98a49dd0ef1661b4998f118151fddbf6e4df75
Christian Brabandt <cb@256bit.org>
parents: 8825
diff changeset
87
3cf6704d6efc commit https://github.com/vim/vim/commit/af98a49dd0ef1661b4998f118151fddbf6e4df75
Christian Brabandt <cb@256bit.org>
parents: 8825
diff changeset
88 func Test_classes_re2()
3cf6704d6efc commit https://github.com/vim/vim/commit/af98a49dd0ef1661b4998f118151fddbf6e4df75
Christian Brabandt <cb@256bit.org>
parents: 8825
diff changeset
89 set re=2
3cf6704d6efc commit https://github.com/vim/vim/commit/af98a49dd0ef1661b4998f118151fddbf6e4df75
Christian Brabandt <cb@256bit.org>
parents: 8825
diff changeset
90 call s:classes_test()
3cf6704d6efc commit https://github.com/vim/vim/commit/af98a49dd0ef1661b4998f118151fddbf6e4df75
Christian Brabandt <cb@256bit.org>
parents: 8825
diff changeset
91 endfunc