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\", '')
|
|
38 /^TEST_2
|
|
39 ENDTEST
|
|
40
|
|
41 TEST_2:
|
|
42
|
|
43 STARTTEST
|
|
44 :set nomagic
|
|
45 :set cpo&
|
|
46 :$put =\"\n\nTEST_2:\"
|
|
47 :$put =substitute('A', 'A', '&&', '')
|
|
48 :$put =substitute('B', 'B', '\&', '')
|
|
49 :$put =substitute('C123456789', 'C\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)', '\0\9\8\7\6\5\4\3\2\1', '')
|
|
50 :$put =substitute('D', 'D', 'd', '')
|
|
51 :$put =substitute('E', 'E', '~', '')
|
|
52 :$put =substitute('F', 'F', '\~', '')
|
|
53 :$put =substitute('G', 'G', '\ugg', '')
|
|
54 :$put =substitute('H', 'H', '\Uh\Eh', '')
|
|
55 :$put =substitute('I', 'I', '\lII', '')
|
|
56 :$put =substitute('J', 'J', '\LJ\EJ', '')
|
|
57 :$put =substitute('K', 'K', '\Uk\ek', '')
|
|
58 :$put =substitute('lLl', 'L', '
', '')
|
|
59 :$put =substitute('mMm', 'M', '\r', '')
|
|
60 :$put =substitute('nNn', 'N', '\
', '')
|
|
61 :$put =substitute('oOo', 'O', '\n', '')
|
|
62 :$put =substitute('pPp', 'P', '\b', '')
|
|
63 :$put =substitute('qQq', 'Q', '\t', '')
|
|
64 :$put =substitute('rRr', 'R', '\\', '')
|
|
65 :$put =substitute('sSs', 'S', '\c', '')
|
|
66 :$put =substitute('tTt', 'T', \"\r\", '')
|
|
67 :$put =substitute('uUu', 'U', \"\n\", '')
|
|
68 :$put =substitute('vVv', 'V', \"\b\", '')
|
|
69 :$put =substitute('wWw', 'W', \"\\\", '')
|
|
70 /^TEST_3
|
|
71 ENDTEST
|
|
72
|
|
73 TEST_3:
|
|
74
|
|
75 STARTTEST
|
|
76 :set magic&
|
|
77 :set cpo&
|
|
78 :$put =\"\n\nTEST_3:\"
|
|
79 :let y = substitute('aAa', 'A', '\="\\"', '') | $put =y
|
|
80 :let y = substitute('bBb', 'B', '\="\\\\"', '') | $put =y
|
|
81 :let y = substitute('cCc', 'C', '\="
"', '') | $put =y
|
|
82 :let y = substitute('dDd', 'D', '\="\\
"', '') | $put =y
|
|
83 :let y = substitute('eEe', 'E', '\="\\\\
"', '') | $put =y
|
|
84 :let y = substitute('fFf', 'F', '\="\\r"', '') | $put =y
|
|
85 :let y = substitute('jJj', 'J', '\="\\n"', '') | $put =y
|
|
86 :let y = substitute('kKk', 'K', '\="\r"', '') | $put =y
|
|
87 :let y = substitute('lLl', 'L', '\="\n"', '') | $put =y
|
|
88 /^TEST_4
|
|
89 ENDTEST
|
|
90
|
|
91 TEST_4:
|
|
92
|
|
93 STARTTEST
|
|
94 :set magic&
|
|
95 :set cpo&
|
|
96 :$put =\"\n\nTEST_4:\"
|
|
97 :let y = substitute('aAa', 'A', '\=substitute(submatch(0), ".", "\\", "")', '') | $put =y
|
|
98 :let y = substitute('bBb', 'B', '\=substitute(submatch(0), ".", "\\\\", "")', '') | $put =y
|
|
99 :let y = substitute('cCc', 'C', '\=substitute(submatch(0), ".", "
", "")', '') | $put =y
|
|
100 :let y = substitute('dDd', 'D', '\=substitute(submatch(0), ".", "\\
", "")', '') | $put =y
|
|
101 :let y = substitute('eEe', 'E', '\=substitute(submatch(0), ".", "\\\\
", "")', '') | $put =y
|
|
102 :let y = substitute('fFf', 'F', '\=substitute(submatch(0), ".", "\\r", "")', '') | $put =y
|
|
103 :let y = substitute('jJj', 'J', '\=substitute(submatch(0), ".", "\\n", "")', '') | $put =y
|
|
104 :let y = substitute('kKk', 'K', '\=substitute(submatch(0), ".", "\r", "")', '') | $put =y
|
|
105 :let y = substitute('lLl', 'L', '\=substitute(submatch(0), ".", "\n", "")', '') | $put =y
|
|
106 /^TEST_5
|
|
107 ENDTEST
|
|
108
|
|
109 TEST_5:
|
|
110
|
|
111 STARTTEST
|
|
112 :set magic&
|
|
113 :set cpo&
|
|
114 :$put =\"\n\nTEST_5:\"
|
|
115 :$put =substitute('A123456789', 'A\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)', '\=submatch(0) . submatch(9) . submatch(8) . submatch(7) . submatch(6) . submatch(5) . submatch(4) . submatch(3) . submatch(2) . submatch(1)', '')
|
|
116 /^TEST_6
|
|
117 ENDTEST
|
|
118
|
|
119 TEST_6:
|
|
120
|
|
121 STARTTEST
|
|
122 :set magic&
|
|
123 :$put =\"\n\nTEST_6:\"
|
|
124 :set cpo+=/
|
|
125 :$put =substitute('A', 'A', 'a', '')
|
|
126 :$put =substitute('B', 'B', '%', '')
|
|
127 :set cpo-=/
|
|
128 :$put =substitute('C', 'C', 'c', '')
|
|
129 :$put =substitute('D', 'D', '%', '')
|
|
130 /^TEST_7
|
|
131 ENDTEST
|
|
132
|
|
133 TEST_7:
|
|
134
|
|
135 STARTTEST
|
|
136 :set magic&
|
|
137 :set cpo&
|
|
138 :$put =\"\n\nTEST_7:\"
|
|
139 :$put =substitute('A
A', 'A.', '\=submatch(0)', '')
|
|
140 :$put =substitute(\"B\nB\", 'B.', '\=submatch(0)', '')
|
|
141 /^TEST_8
|
|
142 ENDTEST
|
|
143
|
|
144 TEST_8:
|
|
145
|
|
146 STARTTEST
|
|
147 :/^Results/,$wq! test.out
|
|
148 ENDTEST
|
|
149
|
|
150 Results of test72:
|