@@ -65,3 +65,47 @@ def expect_error(s):
6565expect_error ("2.0e+" )
6666expect_error ("1e-" )
6767expect_error ("3-4e/21" )
68+
69+
70+ if verbose :
71+ print "testing literals with leading zeroes"
72+
73+ def expect_same (test_source , expected ):
74+ got = eval (test_source )
75+ if got != expected :
76+ raise TestFailed ("eval(%r) gave %r, but expected %r" %
77+ (test_source , got , expected ))
78+
79+ expect_error ("077787" )
80+ expect_error ("0xj" )
81+ expect_error ("0x." )
82+ expect_error ("0e" )
83+ expect_same ("0777" , 511 )
84+ expect_same ("0777L" , 511 )
85+ expect_same ("000777" , 511 )
86+ expect_same ("0xff" , 255 )
87+ expect_same ("0xffL" , 255 )
88+ expect_same ("0XfF" , 255 )
89+ expect_same ("0777." , 777 )
90+ expect_same ("0777.0" , 777 )
91+ expect_same ("000000000000000000000000000000000000000000000000000777e0" , 777 )
92+ expect_same ("0777e1" , 7770 )
93+ expect_same ("0e0" , 0 )
94+ expect_same ("0000E-012" , 0 )
95+ expect_same ("09.5" , 9.5 )
96+ expect_same ("0777j" , 777j )
97+ expect_same ("00j" , 0j )
98+ expect_same ("00.0" , 0 )
99+ expect_same ("0e3" , 0 )
100+ expect_same ("090000000000000." , 90000000000000. )
101+ expect_same ("090000000000000.0000000000000000000000" , 90000000000000. )
102+ expect_same ("090000000000000e0" , 90000000000000. )
103+ expect_same ("090000000000000e-0" , 90000000000000. )
104+ expect_same ("090000000000000j" , 90000000000000j )
105+ expect_error ("090000000000000" ) # plain octal literal w/ decimal digit
106+ expect_error ("080000000000000" ) # plain octal literal w/ decimal digit
107+ expect_error ("000000000000009" ) # plain octal literal w/ decimal digit
108+ expect_error ("000000000000008" ) # plain octal literal w/ decimal digit
109+ expect_same ("000000000000007" , 7 )
110+ expect_same ("000000000000008." , 8. )
111+ expect_same ("000000000000009." , 9. )
0 commit comments