Update of /cvsroot/python/python/dist/src/Lib/test
In directory sc8-pr-cvs1:/tmp/cvs-serv28240/Lib/test
Modified Files:
test_builtin.py test_compile.py test_format.py test_grammar.py
test_hexoct.py
Log Message:
- Removed FutureWarnings related to hex/oct literals and conversions
and left shifts. (Thanks to Kalle Svensson for SF patch 849227.)
This addresses most of the remaining semantic changes promised by
PEP 237, except for repr() of a long, which still shows the trailing
'L'. The PEP appears to promise warnings for operations that
changed semantics compared to Python 2.3, but this is not
implemented; we've suffered through enough warnings related to
hex/oct literals and I think it's best to be silent now.
Index: test_builtin.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_builtin.py,v
retrieving revision 1.25
retrieving revision 1.26
diff -C2 -d -r1.25 -r1.26
*** test_builtin.py 16 Nov 2003 16:17:48 -0000 1.25
--- test_builtin.py 29 Nov 2003 23:52:12 -0000 1.26
***************
*** 438,443 ****
self.assertEqual(hex(16), '0x10')
self.assertEqual(hex(16L), '0x10L')
! self.assertEqual(len(hex(-1)), len(hex(sys.maxint)))
! self.assert_(hex(-16) in ('0xfffffff0', '0xfffffffffffffff0'))
self.assertEqual(hex(-16L), '-0x10L')
self.assertRaises(TypeError, hex, {})
--- 438,442 ----
self.assertEqual(hex(16), '0x10')
self.assertEqual(hex(16L), '0x10L')
! self.assertEqual(hex(-16), '-0x10')
self.assertEqual(hex(-16L), '-0x10L')
self.assertRaises(TypeError, hex, {})
***************
*** 758,762 ****
self.assertEqual(oct(100), '0144')
self.assertEqual(oct(100L), '0144L')
! self.assert_(oct(-100) in ('037777777634', '01777777777777777777634'))
self.assertEqual(oct(-100L), '-0144L')
self.assertRaises(TypeError, oct, ())
--- 757,761 ----
self.assertEqual(oct(100), '0144')
self.assertEqual(oct(100L), '0144L')
! self.assertEqual(oct(-100), '-0144')
self.assertEqual(oct(-100L), '-0144L')
self.assertRaises(TypeError, oct, ())
Index: test_compile.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_compile.py,v
retrieving revision 1.19
retrieving revision 1.20
diff -C2 -d -r1.19 -r1.20
*** test_compile.py 23 Jun 2003 13:36:55 -0000 1.19
--- test_compile.py 29 Nov 2003 23:52:12 -0000 1.20
***************
*** 120,132 ****
def test_unary_minus(self):
# Verify treatment of unary minus on negative numbers SF bug #660455
! warnings.filterwarnings("ignore", "hex/oct constants", FutureWarning)
! warnings.filterwarnings("ignore", "hex.* of negative int", FutureWarning)
! # XXX Of course the following test will have to be changed in Python 2.4
! # This test is in a <string> so the filterwarnings() can affect it
! all_one_bits = '0xffffffff'
! if sys.maxint != 2147483647:
all_one_bits = '0xffffffffffffffff'
! self.assertEqual(eval(all_one_bits), -1)
! self.assertEqual(eval("-" + all_one_bits), 1)
def test_sequence_unpacking_error(self):
--- 120,135 ----
def test_unary_minus(self):
# Verify treatment of unary minus on negative numbers SF bug #660455
! if sys.maxint == 2147483647:
! # 32-bit machine
! all_one_bits = '0xffffffff'
! self.assertEqual(eval(all_one_bits), 4294967295L)
! self.assertEqual(eval("-" + all_one_bits), -4294967295L)
! elif sys.maxint == 9223372036854775807:
! # 64-bit machine
all_one_bits = '0xffffffffffffffff'
! self.assertEqual(eval(all_one_bits), 18446744073709551615L)
! self.assertEqual(eval("-" + all_one_bits), -18446744073709551615L)
! else:
! self.fail("How many bits *does* this machine have???")
def test_sequence_unpacking_error(self):
Index: test_format.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_format.py,v
retrieving revision 1.19
retrieving revision 1.20
diff -C2 -d -r1.19 -r1.20
*** test_format.py 24 Nov 2002 02:35:35 -0000 1.19
--- test_format.py 29 Nov 2003 23:52:12 -0000 1.20
***************
*** 184,193 ****
testboth("%x", 0x42, "42")
! # testboth("%x", -0x42, "ffffffbe") # specific to 32-bit boxes; see below
testboth("%x", 0x42L, "42")
testboth("%x", -0x42L, "-42")
testboth("%o", 042, "42")
! # testboth("%o", -042, "37777777736") # specific to 32-bit boxes; see below
testboth("%o", 042L, "42")
testboth("%o", -042L, "-42")
--- 184,193 ----
testboth("%x", 0x42, "42")
! testboth("%x", -0x42, "-42")
testboth("%x", 0x42L, "42")
testboth("%x", -0x42L, "-42")
testboth("%o", 042, "42")
! testboth("%o", -042, "-42")
testboth("%o", 042L, "42")
testboth("%o", -042L, "-42")
***************
*** 239,243 ****
else:
raise TestFailed, '"%*d"%(sys.maxint, -127) should fail'
- # (different things go wrong on a 64 bit box...)
- testboth("%x", -0x42, "ffffffbe")
- testboth("%o", -042, "37777777736")
--- 239,240 ----
Index: test_grammar.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_grammar.py,v
retrieving revision 1.47
retrieving revision 1.48
diff -C2 -d -r1.47 -r1.48
*** test_grammar.py 15 Jun 2003 23:26:30 -0000 1.47
--- test_grammar.py 29 Nov 2003 23:52:12 -0000 1.48
***************
*** 40,47 ****
# The following test will start to fail in Python 2.4;
# change the 020000000000 to -020000000000
! if -2147483647-1 != 020000000000: raise TestFailed, 'max negative int'
# XXX -2147483648
! if 037777777777 != -1: raise TestFailed, 'oct -1'
! if 0xffffffff != -1: raise TestFailed, 'hex -1'
for s in '2147483648', '040000000000', '0x100000000':
try:
--- 40,47 ----
# The following test will start to fail in Python 2.4;
# change the 020000000000 to -020000000000
! if -2147483647-1 != -020000000000: raise TestFailed, 'max negative int'
# XXX -2147483648
! if 037777777777 < 0: raise TestFailed, 'large oct'
! if 0xffffffff < 0: raise TestFailed, 'large hex'
for s in '2147483648', '040000000000', '0x100000000':
try:
***************
*** 50,57 ****
print "OverflowError on huge integer literal " + `s`
elif eval('maxint == 9223372036854775807'):
! if eval('-9223372036854775807-1 != 01000000000000000000000'):
raise TestFailed, 'max negative int'
! if eval('01777777777777777777777') != -1: raise TestFailed, 'oct -1'
! if eval('0xffffffffffffffff') != -1: raise TestFailed, 'hex -1'
for s in '9223372036854775808', '02000000000000000000000', \
'0x10000000000000000':
--- 50,57 ----
print "OverflowError on huge integer literal " + `s`
elif eval('maxint == 9223372036854775807'):
! if eval('-9223372036854775807-1 != -01000000000000000000000'):
raise TestFailed, 'max negative int'
! if eval('01777777777777777777777') < 0: raise TestFailed, 'large oct'
! if eval('0xffffffffffffffff') < 0: raise TestFailed, 'large hex'
for s in '9223372036854775808', '02000000000000000000000', \
'0x10000000000000000':
Index: test_hexoct.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_hexoct.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** test_hexoct.py 1 May 2003 17:45:37 -0000 1.4
--- test_hexoct.py 29 Nov 2003 23:52:12 -0000 1.5
***************
*** 2,7 ****
This is complex because of changes due to PEP 237.
-
- Some of these tests will have to change in Python 2.4!
"""
--- 2,5 ----
***************
*** 42,70 ****
def test_hex_unsigned(self):
- # This test is in a <string> so we can ignore the warnings
- exec """if 1:
if platform_long_is_32_bits:
! # Positive-looking constants with negavive values
! self.assertEqual(0x80000000, -2147483648L)
! self.assertEqual(0xffffffff, -1)
# Ditto with a minus sign and parentheses
! self.assertEqual(-(0x80000000), 2147483648L)
! self.assertEqual(-(0xffffffff), 1)
# Ditto with a minus sign and NO parentheses
# This failed in Python 2.2 through 2.2.2 and in 2.3a1
! self.assertEqual(-0x80000000, 2147483648L)
! self.assertEqual(-0xffffffff, 1)
else:
! # Positive-looking constants with negavive values
! self.assertEqual(0x8000000000000000, -9223372036854775808L)
! self.assertEqual(0xffffffffffffffff, -1)
# Ditto with a minus sign and parentheses
! self.assertEqual(-(0x8000000000000000), 9223372036854775808L)
! self.assertEqual(-(0xffffffffffffffff), 1)
# Ditto with a minus sign and NO parentheses
# This failed in Python 2.2 through 2.2.2 and in 2.3a1
! self.assertEqual(-0x8000000000000000, 9223372036854775808L)
! self.assertEqual(-0xffffffffffffffff, 1)
! \n"""
def test_oct_baseline(self):
--- 40,65 ----
def test_hex_unsigned(self):
if platform_long_is_32_bits:
! # Positive constants
! self.assertEqual(0x80000000, 2147483648L)
! self.assertEqual(0xffffffff, 4294967295L)
# Ditto with a minus sign and parentheses
! self.assertEqual(-(0x80000000), -2147483648L)
! self.assertEqual(-(0xffffffff), -4294967295L)
# Ditto with a minus sign and NO parentheses
# This failed in Python 2.2 through 2.2.2 and in 2.3a1
! self.assertEqual(-0x80000000, -2147483648L)
! self.assertEqual(-0xffffffff, -4294967295L)
else:
! # Positive constants
! self.assertEqual(0x8000000000000000, 9223372036854775808L)
! self.assertEqual(0xffffffffffffffff, 18446744073709551615L)
# Ditto with a minus sign and parentheses
! self.assertEqual(-(0x8000000000000000), -9223372036854775808L)
! self.assertEqual(-(0xffffffffffffffff), -18446744073709551615L)
# Ditto with a minus sign and NO parentheses
# This failed in Python 2.2 through 2.2.2 and in 2.3a1
! self.assertEqual(-0x8000000000000000, -9223372036854775808L)
! self.assertEqual(-0xffffffffffffffff, -18446744073709551615L)
def test_oct_baseline(self):
***************
*** 92,120 ****
def test_oct_unsigned(self):
- # This test is in a <string> so we can ignore the warnings
- exec """if 1:
if platform_long_is_32_bits:
! # Positive-looking constants with negavive values
! self.assertEqual(020000000000, -2147483648L)
! self.assertEqual(037777777777, -1)
# Ditto with a minus sign and parentheses
! self.assertEqual(-(020000000000), 2147483648L)
! self.assertEqual(-(037777777777), 1)
# Ditto with a minus sign and NO parentheses
# This failed in Python 2.2 through 2.2.2 and in 2.3a1
! self.assertEqual(-020000000000, 2147483648L)
! self.assertEqual(-037777777777, 1)
else:
! # Positive-looking constants with negavive values
! self.assertEqual(01000000000000000000000, -9223372036854775808L)
! self.assertEqual(01777777777777777777777, -1)
# Ditto with a minus sign and parentheses
! self.assertEqual(-(01000000000000000000000), 9223372036854775808L)
! self.assertEqual(-(01777777777777777777777), 1)
# Ditto with a minus sign and NO parentheses
# This failed in Python 2.2 through 2.2.2 and in 2.3a1
! self.assertEqual(-01000000000000000000000, 9223372036854775808L)
! self.assertEqual(-01777777777777777777777, 1)
! \n"""
def test_main():
--- 87,112 ----
def test_oct_unsigned(self):
if platform_long_is_32_bits:
! # Positive constants
! self.assertEqual(020000000000, 2147483648L)
! self.assertEqual(037777777777, 4294967295L)
# Ditto with a minus sign and parentheses
! self.assertEqual(-(020000000000), -2147483648L)
! self.assertEqual(-(037777777777), -4294967295L)
# Ditto with a minus sign and NO parentheses
# This failed in Python 2.2 through 2.2.2 and in 2.3a1
! self.assertEqual(-020000000000, -2147483648L)
! self.assertEqual(-037777777777, -4294967295L)
else:
! # Positive constants
! self.assertEqual(01000000000000000000000, 9223372036854775808L)
! self.assertEqual(01777777777777777777777, 18446744073709551615L)
# Ditto with a minus sign and parentheses
! self.assertEqual(-(01000000000000000000000), -9223372036854775808L)
! self.assertEqual(-(01777777777777777777777), -18446744073709551615L)
# Ditto with a minus sign and NO parentheses
# This failed in Python 2.2 through 2.2.2 and in 2.3a1
! self.assertEqual(-01000000000000000000000, -9223372036854775808L)
! self.assertEqual(-01777777777777777777777, -18446744073709551615L)
def test_main():