Skip to content

Commit 9d26a11

Browse files
Update irbuild-weakref.test
1 parent f34e53c commit 9d26a11

File tree

1 file changed

+58
-2
lines changed

1 file changed

+58
-2
lines changed

mypyc/test-data/irbuild-weakref.test

Lines changed: 58 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,32 @@
11
[case testWeakrefRef]
2+
import weakref
3+
from typing import Any, Callable
4+
def f(x: object) -> object:
5+
return weakref.ref(x)
6+
7+
[out]
8+
def f(x):
9+
x :: object
10+
r0 :: object
11+
L0:
12+
r0 = PyWeakref_NewRef(x, NULL)
13+
return r0
14+
15+
[case testWeakrefRefCallback]
16+
import weakref
17+
from typing import Any, Callable
18+
def f(x: object, cb: Callable[[object], Any]) -> object:
19+
return weakref.ref(x, cb)
20+
21+
[out]
22+
def f(x, cb):
23+
x, cb :: object
24+
r0 :: object
25+
L0:
26+
r0 = PyWeakref_NewRef(x, cb)
27+
return r0
28+
29+
[case testFromWeakrefRef]
230
from typing import Any, Callable
331
from weakref import ref
432
def f(x: object) -> object:
@@ -12,7 +40,7 @@ L0:
1240
r0 = PyWeakref_NewRef(x, NULL)
1341
return r0
1442

15-
[case testWeakrefRefCallback]
43+
[case testFromWeakrefRefCallback]
1644
from typing import Any, Callable
1745
from weakref import ref
1846
def f(x: object, cb: Callable[[object], Any]) -> object:
@@ -27,6 +55,34 @@ L0:
2755
return r0
2856

2957
[case testWeakrefProxy]
58+
import weakref
59+
from typing import Any, Callable
60+
def f(x: object) -> object:
61+
return weakref.proxy(x)
62+
63+
[out]
64+
def f(x):
65+
x :: object
66+
r0 :: object
67+
L0:
68+
r0 = PyWeakref_NewProxy(x, NULL)
69+
return r0
70+
71+
[case testWeakrefProxyCallback]
72+
import weakref
73+
from typing import Any, Callable
74+
def f(x: object, cb: Callable[[object], Any]) -> object:
75+
return weakref.proxy(x, cb)
76+
77+
[out]
78+
def f(x, cb):
79+
x, cb :: object
80+
r0 :: object
81+
L0:
82+
r0 = PyWeakref_NewProxy(x, cb)
83+
return r0
84+
85+
[case testFromWeakrefProxy]
3086
from typing import Any, Callable
3187
from weakref import proxy
3288
def f(x: object) -> object:
@@ -40,7 +96,7 @@ L0:
4096
r0 = PyWeakref_NewProxy(x, NULL)
4197
return r0
4298

43-
[case testWeakrefProxyCallback]
99+
[case testFromWeakrefProxyCallback]
44100
from typing import Any, Callable
45101
from weakref import proxy
46102
def f(x: object, cb: Callable[[object], Any]) -> object:

0 commit comments

Comments
 (0)