2904
|
1 Test for *sub-replace-special* and *sub-replace-expression* on substitue().
|
|
2 Test for submatch() on substitue().
|
|
3 Test for *:s%* on :substitute.
|
|
4
|
|
5 STARTTEST
|
|
6 :so small.vim
|
|
7 ENDTEST
|
|
8
|
|
9 TEST_1:
|
|
10
|
|
11 STARTTEST
|
|
12 :set magic
|
|
13 :set cpo&
|
|
14 :$put =\"\n\nTEST_1:\"
|
|
15 :$put =substitute('A', 'A', '&&', '')
|
|
16 :$put =substitute('B', 'B', '\&', '')
|
|
17 :$put =substitute('C123456789', 'C\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)', '\0\9\8\7\6\5\4\3\2\1', '')
|
|
18 :$put =substitute('D', 'D', 'd', '')
|
|
19 :$put =substitute('E', 'E', '~', '')
|
|
20 :$put =substitute('F', 'F', '\~', '')
|
|
21 :$put =substitute('G', 'G', '\ugg', '')
|
|
22 :$put =substitute('H', 'H', '\Uh\Eh', '')
|
|
23 :$put =substitute('I', 'I', '\lII', '')
|
|
24 :$put =substitute('J', 'J', '\LJ\EJ', '')
|
|
25 :$put =substitute('K', 'K', '\Uk\ek', '')
|
|
26 :$put =substitute('lLl', 'L', '
', '')
|
|
27 :$put =substitute('mMm', 'M', '\r', '')
|
|
28 :$put =substitute('nNn', 'N', '\
', '')
|
|
29 :$put =substitute('oOo', 'O', '\n', '')
|
|
30 :$put =substitute('pPp', 'P', '\b', '')
|
|
31 :$put =substitute('qQq', 'Q', '\t', '')
|
|
32 :$put =substitute('rRr', 'R', '\\', '')
|
|
33 :$put =substitute('sSs', 'S', '\c', '')
|
|
34 :$put =substitute('uUu', 'U', \"\n\", '')
|
|
35 :$put =substitute('vVv', 'V', \"\b\", '')
|
|
36 :$put =substitute('wWw', 'W', \"\\\", '')
|
|
37 :$put =substitute('xXx', 'X', \"\r\", '')
|
4244
|
38 :$put =substitute('Y', 'Y', '\L\uyYy\l\EY', '')
|
|
39 :$put =substitute('Z', 'Z', '\U\lZzZ\u\Ez', '')
|
2904
|
40 /^TEST_2
|
|
41 ENDTEST
|
|
42
|
|
43 TEST_2:
|
|
44
|
|
45 STARTTEST
|
|
46 :set nomagic
|
|
47 :set cpo&
|
|
48 :$put =\"\n\nTEST_2:\"
|
|
49 :$put =substitute('A', 'A', '&&', '')
|
|
50 :$put =substitute('B', 'B', '\&', '')
|
|
51 :$put =substitute('C123456789', 'C\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)', '\0\9\8\7\6\5\4\3\2\1', '')
|
|
52 :$put =substitute('D', 'D', 'd', '')
|
|
53 :$put =substitute('E', 'E', '~', '')
|
|
54 :$put =substitute('F', 'F', '\~', '')
|
|
55 :$put =substitute('G', 'G', '\ugg', '')
|
|
56 :$put =substitute('H', 'H', '\Uh\Eh', '')
|
|
57 :$put =substitute('I', 'I', '\lII', '')
|
|
58 :$put =substitute('J', 'J', '\LJ\EJ', '')
|
|
59 :$put =substitute('K', 'K', '\Uk\ek', '')
|
|
60 :$put =substitute('lLl', 'L', '
', '')
|
|
61 :$put =substitute('mMm', 'M', '\r', '')
|
|
62 :$put =substitute('nNn', 'N', '\
', '')
|
|
63 :$put =substitute('oOo', 'O', '\n', '')
|
|
64 :$put =substitute('pPp', 'P', '\b', '')
|
|
65 :$put =substitute('qQq', 'Q', '\t', '')
|
|
66 :$put =substitute('rRr', 'R', '\\', '')
|
|
67 :$put =substitute('sSs', 'S', '\c', '')
|
|
68 :$put =substitute('tTt', 'T', \"\r\", '')
|
|
69 :$put =substitute('uUu', 'U', \"\n\", '')
|
|
70 :$put =substitute('vVv', 'V', \"\b\", '')
|
|
71 :$put =substitute('wWw', 'W', \"\\\", '')
|
4244
|
72 :$put =substitute('X', 'X', '\L\uxXx\l\EX', '')
|
|
73 :$put =substitute('Y', 'Y', '\U\lYyY\u\Ey', '')
|
2904
|
74 /^TEST_3
|
|
75 ENDTEST
|
|
76
|
|
77 TEST_3:
|
|
78
|
|
79 STARTTEST
|
|
80 :set magic&
|
|
81 :set cpo&
|
|
82 :$put =\"\n\nTEST_3:\"
|
|
83 :let y = substitute('aAa', 'A', '\="\\"', '') | $put =y
|
|
84 :let y = substitute('bBb', 'B', '\="\\\\"', '') | $put =y
|
|
85 :let y = substitute('cCc', 'C', '\="
"', '') | $put =y
|
|
86 :let y = substitute('dDd', 'D', '\="\\
"', '') | $put =y
|
|
87 :let y = substitute('eEe', 'E', '\="\\\\
"', '') | $put =y
|
|
88 :let y = substitute('fFf', 'F', '\="\\r"', '') | $put =y
|
|
89 :let y = substitute('jJj', 'J', '\="\\n"', '') | $put =y
|
|
90 :let y = substitute('kKk', 'K', '\="\r"', '') | $put =y
|
|
91 :let y = substitute('lLl', 'L', '\="\n"', '') | $put =y
|
|
92 /^TEST_4
|
|
93 ENDTEST
|
|
94
|
|
95 TEST_4:
|
|
96
|
|
97 STARTTEST
|
|
98 :set magic&
|
|
99 :set cpo&
|
|
100 :$put =\"\n\nTEST_4:\"
|
|
101 :let y = substitute('aAa', 'A', '\=substitute(submatch(0), ".", "\\", "")', '') | $put =y
|
|
102 :let y = substitute('bBb', 'B', '\=substitute(submatch(0), ".", "\\\\", "")', '') | $put =y
|
|
103 :let y = substitute('cCc', 'C', '\=substitute(submatch(0), ".", "
", "")', '') | $put =y
|
|
104 :let y = substitute('dDd', 'D', '\=substitute(submatch(0), ".", "\\
", "")', '') | $put =y
|
|
105 :let y = substitute('eEe', 'E', '\=substitute(submatch(0), ".", "\\\\
", "")', '') | $put =y
|
|
106 :let y = substitute('fFf', 'F', '\=substitute(submatch(0), ".", "\\r", "")', '') | $put =y
|
|
107 :let y = substitute('jJj', 'J', '\=substitute(submatch(0), ".", "\\n", "")', '') | $put =y
|
|
108 :let y = substitute('kKk', 'K', '\=substitute(submatch(0), ".", "\r", "")', '') | $put =y
|
|
109 :let y = substitute('lLl', 'L', '\=substitute(submatch(0), ".", "\n", "")', '') | $put =y
|
|
110 /^TEST_5
|
|
111 ENDTEST
|
|
112
|
|
113 TEST_5:
|
|
114
|
|
115 STARTTEST
|
|
116 :set magic&
|
|
117 :set cpo&
|
|
118 :$put =\"\n\nTEST_5:\"
|
|
119 :$put =substitute('A123456789', 'A\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)', '\=submatch(0) . submatch(9) . submatch(8) . submatch(7) . submatch(6) . submatch(5) . submatch(4) . submatch(3) . submatch(2) . submatch(1)', '')
|
|
120 /^TEST_6
|
|
121 ENDTEST
|
|
122
|
|
123 TEST_6:
|
|
124
|
|
125 STARTTEST
|
|
126 :set magic&
|
|
127 :$put =\"\n\nTEST_6:\"
|
|
128 :set cpo+=/
|
|
129 :$put =substitute('A', 'A', 'a', '')
|
|
130 :$put =substitute('B', 'B', '%', '')
|
|
131 :set cpo-=/
|
|
132 :$put =substitute('C', 'C', 'c', '')
|
|
133 :$put =substitute('D', 'D', '%', '')
|
|
134 /^TEST_7
|
|
135 ENDTEST
|
|
136
|
|
137 TEST_7:
|
|
138
|
|
139 STARTTEST
|
|
140 :set magic&
|
|
141 :set cpo&
|
|
142 :$put =\"\n\nTEST_7:\"
|
|
143 :$put =substitute('A
A', 'A.', '\=submatch(0)', '')
|
|
144 :$put =substitute(\"B\nB\", 'B.', '\=submatch(0)', '')
|
5388
|
145 :$put =substitute('-bb', '\zeb', 'a', 'g')
|
|
146 :$put =substitute('-bb', '\ze', 'c', 'g')
|
2904
|
147 /^TEST_8
|
|
148 ENDTEST
|
|
149
|
|
150 TEST_8:
|
|
151
|
|
152 STARTTEST
|
4078
|
153 :set magic&
|
|
154 :set cpo&
|
|
155 :$put =\"\n\nTEST_8:\"
|
|
156 :$put =',,X'
|
|
157 :s/\(^\|,\)\ze\(,\|X\)/\1N/g
|
|
158 :$put =',,Y'
|
|
159 :s/\(^\|,\)\ze\(,\|Y\)/\1N/gc
|
|
160 a:$put =',,Z'
|
|
161 :s/\(^\|,\)\ze\(,\|Z\)/\1N/gc
|
4099
|
162 yy/^TEST_9:
|
4078
|
163 ENDTEST
|
|
164
|
|
165 TEST_9:
|
|
166
|
|
167 STARTTEST
|
4099
|
168 :set magic&
|
|
169 :set cpo&
|
|
170 :$put =\"\n\nTEST_9:\"
|
|
171 :$put ='xxx'
|
|
172 :s/x/X/gc
|
|
173 yyq/^TEST_10:
|
|
174 ENDTEST
|
|
175
|
|
176 TEST_10:
|
|
177
|
|
178 STARTTEST
|
2904
|
179 :/^Results/,$wq! test.out
|
|
180 ENDTEST
|
|
181
|
|
182 Results of test72:
|