[pypy-svn] r65719 - in pypy/branch/pyjitpl5-experiments/pypy/jit/backend: llvm test

arigo at codespeak.net arigo at codespeak.net
Wed Jun 10 13:59:45 CEST 2009


Author: arigo
Date: Wed Jun 10 13:59:45 2009
New Revision: 65719

Modified:
   pypy/branch/pyjitpl5-experiments/pypy/jit/backend/llvm/runner.py
   pypy/branch/pyjitpl5-experiments/pypy/jit/backend/test/runner_test.py
Log:
Tests for Unsigned and Bool.


Modified: pypy/branch/pyjitpl5-experiments/pypy/jit/backend/llvm/runner.py
==============================================================================
--- pypy/branch/pyjitpl5-experiments/pypy/jit/backend/llvm/runner.py	(original)
+++ pypy/branch/pyjitpl5-experiments/pypy/jit/backend/llvm/runner.py	Wed Jun 10 13:59:45 2009
@@ -366,14 +366,14 @@
             else:
                 return self.SIZE_INT
         else:
-            if TYPE == lltype.Signed:
+            if TYPE == lltype.Signed or TYPE == lltype.Unsigned:
                 return self.SIZE_INT
-            elif TYPE == lltype.Char:
+            elif TYPE == lltype.Char or TYPE == lltype.Bool:
                 return self.SIZE_CHAR
             elif TYPE == lltype.UniChar:
                 return self.SIZE_UNICHAR
             else:
-                raise BadSizeError(S, fieldname, size)
+                raise BadSizeError(TYPE)
 
     def sizeof(self, S):
         try:

Modified: pypy/branch/pyjitpl5-experiments/pypy/jit/backend/test/runner_test.py
==============================================================================
--- pypy/branch/pyjitpl5-experiments/pypy/jit/backend/test/runner_test.py	(original)
+++ pypy/branch/pyjitpl5-experiments/pypy/jit/backend/test/runner_test.py	Wed Jun 10 13:59:45 2009
@@ -432,6 +432,48 @@
         r = self.execute_operation(rop.GETARRAYITEM_GC, [b_box, BoxInt(1)],
                                    'ptr', descr=arraydescr)
         assert r.value == a_box.value
+        #
+        # Unsigned should work the same as Signed
+        a_box, A = self.alloc_array_of(lltype.Unsigned, 342)
+        arraydescr = self.cpu.arraydescrof(A)
+        r = self.execute_operation(rop.ARRAYLEN_GC, [a_box],
+                                   'int', descr=arraydescr)
+        assert r.value == 342
+        r = self.execute_operation(rop.SETARRAYITEM_GC, [a_box, BoxInt(310),
+                                                         BoxInt(7441)],
+                                   'void', descr=arraydescr)
+        assert r is None
+        r = self.execute_operation(rop.GETARRAYITEM_GC, [a_box, BoxInt(310)],
+                                   'int', descr=arraydescr)
+        assert r.value == 7441
+        #
+        # Bool should work the same as Char
+        a_box, A = self.alloc_array_of(lltype.Bool, 311)
+        arraydescr = self.cpu.arraydescrof(A)
+        r = self.execute_operation(rop.ARRAYLEN_GC, [a_box],
+                                   'int', descr=arraydescr)
+        assert r.value == 311
+        r = self.execute_operation(rop.SETARRAYITEM_GC, [a_box, BoxInt(304),
+                                                         BoxInt(1)],
+                                   'void', descr=arraydescr)
+        assert r is None
+        r = self.execute_operation(rop.SETARRAYITEM_GC, [a_box, BoxInt(303),
+                                                         BoxInt(0)],
+                                   'void', descr=arraydescr)
+        assert r is None
+        r = self.execute_operation(rop.SETARRAYITEM_GC, [a_box, BoxInt(302),
+                                                         BoxInt(1)],
+                                   'void', descr=arraydescr)
+        assert r is None
+        r = self.execute_operation(rop.GETARRAYITEM_GC, [a_box, BoxInt(304)],
+                                   'int', descr=arraydescr)
+        assert r.value == 1
+        r = self.execute_operation(rop.GETARRAYITEM_GC, [a_box, BoxInt(303)],
+                                   'int', descr=arraydescr)
+        assert r.value == 0
+        r = self.execute_operation(rop.GETARRAYITEM_GC, [a_box, BoxInt(302)],
+                                   'int', descr=arraydescr)
+        assert r.value == 1
 
     def test_string_basic(self):
         s_box = self.alloc_string("hello\xfe")



More information about the Pypy-commit mailing list