[pypy-svn] r77507 - in pypy/branch/fast-forward/pypy/objspace/std: . test

agaynor at codespeak.net agaynor at codespeak.net
Thu Sep 30 19:40:48 CEST 2010


Author: agaynor
Date: Thu Sep 30 19:40:47 2010
New Revision: 77507

Modified:
   pypy/branch/fast-forward/pypy/objspace/std/longtype.py
   pypy/branch/fast-forward/pypy/objspace/std/register_all.py
   pypy/branch/fast-forward/pypy/objspace/std/test/test_longobject.py
Log:
long tests for abstract_numbers now pass.

Modified: pypy/branch/fast-forward/pypy/objspace/std/longtype.py
==============================================================================
--- pypy/branch/fast-forward/pypy/objspace/std/longtype.py	(original)
+++ pypy/branch/fast-forward/pypy/objspace/std/longtype.py	Thu Sep 30 19:40:47 2010
@@ -1,8 +1,17 @@
 from pypy.interpreter.error import OperationError
 from pypy.interpreter import gateway, typedef
-from pypy.objspace.std.stdtypedef import StdTypeDef
+from pypy.objspace.std.register_all import register_all
+from pypy.objspace.std.stdtypedef import StdTypeDef, SMM
 from pypy.objspace.std.strutil import string_to_w_long, ParseStringError
 
+long_conjugate = SMM("conjugate", 1, doc="Returns self, the complex conjugate of any long.")
+
+def long_conjugate__ANY(space, w_int):
+    return space.pos(w_int)
+
+register_all(vars(), globals())
+
+
 def descr__new__(space, w_longtype, w_x=0, w_base=gateway.NoneNotWrapped):
     from pypy.objspace.std.longobject import W_LongObject
     w_value = w_x     # 'x' is the keyword argument name in CPython
@@ -71,6 +80,12 @@
 def descr_get_denominator(space, w_obj):
     return space.newlong(1)
 
+def descr_get_real(space, w_obj):
+    return w_obj
+
+def descr_get_imag(space, w_obj):
+    return space.newlong(0)
+
 # ____________________________________________________________
 
 long_typedef = StdTypeDef("long",
@@ -84,4 +99,7 @@
     __new__ = gateway.interp2app(descr__new__),
     numerator = typedef.GetSetProperty(descr_get_numerator),
     denominator = typedef.GetSetProperty(descr_get_denominator),
-    )
+    real = typedef.GetSetProperty(descr_get_real),
+    imag = typedef.GetSetProperty(descr_get_imag),
+)
+long_typedef.registermethods(globals())

Modified: pypy/branch/fast-forward/pypy/objspace/std/register_all.py
==============================================================================
--- pypy/branch/fast-forward/pypy/objspace/std/register_all.py	(original)
+++ pypy/branch/fast-forward/pypy/objspace/std/register_all.py	Thu Sep 30 19:40:47 2010
@@ -21,7 +21,7 @@
         if name.find('__')<1 or name.startswith('app_'):
             continue
         funcname, sig = name.split('__')
-        l=[]
+        l = []
         for i in sig.split('_'):
             if i == 'ANY':        # just in case W_ANY is not in module_dict
                 icls = model.W_ANY

Modified: pypy/branch/fast-forward/pypy/objspace/std/test/test_longobject.py
==============================================================================
--- pypy/branch/fast-forward/pypy/objspace/std/test/test_longobject.py	(original)
+++ pypy/branch/fast-forward/pypy/objspace/std/test/test_longobject.py	Thu Sep 30 19:40:47 2010
@@ -254,3 +254,12 @@
         class myotherlong(long):
             pass
         assert long(myotherlong(21)) == 21L
+    
+    def test_conjugate(self):
+        assert (7L).conjugate() == 7L
+        assert (-7L).conjugate() == -7L
+        
+        class L(long):
+            pass
+        
+        assert type(L(7).conjugate()) is long



More information about the Pypy-commit mailing list