[pypy-commit] pypy kill-ootype: Fix rpython/rtyper/test/

rlamy noreply at buildbot.pypy.org
Tue Jul 9 03:00:36 CEST 2013


Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: kill-ootype
Changeset: r65272:b41acf2f10bc
Date: 2013-07-07 19:23 +0200
http://bitbucket.org/pypy/pypy/changeset/b41acf2f10bc/

Log:	Fix rpython/rtyper/test/

diff --git a/rpython/rtyper/test/test_llann.py b/rpython/rtyper/test/test_llann.py
--- a/rpython/rtyper/test/test_llann.py
+++ b/rpython/rtyper/test/test_llann.py
@@ -7,7 +7,6 @@
     cast_instance_to_base_ptr, cast_base_ptr_to_instance, base_ptr_lltype)
 from rpython.rtyper.llinterp import LLInterpreter
 from rpython.rtyper.lltypesystem.lltype import *
-from rpython.rtyper.ootypesystem import ootype
 from rpython.rtyper.rclass import fishllattr
 from rpython.rtyper.test.test_llinterp import interpret
 from rpython.translator.translator import TranslationContext
@@ -463,34 +462,6 @@
     res = interpret(h, [8, 5, 2])
     assert res == 99
 
-def test_oohelper():
-    S = ootype.Instance('S', ootype.ROOT, {'x': Signed, 'y': Signed})
-    def f(s,z):
-        #assert we_are_translated()
-        return s.x*s.y+z
-
-    def g(s):
-        #assert we_are_translated()
-        return s.x+s.y
-
-    F = ootype.StaticMethod([S, Signed], Signed)
-    G = ootype.StaticMethod([S], Signed)
-
-    def h(x, y, z):
-        s = ootype.new(S)
-        s.x = x
-        s.y = y
-        fsm = llhelper(F, f)
-        gsm = llhelper(G, g)
-        assert typeOf(fsm) == F
-        return fsm(s, z)+fsm(s, z*2)+gsm(s)
-
-    res = h(8, 5, 2)
-    assert res == 99
-    res = interpret(h, [8, 5, 2], type_system='ootype')
-    assert res == 99
-
-
 
 def test_cast_instance_to_base_ptr():
     class A:
diff --git a/rpython/rtyper/test/test_llinterp.py b/rpython/rtyper/test/test_llinterp.py
--- a/rpython/rtyper/test/test_llinterp.py
+++ b/rpython/rtyper/test/test_llinterp.py
@@ -26,14 +26,14 @@
 
 
 
-def timelog(prefix, call, *args, **kwds): 
+def timelog(prefix, call, *args, **kwds):
     #import time
-    #print prefix, "...", 
+    #print prefix, "...",
     #start = time.time()
-    res = call(*args, **kwds) 
-    #elapsed = time.time() - start 
+    res = call(*args, **kwds)
+    #elapsed = time.time() - start
     #print "%.2f secs" % (elapsed,)
-    return res 
+    return res
 
 def gengraph(func, argtypes=[], viewbefore='auto', policy=None,
              type_system="lltype", backendopt=False, config=None,
@@ -49,9 +49,9 @@
         t.view()
     global typer # we need it for find_exception
     typer = t.buildrtyper(type_system=type_system)
-    timelog("rtyper-specializing", typer.specialize) 
+    timelog("rtyper-specializing", typer.specialize)
     #t.view()
-    timelog("checking graphs", t.checkgraphs) 
+    timelog("checking graphs", t.checkgraphs)
     if backendopt:
         from rpython.translator.backendopt.all import backend_optimizations
         backend_optimizations(t)
@@ -93,9 +93,9 @@
                                    **extraconfigopts)
         interp = LLInterpreter(typer)
         _tcache[key] = (t, interp, graph)
-        # keep the cache small 
-        _lastinterpreted.append(key) 
-        if len(_lastinterpreted) >= 4: 
+        # keep the cache small
+        _lastinterpreted.append(key)
+        if len(_lastinterpreted) >= 4:
             del _tcache[_lastinterpreted.pop(0)]
     if view == 'auto':
         view = getattr(option, 'view', False)
@@ -164,8 +164,6 @@
     assert res == 41
     interpret_raises(IndexError, raise_exception, [42])
     interpret_raises(ValueError, raise_exception, [43])
-    interpret_raises(IndexError, raise_exception, [42], type_system="ootype")
-    interpret_raises(ValueError, raise_exception, [43], type_system="ootype")
 
 def test_call_raise():
     res = interpret(call_raise, [41])
@@ -273,7 +271,7 @@
     print res
     for i in range(3):
         assert res.ll_items()[i] == 3-i
-        
+
 def test_list_pop():
     def f():
         l = [1,2,3]
@@ -485,25 +483,6 @@
     except ValueError:
         raise TypeError
 
-def test_llinterp_fail():
-    def aa(i):
-        if i:
-            raise TypeError()
-    
-    def bb(i):
-        try:
-            aa(i)
-        except TypeError:
-            pass
-    
-    t = TranslationContext()
-    annotator = t.buildannotator()
-    annotator.build_types(bb, [int])
-    t.buildrtyper(type_system="ootype").specialize()
-    graph = graphof(t, bb)
-    interp = LLInterpreter(t.rtyper)
-    res = interp.eval_graph(graph, [1])
-
 def test_half_exceptiontransformed_graphs():
     from rpython.translator import exceptiontransform
     def f1(x):
@@ -581,7 +560,7 @@
             free(t, flavor='raw')
     interpret(f, [1])
     py.test.raises(leakfinder.MallocMismatch, "interpret(f, [0])")
-    
+
     def f():
         t1 = malloc(T, flavor='raw')
         t2 = malloc(T, flavor='raw')
@@ -615,7 +594,7 @@
 def test_scoped_allocator():
     from rpython.rtyper.lltypesystem.lltype import scoped_alloc, Array, Signed
     T = Array(Signed)
-    
+
     def f():
         x = 0
         with scoped_alloc(T, 1) as array:
@@ -630,12 +609,12 @@
 
     def external():
         pass
-    
+
     def raising():
         raise OSError(15, "abcd")
-    
+
     ext = register_external(external, [], llimpl=raising, llfakeimpl=raising)
-    
+
     def f():
         # this is a useful llfakeimpl that raises an exception
         try:
diff --git a/rpython/rtyper/test/test_ootype_llinterp.py b/rpython/rtyper/test/test_ootype_llinterp.py
deleted file mode 100644
--- a/rpython/rtyper/test/test_ootype_llinterp.py
+++ /dev/null
@@ -1,28 +0,0 @@
-from rpython.rtyper.ootypesystem.ootype import *
-from rpython.rtyper.test.test_llinterp import interpret
-
-def test_simple_field():
-    C = Instance("test", ROOT, {'a': (Signed, 3)})
-    
-    def f():
-        c = new(C)
-        c.a = 5
-        return c.a
-
-    result = interpret(f, [], type_system="ootype")
-    assert result == 5
-
-def test_simple_method():
-    C = Instance("test", ROOT, {'a': (Signed, 3)})
-    M = Meth([], Signed)
-    def m_(self):
-       return self.a
-    m = meth(M, _name="m", _callable=m_)
-    addMethods(C, {"m": m})
-    
-    def f():
-        c = new(C)
-        return c.m()
-
-    result = interpret(f, [], type_system="ootype")
-    assert result == 3
diff --git a/rpython/rtyper/test/test_rtyper.py b/rpython/rtyper/test/test_rtyper.py
--- a/rpython/rtyper/test/test_rtyper.py
+++ b/rpython/rtyper/test/test_rtyper.py
@@ -115,21 +115,3 @@
     assert rmodel.getgcflavor(DummyClsDescDef(A)) == 'gc'
     assert rmodel.getgcflavor(DummyClsDescDef(B)) == 'gc'
     assert rmodel.getgcflavor(DummyClsDescDef(R)) == 'raw'
-
-def test_missing_gvflavor_bug():
-    class MyClass:
-        def set_x(self):
-            self.x = create_tuple()
-    def create_tuple():
-        return MyClass(), 42
-    def fn():
-        obj = MyClass()
-        obj.set_x()
-        create_tuple()
-    t = TranslationContext()
-    t.buildannotator().build_types(fn, [])
-    t.buildrtyper(type_system='ootype').specialize()
-    #t.view()
-    t.checkgraphs()
-    graph = graphof(t, fn)
-    assert graph.getreturnvar().concretetype == Void


More information about the pypy-commit mailing list