forked from python/mypy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenops-tuple.test
129 lines (120 loc) · 2.2 KB
/
genops-tuple.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
[case testTupleGet]
from typing import Tuple
def f(x: Tuple[Tuple[int, bool], bool]) -> int:
return x[0][0]
[out]
def f(x):
x :: tuple[tuple[int, bool], bool]
r0 :: tuple[int, bool]
r1 :: int
L0:
r0 = x[0]
r1 = r0[0]
return r1
[case testTupleNew]
from typing import Tuple
def f() -> int:
t = (True, 1)
return t[1]
[out]
def f():
r0 :: bool
r1 :: short_int
r2, t :: tuple[bool, int]
r3 :: int
L0:
r0 = True
r1 = 1
r2 = (r0, r1)
t = r2
r3 = t[1]
return r3
[case testTupleLen]
from typing import Tuple
def f(x: Tuple[bool, bool, int]) -> int:
return len(x)
[out]
def f(x):
x :: tuple[bool, bool, int]
r0 :: short_int
L0:
r0 = 3
return r0
[case testSequenceTuple]
from typing import List
def f(x: List[bool]) -> bool:
return tuple(x)[1]
[out]
def f(x):
x :: list
r0 :: tuple
r1 :: short_int
r2 :: object
r3 :: bool
L0:
r0 = tuple x :: list
r1 = 1
r2 = r0[r1] :: tuple
r3 = unbox(bool, r2)
return r3
[case testSequenceTupleLen]
from typing import Tuple
def f(x: Tuple[int, ...]) -> int:
return len(x)
[out]
def f(x):
x :: tuple
r0 :: int
L0:
r0 = len x :: tuple
return r0
[case testSequenceTupleForced]
from typing import Tuple
def f() -> int:
t = (1, 2) # type: Tuple[int, ...]
return t[1]
[out]
def f():
r0, r1 :: short_int
r2 :: tuple[int, int]
t :: tuple
r3 :: object
r4 :: short_int
r5 :: object
r6 :: int
L0:
r0 = 1
r1 = 2
r2 = (r0, r1)
r3 = box(tuple[int, int], r2)
t = r3
r4 = 1
r5 = t[r4] :: tuple
r6 = unbox(int, r5)
return r6
[case testTupleDisplay]
from typing import Sequence, Tuple
def f(x: Sequence[int], y: Sequence[int]) -> Tuple[int, ...]:
return (1, 2, *x, *y, 3)
[out]
def f(x, y):
x, y :: object
r0, r1, r2 :: short_int
r3, r4 :: object
r5 :: list
r6, r7, r8 :: object
r9 :: bool
r10 :: tuple
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
r10 = tuple r5 :: list
return r10