summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_pow.py
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2001-09-03 08:35:41 (GMT)
committerTim Peters <tim.peters@gmail.com>2001-09-03 08:35:41 (GMT)
commit32f453eaa476c78376cd721d29ba8ab726e400bb (patch)
treeaec8b2e54ec4a0a7cbd66569d3a8531db118f153 /Lib/test/test_pow.py
parent5d2b77cf31c5a3cbabc74936831480b9caea3a12 (diff)
downloadcpython-32f453eaa476c78376cd721d29ba8ab726e400bb.zip
cpython-32f453eaa476c78376cd721d29ba8ab726e400bb.tar.gz
cpython-32f453eaa476c78376cd721d29ba8ab726e400bb.tar.bz2
New restriction on pow(x, y, z): If z is not None, x and y must be of
integer types, and y must be >= 0. See discussion at http://sf.net/tracker/index.php?func=detail&aid=457066&group_id=5470&atid=105470
Diffstat (limited to 'Lib/test/test_pow.py')
-rw-r--r--Lib/test/test_pow.py18
1 files changed, 9 insertions, 9 deletions
diff --git a/Lib/test/test_pow.py b/Lib/test/test_pow.py
index 51d7484..41911bf 100644
--- a/Lib/test/test_pow.py
+++ b/Lib/test/test_pow.py
@@ -64,6 +64,15 @@ def powtest(type):
for j in range(jl, jh+1):
for k in range(kl, kh+1):
if k != 0:
+ if type == float or j < 0:
+ try:
+ pow(type(i),j,k)
+ except TypeError:
+ pass
+ else:
+ raise TestFailed("expected TypeError from "
+ "pow%r" % ((type(i), j, k)))
+ continue
if compare(pow(type(i),j,k), pow(type(i),j)% type(k)):
raise ValueError, "pow(" +str(i)+ "," +str(j)+ \
"," +str(k)+ ") != pow(" +str(i)+ "," + \
@@ -96,10 +105,6 @@ print `pow(-3L,3L) % -8`, `pow(-3L,3L,-8)`
print `pow(5L,2) % -8`, `pow(5L,2,-8)`
print
-print pow(3.0,3.0) % 8, pow(3.0,3.0,8)
-print pow(3.0,3.0) % -8, pow(3.0,3.0,-8)
-print pow(3.0,2) % -2, pow(3.0,2,-2)
-print pow(5.0,2) % -8, pow(5.0,2,-8)
print
for i in range(-10, 11):
@@ -112,8 +117,3 @@ for i in range(-10, 11):
if j >= 0 and k != 0:
o = pow(long(i),j) % k
n = pow(long(i),j,k)
- if o != n: print 'Long mismatch:', i,j,k
- if i >= 0 and k != 0:
- o = pow(float(i),j) % k
- n = pow(float(i),j,k)
- if o != n: print 'Float mismatch:', i,j,k