Skip to content

Commit 45623a4

Browse files
committed
tests/basics/fun_code: Test decoded line-number values.
Signed-off-by: Anson Mansfield <amansfield@mantaro.com>
1 parent be3b303 commit 45623a4

File tree

2 files changed

+85
-0
lines changed

2 files changed

+85
-0
lines changed

tests/basics/fun_code_colines.py

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# Chech that we have sensical bytecode offsets in function.__code__.co_lines
2+
3+
def f(x, y, obj, obj2, obj3):
4+
a = x + y # line 4: bc+4 line+4
5+
b = x - y # line 5: bc+4 line+1
6+
# line 6
7+
# line 7
8+
# line 8
9+
# line 9
10+
# line 10
11+
# line 11
12+
# line 12
13+
# line 13
14+
# line 14
15+
# line 15
16+
# line 16
17+
# line 17
18+
# line 18
19+
# line 19
20+
c = a * b # line 20: bc+4 line+15
21+
obj.a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z.fun() # line 21: bc+31 line+1; bc+27 line+0
22+
# line 22
23+
# line 23
24+
# line 24: bc+0 line+3
25+
# line 25
26+
# line 26
27+
# line 27: bc+0 line+3
28+
# line 28
29+
# line 29
30+
obj2.a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z.fun() # line 30: bc+31 line+3; bc+27 line+0
31+
# line 31
32+
# line 32
33+
# line 33: bc+0 line+3
34+
# line 34
35+
# line 35
36+
# line 36
37+
# line 37
38+
# line 38
39+
# line 39
40+
# line 40
41+
# line 41
42+
# line 42
43+
# line 43
44+
# line 44
45+
# line 45
46+
# line 46
47+
# line 47
48+
# line 48
49+
# line 49
50+
# line 50
51+
# line 51
52+
# line 52
53+
# line 53
54+
# line 54
55+
# line 55
56+
# line 56
57+
# line 57
58+
# line 58
59+
# line 59
60+
obj3.a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z.fun() # line 60: bc+31 line+27; bc+27 line+0
61+
return c # line 61: bc+2 line+1
62+
63+
try:
64+
f.__code__.co_lines
65+
except AttributeError:
66+
print("SKIP")
67+
raise SystemExit
68+
69+
for start, end, line_no in f.__code__.co_lines():
70+
print(f"line {line_no} start: {start}")
71+
print(f"line {line_no} end: {end}")

tests/basics/fun_code_colines.py.exp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
line 4 start: 0
2+
line 4 end: 4
3+
line 5 start: 4
4+
line 5 end: 8
5+
line 20 start: 8
6+
line 20 end: 12
7+
line 21 start: 12
8+
line 21 end: 70
9+
line 30 start: 70
10+
line 30 end: 128
11+
line 60 start: 128
12+
line 60 end: 186
13+
line 61 start: 186
14+
line 61 end: 188

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy