[pypy-svn] r14343 - in pypy/dist/pypy/rpython: . test
tismer at codespeak.net
tismer at codespeak.net
Wed Jul 6 16:44:13 CEST 2005
Author: tismer
Date: Wed Jul 6 16:44:12 2005
New Revision: 14343
Modified:
pypy/dist/pypy/rpython/rarithmetic.py
pypy/dist/pypy/rpython/test/test_rarithmetic.py
Log:
mixed types with coercion and limits test.
Modified: pypy/dist/pypy/rpython/rarithmetic.py
==============================================================================
--- pypy/dist/pypy/rpython/rarithmetic.py (original)
+++ pypy/dist/pypy/rpython/rarithmetic.py Wed Jul 6 16:44:12 2005
@@ -329,7 +329,7 @@
class r_ushort(r_uint):
BITS = r_uint.BITS // 2
- MASK = int((1 << BITS) - 1)
+ MASK = (1L << BITS) - 1
class r_ulong(r_uint):
BITS = r_uint.BITS * 2
Modified: pypy/dist/pypy/rpython/test/test_rarithmetic.py
==============================================================================
--- pypy/dist/pypy/rpython/test/test_rarithmetic.py (original)
+++ pypy/dist/pypy/rpython/test/test_rarithmetic.py Wed Jul 6 16:44:12 2005
@@ -139,6 +139,27 @@
res = res & mask
assert res == cmp
+def test_mixed_types():
+ types = [r_ushort, r_uint, r_ulong]
+ for left in types:
+ for right in types:
+ x = left(3) + right(5)
+ expected = max(types.index(left), types.index(right))
+ assert types.index(type(x)) == expected
+
+def test_limits():
+ mask = r_ushort.MASK
+ assert r_ushort(mask) == mask
+ assert r_ushort(mask+1) == 0
+ mask = (mask << r_ushort.BITS) + mask
+ assert mask == r_uint.MASK
+ assert r_uint(mask == mask)
+ assert r_uint(mask+1) == 0
+ mask = (mask << r_uint.BITS) + mask
+ assert mask == r_ulong.MASK
+ assert r_ulong(mask == mask)
+ assert r_ulong(mask+1) == 0
+
def test_intmask():
assert intmask(1) == 1
assert intmask(sys.maxint) == sys.maxint
More information about the Pypy-commit
mailing list