[Python-checkins] CVS: python/dist/src/Lib/test test_b2.py,1.27,1.28 test_long.py,1.9,1.10 test_pow.py,1.10,1.11

Tim Peters tim_one@users.sourceforge.net
Mon, 03 Sep 2001 01:35:42 -0700


Update of /cvsroot/python/python/dist/src/Lib/test
In directory usw-pr-cvs1:/tmp/cvs-serv12739/python/Lib/test

Modified Files:
	test_b2.py test_long.py test_pow.py 
Log Message:
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


Index: test_b2.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_b2.py,v
retrieving revision 1.27
retrieving revision 1.28
diff -C2 -d -r1.27 -r1.28
*** test_b2.py	2001/07/30 22:49:11	1.27
--- test_b2.py	2001/09/03 08:35:40	1.28
***************
*** 83,97 ****
  if fcmp(pow(2.,30), 1024.*1024.*1024.): raise TestFailed, 'pow(2.,30)'
  #
! # XXX These don't work -- negative float to the float power...
! #if fcmp(pow(-2.,0), 1.): raise TestFailed, 'pow(-2.,0)'
! #if fcmp(pow(-2.,1), -2.): raise TestFailed, 'pow(-2.,1)'
! #if fcmp(pow(-2.,2), 4.): raise TestFailed, 'pow(-2.,2)'
! #if fcmp(pow(-2.,3), -8.): raise TestFailed, 'pow(-2.,3)'
! #
  for x in 2, 2L, 2.0:
      for y in 10, 10L, 10.0:
          for z in 1000, 1000L, 1000.0:
!             if fcmp(pow(x, y, z), 24.0):
!                 raise TestFailed, 'pow(%s, %s, %s)' % (x, y, z)
  
  print 'range'
--- 83,108 ----
  if fcmp(pow(2.,30), 1024.*1024.*1024.): raise TestFailed, 'pow(2.,30)'
  #
! if fcmp(pow(-2.,0), 1.): raise TestFailed, 'pow(-2.,0)'
! if fcmp(pow(-2.,1), -2.): raise TestFailed, 'pow(-2.,1)'
! if fcmp(pow(-2.,2), 4.): raise TestFailed, 'pow(-2.,2)'
! if fcmp(pow(-2.,3), -8.): raise TestFailed, 'pow(-2.,3)'
! 
! from types import FloatType
  for x in 2, 2L, 2.0:
      for y in 10, 10L, 10.0:
          for z in 1000, 1000L, 1000.0:
!             if isinstance(x, FloatType) or \
!                isinstance(y, FloatType) or \
!                isinstance(z, FloatType):
!                 try:
!                     pow(x, y, z)
!                 except TypeError:
!                     pass
!                 else:
!                     raise TestFailed("3-arg float pow() should have "
!                                      "raised TypeError %r" % (x, y, z))
!             else:
!                 if fcmp(pow(x, y, z), 24.0):
!                     raise TestFailed, 'pow(%s, %s, %s)' % (x, y, z)
  
  print 'range'

Index: test_long.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_long.py,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** test_long.py	2001/08/23 23:02:57	1.9
--- test_long.py	2001/09/03 08:35:40	1.10
***************
*** 315,322 ****
  
                  for z in special:
!                     if z != 0:
!                         expected = pow(longx, longy, long(z))
!                         got = pow(x, y, z)
!                         checkit('pow', x, y, '%', z)
  
  # ---------------------------------------------------------------- do it
--- 315,331 ----
  
                  for z in special:
!                     if z != 0 :
!                         if y >= 0:
!                             expected = pow(longx, longy, long(z))
!                             got = pow(x, y, z)
!                             checkit('pow', x, y, '%', z)
!                         else:
!                             try:
!                                 pow(longx, longy, long(z))
!                             except TypeError:
!                                 pass
!                             else:
!                                 raise TestFailed("pow%r should have raised "
!                                 "TypeError" % ((longx, longy, long(z))))
  
  # ---------------------------------------------------------------- do it

Index: test_pow.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_pow.py,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** test_pow.py	2001/08/30 19:15:20	1.10
--- test_pow.py	2001/09/03 08:35:40	1.11
***************
*** 65,68 ****
--- 65,77 ----
              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)+ \
***************
*** 97,104 ****
  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
  
--- 106,109 ----
***************
*** 113,119 ****
                  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
--- 118,119 ----