[Python-checkins] CVS: python/dist/src/Lib/test test_descr.py,1.64,1.65

Guido van Rossum gvanrossum@users.sourceforge.net
Tue, 18 Sep 2001 18:25:18 -0700


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

Modified Files:
	test_descr.py 
Log Message:
Add additional coercion support for "self subtypes" to int, long,
float (compare the recent checkin to complex).  Added tests for these.


Index: test_descr.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_descr.py,v
retrieving revision 1.64
retrieving revision 1.65
diff -C2 -d -r1.64 -r1.65
*** test_descr.py	2001/09/19 01:16:16	1.64
--- test_descr.py	2001/09/19 01:25:16	1.65
***************
*** 1925,1928 ****
--- 1925,1955 ----
                             "x=%d, y=%d" % (x, y))
  
+ def coercions():
+     if verbose: print "Testing coercions..."
+     class I(int): pass
+     coerce(I(0), 0)
+     coerce(0, I(0))
+     class L(long): pass
+     coerce(L(0), 0)
+     coerce(L(0), 0L)
+     coerce(0, L(0))
+     coerce(0L, L(0))
+     class F(float): pass
+     coerce(F(0), 0)
+     coerce(F(0), 0L)
+     coerce(F(0), 0.)
+     coerce(0, F(0))
+     coerce(0L, F(0))
+     coerce(0., F(0))
+     class C(complex): pass
+     coerce(C(0), 0)
+     coerce(C(0), 0L)
+     coerce(C(0), 0.)
+     coerce(C(0), 0j)
+     coerce(0, C(0))
+     coerce(0L, C(0))
+     coerce(0., C(0))
+     coerce(0j, C(0))
+ 
  
  def all():
***************
*** 1965,1968 ****
--- 1992,1996 ----
      classic_comparisons()
      rich_comparisons()
+     coercions()
  
  all()