Skip to content

Commit fb0cc18

Browse files
committed
Python: Add test of multi func def based on runtime decision
1 parent 276a825 commit fb0cc18

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ pointsTo_found_typeTracker_notFound
1515
| code/func_defined_outside_class.py:42:1:42:7 | ControlFlowNode for Attribute() | B._gen.func |
1616
| code/func_defined_outside_class.py:43:1:43:7 | ControlFlowNode for Attribute() | B._gen.func |
1717
| code/funky_regression.py:15:9:15:17 | ControlFlowNode for Attribute() | Wat.f2 |
18+
| code/runtime_decision.py:44:1:44:7 | ControlFlowNode for func4() | "code/runtime_decision_defns.py:4:func4" |
19+
| code/runtime_decision.py:44:1:44:7 | ControlFlowNode for func4() | "code/runtime_decision_defns.py:7:func4" |
1820
| code/type_tracking_limitation.py:8:1:8:3 | ControlFlowNode for x() | my_func |
1921
typeTracker_found_pointsTo_notFound
2022
| code/callable_as_argument.py:29:5:29:12 | ControlFlowNode for Attribute() | test_class.InsideTestFunc.sm |

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,21 @@ def rd_bar():
2424
func2 = rd_bar
2525

2626
func2() # $ pt,tt=rd_foo pt,tt=rd_bar
27+
28+
29+
# ==============================================================================
30+
# definition is random
31+
32+
if random.random() < 0.5:
33+
def func3():
34+
print("func3 A")
35+
else:
36+
def func3():
37+
print("func3 B")
38+
39+
func3() # $ pt,tt=33:func3 pt,tt=36:func3
40+
41+
42+
# func4 uses same setup as func3, it's just defined in an other file
43+
from code.runtime_decision_defns import func4
44+
func4() # $ pt="code/runtime_decision_defns.py:4:func4" pt="code/runtime_decision_defns.py:7:func4" MISSING: tt
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import random
2+
3+
if random.random() < 0.5:
4+
def func4():
5+
print("func4 A")
6+
else:
7+
def func4():
8+
print("func4 B")

0 commit comments

Comments
 (0)