[pypy-svn] r16371 - in pypy/dist/pypy/objspace/std: . test

ale at codespeak.net ale at codespeak.net
Wed Aug 24 14:26:03 CEST 2005


Author: ale
Date: Wed Aug 24 14:26:01 2005
New Revision: 16371

Modified:
   pypy/dist/pypy/objspace/std/floatobject.py
   pypy/dist/pypy/objspace/std/test/test_floatobject.py
Log:
Added check for power of a negative number.

Added the actual computation of pow(x,y) if x is negative (and passes the tests for negative numbers)

Modified: pypy/dist/pypy/objspace/std/floatobject.py
==============================================================================
--- pypy/dist/pypy/objspace/std/floatobject.py	(original)
+++ pypy/dist/pypy/objspace/std/floatobject.py	Wed Aug 24 14:26:01 2005
@@ -314,13 +314,13 @@
                     return space.wrap(1.0)
                 else:
                     return space.wrap( -1.0)
-        else:
-                try:
-                    z = math.pow(x,y)
-                except OverflowError:
-                    raise FailedToImplement(space.w_OverflowError, space.wrap("float power"))
-                except ValueError:
-                    raise FailedToImplement(space.w_ValueError, space.wrap("float power")) # xxx
+#        else:
+        try:
+            z = math.pow(x,y)
+        except OverflowError:
+            raise FailedToImplement(space.w_OverflowError, space.wrap("float power"))
+        except ValueError:
+            raise FailedToImplement(space.w_ValueError, space.wrap("float power")) # xxx
 
     return W_FloatObject(space, z)
 

Modified: pypy/dist/pypy/objspace/std/test/test_floatobject.py
==============================================================================
--- pypy/dist/pypy/objspace/std/test/test_floatobject.py	(original)
+++ pypy/dist/pypy/objspace/std/test/test_floatobject.py	Wed Aug 24 14:26:01 2005
@@ -37,6 +37,12 @@
                           self._unwrap_nonimpl(fobj.pow__Float_Float_ANY,
                                                self.space, f1, f2,
                                                self.space.w_None))
+        x = -10
+        y = 2.0
+        f1 = fobj.W_FloatObject(self.space, x)
+        f2 = fobj.W_FloatObject(self.space, y)
+        v = fobj.pow__Float_Float_ANY(self.space, f1, f2, self.space.w_None)
+        assert v.floatval == x**y
 
 class AppTestAppFloatTest:
     def test_negatives(self):



More information about the Pypy-commit mailing list