]> git.madduck.net Git - etc/vim.git/blob - tests/expression.diff

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:

Add support for pyi files (#210)
[etc/vim.git] / tests / expression.diff
1 --- <stdin>  (original)
2 +++ <stdin>  (formatted)
3 @@ -1,8 +1,8 @@
4  ...
5 -'some_string'
6 -b'\\xa3'
7 +"some_string"
8 +b"\\xa3"
9  Name
10  None
11  True
12  False
13  1
14 @@ -29,62 +29,82 @@
15  ~great
16  +value
17  -1
18  ~int and not v1 ^ 123 + v2 | True
19  (~int) and (not ((v1 ^ (123 + v2)) | True))
20 -flags & ~ select.EPOLLIN and waiters.write_task is not None
21 +flags & ~select.EPOLLIN and waiters.write_task is not None
22  lambda arg: None
23  lambda a=True: a
24  lambda a, b, c=True: a
25 -lambda a, b, c=True, *, d=(1 << v2), e='str': a
26 -lambda a, b, c=True, *vararg, d=(v1 << 2), e='str', **kwargs: a + b
27 +lambda a, b, c=True, *, d=(1 << v2), e="str": a
28 +lambda a, b, c=True, *vararg, d=(v1 << 2), e="str", **kwargs: a + b
29  manylambdas = lambda x=lambda y=lambda z=1: z: y(): x()
30 -foo = (lambda port_id, ignore_missing: {"port1": port1_resource, "port2": port2_resource}[port_id])
31 +foo = lambda port_id, ignore_missing: {
32 +    "port1": port1_resource, "port2": port2_resource
33 +}[port_id]
34  1 if True else 2
35  str or None if True else str or bytes or None
36  (str or None) if True else (str or bytes or None)
37  str or None if (1 if True else 2) else str or bytes or None
38  (str or None) if (1 if True else 2) else (str or bytes or None)
39 -((super_long_variable_name or None) if (1 if super_long_test_name else 2) else (str or bytes or None))
40 -{'2.7': dead, '3.7': (long_live or die_hard)}
41 -{'2.7': dead, '3.7': (long_live or die_hard), **{'3.6': verygood}}
42 +(
43 +    (super_long_variable_name or None)
44 +    if (1 if super_long_test_name else 2)
45 +    else (str or bytes or None)
46 +)
47 +{"2.7": dead, "3.7": (long_live or die_hard)}
48 +{"2.7": dead, "3.7": (long_live or die_hard), **{"3.6": verygood}}
49  {**a, **b, **c}
50 -{'2.7', '3.6', '3.7', '3.8', '3.9', ('4.0' if gilectomy else '3.10')}
51 -({'a': 'b'}, (True or False), (+value), 'string', b'bytes') or None
52 +{"2.7", "3.6", "3.7", "3.8", "3.9", ("4.0" if gilectomy else "3.10")}
53 +({"a": "b"}, (True or False), (+value), "string", b"bytes") or None
54  ()
55  (1,)
56  (1, 2)
57  (1, 2, 3)
58  []
59  [1, 2, 3, 4, 5, 6, 7, 8, 9, (10 or A), (11 or B), (12 or C)]
60 -[1, 2, 3,]
61 +[1, 2, 3]
62  [*a]
63  [*range(10)]
64 -[*a, 4, 5,]
65 -[4, *a, 5,]
66 -[this_is_a_very_long_variable_which_will_force_a_delimiter_split, element, another, *more]
67 +[*a, 4, 5]
68 +[4, *a, 5]
69 +[
70 +    this_is_a_very_long_variable_which_will_force_a_delimiter_split,
71 +    element,
72 +    another,
73 +    *more,
74 +]
75  {i for i in (1, 2, 3)}
76  {(i ** 2) for i in (1, 2, 3)}
77 -{(i ** 2) for i, _ in ((1, 'a'), (2, 'b'), (3, 'c'))}
78 +{(i ** 2) for i, _ in ((1, "a"), (2, "b"), (3, "c"))}
79  {((i ** 2) + j) for i in (1, 2, 3) for j in (1, 2, 3)}
80  [i for i in (1, 2, 3)]
81  [(i ** 2) for i in (1, 2, 3)]
82 -[(i ** 2) for i, _ in ((1, 'a'), (2, 'b'), (3, 'c'))]
83 +[(i ** 2) for i, _ in ((1, "a"), (2, "b"), (3, "c"))]
84  [((i ** 2) + j) for i in (1, 2, 3) for j in (1, 2, 3)]
85  {i: 0 for i in (1, 2, 3)}
86 -{i: j for i, j in ((1, 'a'), (2, 'b'), (3, 'c'))}
87 +{i: j for i, j in ((1, "a"), (2, "b"), (3, "c"))}
88  {a: b * 2 for a, b in dictionary.items()}
89  {a: b * -2 for a, b in dictionary.items()}
90 -{k: v for k, v in this_is_a_very_long_variable_which_will_cause_a_trailing_comma_which_breaks_the_comprehension}
91 +{
92 +    k: v
93 +    for k, v in this_is_a_very_long_variable_which_will_cause_a_trailing_comma_which_breaks_the_comprehension
94 +}
95  Python3 > Python2 > COBOL
96  Life is Life
97  call()
98  call(arg)
99 -call(kwarg='hey')
100 -call(arg, kwarg='hey')
101 -call(arg, another, kwarg='hey', **kwargs)
102 -call(this_is_a_very_long_variable_which_will_force_a_delimiter_split, arg, another, kwarg='hey', **kwargs)  # note: no trailing comma pre-3.6
103 +call(kwarg="hey")
104 +call(arg, kwarg="hey")
105 +call(arg, another, kwarg="hey", **kwargs)
106 +call(
107 +    this_is_a_very_long_variable_which_will_force_a_delimiter_split,
108 +    arg,
109 +    another,
110 +    kwarg="hey",
111 +    **kwargs
112 +)  # note: no trailing comma pre-3.6
113  call(*gidgets[:2])
114  call(a, *gidgets[:2])
115  call(**self.screen_kwargs)
116  call(b, **self.screen_kwargs)
117  lukasz.langa.pl
118 @@ -93,11 +113,11 @@
119  1.0 .real
120  ....__class__
121  list[str]
122  dict[str, int]
123  tuple[str, ...]
124 -tuple[str, int, float, dict[str, int],]
125 +tuple[str, int, float, dict[str, int]]
126  very_long_variable_name_filters: t.List[
127      t.Tuple[str, t.Union[str, t.List[t.Optional[str]]]],
128  ]
129  slice[0]
130  slice[0:1]
131 @@ -124,103 +144,138 @@
132  numpy[-(c + 1) :, d]
133  numpy[:, l[-2]]
134  numpy[:, ::-1]
135  numpy[np.newaxis, :]
136  (str or None) if (sys.version_info[0] > (3,)) else (str or bytes or None)
137 -{'2.7': dead, '3.7': long_live or die_hard}
138 -{'2.7', '3.6', '3.7', '3.8', '3.9', '4.0' if gilectomy else '3.10'}
139 +{"2.7": dead, "3.7": long_live or die_hard}
140 +{"2.7", "3.6", "3.7", "3.8", "3.9", "4.0" if gilectomy else "3.10"}
141  [1, 2, 3, 4, 5, 6, 7, 8, 9, 10 or A, 11 or B, 12 or C]
142  (SomeName)
143  SomeName
144  (Good, Bad, Ugly)
145  (i for i in (1, 2, 3))
146  ((i ** 2) for i in (1, 2, 3))
147 -((i ** 2) for i, _ in ((1, 'a'), (2, 'b'), (3, 'c')))
148 +((i ** 2) for i, _ in ((1, "a"), (2, "b"), (3, "c")))
149  (((i ** 2) + j) for i in (1, 2, 3) for j in (1, 2, 3))
150  (*starred)
151 -{"id": "1","type": "type","started_at": now(),"ended_at": now() + timedelta(days=10),"priority": 1,"import_session_id": 1,**kwargs}
152 +{
153 +    "id": "1",
154 +    "type": "type",
155 +    "started_at": now(),
156 +    "ended_at": now() + timedelta(days=10),
157 +    "priority": 1,
158 +    "import_session_id": 1,
159 +    **kwargs,
160 +}
161  a = (1,)
162 -b = 1,
163 +b = (1,)
164  c = 1
165  d = (1,) + a + (2,)
166  e = (1,).count(1)
167 -what_is_up_with_those_new_coord_names = (coord_names + set(vars_to_create)) + set(vars_to_remove)
168 -what_is_up_with_those_new_coord_names = (coord_names | set(vars_to_create)) - set(vars_to_remove)
169 -result = session.query(models.Customer.id).filter(models.Customer.account_id == account_id, models.Customer.email == email_address).order_by(models.Customer.id.asc(),).all()
170 +what_is_up_with_those_new_coord_names = (
171 +    (coord_names + set(vars_to_create)) + set(vars_to_remove)
172 +)
173 +what_is_up_with_those_new_coord_names = (
174 +    (coord_names | set(vars_to_create)) - set(vars_to_remove)
175 +)
176 +result = session.query(models.Customer.id).filter(
177 +    models.Customer.account_id == account_id, models.Customer.email == email_address
178 +).order_by(models.Customer.id.asc()).all()
179  Ø = set()
180  authors.łukasz.say_thanks()
181  mapping = {
182      A: 0.25 * (10.0 / 12),
183      B: 0.1 * (10.0 / 12),
184      C: 0.1 * (10.0 / 12),
185      D: 0.1 * (10.0 / 12),
186  }
187  
188 +
189  def gen():
190      yield from outside_of_generator
191      a = (yield)
192  
193 +
194  async def f():
195      await some.complicated[0].call(with_args=(True or (1 is not 1)))
196 -print(* [] or [1])
197 +
198 +
199 +print(*[] or [1])
200  print(**{1: 3} if False else {x: x for x in range(3)})
201 -print(* lambda x: x)
202 -assert(not Test),("Short message")
203 -assert this is ComplexTest and not requirements.fit_in_a_single_line(force=False), "Short message"
204 -assert(((parens is TooMany)))
205 -for x, in (1,), (2,), (3,): ...
206 -for y in (): ...
207 -for z in (i for i in (1, 2, 3)): ...
208 -for i in (call()): ...
209 -for j in (1 + (2 + 3)): ...
210 -while(this and that): ...
211 -if (
212 -    threading.current_thread() != threading.main_thread() and
213 -    threading.current_thread() != threading.main_thread() or
214 -    signal.getsignal(signal.SIGINT) != signal.default_int_handler
215 -):
216 -    return True
217 -if (
218 -    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa |
219 -    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
220 -):
221 -    return True
222 -if (
223 -    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa &
224 -    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
225 -):
226 -    return True
227 -if (
228 -    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +
229 -    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
230 -):
231 -    return True
232 -if (
233 -    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa -
234 -    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
235 -):
236 -    return True
237 -if (
238 -    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *
239 -    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
240 -):
241 -    return True
242 -if (
243 -    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa /
244 -    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
245 -):
246 -    return True
247 -if (
248 -    ~ aaaa.a + aaaa.b - aaaa.c * aaaa.d / aaaa.e | aaaa.f & aaaa.g % aaaa.h ^ aaaa.i << aaaa.k >> aaaa.l ** aaaa.m // aaaa.n
249 -):
250 -    return True
251 -if (
252 -    ~ aaaaaaaa.a + aaaaaaaa.b - aaaaaaaa.c @ aaaaaaaa.d / aaaaaaaa.e | aaaaaaaa.f & aaaaaaaa.g % aaaaaaaa.h ^ aaaaaaaa.i << aaaaaaaa.k >> aaaaaaaa.l ** aaaaaaaa.m // aaaaaaaa.n
253 -):
254 -    return True
255 -if (
256 -    ~ aaaaaaaaaaaaaaaa.a + aaaaaaaaaaaaaaaa.b - aaaaaaaaaaaaaaaa.c * aaaaaaaaaaaaaaaa.d @ aaaaaaaaaaaaaaaa.e | aaaaaaaaaaaaaaaa.f & aaaaaaaaaaaaaaaa.g % aaaaaaaaaaaaaaaa.h ^ aaaaaaaaaaaaaaaa.i << aaaaaaaaaaaaaaaa.k >> aaaaaaaaaaaaaaaa.l ** aaaaaaaaaaaaaaaa.m // aaaaaaaaaaaaaaaa.n
257 +print(*lambda x: x)
258 +assert not Test, "Short message"
259 +assert (
260 +    this is ComplexTest and not requirements.fit_in_a_single_line(force=False)
261 +), "Short message"
262 +assert parens is TooMany
263 +for (x,) in (1,), (2,), (3,):
264 +    ...
265 +for y in ():
266 +    ...
267 +for z in (i for i in (1, 2, 3)):
268 +    ...
269 +for i in call():
270 +    ...
271 +for j in 1 + (2 + 3):
272 +    ...
273 +while this and that:
274 +    ...
275 +if (
276 +    threading.current_thread() != threading.main_thread()
277 +    and threading.current_thread() != threading.main_thread()
278 +    or signal.getsignal(signal.SIGINT) != signal.default_int_handler
279 +):
280 +    return True
281 +if (
282 +    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
283 +    | aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
284 +):
285 +    return True
286 +if (
287 +    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
288 +    & aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
289 +):
290 +    return True
291 +if (
292 +    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
293 +    + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
294 +):
295 +    return True
296 +if (
297 +    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
298 +    - aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
299 +):
300 +    return True
301 +if (
302 +    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
303 +    * aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
304 +):
305 +    return True
306 +if (
307 +    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
308 +    / aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
309 +):
310 +    return True
311 +if (
312 +    ~aaaa.a + aaaa.b - aaaa.c * aaaa.d / aaaa.e
313 +    | aaaa.f & aaaa.g % aaaa.h ^ aaaa.i << aaaa.k >> aaaa.l ** aaaa.m // aaaa.n
314 +):
315 +    return True
316 +if (
317 +    ~aaaaaaaa.a + aaaaaaaa.b - aaaaaaaa.c @ aaaaaaaa.d / aaaaaaaa.e
318 +    | aaaaaaaa.f & aaaaaaaa.g % aaaaaaaa.h
319 +    ^ aaaaaaaa.i << aaaaaaaa.k >> aaaaaaaa.l ** aaaaaaaa.m // aaaaaaaa.n
320 +):
321 +    return True
322 +if (
323 +    ~aaaaaaaaaaaaaaaa.a
324 +    + aaaaaaaaaaaaaaaa.b
325 +    - aaaaaaaaaaaaaaaa.c * aaaaaaaaaaaaaaaa.d @ aaaaaaaaaaaaaaaa.e
326 +    | aaaaaaaaaaaaaaaa.f & aaaaaaaaaaaaaaaa.g % aaaaaaaaaaaaaaaa.h
327 +    ^ aaaaaaaaaaaaaaaa.i
328 +    << aaaaaaaaaaaaaaaa.k
329 +    >> aaaaaaaaaaaaaaaa.l ** aaaaaaaaaaaaaaaa.m // aaaaaaaaaaaaaaaa.n
330  ):
331      return True
332  last_call()
333  # standalone comment at ENDMARKER