summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_pow.py
diff options
context:
space:
mode:
authorFred Drake <fdrake@acm.org>2001-08-30 18:56:30 (GMT)
committerFred Drake <fdrake@acm.org>2001-08-30 18:56:30 (GMT)
commitd256271c552cd021a91732ddc31552ade6cdf79f (patch)
tree48de4771bb800454c179de0247f97c664a51a6ea /Lib/test/test_pow.py
parent14ef244dfe8b79694d4baa48ceda874fe27ec05d (diff)
downloadcpython-d256271c552cd021a91732ddc31552ade6cdf79f.zip
cpython-d256271c552cd021a91732ddc31552ade6cdf79f.tar.gz
cpython-d256271c552cd021a91732ddc31552ade6cdf79f.tar.bz2
Added a regression test for the negation-of-exponentiation optimization
bug from compile.c. (SF bug #456756.)
Diffstat (limited to 'Lib/test/test_pow.py')
-rw-r--r--Lib/test/test_pow.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/Lib/test/test_pow.py b/Lib/test/test_pow.py
index bccd207..45964b9 100644
--- a/Lib/test/test_pow.py
+++ b/Lib/test/test_pow.py
@@ -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.'