[pypy-svn] r20889 - in pypy/dist/pypy/rpython: . test

mwh at codespeak.net mwh at codespeak.net
Thu Dec 8 13:29:58 CET 2005


Author: mwh
Date: Thu Dec  8 13:29:57 2005
New Revision: 20889

Modified:
   pypy/dist/pypy/rpython/rarithmetic.py
   pypy/dist/pypy/rpython/test/test_rarithmetic.py
Log:
implement __abs__ for our integer types.


Modified: pypy/dist/pypy/rpython/rarithmetic.py
==============================================================================
--- pypy/dist/pypy/rpython/rarithmetic.py	(original)
+++ pypy/dist/pypy/rpython/rarithmetic.py	Thu Dec  8 13:29:57 2005
@@ -201,6 +201,10 @@
         x = long(self)
         return self.__class__(-x)
 
+    def __abs__(self):
+        x = long(self)
+        return self.__class__(abs(x))
+
     def __pos__(self):
         return self.__class__(self)
 

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	Thu Dec  8 13:29:57 2005
@@ -262,5 +262,5 @@
     else:
         assert False
 
-
-
+def test_abs():
+    assert type(abs(r_longlong(1))) is r_longlong



More information about the Pypy-commit mailing list