]> 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:

Fix tests after introducing --check
[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 Python3 > Python2 > COBOL
67 Life is Life
68 call()
69 call(arg)
70 call(kwarg='hey')
71 call(arg, kwarg='hey')
72 call(arg, another, kwarg='hey', **kwargs)
73 lukasz.langa.pl
74 call.me(maybe)
75 1 .real
76 1.0 .real
77 ....__class__
78 list[str]
79 dict[str, int]
80 tuple[str, ...]
81 tuple[str, int, float, dict[str, int]]
82 slice[0]
83 slice[0:1]
84 slice[0:1:2]
85 slice[:]
86 slice[:-1]
87 slice[1:]
88 slice[::-1]
89 (str or None) if (sys.version_info[0] > (3,)) else (str or bytes or None)
90 f'f-string without formatted values is just a string'
91 f'{{NOT a formatted value}}'
92 f'some f-string with {a} {few():.2f} {formatted.values!r}'
93 f"{f'{nested} inner'} outer"
94 f'space between opening braces: { {a for a in (1, 2, 3)}}'
95 {'2.7': dead, '3.7': long_live or die_hard}
96 {'2.7', '3.6', '3.7', '3.8', '3.9', '4.0' if gilectomy else '3.10'}
97 [1, 2, 3, 4, 5, 6, 7, 8, 9, 10 or A, 11 or B, 12 or C]
98 (SomeName)
99 SomeName
100 (Good, Bad, Ugly)
101 (i for i in (1, 2, 3))
102 ((i ** 2) for i in (1, 2, 3))
103 ((i ** 2) for i, _ in ((1, 'a'), (2, 'b'), (3, 'c')))
104 (((i ** 2) + j) for i in (1, 2, 3) for j in (1, 2, 3))
105 (*starred)
106 a = (1,)
107 b = 1,
108 c = 1
109 d = (1,) + a + (2,)
110 what_is_up_with_those_new_coord_names = (coord_names + set(vars_to_create)) + set(vars_to_remove)
111 what_is_up_with_those_new_coord_names = (coord_names | set(vars_to_create)) - set(vars_to_remove)
112
113
114 def gen():
115     yield from outside_of_generator
116     a = (yield)
117
118
119 async def f():
120     await some.complicated[0].call(with_args=(True or (1 is not 1)))
121
122
123 # output
124
125
126 ...
127 'some_string'
128 b'\\xa3'
129 Name
130 None
131 True
132 False
133 1
134 1.0
135 1j
136 True or False
137 True or False or None
138 True and False
139 True and False and None
140 (Name1 and Name2) or Name3
141 Name1 and Name2 or Name3
142 Name1 or (Name2 and Name3)
143 Name1 or Name2 and Name3
144 (Name1 and Name2) or (Name3 and Name4)
145 Name1 and Name2 or Name3 and Name4
146 Name1 or (Name2 and Name3) or Name4
147 Name1 or Name2 and Name3 or Name4
148 v1 << 2
149 1 >> v2
150 1 % finished
151 1 + v2 - v3 * 4 ^ 5 ** v6 / 7 // 8
152 ((1 + v2) - (v3 * 4)) ^ (((5 ** v6) / 7) // 8)
153 not great
154 ~great
155 +value
156 -1
157 ~int and not v1 ^ 123 + v2 | True
158 (~int) and (not ((v1 ^ (123 + v2)) | True))
159 flags & ~select.EPOLLIN and waiters.write_task is not None
160 lambda arg: None
161 lambda a=True: a
162 lambda a, b, c=True: a
163 lambda a, b, c=True, *, d=(1 << v2), e='str': a
164 lambda a, b, c=True, *vararg, d=(v1 << 2), e='str', **kwargs: a + b
165 1 if True else 2
166 str or None if True else str or bytes or None
167 (str or None) if True else (str or bytes or None)
168 str or None if (1 if True else 2) else str or bytes or None
169 (str or None) if (1 if True else 2) else (str or bytes or None)
170 {'2.7': dead, '3.7': (long_live or die_hard)}
171 {'2.7': dead, '3.7': (long_live or die_hard), **{'3.6': verygood}}
172 {**a, **b, **c}
173 {'2.7', '3.6', '3.7', '3.8', '3.9', ('4.0' if gilectomy else '3.10')}
174 ({'a': 'b'}, (True or False), (+value), 'string', b'bytes') or None
175 ()
176 (1,)
177 (1, 2)
178 (1, 2, 3)
179 []
180 [1, 2, 3, 4, 5, 6, 7, 8, 9, (10 or A), (11 or B), (12 or C)]
181 {i for i in (1, 2, 3)}
182 {(i ** 2) for i in (1, 2, 3)}
183 {(i ** 2) for i, _ in ((1, 'a'), (2, 'b'), (3, 'c'))}
184 {((i ** 2) + j) for i in (1, 2, 3) for j in (1, 2, 3)}
185 [i for i in (1, 2, 3)]
186 [(i ** 2) for i in (1, 2, 3)]
187 [(i ** 2) for i, _ in ((1, 'a'), (2, 'b'), (3, 'c'))]
188 [((i ** 2) + j) for i in (1, 2, 3) for j in (1, 2, 3)]
189 {i: 0 for i in (1, 2, 3)}
190 {i: j for i, j in ((1, 'a'), (2, 'b'), (3, 'c'))}
191 Python3 > Python2 > COBOL
192 Life is Life
193 call()
194 call(arg)
195 call(kwarg='hey')
196 call(arg, kwarg='hey')
197 call(arg, another, kwarg='hey', **kwargs)
198 lukasz.langa.pl
199 call.me(maybe)
200 1 .real
201 1.0 .real
202 ....__class__
203 list[str]
204 dict[str, int]
205 tuple[str, ...]
206 tuple[str, int, float, dict[str, int]]
207 slice[0]
208 slice[0:1]
209 slice[0:1:2]
210 slice[:]
211 slice[:-1]
212 slice[1:]
213 slice[::-1]
214 (str or None) if (sys.version_info[0] > (3,)) else (str or bytes or None)
215 f'f-string without formatted values is just a string'
216 f'{{NOT a formatted value}}'
217 f'some f-string with {a} {few():.2f} {formatted.values!r}'
218 f"{f'{nested} inner'} outer"
219 f'space between opening braces: { {a for a in (1, 2, 3)}}'
220 {'2.7': dead, '3.7': long_live or die_hard}
221 {'2.7', '3.6', '3.7', '3.8', '3.9', '4.0' if gilectomy else '3.10'}
222 [1, 2, 3, 4, 5, 6, 7, 8, 9, 10 or A, 11 or B, 12 or C]
223 (SomeName)
224 SomeName
225 (Good, Bad, Ugly)
226 (i for i in (1, 2, 3))
227 ((i ** 2) for i in (1, 2, 3))
228 ((i ** 2) for i, _ in ((1, 'a'), (2, 'b'), (3, 'c')))
229 (((i ** 2) + j) for i in (1, 2, 3) for j in (1, 2, 3))
230 (*starred)
231 a = (1,)
232 b = 1,
233 c = 1
234 d = (1,) + a + (2,)
235 what_is_up_with_those_new_coord_names = (coord_names + set(vars_to_create)) + set(
236     vars_to_remove
237 )
238 what_is_up_with_those_new_coord_names = (coord_names | set(vars_to_create)) - set(
239     vars_to_remove
240 )
241
242
243 def gen():
244     yield from outside_of_generator
245
246     a = (yield)
247
248
249 async def f():
250     await some.complicated[0].call(with_args=(True or (1 is not 1)))