[pypy-svn] rev 577 - in pypy/trunk/src/pypy/objspace/std: . test
tismer at codespeak.net
tismer at codespeak.net
Tue May 27 16:52:46 CEST 2003
Author: tismer
Date: Tue May 27 16:52:45 2003
New Revision: 577
Modified:
pypy/trunk/src/pypy/objspace/std/restricted_int.py
pypy/trunk/src/pypy/objspace/std/test/test_restricted_int.py
Log:
corrected r_int to really support sequences, and added tests
Modified: pypy/trunk/src/pypy/objspace/std/restricted_int.py
==============================================================================
--- pypy/trunk/src/pypy/objspace/std/restricted_int.py (original)
+++ pypy/trunk/src/pypy/objspace/std/restricted_int.py Tue May 27 16:52:45 2003
@@ -37,11 +37,10 @@
def __mul__(self, other):
x = int(self)
+ if not isinstance(other, (int, long)):
+ return x * other
y = int(other)
- res = x * y
- if not isinstance(res, (int, long)):
- res = r_int(res)
- return res
+ return r_int(x * y)
__rmul__ = __mul__
def __div__(self, other):
@@ -177,11 +176,10 @@
def __mul__(self, other):
x = long(self)
+ if not isinstance(other, (int, long)):
+ return x * other
y = long(other)
- res = x * y
- if not isinstance(res, (int, long)):
- res = r_uint(res)
- return res
+ return r_uint(x * y)
__rmul__ = __mul__
def __div__(self, other):
Modified: pypy/trunk/src/pypy/objspace/std/test/test_restricted_int.py
==============================================================================
--- pypy/trunk/src/pypy/objspace/std/test/test_restricted_int.py (original)
+++ pypy/trunk/src/pypy/objspace/std/test/test_restricted_int.py Tue May 27 16:52:45 2003
@@ -16,6 +16,9 @@
self.binary_test(lambda x, y: x - y)
def test__mul__(self):
self.binary_test(lambda x, y: x * y)
+ x = 3; y = [2]
+ self.assertEquals(x*y, r_int(x)*y)
+ self.assertEquals(y*x, y*r_int(x))
def test__div__(self):
self.binary_test(lambda x, y: x // y)
def test__mod__(self):
@@ -73,6 +76,9 @@
self.binary_test(lambda x, y: x - y)
def test__mul__(self):
self.binary_test(lambda x, y: x * y)
+ x = 3; y = [2]
+ self.assertEquals(x*y, r_uint(x)*y)
+ self.assertEquals(y*x, y*r_uint(x))
def test__div__(self):
self.binary_test(lambda x, y: x // y)
def test__mod__(self):
More information about the Pypy-commit
mailing list