(self)
| 242 | self.check_lnotab(g) |
| 243 | |
| 244 | def test_constant_folding_small_int(self): |
| 245 | tests = [ |
| 246 | ('(0, )[0]', 0), |
| 247 | ('(1 + 2, )[0]', 3), |
| 248 | ('(2 + 2 * 2, )[0]', 6), |
| 249 | ('(1, (1 + 2 + 3, ))[1][0]', 6), |
| 250 | ('1 + 2', 3), |
| 251 | ('2 + 2 * 2 // 2 - 2', 2), |
| 252 | ('(255, )[0]', 255), |
| 253 | ('(256, )[0]', None), |
| 254 | ('(1000, )[0]', None), |
| 255 | ('(1 - 2, )[0]', None), |
| 256 | ('255 + 0', 255), |
| 257 | ('255 + 1', None), |
| 258 | ('-1', None), |
| 259 | ('--1', 1), |
| 260 | ('--255', 255), |
| 261 | ('--256', None), |
| 262 | ('~1', None), |
| 263 | ('~~1', 1), |
| 264 | ('~~255', 255), |
| 265 | ('~~256', None), |
| 266 | ('++255', 255), |
| 267 | ('++256', None), |
| 268 | ] |
| 269 | for expr, oparg in tests: |
| 270 | with self.subTest(expr=expr, oparg=oparg): |
| 271 | code = compile(expr, '', 'single') |
| 272 | if oparg is not None: |
| 273 | self.assertInBytecode(code, 'LOAD_SMALL_INT', oparg) |
| 274 | else: |
| 275 | self.assertNotInBytecode(code, 'LOAD_SMALL_INT') |
| 276 | self.check_lnotab(code) |
| 277 | |
| 278 | def test_constant_folding_unaryop(self): |
| 279 | intrinsic_positive = 5 |
nothing calls this directly
no test coverage detected