@@ -143,27 +143,18 @@ def testUnsetVarException(self):
143143 self .assertRaises (TclError ,tcl .unsetvar ,'a' )
144144
145145 def get_integers (self ):
146- integers = (0 , 1 , - 1 , 2 ** 31 - 1 , - 2 ** 31 , 2 ** 31 , - 2 ** 31 - 1 , 2 ** 63 - 1 , - 2 ** 63 )
147- # bignum was added in Tcl 8.5, but its support is able only since 8.5.8.
148- # Actually it is determined at compile time, so using get_tk_patchlevel()
149- # is not reliable.
150- # TODO: expose full static version.
151- if tcl_version >= (8 , 5 ):
152- v = get_tk_patchlevel ()
153- if v >= (8 , 6 , 0 , 'final' ) or (8 , 5 , 8 ) <= v < (8 , 6 ):
154- integers += (2 ** 63 , - 2 ** 63 - 1 , 2 ** 1000 , - 2 ** 1000 )
155- return integers
146+ return (0 , 1 , - 1 ,
147+ 2 ** 31 - 1 , - 2 ** 31 , 2 ** 31 , - 2 ** 31 - 1 ,
148+ 2 ** 63 - 1 , - 2 ** 63 , 2 ** 63 , - 2 ** 63 - 1 ,
149+ 2 ** 1000 , - 2 ** 1000 )
156150
157151 def test_getint (self ):
158152 tcl = self .interp .tk
159153 for i in self .get_integers ():
160154 self .assertEqual (tcl .getint (' %d ' % i ), i )
161- if tcl_version >= (8 , 5 ):
162- self .assertEqual (tcl .getint (' %#o ' % i ), i )
155+ self .assertEqual (tcl .getint (' %#o ' % i ), i )
163156 self .assertEqual (tcl .getint ((' %#o ' % i ).replace ('o' , '' )), i )
164157 self .assertEqual (tcl .getint (' %#x ' % i ), i )
165- if tcl_version < (8 , 5 ): # bignum was added in Tcl 8.5
166- self .assertRaises (TclError , tcl .getint , str (2 ** 1000 ))
167158 self .assertEqual (tcl .getint (42 ), 42 )
168159 self .assertRaises (TypeError , tcl .getint )
169160 self .assertRaises (TypeError , tcl .getint , '42' , '10' )
@@ -317,8 +308,7 @@ def check(expr, expected):
317308 check ('"a\xbd \u20ac "' , 'a\xbd \u20ac ' )
318309 check (r'"a\xbd\u20ac"' , 'a\xbd \u20ac ' )
319310 check (r'"a\0b"' , 'a\x00 b' )
320- if tcl_version >= (8 , 5 ): # bignum was added in Tcl 8.5
321- check ('2**64' , str (2 ** 64 ))
311+ check ('2**64' , str (2 ** 64 ))
322312
323313 def test_exprdouble (self ):
324314 tcl = self .interp
@@ -349,8 +339,7 @@ def check(expr, expected):
349339 check ('[string length "a\xbd \u20ac "]' , 3.0 )
350340 check (r'[string length "a\xbd\u20ac"]' , 3.0 )
351341 self .assertRaises (TclError , tcl .exprdouble , '"abc"' )
352- if tcl_version >= (8 , 5 ): # bignum was added in Tcl 8.5
353- check ('2**64' , float (2 ** 64 ))
342+ check ('2**64' , float (2 ** 64 ))
354343
355344 def test_exprlong (self ):
356345 tcl = self .interp
@@ -381,8 +370,7 @@ def check(expr, expected):
381370 check ('[string length "a\xbd \u20ac "]' , 3 )
382371 check (r'[string length "a\xbd\u20ac"]' , 3 )
383372 self .assertRaises (TclError , tcl .exprlong , '"abc"' )
384- if tcl_version >= (8 , 5 ): # bignum was added in Tcl 8.5
385- self .assertRaises (TclError , tcl .exprlong , '2**64' )
373+ self .assertRaises (TclError , tcl .exprlong , '2**64' )
386374
387375 def test_exprboolean (self ):
388376 tcl = self .interp
@@ -422,10 +410,8 @@ def check(expr, expected):
422410 check ('[string length "a\xbd \u20ac "]' , True )
423411 check (r'[string length "a\xbd\u20ac"]' , True )
424412 self .assertRaises (TclError , tcl .exprboolean , '"abc"' )
425- if tcl_version >= (8 , 5 ): # bignum was added in Tcl 8.5
426- check ('2**64' , True )
413+ check ('2**64' , True )
427414
428- @unittest .skipUnless (tcl_version >= (8 , 5 ), 'requires Tcl version >= 8.5' )
429415 def test_booleans (self ):
430416 tcl = self .interp
431417 def check (expr , expected ):
@@ -455,8 +441,6 @@ def test_expr_bignum(self):
455441 else :
456442 self .assertEqual (result , str (i ))
457443 self .assertIsInstance (result , str )
458- if get_tk_patchlevel () < (8 , 5 ): # bignum was added in Tcl 8.5
459- self .assertRaises (TclError , tcl .call , 'expr' , str (2 ** 1000 ))
460444
461445 def test_passing_values (self ):
462446 def passValue (value ):
@@ -485,8 +469,6 @@ def passValue(value):
485469 b'str\xbd ing' if self .wantobjects else 'str\xbd ing' )
486470 for i in self .get_integers ():
487471 self .assertEqual (passValue (i ), i if self .wantobjects else str (i ))
488- if tcl_version < (8 , 5 ): # bignum was added in Tcl 8.5
489- self .assertEqual (passValue (2 ** 1000 ), str (2 ** 1000 ))
490472 for f in (0.0 , 1.0 , - 1.0 , 1 / 3 ,
491473 sys .float_info .min , sys .float_info .max ,
492474 - sys .float_info .min , - sys .float_info .max ):
@@ -552,8 +534,6 @@ def float_eq(actual, expected):
552534 check (b'str\xc0 \x80 ing\xe2 \x82 \xac ' , 'str\xc0 \x80 ing\xe2 \x82 \xac ' )
553535 for i in self .get_integers ():
554536 check (i , str (i ))
555- if tcl_version < (8 , 5 ): # bignum was added in Tcl 8.5
556- check (2 ** 1000 , str (2 ** 1000 ))
557537 for f in (0.0 , 1.0 , - 1.0 ):
558538 check (f , repr (f ))
559539 for f in (1 / 3.0 , sys .float_info .min , sys .float_info .max ,
@@ -600,16 +580,14 @@ def test_splitlist(self):
600580 ('1' , '2' , '3.4' )),
601581 ]
602582 tk_patchlevel = get_tk_patchlevel ()
603- if tcl_version >= (8 , 5 ):
604- if not self .wantobjects or tk_patchlevel < (8 , 5 , 5 ):
605- # Before 8.5.5 dicts were converted to lists through string
606- expected = ('12' , '\u20ac ' , '\xe2 \x82 \xac ' , '3.4' )
607- else :
608- expected = (12 , '\u20ac ' , b'\xe2 \x82 \xac ' , (3.4 ,))
609- testcases += [
610- (call ('dict' , 'create' , 12 , '\u20ac ' , b'\xe2 \x82 \xac ' , (3.4 ,)),
611- expected ),
612- ]
583+ if not self .wantobjects :
584+ expected = ('12' , '\u20ac ' , '\xe2 \x82 \xac ' , '3.4' )
585+ else :
586+ expected = (12 , '\u20ac ' , b'\xe2 \x82 \xac ' , (3.4 ,))
587+ testcases += [
588+ (call ('dict' , 'create' , 12 , '\u20ac ' , b'\xe2 \x82 \xac ' , (3.4 ,)),
589+ expected ),
590+ ]
613591 dbg_info = ('want objects? %s, Tcl version: %s, Tk patchlevel: %s'
614592 % (self .wantobjects , tcl_version , tk_patchlevel ))
615593 for arg , res in testcases :
@@ -642,15 +620,13 @@ def test_splitdict(self):
642620 {'a' : (1 , 2 , 3 ) if self .wantobjects else '1 2 3' ,
643621 'something' : 'foo' , 'status' : '' })
644622
645- if tcl_version >= (8 , 5 ):
646- arg = tcl .call ('dict' , 'create' ,
647- '-a' , (1 , 2 , 3 ), '-something' , 'foo' , 'status' , ())
648- if not self .wantobjects or get_tk_patchlevel () < (8 , 5 , 5 ):
649- # Before 8.5.5 dicts were converted to lists through string
650- expected = {'a' : '1 2 3' , 'something' : 'foo' , 'status' : '' }
651- else :
652- expected = {'a' : (1 , 2 , 3 ), 'something' : 'foo' , 'status' : '' }
653- self .assertEqual (splitdict (tcl , arg ), expected )
623+ arg = tcl .call ('dict' , 'create' ,
624+ '-a' , (1 , 2 , 3 ), '-something' , 'foo' , 'status' , ())
625+ if not self .wantobjects :
626+ expected = {'a' : '1 2 3' , 'something' : 'foo' , 'status' : '' }
627+ else :
628+ expected = {'a' : (1 , 2 , 3 ), 'something' : 'foo' , 'status' : '' }
629+ self .assertEqual (splitdict (tcl , arg ), expected )
654630
655631 def test_join (self ):
656632 join = tkinter ._join
0 commit comments