[pypy-svn] r66908 - in pypy/branch/pyjitpl5/pypy/jit/backend: test x86

fijal at codespeak.net fijal at codespeak.net
Tue Aug 18 16:23:41 CEST 2009


Author: fijal
Date: Tue Aug 18 16:23:40 2009
New Revision: 66908

Modified:
   pypy/branch/pyjitpl5/pypy/jit/backend/test/runner_test.py
   pypy/branch/pyjitpl5/pypy/jit/backend/x86/runner.py
Log:
(pedronis, fijal)
* Add a real test for sort_key
* Remove dead code


Modified: pypy/branch/pyjitpl5/pypy/jit/backend/test/runner_test.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/backend/test/runner_test.py	(original)
+++ pypy/branch/pyjitpl5/pypy/jit/backend/test/runner_test.py	Tue Aug 18 16:23:40 2009
@@ -797,6 +797,14 @@
         assert isinstance(z, BoxPtr)
         assert z.value == x.value
 
+    def test_sorting_of_fields(self):
+        S = self.S
+        value = self.cpu.fielddescrof(S, 'value').sort_key()
+        chr1 = self.cpu.fielddescrof(S, 'chr1').sort_key()
+        chr2 = self.cpu.fielddescrof(S, 'chr2').sort_key()
+        assert (sorted([chr2, chr1, value]) ==
+                [value, chr1, chr2])
+        assert len(dict.fromkeys([value, chr1, chr2]).keys()) == 3
 
 class OOtypeBackendTest(BaseBackendTest):
 

Modified: pypy/branch/pyjitpl5/pypy/jit/backend/x86/runner.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/backend/x86/runner.py	(original)
+++ pypy/branch/pyjitpl5/pypy/jit/backend/x86/runner.py	Tue Aug 18 16:23:40 2009
@@ -27,15 +27,6 @@
         self.v1 = v1
         self.flag2 = flag2
 
-    def _v(self):
-        l = []
-        for i in (self.v0, self.v1, self.flag2):
-            if isinstance(i, Symbolic):
-                l.append(id(i))
-            else:
-                l.append(i)
-        return tuple(l)
-
     def sort_key(self):
         return self.v0    # the ofs field for fielddescrs
 
@@ -45,15 +36,9 @@
     def is_array_of_pointers(self):
         return self.flag2     # for arraydescrs
 
-    def equals(self, other):
-        if not isinstance(other, ConstDescr3):
-            return False
-        return self.sort_key() == other.sort_key()
-
     def __repr__(self):
         return '<ConstDescr3 %s, %s, %s>' % (self.v0, self.v1, self.flag2)
 
-
 def _check_addr_range(x):
     if sys.platform == 'linux2':
         # this makes assumption about address ranges that are valid
@@ -561,7 +546,9 @@
             pass
         ofs, size = symbolic.get_field_token(S, fieldname,
                                              self.translate_support_code)
-        assert rffi.sizeof(getattr(S, fieldname)) in [1, 2, WORD]
+        exp_size = rffi.sizeof(getattr(S, fieldname))
+        if type(exp_size) is int:
+            assert exp_size in [1, 2, WORD]
         if (isinstance(getattr(S, fieldname), lltype.Ptr) and
             getattr(S, fieldname).TO._gckind == 'gc'):
             ptr = True



More information about the Pypy-commit mailing list