Skip to content

Commit 62ce243

Browse files
committed
Add test for FOR_ITER_RANGE
1 parent df61257 commit 62ce243

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

Lib/test/test_capi/test_misc.py

+16
Original file line numberDiff line numberDiff line change
@@ -2517,6 +2517,22 @@ def testfunc(x):
25172517
uops = {opname for opname, _ in ex}
25182518
self.assertIn("UNPACK_SEQUENCE", uops)
25192519

2520+
def test_for_iter(self):
2521+
def testfunc(x):
2522+
for i in range(x):
2523+
i += 1
2524+
2525+
opt = _testinternalcapi.get_uop_optimizer()
2526+
2527+
with temporary_optimizer(opt):
2528+
testfunc(100)
2529+
2530+
ex = get_first_executor(testfunc.__code__)
2531+
self.assertIsNotNone(ex)
2532+
print(list(ex))
2533+
uops = {opname for opname, _ in ex}
2534+
self.assertIn("FOR_ITER_RANGE", uops)
2535+
25202536

25212537
if __name__ == "__main__":
25222538
unittest.main()

0 commit comments

Comments
 (0)