Files
codeql/python/ql/test/experimental/library-tests/CallGraph/code/runtime_decision.py
Rasmus Wriedt Larsen 6d9745e5c3 Python: Rewrite call-graph tests to be inline expectation (2/2)
I ported the predicates showing difference between points-to and
type-tracking, since it's helpful to see the list of differences,
instead of having to parse expectations!
2022-11-11 10:34:28 +01:00

27 lines
502 B
Python

import sys
import random
# hmm, annoying that you have to keep names unique across files :|
# since I like to use foo and bar ALL the time :D
def rd_foo():
print('rd_foo')
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
func() # $ pt=rd_foo pt=rd_bar
# Random doesn't work with points-to :O
if random.random() < 0.5:
func2 = rd_foo
else:
func2 = rd_bar
func2() # $ pt=rd_foo pt=rd_bar