[pypy-svn] r32043 - in pypy/dist/pypy/translator/transformer: . test

fijal at codespeak.net fijal at codespeak.net
Thu Sep 7 11:35:22 CEST 2006


Author: fijal
Date: Thu Sep  7 11:35:05 2006
New Revision: 32043

Modified:
   pypy/dist/pypy/translator/transformer/basictransform.py
   pypy/dist/pypy/translator/transformer/test/test_basictransform.py
Log:
Added checkgraph and some tests.


Modified: pypy/dist/pypy/translator/transformer/basictransform.py
==============================================================================
--- pypy/dist/pypy/translator/transformer/basictransform.py	(original)
+++ pypy/dist/pypy/translator/transformer/basictransform.py	Thu Sep  7 11:35:05 2006
@@ -6,10 +6,10 @@
 from pypy.translator.unsimplify import varoftype
 from pypy.annotation import model as annmodel
 from pypy.objspace.flow import model
-#from pypy.translator.js.helper import main_exception_helper, ExceptionHelper
 from pypy.rpython.ootypesystem import ootype
 from pypy.rpython.ootypesystem import rclass
 from pypy.rpython.annlowlevel import MixLevelHelperAnnotator
+from pypy.objspace.flow.model import checkgraph
 
 class BasicTransformer(object):
     """ This is basic transformer which applies after annotation level.
@@ -64,7 +64,9 @@
         bk = self.translator.annotator.bookkeeper
         for graph in self.translator.graphs:
             self.transform_graph(graph)
+            checkgraph(graph)
         self.translator.annotator.complete()
+        
 
     def get_const(self, arg):
         bk = self.bookkeeper

Modified: pypy/dist/pypy/translator/transformer/test/test_basictransform.py
==============================================================================
--- pypy/dist/pypy/translator/transformer/test/test_basictransform.py	(original)
+++ pypy/dist/pypy/translator/transformer/test/test_basictransform.py	Thu Sep  7 11:35:05 2006
@@ -8,6 +8,7 @@
 from pypy.rpython import llinterp
 from pypy.objspace.flow import model
 from pypy.translator.unsimplify import copyvar
+from pypy.rpython.nonconst import NonConstant
 
 def transform_function(transformerclass, fun, annotation=[], specialize=True,
     type_system="ootype"):
@@ -115,6 +116,31 @@
     res = interp_fun(t, helper_call_fun)
     assert res == 11
 
+class A(object):
+    def __init__(self):
+        self.l = []
+    
+    def add(self, item):
+        self.l.append(item)
+
+a = A()
+
+class EmptyTransformer(BasicTransformer):
+    def transform_graph(self, graph):
+        pass
+
+def test_list_buildup():
+    def f():
+        a.add(NonConstant("item2"))
+    
+    def wrapper():
+        a.add("item")
+        f()
+        return a.l[2:]
+    
+    t = transform_function(EmptyTransformer, wrapper)
+    #res = interp_fun(t, wrapper)
+    #assert res._list == []
 
 ##def test_transform():
 ##    def fun(i):



More information about the Pypy-commit mailing list