Commits

Alex Gaynor  committed d9e0f6c

long tests for abstract_numbers now pass.

  • Participants
  • Parent commits deb2e22
  • Branches fast-forward

Comments (0)

Files changed (3)

File pypy/objspace/std/longtype.py

 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
 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",
     __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())

File pypy/objspace/std/register_all.py

         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

File pypy/objspace/std/test/test_longobject.py

         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