[pypy-svn] r18761 - in pypy/dist/pypy/rpython/ootypesystem: . test

arigo at codespeak.net arigo at codespeak.net
Wed Oct 19 17:45:43 CEST 2005


Author: arigo
Date: Wed Oct 19 17:45:42 2005
New Revision: 18761

Added:
   pypy/dist/pypy/rpython/ootypesystem/test/test_oopbc.py
Modified:
   pypy/dist/pypy/rpython/ootypesystem/rclass.py
   pypy/dist/pypy/rpython/ootypesystem/test/test_ooclean.py
Log:
Two tests that pass with a minor fix.


Modified: pypy/dist/pypy/rpython/ootypesystem/rclass.py
==============================================================================
--- pypy/dist/pypy/rpython/ootypesystem/rclass.py	(original)
+++ pypy/dist/pypy/rpython/ootypesystem/rclass.py	Wed Oct 19 17:45:42 2005
@@ -185,8 +185,7 @@
         elif mangled in self.allclassattributes:
             # class attributes
             if hop.s_result.is_constant():
-                oovalue = hop.r_result.convert_const(hop.s_result.const)
-                return hop.inputconst(hop.r_result, oovalue)
+                return hop.inputconst(hop.r_result, hop.s_result.const)
             else:
                 cname = hop.inputconst(ootype.Void, mangled)
                 return hop.genop("oosend", [cname, v_inst],

Modified: pypy/dist/pypy/rpython/ootypesystem/test/test_ooclean.py
==============================================================================
--- pypy/dist/pypy/rpython/ootypesystem/test/test_ooclean.py	(original)
+++ pypy/dist/pypy/rpython/ootypesystem/test/test_ooclean.py	Wed Oct 19 17:45:42 2005
@@ -311,6 +311,15 @@
     res = interpret(g, [1], type_system='ootype')
     assert res is True
 
+def test_staticmethod():
+    class A(object):
+        f = staticmethod(lambda x, y: x*y)
+    def f():
+        a = A()
+        return a.f(6, 7)
+    res = interpret(f, [], type_system='ootype')
+    assert res == 42
+
 def test_instance_comparison():
     def f(flag):
         a = Subclass()

Added: pypy/dist/pypy/rpython/ootypesystem/test/test_oopbc.py
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/rpython/ootypesystem/test/test_oopbc.py	Wed Oct 19 17:45:42 2005
@@ -0,0 +1,19 @@
+from pypy.rpython.ootypesystem import ootype
+from pypy.rpython.test.test_llinterp import interpret
+import py
+
+def test_function_pointer():
+    def g1():
+        return 111
+    def g2():
+        return 222
+    def f(flag):
+        if flag:
+            g = g1
+        else:
+            g = g2
+        return g() - 1
+    res = interpret(f, [True], type_system='ootype')
+    assert res == 110
+    res = interpret(f, [False], type_system='ootype')
+    assert res == 221



More information about the Pypy-commit mailing list