Files
codeql/python/ql/test/experimental/library-tests/CallGraph/code/runtime_decision.py
Rasmus Wriedt Larsen 155bbbdec9 Python: Add annotated call-graph tests
See the added README for in-depth details
2020-06-24 22:15:39 +02:00

31 lines
539 B
Python

import sys
import random
# hmm, annoying that you have to keep names unique accross files :|
# since I like to use foo and bar ALL the time :D
# name:rd_foo
def rd_foo():
print('rd_foo')
# name:rd_bar
def rd_bar():
print('rd_bar')
if len(sys.argv) >= 2 and not sys.argv[1] in ['0', 'False', 'false']:
func = rd_foo
else:
func = rd_bar
# calls:rd_foo calls:rd_bar
func()
# Random doesn't work with points-to :O
if random.random() < 0.5:
func2 = rd_foo
else:
func2 = rd_bar
# calls:rd_foo calls:rd_bar
func2()