Author: Ronan Lamy <[email protected]>
Branch: kill-ootype
Changeset: r65233:ad923d70cccc
Date: 2013-07-06 17:40 +0200
http://bitbucket.org/pypy/pypy/changeset/ad923d70cccc/

Log:    Kill rpython.rtyper.test.tool.OORtypeMixin and .LLRtypeMixin

        Update some rlib tests

diff --git a/rpython/rlib/rstruct/test/test_runpack.py 
b/rpython/rlib/rstruct/test/test_runpack.py
--- a/rpython/rlib/rstruct/test/test_runpack.py
+++ b/rpython/rlib/rstruct/test/test_runpack.py
@@ -1,9 +1,9 @@
-from rpython.rtyper.test.tool import BaseRtypingTest, LLRtypeMixin, 
OORtypeMixin
+from rpython.rtyper.test.tool import BaseRtypingTest
 from rpython.rlib.rstruct.runpack import runpack
 from rpython.rlib.rarithmetic import LONG_BIT
 import struct
 
-class BaseTestRStruct(BaseRtypingTest):
+class TestRStruct(BaseRtypingTest):
     def test_unpack(self):
         pad = '\x00' * (LONG_BIT//8-1)    # 3 or 7 null bytes
         def fn():
@@ -37,9 +37,3 @@
             return runpack(">d", "testtest")
         assert fn() == struct.unpack(">d", "testtest")[0]
         assert self.interpret(fn, []) == struct.unpack(">d", "testtest")[0]
-
-class TestLLType(BaseTestRStruct, LLRtypeMixin):
-    pass
-
-class TestOOType(BaseTestRStruct, OORtypeMixin):
-    pass
diff --git a/rpython/rlib/test/test__jit_vref.py 
b/rpython/rlib/test/test__jit_vref.py
--- a/rpython/rlib/test/test__jit_vref.py
+++ b/rpython/rlib/test/test__jit_vref.py
@@ -9,7 +9,7 @@
 from rpython.rtyper.ootypesystem.rclass import OBJECT
 from rpython.rtyper.lltypesystem import lltype
 
-from rpython.rtyper.test.tool import BaseRtypingTest, LLRtypeMixin, 
OORtypeMixin
+from rpython.rtyper.test.tool import BaseRtypingTest
 
 from rpython.rtyper.ootypesystem import ootype
 
@@ -91,7 +91,11 @@
     assert s.s_instance.can_be_None
     assert s.s_instance.classdef == a.bookkeeper.getuniqueclassdef(X)
 
-class BaseTestVRef(BaseRtypingTest):
+class TestVRef(BaseRtypingTest):
+    OBJECTTYPE = OBJECTPTR
+    def castable(self, TO, var):
+        return lltype.castable(TO, lltype.typeOf(var)) > 0
+
     def test_rtype_1(self):
         def f():
             return virtual_ref(X())
@@ -144,14 +148,3 @@
             return vref.virtual
         x = self.interpret(f, [])
         assert x is False
-
-
-class TestLLtype(BaseTestVRef, LLRtypeMixin):
-    OBJECTTYPE = OBJECTPTR
-    def castable(self, TO, var):
-        return lltype.castable(TO, lltype.typeOf(var)) > 0
-
-class TestOOtype(BaseTestVRef, OORtypeMixin):
-    OBJECTTYPE = OBJECT 
-    def castable(self, TO, var):
-        return ootype.isSubclass(lltype.typeOf(var), TO)
diff --git a/rpython/rlib/test/test_debug.py b/rpython/rlib/test/test_debug.py
--- a/rpython/rlib/test/test_debug.py
+++ b/rpython/rlib/test/test_debug.py
@@ -11,14 +11,14 @@
 def test_check_annotation():
     class Error(Exception):
         pass
-    
+
     def checker(ann, bk):
         from rpython.annotator.model import SomeList, SomeInteger
         if not isinstance(ann, SomeList):
             raise Error()
         if not isinstance(ann.listdef.listitem.s_value, SomeInteger):
             raise Error()
-    
+
     def f(x):
         result = [x]
         check_annotation(result, checker)
@@ -50,7 +50,7 @@
         result.append(4)
         return len(result)
 
-    py.test.raises(ListChangeUnallowed, interpret, f, [], 
+    py.test.raises(ListChangeUnallowed, interpret, f, [],
                    list_comprehension_operations=True)
 
 def test_mark_dict_non_null():
@@ -98,11 +98,5 @@
                 ]),
             ]
 
-
-class TestLLType(DebugTests):
     def interpret(self, f, args):
         return interpret(f, args, type_system='lltype')
-
-class TestOOType(DebugTests):
-    def interpret(self, f, args):
-        return interpret(f, args, type_system='ootype')
diff --git a/rpython/rlib/test/test_jit.py b/rpython/rlib/test/test_jit.py
--- a/rpython/rlib/test/test_jit.py
+++ b/rpython/rlib/test/test_jit.py
@@ -5,7 +5,7 @@
 from rpython.rlib.jit import (hint, we_are_jitted, JitDriver, elidable_promote,
     JitHintError, oopspec, isconstant)
 from rpython.rlib.rarithmetic import r_uint
-from rpython.rtyper.test.tool import BaseRtypingTest, LLRtypeMixin, 
OORtypeMixin
+from rpython.rtyper.test.tool import BaseRtypingTest
 from rpython.rtyper.lltypesystem import lltype
 
 
@@ -73,9 +73,9 @@
     assert driver2.foo == 'bar'
     driver.foo = 'xxx'
     assert driver2.foo == 'bar'
-    
 
-class BaseTestJIT(BaseRtypingTest):
+
+class TestJIT(BaseRtypingTest):
     def test_hint(self):
         def f():
             x = hint(5, hello="world")
@@ -109,11 +109,11 @@
             return func + 1
         def f(x):
             return g(x * 2, x)
-        
+
         import dis
         from StringIO import StringIO
         import sys
-        
+
         s = StringIO()
         prev = sys.stdout
         sys.stdout = s
@@ -131,9 +131,9 @@
         assert res == 5
 
     def test_annotate_hooks(self):
-        
+
         def get_printable_location(m): pass
-        
+
         myjitdriver = JitDriver(greens=['m'], reds=['n'],
                                 get_printable_location=get_printable_location)
         def fn(n):
@@ -247,10 +247,3 @@
         # this used to fail on 64-bit, because r_uint == r_ulonglong
         myjitdriver = JitDriver(greens=['i1'], reds=[])
         myjitdriver.jit_merge_point(i1=r_uint(42))
-
-
-class TestJITLLtype(BaseTestJIT, LLRtypeMixin):
-    pass
-
-class TestJITOOtype(BaseTestJIT, OORtypeMixin):
-    pass
diff --git a/rpython/rlib/test/test_nonconst.py 
b/rpython/rlib/test/test_nonconst.py
--- a/rpython/rlib/test/test_nonconst.py
+++ b/rpython/rlib/test/test_nonconst.py
@@ -17,8 +17,6 @@
     s = a.build_types(nonconst_f, [])
     assert s.knowntype is int
     assert not hasattr(s, 'const')
-    #rtyper = a.translator.buildrtyper(type_system="ootype")
-    #rtyper.specialize()
 
 
 def test_nonconst_list():
@@ -41,8 +39,6 @@
 
     a = RPythonAnnotator()
     s = a.build_types(nonconst_i, [])
-    rtyper = a.translator.buildrtyper(type_system="ootype")
-    rtyper.specialize()
     if option.view:
         a.translator.view()
     assert isinstance(s, SomeInstance)
@@ -58,7 +54,5 @@
     assert s.knowntype is bool
     assert not hasattr(s, 'const')
 
-    rtyper = a.translator.buildrtyper(type_system="ootype")
-    rtyper.specialize()
     if option.view:
         a.translator.view()
diff --git a/rpython/rlib/test/test_objectmodel.py 
b/rpython/rlib/test/test_objectmodel.py
--- a/rpython/rlib/test/test_objectmodel.py
+++ b/rpython/rlib/test/test_objectmodel.py
@@ -3,7 +3,7 @@
 from rpython.rlib import types
 from rpython.annotator import model
 from rpython.translator.translator import TranslationContext, graphof
-from rpython.rtyper.test.tool import BaseRtypingTest, LLRtypeMixin, 
OORtypeMixin
+from rpython.rtyper.test.tool import BaseRtypingTest
 from rpython.rtyper.test.test_llinterp import interpret
 from rpython.conftest import option
 
@@ -54,13 +54,13 @@
         assert x == 42
         count += 1
     assert count == 1
-        
+
     count = 0
     for x in d.iteritems():
         assert len(x) == 2 and x[0] == 'hello' and x[1] == 42
         count += 1
     assert count == 1
-        
+
     d.clear()
     assert d.keys() == []
     return True   # for the tests below
@@ -189,7 +189,7 @@
     foo = Foo()
     assert current_object_addr_as_int(foo) == intmask(id(foo))
 
-class BaseTestObjectModel(BaseRtypingTest):
+class TestObjectModel(BaseRtypingTest):
 
     def test_we_are_translated(self):
         assert we_are_translated() == False
@@ -198,7 +198,7 @@
             return we_are_translated()
         res = self.interpret(fn, [])
         assert res is True
-    
+
     def test_rtype_r_dict(self):
         res = self.interpret(test_r_dict, [])
         assert res is True
@@ -239,7 +239,7 @@
             def _freeze_(self):
                 return True
         obj = FreezingClass()
-        pbc_d = r_dict(obj.key_eq, obj.key_hash)        
+        pbc_d = r_dict(obj.key_eq, obj.key_hash)
         def fn():
             return play_with_r_dict(pbc_d)
         assert self.interpret(fn, []) is True
@@ -356,8 +356,6 @@
 
         assert self.interpret(fn, [15]) == 11
 
-class TestLLtype(BaseTestObjectModel, LLRtypeMixin):
-
     def test_rtype_keepalive(self):
         from rpython.rlib import objectmodel
         def f():
@@ -395,21 +393,17 @@
         h_None     = compute_hash(None)
         h_tuple    = compute_hash(("world", None, 42, 7.5))
         h_q        = compute_hash(q)
-        
+
         res = self.interpret(f, [42])
         assert res == 84
 
 
-class TestOOtype(BaseTestObjectModel, OORtypeMixin):
-    pass
-
-
 def test_specialize_decorator():
     def f():
         pass
 
     specialize.memo()(f)
-    
+
     assert f._annspecialcase_ == 'specialize:memo'
 
     specialize.arg(0)(f)
@@ -432,7 +426,7 @@
     exc = py.test.raises(TypeError, "f(1, 2, 3)")
     assert exc.value.message == "f argument 'b' must be of type <type 'str'>"
     py.test.raises(TypeError, "f('hello', 'world', 3)")
-    
+
 
 def test_enforceargs_defaults():
     @enforceargs(int, int)
@@ -529,7 +523,7 @@
         if llop.opname == 'malloc_varsize':
             break
     assert llop.args[2] is graph.startblock.inputargs[0]
-    
+
 def test_resizelist_hint():
     from rpython.annotator.model import SomeInteger
     def f(z):
diff --git a/rpython/rlib/test/test_rarithmetic.py 
b/rpython/rlib/test/test_rarithmetic.py
--- a/rpython/rlib/test/test_rarithmetic.py
+++ b/rpython/rlib/test/test_rarithmetic.py
@@ -1,4 +1,4 @@
-from rpython.rtyper.test.tool import BaseRtypingTest, LLRtypeMixin, 
OORtypeMixin
+from rpython.rtyper.test.tool import BaseRtypingTest
 from rpython.rtyper.test.test_llinterp import interpret
 from rpython.rlib.rarithmetic import *
 from rpython.rlib.rstring import ParseStringError, ParseStringOverflowError
@@ -68,7 +68,7 @@
                     left, right = types
                     cmp = f(left(larg), right(rarg))
                     assert res == cmp
-                    
+
 class Test_r_uint:
     def test__add__(self):
         self.binary_test(lambda x, y: x + y)
@@ -115,12 +115,12 @@
 
     def unary_test(self, f):
         for arg in (0, 3, 12345):
-            res = f(arg) & maxint_mask 
+            res = f(arg) & maxint_mask
             cmp = f(r_uint(arg))
             assert res == cmp
 
     def binary_test(self, f, rargs = None, translated=False):
-        mask = maxint_mask 
+        mask = maxint_mask
         if not rargs:
             rargs = (1, 3, 55)
         # when translated merging different int types is not allowed
@@ -178,7 +178,7 @@
     assert intmask(2*sys.maxint+1) == -1
     assert intmask(sys.maxint*2) == -2
     assert intmask(sys.maxint*2+2) == 0
-    assert intmask(2*(sys.maxint*1+1)) == 0    
+    assert intmask(2*(sys.maxint*1+1)) == 0
     assert intmask(1 << (machbits-1)) == 1 << (machbits-1)
     assert intmask(sys.maxint+1) == minint
     assert intmask(minint-1) == sys.maxint
@@ -229,13 +229,13 @@
     except OverflowError:
         assert False
     else:
-        pass        
+        pass
     try:
         ovfcheck(n-n)
     except OverflowError:
         assert False
     else:
-        pass    
+        pass
 
     # overflowing
     try:
@@ -313,7 +313,7 @@
     assert x != 2.5
     py.test.raises(TypeError, "x>y")
 
-class BaseTestRarithmetic(BaseRtypingTest):
+class TestRarithmetic(BaseRtypingTest):
     def test_compare_singlefloat_crashes(self):
         from rpython.rlib.rarithmetic import r_singlefloat
         from rpython.rtyper.error import MissingRTypeOperation
@@ -332,11 +332,6 @@
         res = self.interpret(f, [123])
         assert res == 4 + 2
 
-class TestLLtype(BaseTestRarithmetic, LLRtypeMixin):
-    pass
-
-class TestOOtype(BaseTestRarithmetic, OORtypeMixin):
-    pass
 
 def test_int_real_union():
     from rpython.rtyper.lltypesystem.rffi import r_int_real
diff --git a/rpython/rlib/test/test_rerased.py 
b/rpython/rlib/test/test_rerased.py
--- a/rpython/rlib/test/test_rerased.py
+++ b/rpython/rlib/test/test_rerased.py
@@ -10,7 +10,7 @@
 from rpython.rtyper.ootypesystem.rclass import OBJECT
 from rpython.rtyper.lltypesystem import lltype, llmemory
 
-from rpython.rtyper.test.tool import BaseRtypingTest, LLRtypeMixin, 
OORtypeMixin
+from rpython.rtyper.test.tool import BaseRtypingTest
 
 def make_annotator():
     a = RPythonAnnotator()
@@ -186,6 +186,11 @@
     assert isinstance(s, annmodel.SomeInteger)
 
 class BaseTestRErased(BaseRtypingTest):
+    ERASED_TYPE = llmemory.GCREF
+    UNERASED_TYPE = OBJECTPTR
+    def castable(self, TO, var):
+        return lltype.castable(TO, lltype.typeOf(var)) > 0
+
     def interpret(self, *args, **kwargs):
         kwargs["taggedpointers"] = True
         return BaseRtypingTest.interpret(self, *args, **kwargs)
@@ -296,23 +301,6 @@
         self.interpret(l, [1])
         self.interpret(l, [2])
 
-class TestLLtype(BaseTestRErased, LLRtypeMixin):
-    ERASED_TYPE = llmemory.GCREF
-    UNERASED_TYPE = OBJECTPTR
-    def castable(self, TO, var):
-        return lltype.castable(TO, lltype.typeOf(var)) > 0
-
-from rpython.rtyper.ootypesystem.ootype import Object
-
-class TestOOtype(BaseTestRErased, OORtypeMixin):
-    ERASED_TYPE = Object
-    UNERASED_TYPE = OBJECT
-    def castable(self, TO, var):
-        return ootype.isSubclass(lltype.typeOf(var), TO)
-    @py.test.mark.xfail
-    def test_prebuilt_erased(self):
-        super(TestOOtype, self).test_prebuilt_erased()
-
 def test_union():
     s_e1 = SomeErased()
     s_e1.const = 1
diff --git a/rpython/rlib/test/test_rsocket.py 
b/rpython/rlib/test/test_rsocket.py
--- a/rpython/rlib/test/test_rsocket.py
+++ b/rpython/rlib/test/test_rsocket.py
@@ -1,7 +1,6 @@
 import py, errno, sys
 from rpython.rlib import rsocket
 from rpython.rlib.rsocket import *
-from rpython.rtyper.test.tool import BaseRtypingTest, LLRtypeMixin, 
OORtypeMixin
 import socket as cpy_socket
 
 # cannot test error codes in Win32 because ll2ctypes doesn't save
diff --git a/rpython/rlib/test/test_rzipfile.py 
b/rpython/rlib/test/test_rzipfile.py
--- a/rpython/rlib/test/test_rzipfile.py
+++ b/rpython/rlib/test/test_rzipfile.py
@@ -3,7 +3,7 @@
 from rpython.rlib.rzipfile import RZipFile
 from rpython.tool.udir import udir
 from zipfile import ZIP_STORED, ZIP_DEFLATED, ZipInfo, ZipFile
-from rpython.rtyper.test.tool import BaseRtypingTest, LLRtypeMixin, 
OORtypeMixin
+from rpython.rtyper.test.tool import BaseRtypingTest
 import os
 import time
 
@@ -25,9 +25,9 @@
         # Value selected to produce a CRC32 which is negative if
         # interpreted as a signed 32 bit integer.  This exercises the
         # masking behavior necessary on 64 bit platforms.
-        zipfile.writestr("three", "hello, world") 
+        zipfile.writestr("three", "hello, world")
         zipfile.close()
-    
+
     def test_rzipfile(self):
         zipname = self.zipname
         year = self.year
@@ -42,8 +42,8 @@
         assert one()
         assert self.interpret(one, [])
 
-class TestRZipFile(BaseTestRZipFile, LLRtypeMixin):
+class TestRZipFile(BaseTestRZipFile):
     compression = ZIP_STORED
 
-class TestRZipFileCompressed(BaseTestRZipFile, LLRtypeMixin):
+class TestRZipFileCompressed(BaseTestRZipFile):
     compression = ZIP_DEFLATED
diff --git a/rpython/rtyper/test/tool.py b/rpython/rtyper/test/tool.py
--- a/rpython/rtyper/test/tool.py
+++ b/rpython/rtyper/test/tool.py
@@ -1,17 +1,16 @@
 import py
-from rpython.rtyper.ootypesystem import ootype
 from rpython.rtyper.lltypesystem import lltype
 from rpython.rtyper.test.test_llinterp import gengraph, interpret, 
interpret_raises
 
 class BaseRtypingTest(object):
-
+    type_system = 'lltype'
     FLOAT_PRECISION = 8
 
     def gengraph(self, func, argtypes=[], viewbefore='auto', policy=None,
              backendopt=False, config=None):
         return gengraph(func, argtypes, viewbefore, policy, 
type_system=self.type_system,
                         backendopt=backendopt, config=config)
-    
+
     def interpret(self, fn, args, **kwds):
         return interpret(fn, args, type_system=self.type_system, **kwds)
 
@@ -38,12 +37,10 @@
 
     def _skip_llinterpreter(self, reason, skipLL=True, skipOO=True):
         if skipLL and self.type_system == 'lltype':
-            py.test.skip("lltypesystem doesn't support %s, yet" % reason)      
  
+            py.test.skip("lltypesystem doesn't support %s, yet" % reason)
         if skipOO and self.type_system == 'ootype':
-            py.test.skip("ootypesystem doesn't support %s, yet" % reason)    
+            py.test.skip("ootypesystem doesn't support %s, yet" % reason)
 
-class LLRtypeMixin(object):
-    type_system = 'lltype'
 
     def ll_to_string(self, s):
         if not s:
@@ -54,11 +51,11 @@
         return u''.join(s.chars)
 
     def string_to_ll(self, s):
-        from rpython.rtyper.module.support import LLSupport        
+        from rpython.rtyper.module.support import LLSupport
         return LLSupport.to_rstr(s)
 
     def unicode_to_ll(self, s):
-        from rpython.rtyper.module.support import LLSupport        
+        from rpython.rtyper.module.support import LLSupport
         return LLSupport.to_runicode(s)
 
     def ll_to_list(self, l):
@@ -90,42 +87,3 @@
     def is_of_instance_type(self, val):
         T = lltype.typeOf(val)
         return isinstance(T, lltype.Ptr) and isinstance(T.TO, lltype.GcStruct)
-
-
-class OORtypeMixin(object):
-    type_system = 'ootype'
-
-    def ll_to_string(self, s):
-        return s._str
-
-    ll_to_unicode = ll_to_string
-
-    def string_to_ll(self, s):
-        from rpython.rtyper.module.support import OOSupport        
-        return OOSupport.to_rstr(s)
-
-    def unicode_to_ll(self, u):
-        from rpython.rtyper.module.support import OOSupport
-        return OOSupport.to_runicode(u)
-
-    def ll_to_list(self, l):
-        if hasattr(l, '_list'):
-            return l._list[:]
-        return l._array[:]
-
-    def ll_unpack_tuple(self, t, length):
-        return tuple([getattr(t, 'item%d' % i) for i in range(length)])
-
-    def get_callable(self, sm):
-        return sm._callable
-
-    def class_name(self, value):
-        return ootype.dynamicType(value)._name.split(".")[-1] 
-
-    def read_attr(self, value, attr):
-        value = ootype.oodowncast(ootype.dynamicType(value), value)
-        return getattr(value, "o" + attr)
-
-    def is_of_instance_type(self, val):
-        T = lltype.typeOf(val)
-        return isinstance(T, ootype.Instance)
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to