Debian Codegraph @

pypy/module/pypyjit/test/test_jit_setup.py

raw symbols SCIP
1 class AppTestPyPyJIT:
2 spaceconfig = dict(usemodules=('pypyjit',))
3
4 def test_setup(self):
5 # this just checks that the module is setting up things correctly, and
6 # the resulting code makes sense on top of CPython.
7 import pypyjit
8 try:
9 pypyjit.set_param(threshold=5, inlining=1)
10 pypyjit.set_param("trace_eagerness=3,inlining=0")
11
12 def f(x, y):
13 return x*y+1
14
15 assert f(6, 7) == 43
16
17 def gen(x):
18 i = 0
19 while i < x:
20 yield i*i
21 i += 1
22
23 assert list(gen(3)) == [0, 1, 4]
24 finally:
25 pypyjit.set_param('default')
26
27 def test_no_jit(self):
28 import pypyjit
29 was_called = []
30 def should_not_be_called(*args, **kwds):
31 was_called.append((args, kwds))
32 try:
33 pypyjit.set_param('off')
34 pypyjit.set_compile_hook(should_not_be_called)
35 def f():
36 pass
37 for i in range(2500):
38 f()
39 assert not was_called
40 finally:
41 pypyjit.set_compile_hook(None)
42 pypyjit.set_param('default')
43
44 def test_doc(self):
45 import pypyjit
46 d = pypyjit.PARAMETER_DOCS
47 assert type(d) is dict
48 assert 'threshold' in d
49
50 def test_interface_residual_call(self):
51 import pypyjit
52 def f(*args, **kwds):
53 return (args, kwds)
54 res = pypyjit.residual_call(f, 4, x=6)
55 assert res == ((4,), {'x': 6})