[pypy-svn] r20304 - pypy/branch/somepbc-refactoring/pypy/rpython/test

pedronis at codespeak.net pedronis at codespeak.net
Sun Nov 27 04:09:00 CET 2005


Author: pedronis
Date: Sun Nov 27 04:08:58 2005
New Revision: 20304

Modified:
   pypy/branch/somepbc-refactoring/pypy/rpython/test/test_llann.py
   pypy/branch/somepbc-refactoring/pypy/rpython/test/test_rtyper.py
Log:
fixes for test_rtyper.

7 failures left of tests under rpython/test/




Modified: pypy/branch/somepbc-refactoring/pypy/rpython/test/test_llann.py
==============================================================================
--- pypy/branch/somepbc-refactoring/pypy/rpython/test/test_llann.py	(original)
+++ pypy/branch/somepbc-refactoring/pypy/rpython/test/test_llann.py	Sun Nov 27 04:08:58 2005
@@ -161,6 +161,7 @@
         seen = {}
         ngraphs = len(a.translator.graphs)
 
+        vTs = []
         for call in annotated_calls(a):
             if derived(call, "ll_"):
 
@@ -187,8 +188,11 @@
                     assert a.binding(rv).ll_ptrtype.TO == T
                 else:
                     assert False, func
+                vTs.append(vT)
 
         assert len(seen) == 4
+
+        return a, vTs # reused by a test in test_rtyper
  
     def test_ll_calling_ll2(self):
         A = GcArray(Float)
@@ -224,6 +228,8 @@
             else:
                 return s.ll_ptrtype
         
+        vTs = []
+
         for call in annotated_calls(a):
             if derived(call, "ll_")  or derived(call, "makelen4"):
 
@@ -243,10 +249,12 @@
                     assert a.binding(vT) == a.bookkeeper.immutablevalue(T)
                     assert a.binding(vn).knowntype == int
                     assert a.binding(rv).ll_ptrtype.TO == T
+                    vTs.append(vT)
                 elif func is makelen4:
                     vT, = args
                     assert a.binding(vT) == a.bookkeeper.immutablevalue(T)
                     assert a.binding(rv).ll_ptrtype.TO == T
+                    vTs.append(vT)
                 elif func is ll_get:
                     vp, vi = args
                     assert a.binding(vi).knowntype == int
@@ -258,6 +266,8 @@
 
         assert len(seen) == 5
 
+        return a, vTs # reused by a test in test_rtyper
+
     def test_getRuntimeTypeInfo(self):
         S = GcStruct('s', ('x', Signed))
         attachRuntimeTypeInfo(S)

Modified: pypy/branch/somepbc-refactoring/pypy/rpython/test/test_rtyper.py
==============================================================================
--- pypy/branch/somepbc-refactoring/pypy/rpython/test/test_rtyper.py	(original)
+++ pypy/branch/somepbc-refactoring/pypy/rpython/test/test_rtyper.py	Sun Nov 27 04:08:58 2005
@@ -1,5 +1,6 @@
 from pypy.annotation import model as annmodel
-from pypy.translator.translator import Translator
+from pypy.objspace.flow.model import Constant
+from pypy.translator.translator import Translator, graphof
 from pypy.translator import annrpython
 from pypy.rpython.lltypesystem.lltype import *
 from pypy.rpython.test.test_llinterp import interpret 
@@ -32,7 +33,7 @@
     three.const = 3
     minusone = annmodel.SomeInteger()
     minusone.const = -1
-    none = annmodel.SomePBC({None: True})
+    none = annmodel.s_None
 
     startonly = annmodel.SomeSlice(one, none, none)
     startonly2 = annmodel.SomeSlice(one, none, one)
@@ -79,7 +80,7 @@
     typer.specialize()
     #t.view()
     t.checkgraphs()
-    graph = t.getflowgraph(f)
+    graph = graphof(t, f)
     assert graph.getreturnvar().concretetype == Signed
     assert graph.startblock.exits[0].args[0].concretetype == Signed
 
@@ -92,7 +93,7 @@
     typer.specialize()
     #t.view()
     t.checkgraphs()
-    graph = t.getflowgraph(f)
+    graph = graphof(t, f)
     assert graph.getreturnvar().concretetype == Void
     assert graph.startblock.exits[0].args[0].concretetype == Void
 
@@ -100,14 +101,16 @@
     import test_llann
     tst = test_llann.TestLowLevelAnnotateTestCase()
     a, vTs = tst.test_ll_calling_ll()
-    a.translator.specialize()
+    rt = RPythonTyper(a)
+    rt.specialize()
     assert [vT.concretetype for vT in vTs] == [Void] * 4
 
 def test_ll_calling_ll2():
     import test_llann
     tst = test_llann.TestLowLevelAnnotateTestCase()
     a, vTs = tst.test_ll_calling_ll2()
-    a.translator.specialize()
+    rt = RPythonTyper(a)
+    rt.specialize()
     assert [vT.concretetype for vT in vTs] == [Void] * 3
     
 
@@ -118,16 +121,29 @@
         _alloc_flavor_ = "gc"
     class R:
         _alloc_flavor_ = "nongc"
-    class DummyClsDef:
+
+    NDF = object()
+
+    class DummyClsDescDef:
         def __init__(self, cls):
-            self.cls = cls
+            self._cls = cls
+            self.classdesc = self
 
-    assert rmodel.needsgc(DummyClsDef(A))
-    assert rmodel.needsgc(DummyClsDef(A), nogc=True)
-    assert rmodel.needsgc(DummyClsDef(B))
-    assert rmodel.needsgc(DummyClsDef(B), nogc=True)
-    assert not rmodel.needsgc(DummyClsDef(R))
-    assert not rmodel.needsgc(DummyClsDef(R), nogc=False)
+        def read_attribute(self, attr, default=NDF):
+            try:
+                return Constant(getattr(self._cls, attr))
+            except AttributeError:
+                if default is NDF:
+                    raise
+                else:
+                    return default
+            
+    assert rmodel.needsgc(DummyClsDescDef(A))
+    assert rmodel.needsgc(DummyClsDescDef(A), nogc=True)
+    assert rmodel.needsgc(DummyClsDescDef(B))
+    assert rmodel.needsgc(DummyClsDescDef(B), nogc=True)
+    assert not rmodel.needsgc(DummyClsDescDef(R))
+    assert not rmodel.needsgc(DummyClsDescDef(R), nogc=False)
     assert rmodel.needsgc(None)
     assert rmodel.needsgc(None, nogc=False)
     assert not rmodel.needsgc(None, nogc=True)            



More information about the Pypy-commit mailing list