Skip to content

Commit a95bb7c

Browse files
committed
Python: Expand function reference in content test
1 parent 7721fb3 commit a95bb7c

3 files changed

Lines changed: 55 additions & 16 deletions

File tree

python/ql/test/experimental/library-tests/CallGraph/InlineCallGraphTest.expected

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ pointsTo_found_typeTracker_notFound
1515
| code/func_defined_outside_class.py:39:11:39:21 | ControlFlowNode for _gen() | B._gen |
1616
| code/func_defined_outside_class.py:42:1:42:7 | ControlFlowNode for Attribute() | B._gen.func |
1717
| code/func_defined_outside_class.py:43:1:43:7 | ControlFlowNode for Attribute() | B._gen.func |
18+
| code/func_ref_in_content.py:17:1:17:4 | ControlFlowNode for f2() | func |
19+
| code/func_ref_in_content.py:20:1:20:4 | ControlFlowNode for f3() | func |
1820
| code/funky_regression.py:15:9:15:17 | ControlFlowNode for Attribute() | Wat.f2 |
19-
| code/tuple_function_return.py:15:1:15:4 | ControlFlowNode for f2() | func |
2021
| code/type_tracking_limitation.py:8:1:8:3 | ControlFlowNode for x() | my_func |
2122
typeTracker_found_pointsTo_notFound
2223
| code/callable_as_argument.py:29:5:29:12 | ControlFlowNode for Attribute() | test_class.InsideTestFunc.sm |
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
def func():
2+
print("func()")
3+
4+
def return_func():
5+
return func
6+
7+
f1 = return_func() # $ pt,tt=return_func
8+
f1() # $ pt,tt=func
9+
10+
11+
def return_func_in_tuple():
12+
return (func, 42)
13+
14+
tup = return_func_in_tuple() # $ pt,tt=return_func_in_tuple
15+
16+
f2, _ = tup
17+
f2() # $ pt=func MISSING: tt
18+
19+
f3 = tup[0]
20+
f3() # $ pt=func MISSING: tt
21+
22+
23+
def return_func_in_dict():
24+
return {'func': func, 'val': 42}
25+
26+
dct = return_func_in_dict() # $ pt,tt=return_func_in_dict
27+
28+
f4 = dct['func']
29+
f4() # $ MISSING: tt=func
30+
31+
32+
def return_func_in_dict_update():
33+
d = {}
34+
d["func"] = func
35+
return d
36+
37+
dct2 = return_func_in_dict_update() # $ pt,tt=return_func_in_dict_update
38+
39+
f5 = dct2['func']
40+
f5() # $ MISSING: tt=func
41+
42+
43+
def return_func_in_list():
44+
return [func, 42]
45+
46+
lst = return_func_in_list() # $ pt,tt=return_func_in_list
47+
48+
f6 = lst[0]
49+
f6() # $ MISSING: pt,tt=func
50+
51+
if eval("False"): # don't run this, but fool analysis to still consider it (doesn't wok if you just to `if False:`)
52+
f7 = lst[1]
53+
f7()

python/ql/test/experimental/library-tests/CallGraph/code/tuple_function_return.py

Lines changed: 0 additions & 15 deletions
This file was deleted.

0 commit comments

Comments
 (0)