Skip to content

Commit 0d51ead

Browse files
committed
add ir test
1 parent 1975746 commit 0d51ead

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

mypyc/test-data/irbuild-isinstance.test

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,3 +189,31 @@ def is_tuple(x):
189189
L0:
190190
r0 = PyTuple_Check(x)
191191
return r0
192+
193+
[case testTupleOfPrimitives]
194+
from typing import Any
195+
196+
def is_instance(x: Any) -> bool:
197+
return isinstance(x, (str, int, bytes))
198+
199+
[out]
200+
def is_instance(x):
201+
x :: object
202+
r0, r1, r2 :: bit
203+
r3 :: bool
204+
L0:
205+
r0 = PyUnicode_Check(x)
206+
if r0 goto L3 else goto L1 :: bool
207+
L1:
208+
r1 = PyLong_Check(x)
209+
if r1 goto L3 else goto L2 :: bool
210+
L2:
211+
r2 = PyBytes_Check(x)
212+
if r2 goto L3 else goto L4 :: bool
213+
L3:
214+
r3 = 1
215+
goto L5
216+
L4:
217+
r3 = 0
218+
L5:
219+
return r3

0 commit comments

Comments
 (0)