File: test_Chars.py

package info (click to toggle)
vim-ultisnips 3.2-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,924 kB
  • sloc: python: 8,353; sh: 64; makefile: 38
file content (270 lines) | stat: -rw-r--r-- 5,444 bytes parent folder | download | duplicates (2)
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
# encoding: utf-8
from test.vim_test_case import VimTestCase as _VimTest
from test.constant import *
from test.util import running_on_windows

# Test for Bug #774917


def _snip_quote(qt):
    return (
        ("te" + qt + "st", "Expand me" + qt + "!", "test: " + qt),
        ("te", "Bad", ""),
    )


class Snippet_With_SingleQuote(_VimTest):
    snippets = _snip_quote("'")
    keys = "te'st" + EX
    wanted = "Expand me'!"


class Snippet_With_SingleQuote_List(_VimTest):
    snippets = _snip_quote("'")
    keys = "te" + LS + "2\n"
    wanted = "Expand me'!"


class Snippet_With_DoubleQuote(_VimTest):
    snippets = _snip_quote('"')
    keys = 'te"st' + EX
    wanted = 'Expand me"!'


class Snippet_With_DoubleQuote_List(_VimTest):
    snippets = _snip_quote('"')
    keys = "te" + LS + "2\n"
    wanted = 'Expand me"!'


class RemoveTrailingWhitespace(_VimTest):
    snippets = ("test", """Hello\t ${1:default}\n$2""", "", "s")
    wanted = """Hello\nGoodbye"""
    keys = "test" + EX + BS + JF + "Goodbye"


class TrimSpacesAtEndOfLines(_VimTest):
    snippets = ("test", """next line\n\nshould be empty""", "", "m")
    wanted = """\tnext line\n\n\tshould be empty"""
    keys = "\ttest" + EX


class DoNotTrimSpacesAtEndOfLinesByDefault(_VimTest):
    snippets = ("test", """next line\n\nshould be empty""", "", "")
    wanted = """\tnext line\n\t\n\tshould be empty"""
    keys = "\ttest" + EX


class LeaveTrailingWhitespace(_VimTest):
    snippets = ("test", """Hello \t ${1:default}\n$2""")
    wanted = """Hello \t \nGoodbye"""
    keys = "test" + EX + BS + JF + "Goodbye"


# Tests for bug 616315 #


class TrailingNewline_TabStop_NLInsideStuffBehind(_VimTest):
    snippets = (
        "test",
        r"""
x${1:
}<-behind1
$2<-behind2""",
    )
    keys = "test" + EX + "j" + JF + "k"
    wanted = """
xj<-behind1
k<-behind2"""


class TrailingNewline_TabStop_JustNL(_VimTest):
    snippets = (
        "test",
        r"""
x${1:
}
$2""",
    )
    keys = "test" + EX + "j" + JF + "k"
    wanted = """
xj
k"""


class TrailingNewline_TabStop_EndNL(_VimTest):
    snippets = (
        "test",
        r"""
x${1:a
}
$2""",
    )
    keys = "test" + EX + "j" + JF + "k"
    wanted = """
xj
k"""


class TrailingNewline_TabStop_StartNL(_VimTest):
    snippets = (
        "test",
        r"""
x${1:
a}
$2""",
    )
    keys = "test" + EX + "j" + JF + "k"
    wanted = """
xj
k"""


class TrailingNewline_TabStop_EndStartNL(_VimTest):
    snippets = (
        "test",
        r"""
x${1:
a
}
$2""",
    )
    keys = "test" + EX + "j" + JF + "k"
    wanted = """
xj
k"""


class TrailingNewline_TabStop_NotEndStartNL(_VimTest):
    snippets = (
        "test",
        r"""
x${1:a
a}
$2""",
    )
    keys = "test" + EX + "j" + JF + "k"
    wanted = """
xj
k"""


class TrailingNewline_TabStop_ExtraNL_ECR(_VimTest):
    snippets = (
        "test",
        r"""
x${1:a
a}
$2
""",
    )
    keys = "test" + EX + "j" + JF + "k"
    wanted = """
xj
k
"""


class _MultiLineDefault(_VimTest):
    snippets = (
        "test",
        r"""
x${1:a
b
c
d
e
f}
$2""",
    )


class MultiLineDefault_Jump(_MultiLineDefault):
    keys = "test" + EX + JF + "y"
    wanted = """
xa
b
c
d
e
f
y"""


class MultiLineDefault_Type(_MultiLineDefault):
    keys = "test" + EX + "z" + JF + "y"
    wanted = """
xz
y"""


class MultiLineDefault_BS(_MultiLineDefault):
    keys = "test" + EX + BS + JF + "y"
    wanted = """
x
y"""


class _UmlautsBase(_VimTest):
    # SendKeys can't send UTF characters
    skip_if = lambda self: running_on_windows()


class Snippet_With_Umlauts_List(_UmlautsBase):
    snippets = _snip_quote("ü")
    keys = "te" + LS + "2\n"
    wanted = "Expand meü!"


class Snippet_With_Umlauts(_UmlautsBase):
    snippets = _snip_quote("ü")
    keys = "teüst" + EX
    wanted = "Expand meü!"


class Snippet_With_Umlauts_TypeOn(_UmlautsBase):
    snippets = ("ül", "üüüüüßßßß")
    keys = "te ül" + EX + "more text"
    wanted = "te üüüüüßßßßmore text"


class Snippet_With_Umlauts_OverwriteFirst(_UmlautsBase):
    snippets = ("ül", "üü ${1:world} üü ${2:hello}ßß\nüüüü")
    keys = "te ül" + EX + "more text" + JF + JF + "end"
    wanted = "te üü more text üü helloßß\nüüüüend"


class Snippet_With_Umlauts_OverwriteSecond(_UmlautsBase):
    snippets = ("ül", "üü ${1:world} üü ${2:hello}ßß\nüüüü")
    keys = "te ül" + EX + JF + "more text" + JF + "end"
    wanted = "te üü world üü more textßß\nüüüüend"


class Snippet_With_Umlauts_OverwriteNone(_UmlautsBase):
    snippets = ("ül", "üü ${1:world} üü ${2:hello}ßß\nüüüü")
    keys = "te ül" + EX + JF + JF + "end"
    wanted = "te üü world üü helloßß\nüüüüend"


class Snippet_With_Umlauts_Mirrors(_UmlautsBase):
    snippets = ("ül", "üü ${1:world} üü $1")
    keys = "te ül" + EX + "hello"
    wanted = "te üü hello üü hello"


class Snippet_With_Umlauts_Python(_UmlautsBase):
    snippets = ("ül", 'üü ${1:world} üü `!p snip.rv = len(t[1])*"a"`')
    keys = "te ül" + EX + "hüüll"
    wanted = "te üü hüüll üü aaaaa"


class UmlautsBeforeTriggerAndCharsAfter(_UmlautsBase):
    snippets = ("trig", "success")
    keys = "ööuu trig b" + 2 * ARR_L + EX
    wanted = "ööuu success b"


class NoUmlautsBeforeTriggerAndCharsAfter(_UmlautsBase):
    snippets = ("trig", "success")
    keys = "oouu trig b" + 2 * ARR_L + EX
    wanted = "oouu success b"