[pypy-svn] r15441 - in pypy/dist/pypy/translator/llvm2: . test

rxe at codespeak.net rxe at codespeak.net
Sat Jul 30 21:44:46 CEST 2005


Author: rxe
Date: Sat Jul 30 21:44:42 2005
New Revision: 15441

Modified:
   pypy/dist/pypy/translator/llvm2/codewriter.py
   pypy/dist/pypy/translator/llvm2/funcnode.py
   pypy/dist/pypy/translator/llvm2/test/llvmsnippet.py
   pypy/dist/pypy/translator/llvm2/test/test_class.py
   pypy/dist/pypy/translator/llvm2/test/test_lltype.py
Log:
Various fixes to make all tests in test_class work.
Passed arigo's test_aliasing2.



Modified: pypy/dist/pypy/translator/llvm2/codewriter.py
==============================================================================
--- pypy/dist/pypy/translator/llvm2/codewriter.py	(original)
+++ pypy/dist/pypy/translator/llvm2/codewriter.py	Sat Jul 30 21:44:42 2005
@@ -34,7 +34,7 @@
         self.append("    %s:" % name)
 
     def globalinstance(self, name, typeandata):
-        self.append("%s = constant %s" % (name, typeandata))
+        self.append("%s = global %s" % (name, typeandata))
 
     def structdef(self, name, typereprs):
         self.append("%s = type { %s }" %(name, ", ".join(typereprs)))

Modified: pypy/dist/pypy/translator/llvm2/funcnode.py
==============================================================================
--- pypy/dist/pypy/translator/llvm2/funcnode.py	(original)
+++ pypy/dist/pypy/translator/llvm2/funcnode.py	Sat Jul 30 21:44:42 2005
@@ -32,7 +32,7 @@
     def __init__(self, db, value):
         self.db = db
         self.value = value
-        self.ref = "%" + value._name
+        self.ref = "%" + value.graph.name
         self.graph = value.graph 
         remove_same_as(self.graph) 
         remove_double_links(self.db._translator, self.graph) 

Modified: pypy/dist/pypy/translator/llvm2/test/llvmsnippet.py
==============================================================================
--- pypy/dist/pypy/translator/llvm2/test/llvmsnippet.py	(original)
+++ pypy/dist/pypy/translator/llvm2/test/llvmsnippet.py	Sat Jul 30 21:44:42 2005
@@ -188,7 +188,7 @@
     a = A()
     return a.a
 
-class B(object):
+class B(A):
     def __init__(self):
         self.a = 14
         self.b = False
@@ -201,7 +201,7 @@
     b.change(newa)
     return b.a
 
-class C(object):
+class C(A):
     def __init__(self, a):
         self.a = a
         self.b = 1
@@ -233,7 +233,7 @@
 def class_inherit2():
     aa = AA()
     bb = BB()
-    return aa.g() + bb.g() 
+    return aa.g() - bb.g() 
 
 class D(object):
     def __init__(self, a, length):
@@ -268,6 +268,20 @@
     36 + d + 3
     return previous + d + previous1
 
+class FFF: pass
+fff = FFF()
+fff.x = 10
+
+def getset(x):
+    res = fff.x
+    fff.x = x
+    return res
+
+def testgetset(y):
+    res1 = getset(y)
+    res2 = getset(y)
+    return res1 + res2
+
 def degrading_func(obj):
     if isinstance(obj, C):
         return obj.a + obj.b

Modified: pypy/dist/pypy/translator/llvm2/test/test_class.py
==============================================================================
--- pypy/dist/pypy/translator/llvm2/test/test_class.py	(original)
+++ pypy/dist/pypy/translator/llvm2/test/test_class.py	Sat Jul 30 21:44:42 2005
@@ -31,12 +31,10 @@
         assert f() == 11
 
     def test_inherit2(self):
-        py.test.skip("function redefinition problem")
         f = compile_function(llvmsnippet.class_inherit2, [])
         assert f() == 1
 
     def test_method_of_base_class(self):
-        py.test.skip("rtyper problem")
         f = compile_function(llvmsnippet.method_of_base_class, [])
         assert f() == 14
 
@@ -45,7 +43,6 @@
         assert f() == 4
 
     def test_direct_call_of_virtual_method(self):
-        py.test.skip("function redefinition problem")
         f = compile_function(llvmsnippet.direct_call_of_virtual_method, [])
         assert f() == 14
 
@@ -64,17 +61,21 @@
         assert f(False) == 2
 
     def test_global_instance(self):
-        py.test.skip("function redefinition problems")
         f = compile_function(llvmsnippet.global_instance, [int])
         assert f(-1) == llvmsnippet.global_instance(-1)
         for i in range(20):
-            assert f(i) == llvmsnippet.global_instance(i)
+            x = f(i)
+            y = llvmsnippet.global_instance(i)
+            assert x == y
+
+    def test_getset(self):
+        f = compile_function(llvmsnippet.testgetset, [int])
+        assert f(15) == 25
 
     def test_call_degrading_func(self):
-        py.test.skip("rtyper problem")
         f = compile_function(llvmsnippet.call_degrading_func, [bool])
-        assert f(True) == llvmsnippet.call_degrading_func(True)     #-36
-        assert f(False) == llvmsnippet.call_degrading_func(False)   #14
+        assert f(True) == llvmsnippet.call_degrading_func(True)
+        assert f(False) == llvmsnippet.call_degrading_func(False)
     
     def test_circular_classdef(self):
         f = compile_function(llvmsnippet.circular_classdef, [])

Modified: pypy/dist/pypy/translator/llvm2/test/test_lltype.py
==============================================================================
--- pypy/dist/pypy/translator/llvm2/test/test_lltype.py	(original)
+++ pypy/dist/pypy/translator/llvm2/test/test_lltype.py	Sat Jul 30 21:44:42 2005
@@ -116,6 +116,20 @@
     assert f(2) == 0
     assert f(3) == 17
 
+def test_aliasing2():
+    B = lltype.Struct('B', ('x', lltype.Signed))
+    A = lltype.Array(B)
+    C = lltype.Struct('C', ('x', lltype.Signed), ('bptr', lltype.Ptr(B)))
+    global_a = lltype.malloc(A, 5, immortal=True)
+    global_c = lltype.malloc(C, immortal=True)
+    global_c.bptr = global_a[3]
+    def aliasing(i):
+        global_c.bptr.x = 17
+        return global_a[i].x
+    f = compile_function(aliasing, [int], embedexterns=False)
+    assert f(2) == 0
+    assert f(3) == 17    
+
 def test_array_constant():
     A = lltype.GcArray(lltype.Signed)
     a = lltype.malloc(A, 3)



More information about the Pypy-commit mailing list