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

arigo at codespeak.net arigo at codespeak.net
Mon Apr 3 17:04:18 CEST 2006


Author: arigo
Date: Mon Apr  3 17:04:17 2006
New Revision: 25258

Modified:
   pypy/dist/pypy/rpython/rpbc.py
   pypy/dist/pypy/rpython/test/test_rpbc.py
Log:
Converting None pbcs to Multiple pbcs (getting the test right is fun).


Modified: pypy/dist/pypy/rpython/rpbc.py
==============================================================================
--- pypy/dist/pypy/rpython/rpbc.py	(original)
+++ pypy/dist/pypy/rpython/rpbc.py	Mon Apr  3 17:04:17 2006
@@ -558,12 +558,13 @@
         return pair(r_from.r_im_self, r_to.r_im_self).convert_from_to(v, llops)
 
 # __ None ____________________________________________________
-class NoneFrozenPBCRepr(SingleFrozenPBCRepr):
-    
+class NoneFrozenPBCRepr(Repr):
+    lowleveltype = Void
+
     def rtype_is_true(self, hop):
         return Constant(False, Bool)
 
-none_frozen_pbc_repr = NoneFrozenPBCRepr(None)
+none_frozen_pbc_repr = NoneFrozenPBCRepr()
 
 
 class __extend__(pairtype(Repr, NoneFrozenPBCRepr)):
@@ -582,11 +583,6 @@
     def rtype_is_((rnone1, robj2), hop):
         return hop.rtyper.type_system.rpbc.rtype_is_None(
                                                 robj2, rnone1, hop, pos=1)
-        
-class __extend__(pairtype(NoneFrozenPBCRepr, robject.PyObjRepr)):
-
-    def convert_from_to(_, v, llops):
-        return inputconst(robject.pyobj_repr, None)
 
 # ____________________________________________________________
 

Modified: pypy/dist/pypy/rpython/test/test_rpbc.py
==============================================================================
--- pypy/dist/pypy/rpython/test/test_rpbc.py	(original)
+++ pypy/dist/pypy/rpython/test/test_rpbc.py	Mon Apr  3 17:04:17 2006
@@ -1180,6 +1180,22 @@
         res = interpret(f, [], type_system=self.ts)
         assert res == 165 * 1066
 
+    def test_convert_none_to_frozen_pbc(self):
+        fr1 = Freezing(); fr1.x = 65
+        fr2 = Freezing(); fr2.y = 65
+        def g(fr):
+            return fr.x
+        def identity(z):
+            return z
+        def f(n):  # NB. this crashes with n == 0
+            if n == 0:
+                fr = identity(None)
+            else:
+                fr = fr1
+            return g(fr)
+        res = interpret(f, [1], type_system=self.ts)
+        assert res == 65
+
 
 def test_call_from_list():
     # Don't test with ootype, since it doesn't support lists in a



More information about the Pypy-commit mailing list