Debian Codegraph @

pypy/tool/test/test_template.py

raw symbols SCIP
1 from rpython.tool.sourcetools import compile_template
2
3
4 some_global = 5
5
6 def test_template():
7 init_value = 50
8
9 def template(n):
10 args = ['arg%d' % i for i in range(n)]
11 yield 'def add(%s):' % (', '.join(args),)
12 yield ' total = init_value + some_global'
13 for i in range(n):
14 yield ' total += arg%d' % i
15 yield ' return total'
16
17 add = compile_template(template(5), 'add')
18 assert add(10000, 1000, 100, 10, 1) == 11166