6 print " Testing 2-argument pow() function..."
7 for i
in range(-1000, 1000):
8 if (pow(type(i
),0)!=1):
9 raise ValueError, 'pow('+str(i
)+',0) != 1'
10 if (pow(type(i
),1)!=type(i
)):
11 raise ValueError, 'pow('+str(i
)+',1) != '+str(i
)
12 if (pow(type(0),1)!=type(0)):
13 raise ValueError, 'pow(0,'+str(i
)+') != 0'
14 if (pow(type(1),1)!=type(1)):
15 raise ValueError, 'pow(1,'+str(i
)+') != 1'
17 for i
in range(-100, 100):
18 if (pow(type(i
),3)!=i
*i
*i
):
19 raise ValueError, 'pow('+str(i
)+',3) != '+str(i
*i
*i
)
24 raise ValueError, 'pow(2,'+str(i
)+') != '+str(pow2
)
25 if (i
!=30): pow2
=pow2
*2
27 print " Testing 3-argument pow() function..."
34 compare
= test_support
.fcmp
39 for i
in range(il
, ih
+1):
40 for j
in range(jl
,jh
+1):
41 for k
in range(kl
, kh
+1):
43 if compare(pow(type(i
),j
,k
), pow(type(i
),j
)% type(k
)):
44 raise ValueError, "pow(" +str(i
)+ "," +str(j
)+ \
45 "," +str(k
)+ ") != pow(" +str(i
)+ "," + \
46 str(j
)+ ") % " +str(k
)
49 print 'Testing integer mode...'
51 print 'Testing long integer mode...'
53 print 'Testing floating point mode...'
56 # Other tests-- not very systematic
58 print 'The number in both columns should match.'
59 print `
pow(3,3) % 8`
, `
pow(3,3,8)`
60 print `
pow(3,3) % -8`
, `
pow(3,3,-8)`
61 print `
pow(3,2) % -2`
, `
pow(3,2,-2)`
62 print `
pow(-3,3) % 8`
, `
pow(-3,3,8)`
63 print `
pow(-3,3) % -8`
, `
pow(-3,3,-8)`
64 print `
pow(5,2) % -8`
, `
pow(5,2,-8)`
67 print `
pow(3L,3L) % 8`
, `
pow(3L,3L,8)`
68 print `
pow(3L,3L) % -8`
, `
pow(3L,3L,-8)`
69 print `
pow(3L,2) % -2`
, `
pow(3L,2,-2)`
70 print `
pow(-3L,3L) % 8`
, `
pow(-3L,3L,8)`
71 print `
pow(-3L,3L) % -8`
, `
pow(-3L,3L,-8)`
72 print `
pow(5L,2) % -8`
, `
pow(5L,2,-8)`
75 print pow(3.0,3.0) % 8, pow(3.0,3.0,8)
76 print pow(3.0,3.0) % -8, pow(3.0,3.0,-8)
77 print pow(3.0,2) % -2, pow(3.0,2,-2)
78 print pow(5.0,2) % -8, pow(5.0,2,-8)
81 for i
in range(-10, 11):
83 for k
in range(-7, 11):
87 if (o
!=n
): print 'Integer mismatch:', i
,j
,k
91 if (o
!=n
): print 'Long mismatch:', i
,j
,k
95 if (o
!=n
): print 'Float mismatch:', i
,j
,k