Added a regression test for the negation-of-exponentiation optimization
authorFred Drake <fdrake@acm.org>
Thu, 30 Aug 2001 18:56:30 +0000 (18:56 +0000)
committerFred Drake <fdrake@acm.org>
Thu, 30 Aug 2001 18:56:30 +0000 (18:56 +0000)
bug from compile.c.  (SF bug #456756.)

Lib/test/test_pow.py

index bccd207fc7f370114c943db6a0a1f9ceb1944d42..45964b975e5b690f3fe7eaf06e65ab637c5b335d 100644 (file)
@@ -1,6 +1,9 @@
 import sys
 import test_support
 
+from test_support import verify
+
+
 def powtest(type):
     if type != float:
         print "    Testing 2-argument pow() function..."
@@ -76,6 +79,14 @@ 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.'