[pypy-svn] r48155 - pypy/dist/pypy/translator/llvm/test

santagada at codespeak.net santagada at codespeak.net
Mon Oct 29 15:37:35 CET 2007


Author: santagada
Date: Mon Oct 29 15:37:35 2007
New Revision: 48155

Added:
   pypy/dist/pypy/translator/llvm/test/test_rlist.py
Modified:
   pypy/dist/pypy/translator/llvm/test/runtest.py
Log:
begginings of a LLVMTest class, still lots to go

Modified: pypy/dist/pypy/translator/llvm/test/runtest.py
==============================================================================
--- pypy/dist/pypy/translator/llvm/test/runtest.py	(original)
+++ pypy/dist/pypy/translator/llvm/test/runtest.py	Mon Oct 29 15:37:35 2007
@@ -1,6 +1,7 @@
 import py
 py.test.skip("llvm is a state of flux")
 
+from pypy.rpython.test.tool import BaseRtypingTest, LLRtypeMixin
 from pypy.translator.llvm.buildllvm import llvm_is_on_path, llvm_version, gcc_version
 from pypy.translator.llvm.genllvm import GenLLVM
 
@@ -107,3 +108,64 @@
     " returns compiled function "
     return compile_test(function, annotation, isolate_hint=isolate_hint, **kwds)[1]
 
+# XXX Work in progress, this was mostly copied from JsTest
+class LLVMTest(BaseRtypingTest, LLRtypeMixin):
+    def _compile(self, _fn, args, policy=None):
+        # argnames = _fn.func_code.co_varnames[:_fn.func_code.co_argcount]
+        # func_name = _fn.func_name
+        # if func_name == '<lambda>':
+        #     func_name = 'func'
+        # source = py.code.Source("""
+        # def %s():
+        #     from pypy.rlib.nonconst import NonConstant
+        #     res = _fn(%s)
+        #     if isinstance(res, type(None)):
+        #         return None
+        #     else:
+        #         return str(res)"""
+        # % (func_name, ",".join(["%s=NonConstant(%r)" % (name, i) for
+        #                            name, i in zip(argnames, args)])))
+        # exec source.compile() in locals()
+        return compile_function(_fn, [])
+
+    def interpret(self, fn, args, policy=None):
+        f = self._compile(fn, args)
+        res = f(*args)
+        return res
+
+    def interpret_raises(self, exception, fn, args):
+        #import exceptions # needed by eval
+        #try:
+        #import pdb; pdb.set_trace()
+        try:
+            res = self.interpret(fn, args)
+        except JSException, e:
+            s = e.args[0]
+            assert s.startswith('uncaught exception:')
+            assert re.search(exception.__name__, s)
+        else:
+            raise AssertionError("Did not raise, returned %s" % res)
+        #except ExceptionWrapper, ex:
+        #    assert issubclass(eval(ex.class_name), exception)
+        #else:
+        #    assert False, 'function did raise no exception at all'
+    # 
+    # def ll_to_string(self, s):
+    #     return str(s)
+    # 
+    # def ll_to_list(self, l):
+    #     return l
+    # 
+    # def ll_unpack_tuple(self, t, length):
+    #     assert len(t) == length
+    #     return tuple(t)
+    # 
+    # def class_name(self, value):
+    #     return value[:-8].split('.')[-1]
+    # 
+    # def is_of_instance_type(self, val):
+    #     m = re.match("^<.* object>$", val)
+    #     return bool(m)
+    # 
+    # def read_attr(self, obj, name):
+    #     py.test.skip('read_attr not supported on genjs tests')

Added: pypy/dist/pypy/translator/llvm/test/test_rlist.py
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/translator/llvm/test/test_rlist.py	Mon Oct 29 15:37:35 2007
@@ -0,0 +1,8 @@
+import py
+from pypy.rpython.test.test_rlist import BaseTestRlist
+from pypy.translator.llvm.test.runtest import LLVMTest
+
+# ====> ../../../rpython/test/test_rlist.py
+
+class TestLLVMList(LLVMTest, BaseTestRlist):
+    pass
\ No newline at end of file



More information about the Pypy-commit mailing list