]> git.madduck.net Git - etc/vim.git/blob - tests/expression.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:

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