]> git.madduck.net Git - etc/vim.git/blob - tests/data/cases/preview_multiline_strings.py

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

dec4ef2e548d0095b275035a4e74d36abe36b0c2
[etc/vim.git] / tests / data / cases / preview_multiline_strings.py
1 # flags: --preview
2 """cow
3 say""",
4 call(3, "dogsay", textwrap.dedent("""dove
5     coo""" % "cowabunga"))
6 call(3, "dogsay", textwrap.dedent("""dove
7 coo""" % "cowabunga"))
8 call(3, textwrap.dedent("""cow
9     moo""" % "cowabunga"), "dogsay")
10 call(3, "dogsay", textwrap.dedent("""crow
11     caw""" % "cowabunga"),)
12 call(3, textwrap.dedent("""cat
13     meow""" % "cowabunga"), {"dog", "say"})
14 call(3, {"dog", "say"}, textwrap.dedent("""horse
15     neigh""" % "cowabunga"))
16 call(3, {"dog", "say"}, textwrap.dedent("""pig
17     oink""" % "cowabunga"),)
18 textwrap.dedent("""A one-line triple-quoted string.""")
19 textwrap.dedent("""A two-line triple-quoted string
20 since it goes to the next line.""")
21 textwrap.dedent("""A three-line triple-quoted string
22 that not only goes to the next line
23 but also goes one line beyond.""")
24 textwrap.dedent("""\
25     A triple-quoted string
26     actually leveraging the textwrap.dedent functionality
27     that ends in a trailing newline,
28     representing e.g. file contents.
29 """)
30 path.write_text(textwrap.dedent("""\
31     A triple-quoted string
32     actually leveraging the textwrap.dedent functionality
33     that ends in a trailing newline,
34     representing e.g. file contents.
35 """))
36 path.write_text(textwrap.dedent("""\
37     A triple-quoted string
38     actually leveraging the textwrap.dedent functionality
39     that ends in a trailing newline,
40     representing e.g. {config_filename} file contents.
41 """.format("config_filename", config_filename)))
42 # Another use case
43 data = yaml.load("""\
44 a: 1
45 b: 2
46 """)
47 data = yaml.load("""\
48 a: 1
49 b: 2
50 """,)
51 data = yaml.load(
52     """\
53     a: 1
54     b: 2
55 """
56 )
57
58 MULTILINE = """
59 foo
60 """.replace("\n", "")
61 generated_readme = lambda project_name: """
62 {}
63
64 <Add content here!>
65 """.strip().format(project_name)
66 parser.usage += """
67 Custom extra help summary.
68
69 Extra test:
70 - with
71 - bullets
72 """
73
74
75 def get_stuff(cr, value):
76     # original
77     cr.execute("""
78         SELECT whatever
79           FROM some_table t
80          WHERE id = %s
81     """, [value])
82     return cr.fetchone()
83
84
85 def get_stuff(cr, value):
86     # preferred
87     cr.execute(
88         """
89         SELECT whatever
90           FROM some_table t
91          WHERE id = %s
92         """,
93         [value],
94     )
95     return cr.fetchone()
96
97
98 call(arg1, arg2, """
99 short
100 """, arg3=True)
101 test_vectors = [
102     "one-liner\n",
103     "two\nliner\n",
104     """expressed
105 as a three line
106 mulitline string""",
107 ]
108
109 _wat = re.compile(
110     r"""
111     regex
112     """,
113     re.MULTILINE | re.VERBOSE,
114 )
115 dis_c_instance_method = """\
116 %3d           0 LOAD_FAST                1 (x)
117               2 LOAD_CONST               1 (1)
118               4 COMPARE_OP               2 (==)
119               6 LOAD_FAST                0 (self)
120               8 STORE_ATTR               0 (x)
121              10 LOAD_CONST               0 (None)
122              12 RETURN_VALUE
123 """ % (_C.__init__.__code__.co_firstlineno + 1,)
124 path.write_text(textwrap.dedent("""\
125     A triple-quoted string
126     actually {verb} the textwrap.dedent functionality
127     that ends in a trailing newline,
128     representing e.g. {file_type} file contents.
129 """.format(verb="using", file_type="test")))
130 {"""cow
131 moos"""}
132 ["""cow
133 moos"""]
134 ["""cow
135 moos""", """dog
136 woofs
137 and
138 barks"""]
139 def dastardly_default_value(
140     cow: String = json.loads("""this
141 is
142 quite
143 the
144 dastadardly
145 value!"""),
146     **kwargs,
147 ):
148     pass
149
150 print(f"""
151     This {animal}
152     moos and barks
153 {animal} say
154 """)
155 msg = f"""The arguments {bad_arguments} were passed in.
156 Please use `--build-option` instead,
157 `--global-option` is reserved to flags like `--verbose` or `--quiet`.
158 """
159
160 # output
161 """cow
162 say""",
163 call(
164     3,
165     "dogsay",
166     textwrap.dedent("""dove
167     coo""" % "cowabunga"),
168 )
169 call(
170     3,
171     "dogsay",
172     textwrap.dedent("""dove
173 coo""" % "cowabunga"),
174 )
175 call(
176     3,
177     textwrap.dedent("""cow
178     moo""" % "cowabunga"),
179     "dogsay",
180 )
181 call(
182     3,
183     "dogsay",
184     textwrap.dedent("""crow
185     caw""" % "cowabunga"),
186 )
187 call(
188     3,
189     textwrap.dedent("""cat
190     meow""" % "cowabunga"),
191     {"dog", "say"},
192 )
193 call(
194     3,
195     {"dog", "say"},
196     textwrap.dedent("""horse
197     neigh""" % "cowabunga"),
198 )
199 call(
200     3,
201     {"dog", "say"},
202     textwrap.dedent("""pig
203     oink""" % "cowabunga"),
204 )
205 textwrap.dedent("""A one-line triple-quoted string.""")
206 textwrap.dedent("""A two-line triple-quoted string
207 since it goes to the next line.""")
208 textwrap.dedent("""A three-line triple-quoted string
209 that not only goes to the next line
210 but also goes one line beyond.""")
211 textwrap.dedent("""\
212     A triple-quoted string
213     actually leveraging the textwrap.dedent functionality
214     that ends in a trailing newline,
215     representing e.g. file contents.
216 """)
217 path.write_text(textwrap.dedent("""\
218     A triple-quoted string
219     actually leveraging the textwrap.dedent functionality
220     that ends in a trailing newline,
221     representing e.g. file contents.
222 """))
223 path.write_text(textwrap.dedent("""\
224     A triple-quoted string
225     actually leveraging the textwrap.dedent functionality
226     that ends in a trailing newline,
227     representing e.g. {config_filename} file contents.
228 """.format("config_filename", config_filename)))
229 # Another use case
230 data = yaml.load("""\
231 a: 1
232 b: 2
233 """)
234 data = yaml.load(
235     """\
236 a: 1
237 b: 2
238 """,
239 )
240 data = yaml.load("""\
241     a: 1
242     b: 2
243 """)
244
245 MULTILINE = """
246 foo
247 """.replace("\n", "")
248 generated_readme = lambda project_name: """
249 {}
250
251 <Add content here!>
252 """.strip().format(project_name)
253 parser.usage += """
254 Custom extra help summary.
255
256 Extra test:
257 - with
258 - bullets
259 """
260
261
262 def get_stuff(cr, value):
263     # original
264     cr.execute(
265         """
266         SELECT whatever
267           FROM some_table t
268          WHERE id = %s
269     """,
270         [value],
271     )
272     return cr.fetchone()
273
274
275 def get_stuff(cr, value):
276     # preferred
277     cr.execute(
278         """
279         SELECT whatever
280           FROM some_table t
281          WHERE id = %s
282         """,
283         [value],
284     )
285     return cr.fetchone()
286
287
288 call(
289     arg1,
290     arg2,
291     """
292 short
293 """,
294     arg3=True,
295 )
296 test_vectors = [
297     "one-liner\n",
298     "two\nliner\n",
299     """expressed
300 as a three line
301 mulitline string""",
302 ]
303
304 _wat = re.compile(
305     r"""
306     regex
307     """,
308     re.MULTILINE | re.VERBOSE,
309 )
310 dis_c_instance_method = """\
311 %3d           0 LOAD_FAST                1 (x)
312               2 LOAD_CONST               1 (1)
313               4 COMPARE_OP               2 (==)
314               6 LOAD_FAST                0 (self)
315               8 STORE_ATTR               0 (x)
316              10 LOAD_CONST               0 (None)
317              12 RETURN_VALUE
318 """ % (_C.__init__.__code__.co_firstlineno + 1,)
319 path.write_text(textwrap.dedent("""\
320     A triple-quoted string
321     actually {verb} the textwrap.dedent functionality
322     that ends in a trailing newline,
323     representing e.g. {file_type} file contents.
324 """.format(verb="using", file_type="test")))
325 {"""cow
326 moos"""}
327 ["""cow
328 moos"""]
329 [
330     """cow
331 moos""",
332     """dog
333 woofs
334 and
335 barks""",
336 ]
337
338
339 def dastardly_default_value(
340     cow: String = json.loads("""this
341 is
342 quite
343 the
344 dastadardly
345 value!"""),
346     **kwargs,
347 ):
348     pass
349
350
351 print(f"""
352     This {animal}
353     moos and barks
354 {animal} say
355 """)
356 msg = f"""The arguments {bad_arguments} were passed in.
357 Please use `--build-option` instead,
358 `--global-option` is reserved to flags like `--verbose` or `--quiet`.
359 """