forked from SirVer/ultisnips
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_Transformation.py
278 lines (194 loc) · 8.9 KB
/
test_Transformation.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
# encoding: utf-8
from test.vim_test_case import VimTestCase as _VimTest
from test.constant import *
from test.util import no_unidecode_available
class Transformation_SimpleCase_ExpectCorrectResult(_VimTest):
snippets = ("test", "$1 ${1/foo/batzl/}")
keys = "test" + EX + "hallo foo boy"
wanted = "hallo foo boy hallo batzl boy"
class Transformation_SimpleCaseNoTransform_ExpectCorrectResult(_VimTest):
snippets = ("test", "$1 ${1/foo/batzl/}")
keys = "test" + EX + "hallo"
wanted = "hallo hallo"
class Transformation_SimpleCaseTransformInFront_ExpectCorrectResult(_VimTest):
snippets = ("test", "${1/foo/batzl/} $1")
keys = "test" + EX + "hallo foo"
wanted = "hallo batzl hallo foo"
class Transformation_SimpleCaseTransformInFrontDefVal_ECR(_VimTest):
snippets = ("test", "${1/foo/batzl/} ${1:replace me}")
keys = "test" + EX + "hallo foo"
wanted = "hallo batzl hallo foo"
class Transformation_MultipleTransformations_ECR(_VimTest):
snippets = ("test", "${1:Some Text}${1/.+/\\U$0\E/}\n${1/.+/\L$0\E/}")
keys = "test" + EX + "SomE tExt "
wanted = "SomE tExt SOME TEXT \nsome text "
class Transformation_TabIsAtEndAndDeleted_ECR(_VimTest):
snippets = ("test", "${1/.+/is something/}${1:some}")
keys = "hallo test" + EX + "some\b\b\b\b\b"
wanted = "hallo "
class Transformation_TabIsAtEndAndDeleted1_ECR(_VimTest):
snippets = ("test", "${1/.+/is something/}${1:some}")
keys = "hallo test" + EX + "some\b\b\b\bmore"
wanted = "hallo is somethingmore"
class Transformation_TabIsAtEndNoTextLeave_ECR(_VimTest):
snippets = ("test", "${1/.+/is something/}${1}")
keys = "hallo test" + EX
wanted = "hallo "
class Transformation_TabIsAtEndNoTextType_ECR(_VimTest):
snippets = ("test", "${1/.+/is something/}${1}")
keys = "hallo test" + EX + "b"
wanted = "hallo is somethingb"
class Transformation_InsideTabLeaveAtDefault_ECR(_VimTest):
snippets = ("test", r"$1 ${2:${1/.+/(?0:defined $0)/}}")
keys = "test" + EX + "sometext" + JF
wanted = "sometext defined sometext"
class Transformation_InsideTabOvertype_ECR(_VimTest):
snippets = ("test", r"$1 ${2:${1/.+/(?0:defined $0)/}}")
keys = "test" + EX + "sometext" + JF + "overwrite"
wanted = "sometext overwrite"
class Transformation_Backreference_ExpectCorrectResult(_VimTest):
snippets = ("test", "$1 ${1/([ab])oo/$1ull/}")
keys = "test" + EX + "foo boo aoo"
wanted = "foo boo aoo foo bull aoo"
class Transformation_BackreferenceTwice_ExpectCorrectResult(_VimTest):
snippets = ("test", r"$1 ${1/(dead) (par[^ ]*)/this $2 is a bit $1/}")
keys = "test" + EX + "dead parrot"
wanted = "dead parrot this parrot is a bit dead"
class Transformation_CleverTransformUpercaseChar_ExpectCorrectResult(_VimTest):
snippets = ("test", "$1 ${1/(.)/\\u$1/}")
keys = "test" + EX + "hallo"
wanted = "hallo Hallo"
class Transformation_CleverTransformLowercaseChar_ExpectCorrectResult(_VimTest):
snippets = ("test", "$1 ${1/(.*)/\l$1/}")
keys = "test" + EX + "Hallo"
wanted = "Hallo hallo"
class Transformation_CleverTransformLongUpper_ExpectCorrectResult(_VimTest):
snippets = ("test", "$1 ${1/(.*)/\\U$1\E/}")
keys = "test" + EX + "hallo"
wanted = "hallo HALLO"
class Transformation_CleverTransformLongLower_ExpectCorrectResult(_VimTest):
snippets = ("test", "$1 ${1/(.*)/\L$1\E/}")
keys = "test" + EX + "HALLO"
wanted = "HALLO hallo"
class Transformation_SimpleCaseAsciiResult(_VimTest):
skip_if = lambda self: no_unidecode_available()
snippets = ("ascii", "$1 ${1/(.*)/$1/a}")
keys = "ascii" + EX + "éèàçôïÉÈÀÇÔÏ€"
wanted = "éèàçôïÉÈÀÇÔÏ€ eeacoiEEACOIEUR"
class Transformation_LowerCaseAsciiResult(_VimTest):
skip_if = lambda self: no_unidecode_available()
snippets = ("ascii", "$1 ${1/(.*)/\L$1\E/a}")
keys = "ascii" + EX + "éèàçôïÉÈÀÇÔÏ€"
wanted = "éèàçôïÉÈÀÇÔÏ€ eeacoieeacoieur"
class Transformation_ConditionalInsertionSimple_ExpectCorrectResult(_VimTest):
snippets = ("test", "$1 ${1/(^a).*/(?0:began with an a)/}")
keys = "test" + EX + "a some more text"
wanted = "a some more text began with an a"
class Transformation_CIBothDefinedNegative_ExpectCorrectResult(_VimTest):
snippets = ("test", "$1 ${1/(?:(^a)|(^b)).*/(?1:yes:no)/}")
keys = "test" + EX + "b some"
wanted = "b some no"
class Transformation_CIBothDefinedPositive_ExpectCorrectResult(_VimTest):
snippets = ("test", "$1 ${1/(?:(^a)|(^b)).*/(?1:yes:no)/}")
keys = "test" + EX + "a some"
wanted = "a some yes"
class Transformation_ConditionalInsertRWEllipsis_ECR(_VimTest):
snippets = ("test", r"$1 ${1/(\w+(?:\W+\w+){,7})\W*(.+)?/$1(?2:...)/}")
keys = "test" + EX + "a b c d e f ghhh h oha"
wanted = "a b c d e f ghhh h oha a b c d e f ghhh h..."
class Transformation_ConditionalInConditional_ECR(_VimTest):
snippets = ("test", r"$1 ${1/^.*?(-)?(>)?$/(?2::(?1:>:.))/}")
keys = (
"test"
+ EX
+ "hallo"
+ ESC
+ "$a\n"
+ "test"
+ EX
+ "hallo-"
+ ESC
+ "$a\n"
+ "test"
+ EX
+ "hallo->"
)
wanted = "hallo .\nhallo- >\nhallo-> "
class Transformation_CINewlines_ECR(_VimTest):
snippets = ("test", r"$1 ${1/, */\n/}")
keys = "test" + EX + "test, hallo"
wanted = "test, hallo test\nhallo"
class Transformation_CITabstop_ECR(_VimTest):
snippets = ("test", r"$1 ${1/, */\t/}")
keys = "test" + EX + "test, hallo"
wanted = "test, hallo test\thallo"
class Transformation_CIEscapedParensinReplace_ECR(_VimTest):
snippets = ("test", r"$1 ${1/hal((?:lo)|(?:ul))/(?1:ha\($1\))/}")
keys = "test" + EX + "test, halul"
wanted = "test, halul test, ha(ul)"
class Transformation_OptionIgnoreCase_ECR(_VimTest):
snippets = ("test", r"$1 ${1/test/blah/i}")
keys = "test" + EX + "TEST"
wanted = "TEST blah"
class Transformation_OptionMultiline_ECR(_VimTest):
snippets = ("test", r"${VISUAL/^/* /mg}")
keys = "test\ntest\ntest" + ESC + "V2k" + EX + "test" + EX
wanted = "* test\n* test\n* test"
class Transformation_OptionReplaceGlobal_ECR(_VimTest):
snippets = ("test", r"$1 ${1/, */-/g}")
keys = "test" + EX + "a, nice, building"
wanted = "a, nice, building a-nice-building"
class Transformation_OptionReplaceGlobalMatchInReplace_ECR(_VimTest):
snippets = ("test", r"$1 ${1/, */, /g}")
keys = "test" + EX + "a, nice, building"
wanted = "a, nice, building a, nice, building"
class TransformationUsingBackspaceToDeleteDefaultValueInFirstTab_ECR(_VimTest):
snippets = (
"test",
"snip ${1/.+/(?0:m1)/} ${2/.+/(?0:m2)/} " "${1:default} ${2:def}",
)
keys = "test" + EX + BS + JF + "hi"
wanted = "snip m2 hi"
class TransformationUsingBackspaceToDeleteDefaultValueInSecondTab_ECR(_VimTest):
snippets = (
"test",
"snip ${1/.+/(?0:m1)/} ${2/.+/(?0:m2)/} " "${1:default} ${2:def}",
)
keys = "test" + EX + "hi" + JF + BS
wanted = "snip m1 hi "
class TransformationUsingBackspaceToDeleteDefaultValueTypeSomethingThen_ECR(_VimTest):
snippets = ("test", "snip ${1/.+/(?0:matched)/} ${1:default}")
keys = "test" + EX + BS + "hallo"
wanted = "snip matched hallo"
class TransformationUsingBackspaceToDeleteDefaultValue_ECR(_VimTest):
snippets = ("test", "snip ${1/.+/(?0:matched)/} ${1:default}")
keys = "test" + EX + BS
wanted = "snip "
class Transformation_TestKill_InsertBefore_NoKill(_VimTest):
snippets = "test", r"$1 ${1/.*/\L$0$0\E/}_"
keys = "hallo test" + EX + "AUCH" + ESC + "wihi" + ESC + "bb" + "ino" + JF + "end"
wanted = "hallo noAUCH hinoauchnoauch_end"
class Transformation_TestKill_InsertAfter_NoKill(_VimTest):
snippets = "test", r"$1 ${1/.*/\L$0$0\E/}_"
keys = "hallo test" + EX + "AUCH" + ESC + "eiab" + ESC + "bb" + "ino" + JF + "end"
wanted = "hallo noAUCH noauchnoauchab_end"
class Transformation_TestKill_InsertBeginning_Kill(_VimTest):
snippets = "test", r"$1 ${1/.*/\L$0$0\E/}_"
keys = "hallo test" + EX + "AUCH" + ESC + "wahi" + ESC + "bb" + "ino" + JF + "end"
wanted = "hallo noAUCH ahiuchauch_end"
class Transformation_TestKill_InsertEnd_Kill(_VimTest):
snippets = "test", r"$1 ${1/.*/\L$0$0\E/}_"
keys = "hallo test" + EX + "AUCH" + ESC + "ehihi" + ESC + "bb" + "ino" + JF + "end"
wanted = "hallo noAUCH auchauchih_end"
class Transformation_ConditionalWithEscapedDelimiter(_VimTest):
snippets = "test", r"$1 ${1/(aa)|.*/(?1:yes\:no\))/}"
keys = "test" + EX + "aa"
wanted = "aa yes:no)"
class Transformation_ConditionalWithBackslashBeforeDelimiter(_VimTest):
snippets = "test", r"$1 ${1/(aa)|.*/(?1:yes\\:no)/}"
keys = "test" + EX + "aa"
wanted = "aa yes\\"
class Transformation_ConditionalWithBackslashBeforeDelimiter1(_VimTest):
snippets = "test", r"$1 ${1/(aa)|.*/(?1:yes:no\\)/}"
keys = "test" + EX + "ab"
wanted = "ab no\\"