[pypy-svn] r26237 - pypy/dist/pypy/objspace/cpy/test
arigo at codespeak.net
arigo at codespeak.net
Mon Apr 24 10:27:19 CEST 2006
Author: arigo
Date: Mon Apr 24 10:27:17 2006
New Revision: 26237
Modified:
pypy/dist/pypy/objspace/cpy/test/test_compile.py
Log:
Added skipped tests: the next goals
Modified: pypy/dist/pypy/objspace/cpy/test/test_compile.py
==============================================================================
--- pypy/dist/pypy/objspace/cpy/test/test_compile.py (original)
+++ pypy/dist/pypy/objspace/cpy/test/test_compile.py Mon Apr 24 10:27:17 2006
@@ -1,7 +1,12 @@
+import py
from pypy.translator.c.test.test_genc import compile
+from pypy.annotation.annrpython import RPythonAnnotator
+from pypy.translator.translator import TranslationContext, graphof
from pypy.translator.goal.ann_override import PyPyAnnotatorPolicy
from pypy.objspace.cpy.objspace import CPyObjSpace
import pypy.rpython.rctypes.implementation
+from pypy.interpreter.function import BuiltinFunction
+from pypy.interpreter.gateway import interp2app, ObjSpace, W_Root
def test_demo():
@@ -16,3 +21,40 @@
res = fn(10, long)
assert isinstance(res, int)
+
+# ____________________________________________________________
+
+def myfunc(space, w_x):
+ x = space.int_w(w_x)
+ result = x * 7
+ return space.wrap(result)
+myfunc.unwrap_spec = [ObjSpace, W_Root]
+
+def maketest():
+ space = CPyObjSpace()
+ func = interp2app(myfunc).__spacebind__(space)
+ bltin = BuiltinFunction(func)
+ w_myfunc = space.wrap(bltin)
+ def entrypoint(n):
+ w_result = space.call_function(w_myfunc, space.wrap(n))
+ return space.int_w(w_result)
+ return entrypoint
+
+def test_annotate():
+ py.test.skip("in-progress")
+ entrypoint = maketest()
+ t = TranslationContext()
+ a = t.buildannotator(policy=PyPyAnnotatorPolicy())
+ s = a.build_types(entrypoint, [int])
+ assert s.knowntype == int
+ graph = graphof(t, myfunc)
+ assert len(graph.inputargs()) == 2
+ s = a.getbinding(graph.inputargs()[1])
+ assert s.knowntype == CPyObjSpace.W_Object
+
+def test_compile():
+ py.test.skip("in-progress")
+ entrypoint = maketest()
+ fn = compile(entrypoint, [int], annotatorpolicy=PyPyAnnotatorPolicy())
+ res = fn(-6)
+ assert res == -42
More information about the Pypy-commit
mailing list