Commits

Armin Rigo committed 41a4884

Add three tests, one of which fails.

Comments (0)

Files changed (2)

rpython/jit/backend/test/runner_test.py

             p = rawstorage.alloc_raw_storage(31)
             for i in range(31):
                 p[i] = '\xDD'
-            value = rffi.cast(T, 0x4243444546474849)
+            value = rffi.cast(T, -0x4243444546474849)
             rawstorage.raw_storage_setitem(p, 16, value)
+            got = self.cpu.bh_raw_load_i(rffi.cast(lltype.Signed, p), 16,
+                                         arraydescr)
+            assert got == rffi.cast(lltype.Signed, value)
+            #
             loop = parse(ops, self.cpu, namespace=locals())
             looptoken = JitCellToken()
             self.cpu.compile_loop(loop.inputargs, loop.operations, looptoken)
                 p[i] = '\xDD'
             value = rffi.cast(T, 1.12e20)
             rawstorage.raw_storage_setitem(p, 16, value)
+            got = self.cpu.bh_raw_load_f(rffi.cast(lltype.Signed, p), 16,
+                                         arraydescr)
+            got = longlong.getrealfloat(got)
+            assert got == rffi.cast(lltype.Float, value)
+            #
             loop = parse(ops, self.cpu, namespace=locals())
             looptoken = JitCellToken()
             self.cpu.compile_loop(loop.inputargs, loop.operations, looptoken)

rpython/jit/metainterp/test/test_rawmem.py

                                        'raw_store': 1, 'raw_load': 1,
                                        'finish': 1})
 
+    def test_raw_storage_byte(self):
+        def f():
+            p = alloc_raw_storage(15)
+            raw_storage_setitem(p, 5, rffi.cast(rffi.UCHAR, 254))
+            res = raw_storage_getitem(rffi.UCHAR, p, 5)
+            free_raw_storage(p)
+            return rffi.cast(lltype.Signed, res)
+        res = self.interp_operations(f, [])
+        assert res == 254
+        self.check_operations_history({'call': 2, 'guard_no_exception': 1,
+                                       'raw_store': 1, 'raw_load': 1,
+                                       'finish': 1})
+
 class TestRawMem(RawMemTests, LLJitMixin):
     pass