]> granicus.if.org Git - python/commitdiff
Revert the previous patch to test_pow.py and move the test to test_unary.py
authorFred Drake <fdrake@acm.org>
Thu, 30 Aug 2001 19:15:20 +0000 (19:15 +0000)
committerFred Drake <fdrake@acm.org>
Thu, 30 Aug 2001 19:15:20 +0000 (19:15 +0000)
based on a suggestion from Tim Peters; also make sure that we're really
doing exponentiation and not multiplication.

Lib/test/test_pow.py
Lib/test/test_unary.py

index 45964b975e5b690f3fe7eaf06e65ab637c5b335d..51d7484ae9487a331014cd1ca57bc1168c9a858c 100644 (file)
@@ -1,8 +1,6 @@
 import sys
 import test_support
 
-from test_support import verify
-
 
 def powtest(type):
     if type != float:
@@ -79,14 +77,6 @@ powtest(long)
 print 'Testing floating point mode...'
 powtest(float)
 
-# Make sure '**' does the right thing; these form a
-# regression test for SourceForge bug #456756.
-#
-verify((-2 ** 2) == -4,
-       "expected '-2 ** 2' to be -4, got %s" % (-2 ** 2))
-verify(((-2) ** 2) == 4,
-       "expected '(-2) ** 2' to be 4, got %s" % ((-2) ** 2))
-
 # Other tests-- not very systematic
 
 print 'The number in both columns should match.'
index 3402c55c19142caefcde3d9a0343d12477b2b813..01c5f01f9b3a18839f138a67f824c60c9cc3fdd4 100644 (file)
@@ -33,6 +33,14 @@ class UnaryOpTestCase(unittest.TestCase):
         self.assert_(eval("-" + nines) == eval("-" + nines + "L"))
         self.assert_(eval("~" + nines) == eval("~" + nines + "L"))
 
+    def test_negation_of_exponentiation(self):
+        # Make sure '**' does the right thing; these form a
+        # regression test for SourceForge bug #456756.
+        self.assertEqual(-2 ** 3, -8)
+        self.assertEqual((-2) ** 3, -8)
+        self.assertEqual(-2 ** 4, -16)
+        self.assertEqual((-2) ** 4, 16)
+
     def test_bad_types(self):
         for op in '+', '-', '~':
             self.assertRaises(TypeError, eval, op + "'a'")