[pypy-svn] r23277 - pypy/dist/pypy/rpython/test

pedronis at codespeak.net pedronis at codespeak.net
Mon Feb 13 13:45:36 CET 2006


Author: pedronis
Date: Mon Feb 13 13:45:34 2006
New Revision: 23277

Modified:
   pypy/dist/pypy/rpython/test/test_rdict.py
   pypy/dist/pypy/rpython/test/test_rtuple.py
Log:
explicit tests about type erasure. I similar test is failing right now for lists. Working on 
that.



Modified: pypy/dist/pypy/rpython/test/test_rdict.py
==============================================================================
--- pypy/dist/pypy/rpython/test/test_rdict.py	(original)
+++ pypy/dist/pypy/rpython/test/test_rdict.py	Mon Feb 13 13:45:34 2006
@@ -1,4 +1,4 @@
-
+from pypy.translator.translator import TranslationContext
 from pypy.rpython.lltypesystem import lltype 
 from pypy.rpython.test.test_llinterp import interpret 
 from pypy.rpython import rstr, rint, rdict
@@ -526,3 +526,27 @@
         return res1+len(d2)
     res = interpret(f, [])
     assert res == 2
+
+
+def test_type_erase():
+    class A(object):
+        pass
+    class B(object):
+        pass
+
+    def f():
+        return {A(): B()}, {B(): A()}
+
+    t = TranslationContext()
+    s = t.buildannotator().build_types(f, [])
+    rtyper = t.buildrtyper()
+    rtyper.specialize()
+
+    s_AB_dic = s.items[0]
+    s_BA_dic = s.items[1]
+    
+    r_AB_dic = rtyper.getrepr(s_AB_dic)
+    r_BA_dic = rtyper.getrepr(s_AB_dic)
+
+    assert r_AB_dic.lowleveltype == r_BA_dic.lowleveltype
+

Modified: pypy/dist/pypy/rpython/test/test_rtuple.py
==============================================================================
--- pypy/dist/pypy/rpython/test/test_rtuple.py	(original)
+++ pypy/dist/pypy/rpython/test/test_rtuple.py	Mon Feb 13 13:45:34 2006
@@ -1,3 +1,4 @@
+from pypy.translator.translator import TranslationContext
 from pypy.rpython.lltypesystem.lltype import *
 from pypy.rpython.rtuple import *
 from pypy.rpython.rint import signed_repr
@@ -176,3 +177,26 @@
     res = interpret(f, [0])
     assert ''.join(res.super.typeptr.name) == "B\00"
     
+
+def test_type_erase():
+    class A(object):
+        pass
+    class B(object):
+        pass
+
+    def f():
+        return (A(), B()), (B(), A())
+
+    t = TranslationContext()
+    s = t.buildannotator().build_types(f, [])
+    rtyper = t.buildrtyper()
+    rtyper.specialize()
+
+    s_AB_tup = s.items[0]
+    s_BA_tup = s.items[1]
+    
+    r_AB_tup = rtyper.getrepr(s_AB_tup)
+    r_BA_tup = rtyper.getrepr(s_AB_tup)
+
+    assert r_AB_tup.lowleveltype == r_BA_tup.lowleveltype
+



More information about the Pypy-commit mailing list