summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorNeal Norwitz <nnorwitz@gmail.com>2001-12-29 00:16:09 (GMT)
committerNeal Norwitz <nnorwitz@gmail.com>2001-12-29 00:16:09 (GMT)
commit26e5341c003066cae00c01e76384b47739cd6f7d (patch)
tree030ced2e92d32ada8df7e97625d8f99e10906a57 /Lib/test
parentf21b2aafa9b78891b568264a32f40ee8a8384aa1 (diff)
downloadcpython-26e5341c003066cae00c01e76384b47739cd6f7d.zip
cpython-26e5341c003066cae00c01e76384b47739cd6f7d.tar.gz
cpython-26e5341c003066cae00c01e76384b47739cd6f7d.tar.bz2
SF Patch #494876, test invalid parameters to pow()
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_b2.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/Lib/test/test_b2.py b/Lib/test/test_b2.py
index ca26a77..c5af1b3 100644
--- a/Lib/test/test_b2.py
+++ b/Lib/test/test_b2.py
@@ -105,6 +105,26 @@ for x in 2, 2L, 2.0:
if fcmp(pow(x, y, z), 24.0):
raise TestFailed, 'pow(%s, %s, %s)' % (x, y, z)
+try: pow(-1, -2, 3)
+except TypeError: pass
+else: raise TestFailed, 'pow(1, -2, 3) should raise TypeError'
+
+try: pow(1, 2, 0)
+except ValueError: pass
+else: raise TestFailed, 'pow(1, 2, 0) should raise ValueError'
+
+try: pow(-1L, -2L, 3L)
+except TypeError: pass
+else: raise TestFailed, 'pow(1L, -2L, 3L) should raise TypeError'
+
+try: pow(1L, 2L, 0L)
+except ValueError: pass
+else: raise TestFailed, 'pow(1L, 2L, 0L) should raise ValueError'
+
+try: pow(-342.43, 0.234)
+except ValueError: pass
+else: raise TestFailed, 'pow(-342.43, 0.234) should raise ValueError'
+
print 'range'
if range(3) != [0, 1, 2]: raise TestFailed, 'range(3)'
if range(1, 5) != [1, 2, 3, 4]: raise TestFailed, 'range(1, 5)'