Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Update irbuild tests
  • Loading branch information
JukkaL committed Jul 8, 2025
commit 5c459113d1ee0e555a01d65d0aa130ac46afb1a5
31 changes: 9 additions & 22 deletions mypyc/test-data/irbuild-dict.test
Original file line number Diff line number Diff line change
Expand Up @@ -399,12 +399,9 @@ def typeddict(d):
r9, k :: str
v :: object
r10 :: str
r11 :: i32
r12 :: bit
r13 :: object
r14, r15, r16 :: bit
r11 :: bool
name :: object
r17, r18 :: bit
r12, r13 :: bit
L0:
r0 = 0
r1 = PyDict_Size(d)
Expand All @@ -415,35 +412,25 @@ L1:
r5 = r4[1]
r0 = r5
r6 = r4[0]
if r6 goto L2 else goto L9 :: bool
if r6 goto L2 else goto L6 :: bool
L2:
r7 = r4[2]
r8 = r4[3]
r9 = cast(str, r7)
k = r9
v = r8
r10 = 'name'
r11 = PyUnicode_Compare(k, r10)
r12 = r11 == -1
if r12 goto L3 else goto L5 :: bool
r11 = CPyStr_Equal(k, r10)
if r11 goto L3 else goto L4 :: bool
L3:
r13 = PyErr_Occurred()
r14 = r13 != 0
if r14 goto L4 else goto L5 :: bool
name = v
L4:
r15 = CPy_KeepPropagating()
L5:
r16 = r11 == 0
if r16 goto L6 else goto L7 :: bool
r12 = CPyDict_CheckSize(d, r2)
goto L1
L6:
name = v
r13 = CPy_NoErrOccurred()
L7:
L8:
r17 = CPyDict_CheckSize(d, r2)
goto L1
L9:
r18 = CPy_NoErrOccurred()
L10:
return 1

[case testDictLoadAddress]
Expand Down
38 changes: 7 additions & 31 deletions mypyc/test-data/irbuild-str.test
Original file line number Diff line number Diff line change
Expand Up @@ -65,42 +65,18 @@ def neq(x: str, y: str) -> bool:
[out]
def eq(x, y):
x, y :: str
r0 :: i32
r1 :: bit
r2 :: object
r3, r4, r5 :: bit
r0 :: bool
L0:
r0 = PyUnicode_Compare(x, y)
r1 = r0 == -1
if r1 goto L1 else goto L3 :: bool
L1:
r2 = PyErr_Occurred()
r3 = r2 != 0
if r3 goto L2 else goto L3 :: bool
L2:
r4 = CPy_KeepPropagating()
L3:
r5 = r0 == 0
return r5
r0 = CPyStr_Equal(x, y)
return r0
def neq(x, y):
x, y :: str
r0 :: i32
r0 :: bool
r1 :: bit
r2 :: object
r3, r4, r5 :: bit
L0:
r0 = PyUnicode_Compare(x, y)
r1 = r0 == -1
if r1 goto L1 else goto L3 :: bool
L1:
r2 = PyErr_Occurred()
r3 = r2 != 0
if r3 goto L2 else goto L3 :: bool
L2:
r4 = CPy_KeepPropagating()
L3:
r5 = r0 != 0
return r5
r0 = CPyStr_Equal(x, y)
r1 = r0 == 0
return r1

[case testStrReplace]
from typing import Optional
Expand Down
76 changes: 24 additions & 52 deletions mypyc/test-data/irbuild-unreachable.test
Original file line number Diff line number Diff line change
Expand Up @@ -11,41 +11,27 @@ def f():
r1 :: str
r2 :: object
r3, r4 :: str
r5 :: i32
r6 :: bit
r7 :: object
r8, r9, r10 :: bit
r11, r12 :: bool
r13 :: object
r14, y :: bool
r5, r6, r7 :: bool
r8 :: object
r9, y :: bool
L0:
r0 = sys :: module
r1 = 'platform'
r2 = CPyObject_GetAttr(r0, r1)
r3 = cast(str, r2)
r4 = 'x'
r5 = PyUnicode_Compare(r3, r4)
r6 = r5 == -1
if r6 goto L1 else goto L3 :: bool
r5 = CPyStr_Equal(r3, r4)
if r5 goto L2 else goto L1 :: bool
L1:
r7 = PyErr_Occurred()
r8 = r7 != 0
if r8 goto L2 else goto L3 :: bool
r6 = r5
goto L3
L2:
r9 = CPy_KeepPropagating()
r7 = raise RuntimeError('mypyc internal error: should be unreachable')
r8 = box(None, 1)
r9 = unbox(bool, r8)
r6 = r9
L3:
r10 = r5 == 0
if r10 goto L5 else goto L4 :: bool
L4:
r11 = r10
goto L6
L5:
r12 = raise RuntimeError('mypyc internal error: should be unreachable')
r13 = box(None, 1)
r14 = unbox(bool, r13)
r11 = r14
L6:
y = r11
y = r6
return 1

[case testUnreachableNameExpr]
Expand All @@ -59,41 +45,27 @@ def f():
r1 :: str
r2 :: object
r3, r4 :: str
r5 :: i32
r6 :: bit
r7 :: object
r8, r9, r10 :: bit
r11, r12 :: bool
r13 :: object
r14, y :: bool
r5, r6, r7 :: bool
r8 :: object
r9, y :: bool
L0:
r0 = sys :: module
r1 = 'platform'
r2 = CPyObject_GetAttr(r0, r1)
r3 = cast(str, r2)
r4 = 'x'
r5 = PyUnicode_Compare(r3, r4)
r6 = r5 == -1
if r6 goto L1 else goto L3 :: bool
r5 = CPyStr_Equal(r3, r4)
if r5 goto L2 else goto L1 :: bool
L1:
r7 = PyErr_Occurred()
r8 = r7 != 0
if r8 goto L2 else goto L3 :: bool
r6 = r5
goto L3
L2:
r9 = CPy_KeepPropagating()
r7 = raise RuntimeError('mypyc internal error: should be unreachable')
r8 = box(None, 1)
r9 = unbox(bool, r8)
r6 = r9
L3:
r10 = r5 == 0
if r10 goto L5 else goto L4 :: bool
L4:
r11 = r10
goto L6
L5:
r12 = raise RuntimeError('mypyc internal error: should be unreachable')
r13 = box(None, 1)
r14 = unbox(bool, r13)
r11 = r14
L6:
y = r11
y = r6
return 1

[case testUnreachableStatementAfterReturn]
Expand Down