[pypy-svn] r16054 - pypy/dist/pypy/translator/llvm2/test

rxe at codespeak.net rxe at codespeak.net
Sun Aug 14 00:40:05 CEST 2005


Author: rxe
Date: Sun Aug 14 00:40:04 2005
New Revision: 16054

Modified:
   pypy/dist/pypy/translator/llvm2/test/test_genllvm.py
   pypy/dist/pypy/translator/llvm2/test/test_seq.py
Log:
Wild goose chase: introduced a test to discover why graphs seem to not be in
SSA form (or what SSA form means here http://en.wikipedia.org/wiki/SSA_form)
when running translate_pypy.

Ironically the problem stemmed from SSI_to_SSA() transformation being run
inadvertently via backend_optimizations from translate_pypy.

ASIDE - any pointers to any docs relating to acronyms used in the
transformation would be much appreciated.  Before I read the docstring I
assumed it was doing the opposite of what it does.  Sorry for my ignorance in
this matter.

The test was a interesting so checking it in and also reenabled a test which
was related to this.



Modified: pypy/dist/pypy/translator/llvm2/test/test_genllvm.py
==============================================================================
--- pypy/dist/pypy/translator/llvm2/test/test_genllvm.py	(original)
+++ pypy/dist/pypy/translator/llvm2/test/test_genllvm.py	Sun Aug 14 00:40:04 2005
@@ -371,3 +371,45 @@
     assert createdict(0,1) == 44
     f = compile_function(createdict, [int, int])
     assert f(0,1) == createdict(0,1)
+
+def test_closure(): 
+    class A:
+        def set(self, x):
+            self.x = x
+        def get(self):
+            return self.x
+    class B(A):
+        def get(self):
+            return A.get(self) * 2
+    a = A()
+    b = B()
+    def createfn(y):
+        z = 42
+        def fn(x):
+            return x + y + z + a.get() + b.get()
+        f2 = lambda: A.get(b)
+        def getfn(x):
+            if x % 2:
+                f = A.get
+            else:
+                f = B.get
+            return f
+        def proxy(s):
+            f1 = s.get
+            t = 0
+            for ii in range(5):
+                f3 = getfn(ii)
+                t += f1()
+                t += f2()
+                t += f3(s)
+            return t
+        setattr(B, "f2", proxy)
+        return fn
+    fn = createfn(10)
+    def testf(x):
+        a.set(10)        
+        b.set(25)        
+        return fn(x) + b.get() + b.f2()
+    f = compile_function(testf, [int])
+    assert f(1) == testf(1)
+    assert f(2) == testf(2)

Modified: pypy/dist/pypy/translator/llvm2/test/test_seq.py
==============================================================================
--- pypy/dist/pypy/translator/llvm2/test/test_seq.py	(original)
+++ pypy/dist/pypy/translator/llvm2/test/test_seq.py	Sun Aug 14 00:40:04 2005
@@ -12,7 +12,6 @@
         assert f() == 42
 
     def test_array1(self):
-        py.test.skip("unknown raison")
         f = compile_function(llvmsnippet.array_simple1, [int])
         assert f(1) == 10
         assert f(-42) == -420



More information about the Pypy-commit mailing list