Debian Codegraph @

pypy/module/pypyjit/test_pypy_c/test_alloc.py

raw symbols SCIP
1 import py, sys
2 from pypy.module.pypyjit.test_pypy_c.test_00_model import BaseTestPyPyC
3
4 class TestAlloc(BaseTestPyPyC):
5
6 SIZES = dict.fromkeys([2 ** n for n in range(26)] + # up to 32MB
7 [2 ** n - 1 for n in range(26)])
8
9 def test_newstr_constant_size(self):
10 for size in sorted(TestAlloc.SIZES):
11 yield self.newstr_constant_size, size
12
13 def newstr_constant_size(self, size):
14 print 'size =', size
15 src = """if 1:
16 N = %(size)d
17 part_a = 'a' * N
18 part_b = 'b' * N
19 for i in range(20):
20 ao = '%%s%%s' %% (part_a, part_b)
21 def main():
22 return 42
23 """ % {'size': size}
24 log = self.run(src, [], threshold=10)
25 assert log.result == 42
26 loop, = log.loops_by_filename(self.filepath)
27 # assert did not crash