[pypy-commit] pypy default: Fix tests, now that 'lltype.typeOf(very_large_long)' gives an error

arigo pypy.commits at gmail.com
Fri Jul 29 14:23:55 EDT 2016


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r85917:0cafa40b38a9
Date: 2016-07-29 20:25 +0200
http://bitbucket.org/pypy/pypy/changeset/0cafa40b38a9/

Log:	Fix tests, now that 'lltype.typeOf(very_large_long)' gives an error

diff --git a/pypy/objspace/std/test/test_stdobjspace.py b/pypy/objspace/std/test/test_stdobjspace.py
--- a/pypy/objspace/std/test/test_stdobjspace.py
+++ b/pypy/objspace/std/test/test_stdobjspace.py
@@ -66,17 +66,18 @@
 
     def test_wrap_various_unsigned_types(self):
         import sys
+        from rpython.rlib.rarithmetic import r_uint
         from rpython.rtyper.lltypesystem import lltype, rffi
         space = self.space
         value = sys.maxint * 2
-        x = rffi.cast(lltype.Unsigned, value)
+        x = r_uint(value)
         assert space.eq_w(space.wrap(value), space.wrap(x))
-        x = rffi.cast(rffi.UINTPTR_T, value)
+        x = rffi.cast(rffi.UINTPTR_T, r_uint(value))
         assert x > 0
         assert space.eq_w(space.wrap(value), space.wrap(x))
         value = 60000
-        x = rffi.cast(rffi.USHORT, value)
+        x = rffi.cast(rffi.USHORT, r_uint(value))
         assert space.eq_w(space.wrap(value), space.wrap(x))
         value = 200
-        x = rffi.cast(rffi.UCHAR, value)
+        x = rffi.cast(rffi.UCHAR, r_uint(value))
         assert space.eq_w(space.wrap(value), space.wrap(x))
diff --git a/rpython/jit/backend/x86/test/test_regloc.py b/rpython/jit/backend/x86/test/test_regloc.py
--- a/rpython/jit/backend/x86/test/test_regloc.py
+++ b/rpython/jit/backend/x86/test/test_regloc.py
@@ -147,7 +147,7 @@
             py.test.skip()
 
     def test_reuse_scratch_register(self):
-        base_addr = 0xFEDCBA9876543210
+        base_addr = intmask(0xFEDCBA9876543210)
         cb = LocationCodeBuilder64()
         cb.begin_reuse_scratch_register()
         cb.MOV(ecx, heap(base_addr))
@@ -167,7 +167,7 @@
     # ------------------------------------------------------------
 
     def test_64bit_address_1(self):
-        base_addr = 0xFEDCBA9876543210
+        base_addr = intmask(0xFEDCBA9876543210)
         cb = LocationCodeBuilder64()
         cb.CMP(ecx, AddressLoc(ImmedLoc(0), ImmedLoc(0), 0, base_addr))
         # this case is a CMP_rj
@@ -181,7 +181,7 @@
         assert cb.getvalue() == expected_instructions
 
     def test_64bit_address_2(self):
-        base_addr = 0xFEDCBA9876543210
+        base_addr = intmask(0xFEDCBA9876543210)
         cb = LocationCodeBuilder64()
         cb.MOV(ecx, AddressLoc(ImmedLoc(0), edx, 3, base_addr))
         # this case is a CMP_ra
@@ -195,7 +195,7 @@
         assert cb.getvalue() == expected_instructions
 
     def test_64bit_address_3(self):
-        base_addr = 0xFEDCBA9876543210
+        base_addr = intmask(0xFEDCBA9876543210)
         cb = LocationCodeBuilder64()
         cb.MOV(ecx, AddressLoc(edx, ImmedLoc(0), 0, base_addr))
         # this case is a CMP_rm
@@ -211,7 +211,7 @@
         assert cb.getvalue() == expected_instructions
 
     def test_64bit_address_4(self):
-        base_addr = 0xFEDCBA9876543210
+        base_addr = intmask(0xFEDCBA9876543210)
         cb = LocationCodeBuilder64()
         cb.begin_reuse_scratch_register()
         assert cb._reuse_scratch_register is True
@@ -234,7 +234,7 @@
     # ------------------------------------------------------------
 
     def test_MOV_64bit_constant_into_r11(self):
-        base_constant = 0xFEDCBA9876543210
+        base_constant = intmask(0xFEDCBA9876543210)
         cb = LocationCodeBuilder64()
         cb.MOV(r11, imm(base_constant))
 
@@ -245,7 +245,7 @@
         assert cb.getvalue() == expected_instructions
 
     def test_MOV_64bit_constant_into_rax(self):
-        base_constant = 0xFEDCBA9876543210
+        base_constant = intmask(0xFEDCBA9876543210)
         cb = LocationCodeBuilder64()
         cb.MOV(eax, imm(base_constant))
 
@@ -256,7 +256,7 @@
         assert cb.getvalue() == expected_instructions
 
     def test_MOV_64bit_address_into_r11(self):
-        base_addr = 0xFEDCBA9876543210
+        base_addr = intmask(0xFEDCBA9876543210)
         cb = LocationCodeBuilder64()
         cb.MOV(r11, heap(base_addr))
 
@@ -270,7 +270,7 @@
 
     def test_MOV_immed32_into_64bit_address_1(self):
         immed = -0x01234567
-        base_addr = 0xFEDCBA9876543210
+        base_addr = intmask(0xFEDCBA9876543210)
         cb = LocationCodeBuilder64()
         cb.MOV(AddressLoc(ImmedLoc(0), ImmedLoc(0), 0, base_addr),
                ImmedLoc(immed))
@@ -286,7 +286,7 @@
 
     def test_MOV_immed32_into_64bit_address_2(self):
         immed = -0x01234567
-        base_addr = 0xFEDCBA9876543210
+        base_addr = intmask(0xFEDCBA9876543210)
         cb = LocationCodeBuilder64()
         cb.MOV(AddressLoc(ImmedLoc(0), edx, 3, base_addr),
                ImmedLoc(immed))
@@ -302,7 +302,7 @@
 
     def test_MOV_immed32_into_64bit_address_3(self):
         immed = -0x01234567
-        base_addr = 0xFEDCBA9876543210
+        base_addr = intmask(0xFEDCBA9876543210)
         cb = LocationCodeBuilder64()
         cb.MOV(AddressLoc(edx, ImmedLoc(0), 0, base_addr),
                ImmedLoc(immed))
@@ -320,7 +320,7 @@
 
     def test_MOV_immed32_into_64bit_address_4(self):
         immed = -0x01234567
-        base_addr = 0xFEDCBA9876543210
+        base_addr = intmask(0xFEDCBA9876543210)
         cb = LocationCodeBuilder64()
         cb.MOV(AddressLoc(edx, esi, 2, base_addr), ImmedLoc(immed))
         # this case is a MOV_ai
@@ -339,7 +339,7 @@
 
     def test_MOV_immed64_into_64bit_address_1(self):
         immed = 0x0123456789ABCDEF
-        base_addr = 0xFEDCBA9876543210
+        base_addr = intmask(0xFEDCBA9876543210)
         cb = LocationCodeBuilder64()
         cb.MOV(AddressLoc(ImmedLoc(0), ImmedLoc(0), 0, base_addr),
                ImmedLoc(immed))
@@ -361,7 +361,7 @@
 
     def test_MOV_immed64_into_64bit_address_2(self):
         immed = 0x0123456789ABCDEF
-        base_addr = 0xFEDCBA9876543210
+        base_addr = intmask(0xFEDCBA9876543210)
         cb = LocationCodeBuilder64()
         cb.MOV(AddressLoc(ImmedLoc(0), edx, 3, base_addr),
                ImmedLoc(immed))
@@ -383,7 +383,7 @@
 
     def test_MOV_immed64_into_64bit_address_3(self):
         immed = 0x0123456789ABCDEF
-        base_addr = 0xFEDCBA9876543210
+        base_addr = intmask(0xFEDCBA9876543210)
         cb = LocationCodeBuilder64()
         cb.MOV(AddressLoc(eax, ImmedLoc(0), 0, base_addr),
                ImmedLoc(immed))
@@ -407,7 +407,7 @@
 
     def test_MOV_immed64_into_64bit_address_4(self):
         immed = 0x0123456789ABCDEF
-        base_addr = 0xFEDCBA9876543210
+        base_addr = intmask(0xFEDCBA9876543210)
         cb = LocationCodeBuilder64()
         cb.MOV(AddressLoc(edx, eax, 2, base_addr), ImmedLoc(immed))
         # this case is a MOV_ai
diff --git a/rpython/jit/metainterp/test/test_fficall.py b/rpython/jit/metainterp/test/test_fficall.py
--- a/rpython/jit/metainterp/test/test_fficall.py
+++ b/rpython/jit/metainterp/test/test_fficall.py
@@ -11,7 +11,7 @@
 from rpython.rlib.jit_libffi import (types, CIF_DESCRIPTION, FFI_TYPE_PP,
                                      jit_ffi_call)
 from rpython.rlib.unroll import unrolling_iterable
-from rpython.rlib.rarithmetic import intmask, r_longlong, r_singlefloat
+from rpython.rlib.rarithmetic import intmask, r_longlong, r_singlefloat, r_uint
 from rpython.rlib.longlong2float import float2longlong
 
 def get_description(atypes, rtype):
@@ -230,8 +230,8 @@
 
     def test_handle_unsigned(self):
         self._run([types.ulong], types.ulong,
-                  [rffi.cast(rffi.ULONG, sys.maxint + 91348)],
-                  rffi.cast(rffi.ULONG, sys.maxint + 4242))
+                  [rffi.cast(rffi.ULONG, r_uint(sys.maxint + 91348))],
+                  rffi.cast(rffi.ULONG, r_uint(sys.maxint + 4242)))
 
     def test_handle_unsignedchar(self):
         self._run([types.uint8], types.uint8,


More information about the pypy-commit mailing list