summaryrefslogtreecommitdiff
path: root/Lib
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2015-04-02 18:49:14 +0300
committerSerhiy Storchaka <storchaka@gmail.com>2015-04-02 18:49:14 +0300
commit4c7dc48ea579164e98c9a399711b4bb1c67d70eb (patch)
tree8b76d73f5bc00ab0506db32414f5110eb599cd99 /Lib
parentea534f79a5cb388d96393f98882d724affdd29b9 (diff)
parentea134da9297b14bfa8dbf3a45149bc2df28c1eb9 (diff)
downloadcpython-git-4c7dc48ea579164e98c9a399711b4bb1c67d70eb.tar.gz
Issue #16840: Tkinter now supports 64-bit integers added in Tcl 8.4 and
arbitrary precision integers added in Tcl 8.5.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_tcl.py44
1 files changed, 37 insertions, 7 deletions
diff --git a/Lib/test/test_tcl.py b/Lib/test/test_tcl.py
index 1e6ac663f9..03f28d4d3e 100644
--- a/Lib/test/test_tcl.py
+++ b/Lib/test/test_tcl.py
@@ -133,9 +133,20 @@ class TclTest(unittest.TestCase):
tcl = self.interp
self.assertRaises(TclError,tcl.unsetvar,'a')
+ def get_integers(self):
+ integers = (0, 1, -1, 2**31-1, -2**31, 2**31, -2**31-1, 2**63-1, -2**63)
+ if tcl_version >= (8, 5): # bignum was added in Tcl 8.5
+ integers += (2**63, -2**63-1, 2**1000, -2**1000)
+ return integers
+
def test_getint(self):
tcl = self.interp.tk
- self.assertEqual(tcl.getint(' 42 '), 42)
+ for i in self.get_integers():
+ self.assertEqual(tcl.getint(' %d ' % i), i)
+ self.assertEqual(tcl.getint(' %#o ' % i), i)
+ self.assertEqual(tcl.getint(' %#x ' % i), i)
+ if tcl_version < (8, 5): # bignum was added in Tcl 8.5
+ self.assertRaises(TclError, tcl.getint, str(2**1000))
self.assertEqual(tcl.getint(42), 42)
self.assertRaises(TypeError, tcl.getint)
self.assertRaises(TypeError, tcl.getint, '42', '10')
@@ -270,7 +281,7 @@ class TclTest(unittest.TestCase):
check('"a\xbd\u20ac"', 'a\xbd\u20ac')
check(r'"a\xbd\u20ac"', 'a\xbd\u20ac')
check(r'"a\0b"', 'a\x00b')
- if tcl_version >= (8, 5):
+ if tcl_version >= (8, 5): # bignum was added in Tcl 8.5
check('2**64', str(2**64))
def test_exprdouble(self):
@@ -302,7 +313,7 @@ class TclTest(unittest.TestCase):
check('[string length "a\xbd\u20ac"]', 3.0)
check(r'[string length "a\xbd\u20ac"]', 3.0)
self.assertRaises(TclError, tcl.exprdouble, '"abc"')
- if tcl_version >= (8, 5):
+ if tcl_version >= (8, 5): # bignum was added in Tcl 8.5
check('2**64', float(2**64))
def test_exprlong(self):
@@ -334,7 +345,7 @@ class TclTest(unittest.TestCase):
check('[string length "a\xbd\u20ac"]', 3)
check(r'[string length "a\xbd\u20ac"]', 3)
self.assertRaises(TclError, tcl.exprlong, '"abc"')
- if tcl_version >= (8, 5):
+ if tcl_version >= (8, 5): # bignum was added in Tcl 8.5
self.assertRaises(TclError, tcl.exprlong, '2**64')
def test_exprboolean(self):
@@ -375,7 +386,7 @@ class TclTest(unittest.TestCase):
check('[string length "a\xbd\u20ac"]', True)
check(r'[string length "a\xbd\u20ac"]', True)
self.assertRaises(TclError, tcl.exprboolean, '"abc"')
- if tcl_version >= (8, 5):
+ if tcl_version >= (8, 5): # bignum was added in Tcl 8.5
check('2**64', True)
def test_booleans(self):
@@ -397,6 +408,21 @@ class TclTest(unittest.TestCase):
check('1 < 2', True)
check('1 > 2', False)
+ def test_expr_bignum(self):
+ tcl = self.interp
+ for i in self.get_integers():
+ result = tcl.call('expr', str(i))
+ if self.wantobjects:
+ self.assertEqual(result, i)
+ self.assertIsInstance(result, int)
+ else:
+ self.assertEqual(result, str(i))
+ self.assertIsInstance(result, str)
+ if tcl_version < (8, 5): # bignum was added in Tcl 8.5
+ result = tcl.call('expr', str(2**1000))
+ self.assertEqual(result, str(2**1000))
+ self.assertIsInstance(result, str)
+
def test_passing_values(self):
def passValue(value):
return self.interp.call('set', '_', value)
@@ -414,8 +440,10 @@ class TclTest(unittest.TestCase):
b'str\xc0\x80ing' if self.wantobjects else 'str\xc0\x80ing')
self.assertEqual(passValue(b'str\xbding'),
b'str\xbding' if self.wantobjects else 'str\xbding')
- for i in (0, 1, -1, 2**31-1, -2**31):
+ for i in self.get_integers():
self.assertEqual(passValue(i), i if self.wantobjects else str(i))
+ if tcl_version < (8, 5): # bignum was added in Tcl 8.5
+ self.assertEqual(passValue(2**1000), str(2**1000))
for f in (0.0, 1.0, -1.0, 1/3,
sys.float_info.min, sys.float_info.max,
-sys.float_info.min, -sys.float_info.max):
@@ -475,8 +503,10 @@ class TclTest(unittest.TestCase):
check(b'str\x00ing', 'str\x00ing')
check(b'str\xc0\x80ing', 'str\xc0\x80ing')
check(b'str\xc0\x80ing\xe2\x82\xac', 'str\xc0\x80ing\xe2\x82\xac')
- for i in (0, 1, -1, 2**31-1, -2**31):
+ for i in self.get_integers():
check(i, str(i))
+ if tcl_version < (8, 5): # bignum was added in Tcl 8.5
+ check(2**1000, str(2**1000))
for f in (0.0, 1.0, -1.0):
check(f, repr(f))
for f in (1/3.0, sys.float_info.min, sys.float_info.max,