| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -133,9 +133,20 @@ def testUnsetVarException(self): | |||
| 133 | 133 | tcl = self.interp | |
| 134 | 134 | self.assertRaises(TclError,tcl.unsetvar,'a') | |
| 135 | 135 | ||
| 136 | + def get_integers(self): | ||
| 137 | + integers = (0, 1, -1, 2**31-1, -2**31, 2**31, -2**31-1, 2**63-1, -2**63) | ||
| 138 | + if tcl_version >= (8, 5): # bignum was added in Tcl 8.5 | ||
| 139 | + integers += (2**63, -2**63-1, 2**1000, -2**1000) | ||
| 140 | + return integers | ||
| 141 | + | ||
| 136 | 142 | def test_getint(self): | |
| 137 | 143 | tcl = self.interp.tk | |
| 138 | - self.assertEqual(tcl.getint(' 42 '), 42) | ||
| 144 | + for i in self.get_integers(): | ||
| 145 | + self.assertEqual(tcl.getint(' %d ' % i), i) | ||
| 146 | + self.assertEqual(tcl.getint(' %#o ' % i), i) | ||
| 147 | + self.assertEqual(tcl.getint(' %#x ' % i), i) | ||
| 148 | + if tcl_version < (8, 5): # bignum was added in Tcl 8.5 | ||
| 149 | + self.assertRaises(TclError, tcl.getint, str(2**1000)) | ||
| 139 | 150 | self.assertEqual(tcl.getint(42), 42) | |
| 140 | 151 | self.assertRaises(TypeError, tcl.getint) | |
| 141 | 152 | self.assertRaises(TypeError, tcl.getint, '42', '10') | |
@@ -270,7 +281,7 @@ def check(expr, expected): | |||
| 270 | 281 | check('"a\xbd\u20ac"', 'a\xbd\u20ac') | |
| 271 | 282 | check(r'"a\xbd\u20ac"', 'a\xbd\u20ac') | |
| 272 | 283 | check(r'"a\0b"', 'a\x00b') | |
| 273 | - if tcl_version >= (8, 5): | ||
| 284 | + if tcl_version >= (8, 5): # bignum was added in Tcl 8.5 | ||
| 274 | 285 | check('2**64', str(2**64)) | |
| 275 | 286 | ||
| 276 | 287 | def test_exprdouble(self): | |
@@ -302,7 +313,7 @@ def check(expr, expected): | |||
| 302 | 313 | check('[string length "a\xbd\u20ac"]', 3.0) | |
| 303 | 314 | check(r'[string length "a\xbd\u20ac"]', 3.0) | |
| 304 | 315 | self.assertRaises(TclError, tcl.exprdouble, '"abc"') | |
| 305 | - if tcl_version >= (8, 5): | ||
| 316 | + if tcl_version >= (8, 5): # bignum was added in Tcl 8.5 | ||
| 306 | 317 | check('2**64', float(2**64)) | |
| 307 | 318 | ||
| 308 | 319 | def test_exprlong(self): | |
@@ -334,7 +345,7 @@ def check(expr, expected): | |||
| 334 | 345 | check('[string length "a\xbd\u20ac"]', 3) | |
| 335 | 346 | check(r'[string length "a\xbd\u20ac"]', 3) | |
| 336 | 347 | self.assertRaises(TclError, tcl.exprlong, '"abc"') | |
| 337 | - if tcl_version >= (8, 5): | ||
| 348 | + if tcl_version >= (8, 5): # bignum was added in Tcl 8.5 | ||
| 338 | 349 | self.assertRaises(TclError, tcl.exprlong, '2**64') | |
| 339 | 350 | ||
| 340 | 351 | def test_exprboolean(self): | |
@@ -375,7 +386,7 @@ def check(expr, expected): | |||
| 375 | 386 | check('[string length "a\xbd\u20ac"]', True) | |
| 376 | 387 | check(r'[string length "a\xbd\u20ac"]', True) | |
| 377 | 388 | self.assertRaises(TclError, tcl.exprboolean, '"abc"') | |
| 378 | - if tcl_version >= (8, 5): | ||
| 389 | + if tcl_version >= (8, 5): # bignum was added in Tcl 8.5 | ||
| 379 | 390 | check('2**64', True) | |
| 380 | 391 | ||
| 381 | 392 | def test_booleans(self): | |
@@ -397,6 +408,21 @@ def check(expr, expected): | |||
| 397 | 408 | check('1 < 2', True) | |
| 398 | 409 | check('1 > 2', False) | |
| 399 | 410 | ||
| 411 | + def test_expr_bignum(self): | ||
| 412 | + tcl = self.interp | ||
| 413 | + for i in self.get_integers(): | ||
| 414 | + result = tcl.call('expr', str(i)) | ||
| 415 | + if self.wantobjects: | ||
| 416 | + self.assertEqual(result, i) | ||
| 417 | + self.assertIsInstance(result, int) | ||
| 418 | + else: | ||
| 419 | + self.assertEqual(result, str(i)) | ||
| 420 | + self.assertIsInstance(result, str) | ||
| 421 | + if tcl_version < (8, 5): # bignum was added in Tcl 8.5 | ||
| 422 | + result = tcl.call('expr', str(2**1000)) | ||
| 423 | + self.assertEqual(result, str(2**1000)) | ||
| 424 | + self.assertIsInstance(result, str) | ||
| 425 | + | ||
| 400 | 426 | def test_passing_values(self): | |
| 401 | 427 | def passValue(value): | |
| 402 | 428 | return self.interp.call('set', '_', value) | |
@@ -414,8 +440,10 @@ def passValue(value): | |||
| 414 | 440 | b'str\xc0\x80ing' if self.wantobjects else 'str\xc0\x80ing') | |
| 415 | 441 | self.assertEqual(passValue(b'str\xbding'), | |
| 416 | 442 | b'str\xbding' if self.wantobjects else 'str\xbding') | |
| 417 | - for i in (0, 1, -1, 2**31-1, -2**31): | ||
| 443 | + for i in self.get_integers(): | ||
| 418 | 444 | self.assertEqual(passValue(i), i if self.wantobjects else str(i)) | |
| 445 | + if tcl_version < (8, 5): # bignum was added in Tcl 8.5 | ||
| 446 | + self.assertEqual(passValue(2**1000), str(2**1000)) | ||
| 419 | 447 | for f in (0.0, 1.0, -1.0, 1/3, | |
| 420 | 448 | sys.float_info.min, sys.float_info.max, | |
| 421 | 449 | -sys.float_info.min, -sys.float_info.max): | |
@@ -475,8 +503,10 @@ def float_eq(actual, expected): | |||
| 475 | 503 | check(b'str\x00ing', 'str\x00ing') | |
| 476 | 504 | check(b'str\xc0\x80ing', 'str\xc0\x80ing') | |
| 477 | 505 | check(b'str\xc0\x80ing\xe2\x82\xac', 'str\xc0\x80ing\xe2\x82\xac') | |
| 478 | - for i in (0, 1, -1, 2**31-1, -2**31): | ||
| 506 | + for i in self.get_integers(): | ||
| 479 | 507 | check(i, str(i)) | |
| 508 | + if tcl_version < (8, 5): # bignum was added in Tcl 8.5 | ||
| 509 | + check(2**1000, str(2**1000)) | ||
| 480 | 510 | for f in (0.0, 1.0, -1.0): | |
| 481 | 511 | check(f, repr(f)) | |
| 482 | 512 | for f in (1/3.0, sys.float_info.min, sys.float_info.max, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -16,6 +16,9 @@ Core and Builtins | |||
| 16 | 16 | Library | |
| 17 | 17 | ------- | |
| 18 | 18 | ||
| 19 | + - Issue #16840: Tkinter now supports 64-bit integers added in Tcl 8.4 and | ||
| 20 | + arbitrary precision integers added in Tcl 8.5. | ||
| 21 | + | ||
| 19 | 22 | - Issue #23834: Fix socket.sendto(), use the C Py_ssize_t type to store the | |
| 20 | 23 | result of sendto() instead of the C int type. | |
| 21 | 24 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments