[pypy-svn] r45544 - in pypy/dist/pypy: annotation rpython/ootypesystem/test

antocuni at codespeak.net antocuni at codespeak.net
Wed Aug 8 11:22:54 CEST 2007


Author: antocuni
Date: Wed Aug  8 11:22:53 2007
New Revision: 45544

Modified:
   pypy/dist/pypy/annotation/bookkeeper.py
   pypy/dist/pypy/rpython/ootypesystem/test/test_ooann.py
   pypy/dist/pypy/rpython/ootypesystem/test/test_oortype.py
Log:
(antocuni, with moral support from fijal :-))

handle correctly ootype._record pbcs



Modified: pypy/dist/pypy/annotation/bookkeeper.py
==============================================================================
--- pypy/dist/pypy/annotation/bookkeeper.py	(original)
+++ pypy/dist/pypy/annotation/bookkeeper.py	Wed Aug  8 11:22:53 2007
@@ -408,6 +408,8 @@
             result = SomeOOClass(x._INSTANCE)   # NB. can be None
         elif isinstance(x, ootype.instance_impl): # XXX
             result = SomeOOInstance(ootype.typeOf(x))
+        elif isinstance(x, ootype._record):
+            result = SomeOOInstance(ootype.typeOf(x))
         elif callable(x):
             if hasattr(x, '__self__') and x.__self__ is not None:
                 # for cases like 'l.append' where 'l' is a global constant list

Modified: pypy/dist/pypy/rpython/ootypesystem/test/test_ooann.py
==============================================================================
--- pypy/dist/pypy/rpython/ootypesystem/test/test_ooann.py	(original)
+++ pypy/dist/pypy/rpython/ootypesystem/test/test_ooann.py	Wed Aug  8 11:22:53 2007
@@ -149,6 +149,18 @@
 
     assert s == annmodel.SomeOOInstance(C1)
 
+def test_record():
+    R = Record({'foo': Signed})
+    r = new(R)
+    
+    def oof():
+        return r
+
+    a = RPythonAnnotator()
+    s = a.build_types(oof, [])
+    assert isinstance(s, annmodel.SomeOOInstance)
+    assert s.ootype == R
+
 def test_static_method():
     F = StaticMethod([Signed, Signed], Signed)
     def f_(a, b):

Modified: pypy/dist/pypy/rpython/ootypesystem/test/test_oortype.py
==============================================================================
--- pypy/dist/pypy/rpython/ootypesystem/test/test_oortype.py	(original)
+++ pypy/dist/pypy/rpython/ootypesystem/test/test_oortype.py	Wed Aug  8 11:22:53 2007
@@ -288,3 +288,14 @@
     def fn():
         return Bar()
     py.test.raises(AssertionError, gengraph, fn, mangle=False)
+
+def test_pbc_record():
+    R = Record({'foo': Signed})
+    r = new(R)
+    r.foo = 42
+
+    def oof():
+        return r.foo
+    
+    res = interpret(oof, [], type_system='ootype')
+    assert res == 42



More information about the Pypy-commit mailing list