summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_grammar.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1993-12-29 15:33:08 (GMT)
committerGuido van Rossum <guido@python.org>1993-12-29 15:33:08 (GMT)
commitdd8cb446e19cb24131227bd66aa690b34e64a75a (patch)
tree7e944159562f197b8288ae0dacc78343db173d0f /Lib/test/test_grammar.py
parent424e4da9f38fe8281cae370936ff266bcbeb0804 (diff)
downloadcpython-dd8cb446e19cb24131227bd66aa690b34e64a75a.zip
cpython-dd8cb446e19cb24131227bd66aa690b34e64a75a.tar.gz
cpython-dd8cb446e19cb24131227bd66aa690b34e64a75a.tar.bz2
Some minute changes.
Diffstat (limited to 'Lib/test/test_grammar.py')
-rw-r--r--Lib/test/test_grammar.py24
1 files changed, 21 insertions, 3 deletions
diff --git a/Lib/test/test_grammar.py b/Lib/test/test_grammar.py
index 742477f..0988574 100644
--- a/Lib/test/test_grammar.py
+++ b/Lib/test/test_grammar.py
@@ -23,9 +23,12 @@ print '1.1.2 Numeric literals'
print '1.1.2.1 Plain integers'
if 0xff <> 255: raise TestFailed, 'hex int'
if 0377 <> 255: raise TestFailed, 'octal int'
-if 2147483647 != 017777777777: raise TestFailed, 'max positive int'
-# Change the following line to "if 0:" if you have 64-bit integers
-if 1:
+if 2147483647 != 017777777777: raise TestFailed, 'large positive int'
+try:
+ from sys import maxint
+except ImportError:
+ maxint = 2147483647
+if maxint == 2147483647:
if -2147483647-1 != 020000000000: raise TestFailed, 'max negative int'
# XXX -2147483648
if 037777777777 != -1: raise TestFailed, 'oct -1'
@@ -37,6 +40,21 @@ if 1:
continue
raise TestFailed, \
'No 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':
+ try:
+ x = eval(s)
+ except OverflowError:
+ continue
+ raise TestFailed, \
+ 'No OverflowError on huge integer literal ' + `s`
+else:
+ print 'Weird maxint value', maxint
print '1.1.2.2 Long integers'
x = 0L