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