-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
/
irbuild-lists.test
229 lines (218 loc) · 3.76 KB
/
irbuild-lists.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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
[case testListGet]
from typing import List
def f(x: List[int]) -> int:
return x[0]
[out]
def f(x):
x :: list
r0 :: short_int
r1 :: object
r2 :: int
L0:
r0 = 0
r1 = x[r0] :: list
r2 = unbox(int, r1)
return r2
[case testListOfListGet]
from typing import List
def f(x: List[List[int]]) -> List[int]:
return x[0]
[out]
def f(x):
x :: list
r0 :: short_int
r1 :: object
r2 :: list
L0:
r0 = 0
r1 = x[r0] :: list
r2 = cast(list, r1)
return r2
[case testListOfListGet2]
from typing import List
def f(x: List[List[int]]) -> int:
return x[0][1]
[out]
def f(x):
x :: list
r0 :: short_int
r1 :: object
r2 :: list
r3 :: short_int
r4 :: object
r5 :: int
L0:
r0 = 0
r1 = x[r0] :: list
r2 = cast(list, r1)
r3 = 1
r4 = r2[r3] :: list
r5 = unbox(int, r4)
return r5
[case testListSet]
from typing import List
def f(x: List[int]) -> None:
x[0] = 1
[out]
def f(x):
x :: list
r0, r1 :: short_int
r2 :: object
r3 :: bool
r4 :: None
L0:
r0 = 1
r1 = 0
r2 = box(short_int, r0)
r3 = x.__setitem__(r1, r2) :: list
r4 = None
return r4
[case testNewListEmpty]
from typing import List
def f() -> None:
x = [] # type: List[int]
[out]
def f():
r0, x :: list
r1 :: None
L0:
r0 = []
x = r0
r1 = None
return r1
[case testNewListTwoItems]
from typing import List
def f() -> None:
x: List[int] = [1, 2]
[out]
def f():
r0, r1 :: short_int
r2, r3 :: object
r4, x :: list
r5 :: None
L0:
r0 = 1
r1 = 2
r2 = box(short_int, r0)
r3 = box(short_int, r1)
r4 = [r2, r3]
x = r4
r5 = None
return r5
[case testListMultiply]
from typing import List
def f(a: List[int]) -> None:
b = a * 2
b = 3 * [4]
[out]
def f(a):
a :: list
r0 :: short_int
r1, b :: list
r2, r3 :: short_int
r4 :: object
r5, r6 :: list
r7 :: None
L0:
r0 = 2
r1 = CPySequence_Multiply(a, r0)
b = r1
r2 = 3
r3 = 4
r4 = box(short_int, r3)
r5 = [r4]
r6 = CPySequence_RMultiply(r2, r5)
b = r6
r7 = None
return r7
[case testListLen]
from typing import List
def f(a: List[int]) -> int:
return len(a)
[out]
def f(a):
a :: list
r0 :: short_int
L0:
r0 = len a :: list
return r0
[case testListAppend]
from typing import List
def f(a: List[int], x: int) -> None:
a.append(x)
[out]
def f(a, x):
a :: list
x :: int
r0 :: object
r1 :: bool
r2, r3 :: None
L0:
r0 = box(int, x)
r1 = a.append(r0) :: list
r2 = None
r3 = None
return r3
[case testIndexLvalue]
from typing import List
def increment(l: List[int]) -> List[int]:
for i in range(len(l)):
l[i] += 1
return l
[out]
def increment(l):
l :: list
r0, r1, r2 :: short_int
i :: int
r3 :: bool
r4 :: object
r5 :: short_int
r6, r7 :: object
r8 :: bool
r9, r10 :: short_int
L0:
r0 = 0
r1 = len l :: list
r2 = r0
i = r2
L1:
r3 = r2 < r1 :: short_int
if r3 goto L2 else goto L4 :: bool
L2:
r4 = l[i] :: list
r5 = 1
r6 = box(short_int, r5)
r7 = r4 += r6
r8 = l.__setitem__(i, r7) :: list
L3:
r9 = 1
r10 = r2 + r9 :: short_int
r2 = r10
i = r10
goto L1
L4:
return l
[case testListDisplay]
from typing import List
def f(x: List[int], y: List[int]) -> List[int]:
return [1, 2, *x, *y, 3]
[out]
def f(x, y):
x, y :: list
r0, r1, r2 :: short_int
r3, r4 :: object
r5 :: list
r6, r7, r8 :: object
r9 :: bool
L0:
r0 = 1
r1 = 2
r2 = 3
r3 = box(short_int, r0)
r4 = box(short_int, r1)
r5 = [r3, r4]
r6 = r5.extend(x) :: list
r7 = r5.extend(y) :: list
r8 = box(short_int, r2)
r9 = r5.append(r8) :: list
return r5