Skip to content

Commit af89564

Browse files
authored
[mypyc] Add irbuild test case for cast(i64, ...) (python#14493)
This tests already supported functionality to detect regressions.
1 parent eea917e commit af89564

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

mypyc/test-data/irbuild-i64.test

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1730,3 +1730,44 @@ L0:
17301730
def f5():
17311731
L0:
17321732
return 4
1733+
1734+
[case testI64Cast]
1735+
from typing import cast
1736+
from mypy_extensions import i64
1737+
1738+
def cast_object(o: object) -> i64:
1739+
return cast(i64, o)
1740+
1741+
def cast_int(x: int) -> i64:
1742+
return cast(i64, x)
1743+
[out]
1744+
def cast_object(o):
1745+
o :: object
1746+
r0 :: int64
1747+
L0:
1748+
r0 = unbox(int64, o)
1749+
return r0
1750+
def cast_int(x):
1751+
x :: int
1752+
r0 :: native_int
1753+
r1 :: bit
1754+
r2, r3 :: int64
1755+
r4 :: ptr
1756+
r5 :: c_ptr
1757+
r6 :: int64
1758+
L0:
1759+
r0 = x & 1
1760+
r1 = r0 == 0
1761+
if r1 goto L1 else goto L2 :: bool
1762+
L1:
1763+
r2 = x >> 1
1764+
r3 = r2
1765+
goto L3
1766+
L2:
1767+
r4 = x ^ 1
1768+
r5 = r4
1769+
r6 = CPyLong_AsInt64(r5)
1770+
r3 = r6
1771+
keep_alive x
1772+
L3:
1773+
return r3

0 commit comments

Comments
 (0)