-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
/
Copy pathirbuild-bytes.test
187 lines (178 loc) · 3.6 KB
/
irbuild-bytes.test
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
[case testBytesBasics]
def f(num: int, l: list, d: dict, s: str) -> None:
b1 = bytes()
b2 = bytes(num)
b3 = bytes(l)
b4 = bytes(d)
b5 = bytes(s)
[out]
def f(num, l, d, s):
num :: int
l :: list
d :: dict
s :: str
r0, r1 :: object
r2, b1 :: bytes
r3, r4 :: object
r5 :: object[1]
r6 :: object_ptr
r7 :: object
r8, b2, r9, b3, r10, b4, r11, b5 :: bytes
L0:
r0 = load_address PyBytes_Type
r1 = PyObject_Vectorcall(r0, 0, 0, 0)
r2 = cast(bytes, r1)
b1 = r2
r3 = load_address PyBytes_Type
r4 = box(int, num)
r5 = [r4]
r6 = load_address r5
r7 = PyObject_Vectorcall(r3, r6, 1, 0)
keep_alive r4
r8 = cast(bytes, r7)
b2 = r8
r9 = PyBytes_FromObject(l)
b3 = r9
r10 = PyBytes_FromObject(d)
b4 = r10
r11 = PyBytes_FromObject(s)
b5 = r11
return 1
[case testBytearrayBasics]
def f(s: str, num: int) -> None:
a = bytearray()
b = bytearray(s)
c = bytearray(num)
[out]
def f(s, num):
s :: str
num :: int
r0 :: object
r1 :: str
r2, r3, a :: object
r4 :: bytes
b, r5 :: object
r6 :: bytes
c :: object
L0:
r0 = builtins :: module
r1 = 'bytearray'
r2 = CPyObject_GetAttr(r0, r1)
r3 = PyObject_Vectorcall(r2, 0, 0, 0)
a = r3
r4 = PyByteArray_FromObject(s)
b = r4
r5 = box(int, num)
r6 = PyByteArray_FromObject(r5)
c = r6
return 1
[case testBytesEquality]
def eq(x: bytes, y: bytes) -> bool:
return x == y
def neq(x: bytes, y: bytes) -> bool:
return x != y
[out]
def eq(x, y):
x, y :: bytes
r0 :: i32
r1, r2 :: bit
L0:
r0 = CPyBytes_Compare(x, y)
r1 = r0 >= 0 :: signed
r2 = r0 == 1
return r2
def neq(x, y):
x, y :: bytes
r0 :: i32
r1, r2 :: bit
L0:
r0 = CPyBytes_Compare(x, y)
r1 = r0 >= 0 :: signed
r2 = r0 != 1
return r2
[case testBytesSlicing]
def f(a: bytes, start: int, end: int) -> bytes:
return a[start:end]
[out]
def f(a, start, end):
a :: bytes
start, end :: int
r0 :: bytes
L0:
r0 = CPyBytes_GetSlice(a, start, end)
return r0
[case testBytesIndex]
def f(a: bytes, i: int) -> int:
return a[i]
[out]
def f(a, i):
a :: bytes
i, r0 :: int
L0:
r0 = CPyBytes_GetItem(a, i)
return r0
[case testBytesConcat]
def f(a: bytes, b: bytes) -> bytes:
return a + b
[out]
def f(a, b):
a, b, r0 :: bytes
L0:
r0 = CPyBytes_Concat(a, b)
return r0
[case testBytesJoin]
from typing import List
def f(b: List[bytes]) -> bytes:
return b" ".join(b)
[out]
def f(b):
b :: list
r0, r1 :: bytes
L0:
r0 = b' '
r1 = CPyBytes_Join(r0, b)
return r1
[case testBytesLen]
def f(b: bytes) -> int:
return len(b)
[out]
def f(b):
b :: bytes
r0 :: native_int
r1 :: short_int
L0:
r0 = var_object_size b
r1 = r0 << 1
return r1
[case testBytesFormatting]
def f(var: bytes, num: int) -> None:
b1 = b'aaaa%bbbbb%s' % (var, var)
b2 = b'aaaa%bbbbb%s%d' % (var, var, num)
b3 = b'%b' % var
b4 = b'%ssss' % var
[typing fixtures/typing-full.pyi]
[out]
def f(var, num):
var :: bytes
num :: int
r0, r1, r2, b1, r3 :: bytes
r4 :: tuple[bytes, bytes, int]
r5, r6 :: object
r7, b2, r8, b3, r9, r10, b4 :: bytes
L0:
r0 = b'aaaa'
r1 = b'bbbb'
r2 = CPyBytes_Build(4, r0, var, r1, var)
b1 = r2
r3 = b'aaaa%bbbbb%s%d'
r4 = (var, var, num)
r5 = box(tuple[bytes, bytes, int], r4)
r6 = PyNumber_Remainder(r3, r5)
r7 = cast(bytes, r6)
b2 = r7
r8 = CPyBytes_Build(1, var)
b3 = r8
r9 = b'sss'
r10 = CPyBytes_Build(2, var, r9)
b4 = r10
return 1