[pypy-svn] r33227 - pypy/dist/pypy/translator/c/test

pedronis at codespeak.net pedronis at codespeak.net
Thu Oct 12 16:24:15 CEST 2006


Author: pedronis
Date: Thu Oct 12 16:24:13 2006
New Revision: 33227

Modified:
   pypy/dist/pypy/translator/c/test/test_boehm.py
Log:
generalize a bit the abstract class for reuse (we should go for larger scale and reuse really
but problem in the config branch)



Modified: pypy/dist/pypy/translator/c/test/test_boehm.py
==============================================================================
--- pypy/dist/pypy/translator/c/test/test_boehm.py	(original)
+++ pypy/dist/pypy/translator/c/test/test_boehm.py	Thu Oct 12 16:24:13 2006
@@ -8,8 +8,9 @@
     if not check_boehm_presence():
         py.test.skip("Boehm GC not present")
 
-class AbstractTestClass:
-    
+class AbstractTestBoehmClass:
+    from pypy.translator.c.gc import BoehmGcPolicy as gcpolicy
+   
     # deal with cleanups
     def setup_method(self, meth):
         self._cleanups = []
@@ -18,17 +19,12 @@
             #print "CLEANUP"
             self._cleanups.pop()()
 
-    def getcompiled(self, func):
+    def getcompiled(self, func, argstypelist = [],
+                    annotatorpolicy=None):
         t = TranslationContext(simplifying=True)
         self.t = t
-        # builds starting-types from func_defs 
-        argstypelist = []
-        if func.func_defaults:
-            for spec in func.func_defaults:
-                if isinstance(spec, tuple):
-                    spec = spec[0] # use the first type only for the tests
-                argstypelist.append(spec)
-        a = t.buildannotator().build_types(func, argstypelist)
+        a = t.buildannotator(policy=annotatorpolicy)
+        a.build_types(func, argstypelist)
         t.buildrtyper().specialize()
         t.checkgraphs()
         def compile():
@@ -43,8 +39,7 @@
         return compile()
 
 
-class TestUsingBoehm(AbstractTestClass):
-    from pypy.translator.c.gc import BoehmGcPolicy as gcpolicy
+class TestUsingBoehm(AbstractTestBoehmClass):
 
     def test_malloc_a_lot(self):
         def malloc_a_lot():
@@ -105,7 +100,7 @@
         class A(object):
             def __del__(self):
                 s.a_dels += 1
-        def f(i=int):
+        def f(i):
             if i:
                 s.a_dels = 0
                 a = A()
@@ -116,7 +111,7 @@
             llop.gc__collect(lltype.Void)
             llop.gc__collect(lltype.Void)
             return s.a_dels
-        fn = self.getcompiled(f)
+        fn = self.getcompiled(f, [int])
         # we can't demand that boehm has collected all of the objects,
         # even with the gc__collect call.  calling the compiled
         # function twice seems to help, though.



More information about the Pypy-commit mailing list