]> granicus.if.org Git - python/commitdiff
Added some tests to make sure that long->int conversions near
authorGuido van Rossum <guido@python.org>
Tue, 26 May 1998 14:51:55 +0000 (14:51 +0000)
committerGuido van Rossum <guido@python.org>
Tue, 26 May 1998 14:51:55 +0000 (14:51 +0000)
sys.maxint and near -sys.maxint-1 work correctly.

Lib/test/test_types.py

index 6be66ca17c41f1b206034a177e300507b979b10f..685c05b7d03effb1b274c3168853d9e37212eff3 100644 (file)
@@ -78,6 +78,18 @@ if (-12L) + 24L <> 12L: raise TestFailed, 'long op'
 if (-12L) + (-24L) <> -36L: raise TestFailed, 'long op'
 if not 12L < 24L: raise TestFailed, 'long op'
 if not -24L < -12L: raise TestFailed, 'long op'
+x = sys.maxint
+if int(long(x)) != x: raise TestFailed, 'long op'
+try: int(long(x)+1L)
+except OverflowError: pass
+else:raise TestFailed, 'long op'
+x = -x
+if int(long(x)) != x: raise TestFailed, 'long op'
+x = x-1
+if int(long(x)) != x: raise TestFailed, 'long op'
+try: int(long(x)-1L)
+except OverflowError: pass
+else:raise TestFailed, 'long op'
 print '6.4.3 Floating point numbers'
 if 12.0 + 24.0 <> 36.0: raise TestFailed, 'float op'
 if 12.0 + (-24.0) <> -12.0: raise TestFailed, 'float op'